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