IxEthDBAPISupport.c 19 KB

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