IxEthDBVlan.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. /**
  2. * @file IxEthDBVlan.c
  3. *
  4. * @brief Implementation of the VLAN 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 "IxEthDB.h"
  45. #include "IxEthDB_p.h"
  46. /* forward prototypes */
  47. IX_ETH_DB_PUBLIC
  48. IxEthDBStatus ixEthDBUpdateTrafficClass(IxEthDBPortId portID, UINT32 classIndex);
  49. IX_ETH_DB_PUBLIC
  50. IxEthDBStatus ixEthDBVlanTableGet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet);
  51. /* contants used by various functions as "action" parameter */
  52. #define ADD_VLAN (0x1)
  53. #define REMOVE_VLAN (0x2)
  54. /**
  55. * @brief adds or removes a VLAN from a VLAN set
  56. *
  57. * @param vlanID VLAN ID to add or remove
  58. * @param table VLAN set to add into or remove from
  59. * @param action ADD_VLAN or REMOVE_VLAN
  60. *
  61. * @internal
  62. */
  63. IX_ETH_DB_PRIVATE
  64. void ixEthDBLocalVlanMembershipChange(UINT32 vlanID, IxEthDBVlanSet table, UINT32 action)
  65. {
  66. UINT32 setOffset;
  67. /* add/remove VID to membership table */
  68. setOffset = VLAN_SET_OFFSET(vlanID); /* we need 9 bits to index the 512 byte membership array */
  69. if (action == ADD_VLAN)
  70. {
  71. table[setOffset] |= 1 << VLAN_SET_MASK(vlanID);
  72. }
  73. else if (action == REMOVE_VLAN)
  74. {
  75. table[setOffset] &= ~(1 << VLAN_SET_MASK(vlanID));
  76. }
  77. }
  78. /**
  79. * @brief updates a set of 8 VLANs in an NPE
  80. *
  81. * @param portID ID of the port
  82. * @param setOffset offset of the 8 VLANs
  83. *
  84. * This function updates the VLAN membership table
  85. * and Transmit Tagging Info table for 8 consecutive
  86. * VLAN IDs indexed by setOffset.
  87. *
  88. * For example, a setOffset of 0 indexes VLAN IDs 0
  89. * through 7, 1 indexes VLAN IDs 8 through 9 etc.
  90. *
  91. * @return IX_ETH_DB_SUCCESS if the operation completed
  92. * successfully or an appropriate error message otherwise
  93. *
  94. * @internal
  95. */
  96. IX_ETH_DB_PRIVATE
  97. IxEthDBStatus ixEthDBVlanTableEntryUpdate(IxEthDBPortId portID, UINT32 setOffset)
  98. {
  99. PortInfo *portInfo = &ixEthDBPortInfo[portID];
  100. IxNpeMhMessage message;
  101. IX_STATUS result;
  102. FILL_SETPORTVLANTABLEENTRY_MSG(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID),
  103. 2 * setOffset,
  104. portInfo->vlanMembership[setOffset],
  105. portInfo->transmitTaggingInfo[setOffset]);
  106. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  107. return result;
  108. }
  109. /**
  110. * @brief updates a VLAN range in an NPE
  111. *
  112. * @param portID ID of the port
  113. *
  114. * This function is similar to @ref ixEthDBVlanTableEntryUpdate
  115. * except that it can update more than one VLAN set (up to
  116. * the entire VLAN membership and TTI tables if the offset is 0
  117. * and length is sizeof (IxEthDBVlanSet) (512 bytes).
  118. *
  119. * Updating the NPE via this method is slower as it requires
  120. * a memory copy from SDRAM, hence it is recommended that the
  121. * ixEthDBVlanTableEntryUpdate function is used where possible.
  122. *
  123. * @return IX_ETH_DB_SUCCESS if the operation completed
  124. * successfully or an appropriate error message otherwise
  125. *
  126. * @internal
  127. */
  128. IX_ETH_DB_PRIVATE
  129. IxEthDBStatus ixEthDBVlanTableRangeUpdate(IxEthDBPortId portID)
  130. {
  131. PortInfo *portInfo = &ixEthDBPortInfo[portID];
  132. UINT8 *vlanUpdateZone = (UINT8 *) portInfo->updateMethod.vlanUpdateZone;
  133. IxNpeMhMessage message;
  134. UINT32 setIndex;
  135. IX_STATUS result;
  136. /* copy membership info and transmit tagging into into exchange area */
  137. for (setIndex = 0 ; setIndex < sizeof (portInfo->vlanMembership) ; setIndex++)
  138. {
  139. /* membership and TTI data are interleaved */
  140. vlanUpdateZone[setIndex * 2] = portInfo->vlanMembership[setIndex];
  141. vlanUpdateZone[setIndex * 2 + 1] = portInfo->transmitTaggingInfo[setIndex];
  142. }
  143. IX_OSAL_CACHE_FLUSH(vlanUpdateZone, FULL_VLAN_BYTE_SIZE);
  144. /* build NPE message */
  145. FILL_SETPORTVLANTABLERANGE_MSG(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID), 0, 0,
  146. IX_OSAL_MMU_VIRT_TO_PHYS(vlanUpdateZone));
  147. /* send message */
  148. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  149. return result;
  150. }
  151. /**
  152. * @brief adds or removes a VLAN from a port's VLAN membership table
  153. * or Transmit Tagging Information table
  154. *
  155. * @param portID ID of the port
  156. * @param vlanID VLAN ID to add or remove
  157. * @param table to add or remove from
  158. * @param action ADD_VLAN or REMOVE_VLAN
  159. *
  160. * @return IX_ETH_DB_SUCCESS if the operation completed
  161. * successfully or an appropriate error message otherwise
  162. *
  163. * @internal
  164. */
  165. IX_ETH_DB_PRIVATE
  166. IxEthDBStatus ixEthDBPortVlanMembershipChange(IxEthDBPortId portID, IxEthDBVlanId vlanID, IxEthDBVlanSet table, UINT32 action)
  167. {
  168. /* change VLAN in local membership table */
  169. ixEthDBLocalVlanMembershipChange(vlanID, table, action);
  170. /* send updated entry to NPE */
  171. return ixEthDBVlanTableEntryUpdate(portID, VLAN_SET_OFFSET(vlanID));
  172. }
  173. /**
  174. * @brief sets the default port VLAN tag (the lower 3 bytes are the PVID)
  175. *
  176. * @param portID ID of the port
  177. * @param vlanTag port VLAN tag (802.1Q tag)
  178. *
  179. * Note that this function is documented in the main component
  180. * header file, IxEthDB.h.
  181. *
  182. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  183. * or an appropriate error message otherwise
  184. */
  185. IX_ETH_DB_PUBLIC
  186. IxEthDBStatus ixEthDBPortVlanTagSet(IxEthDBPortId portID, IxEthDBVlanTag vlanTag)
  187. {
  188. IxNpeMhMessage message;
  189. IX_STATUS result;
  190. IX_ETH_DB_CHECK_PORT(portID);
  191. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  192. IX_ETH_DB_CHECK_VLAN_TAG(vlanTag);
  193. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  194. /* add VLAN ID to local membership table */
  195. ixEthDBPortVlanMembershipChange(portID,
  196. vlanTag & IX_ETH_DB_802_1Q_VLAN_MASK,
  197. ixEthDBPortInfo[portID].vlanMembership,
  198. ADD_VLAN);
  199. /* set tag in portInfo */
  200. ixEthDBPortInfo[portID].vlanTag = vlanTag;
  201. /* build VLAN_SetDefaultRxVID message */
  202. FILL_SETDEFAULTRXVID_MSG(message,
  203. IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID),
  204. IX_IEEE802_1Q_VLAN_TPID,
  205. vlanTag);
  206. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  207. return result;
  208. }
  209. /**
  210. * @brief retrieves the default port VLAN tag (the lower 3 bytes are the PVID)
  211. *
  212. * @param portID ID of the port
  213. * @param vlanTag address to write the port VLAN tag (802.1Q tag) into
  214. *
  215. * Note that this function is documented in the main component
  216. * header file, IxEthDB.h.
  217. *
  218. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  219. * or an appropriate error message otherwise
  220. */
  221. IX_ETH_DB_PUBLIC
  222. IxEthDBStatus ixEthDBPortVlanTagGet(IxEthDBPortId portID, IxEthDBVlanTag *vlanTag)
  223. {
  224. IX_ETH_DB_CHECK_PORT(portID);
  225. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  226. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  227. IX_ETH_DB_CHECK_REFERENCE(vlanTag);
  228. *vlanTag = ixEthDBPortInfo[portID].vlanTag;
  229. return IX_ETH_DB_SUCCESS;
  230. }
  231. /**
  232. * @brief sets the VLAN tag (the lower 3 bytes are the PVID) of a
  233. * database filtering record
  234. *
  235. * @param portID ID of the port
  236. * @param vlanTag VLAN tag (802.1Q tag)
  237. *
  238. * Important: filtering records are automatically converted to
  239. * IX_ETH_DB_FILTERING_VLAN record when added a VLAN tag.
  240. *
  241. * Note that this function is documented in the main component
  242. * header file, IxEthDB.h.
  243. *
  244. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  245. * or an appropriate error message otherwise
  246. */
  247. IX_ETH_DB_PUBLIC
  248. IxEthDBStatus ixEthDBVlanTagSet(IxEthDBMacAddr *macAddr, IxEthDBVlanTag vlanTag)
  249. {
  250. HashNode *searchResult;
  251. MacDescriptor *descriptor;
  252. IX_ETH_DB_CHECK_REFERENCE(macAddr);
  253. IX_ETH_DB_CHECK_VLAN_TAG(vlanTag);
  254. searchResult = ixEthDBSearch(macAddr, IX_ETH_DB_ALL_FILTERING_RECORDS);
  255. if (searchResult == NULL)
  256. {
  257. return IX_ETH_DB_NO_SUCH_ADDR;
  258. }
  259. descriptor = (MacDescriptor *) searchResult->data;
  260. /* set record type to VLAN if not already set */
  261. descriptor->type = IX_ETH_DB_FILTERING_VLAN_RECORD;
  262. /* add vlan tag */
  263. descriptor->recordData.filteringVlanData.ieee802_1qTag = vlanTag;
  264. /* transaction completed */
  265. ixEthDBReleaseHashNode(searchResult);
  266. return IX_ETH_DB_SUCCESS;
  267. }
  268. /**
  269. * @brief retrieves the VLAN tag (the lower 3 bytes are the PVID) from a
  270. * database VLAN filtering record
  271. *
  272. * @param portID ID of the port
  273. * @param vlanTag address to write the VLAN tag (802.1Q tag) into
  274. *
  275. * Note that this function is documented in the main component
  276. * header file, IxEthDB.h.
  277. *
  278. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  279. * or an appropriate error message otherwise
  280. */
  281. IX_ETH_DB_PUBLIC
  282. IxEthDBStatus ixEthDBVlanTagGet(IxEthDBMacAddr *macAddr, IxEthDBVlanTag *vlanTag)
  283. {
  284. HashNode *searchResult;
  285. MacDescriptor *descriptor;
  286. IX_ETH_DB_CHECK_REFERENCE(macAddr);
  287. IX_ETH_DB_CHECK_REFERENCE(vlanTag);
  288. searchResult = ixEthDBSearch(macAddr, IX_ETH_DB_FILTERING_VLAN_RECORD);
  289. if (searchResult == NULL)
  290. {
  291. return IX_ETH_DB_NO_SUCH_ADDR;
  292. }
  293. descriptor = (MacDescriptor *) searchResult->data;
  294. /* get vlan tag */
  295. *vlanTag = descriptor->recordData.filteringVlanData.ieee802_1qTag;
  296. /* transaction completed */
  297. ixEthDBReleaseHashNode(searchResult);
  298. return IX_ETH_DB_SUCCESS;
  299. }
  300. /**
  301. * @brief adds a VLAN to a port's VLAN membership table
  302. *
  303. * @param portID ID of the port
  304. * @param vlanID VLAN ID to add
  305. *
  306. * Note that this function is documented in the main component
  307. * header file, IxEthDB.h.
  308. *
  309. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  310. * or an appropriate error message otherwise
  311. */
  312. IX_ETH_DB_PUBLIC
  313. IxEthDBStatus ixEthDBPortVlanMembershipAdd(IxEthDBPortId portID, IxEthDBVlanId vlanID)
  314. {
  315. IX_ETH_DB_CHECK_PORT(portID);
  316. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  317. IX_ETH_DB_CHECK_VLAN_ID(vlanID);
  318. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  319. return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].vlanMembership, ADD_VLAN);
  320. }
  321. /**
  322. * @brief removes a VLAN from a port's VLAN membership table
  323. *
  324. * @param portID ID of the port
  325. * @param vlanID VLAN ID to remove
  326. *
  327. * Note that this function is documented in the main component
  328. * header file, IxEthDB.h.
  329. *
  330. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  331. * or an appropriate error message otherwise
  332. */
  333. IX_ETH_DB_PUBLIC
  334. IxEthDBStatus ixEthDBPortVlanMembershipRemove(IxEthDBPortId portID, IxEthDBVlanId vlanID)
  335. {
  336. IX_ETH_DB_CHECK_PORT(portID);
  337. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  338. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  339. IX_ETH_DB_CHECK_VLAN_ID(vlanID);
  340. /* for safety isolate only the VLAN ID in the tag (the lower 12 bits) */
  341. vlanID = vlanID & IX_ETH_DB_802_1Q_VLAN_MASK;
  342. /* check we're not asked to remove the default port VID */
  343. if (vlanID == IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag))
  344. {
  345. return IX_ETH_DB_NO_PERMISSION;
  346. }
  347. return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].vlanMembership, REMOVE_VLAN);
  348. }
  349. /**
  350. * @brief adds or removes a VLAN range from a port's
  351. * VLAN membership table or TTI table
  352. *
  353. * @param portID ID of the port
  354. * @param vlanIDMin start of the VLAN range
  355. * @param vlanIDMax end of the VLAN range
  356. * @param table VLAN set to add or remove from
  357. * @param action ADD_VLAN or REMOVE_VLAN
  358. *
  359. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  360. * or an appropriate error message otherwise
  361. *
  362. * @internal
  363. */
  364. IX_ETH_DB_PRIVATE
  365. IxEthDBStatus ixEthDBPortVlanMembershipRangeChange(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax, IxEthDBVlanSet table, UINT32 action)
  366. {
  367. UINT32 setOffsetMin, setOffsetMax;
  368. IX_ETH_DB_CHECK_PORT(portID);
  369. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  370. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  371. IX_ETH_DB_CHECK_VLAN_ID(vlanIDMin);
  372. IX_ETH_DB_CHECK_VLAN_ID(vlanIDMax);
  373. /* for safety isolate only the VLAN ID in the tags (the lower 12 bits) */
  374. vlanIDMin = vlanIDMin & IX_ETH_DB_802_1Q_VLAN_MASK;
  375. vlanIDMax = vlanIDMax & IX_ETH_DB_802_1Q_VLAN_MASK;
  376. /* is this a range? */
  377. if (vlanIDMax < vlanIDMin)
  378. {
  379. return IX_ETH_DB_INVALID_VLAN;
  380. }
  381. /* check that we're not specifically asked to remove the default port VID */
  382. if (action == REMOVE_VLAN && vlanIDMax == vlanIDMin && IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag) == vlanIDMin)
  383. {
  384. return IX_ETH_DB_NO_PERMISSION;
  385. }
  386. /* compute set offsets */
  387. setOffsetMin = VLAN_SET_OFFSET(vlanIDMin);
  388. setOffsetMax = VLAN_SET_OFFSET(vlanIDMax);
  389. /* change VLAN range */
  390. for (; vlanIDMin <= vlanIDMax ; vlanIDMin++)
  391. {
  392. /* change vlan in local membership table */
  393. ixEthDBLocalVlanMembershipChange(vlanIDMin, table, action);
  394. }
  395. /* if the range is within one set (max 8 VLANs in one table byte) we can just update that entry in the NPE */
  396. if (setOffsetMin == setOffsetMax)
  397. {
  398. /* send updated entry to NPE */
  399. return ixEthDBVlanTableEntryUpdate(portID, setOffsetMin);
  400. }
  401. else
  402. {
  403. /* update a zone of the membership/transmit tag info table */
  404. return ixEthDBVlanTableRangeUpdate(portID);
  405. }
  406. }
  407. /**
  408. * @brief adds a VLAN range to a port's VLAN membership table
  409. *
  410. * @param portID ID of the port
  411. * @param vlanIDMin start of the VLAN range
  412. * @param vlanIDMax end of the VLAN range
  413. *
  414. * Note that this function is documented in the main component
  415. * header file, IxEthDB.h.
  416. *
  417. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  418. * or an appropriate error message otherwise
  419. */
  420. IX_ETH_DB_PUBLIC
  421. IxEthDBStatus ixEthDBPortVlanMembershipRangeAdd(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax)
  422. {
  423. IX_ETH_DB_CHECK_PORT(portID);
  424. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  425. return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].vlanMembership, ADD_VLAN);
  426. }
  427. /**
  428. * @brief removes a VLAN range from a port's VLAN membership table
  429. *
  430. * @param portID ID of the port
  431. * @param vlanIDMin start of the VLAN range
  432. * @param vlanIDMax end of the VLAN range
  433. *
  434. * Note that this function is documented in the main component
  435. * header file, IxEthDB.h.
  436. *
  437. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  438. * or an appropriate error message otherwise
  439. */
  440. IX_ETH_DB_PUBLIC
  441. IxEthDBStatus ixEthDBPortVlanMembershipRangeRemove(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax)
  442. {
  443. IX_ETH_DB_CHECK_PORT(portID);
  444. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  445. return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].vlanMembership, REMOVE_VLAN);
  446. }
  447. /**
  448. * @brief sets a port's VLAN membership table or TTI table and
  449. * updates the NPE VLAN configuration
  450. *
  451. * @param portID ID of the port
  452. * @param portVlanTable port VLAN table to set
  453. * @param vlanSet new set contents
  454. *
  455. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  456. * or an appropriate error message otherwise
  457. *
  458. * @internal
  459. */
  460. IX_ETH_DB_PUBLIC
  461. IxEthDBStatus ixEthDBPortVlanTableSet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet)
  462. {
  463. IX_ETH_DB_CHECK_PORT(portID);
  464. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  465. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  466. IX_ETH_DB_CHECK_REFERENCE(vlanSet);
  467. memcpy(portVlanTable, vlanSet, sizeof (IxEthDBVlanSet));
  468. return ixEthDBVlanTableRangeUpdate(portID);
  469. }
  470. /**
  471. * @brief retireves a port's VLAN membership table or TTI table
  472. *
  473. * @param portID ID of the port
  474. * @param portVlanTable port VLAN table to retrieve
  475. * @param vlanSet address to
  476. *
  477. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  478. * or an appropriate error message otherwise
  479. *
  480. * @internal
  481. */
  482. IX_ETH_DB_PUBLIC
  483. IxEthDBStatus ixEthDBVlanTableGet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet)
  484. {
  485. IX_ETH_DB_CHECK_PORT(portID);
  486. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  487. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  488. IX_ETH_DB_CHECK_REFERENCE(vlanSet);
  489. memcpy(vlanSet, portVlanTable, sizeof (IxEthDBVlanSet));
  490. return IX_ETH_DB_SUCCESS;
  491. }
  492. /**
  493. * @brief sets a port's VLAN membership table
  494. *
  495. * @param portID ID of the port
  496. * @param vlanSet new VLAN membership table
  497. *
  498. * Note that this function is documented in the main component
  499. * header file, IxEthDB.h.
  500. *
  501. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  502. * or an appropriate error message otherwise
  503. */
  504. IX_ETH_DB_PUBLIC
  505. IxEthDBStatus ixEthDBPortVlanMembershipSet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
  506. {
  507. IxEthDBVlanId vlanID;
  508. IX_ETH_DB_CHECK_PORT(portID);
  509. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  510. IX_ETH_DB_CHECK_REFERENCE(vlanSet);
  511. /* set the bit corresponding to the PVID just in case */
  512. vlanID = IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag);
  513. vlanSet[VLAN_SET_OFFSET(vlanID)] |= 1 << VLAN_SET_MASK(vlanID);
  514. return ixEthDBPortVlanTableSet(portID, ixEthDBPortInfo[portID].vlanMembership, vlanSet);
  515. }
  516. /**
  517. * @brief retrieves a port's VLAN membership table
  518. *
  519. * @param portID ID of the port
  520. * @param vlanSet location to store the port's VLAN membership table
  521. *
  522. * Note that this function is documented in the main component
  523. * header file, IxEthDB.h.
  524. *
  525. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  526. * or an appropriate error message otherwise
  527. */
  528. IX_ETH_DB_PUBLIC
  529. IxEthDBStatus ixEthDBPortVlanMembershipGet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
  530. {
  531. IX_ETH_DB_CHECK_PORT(portID);
  532. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  533. return ixEthDBVlanTableGet(portID, ixEthDBPortInfo[portID].vlanMembership, vlanSet);
  534. }
  535. /**
  536. * @brief enables or disables Egress tagging for one VLAN ID
  537. *
  538. * @param portID ID of the port
  539. * @param vlanID VLAN ID to enable or disable Egress tagging on
  540. * @param enabled TRUE to enable and FALSE to disable tagging
  541. *
  542. * Note that this function is documented in the main component
  543. * header file, IxEthDB.h.
  544. *
  545. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  546. * or an appropriate error message otherwise
  547. */
  548. IX_ETH_DB_PUBLIC
  549. IxEthDBStatus ixEthDBEgressVlanEntryTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanId vlanID, BOOL enabled)
  550. {
  551. IX_ETH_DB_CHECK_PORT(portID);
  552. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  553. IX_ETH_DB_CHECK_VLAN_ID(vlanID);
  554. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  555. return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].transmitTaggingInfo, enabled? ADD_VLAN : REMOVE_VLAN);
  556. }
  557. /**
  558. * @brief retrieves the Egress tagging status for one VLAN ID
  559. *
  560. * @param portID ID of the port
  561. * @param vlanID VLAN ID to retrieve the tagging status for
  562. * @param enabled location to store the tagging status
  563. * (TRUE - tagging enabled, FALSE - tagging disabled)
  564. *
  565. * Note that this function is documented in the main component
  566. * header file, IxEthDB.h.
  567. *
  568. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  569. * or an appropriate error message otherwise
  570. */
  571. IX_ETH_DB_PUBLIC
  572. IxEthDBStatus ixEthDBEgressVlanEntryTaggingEnabledGet(IxEthDBPortId portID, IxEthDBVlanId vlanID, BOOL *enabled)
  573. {
  574. IX_ETH_DB_CHECK_PORT(portID);
  575. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  576. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  577. IX_ETH_DB_CHECK_REFERENCE(enabled);
  578. IX_ETH_DB_CHECK_VLAN_ID(vlanID);
  579. *enabled = ((ixEthDBPortInfo[portID].transmitTaggingInfo[VLAN_SET_OFFSET(vlanID)] & (1 << VLAN_SET_MASK(vlanID))) != 0);
  580. return IX_ETH_DB_SUCCESS;
  581. }
  582. /**
  583. * @brief enables or disables Egress VLAN tagging for a VLAN range
  584. *
  585. * @param portID ID of the port
  586. * @param vlanIDMin start of VLAN range
  587. * @param vlanIDMax end of VLAN range
  588. * @param enabled TRUE to enable or FALSE to disable VLAN tagging
  589. *
  590. * Note that this function is documented in the main component
  591. * header file, IxEthDB.h.
  592. *
  593. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  594. * or an appropriate error message otherwise
  595. */
  596. IX_ETH_DB_PUBLIC
  597. IxEthDBStatus ixEthDBEgressVlanRangeTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax, BOOL enabled)
  598. {
  599. IX_ETH_DB_CHECK_PORT(portID);
  600. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  601. return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].transmitTaggingInfo, enabled? ADD_VLAN : REMOVE_VLAN);
  602. }
  603. /**
  604. * @brief sets the Egress VLAN tagging table (the Transmit Tagging
  605. * Information table)
  606. *
  607. * @param portID ID of the port
  608. * @param vlanSet new TTI table
  609. *
  610. * Note that this function is documented in the main component
  611. * header file, IxEthDB.h.
  612. *
  613. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  614. * or an appropriate error message otherwise
  615. */
  616. IX_ETH_DB_PUBLIC
  617. IxEthDBStatus ixEthDBEgressVlanTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
  618. {
  619. IxEthDBVlanId vlanID;
  620. IX_ETH_DB_CHECK_PORT(portID);
  621. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  622. IX_ETH_DB_CHECK_REFERENCE(vlanSet);
  623. /* set the PVID bit just in case */
  624. vlanID = IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag);
  625. vlanSet[VLAN_SET_OFFSET(vlanID)] |= 1 << VLAN_SET_MASK(vlanID);
  626. return ixEthDBPortVlanTableSet(portID, ixEthDBPortInfo[portID].transmitTaggingInfo, vlanSet);
  627. }
  628. /**
  629. * @brief retrieves the Egress VLAN tagging table (the Transmit
  630. * Tagging Information table)
  631. *
  632. * @param portID ID of the port
  633. * @param vlanSet location to store the port's TTI table
  634. *
  635. * Note that this function is documented in the main component
  636. * header file, IxEthDB.h.
  637. *
  638. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  639. * or an appropriate error message otherwise
  640. */
  641. IX_ETH_DB_PUBLIC
  642. IxEthDBStatus ixEthDBEgressVlanTaggingEnabledGet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
  643. {
  644. IX_ETH_DB_CHECK_PORT(portID);
  645. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  646. return ixEthDBVlanTableGet(portID, ixEthDBPortInfo[portID].transmitTaggingInfo, vlanSet);
  647. }
  648. /**
  649. * @brief sends the NPE the updated frame filter and default
  650. * Ingress tagging
  651. *
  652. * @param portID ID of the port
  653. *
  654. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  655. * or an appropriate error message otherwise
  656. *
  657. * @internal
  658. */
  659. IX_ETH_DB_PRIVATE
  660. IxEthDBStatus ixEthDBIngressVlanModeUpdate(IxEthDBPortId portID)
  661. {
  662. PortInfo *portInfo = &ixEthDBPortInfo[portID];
  663. IxNpeMhMessage message;
  664. IX_STATUS result;
  665. FILL_SETRXTAGMODE_MSG(message, portID, portInfo->npeFrameFilter, portInfo->npeTaggingAction);
  666. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  667. return result;
  668. }
  669. /**
  670. * @brief sets the default Ingress tagging behavior
  671. *
  672. * @param portID ID of the port
  673. * @param taggingAction default tagging behavior
  674. *
  675. * Note that this function is documented in the main component
  676. * header file, IxEthDB.h.
  677. *
  678. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  679. * or an appropriate error message otherwise
  680. */
  681. IX_ETH_DB_PUBLIC
  682. IxEthDBStatus ixEthDBIngressVlanTaggingEnabledSet(IxEthDBPortId portID, IxEthDBTaggingAction taggingAction)
  683. {
  684. PortInfo *portInfo;
  685. IX_ETH_DB_CHECK_PORT(portID);
  686. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  687. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  688. portInfo = &ixEthDBPortInfo[portID];
  689. if (taggingAction == IX_ETH_DB_PASS_THROUGH)
  690. {
  691. portInfo->npeTaggingAction = 0x00;
  692. }
  693. else if (taggingAction == IX_ETH_DB_ADD_TAG)
  694. {
  695. portInfo->npeTaggingAction = 0x02;
  696. }
  697. else if (taggingAction == IX_ETH_DB_REMOVE_TAG)
  698. {
  699. portInfo->npeTaggingAction = 0x01;
  700. }
  701. else
  702. {
  703. return IX_ETH_DB_INVALID_ARG;
  704. }
  705. portInfo->taggingAction = taggingAction;
  706. return ixEthDBIngressVlanModeUpdate(portID);
  707. }
  708. /**
  709. * @brief retrieves the default Ingress tagging behavior of a port
  710. *
  711. * @param portID ID of the port
  712. * @param taggingAction location to save the default tagging behavior
  713. *
  714. * Note that this function is documented in the main component
  715. * header file, IxEthDB.h.
  716. *
  717. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  718. * or an appropriate error message otherwise
  719. */
  720. IX_ETH_DB_PUBLIC
  721. IxEthDBStatus ixEthDBIngressVlanTaggingEnabledGet(IxEthDBPortId portID, IxEthDBTaggingAction *taggingAction)
  722. {
  723. IX_ETH_DB_CHECK_PORT(portID);
  724. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  725. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  726. IX_ETH_DB_CHECK_REFERENCE(taggingAction);
  727. *taggingAction = ixEthDBPortInfo[portID].taggingAction;
  728. return IX_ETH_DB_SUCCESS;
  729. }
  730. /**
  731. * @brief sets the Ingress acceptable frame type filter
  732. *
  733. * @param portID ID of the port
  734. * @param frameFilter acceptable frame type filter
  735. *
  736. * Note that this function is documented in the main component
  737. * header file, IxEthDB.h.
  738. *
  739. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  740. * or an appropriate error message otherwise
  741. */
  742. IX_ETH_DB_PUBLIC
  743. IxEthDBStatus ixEthDBAcceptableFrameTypeSet(IxEthDBPortId portID, IxEthDBFrameFilter frameFilter)
  744. {
  745. PortInfo *portInfo;
  746. IxEthDBStatus result = IX_ETH_DB_SUCCESS;
  747. IX_ETH_DB_CHECK_PORT(portID);
  748. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  749. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  750. /* check parameter range
  751. the ORed value of the valid values is 0x7
  752. a value having extra bits is invalid */
  753. if ((frameFilter | 0x7) != 0x7 || frameFilter == 0)
  754. {
  755. return IX_ETH_DB_INVALID_ARG;
  756. }
  757. portInfo = &ixEthDBPortInfo[portID];
  758. portInfo->frameFilter = frameFilter;
  759. portInfo->npeFrameFilter = 0; /* allow all by default */
  760. /* if accepting priority tagged but not all VLAN tagged
  761. set the membership table to contain only VLAN ID 0
  762. hence remove vlans 1-4094 and add VLAN ID 0 */
  763. if (((frameFilter & IX_ETH_DB_PRIORITY_TAGGED_FRAMES) != 0)
  764. && ((frameFilter & IX_ETH_DB_VLAN_TAGGED_FRAMES) == 0))
  765. {
  766. result = ixEthDBPortVlanMembershipRangeChange(portID,
  767. 1, IX_ETH_DB_802_1Q_MAX_VLAN_ID, portInfo->vlanMembership, REMOVE_VLAN);
  768. if (result == IX_ETH_DB_SUCCESS)
  769. {
  770. ixEthDBLocalVlanMembershipChange(0, portInfo->vlanMembership, ADD_VLAN);
  771. result = ixEthDBVlanTableRangeUpdate(portID);
  772. }
  773. }
  774. /* untagged only? */
  775. if (frameFilter == IX_ETH_DB_UNTAGGED_FRAMES)
  776. {
  777. portInfo->npeFrameFilter = 0x01;
  778. }
  779. /* tagged only? */
  780. if ((frameFilter & IX_ETH_DB_UNTAGGED_FRAMES) == 0)
  781. {
  782. portInfo->npeFrameFilter = 0x02;
  783. }
  784. if (result == IX_ETH_DB_SUCCESS)
  785. {
  786. result = ixEthDBIngressVlanModeUpdate(portID);
  787. }
  788. return result;
  789. }
  790. /**
  791. * @brief retrieves the acceptable frame type filter for a port
  792. *
  793. * @param portID ID of the port
  794. * @param frameFilter location to store the frame filter
  795. *
  796. * Note that this function is documented in the main component
  797. * header file, IxEthDB.h.
  798. *
  799. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  800. * or an appropriate error message otherwise
  801. */
  802. IX_ETH_DB_PUBLIC
  803. IxEthDBStatus ixEthDBAcceptableFrameTypeGet(IxEthDBPortId portID, IxEthDBFrameFilter *frameFilter)
  804. {
  805. IX_ETH_DB_CHECK_PORT(portID);
  806. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  807. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  808. IX_ETH_DB_CHECK_REFERENCE(frameFilter);
  809. *frameFilter = ixEthDBPortInfo[portID].frameFilter;
  810. return IX_ETH_DB_SUCCESS;
  811. }
  812. /**
  813. * @brief sends an NPE the updated configuration related
  814. * to one QoS priority (associated traffic class and AQM mapping)
  815. *
  816. * @param portID ID of the port
  817. * @param classIndex QoS priority (traffic class index)
  818. *
  819. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  820. * or an appropriate error message otherwise
  821. *
  822. * @internal
  823. */
  824. IX_ETH_DB_PUBLIC
  825. IxEthDBStatus ixEthDBUpdateTrafficClass(IxEthDBPortId portID, UINT32 classIndex)
  826. {
  827. IxNpeMhMessage message;
  828. IX_STATUS result;
  829. UINT32 trafficClass = ixEthDBPortInfo[portID].priorityTable[classIndex];
  830. UINT32 aqmQueue = ixEthDBPortInfo[portID].ixEthDBTrafficClassAQMAssignments[trafficClass];
  831. FILL_SETRXQOSENTRY(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID), classIndex, trafficClass, aqmQueue);
  832. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  833. return result;
  834. }
  835. /**
  836. * @brief sets the priority mapping table
  837. *
  838. * @param portID ID of the port
  839. * @param priorityTable new priority mapping table
  840. *
  841. * Note that this function is documented in the main component
  842. * header file, IxEthDB.h.
  843. *
  844. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  845. * or an appropriate error message otherwise
  846. */
  847. IX_ETH_DB_PUBLIC
  848. IxEthDBStatus ixEthDBPriorityMappingTableSet(IxEthDBPortId portID, IxEthDBPriorityTable priorityTable)
  849. {
  850. UINT32 classIndex;
  851. IX_ETH_DB_CHECK_PORT(portID);
  852. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  853. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  854. IX_ETH_DB_CHECK_REFERENCE(priorityTable);
  855. for (classIndex = 0 ; classIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; classIndex++)
  856. {
  857. /* check range */
  858. if (priorityTable[classIndex] >= ixEthDBPortInfo[portID].ixEthDBTrafficClassCount)
  859. {
  860. return IX_ETH_DB_INVALID_PRIORITY;
  861. }
  862. }
  863. /* set new traffic classes */
  864. for (classIndex = 0 ; classIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; classIndex++)
  865. {
  866. ixEthDBPortInfo[portID].priorityTable[classIndex] = priorityTable[classIndex];
  867. if (ixEthDBUpdateTrafficClass(portID, classIndex) != IX_ETH_DB_SUCCESS)
  868. {
  869. return IX_ETH_DB_FAIL;
  870. }
  871. }
  872. return IX_ETH_DB_SUCCESS;
  873. }
  874. /**
  875. * @brief retrieves a port's priority mapping table
  876. *
  877. * @param portID ID of the port
  878. * @param priorityTable location to store the priority table
  879. *
  880. * Note that this function is documented in the main component
  881. * header file, IxEthDB.h.
  882. *
  883. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  884. * or an appropriate error message otherwise
  885. */
  886. IX_ETH_DB_PUBLIC
  887. IxEthDBStatus ixEthDBPriorityMappingTableGet(IxEthDBPortId portID, IxEthDBPriorityTable priorityTable)
  888. {
  889. IX_ETH_DB_CHECK_PORT(portID);
  890. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  891. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  892. IX_ETH_DB_CHECK_REFERENCE(priorityTable);
  893. memcpy(priorityTable, ixEthDBPortInfo[portID].priorityTable, sizeof (IxEthDBPriorityTable));
  894. return IX_ETH_DB_SUCCESS;
  895. }
  896. /**
  897. * @brief sets one QoS priority => traffic class mapping
  898. *
  899. * @param portID ID of the port
  900. * @param userPriority QoS (user) priority
  901. * @param trafficClass associated traffic class
  902. *
  903. * Note that this function is documented in the main component
  904. * header file, IxEthDB.h.
  905. *
  906. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  907. * or an appropriate error message otherwise
  908. */
  909. IX_ETH_DB_PUBLIC
  910. IxEthDBStatus ixEthDBPriorityMappingClassSet(IxEthDBPortId portID, IxEthDBPriority userPriority, IxEthDBPriority trafficClass)
  911. {
  912. IX_ETH_DB_CHECK_PORT(portID);
  913. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  914. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  915. /* check ranges for userPriority and trafficClass */
  916. if (userPriority >= IX_IEEE802_1Q_QOS_PRIORITY_COUNT || trafficClass >= ixEthDBPortInfo[portID].ixEthDBTrafficClassCount)
  917. {
  918. return IX_ETH_DB_INVALID_PRIORITY;
  919. }
  920. ixEthDBPortInfo[portID].priorityTable[userPriority] = trafficClass;
  921. return ixEthDBUpdateTrafficClass(portID, userPriority);
  922. }
  923. /**
  924. * @brief retrieves one QoS priority => traffic class mapping
  925. *
  926. * @param portID ID of the port
  927. * @param userPriority QoS (user) priority
  928. * @param trafficClass location to store the associated traffic class
  929. *
  930. * Note that this function is documented in the main component
  931. * header file, IxEthDB.h.
  932. *
  933. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  934. * or an appropriate error message otherwise
  935. */
  936. IX_ETH_DB_PUBLIC
  937. IxEthDBStatus ixEthDBPriorityMappingClassGet(IxEthDBPortId portID, IxEthDBPriority userPriority, IxEthDBPriority *trafficClass)
  938. {
  939. IX_ETH_DB_CHECK_PORT(portID);
  940. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  941. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  942. IX_ETH_DB_CHECK_REFERENCE(trafficClass);
  943. /* check userPriority range */
  944. if (userPriority >= IX_IEEE802_1Q_QOS_PRIORITY_COUNT)
  945. {
  946. return IX_ETH_DB_INVALID_PRIORITY;
  947. }
  948. *trafficClass = ixEthDBPortInfo[portID].priorityTable[userPriority];
  949. return IX_ETH_DB_SUCCESS;
  950. }
  951. /**
  952. * @brief enables or disables the source port extraction
  953. * from the VLAN TPID field
  954. *
  955. * @param portID ID of the port
  956. * @param enable TRUE to enable or FALSE to disable
  957. *
  958. * Note that this function is documented in the main component
  959. * header file, IxEthDB.h.
  960. *
  961. * @return IX_ETH_DB_SUCCESS if the operation completed successfully
  962. * or an appropriate error message otherwise
  963. */
  964. IX_ETH_DB_PUBLIC
  965. IxEthDBStatus ixEthDBVlanPortExtractionEnable(IxEthDBPortId portID, BOOL enable)
  966. {
  967. IxNpeMhMessage message;
  968. IX_STATUS result;
  969. IX_ETH_DB_CHECK_PORT(portID);
  970. IX_ETH_DB_CHECK_SINGLE_NPE(portID);
  971. IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
  972. FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable);
  973. IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
  974. return result;
  975. }