📄 ixethdbapisupport.c
字号:
/* STP */ if ((portInfo->featureCapability & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0) { ixEthDBSpanningTreeBlockingStateSet((IxEthDBPortId) portID, FALSE); } /* Firewall */ if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0) { ixEthDBFirewallModeSet((IxEthDBPortId) portID, IX_ETH_DB_FIREWALL_BLACK_LIST); ixEthDBFirewallTableDownload((IxEthDBPortId) portID); ixEthDBFirewallInvalidAddressFilterEnable((IxEthDBPortId) portID, FALSE); } /* Frame size filter */ ixEthDBFilteringPortMaximumFrameSizeSet((IxEthDBPortId) portID, IX_ETH_DB_DEFAULT_FRAME_SIZE); /* WiFi */ if ((portInfo->featureCapability & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0) { ixEthDBWiFiConversionTableDownload((IxEthDBPortId) portID); } /* save and disable the learning feature bit */ learningEnabled = portInfo->featureStatus & IX_ETH_DB_LEARNING; portInfo->featureStatus &= ~IX_ETH_DB_LEARNING; } else { /* save the learning feature bit */ learningEnabled = portInfo->featureStatus & IX_ETH_DB_LEARNING; } SET_EMPTY_DEPENDENCY_MAP(triggerPorts); ixEthDBUpdateLock(); /* wipe out current entries for this port */ BUSY_RETRY(ixEthDBInitHashIterator(&dbHashtable, &iterator)); while (IS_ITERATOR_VALID(&iterator)) { MacDescriptor *descriptor = (MacDescriptor *) iterator.node->data; /* check if the port match. If so, remove the entry */ if (descriptor->portID == portID && (descriptor->type == IX_ETH_DB_FILTERING_RECORD || descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD) && !descriptor->recordData.filteringData.staticEntry) { /* delete entry */ BUSY_RETRY(ixEthDBRemoveEntryAtHashIterator(&dbHashtable, &iterator)); /* add port to the set of update trigger ports */ JOIN_PORT_TO_MAP(triggerPorts, portID); } else { /* move to the next record */ BUSY_RETRY(ixEthDBIncrementHashIterator(&dbHashtable, &iterator)); } } if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { if (portInfo->updateMethod.searchTree != NULL) { ixEthDBFreeMacTreeNode(portInfo->updateMethod.searchTree); portInfo->updateMethod.searchTree = NULL; } ixEthDBNPEUpdateHandler(portID, IX_ETH_DB_FILTERING_RECORD); } /* mark as disabled */ portInfo->enabled = FALSE; /* disable updates unless the user has specifically altered the default behavior */ if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { if (!portInfo->updateMethod.userControlled) { portInfo->updateMethod.updateEnabled = FALSE; } /* make sure we re-initialize the NPE learning tree when the port is re-enabled */ portInfo->updateMethod.treeInitialized = FALSE; } ixEthDBUpdateUnlock(); /* restore learning feature bit */ portInfo->featureStatus |= learningEnabled; /* if we've removed any records or lost any events make sure to force an update */ IS_EMPTY_DEPENDENCY_MAP(result, triggerPorts); if (!result) { ixEthDBUpdatePortLearningTrees(triggerPorts); } return IX_ETH_DB_SUCCESS;}/** * @brief sends the updated maximum Tx/Rx frame lengths to the NPE * * @param portID ID of the port to update * * @return IX_ETH_DB_SUCCESS if the update completed * successfully or an appropriate error message otherwise * * @internal */IX_ETH_DB_PRIVATEIxEthDBStatus ixEthDBPortFrameLengthsUpdate(IxEthDBPortId portID){ IxNpeMhMessage message; PortInfo *portInfo = &ixEthDBPortInfo[portID]; IX_STATUS result; FILL_SETMAXFRAMELENGTHS_MSG(message, portID, portInfo->maxRxFrameSize, portInfo->maxTxFrameSize); IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result); return result;}/** * @brief sets the port maximum Rx frame size * * @param portID ID of the port to set the frame size on * @param maximumRxFrameSize maximum Rx frame size * * This function updates the internal data structures and * calls ixEthDBPortFrameLengthsUpdate() for NPE update. * * This function is fully documented in the main header * file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation was * successfull or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBFilteringPortMaximumRxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumRxFrameSize){ IX_ETH_DB_CHECK_PORT_EXISTS(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); if (!ixEthDBPortInfo[portID].initialized) { return IX_ETH_DB_PORT_UNINITIALIZED; } if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { if ((maximumRxFrameSize < IX_ETHDB_MIN_NPE_FRAME_SIZE) || (maximumRxFrameSize > IX_ETHDB_MAX_NPE_FRAME_SIZE)) { return IX_ETH_DB_INVALID_ARG; } } else { return IX_ETH_DB_NO_PERMISSION; } /* update internal structure */ ixEthDBPortInfo[portID].maxRxFrameSize = maximumRxFrameSize; /* update the maximum frame size in the NPE */ return ixEthDBPortFrameLengthsUpdate(portID);}/** * @brief sets the port maximum Tx frame size * * @param portID ID of the port to set the frame size on * @param maximumTxFrameSize maximum Tx frame size * * This function updates the internal data structures and * calls ixEthDBPortFrameLengthsUpdate() for NPE update. * * This function is fully documented in the main header * file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation was * successfull or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBFilteringPortMaximumTxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumTxFrameSize){ IX_ETH_DB_CHECK_PORT_EXISTS(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); if (!ixEthDBPortInfo[portID].initialized) { return IX_ETH_DB_PORT_UNINITIALIZED; } if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { if ((maximumTxFrameSize < IX_ETHDB_MIN_NPE_FRAME_SIZE) || (maximumTxFrameSize > IX_ETHDB_MAX_NPE_FRAME_SIZE)) { return IX_ETH_DB_INVALID_ARG; } } else { return IX_ETH_DB_NO_PERMISSION; } /* update internal structure */ ixEthDBPortInfo[portID].maxTxFrameSize = maximumTxFrameSize; /* update the maximum frame size in the NPE */ return ixEthDBPortFrameLengthsUpdate(portID);}/** * @brief sets the port maximum Tx and Rx frame sizes * * @param portID ID of the port to set the frame size on * @param maximumFrameSize maximum Tx and Rx frame sizes * * This function updates the internal data structures and * calls ixEthDBPortFrameLengthsUpdate() for NPE update. * * Note that both the maximum Tx and Rx frame size are set * to the same value. This function is kept for compatibility * reasons. * * This function is fully documented in the main header * file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation was * successfull or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBFilteringPortMaximumFrameSizeSet(IxEthDBPortId portID, UINT32 maximumFrameSize){ IX_ETH_DB_CHECK_PORT_EXISTS(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); if (!ixEthDBPortInfo[portID].initialized) { return IX_ETH_DB_PORT_UNINITIALIZED; } if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { if ((maximumFrameSize < IX_ETHDB_MIN_NPE_FRAME_SIZE) || (maximumFrameSize > IX_ETHDB_MAX_NPE_FRAME_SIZE)) { return IX_ETH_DB_INVALID_ARG; } } else { return IX_ETH_DB_NO_PERMISSION; } /* update internal structure */ ixEthDBPortInfo[portID].maxRxFrameSize = maximumFrameSize; ixEthDBPortInfo[portID].maxTxFrameSize = maximumFrameSize; /* update the maximum frame size in the NPE */ return ixEthDBPortFrameLengthsUpdate(portID);}/** * @brief sets the MAC address of an NPE port * * @param portID port ID to set the MAC address on * @param macAddr pointer to the 6-byte MAC address * * This function is called by the EthAcc * ixEthAccUnicastMacAddressSet() and should not be * manually invoked unless required by special circumstances. * * @return IX_ETH_DB_SUCCESS if the operation succeeded * or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBPortAddressSet(IxEthDBPortId portID, IxEthDBMacAddr *macAddr){ IxNpeMhMessage message; IxOsalMutex *ackPortAddressLock; IX_STATUS result; /* use this macro instead CHECK_PORT as the port doesn't need to be enabled */ IX_ETH_DB_CHECK_PORT_EXISTS(portID); IX_ETH_DB_CHECK_REFERENCE(macAddr); if (!ixEthDBPortInfo[portID].initialized) { return IX_ETH_DB_PORT_UNINITIALIZED; } ackPortAddressLock = &ixEthDBPortInfo[portID].npeAckLock; /* Operation stops here when Ethernet Learning is not enabled */ if(IX_FEATURE_CTRL_SWCONFIG_DISABLED == ixFeatureCtrlSwConfigurationCheck(IX_FEATURECTRL_ETH_LEARNING)) { return IX_ETH_DB_SUCCESS; } IX_ETH_DB_CHECK_SINGLE_NPE(portID); /* exit if the port is not an Ethernet NPE */ if (ixEthDBPortDefinitions[portID].type != IX_ETH_NPE) { return IX_ETH_DB_INVALID_PORT; } /* populate message */ FILL_SETPORTADDRESS_MSG(message, portID, macAddr->macAddress); IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Sending SetPortAddress on port %d...\n", portID); /* send a SetPortAddress message */ IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result); if (result == IX_SUCCESS) { ixEthDBPortInfo[portID].macAddressUploaded = TRUE; } return result;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -