IxEthDBFeatures.c 25 KB

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