📄 ixethdbapisupport.c
字号:
/** * @file IxEthDBAPISupport.c * * @brief Public API support functions * * @par * IXP400 SW Release version 2.1 * * -- Copyright Notice -- * * @par * Copyright (c) 2001-2005, Intel Corporation. * All rights reserved. * * @par * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Intel Corporation nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * * @par * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * @par * -- End of Copyright Notice -- */#include <IxEthDB.h>#include <IxNpeMh.h>#include <IxFeatureCtrl.h>#include "IxEthDB_p.h"#include "IxEthDBMessages_p.h"#include "IxEthDB_p.h"#include "IxEthDBLog_p.h"#ifdef IX_UNIT_TESTint dbAccessCounter = 0;int overflowEvent = 0;#endif/* * External declaration */extern HashTable dbHashtable;/* * Internal declaration */IX_ETH_DB_PUBLIC PortInfo ixEthDBPortInfo[IX_ETH_DB_NUMBER_OF_PORTS];IX_ETH_DB_PRIVATE struct{ BOOL saved; IxEthDBPriorityTable priorityTable; IxEthDBVlanSet vlanMembership; IxEthDBVlanSet transmitTaggingInfo; IxEthDBFrameFilter frameFilter; IxEthDBTaggingAction taggingAction; IxEthDBFirewallMode firewallMode; BOOL stpBlocked; BOOL srcAddressFilterEnabled; UINT32 maxRxFrameSize; UINT32 maxTxFrameSize;} ixEthDBPortState[IX_ETH_DB_NUMBER_OF_PORTS];#define IX_ETH_DB_DEFAULT_FRAME_SIZE (1518)/** * @brief initializes a port * * @param portID ID of the port to be initialized * * Note that redundant initializations are silently * dealt with and do not constitute an error * * This function is fully documented in the main * header file, IxEthDB.h */IX_ETH_DB_PUBLICvoid ixEthDBPortInit(IxEthDBPortId portID){ PortInfo *portInfo; if (portID >= IX_ETH_DB_NUMBER_OF_PORTS) { return; } portInfo = &ixEthDBPortInfo[portID]; if (ixEthDBSingleEthNpeCheck(portID) != IX_ETH_DB_SUCCESS) { WARNING_LOG("EthDB: Unavailable Eth %d: Cannot initialize EthDB Port.\n", (UINT32) portID); return; } if (portInfo->initialized) { /* redundant */ return; } /* initialize core fields */ portInfo->portID = portID; SET_DEPENDENCY_MAP(portInfo->dependencyPortMap, portID); /* default values */ portInfo->agingEnabled = FALSE; portInfo->enabled = FALSE; portInfo->macAddressUploaded = FALSE; portInfo->maxRxFrameSize = IX_ETHDB_DEFAULT_FRAME_SIZE; portInfo->maxTxFrameSize = IX_ETHDB_DEFAULT_FRAME_SIZE; portInfo->wifiRecordsCount = 1; portInfo->fwRecordsCount = 1; /* default update control values */ portInfo->updateMethod.searchTree = NULL; portInfo->updateMethod.searchTreePendingWrite = FALSE; portInfo->updateMethod.treeInitialized = FALSE; portInfo->updateMethod.updateEnabled = FALSE; portInfo->updateMethod.userControlled = FALSE; /* default WiFi parameters */ memset(portInfo->bssid, 0, sizeof (portInfo->bssid)); portInfo->frameControlDurationID = 0; /* Ethernet NPE-specific initializations */ if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { /* update handler */ portInfo->updateMethod.updateHandler = ixEthDBNPEUpdateHandler; } /* initialize state save */ ixEthDBPortState[portID].saved = FALSE; portInfo->initialized = TRUE;}/** * @brief enables a port * * @param portID ID of the port to enable * * This function is fully documented in the main * header file, IxEthDB.h * * @return IX_ETH_DB_SUCCESS if enabling was * accomplished, or a meaningful error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBPortEnable(IxEthDBPortId portID){ IxEthDBPortMap triggerPorts; PortInfo *portInfo; IX_ETH_DB_CHECK_PORT_EXISTS(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); portInfo = &ixEthDBPortInfo[portID]; if (portInfo->enabled) { /* redundant */ return IX_ETH_DB_SUCCESS; } SET_DEPENDENCY_MAP(triggerPorts, portID); /* mark as enabled */ portInfo->enabled = TRUE; /* 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; } if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE && !portInfo->macAddressUploaded) { IX_ETH_DB_SUPPORT_TRACE("DB: (Support) MAC address not set on port %d, enable failed\n", portID); /* must use UnicastAddressSet() before enabling an NPE port */ return IX_ETH_DB_MAC_UNINITIALIZED; } if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Attempting to enable the NPE callback for port %d...\n", portID); if (!portInfo->updateMethod.userControlled && ((portInfo->featureCapability & IX_ETH_DB_FILTERING) != 0)) { portInfo->updateMethod.updateEnabled = TRUE; } /* if this is first time initialization then we already have write access to the tree and can AccessRelease directly */ if (!portInfo->updateMethod.treeInitialized) { IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Initializing tree for port %d\n", portID); /* create an initial tree and release access into it */ ixEthDBUpdatePortLearningTrees(triggerPorts); /* mark tree as being initialized */ portInfo->updateMethod.treeInitialized = TRUE; } } if (ixEthDBPortState[portID].saved) { /* previous configuration data stored, restore state */ if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0) { ixEthDBFirewallModeSet(portID, ixEthDBPortState[portID].firewallMode); ixEthDBFirewallInvalidAddressFilterEnable(portID, ixEthDBPortState[portID].srcAddressFilterEnabled); } if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0) { ixEthDBAcceptableFrameTypeSet(portID, ixEthDBPortState[portID].frameFilter); ixEthDBIngressVlanTaggingEnabledSet(portID, ixEthDBPortState[portID].taggingAction); ixEthDBEgressVlanTaggingEnabledSet(portID, ixEthDBPortState[portID].transmitTaggingInfo); ixEthDBPortVlanMembershipSet(portID, ixEthDBPortState[portID].vlanMembership); ixEthDBPriorityMappingTableSet(portID, ixEthDBPortState[portID].priorityTable); } if ((portInfo->featureCapability & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0) { ixEthDBSpanningTreeBlockingStateSet(portID, ixEthDBPortState[portID].stpBlocked); } ixEthDBFilteringPortMaximumRxFrameSizeSet(portID, ixEthDBPortState[portID].maxRxFrameSize); ixEthDBFilteringPortMaximumTxFrameSizeSet(portID, ixEthDBPortState[portID].maxTxFrameSize); /* discard previous save */ ixEthDBPortState[portID].saved = FALSE; } IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Enabling succeeded for port %d\n", portID); return IX_ETH_DB_SUCCESS;}/** * @brief disables a port * * @param portID ID of the port to disable * * This function is fully documented in the * main header file, IxEthDB.h * * @return IX_ETH_DB_SUCCESS if disabling was * successful or an appropriate error message * otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBPortDisable(IxEthDBPortId portID){ HashIterator iterator; IxEthDBPortMap triggerPorts; /* ports who will have deleted records and therefore will need updating */ BOOL result; PortInfo *portInfo; IxEthDBFeature learningEnabled; IxEthDBPriorityTable classZeroTable; IX_ETH_DB_CHECK_PORT_EXISTS(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); portInfo = &ixEthDBPortInfo[portID]; if (!portInfo->enabled) { /* redundant */ return IX_ETH_DB_SUCCESS; } if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { /* save filtering state */ ixEthDBPortState[portID].firewallMode = portInfo->firewallMode; ixEthDBPortState[portID].frameFilter = portInfo->frameFilter; ixEthDBPortState[portID].taggingAction = portInfo->taggingAction; ixEthDBPortState[portID].stpBlocked = portInfo->stpBlocked; ixEthDBPortState[portID].srcAddressFilterEnabled = portInfo->srcAddressFilterEnabled; ixEthDBPortState[portID].maxRxFrameSize = portInfo->maxRxFrameSize; ixEthDBPortState[portID].maxTxFrameSize = portInfo->maxTxFrameSize; memcpy(ixEthDBPortState[portID].vlanMembership, portInfo->vlanMembership, sizeof (IxEthDBVlanSet)); memcpy(ixEthDBPortState[portID].transmitTaggingInfo, portInfo->transmitTaggingInfo, sizeof (IxEthDBVlanSet)); memcpy(ixEthDBPortState[portID].priorityTable, portInfo->priorityTable, sizeof (IxEthDBPriorityTable)); ixEthDBPortState[portID].saved = TRUE; /* now turn off all EthDB filtering features on the port */ /* VLAN & QoS */ if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0) { ixEthDBPortVlanMembershipRangeAdd((IxEthDBPortId) portID, 0, IX_ETH_DB_802_1Q_MAX_VLAN_ID); ixEthDBEgressVlanRangeTaggingEnabledSet((IxEthDBPortId) portID, 0, IX_ETH_DB_802_1Q_MAX_VLAN_ID, FALSE); ixEthDBAcceptableFrameTypeSet((IxEthDBPortId) portID, IX_ETH_DB_ACCEPT_ALL_FRAMES); ixEthDBIngressVlanTaggingEnabledSet((IxEthDBPortId) portID, IX_ETH_DB_PASS_THROUGH); memset(classZeroTable, 0, sizeof (classZeroTable)); ixEthDBPriorityMappingTableSet((IxEthDBPortId) portID, classZeroTable); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -