static int32 _rtl865x_delPpp(uint32 sessionId) { int i; rtl865x_ppp_t *entry = NULL; rtl865x_tblAsicDrv_pppoeParam_t asicppp; int32 retval = FAILED; uint32 fid; /*found the entry*/ for(i = 0; i < PPP_NUMBER; i++) { if(rtl865x_pppTable[i].valid == 1 && rtl865x_pppTable[i].sessionId== sessionId) { entry = &rtl865x_pppTable[i]; break; } } if (entry==NULL) return SUCCESS; /*check reference count*/ if(entry->refCnt > 1) { printk("Please del other table entry which referenced me...ppp sessionId(%d)\n",sessionId); return RTL_EREFERENCEDBYOTHER; } /*del asic ppp table*/ asicppp.age = 0; asicppp.sessionId = 0; rtl8651_setAsicPppoe(PPP_TABLE_INDEX(entry), &asicppp); /*FIXME_hyking:dereference netif & mac*/ retval = rtl865x_deReferNetif(entry->netif->name); retval = rtl865x_getVlanFilterDatabaseId(entry->netif->vid, &fid); retval = rtl865x_delFilterDatabaseEntry(RTL865x_L2_TYPEII, fid, &entry->server_mac); /*raise event??*/ rtl865x_raiseEvent(EVENT_DEL_PPP,(void *)entry); memset(entry,0,sizeof(rtl865x_ppp_t)); return SUCCESS; }
static int32 _rtl865x_synNxtHop_by_arp_entry(rtl865x_nextHopEntry_t *entry_t,rtl865x_arpMapping_entry_t *arp) { rtl865x_tblAsicDrv_nextHopParam_t asic; ether_addr_t reservedMac; ether_addr_t zero_mac ={{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; rtl865x_tblAsicDrv_l2Param_t asic_l2; rtl865x_netif_local_t *dstNetif; uint32 fid = 0; uint32 columIdx = 0; int32 retval = 0; int32 ipIdx = 0; retval = rtl865x_getReserveMacAddr(&reservedMac); bzero(&asic, sizeof(rtl865x_tblAsicDrv_nextHopParam_t)); if(entry_t == NULL || arp == NULL) { return RTL_EINVALIDINPUT; } if (entry_t->nextHopType == IF_ETHER) { int mac_valid = 0; mac_valid = memcmp(arp->mac.octet,zero_mac.octet,ETHER_ADDR_LEN); rtl865x_getVlanFilterDatabaseId(entry_t->dstNetif->vid,&fid); retval = rtl865x_Lookup_fdb_entry(fid, (mac_valid)? &arp->mac : &reservedMac, FDB_DYNAMIC, &columIdx,&asic_l2); asic.nextHopRow = rtl8651_filterDbIndex( (mac_valid)? &arp->mac : &reservedMac, fid ); asic.nextHopColumn = (retval == SUCCESS)? columIdx: 0; asic.isPppoe = FALSE; asic.pppoeIdx = 0; } else { /*session based interface type*/ rtl865x_ppp_t pppoe; int32 pppidx = 0; memset(&pppoe,0,sizeof(rtl865x_ppp_t)); if(entry_t->nexthop) retval = rtl865x_getPppBySessionId(entry_t->nexthop,&pppoe); rtl865x_getVlanFilterDatabaseId(entry_t->dstNetif->vid,&fid); retval =rtl865x_Lookup_fdb_entry(fid, (pppoe.valid)? &pppoe.server_mac : &reservedMac, FDB_DYNAMIC, &columIdx,&asic_l2); asic.nextHopRow = rtl8651_filterDbIndex( (pppoe.valid)? &pppoe.server_mac : &reservedMac, fid); asic.nextHopColumn = (pppoe.valid)? columIdx: 0; asic.isPppoe = (pppoe.type == IF_PPPOE)? TRUE: FALSE; retval = rtl865x_getPppIdx(&pppoe, &pppidx); //printk("%s(%d): pppoeIdx(%d), pppoeType(%d), pppoevalid(%d),pppoeSid(%d)\n",__FUNCTION__,__LINE__,pppidx,pppoe.type,pppoe.valid,pppoe.sessionId); asic.pppoeIdx = (pppoe.type == IF_PPPOE)? pppidx: 0; } if(entry_t->dstNetif->is_slave == 1) { dstNetif = entry_t->dstNetif->master; if(dstNetif == NULL) dstNetif = _rtl865x_getDefaultWanNetif(); } else dstNetif = entry_t->dstNetif; if(dstNetif == NULL) printk("_%s(%d), BUG!!!!!!",__FUNCTION__,__LINE__); asic.dvid = dstNetif->asicIdx; if(entry_t->srcIp) retval = rtl865x_getIpIdxByExtIp(entry_t->srcIp, &ipIdx); asic.extIntIpIdx = entry_t->srcIp? ipIdx: 0; //printk("%s(%d), entryIdx(%d),asic.isPPPoe(%d),asic.pppoeIdx(%d),asic.dvid(%d)\n", __FUNCTION__,__LINE__,entry_t->entryIndex,asic.isPppoe,asic.pppoeIdx,asic.dvid); rtl8651_setAsicNextHopTable(entry_t->entryIndex, &asic); return SUCCESS; }
static int32 _rtl865x_synNxtHopToAsic(rtl865x_nextHopEntry_t *entry_t) { rtl865x_tblAsicDrv_nextHopParam_t asic; ether_addr_t reservedMac; rtl865x_tblAsicDrv_l2Param_t asic_l2; rtl865x_netif_local_t *dstNetif; uint32 fid = 0; uint32 columIdx = 0; int32 retval = 0; int32 ipIdx = 0; retval = rtl865x_getReserveMacAddr(&reservedMac); bzero(&asic, sizeof(rtl865x_tblAsicDrv_nextHopParam_t)); if(entry_t == NULL) { return RTL_EINVALIDINPUT; } if (entry_t->nextHopType == IF_ETHER) { rtl865x_arpMapping_entry_t arp_t; int32 ret_arpFound = FAILED; /*if the arp info of nexthop is not found, reserved to cpu Mac is used for trap packet to CPU*/ #if defined (CONFIG_RTL_LOCAL_PUBLIC) if(entry_t->nexthop) { ret_arpFound = rtl865x_getArpMapping(entry_t->nexthop,&arp_t); if(ret_arpFound!=SUCCESS) { /*try to match local pulbic ip*/ ret_arpFound = rtl865x_getLocalPublicArpMapping(entry_t->nexthop, &arp_t); } } #else if(entry_t->nexthop) ret_arpFound = rtl865x_getArpMapping(entry_t->nexthop,&arp_t); #endif rtl865x_getVlanFilterDatabaseId(entry_t->dstNetif->vid,&fid); retval = rtl865x_Lookup_fdb_entry(fid, (ret_arpFound == SUCCESS)? &arp_t.mac : &reservedMac, FDB_DYNAMIC, &columIdx,&asic_l2); asic.nextHopRow = rtl8651_filterDbIndex( (ret_arpFound == SUCCESS)? &arp_t.mac : &reservedMac, fid ); asic.nextHopColumn = (retval == SUCCESS)? columIdx: 0; asic.isPppoe = FALSE; asic.pppoeIdx = 0; } else { /*session based interface type*/ rtl865x_ppp_t pppoe; int32 pppidx = 0; memset(&pppoe,0,sizeof(rtl865x_ppp_t)); if(entry_t->nexthop) retval = rtl865x_getPppBySessionId(entry_t->nexthop,&pppoe); rtl865x_getVlanFilterDatabaseId(entry_t->dstNetif->vid,&fid); retval =rtl865x_Lookup_fdb_entry(fid, (pppoe.valid)? &pppoe.server_mac : &reservedMac, FDB_DYNAMIC, &columIdx,&asic_l2); asic.nextHopRow = rtl8651_filterDbIndex( (pppoe.valid)? &pppoe.server_mac : &reservedMac, fid); asic.nextHopColumn = (pppoe.valid)? columIdx: 0; asic.isPppoe = (pppoe.type == IF_PPPOE)? TRUE: FALSE; retval = rtl865x_getPppIdx(&pppoe, &pppidx); //printk("%s(%d): pppoeIdx(%d), pppoeType(%d), pppoevalid(%d),pppoeSid(%d)\n",__FUNCTION__,__LINE__,pppidx,pppoe.type,pppoe.valid,pppoe.sessionId); asic.pppoeIdx = (pppoe.type == IF_PPPOE)? pppidx: 0; } if(entry_t->dstNetif->is_slave == 1) { dstNetif = entry_t->dstNetif->master; if(dstNetif == NULL) dstNetif = _rtl865x_getDefaultWanNetif(); } else dstNetif = entry_t->dstNetif; if(dstNetif == NULL) printk("_%s(%d), BUG!!!!!!",__FUNCTION__,__LINE__); asic.dvid = dstNetif->asicIdx; if(entry_t->srcIp) retval = rtl865x_getIpIdxByExtIp(entry_t->srcIp, &ipIdx); asic.extIntIpIdx = entry_t->srcIp? ipIdx: 0; //printk("%s(%d), entryIdx(%d),asic.isPPPoe(%d),asic.pppoeIdx(%d),asic.dvid(%d)\n", __FUNCTION__,__LINE__,entry_t->entryIndex,asic.isPppoe,asic.pppoeIdx,asic.dvid); rtl8651_setAsicNextHopTable(entry_t->entryIndex, &asic); return SUCCESS; }
static int32 _rtl865x_addPpp(uint8 *ifname, ether_addr_t *mac, uint32 sessionId, int32 type) { int i; rtl865x_netif_local_t *netif; rtl865x_ppp_t *entry = NULL; rtl865x_tblAsicDrv_pppoeParam_t asicPpp; rtl865x_tblAsicDrv_l2Param_t fdbEntry; rtl865x_filterDbTableEntry_t l2temp_entry; uint32 fid,column; int32 retval; uint32 fdb_type[]={ FDB_STATIC, FDB_DYNAMIC }; /*printk("%s(%d): ifname(%s),mac(%02x:%02x:%02x:%02x:%02x:%02x),sid(%d),type(%d)",__FUNCTION__,__LINE__,ifname, mac->octet[0],mac->octet[1],mac->octet[2],mac->octet[3],mac->octet[4],mac->octet[5], sessionId,type);*/ /*duplicate check*/ for(i = 0; i < PPP_NUMBER; i++) { if(rtl865x_pppTable[i].valid && rtl865x_pppTable[i].sessionId == sessionId) return RTL_EENTRYALREADYEXIST; } netif = _rtl865x_getSWNetifByName(ifname); if(netif == NULL) return RTL_ENETIFINVALID; if(netif->if_type != IF_PPPOE) return RTL_ELINKTYPESHOULDBERESET; /*found a valid entry*/ for(i = 0; i < PPP_NUMBER; i++) if(rtl865x_pppTable[i].valid == 0) { entry = &rtl865x_pppTable[i]; break; } if(entry == NULL) return RTL_ENOFREEBUFFER; /*update releated information*/ entry->valid = 1; entry->netif = netif; memcpy(&entry->server_mac,mac,sizeof(ether_addr_t)); entry->sessionId = sessionId; entry->type = type; entry->refCnt = 1; /*add this ip entry to asic*/ /* Set asic */ bzero(&asicPpp, sizeof(rtl865x_tblAsicDrv_pppoeParam_t)); asicPpp.sessionId = sessionId; asicPpp.age = 300; rtl8651_setAsicPppoe(PPP_TABLE_INDEX(entry), &asicPpp); /*FIXME_hyking:reference netif & mac*/ retval = rtl865x_referNetif(netif->name); /*add fdb entry...*/ fid = 0; column = 0; retval = rtl865x_getVlanFilterDatabaseId(netif->vid,&fid); for(i = 0; i < 2; i++) { /* printk("%s:%d\n,fid(%d),mac(%02x:%02x:%02x:%02x:%02x:%02x)\n",__FUNCTION__,__LINE__,fid,mac->octet[0],mac->octet[1], mac->octet[2],mac->octet[3],mac->octet[4],mac->octet[5]); printk("%s:%d\n",__FUNCTION__,__LINE__); */ if(rtl865x_Lookup_fdb_entry(fid, mac, fdb_type[i], &column,&fdbEntry) != SUCCESS) { continue; } /*in case of layer2 auto learn, add hardware entry to layer 2 software table*/ l2temp_entry.l2type = (fdbEntry.nhFlag==0)?RTL865x_L2_TYPEI: RTL865x_L2_TYPEII; l2temp_entry.process = FDB_TYPE_FWD; l2temp_entry.memberPortMask = fdbEntry.memberPortMask; l2temp_entry.auth = fdbEntry.auth; l2temp_entry.SrcBlk = fdbEntry.srcBlk; memcpy(&(l2temp_entry.macAddr), mac, sizeof(ether_addr_t)); rtl865x_addFilterDatabaseEntryExtension(fid, &l2temp_entry); // retval = _rtl865x_addFilterDatabaseEntry((fdbEntry.nhFlag==0)?RTL865x_L2_TYPEI: RTL865x_L2_TYPEII, fid, mac, FDB_TYPE_FWD, fdbEntry.memberPortMask, fdbEntry.auth,fdbEntry.srcBlk); rtl865x_refleshHWL2Table(mac, FDB_DYNAMIC|FDB_STATIC,fid); } /*raise event??*/ rtl865x_raiseEvent(EVENT_ADD_PPP, (void*)entry); return SUCCESS; }