IxEthDBAPISupport.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /**
  2. * @file IxEthDBAPISupport.c
  3. *
  4. * @brief Public API support functions
  5. *
  6. * @par
  7. * IXP400 SW Release version 2.0
  8. *
  9. * -- Copyright Notice --
  10. *
  11. * @par
  12. * Copyright 2001-2005, Intel Corporation.
  13. * All rights reserved.
  14. *
  15. * @par
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions
  18. * are met:
  19. * 1. Redistributions of source code must retain the above copyright
  20. * notice, this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  25. * may be used to endorse or promote products derived from this software
  26. * without specific prior written permission.
  27. *
  28. * @par
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  30. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  33. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  37. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  38. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  39. * SUCH DAMAGE.
  40. *
  41. * @par
  42. * -- End of Copyright Notice --
  43. */
  44. #include <IxEthDB.h>
  45. #include <IxNpeMh.h>
  46. #include <IxFeatureCtrl.h>
  47. #include "IxEthDB_p.h"
  48. #include "IxEthDBMessages_p.h"
  49. #include "IxEthDB_p.h"
  50. #include "IxEthDBLog_p.h"
  51. #ifdef IX_UNIT_TEST
  52. int dbAccessCounter = 0;
  53. int overflowEvent = 0;
  54. #endif
  55. /*
  56. * External declaration
  57. */
  58. extern HashTable dbHashtable;
  59. /*
  60. * Internal declaration
  61. */
  62. IX_ETH_DB_PUBLIC
  63. PortInfo ixEthDBPortInfo[IX_ETH_DB_NUMBER_OF_PORTS];
  64. IX_ETH_DB_PRIVATE
  65. struct
  66. {
  67. BOOL saved;
  68. IxEthDBPriorityTable priorityTable;
  69. IxEthDBVlanSet vlanMembership;
  70. IxEthDBVlanSet transmitTaggingInfo;
  71. IxEthDBFrameFilter frameFilter;
  72. IxEthDBTaggingAction taggingAction;
  73. IxEthDBFirewallMode firewallMode;
  74. BOOL stpBlocked;
  75. BOOL srcAddressFilterEnabled;
  76. UINT32 maxRxFrameSize;
  77. UINT32 maxTxFrameSize;
  78. } ixEthDBPortState[IX_ETH_DB_NUMBER_OF_PORTS];
  79. #define IX_ETH_DB_DEFAULT_FRAME_SIZE (1518)
  80. /**
  81. * @brief initializes a port
  82. *
  83. * @param portID ID of the port to be initialized
  84. *
  85. * Note that redundant initializations are silently
  86. * dealt with and do not constitute an error
  87. *
  88. * This function is fully documented in the main
  89. * header file, IxEthDB.h
  90. */
  91. IX_ETH_DB_PUBLIC
  92. void ixEthDBPortInit(IxEthDBPortId portID)
  93. {
  94. PortInfo *portInfo;
  95. if (portID >= IX_ETH_DB_NUMBER_OF_PORTS)
  96. {
  97. return;
  98. }
  99. portInfo = &ixEthDBPortInfo[portID];
  100. if (ixEthDBSingleEthNpeCheck(portID) != IX_ETH_DB_SUCCESS)
  101. {
  102. WARNING_LOG("EthDB: Unavailable Eth %d: Cannot initialize EthDB Port.\n", (UINT32) portID);
  103. return;
  104. }
  105. if (portInfo->initialized)
  106. {
  107. /* redundant */
  108. return;
  109. }
  110. /* initialize core fields */
  111. portInfo->portID = portID;
  112. SET_DEPENDENCY_MAP(portInfo->dependencyPortMap, portID);
  113. /* default values */
  114. portInfo->agingEnabled = FALSE;
  115. portInfo->enabled = FALSE;
  116. portInfo->macAddressUploaded = FALSE;
  117. portInfo->maxRxFrameSize = IX_ETHDB_DEFAULT_FRAME_SIZE;
  118. portInfo->maxTxFrameSize = IX_ETHDB_DEFAULT_FRAME_SIZE;
  119. /* default update control values */
  120. portInfo->updateMethod.searchTree = NULL;
  121. portInfo->updateMethod.searchTreePendingWrite = FALSE;
  122. portInfo->updateMethod.treeInitialized = FALSE;
  123. portInfo->updateMethod.updateEnabled = FALSE;
  124. portInfo->updateMethod.userControlled = FALSE;
  125. /* default WiFi parameters */
  126. memset(portInfo->bbsid, 0, sizeof (portInfo->bbsid));
  127. portInfo->frameControlDurationID = 0;
  128. /* Ethernet NPE-specific initializations */
  129. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  130. {
  131. /* update handler */
  132. portInfo->updateMethod.updateHandler = ixEthDBNPEUpdateHandler;
  133. }
  134. /* initialize state save */
  135. ixEthDBPortState[portID].saved = FALSE;
  136. portInfo->initialized = TRUE;
  137. }
  138. /**
  139. * @brief enables a port
  140. *
  141. * @param portID ID of the port to enable
  142. *
  143. * This function is fully documented in the main
  144. * header file, IxEthDB.h
  145. *
  146. * @return IX_ETH_DB_SUCCESS if enabling was
  147. * accomplished, or a meaningful error message otherwise
  148. */
  149. IX_ETH_DB_PUBLIC
  150. IxEthDBStatus ixEthDBPortEnable(IxEthDBPortId portID)
  151. {
  152. IxEthDBPortMap triggerPorts;
  153. PortInfo *portInfo;
  154. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  155. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  156. portInfo = &ixEthDBPortInfo[portID];
  157. if (portInfo->enabled)
  158. {
  159. /* redundant */
  160. return IX_ETH_DB_SUCCESS;
  161. }
  162. SET_DEPENDENCY_MAP(triggerPorts, portID);
  163. /* mark as enabled */
  164. portInfo->enabled = TRUE;
  165. /* Operation stops here when Ethernet Learning is not enabled */
  166. if(IX_FEATURE_CTRL_SWCONFIG_DISABLED ==
  167. ixFeatureCtrlSwConfigurationCheck(IX_FEATURECTRL_ETH_LEARNING))
  168. {
  169. return IX_ETH_DB_SUCCESS;
  170. }
  171. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE && !portInfo->macAddressUploaded)
  172. {
  173. IX_ETH_DB_SUPPORT_TRACE("DB: (Support) MAC address not set on port %d, enable failed\n", portID);
  174. /* must use UnicastAddressSet() before enabling an NPE port */
  175. return IX_ETH_DB_MAC_UNINITIALIZED;
  176. }
  177. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  178. {
  179. IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Attempting to enable the NPE callback for port %d...\n", portID);
  180. if (!portInfo->updateMethod.userControlled
  181. && ((portInfo->featureCapability & IX_ETH_DB_FILTERING) != 0))
  182. {
  183. portInfo->updateMethod.updateEnabled = TRUE;
  184. }
  185. /* if this is first time initialization then we already have
  186. write access to the tree and can AccessRelease directly */
  187. if (!portInfo->updateMethod.treeInitialized)
  188. {
  189. IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Initializing tree for port %d\n", portID);
  190. /* create an initial tree and release access into it */
  191. ixEthDBUpdatePortLearningTrees(triggerPorts);
  192. /* mark tree as being initialized */
  193. portInfo->updateMethod.treeInitialized = TRUE;
  194. }
  195. }
  196. if (ixEthDBPortState[portID].saved)
  197. {
  198. /* previous configuration data stored, restore state */
  199. if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0)
  200. {
  201. ixEthDBFirewallModeSet(portID, ixEthDBPortState[portID].firewallMode);
  202. ixEthDBFirewallInvalidAddressFilterEnable(portID, ixEthDBPortState[portID].srcAddressFilterEnabled);
  203. }
  204. #if 0 /* test-only */
  205. if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0)
  206. {
  207. ixEthDBAcceptableFrameTypeSet(portID, ixEthDBPortState[portID].frameFilter);
  208. ixEthDBIngressVlanTaggingEnabledSet(portID, ixEthDBPortState[portID].taggingAction);
  209. ixEthDBEgressVlanTaggingEnabledSet(portID, ixEthDBPortState[portID].transmitTaggingInfo);
  210. ixEthDBPortVlanMembershipSet(portID, ixEthDBPortState[portID].vlanMembership);
  211. ixEthDBPriorityMappingTableSet(portID, ixEthDBPortState[portID].priorityTable);
  212. }
  213. #endif
  214. if ((portInfo->featureCapability & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0)
  215. {
  216. ixEthDBSpanningTreeBlockingStateSet(portID, ixEthDBPortState[portID].stpBlocked);
  217. }
  218. ixEthDBFilteringPortMaximumRxFrameSizeSet(portID, ixEthDBPortState[portID].maxRxFrameSize);
  219. ixEthDBFilteringPortMaximumTxFrameSizeSet(portID, ixEthDBPortState[portID].maxTxFrameSize);
  220. /* discard previous save */
  221. ixEthDBPortState[portID].saved = FALSE;
  222. }
  223. IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Enabling succeeded for port %d\n", portID);
  224. return IX_ETH_DB_SUCCESS;
  225. }
  226. /**
  227. * @brief disables a port
  228. *
  229. * @param portID ID of the port to disable
  230. *
  231. * This function is fully documented in the
  232. * main header file, IxEthDB.h
  233. *
  234. * @return IX_ETH_DB_SUCCESS if disabling was
  235. * successful or an appropriate error message
  236. * otherwise
  237. */
  238. IX_ETH_DB_PUBLIC
  239. IxEthDBStatus ixEthDBPortDisable(IxEthDBPortId portID)
  240. {
  241. HashIterator iterator;
  242. IxEthDBPortMap triggerPorts; /* ports who will have deleted records and therefore will need updating */
  243. BOOL result;
  244. PortInfo *portInfo;
  245. IxEthDBFeature learningEnabled;
  246. #if 0 /* test-only */
  247. IxEthDBPriorityTable classZeroTable;
  248. #endif
  249. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  250. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  251. portInfo = &ixEthDBPortInfo[portID];
  252. if (!portInfo->enabled)
  253. {
  254. /* redundant */
  255. return IX_ETH_DB_SUCCESS;
  256. }
  257. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  258. {
  259. /* save filtering state */
  260. ixEthDBPortState[portID].firewallMode = portInfo->firewallMode;
  261. ixEthDBPortState[portID].frameFilter = portInfo->frameFilter;
  262. ixEthDBPortState[portID].taggingAction = portInfo->taggingAction;
  263. ixEthDBPortState[portID].stpBlocked = portInfo->stpBlocked;
  264. ixEthDBPortState[portID].srcAddressFilterEnabled = portInfo->srcAddressFilterEnabled;
  265. ixEthDBPortState[portID].maxRxFrameSize = portInfo->maxRxFrameSize;
  266. ixEthDBPortState[portID].maxTxFrameSize = portInfo->maxTxFrameSize;
  267. memcpy(ixEthDBPortState[portID].vlanMembership, portInfo->vlanMembership, sizeof (IxEthDBVlanSet));
  268. memcpy(ixEthDBPortState[portID].transmitTaggingInfo, portInfo->transmitTaggingInfo, sizeof (IxEthDBVlanSet));
  269. memcpy(ixEthDBPortState[portID].priorityTable, portInfo->priorityTable, sizeof (IxEthDBPriorityTable));
  270. ixEthDBPortState[portID].saved = TRUE;
  271. /* now turn off all EthDB filtering features on the port */
  272. #if 0 /* test-only */
  273. /* VLAN & QoS */
  274. if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0)
  275. {
  276. ixEthDBPortVlanMembershipRangeAdd((IxEthDBPortId) portID, 0, IX_ETH_DB_802_1Q_MAX_VLAN_ID);
  277. ixEthDBEgressVlanRangeTaggingEnabledSet((IxEthDBPortId) portID, 0, IX_ETH_DB_802_1Q_MAX_VLAN_ID, FALSE);
  278. ixEthDBAcceptableFrameTypeSet((IxEthDBPortId) portID, IX_ETH_DB_ACCEPT_ALL_FRAMES);
  279. ixEthDBIngressVlanTaggingEnabledSet((IxEthDBPortId) portID, IX_ETH_DB_PASS_THROUGH);
  280. memset(classZeroTable, 0, sizeof (classZeroTable));
  281. ixEthDBPriorityMappingTableSet((IxEthDBPortId) portID, classZeroTable);
  282. }
  283. #endif
  284. /* STP */
  285. if ((portInfo->featureCapability & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0)
  286. {
  287. ixEthDBSpanningTreeBlockingStateSet((IxEthDBPortId) portID, FALSE);
  288. }
  289. /* Firewall */
  290. if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0)
  291. {
  292. ixEthDBFirewallModeSet((IxEthDBPortId) portID, IX_ETH_DB_FIREWALL_BLACK_LIST);
  293. ixEthDBFirewallTableDownload((IxEthDBPortId) portID);
  294. ixEthDBFirewallInvalidAddressFilterEnable((IxEthDBPortId) portID, FALSE);
  295. }
  296. /* Frame size filter */
  297. ixEthDBFilteringPortMaximumFrameSizeSet((IxEthDBPortId) portID, IX_ETH_DB_DEFAULT_FRAME_SIZE);
  298. /* WiFi */
  299. if ((portInfo->featureCapability & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0)
  300. {
  301. ixEthDBWiFiConversionTableDownload((IxEthDBPortId) portID);
  302. }
  303. /* save and disable the learning feature bit */
  304. learningEnabled = portInfo->featureStatus & IX_ETH_DB_LEARNING;
  305. portInfo->featureStatus &= ~IX_ETH_DB_LEARNING;
  306. }
  307. else
  308. {
  309. /* save the learning feature bit */
  310. learningEnabled = portInfo->featureStatus & IX_ETH_DB_LEARNING;
  311. }
  312. SET_EMPTY_DEPENDENCY_MAP(triggerPorts);
  313. ixEthDBUpdateLock();
  314. /* wipe out current entries for this port */
  315. BUSY_RETRY(ixEthDBInitHashIterator(&dbHashtable, &iterator));
  316. while (IS_ITERATOR_VALID(&iterator))
  317. {
  318. MacDescriptor *descriptor = (MacDescriptor *) iterator.node->data;
  319. /* check if the port match. If so, remove the entry */
  320. if (descriptor->portID == portID
  321. && (descriptor->type == IX_ETH_DB_FILTERING_RECORD || descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD)
  322. && !descriptor->recordData.filteringData.staticEntry)
  323. {
  324. /* delete entry */
  325. BUSY_RETRY(ixEthDBRemoveEntryAtHashIterator(&dbHashtable, &iterator));
  326. /* add port to the set of update trigger ports */
  327. JOIN_PORT_TO_MAP(triggerPorts, portID);
  328. }
  329. else
  330. {
  331. /* move to the next record */
  332. BUSY_RETRY(ixEthDBIncrementHashIterator(&dbHashtable, &iterator));
  333. }
  334. }
  335. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  336. {
  337. if (portInfo->updateMethod.searchTree != NULL)
  338. {
  339. ixEthDBFreeMacTreeNode(portInfo->updateMethod.searchTree);
  340. portInfo->updateMethod.searchTree = NULL;
  341. }
  342. ixEthDBNPEUpdateHandler(portID, IX_ETH_DB_FILTERING_RECORD);
  343. }
  344. /* mark as disabled */
  345. portInfo->enabled = FALSE;
  346. /* disable updates unless the user has specifically altered the default behavior */
  347. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  348. {
  349. if (!portInfo->updateMethod.userControlled)
  350. {
  351. portInfo->updateMethod.updateEnabled = FALSE;
  352. }
  353. /* make sure we re-initialize the NPE learning tree when the port is re-enabled */
  354. portInfo->updateMethod.treeInitialized = FALSE;
  355. }
  356. ixEthDBUpdateUnlock();
  357. /* restore learning feature bit */
  358. portInfo->featureStatus |= learningEnabled;
  359. /* if we've removed any records or lost any events make sure to force an update */
  360. IS_EMPTY_DEPENDENCY_MAP(result, triggerPorts);
  361. if (!result)
  362. {
  363. ixEthDBUpdatePortLearningTrees(triggerPorts);
  364. }
  365. return IX_ETH_DB_SUCCESS;
  366. }
  367. /**
  368. * @brief sends the updated maximum Tx/Rx frame lengths to the NPE
  369. *
  370. * @param portID ID of the port to update
  371. *
  372. * @return IX_ETH_DB_SUCCESS if the update completed
  373. * successfully or an appropriate error message otherwise
  374. *
  375. * @internal
  376. */
  377. IX_ETH_DB_PRIVATE
  378. IxEthDBStatus ixEthDBPortFrameLengthsUpdate(IxEthDBPortId portID)
  379. {
  380. IxNpeMhMessage message;
  381. PortInfo *portInfo = &ixEthDBPortInfo[portID];
  382. IX_STATUS result;
  383. FILL_SETMAXFRAMELENGTHS_MSG(message, portID, portInfo->maxRxFrameSize, portInfo->maxTxFrameSize);
  384. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  385. return result;
  386. }
  387. /**
  388. * @brief sets the port maximum Rx frame size
  389. *
  390. * @param portID ID of the port to set the frame size on
  391. * @param maximumRxFrameSize maximum Rx frame size
  392. *
  393. * This function updates the internal data structures and
  394. * calls ixEthDBPortFrameLengthsUpdate() for NPE update.
  395. *
  396. * This function is fully documented in the main header
  397. * file, IxEthDB.h.
  398. *
  399. * @return IX_ETH_DB_SUCCESS if the operation was
  400. * successfull or an appropriate error message otherwise
  401. */
  402. IX_ETH_DB_PUBLIC
  403. IxEthDBStatus ixEthDBFilteringPortMaximumRxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumRxFrameSize)
  404. {
  405. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  406. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  407. if (!ixEthDBPortInfo[portID].initialized)
  408. {
  409. return IX_ETH_DB_PORT_UNINITIALIZED;
  410. }
  411. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  412. {
  413. if ((maximumRxFrameSize < IX_ETHDB_MIN_NPE_FRAME_SIZE) ||
  414. (maximumRxFrameSize > IX_ETHDB_MAX_NPE_FRAME_SIZE))
  415. {
  416. return IX_ETH_DB_INVALID_ARG;
  417. }
  418. }
  419. else
  420. {
  421. return IX_ETH_DB_NO_PERMISSION;
  422. }
  423. /* update internal structure */
  424. ixEthDBPortInfo[portID].maxRxFrameSize = maximumRxFrameSize;
  425. /* update the maximum frame size in the NPE */
  426. return ixEthDBPortFrameLengthsUpdate(portID);
  427. }
  428. /**
  429. * @brief sets the port maximum Tx frame size
  430. *
  431. * @param portID ID of the port to set the frame size on
  432. * @param maximumTxFrameSize maximum Tx frame size
  433. *
  434. * This function updates the internal data structures and
  435. * calls ixEthDBPortFrameLengthsUpdate() for NPE update.
  436. *
  437. * This function is fully documented in the main header
  438. * file, IxEthDB.h.
  439. *
  440. * @return IX_ETH_DB_SUCCESS if the operation was
  441. * successfull or an appropriate error message otherwise
  442. */
  443. IX_ETH_DB_PUBLIC
  444. IxEthDBStatus ixEthDBFilteringPortMaximumTxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumTxFrameSize)
  445. {
  446. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  447. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  448. if (!ixEthDBPortInfo[portID].initialized)
  449. {
  450. return IX_ETH_DB_PORT_UNINITIALIZED;
  451. }
  452. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  453. {
  454. if ((maximumTxFrameSize < IX_ETHDB_MIN_NPE_FRAME_SIZE) ||
  455. (maximumTxFrameSize > IX_ETHDB_MAX_NPE_FRAME_SIZE))
  456. {
  457. return IX_ETH_DB_INVALID_ARG;
  458. }
  459. }
  460. else
  461. {
  462. return IX_ETH_DB_NO_PERMISSION;
  463. }
  464. /* update internal structure */
  465. ixEthDBPortInfo[portID].maxTxFrameSize = maximumTxFrameSize;
  466. /* update the maximum frame size in the NPE */
  467. return ixEthDBPortFrameLengthsUpdate(portID);
  468. }
  469. /**
  470. * @brief sets the port maximum Tx and Rx frame sizes
  471. *
  472. * @param portID ID of the port to set the frame size on
  473. * @param maximumFrameSize maximum Tx and Rx frame sizes
  474. *
  475. * This function updates the internal data structures and
  476. * calls ixEthDBPortFrameLengthsUpdate() for NPE update.
  477. *
  478. * Note that both the maximum Tx and Rx frame size are set
  479. * to the same value. This function is kept for compatibility
  480. * reasons.
  481. *
  482. * This function is fully documented in the main header
  483. * file, IxEthDB.h.
  484. *
  485. * @return IX_ETH_DB_SUCCESS if the operation was
  486. * successfull or an appropriate error message otherwise
  487. */
  488. IX_ETH_DB_PUBLIC
  489. IxEthDBStatus ixEthDBFilteringPortMaximumFrameSizeSet(IxEthDBPortId portID, UINT32 maximumFrameSize)
  490. {
  491. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  492. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  493. if (!ixEthDBPortInfo[portID].initialized)
  494. {
  495. return IX_ETH_DB_PORT_UNINITIALIZED;
  496. }
  497. if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
  498. {
  499. if ((maximumFrameSize < IX_ETHDB_MIN_NPE_FRAME_SIZE) ||
  500. (maximumFrameSize > IX_ETHDB_MAX_NPE_FRAME_SIZE))
  501. {
  502. return IX_ETH_DB_INVALID_ARG;
  503. }
  504. }
  505. else
  506. {
  507. return IX_ETH_DB_NO_PERMISSION;
  508. }
  509. /* update internal structure */
  510. ixEthDBPortInfo[portID].maxRxFrameSize = maximumFrameSize;
  511. ixEthDBPortInfo[portID].maxTxFrameSize = maximumFrameSize;
  512. /* update the maximum frame size in the NPE */
  513. return ixEthDBPortFrameLengthsUpdate(portID);
  514. }
  515. /**
  516. * @brief sets the MAC address of an NPE port
  517. *
  518. * @param portID port ID to set the MAC address on
  519. * @param macAddr pointer to the 6-byte MAC address
  520. *
  521. * This function is called by the EthAcc
  522. * ixEthAccUnicastMacAddressSet() and should not be
  523. * manually invoked unless required by special circumstances.
  524. *
  525. * @return IX_ETH_DB_SUCCESS if the operation succeeded
  526. * or an appropriate error message otherwise
  527. */
  528. IX_ETH_DB_PUBLIC
  529. IxEthDBStatus ixEthDBPortAddressSet(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
  530. {
  531. IxNpeMhMessage message;
  532. IxOsalMutex *ackPortAddressLock;
  533. IX_STATUS result;
  534. /* use this macro instead CHECK_PORT
  535. as the port doesn't need to be enabled */
  536. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  537. IX_ETH_DB_CHECK_REFERENCE(macAddr);
  538. if (!ixEthDBPortInfo[portID].initialized)
  539. {
  540. return IX_ETH_DB_PORT_UNINITIALIZED;
  541. }
  542. ackPortAddressLock = &ixEthDBPortInfo[portID].npeAckLock;
  543. /* Operation stops here when Ethernet Learning is not enabled */
  544. if(IX_FEATURE_CTRL_SWCONFIG_DISABLED ==
  545. ixFeatureCtrlSwConfigurationCheck(IX_FEATURECTRL_ETH_LEARNING))
  546. {
  547. return IX_ETH_DB_SUCCESS;
  548. }
  549. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  550. /* exit if the port is not an Ethernet NPE */
  551. if (ixEthDBPortDefinitions[portID].type != IX_ETH_NPE)
  552. {
  553. return IX_ETH_DB_INVALID_PORT;
  554. }
  555. /* populate message */
  556. FILL_SETPORTADDRESS_MSG(message, portID, macAddr->macAddress);
  557. IX_ETH_DB_SUPPORT_TRACE("DB: (Support) Sending SetPortAddress on port %d...\n", portID);
  558. /* send a SetPortAddress message */
  559. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  560. if (result == IX_SUCCESS)
  561. {
  562. ixEthDBPortInfo[portID].macAddressUploaded = TRUE;
  563. }
  564. return result;
  565. }