IxEthDBFeatures.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /**
  2. * @file IxEthDBFeatures.c
  3. *
  4. * @brief Implementation of the EthDB feature control API
  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 "IxNpeDl.h"
  21. #include "IxEthDBQoS.h"
  22. #include "IxEthDB_p.h"
  23. /**
  24. * @brief scans the capabilities of the loaded NPE images
  25. *
  26. * This function MUST be called by the ixEthDBInit() function.
  27. * No EthDB features (including learning and filtering) are enabled
  28. * before this function is called.
  29. *
  30. * @return none
  31. *
  32. * @internal
  33. */
  34. IX_ETH_DB_PUBLIC
  35. void ixEthDBFeatureCapabilityScan(void)
  36. {
  37. IxNpeDlImageId imageId, npeAImageId;
  38. IxEthDBPortId portIndex;
  39. PortInfo *portInfo;
  40. IxEthDBPriorityTable defaultPriorityTable;
  41. IX_STATUS result;
  42. UINT32 queueIndex;
  43. UINT32 queueStructureIndex;
  44. UINT32 trafficClassDefinitionIndex;
  45. /* read version of NPE A - required to set the AQM queues for B and C */
  46. npeAImageId.functionalityId = 0;
  47. ixNpeDlLoadedImageGet(IX_NPEDL_NPEID_NPEA, &npeAImageId);
  48. for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)
  49. {
  50. IxNpeMhMessage msg;
  51. portInfo = &ixEthDBPortInfo[portIndex];
  52. /* check and bypass if NPE B or C is fused out */
  53. if (ixEthDBSingleEthNpeCheck(portIndex) != IX_ETH_DB_SUCCESS) continue;
  54. /* all ports are capable of LEARNING by default */
  55. portInfo->featureCapability |= IX_ETH_DB_LEARNING;
  56. portInfo->featureStatus |= IX_ETH_DB_LEARNING;
  57. if (ixEthDBPortDefinitions[portIndex].type == IX_ETH_NPE)
  58. {
  59. if (ixNpeDlLoadedImageGet(IX_ETH_DB_PORT_ID_TO_NPE(portIndex), &imageId) != IX_SUCCESS)
  60. {
  61. WARNING_LOG("DB: (FeatureScan) NpeDl did not provide the image ID for NPE port %d\n", portIndex);
  62. }
  63. else
  64. {
  65. /* initialize and empty NPE response mutex */
  66. ixOsalMutexInit(&portInfo->npeAckLock);
  67. ixOsalMutexLock(&portInfo->npeAckLock, IX_OSAL_WAIT_FOREVER);
  68. /* check NPE response to GetStatus */
  69. msg.data[0] = IX_ETHNPE_NPE_GETSTATUS << 24;
  70. msg.data[1] = 0;
  71. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portIndex), msg, result);
  72. if (result != IX_SUCCESS)
  73. {
  74. WARNING_LOG("DB: (FeatureScan) warning, could not send message to the NPE\n");
  75. continue;
  76. }
  77. if (imageId.functionalityId == 0x00
  78. || imageId.functionalityId == 0x03
  79. || imageId.functionalityId == 0x04
  80. || imageId.functionalityId == 0x80)
  81. {
  82. portInfo->featureCapability |= IX_ETH_DB_FILTERING;
  83. portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
  84. portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
  85. }
  86. else if (imageId.functionalityId == 0x01
  87. || imageId.functionalityId == 0x81)
  88. {
  89. portInfo->featureCapability |= IX_ETH_DB_FILTERING;
  90. portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
  91. portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
  92. portInfo->featureCapability |= IX_ETH_DB_VLAN_QOS;
  93. }
  94. else if (imageId.functionalityId == 0x02
  95. || imageId.functionalityId == 0x82)
  96. {
  97. portInfo->featureCapability |= IX_ETH_DB_WIFI_HEADER_CONVERSION;
  98. portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
  99. portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
  100. portInfo->featureCapability |= IX_ETH_DB_VLAN_QOS;
  101. }
  102. /* reset AQM queues */
  103. memset(portInfo->ixEthDBTrafficClassAQMAssignments, 0, sizeof (portInfo->ixEthDBTrafficClassAQMAssignments));
  104. /* ensure there's at least one traffic class record in the definition table, otherwise we have no default case, hence no queues */
  105. IX_ENSURE(sizeof (ixEthDBTrafficClassDefinitions) != 0, "DB: no traffic class definitions found, check IxEthDBQoS.h");
  106. /* find the traffic class definition index compatible with the current NPE A functionality ID */
  107. for (trafficClassDefinitionIndex = 0 ;
  108. trafficClassDefinitionIndex < ARRAY_SIZE(ixEthDBTrafficClassDefinitions);
  109. trafficClassDefinitionIndex++)
  110. {
  111. if (ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_NPE_A_FUNCTIONALITY_ID_INDEX] == npeAImageId.functionalityId)
  112. {
  113. /* found it */
  114. break;
  115. }
  116. }
  117. /* select the default case if we went over the array boundary */
  118. if (trafficClassDefinitionIndex == ARRAY_SIZE(ixEthDBTrafficClassDefinitions))
  119. {
  120. trafficClassDefinitionIndex = 0; /* the first record is the default case */
  121. }
  122. /* select queue assignment structure based on the traffic class configuration index */
  123. queueStructureIndex = ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_QUEUE_ASSIGNMENT_INDEX];
  124. /* only traffic class 0 is active at initialization time */
  125. portInfo->ixEthDBTrafficClassCount = 1;
  126. /* enable port, VLAN and Firewall feature bits to initialize QoS/VLAN/Firewall configuration */
  127. portInfo->featureStatus |= IX_ETH_DB_VLAN_QOS;
  128. portInfo->featureStatus |= IX_ETH_DB_FIREWALL;
  129. portInfo->enabled = true;
  130. #define CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
  131. #ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
  132. /* set VLAN initial configuration (permissive) */
  133. if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0) /* QoS-enabled image */
  134. {
  135. /* QoS capable */
  136. portInfo->ixEthDBTrafficClassAvailable = ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_TRAFFIC_CLASS_COUNT_INDEX];
  137. /* set AQM queues */
  138. for (queueIndex = 0 ; queueIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; queueIndex++)
  139. {
  140. portInfo->ixEthDBTrafficClassAQMAssignments[queueIndex] = ixEthDBQueueAssignments[queueStructureIndex][queueIndex];
  141. }
  142. /* set default PVID (0) and default traffic class 0 */
  143. ixEthDBPortVlanTagSet(portIndex, 0);
  144. /* enable reception of all frames */
  145. ixEthDBAcceptableFrameTypeSet(portIndex, IX_ETH_DB_ACCEPT_ALL_FRAMES);
  146. /* clear full VLAN membership */
  147. ixEthDBPortVlanMembershipRangeRemove(portIndex, 0, IX_ETH_DB_802_1Q_MAX_VLAN_ID);
  148. /* clear TTI table - no VLAN tagged frames will be transmitted */
  149. ixEthDBEgressVlanRangeTaggingEnabledSet(portIndex, 0, 4094, false);
  150. /* set membership on 0, otherwise no Tx or Rx is working */
  151. ixEthDBPortVlanMembershipAdd(portIndex, 0);
  152. }
  153. else /* QoS not available in this image */
  154. #endif /* test-only */
  155. {
  156. /* initialize traffic class availability (only class 0 is available) */
  157. portInfo->ixEthDBTrafficClassAvailable = 1;
  158. /* point all AQM queues to traffic class 0 */
  159. for (queueIndex = 0 ; queueIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; queueIndex++)
  160. {
  161. portInfo->ixEthDBTrafficClassAQMAssignments[queueIndex] =
  162. ixEthDBQueueAssignments[queueStructureIndex][0];
  163. }
  164. }
  165. #ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
  166. /* download priority mapping table and Rx queue configuration */
  167. memset (defaultPriorityTable, 0, sizeof (defaultPriorityTable));
  168. ixEthDBPriorityMappingTableSet(portIndex, defaultPriorityTable);
  169. #endif
  170. /* by default we turn off invalid source MAC address filtering */
  171. ixEthDBFirewallInvalidAddressFilterEnable(portIndex, false);
  172. /* disable port, VLAN, Firewall feature bits */
  173. portInfo->featureStatus &= ~IX_ETH_DB_VLAN_QOS;
  174. portInfo->featureStatus &= ~IX_ETH_DB_FIREWALL;
  175. portInfo->enabled = false;
  176. /* enable filtering by default if present */
  177. if ((portInfo->featureCapability & IX_ETH_DB_FILTERING) != 0)
  178. {
  179. portInfo->featureStatus |= IX_ETH_DB_FILTERING;
  180. }
  181. }
  182. }
  183. }
  184. }
  185. /**
  186. * @brief returns the capability of a port
  187. *
  188. * @param portID ID of the port
  189. * @param featureSet location to store the port capability in
  190. *
  191. * This function will save the capability set of the given port
  192. * into the given location. Capabilities are bit-ORed, each representing
  193. * a bit of the feature set.
  194. *
  195. * Note that this function is documented in the main component
  196. * public header file, IxEthDB.h.
  197. *
  198. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  199. * or IX_ETH_DB_INVALID_PORT if the given port is invalid
  200. */
  201. IX_ETH_DB_PUBLIC
  202. IxEthDBStatus ixEthDBFeatureCapabilityGet(IxEthDBPortId portID, IxEthDBFeature *featureSet)
  203. {
  204. IX_ETH_DB_CHECK_PORT_INITIALIZED(portID);
  205. IX_ETH_DB_CHECK_REFERENCE(featureSet);
  206. *featureSet = ixEthDBPortInfo[portID].featureCapability;
  207. return IX_ETH_DB_SUCCESS;
  208. }
  209. /**
  210. * @brief enables or disables a port capability
  211. *
  212. * @param portID ID of the port
  213. * @param feature feature to enable or disable
  214. * @param enabled true to enable the selected feature or false to disable it
  215. *
  216. * Note that this function is documented in the main component
  217. * header file, IxEthDB.h.
  218. *
  219. * @return IX_ETH_DB_SUCCESS if the operation completed
  220. * successfully or an appropriate error message otherwise
  221. */
  222. IX_ETH_DB_PUBLIC
  223. IxEthDBStatus ixEthDBFeatureEnable(IxEthDBPortId portID, IxEthDBFeature feature, BOOL enable)
  224. {
  225. PortInfo *portInfo;
  226. IxEthDBPriorityTable defaultPriorityTable;
  227. IxEthDBVlanSet vlanSet;
  228. IxEthDBStatus status = IX_ETH_DB_SUCCESS;
  229. BOOL portEnabled;
  230. IX_ETH_DB_CHECK_PORT_INITIALIZED(portID);
  231. portInfo = &ixEthDBPortInfo[portID];
  232. portEnabled = portInfo->enabled;
  233. /* check that only one feature is selected */
  234. if (!ixEthDBCheckSingleBitValue(feature))
  235. {
  236. return IX_ETH_DB_FEATURE_UNAVAILABLE;
  237. }
  238. /* port capable of this feature? */
  239. if ((portInfo->featureCapability & feature) == 0)
  240. {
  241. return IX_ETH_DB_FEATURE_UNAVAILABLE;
  242. }
  243. /* mutual exclusion between learning and WiFi header conversion */
  244. if (enable && ((feature | portInfo->featureStatus) & (IX_ETH_DB_FILTERING | IX_ETH_DB_WIFI_HEADER_CONVERSION))
  245. == (IX_ETH_DB_FILTERING | IX_ETH_DB_WIFI_HEADER_CONVERSION))
  246. {
  247. return IX_ETH_DB_NO_PERMISSION;
  248. }
  249. /* learning must be enabled before filtering */
  250. if (enable && (feature == IX_ETH_DB_FILTERING) && ((portInfo->featureStatus & IX_ETH_DB_LEARNING) == 0))
  251. {
  252. return IX_ETH_DB_NO_PERMISSION;
  253. }
  254. /* filtering must be disabled before learning */
  255. if (!enable && (feature == IX_ETH_DB_LEARNING) && ((portInfo->featureStatus & IX_ETH_DB_FILTERING) != 0))
  256. {
  257. return IX_ETH_DB_NO_PERMISSION;
  258. }
  259. /* redundant enabling or disabling */
  260. if ((!enable && ((portInfo->featureStatus & feature) == 0))
  261. || (enable && ((portInfo->featureStatus & feature) != 0)))
  262. {
  263. /* do nothing */
  264. return IX_ETH_DB_SUCCESS;
  265. }
  266. /* force port enabled */
  267. portInfo->enabled = true;
  268. if (enable)
  269. {
  270. /* turn on enable bit */
  271. portInfo->featureStatus |= feature;
  272. #ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
  273. /* if this is VLAN/QoS set the default priority table */
  274. if (feature == IX_ETH_DB_VLAN_QOS)
  275. {
  276. /* turn on VLAN/QoS (most permissive mode):
  277. - set default 802.1Q priority mapping table, in accordance to the
  278. availability of traffic classes
  279. - set the acceptable frame filter to accept all
  280. - set the Ingress tagging mode to pass-through
  281. - set full VLAN membership list
  282. - set full TTI table
  283. - set the default 802.1Q tag to 0 (VLAN ID 0, Pri 0, CFI 0)
  284. - enable TPID port extraction
  285. */
  286. portInfo->ixEthDBTrafficClassCount = portInfo->ixEthDBTrafficClassAvailable;
  287. /* set default 802.1Q priority mapping table - note that C indexing starts from 0, so we substract 1 here */
  288. memcpy (defaultPriorityTable,
  289. (const void *) ixEthIEEE802_1QUserPriorityToTrafficClassMapping[portInfo->ixEthDBTrafficClassCount - 1],
  290. sizeof (defaultPriorityTable));
  291. /* update priority mapping and AQM queue assignments */
  292. status = ixEthDBPriorityMappingTableSet(portID, defaultPriorityTable);
  293. if (status == IX_ETH_DB_SUCCESS)
  294. {
  295. status = ixEthDBAcceptableFrameTypeSet(portID, IX_ETH_DB_ACCEPT_ALL_FRAMES);
  296. }
  297. if (status == IX_ETH_DB_SUCCESS)
  298. {
  299. status = ixEthDBIngressVlanTaggingEnabledSet(portID, IX_ETH_DB_PASS_THROUGH);
  300. }
  301. /* set membership and TTI tables */
  302. memset (vlanSet, 0xFF, sizeof (vlanSet));
  303. if (status == IX_ETH_DB_SUCCESS)
  304. {
  305. /* use the internal function to bypass PVID check */
  306. status = ixEthDBPortVlanTableSet(portID, portInfo->vlanMembership, vlanSet);
  307. }
  308. if (status == IX_ETH_DB_SUCCESS)
  309. {
  310. /* use the internal function to bypass PVID check */
  311. status = ixEthDBPortVlanTableSet(portID, portInfo->transmitTaggingInfo, vlanSet);
  312. }
  313. /* reset the PVID */
  314. if (status == IX_ETH_DB_SUCCESS)
  315. {
  316. status = ixEthDBPortVlanTagSet(portID, 0);
  317. }
  318. /* enable TPID port extraction */
  319. if (status == IX_ETH_DB_SUCCESS)
  320. {
  321. status = ixEthDBVlanPortExtractionEnable(portID, true);
  322. }
  323. }
  324. else if (feature == IX_ETH_DB_FIREWALL)
  325. #endif
  326. {
  327. /* firewall starts in black-list mode unless otherwise configured before *
  328. * note that invalid source MAC address filtering is disabled by default */
  329. if (portInfo->firewallMode != IX_ETH_DB_FIREWALL_BLACK_LIST
  330. && portInfo->firewallMode != IX_ETH_DB_FIREWALL_WHITE_LIST)
  331. {
  332. status = ixEthDBFirewallModeSet(portID, IX_ETH_DB_FIREWALL_BLACK_LIST);
  333. if (status == IX_ETH_DB_SUCCESS)
  334. {
  335. status = ixEthDBFirewallInvalidAddressFilterEnable(portID, false);
  336. }
  337. }
  338. }
  339. if (status != IX_ETH_DB_SUCCESS)
  340. {
  341. /* checks failed, disable */
  342. portInfo->featureStatus &= ~feature;
  343. }
  344. }
  345. else
  346. {
  347. /* turn off features */
  348. if (feature == IX_ETH_DB_FIREWALL)
  349. {
  350. /* turning off the firewall is equivalent to:
  351. - set to black-list mode
  352. - clear all the entries and download the new table
  353. - turn off the invalid source address checking
  354. */
  355. status = ixEthDBDatabaseClear(portID, IX_ETH_DB_FIREWALL_RECORD);
  356. if (status == IX_ETH_DB_SUCCESS)
  357. {
  358. status = ixEthDBFirewallModeSet(portID, IX_ETH_DB_FIREWALL_BLACK_LIST);
  359. }
  360. if (status == IX_ETH_DB_SUCCESS)
  361. {
  362. status = ixEthDBFirewallInvalidAddressFilterEnable(portID, false);
  363. }
  364. if (status == IX_ETH_DB_SUCCESS)
  365. {
  366. status = ixEthDBFirewallTableDownload(portID);
  367. }
  368. }
  369. else if (feature == IX_ETH_DB_WIFI_HEADER_CONVERSION)
  370. {
  371. /* turn off header conversion */
  372. status = ixEthDBDatabaseClear(portID, IX_ETH_DB_WIFI_RECORD);
  373. if (status == IX_ETH_DB_SUCCESS)
  374. {
  375. status = ixEthDBWiFiConversionTableDownload(portID);
  376. }
  377. }
  378. #ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
  379. else if (feature == IX_ETH_DB_VLAN_QOS)
  380. {
  381. /* turn off VLAN/QoS:
  382. - set a priority mapping table with one traffic class
  383. - set the acceptable frame filter to accept all
  384. - set the Ingress tagging mode to pass-through
  385. - clear the VLAN membership list
  386. - clear the TTI table
  387. - set the default 802.1Q tag to 0 (VLAN ID 0, Pri 0, CFI 0)
  388. - disable TPID port extraction
  389. */
  390. /* initialize all => traffic class 0 priority mapping table */
  391. memset (defaultPriorityTable, 0, sizeof (defaultPriorityTable));
  392. portInfo->ixEthDBTrafficClassCount = 1;
  393. status = ixEthDBPriorityMappingTableSet(portID, defaultPriorityTable);
  394. if (status == IX_ETH_DB_SUCCESS)
  395. {
  396. status = ixEthDBAcceptableFrameTypeSet(portID, IX_ETH_DB_ACCEPT_ALL_FRAMES);
  397. }
  398. if (status == IX_ETH_DB_SUCCESS)
  399. {
  400. status = ixEthDBIngressVlanTaggingEnabledSet(portID, IX_ETH_DB_PASS_THROUGH);
  401. }
  402. /* clear membership and TTI tables */
  403. memset (vlanSet, 0, sizeof (vlanSet));
  404. if (status == IX_ETH_DB_SUCCESS)
  405. {
  406. /* use the internal function to bypass PVID check */
  407. status = ixEthDBPortVlanTableSet(portID, portInfo->vlanMembership, vlanSet);
  408. }
  409. if (status == IX_ETH_DB_SUCCESS)
  410. {
  411. /* use the internal function to bypass PVID check */
  412. status = ixEthDBPortVlanTableSet(portID, portInfo->transmitTaggingInfo, vlanSet);
  413. }
  414. /* reset the PVID */
  415. if (status == IX_ETH_DB_SUCCESS)
  416. {
  417. status = ixEthDBPortVlanTagSet(portID, 0);
  418. }
  419. /* disable TPID port extraction */
  420. if (status == IX_ETH_DB_SUCCESS)
  421. {
  422. status = ixEthDBVlanPortExtractionEnable(portID, false);
  423. }
  424. }
  425. #endif
  426. if (status == IX_ETH_DB_SUCCESS)
  427. {
  428. /* checks passed, disable */
  429. portInfo->featureStatus &= ~feature;
  430. }
  431. }
  432. /* restore port enabled state */
  433. portInfo->enabled = portEnabled;
  434. return status;
  435. }
  436. /**
  437. * @brief returns the status of a feature
  438. *
  439. * @param portID port ID
  440. * @param present location to store a boolean value indicating
  441. * if the feature is present (true) or not (false)
  442. * @param enabled location to store a booleam value indicating
  443. * if the feature is present (true) or not (false)
  444. *
  445. * Note that this function is documented in the main component
  446. * header file, IxEthDB.h.
  447. *
  448. * @return IX_ETH_DB_SUCCESS if the operation completed
  449. * successfully or an appropriate error message otherwise
  450. */
  451. IX_ETH_DB_PUBLIC
  452. IxEthDBStatus ixEthDBFeatureStatusGet(IxEthDBPortId portID, IxEthDBFeature feature, BOOL *present, BOOL *enabled)
  453. {
  454. PortInfo *portInfo;
  455. IX_ETH_DB_CHECK_PORT(portID);
  456. IX_ETH_DB_CHECK_REFERENCE(present);
  457. IX_ETH_DB_CHECK_REFERENCE(enabled);
  458. portInfo = &ixEthDBPortInfo[portID];
  459. *present = (portInfo->featureCapability & feature) != 0;
  460. *enabled = (portInfo->featureStatus & feature) != 0;
  461. return IX_ETH_DB_SUCCESS;
  462. }
  463. /**
  464. * @brief returns the value of an EthDB property
  465. *
  466. * @param portID ID of the port
  467. * @param feature feature owning the property
  468. * @param property ID of the property
  469. * @param type location to store the property type into
  470. * @param value location to store the property value into
  471. *
  472. * Note that this function is documented in the main component
  473. * header file, IxEthDB.h.
  474. *
  475. * @return IX_ETH_DB_SUCCESS if the operation completed
  476. * successfully or an appropriate error message otherwise
  477. */
  478. IX_ETH_DB_PUBLIC
  479. IxEthDBStatus ixEthDBFeaturePropertyGet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, IxEthDBPropertyType *type, void *value)
  480. {
  481. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  482. IX_ETH_DB_CHECK_REFERENCE(type);
  483. IX_ETH_DB_CHECK_REFERENCE(value);
  484. if (feature == IX_ETH_DB_VLAN_QOS)
  485. {
  486. if (property == IX_ETH_DB_QOS_TRAFFIC_CLASS_COUNT_PROPERTY)
  487. {
  488. * (UINT32 *) value = ixEthDBPortInfo[portID].ixEthDBTrafficClassCount;
  489. *type = IX_ETH_DB_INTEGER_PROPERTY;
  490. return IX_ETH_DB_SUCCESS;
  491. }
  492. else if (property >= IX_ETH_DB_QOS_TRAFFIC_CLASS_0_RX_QUEUE_PROPERTY
  493. && property <= IX_ETH_DB_QOS_TRAFFIC_CLASS_7_RX_QUEUE_PROPERTY)
  494. {
  495. UINT32 classDelta = property - IX_ETH_DB_QOS_TRAFFIC_CLASS_0_RX_QUEUE_PROPERTY;
  496. if (classDelta >= ixEthDBPortInfo[portID].ixEthDBTrafficClassCount)
  497. {
  498. return IX_ETH_DB_FAIL;
  499. }
  500. * (UINT32 *) value = ixEthDBPortInfo[portID].ixEthDBTrafficClassAQMAssignments[classDelta];
  501. *type = IX_ETH_DB_INTEGER_PROPERTY;
  502. return IX_ETH_DB_SUCCESS;
  503. }
  504. }
  505. return IX_ETH_DB_INVALID_ARG;
  506. }
  507. /**
  508. * @brief sets the value of an EthDB property
  509. *
  510. * @param portID ID of the port
  511. * @param feature feature owning the property
  512. * @param property ID of the property
  513. * @param value location containing the property value
  514. *
  515. * This function implements a private property intended
  516. * only for EthAcc usage. Upon setting the IX_ETH_DB_QOS_QUEUE_CONFIGURATION_COMPLETE
  517. * property (the value is ignored), the availability of traffic classes is
  518. * frozen to whatever traffic class structure is currently in use.
  519. * This means that if VLAN_QOS has been enabled before EthAcc
  520. * initialization then all the defined traffic classes will be available;
  521. * otherwise only one traffic class (0) will be available.
  522. *
  523. * Note that this function is documented in the main component
  524. * header file, IxEthDB.h as not accepting any parameters. The
  525. * current implementation is only intended for the private use of EthAcc.
  526. *
  527. * Also note that once this function is called the effect is irreversible,
  528. * unless EthDB is complete unloaded and re-initialized.
  529. *
  530. * @return IX_ETH_DB_INVALID_ARG (no read-write properties are
  531. * supported in this release)
  532. */
  533. IX_ETH_DB_PUBLIC
  534. IxEthDBStatus ixEthDBFeaturePropertySet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, void *value)
  535. {
  536. IX_ETH_DB_CHECK_PORT_EXISTS(portID);
  537. if ((feature == IX_ETH_DB_VLAN_QOS) && (property == IX_ETH_DB_QOS_QUEUE_CONFIGURATION_COMPLETE))
  538. {
  539. ixEthDBPortInfo[portID].ixEthDBTrafficClassAvailable = ixEthDBPortInfo[portID].ixEthDBTrafficClassCount;
  540. return IX_ETH_DB_SUCCESS;
  541. }
  542. return IX_ETH_DB_INVALID_ARG;
  543. }