- mac老化机制 :硬件老化,删除硬件mac,通告上层软件
1.mac超时老化删除本地mac,保留mlag同步过来的mac
case MACSYN_MSG_RECVMACDEL:
ret = macSynLocalNotifier(&message);
if(message.pData != NULL)
netMblkClChainFree((M_BLK_ID)message.pData);
break;
/*本地网管和地址学习的处理函数*/
STATUS macSynLocalNotifier(tMacSynMsg *pMacSynMsg)
{
tPhyIfInfo phyinfo;
int32_t i =0, size = 0, msgType = 0, ret = OK;
tHwMacAddrEntry *pHwMac =NULL, macAddr;
M_BLK_ID pMblk = NULL;
size = sizeof(tHwMacAddrEntry);
pMblk = pMacSynMsg->pData;
msgType = pMacSynMsg->pktHead.msgType;
for(i=0; i<(pMacSynMsg->pktHead.dataLen/size); i++) /*解析所有mac地址表项, 对于静态表项来说,只有一条*/
{
if((msgType== MACSYN_MSG_RECVMACADD)||(msgType== MACSYN_MSG_RECVMACDEL))
{
if(pMblk->mBlkHdr.mLen < size)
{
pHwMac = &macAddr;
if(netMblkOffsetToBufCopy(pMblk, 0, (char *)pHwMac, size,(FUNCPTR) bcopy) < size)
{
macSynPrintf(MACSYN_DBG_ERR,("\r\n macSynLocalNotifier: Failed to copy entry %d.", i));
return ERROR;
}
pMblk = pMblk->mBlkHdr.mNext;
}
else
{
pHwMac = (tHwMacAddrEntry *)((char *)pMblk->mBlkHdr.mData);
pMblk->mBlkHdr.mLen -= size;
pMblk->mBlkHdr.mData += size;
}
}
else
pHwMac = &pMacSynMsg->pktHead.l2entry;
bzero((void *)&phyinfo, sizeof(tPhyIfInfo));
logical_to_phyical(&phyinfo, pHwMac->port[0]);
pHwMac->sys = phyinfo.unit;
if((pHwMac->mac[0] == 0x00)&&(pHwMac->mac[1] == 0x04)&&(pHwMac->mac[2] == 0x67))
gMacFhnLocal = 1;
if((gMacSynDebug & MACSYN_DBG_PKT)&&(gMacFhnLocal == 0))
macSynEntryPrint(pHwMac);
switch(pHwMac->keyType)
{
case HW_MACKEYTYPE_BRIDGE:
case HW_MACKEYTYPE_VP:
if((pHwMac->vlanId < 1)||(pHwMac->vlanId > 4094))
{
macSynPrintf(MACSYN_DBG_ERR,("\r\n macSynLocalNotifier: Bad vlan id %d.", pHwMac->vlanId));
if((msgType == MACSYN_MSG_RECVMACADD)||(msgType == MACSYN_MSG_RECVMACDEL))
gSysMacSynStatis.macLocalNotifyVidErr++;
continue;
}
break;
default:
break;
}
switch(msgType)
{
case MACSYN_MSG_RECVMACADD:
/*macSynPrintf(MACSYN_DBG_ADD,("\r\n macSynLocalNotifier,mac:0x%02x%02x%02x%02x%02x%02x.",pHwMac->mac[0],
pHwMac->mac[1],pHwMac->mac[2],pHwMac->mac[3],pHwMac->mac[4],pHwMac->mac[5]));*/
if(macSynMacLocalAdd(pHwMac) != OK)
break;
gSysMacSynStatis.macLocalAddSuccess++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEADD);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEADD);
break;
case MACSYN_MSG_RECVMACDEL:
if(macSynMacLocalDel(pHwMac) != OK)
break;
gSysMacSynStatis.macLocalDelSuccess++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
break;
case MACSYN_MSG_ADDL2FDB:
gSysMacSynStatis.macLocalL3AddCnt02++;
if(macSynMacLocalAdd(pHwMac) != OK)
return ERROR;
gSysMacSynStatis.macLocalStaticAdd++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEADD);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEADD);
break;
case MACSYN_MSG_DELL2FDB:
gSysMacSynStatis.macLocalL3DelCnt02++;
if(macSynMacLocalDel(pHwMac) != OK)
return ERROR;
gSysMacSynStatis.macLocalStaticDel++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
break;
default:
break;
}
gMacFhnLocal = 0;
}
return OK;
}
case MACSYN_MSG_RECVMACDEL:
if(macSynMacLocalDel(pHwMac) != OK)
break;
gSysMacSynStatis.macLocalDelSuccess++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
break;
STATUS macSynMacLocalDel(tHwMacAddrEntry *pHwMac)
{
tPhyIfInfo phyInfo;
uint8_t ifName[64] = {0};
int32_t ret = OK, value = USP_IF_ENABLE;
tMacSynVlan *pMacSynVlan = NULL;
tMacSynPort *pMacSynPort = NULL;
tMacSynFdbNode *pMacSyn = NULL, macEntry;
semTake(gSysMacSynInfo.semTree, WAIT_FOREVER);
pMacSyn = macSynFdbNodeGet(pHwMac->mac, pHwMac->vlanId, pHwMac->keyType);
if(pMacSyn == NULL)
{
gSysMacSynStatis.macLocalDelNotFound++;
semGive(gSysMacSynInfo.semTree);
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalDel: Mac can NOT be found."));
return ENOENT;
}
/*lisong add 20200120 for mlag;because this pHwMac */
/*comes from driver without any idea about owner*/
if(pMacSyn->l2Entry.owner == 1)
{
pHwMac->owner = 1;
ret = macSynMacLocalAdd(&(pMacSyn->l2Entry));
semGive(gSysMacSynInfo.semTree);
return ret;
}
/*在双芯片或者堆叠环境的L2MOD模式下,同步到另一片芯片的mac条目会老化,这时需要重新添加一次*/
if((pHwMac->port[0] == pMacSyn->l2Entry.port[0])&&(pHwMac->onuId != pMacSyn->l2Entry.onuId))
{
bzero(&phyInfo, sizeof(tPhyIfInfo));
if(sysIndexTrans((void*)pHwMac->port[0], SYS_LOGICAL2PHY_NUM, (void*)&phyInfo) != OK)
{
semGive(gSysMacSynInfo.semTree);
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalDel: Failed to get phyinfo."));
return EACCES;
}
if((phyInfo.endType == USP_END_ETHAGG)
&&((gSysMacSynInfo.coreDual == 0)||((gSysMacSynInfo.coreDual == 1)&&(((pHwMac->onuId-1)/2)!= ((pMacSyn->l2Entry.onuId-1)/2)))))
goto MACDELETE;
gSysMacSynStatis.macLocalDelAgedCnt++;
ret = udr_driver_api(&pHwMac->port[0], udr_cmd_mac_set(UDR_CMD_MAC_L2ADDR), pHwMac);
if(ret != OK)
{
#if 0 /*hqs-2019-12-18 泰国true测试增加log,在工程版本中不开放*/
zlog_write_logging(4, "[MSYN] macSynMacLocalAdd: Add HW error,ret=%d.",ret);
#endif
gSysMacSynStatis.macLocalDelAgedErr++;
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalDel: Add HW error, ret=%d.",ret));
}
semGive(gSysMacSynInfo.semTree);
macSynPrintf(MACSYN_DBG_DEL, ("\r\n macSynMacLocalDel: anther core mac had been aged, then add it."));
if(((pHwMac->mac[0] != 0x00)||(pHwMac->mac[1] != 0x04)||(pHwMac->mac[2] != 0x67))&&(gMacSynLog == 1))
zlog_write_logging(6, "LOCAL AGED mac = %02x%02x:%02x%02x:%02x%02x, vid = %d, unit = %s, src = %d, new = %d.\r\n", pHwMac->mac[0], pHwMac->mac[1], pHwMac->mac[2],
pHwMac->mac[3], pHwMac->mac[4], pHwMac->mac[5], pHwMac->vlanId, uspIfUnit2Name(pHwMac->port[0], ifName, sizeof(ifName)), pMacSyn->l2Entry.onuId, pHwMac->onuId);
return EAGAIN;
}
MACDELETE:
macSynPrintf(MACSYN_DBG_DEL, ("\r\n macSynMacLocalDel: Mac can be found."));
macSynFdbNodeDel(pMacSyn);
macSynCntDecrease(&pMacSyn->l2Entry);
semGive(gSysMacSynInfo.semTree);
if(pHwMac->type = HW_MAC_STICK)
{
pHwMac->type = HW_MAC_STATIC;
}
if((gSysMacSynInfo.coreDual == 1)||(pHwMac->type == HW_MAC_STATIC)||(gSysMacSynInfo.learnMode == 1))
{
macSynPrintf(MACSYN_DBG_DEL, ("\r\n macSynMacLocalDel: sync anther core."));
if(pHwMac->l3Mac == 1)
gSysMacSynStatis.macLocalL3DelCnt03++;
ret = udr_driver_api(NULL, udr_cmd_mac_set(UDR_CMD_MAC_DEL), pHwMac);
if((ret != OK)&&(ret != -7))
{
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalDel: mac del error,ret=%d.",ret));
gSysMacSynStatis.macLocalDelHwErr++;
return ENOSYS;
}
if(pHwMac->l3Mac == 1)
gSysMacSynStatis.macLocalL3DelCnt04++;
}
if(pHwMac->l3Mac == 1)
gSysMacSynStatis.macLocalL3DelCnt05++;
else if(pHwMac->port[0] != 0)
gSwApiFunction.SwIfNotify((void *)pHwMac->port[0], SW_IF_MACDEL, pHwMac);
if(((pHwMac->mac[0] != 0x00)||(pHwMac->mac[1] != 0x04)||(pHwMac->mac[2] != 0x67))&&(gMacSynLog == 1))
zlog_write_logging(6, "LOCAL DEL mac = %02x%02x:%02x%02x:%02x%02x, vid = %d, unit = %s.\r\n", pHwMac->mac[0], pHwMac->mac[1],
pHwMac->mac[2],pHwMac->mac[3],pHwMac->mac[4],pHwMac->mac[5], pHwMac->vlanId, uspIfUnit2Name(pHwMac->port[0], ifName, sizeof(ifName)));
macSynPrintf(MACSYN_DBG_DEL, ("\r\n macSynMacLocalDel: Del mac entry successful."));
return OK;
}
if(pMacSyn->l2Entry.owner == 1)/*lisong add 20200120 for mlag;because this pHwMac comes from driver without any idea about owner*/
{
pHwMac->owner = 1;
ret = macSynMacLocalAdd(&(pMacSyn->l2Entry));
semGive(gSysMacSynInfo.semTree);
return ret;
}
STATUS macSynMacLocalAdd(tHwMacAddrEntry *pHwMac)
{
uint8_t ifName[64] = {0};
int32_t ret = OK, value = 0, unit = 0;
tMacSynFdbNode *pMacSyn = NULL, macEntry;
tMacSynPort* pMacPort = NULL;
semTake(gSysMacSynInfo.semTree, WAIT_FOREVER);
pMacSyn = macSynFdbNodeGet(pHwMac->mac, pHwMac->vlanId, pHwMac->keyType);
if(pMacSyn != NULL)
{
macSynPrintf(MACSYN_DBG_ADD, ("\r\n macSynMacLocalAdd: Mac entry is exist."));
unit = pMacSyn->l2Entry.port[0];
if(pMacSyn->l2Entry.type == pHwMac->type) /*类型相同的mac表项*/
{
if(pHwMac->type == HW_MAC_DYNAMIC)
{
if(pMacSyn->l2Entry.port[0] == pHwMac->port[0]) /*相同的mac表项*/
{
semGive(gSysMacSynInfo.semTree);
macSynPrintf(MACSYN_DBG_ADD, ("\r\n macSynMacLocalAdd: Dynacmic mac is same."));
gSysMacSynStatis.macLocalAddSame++;
return EEXIST;
}
else
{
/*暂时不考虑mac地址漂移功能是否使能*/
macSynPrintf(MACSYN_DBG_ADD, ("\r\n macSynMacLocalAdd: Dynamic mac is NOT same, so replace it."));
memcpy(&pMacSyn->l2Entry, pHwMac, sizeof(tHwMacAddrEntry));
semGive(gSysMacSynInfo.semTree);
if((gSysMacSynInfo.coreDual == 1)||(gSysMacSynInfo.learnMode == 1)) /*双芯片同步或者l2mode*/
{
ret = udr_driver_api(NULL, udr_cmd_mac_set(UDR_CMD_MAC_L2ADDR), pHwMac);
if(ret != OK)
{
#if 0 /*hqs-2019-12-18 泰国true测试增加log,在工程版本中不开放*/
zlog_write_logging(4, "[MSYN] macSynMacLocalAdd: Add HW error,ret=%d.",ret);
#endif
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalAdd: Add HW error,ret=%d.",ret));
gSysMacSynStatis.macLocalAddFlapErr++;
return ENOSYS;
}
}
if((pHwMac->l3Mac != 1) &&(pHwMac->port[0] != 0))
gSwApiFunction.SwIfNotify((void *)unit, SW_IF_MACCHANGE, pHwMac);
if(((pHwMac->mac[0] != 0x00)||(pHwMac->mac[1] != 0x04)||(pHwMac->mac[2] != 0x67))&&(gMacSynLog == 1))
zlog_write_logging(6, "LOCAL FLAPPING mac = %02x%02x:%02x%02x:%02x%02x, vid = %d, unit = %s.\r\n", pHwMac->mac[0], pHwMac->mac[1],
pHwMac->mac[2],pHwMac->mac[3],pHwMac->mac[4],pHwMac->mac[5], pHwMac->vlanId, uspIfUnit2Name(pHwMac->port[0], ifName, sizeof(ifName)));
return OK;
}
}
else
{
if((pMacSyn->l2Entry.port[0] == pHwMac->port[0])&&(pMacSyn->l2Entry.operation == pHwMac->operation))
{
semGive(gSysMacSynInfo.semTree);
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalAdd: Static mac is same, do nothing."));
gSysMacSynStatis.macLocalAddSame++;
return EEXIST;
}
else
{
if(pHwMac->type == HW_MAC_STATIC)
{
macSynPrintf(MACSYN_DBG_ADD, ("\r\n macSynMacLocalAdd: Static mac is NOT same, so replace it."));
macSynCntDecrease(&pMacSyn->l2Entry);
macSynCntIncrease(pHwMac);
memcpy(&pMacSyn->l2Entry, pHwMac, sizeof(tHwMacAddrEntry));
semGive(gSysMacSynInfo.semTree);
ret = udr_driver_api(NULL, udr_cmd_mac_set(UDR_CMD_MAC_L2ADDR), pHwMac);
if(ret != OK)
{
#if 0 /*hqs-2019-12-18 泰国true测试增加log,在工程版本中不开放*/
zlog_write_logging(4, "[MSYN] macSynMacLocalAdd: Add HW error,ret=%d.",ret);
#endif
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalAdd: Add HW error,ret=%d.",ret));
gSysMacSynStatis.macLocalAddHwErr++;
return ENOSYS;
}
if((pHwMac->l3Mac != 1) &&(pHwMac->port[0] != 0))
gSwApiFunction.SwIfNotify((void *)unit, SW_IF_MACCHANGE, pHwMac);
return OK;
}
else
{
semGive(gSysMacSynInfo.semTree);
zlog_output_logging(2, "\r\n %%Error: The same MAC address has been configured on another port.");
return EEXIST;
}
}
}
}
else /*类型不相同的mac表项*/
{
if(pHwMac->type == HW_MAC_DYNAMIC) /*目前不会出现该情况*/
{
gSysMacSynStatis.macLocalAddUnknownErr++;
semGive(gSysMacSynInfo.semTree);
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalAdd: Dynamic replace static error."));
return EAGAIN;
}
else if(pHwMac->type == HW_MAC_STICK)
{
semGive(gSysMacSynInfo.semTree);
zlog_output_logging(2, "\r\n %%Error: The MAC address entry of another type already exists.");
return EEXIST;
}
else
{
if(pMacSyn->l2Entry.type != HW_MAC_STICK)
{
macSynPrintf(MACSYN_DBG_ADD, ("\r\n macSynMacLocalAdd: Static replaced dynamic."));
macSynCntDecrease(&pMacSyn->l2Entry);
macSynCntIncrease(pHwMac);
memcpy(&pMacSyn->l2Entry, pHwMac, sizeof(tHwMacAddrEntry));
semGive(gSysMacSynInfo.semTree);
ret = udr_driver_api(NULL, udr_cmd_mac_set(UDR_CMD_MAC_L2ADDR), pHwMac);
if(ret != OK)
{
#if 0 /*hqs-2019-12-18 泰国true测试增加log,在工程版本中不开放*/
zlog_write_logging(4, "[MSYN] macSynMacLocalAdd: Add HW error,ret=%d.",ret);
#endif
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalAdd: Add HW error,ret=%d.",ret));
gSysMacSynStatis.macLocalAddHwErr++;
return ENOSYS;
}
if((pHwMac->l3Mac != 1) &&(pHwMac->port[0] != 0))
gSwApiFunction.SwIfNotify((void *)unit, SW_IF_MACCHANGE, pHwMac);
return OK;
}
else
{
semGive(gSysMacSynInfo.semTree);
zlog_output_logging(2, "\r\n %%Error: The same MAC address has been configured on another port.");
return EEXIST;
}
}
}
}
macSynPrintf(MACSYN_DBG_ADD, ("\r\n macSynMacLocalAdd: Mac entry is NOT exist,add new."));
bzero((void *)&macEntry, sizeof(tMacSynFdbNode));
memcpy(&macEntry.l2Entry, pHwMac, sizeof(tHwMacAddrEntry));
if(((pMacPort = macSynStickyEnable(pHwMac->port[0], &value)) != NULL)&&(value == 1)&&((pHwMac->type == HW_MAC_DYNAMIC)||(pHwMac->type == HW_MAC_STICK)))
{
if(pMacPort->stickCount == pMacPort->portSecurityLimitNum)
{
if(pHwMac->type == HW_MAC_DYNAMIC)
udr_driver_api(NULL, udr_cmd_mac_set(UDR_CMD_MAC_DEL), pHwMac);
else
zlog_output_logging(2, "\r\n %%Error: Security mac number or sticky mac number reach the upper limit.");
semGive(gSysMacSynInfo.semTree);
return ERROR;
}
pHwMac->type = HW_MAC_STATIC;
macEntry.l2Entry.onuId = 0;
macEntry.l2Entry.type = HW_MAC_STICK;
}
if((gSysMacSynInfo.coreDual == 1)||(pHwMac->type == HW_MAC_STATIC)||(gSysMacSynInfo.learnMode == 1))
{
if(pHwMac->l3Mac == 1)
gSysMacSynStatis.macLocalL3AddCnt03++;
ret = udr_driver_api(NULL, udr_cmd_mac_set(UDR_CMD_MAC_L2ADDR), pHwMac);
if(ret != OK)
{
semGive(gSysMacSynInfo.semTree);
#if 0 /*hqs-2019-12-18 泰国true测试增加log,在工程版本中不开放*/
zlog_write_logging(4, "[MSYN] macSynMacLocalAdd: Add HW error,ret=%d.",ret);
#endif
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalAdd: Add HW error, ret=%d.",ret));
gSysMacSynStatis.macLocalAddHwErr++;
return ENOSYS;
}
if(pHwMac->l3Mac == 1)
gSysMacSynStatis.macLocalL3AddCnt04++;
}
/*新的mac地址可以添加到树上。*/
#if 0 /*初始化提前*/
bzero((void *)&macEntry, sizeof(tMacSynFdbNode));
memcpy(&macEntry.l2Entry, pHwMac, sizeof(tHwMacAddrEntry));
#endif
if(macSynFdbNodeAdd(&macEntry) != OK)
{
semGive(gSysMacSynInfo.semTree);
return ENOSPC;
}
#if 0
macSynCntIncrease(pHwMac);
#else
macSynCntIncrease(&macEntry.l2Entry);
#endif
semGive(gSysMacSynInfo.semTree);
if(pHwMac->l3Mac == 1)
gSysMacSynStatis.macLocalL3AddCnt05++;
else if(pHwMac->port[0] != 0)
gSwApiFunction.SwIfNotify((void *)pHwMac->port[0], SW_IF_MACADD, pHwMac);
if(((pHwMac->mac[0] != 0x00)||(pHwMac->mac[1] != 0x04)||(pHwMac->mac[2] != 0x67))&&(gMacSynLog == 1))
zlog_write_logging(6, "LOCAL ADD mac = %02x%02x:%02x%02x:%02x%02x, vid = %d, unit = %s.\r\n", pHwMac->mac[0], pHwMac->mac[1],
pHwMac->mac[2],pHwMac->mac[3],pHwMac->mac[4],pHwMac->mac[5], pHwMac->vlanId, uspIfUnit2Name(pHwMac->port[0], ifName, sizeof(ifName)));
macSynPrintf(MACSYN_DBG_ADD, ("\r\n macSynMacLocalAdd: Add mac successful."));
return OK;
}
2.角色改变,删除所有mlag同步过来的mac和local mac,同时通告对端删除mlag学到的mac
/*master or slaver role*/
if(p_mlag_notify->role != 3)
{
memcpy(mlag_peer_mac,p_mlag_notify->peer_mac,6);
mlag_peerlink = p_mlag_notify->peerlink;
if((p_mlag_notify->mlagId >= 1) && (p_mlag_notify->mlagId <= 64))
{
bitListSet(mlag_group_role, p_mlag_notify->mlagId - 1);
}
devMaclFlushByMlag();
mlag_peerlink_first_port_set(mlag_peerlink);
}
STATUS devMaclFlushByMlag()
{
tHwMacAddrEntry macDel;
int ret;
bzero(&macDel,sizeof(tHwMacAddrEntry));
macDel.sys = 1;
macDel.filterBits |= (1<<FDB_ACL_SYS) /*| (1<<FDB_ACL_MLAG)*/;
macSynSetApi(NULL, HW_SYS_FLUSHL2FDB, &macDel, 0);
return ret;
}
case HW_SYS_FLUSHL2FDB: /*需要替换HWAPI的实现*/
if(pHwMac == NULL)
{
macSynPrintf(MACSYN_DBG_EVT,("macSynSetApi: Invalid param, line %d.\r\n", __LINE__));
return EINVAL;
}
macSynPrintf(MACSYN_DBG_EVT,("\r\n macSynSetApi: recv HL flush mac event(0x%x).",pHwMac->filterBits));
message.pktHead.msgType = MACSYN_MSG_FLUSHL2FDB;
message.pktHead.dataLen = sizeof(tHwMacAddrEntry);
memcpy(&message.pktHead.l2entry, pHwMac, sizeof(tHwMacAddrEntry));
if(msgQSend(gSysMacSynInfo.msgQ, (UINT1 *)&message ,sizeof(tMacSynMsg), NO_WAIT, MSG_PRI_NORMAL) == ERROR)
{
gSysMacSynStatis.macLocalFlushMsgErr++;
return EBADMSG;
}
break;
case MACSYN_MSG_FLUSHL2FDB:
devMacLearnHandle(2);
ret = macSynMacLocalFlush(&message.pktHead.l2entry);
devMacLearnHandle(1);
break;
STATUS macSynMacLocalFlush(tHwMacAddrEntry *pHwMac)
{
int32_t ret = OK;
tMacSynFdbNode *pMacFdbEntry = NULL,*prevEntry = NULL;
if((pHwMac == NULL)||(pHwMac->filterBits == 0))
return EINVAL;
semTake(gSysMacSynInfo.semTree,WAIT_FOREVER);
pMacFdbEntry = (tMacSynFdbNode *)avl_first(&gSysMacSynInfo.avlFdbTree);
while(pMacFdbEntry != NULL)
{
prevEntry = (tMacSynFdbNode *)avl_next(&gSysMacSynInfo.avlFdbTree, pMacFdbEntry);
/*
if((pMacFdbEntry->l2Entry.owner == 1) && !(pHwMac->filterBits & (1<<FDB_ACL_MLAG)))
{
pMacFdbEntry = prevEntry;
printf("%s %d ,fiterbits:0x%x\r\n",__FUNCTION__,__LINE__,pHwMac->filterBits);
continue;
}
*/
if((pMacFdbEntry->l2Entry.l3Mac != 1)&&(macSynFilterMatch(pMacFdbEntry, pHwMac)))
{
avl_remove(&gSysMacSynInfo.avlFdbTree, pMacFdbEntry);
list_add((struct list_head *)&pMacFdbEntry->node, &gSysMacSynInfo.freeFdbTbl);
macSynCntDecrease(&pMacFdbEntry->l2Entry);
if(pMacFdbEntry->l2Entry.type == HW_MAC_STICK) /*STICK MAC*/
{
pMacFdbEntry->l2Entry.type = HW_MAC_STATIC;
}
ret = udr_driver_api(&pMacFdbEntry->l2Entry.port[0], udr_cmd_mac_set(UDR_CMD_MAC_DEL), &pMacFdbEntry->l2Entry);
if((ret != OK)&&(ret != -7))
{
macSynPrintf(MACSYN_DBG_ERR, ("\r\n macSynMacLocalFlush: Mac del error, ret = %d.",ret));
gSysMacSynStatis.macLoaclFlushHwErr++;
}
macSynPrintf(MACSYN_DBG_EVT, ("%s %d ,mac:0x%02x%02x%02x%02x%02x%02x\r\n",__FUNCTION__,__LINE__,pMacFdbEntry->l2Entry.mac[0],pMacFdbEntry->l2Entry.mac[1],pMacFdbEntry->l2Entry.mac[2],
pMacFdbEntry->l2Entry.mac[3],pMacFdbEntry->l2Entry.mac[4],pMacFdbEntry->l2Entry.mac[5]));
if(pMacFdbEntry->l2Entry.port[0] != 0)
gSwApiFunction.SwIfNotify((void *)pMacFdbEntry->l2Entry.port[0], SW_IF_MACDEL, &pMacFdbEntry->l2Entry);
macSynMlagEncode(&(pMacFdbEntry->l2Entry), MACSYN_SYNC_TYPEDEL);/*lisong add 20200119 for mlag*/
}
pMacFdbEntry = prevEntry;
}
semGive(gSysMacSynInfo.semTree);
return OK;
}