4 * @brief Implementation of the VLAN API
7 * IXP400 SW Release version 2.0
9 * -- Copyright Notice --
12 * Copyright 2001-2005, Intel Corporation.
13 * All rights reserved.
16 * SPDX-License-Identifier: BSD-3-Clause
18 * -- End of Copyright Notice --
22 #include "IxEthDB_p.h"
24 /* forward prototypes */
26 IxEthDBStatus ixEthDBUpdateTrafficClass(IxEthDBPortId portID, UINT32 classIndex);
28 IxEthDBStatus ixEthDBVlanTableGet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet);
30 /* contants used by various functions as "action" parameter */
31 #define ADD_VLAN (0x1)
32 #define REMOVE_VLAN (0x2)
35 * @brief adds or removes a VLAN from a VLAN set
37 * @param vlanID VLAN ID to add or remove
38 * @param table VLAN set to add into or remove from
39 * @param action ADD_VLAN or REMOVE_VLAN
44 void ixEthDBLocalVlanMembershipChange(UINT32 vlanID, IxEthDBVlanSet table, UINT32 action)
48 /* add/remove VID to membership table */
49 setOffset = VLAN_SET_OFFSET(vlanID); /* we need 9 bits to index the 512 byte membership array */
51 if (action == ADD_VLAN)
53 table[setOffset] |= 1 << VLAN_SET_MASK(vlanID);
55 else if (action == REMOVE_VLAN)
57 table[setOffset] &= ~(1 << VLAN_SET_MASK(vlanID));
62 * @brief updates a set of 8 VLANs in an NPE
64 * @param portID ID of the port
65 * @param setOffset offset of the 8 VLANs
67 * This function updates the VLAN membership table
68 * and Transmit Tagging Info table for 8 consecutive
69 * VLAN IDs indexed by setOffset.
71 * For example, a setOffset of 0 indexes VLAN IDs 0
72 * through 7, 1 indexes VLAN IDs 8 through 9 etc.
74 * @return IX_ETH_DB_SUCCESS if the operation completed
75 * successfully or an appropriate error message otherwise
80 IxEthDBStatus ixEthDBVlanTableEntryUpdate(IxEthDBPortId portID, UINT32 setOffset)
82 PortInfo *portInfo = &ixEthDBPortInfo[portID];
83 IxNpeMhMessage message;
86 FILL_SETPORTVLANTABLEENTRY_MSG(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID),
88 portInfo->vlanMembership[setOffset],
89 portInfo->transmitTaggingInfo[setOffset]);
91 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
97 * @brief updates a VLAN range in an NPE
99 * @param portID ID of the port
101 * This function is similar to @ref ixEthDBVlanTableEntryUpdate
102 * except that it can update more than one VLAN set (up to
103 * the entire VLAN membership and TTI tables if the offset is 0
104 * and length is sizeof (IxEthDBVlanSet) (512 bytes).
106 * Updating the NPE via this method is slower as it requires
107 * a memory copy from SDRAM, hence it is recommended that the
108 * ixEthDBVlanTableEntryUpdate function is used where possible.
110 * @return IX_ETH_DB_SUCCESS if the operation completed
111 * successfully or an appropriate error message otherwise
116 IxEthDBStatus ixEthDBVlanTableRangeUpdate(IxEthDBPortId portID)
118 PortInfo *portInfo = &ixEthDBPortInfo[portID];
119 UINT8 *vlanUpdateZone = (UINT8 *) portInfo->updateMethod.vlanUpdateZone;
120 IxNpeMhMessage message;
124 /* copy membership info and transmit tagging into into exchange area */
125 for (setIndex = 0 ; setIndex < sizeof (portInfo->vlanMembership) ; setIndex++)
127 /* membership and TTI data are interleaved */
128 vlanUpdateZone[setIndex * 2] = portInfo->vlanMembership[setIndex];
129 vlanUpdateZone[setIndex * 2 + 1] = portInfo->transmitTaggingInfo[setIndex];
132 IX_OSAL_CACHE_FLUSH(vlanUpdateZone, FULL_VLAN_BYTE_SIZE);
134 /* build NPE message */
135 FILL_SETPORTVLANTABLERANGE_MSG(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID), 0, 0,
136 IX_OSAL_MMU_VIRT_TO_PHYS(vlanUpdateZone));
139 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
145 * @brief adds or removes a VLAN from a port's VLAN membership table
146 * or Transmit Tagging Information table
148 * @param portID ID of the port
149 * @param vlanID VLAN ID to add or remove
150 * @param table to add or remove from
151 * @param action ADD_VLAN or REMOVE_VLAN
153 * @return IX_ETH_DB_SUCCESS if the operation completed
154 * successfully or an appropriate error message otherwise
159 IxEthDBStatus ixEthDBPortVlanMembershipChange(IxEthDBPortId portID, IxEthDBVlanId vlanID, IxEthDBVlanSet table, UINT32 action)
161 /* change VLAN in local membership table */
162 ixEthDBLocalVlanMembershipChange(vlanID, table, action);
164 /* send updated entry to NPE */
165 return ixEthDBVlanTableEntryUpdate(portID, VLAN_SET_OFFSET(vlanID));
169 * @brief sets the default port VLAN tag (the lower 3 bytes are the PVID)
171 * @param portID ID of the port
172 * @param vlanTag port VLAN tag (802.1Q tag)
174 * Note that this function is documented in the main component
175 * header file, IxEthDB.h.
177 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
178 * or an appropriate error message otherwise
181 IxEthDBStatus ixEthDBPortVlanTagSet(IxEthDBPortId portID, IxEthDBVlanTag vlanTag)
183 IxNpeMhMessage message;
186 IX_ETH_DB_CHECK_PORT(portID);
188 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
190 IX_ETH_DB_CHECK_VLAN_TAG(vlanTag);
192 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,
200 /* set tag in portInfo */
201 ixEthDBPortInfo[portID].vlanTag = vlanTag;
203 /* build VLAN_SetDefaultRxVID message */
204 FILL_SETDEFAULTRXVID_MSG(message,
205 IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID),
206 IX_IEEE802_1Q_VLAN_TPID,
209 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
215 * @brief retrieves the default port VLAN tag (the lower 3 bytes are the PVID)
217 * @param portID ID of the port
218 * @param vlanTag address to write the port VLAN tag (802.1Q tag) into
220 * Note that this function is documented in the main component
221 * header file, IxEthDB.h.
223 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
224 * or an appropriate error message otherwise
227 IxEthDBStatus ixEthDBPortVlanTagGet(IxEthDBPortId portID, IxEthDBVlanTag *vlanTag)
229 IX_ETH_DB_CHECK_PORT(portID);
231 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
233 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
235 IX_ETH_DB_CHECK_REFERENCE(vlanTag);
237 *vlanTag = ixEthDBPortInfo[portID].vlanTag;
239 return IX_ETH_DB_SUCCESS;
243 * @brief sets the VLAN tag (the lower 3 bytes are the PVID) of a
244 * database filtering record
246 * @param portID ID of the port
247 * @param vlanTag VLAN tag (802.1Q tag)
249 * Important: filtering records are automatically converted to
250 * IX_ETH_DB_FILTERING_VLAN record when added a VLAN tag.
252 * Note that this function is documented in the main component
253 * header file, IxEthDB.h.
255 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
256 * or an appropriate error message otherwise
259 IxEthDBStatus ixEthDBVlanTagSet(IxEthDBMacAddr *macAddr, IxEthDBVlanTag vlanTag)
261 HashNode *searchResult;
262 MacDescriptor *descriptor;
264 IX_ETH_DB_CHECK_REFERENCE(macAddr);
266 IX_ETH_DB_CHECK_VLAN_TAG(vlanTag);
268 searchResult = ixEthDBSearch(macAddr, IX_ETH_DB_ALL_FILTERING_RECORDS);
270 if (searchResult == NULL)
272 return IX_ETH_DB_NO_SUCH_ADDR;
275 descriptor = (MacDescriptor *) searchResult->data;
277 /* set record type to VLAN if not already set */
278 descriptor->type = IX_ETH_DB_FILTERING_VLAN_RECORD;
281 descriptor->recordData.filteringVlanData.ieee802_1qTag = vlanTag;
283 /* transaction completed */
284 ixEthDBReleaseHashNode(searchResult);
286 return IX_ETH_DB_SUCCESS;
290 * @brief retrieves the VLAN tag (the lower 3 bytes are the PVID) from a
291 * database VLAN filtering record
293 * @param portID ID of the port
294 * @param vlanTag address to write the VLAN tag (802.1Q tag) into
296 * Note that this function is documented in the main component
297 * header file, IxEthDB.h.
299 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
300 * or an appropriate error message otherwise
303 IxEthDBStatus ixEthDBVlanTagGet(IxEthDBMacAddr *macAddr, IxEthDBVlanTag *vlanTag)
305 HashNode *searchResult;
306 MacDescriptor *descriptor;
308 IX_ETH_DB_CHECK_REFERENCE(macAddr);
310 IX_ETH_DB_CHECK_REFERENCE(vlanTag);
312 searchResult = ixEthDBSearch(macAddr, IX_ETH_DB_FILTERING_VLAN_RECORD);
314 if (searchResult == NULL)
316 return IX_ETH_DB_NO_SUCH_ADDR;
319 descriptor = (MacDescriptor *) searchResult->data;
322 *vlanTag = descriptor->recordData.filteringVlanData.ieee802_1qTag;
324 /* transaction completed */
325 ixEthDBReleaseHashNode(searchResult);
327 return IX_ETH_DB_SUCCESS;
331 * @brief adds a VLAN to a port's VLAN membership table
333 * @param portID ID of the port
334 * @param vlanID VLAN ID to add
336 * Note that this function is documented in the main component
337 * header file, IxEthDB.h.
339 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
340 * or an appropriate error message otherwise
343 IxEthDBStatus ixEthDBPortVlanMembershipAdd(IxEthDBPortId portID, IxEthDBVlanId vlanID)
345 IX_ETH_DB_CHECK_PORT(portID);
347 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
349 IX_ETH_DB_CHECK_VLAN_ID(vlanID);
351 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
353 return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].vlanMembership, ADD_VLAN);
357 * @brief removes a VLAN from a port's VLAN membership table
359 * @param portID ID of the port
360 * @param vlanID VLAN ID to remove
362 * Note that this function is documented in the main component
363 * header file, IxEthDB.h.
365 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
366 * or an appropriate error message otherwise
369 IxEthDBStatus ixEthDBPortVlanMembershipRemove(IxEthDBPortId portID, IxEthDBVlanId vlanID)
371 IX_ETH_DB_CHECK_PORT(portID);
373 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
375 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
377 IX_ETH_DB_CHECK_VLAN_ID(vlanID);
379 /* for safety isolate only the VLAN ID in the tag (the lower 12 bits) */
380 vlanID = vlanID & IX_ETH_DB_802_1Q_VLAN_MASK;
382 /* check we're not asked to remove the default port VID */
383 if (vlanID == IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag))
385 return IX_ETH_DB_NO_PERMISSION;
388 return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].vlanMembership, REMOVE_VLAN);
392 * @brief adds or removes a VLAN range from a port's
393 * VLAN membership table or TTI table
395 * @param portID ID of the port
396 * @param vlanIDMin start of the VLAN range
397 * @param vlanIDMax end of the VLAN range
398 * @param table VLAN set to add or remove from
399 * @param action ADD_VLAN or REMOVE_VLAN
401 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
402 * or an appropriate error message otherwise
407 IxEthDBStatus ixEthDBPortVlanMembershipRangeChange(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax, IxEthDBVlanSet table, UINT32 action)
409 UINT32 setOffsetMin, setOffsetMax;
411 IX_ETH_DB_CHECK_PORT(portID);
413 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
415 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
417 IX_ETH_DB_CHECK_VLAN_ID(vlanIDMin);
419 IX_ETH_DB_CHECK_VLAN_ID(vlanIDMax);
421 /* for safety isolate only the VLAN ID in the tags (the lower 12 bits) */
422 vlanIDMin = vlanIDMin & IX_ETH_DB_802_1Q_VLAN_MASK;
423 vlanIDMax = vlanIDMax & IX_ETH_DB_802_1Q_VLAN_MASK;
425 /* is this a range? */
426 if (vlanIDMax < vlanIDMin)
428 return IX_ETH_DB_INVALID_VLAN;
431 /* check that we're not specifically asked to remove the default port VID */
432 if (action == REMOVE_VLAN && vlanIDMax == vlanIDMin && IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag) == vlanIDMin)
434 return IX_ETH_DB_NO_PERMISSION;
437 /* compute set offsets */
438 setOffsetMin = VLAN_SET_OFFSET(vlanIDMin);
439 setOffsetMax = VLAN_SET_OFFSET(vlanIDMax);
441 /* change VLAN range */
442 for (; vlanIDMin <= vlanIDMax ; vlanIDMin++)
444 /* change vlan in local membership table */
445 ixEthDBLocalVlanMembershipChange(vlanIDMin, table, action);
448 /* if the range is within one set (max 8 VLANs in one table byte) we can just update that entry in the NPE */
449 if (setOffsetMin == setOffsetMax)
451 /* send updated entry to NPE */
452 return ixEthDBVlanTableEntryUpdate(portID, setOffsetMin);
456 /* update a zone of the membership/transmit tag info table */
457 return ixEthDBVlanTableRangeUpdate(portID);
462 * @brief adds a VLAN range to a port's VLAN membership table
464 * @param portID ID of the port
465 * @param vlanIDMin start of the VLAN range
466 * @param vlanIDMax end of the VLAN range
468 * Note that this function is documented in the main component
469 * header file, IxEthDB.h.
471 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
472 * or an appropriate error message otherwise
475 IxEthDBStatus ixEthDBPortVlanMembershipRangeAdd(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax)
477 IX_ETH_DB_CHECK_PORT(portID);
479 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
481 return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].vlanMembership, ADD_VLAN);
485 * @brief removes a VLAN range from a port's VLAN membership table
487 * @param portID ID of the port
488 * @param vlanIDMin start of the VLAN range
489 * @param vlanIDMax end of the VLAN range
491 * Note that this function is documented in the main component
492 * header file, IxEthDB.h.
494 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
495 * or an appropriate error message otherwise
498 IxEthDBStatus ixEthDBPortVlanMembershipRangeRemove(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax)
500 IX_ETH_DB_CHECK_PORT(portID);
502 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
504 return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].vlanMembership, REMOVE_VLAN);
508 * @brief sets a port's VLAN membership table or TTI table and
509 * updates the NPE VLAN configuration
511 * @param portID ID of the port
512 * @param portVlanTable port VLAN table to set
513 * @param vlanSet new set contents
515 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
516 * or an appropriate error message otherwise
521 IxEthDBStatus ixEthDBPortVlanTableSet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet)
523 IX_ETH_DB_CHECK_PORT(portID);
525 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
527 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
529 IX_ETH_DB_CHECK_REFERENCE(vlanSet);
531 memcpy(portVlanTable, vlanSet, sizeof (IxEthDBVlanSet));
533 return ixEthDBVlanTableRangeUpdate(portID);
537 * @brief retireves a port's VLAN membership table or TTI table
539 * @param portID ID of the port
540 * @param portVlanTable port VLAN table to retrieve
541 * @param vlanSet address to
543 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
544 * or an appropriate error message otherwise
549 IxEthDBStatus ixEthDBVlanTableGet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet)
551 IX_ETH_DB_CHECK_PORT(portID);
553 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
555 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
557 IX_ETH_DB_CHECK_REFERENCE(vlanSet);
559 memcpy(vlanSet, portVlanTable, sizeof (IxEthDBVlanSet));
561 return IX_ETH_DB_SUCCESS;
565 * @brief sets a port's VLAN membership table
567 * @param portID ID of the port
568 * @param vlanSet new VLAN membership table
570 * Note that this function is documented in the main component
571 * header file, IxEthDB.h.
573 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
574 * or an appropriate error message otherwise
577 IxEthDBStatus ixEthDBPortVlanMembershipSet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
579 IxEthDBVlanId vlanID;
581 IX_ETH_DB_CHECK_PORT(portID);
583 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
585 IX_ETH_DB_CHECK_REFERENCE(vlanSet);
587 /* set the bit corresponding to the PVID just in case */
588 vlanID = IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag);
589 vlanSet[VLAN_SET_OFFSET(vlanID)] |= 1 << VLAN_SET_MASK(vlanID);
591 return ixEthDBPortVlanTableSet(portID, ixEthDBPortInfo[portID].vlanMembership, vlanSet);
595 * @brief retrieves a port's VLAN membership table
597 * @param portID ID of the port
598 * @param vlanSet location to store the port's VLAN membership table
600 * Note that this function is documented in the main component
601 * header file, IxEthDB.h.
603 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
604 * or an appropriate error message otherwise
607 IxEthDBStatus ixEthDBPortVlanMembershipGet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
609 IX_ETH_DB_CHECK_PORT(portID);
611 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
613 return ixEthDBVlanTableGet(portID, ixEthDBPortInfo[portID].vlanMembership, vlanSet);
617 * @brief enables or disables Egress tagging for one VLAN ID
619 * @param portID ID of the port
620 * @param vlanID VLAN ID to enable or disable Egress tagging on
621 * @param enabled true to enable and false to disable tagging
623 * Note that this function is documented in the main component
624 * header file, IxEthDB.h.
626 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
627 * or an appropriate error message otherwise
630 IxEthDBStatus ixEthDBEgressVlanEntryTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanId vlanID, BOOL enabled)
632 IX_ETH_DB_CHECK_PORT(portID);
634 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
636 IX_ETH_DB_CHECK_VLAN_ID(vlanID);
638 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
640 return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].transmitTaggingInfo, enabled? ADD_VLAN : REMOVE_VLAN);
644 * @brief retrieves the Egress tagging status for one VLAN ID
646 * @param portID ID of the port
647 * @param vlanID VLAN ID to retrieve the tagging status for
648 * @param enabled location to store the tagging status
649 * (true - tagging enabled, false - tagging disabled)
651 * Note that this function is documented in the main component
652 * header file, IxEthDB.h.
654 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
655 * or an appropriate error message otherwise
658 IxEthDBStatus ixEthDBEgressVlanEntryTaggingEnabledGet(IxEthDBPortId portID, IxEthDBVlanId vlanID, BOOL *enabled)
660 IX_ETH_DB_CHECK_PORT(portID);
662 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
664 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
666 IX_ETH_DB_CHECK_REFERENCE(enabled);
668 IX_ETH_DB_CHECK_VLAN_ID(vlanID);
670 *enabled = ((ixEthDBPortInfo[portID].transmitTaggingInfo[VLAN_SET_OFFSET(vlanID)] & (1 << VLAN_SET_MASK(vlanID))) != 0);
672 return IX_ETH_DB_SUCCESS;
676 * @brief enables or disables Egress VLAN tagging for a VLAN range
678 * @param portID ID of the port
679 * @param vlanIDMin start of VLAN range
680 * @param vlanIDMax end of VLAN range
681 * @param enabled true to enable or false to disable VLAN tagging
683 * Note that this function is documented in the main component
684 * header file, IxEthDB.h.
686 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
687 * or an appropriate error message otherwise
690 IxEthDBStatus ixEthDBEgressVlanRangeTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax, BOOL enabled)
692 IX_ETH_DB_CHECK_PORT(portID);
694 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
696 return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].transmitTaggingInfo, enabled? ADD_VLAN : REMOVE_VLAN);
700 * @brief sets the Egress VLAN tagging table (the Transmit Tagging
703 * @param portID ID of the port
704 * @param vlanSet new TTI table
706 * Note that this function is documented in the main component
707 * header file, IxEthDB.h.
709 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
710 * or an appropriate error message otherwise
713 IxEthDBStatus ixEthDBEgressVlanTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
715 IxEthDBVlanId vlanID;
717 IX_ETH_DB_CHECK_PORT(portID);
719 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
721 IX_ETH_DB_CHECK_REFERENCE(vlanSet);
723 /* set the PVID bit just in case */
724 vlanID = IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag);
725 vlanSet[VLAN_SET_OFFSET(vlanID)] |= 1 << VLAN_SET_MASK(vlanID);
727 return ixEthDBPortVlanTableSet(portID, ixEthDBPortInfo[portID].transmitTaggingInfo, vlanSet);
731 * @brief retrieves the Egress VLAN tagging table (the Transmit
732 * Tagging Information table)
734 * @param portID ID of the port
735 * @param vlanSet location to store the port's TTI table
737 * Note that this function is documented in the main component
738 * header file, IxEthDB.h.
740 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
741 * or an appropriate error message otherwise
744 IxEthDBStatus ixEthDBEgressVlanTaggingEnabledGet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet)
746 IX_ETH_DB_CHECK_PORT(portID);
748 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
750 return ixEthDBVlanTableGet(portID, ixEthDBPortInfo[portID].transmitTaggingInfo, vlanSet);
754 * @brief sends the NPE the updated frame filter and default
757 * @param portID ID of the port
759 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
760 * or an appropriate error message otherwise
765 IxEthDBStatus ixEthDBIngressVlanModeUpdate(IxEthDBPortId portID)
767 PortInfo *portInfo = &ixEthDBPortInfo[portID];
768 IxNpeMhMessage message;
771 FILL_SETRXTAGMODE_MSG(message, portID, portInfo->npeFrameFilter, portInfo->npeTaggingAction);
772 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
778 * @brief sets the default Ingress tagging behavior
780 * @param portID ID of the port
781 * @param taggingAction default tagging behavior
783 * Note that this function is documented in the main component
784 * header file, IxEthDB.h.
786 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
787 * or an appropriate error message otherwise
790 IxEthDBStatus ixEthDBIngressVlanTaggingEnabledSet(IxEthDBPortId portID, IxEthDBTaggingAction taggingAction)
794 IX_ETH_DB_CHECK_PORT(portID);
796 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
798 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
800 portInfo = &ixEthDBPortInfo[portID];
802 if (taggingAction == IX_ETH_DB_PASS_THROUGH)
804 portInfo->npeTaggingAction = 0x00;
806 else if (taggingAction == IX_ETH_DB_ADD_TAG)
808 portInfo->npeTaggingAction = 0x02;
810 else if (taggingAction == IX_ETH_DB_REMOVE_TAG)
812 portInfo->npeTaggingAction = 0x01;
816 return IX_ETH_DB_INVALID_ARG;
819 portInfo->taggingAction = taggingAction;
821 return ixEthDBIngressVlanModeUpdate(portID);
825 * @brief retrieves the default Ingress tagging behavior of a port
827 * @param portID ID of the port
828 * @param taggingAction location to save the default tagging behavior
830 * Note that this function is documented in the main component
831 * header file, IxEthDB.h.
833 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
834 * or an appropriate error message otherwise
837 IxEthDBStatus ixEthDBIngressVlanTaggingEnabledGet(IxEthDBPortId portID, IxEthDBTaggingAction *taggingAction)
839 IX_ETH_DB_CHECK_PORT(portID);
841 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
843 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
845 IX_ETH_DB_CHECK_REFERENCE(taggingAction);
847 *taggingAction = ixEthDBPortInfo[portID].taggingAction;
849 return IX_ETH_DB_SUCCESS;
853 * @brief sets the Ingress acceptable frame type filter
855 * @param portID ID of the port
856 * @param frameFilter acceptable frame type filter
858 * Note that this function is documented in the main component
859 * header file, IxEthDB.h.
861 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
862 * or an appropriate error message otherwise
865 IxEthDBStatus ixEthDBAcceptableFrameTypeSet(IxEthDBPortId portID, IxEthDBFrameFilter frameFilter)
868 IxEthDBStatus result = IX_ETH_DB_SUCCESS;
870 IX_ETH_DB_CHECK_PORT(portID);
872 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
874 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
876 /* check parameter range
877 the ORed value of the valid values is 0x7
878 a value having extra bits is invalid */
879 if ((frameFilter | 0x7) != 0x7 || frameFilter == 0)
881 return IX_ETH_DB_INVALID_ARG;
884 portInfo = &ixEthDBPortInfo[portID];
886 portInfo->frameFilter = frameFilter;
887 portInfo->npeFrameFilter = 0; /* allow all by default */
889 /* if accepting priority tagged but not all VLAN tagged
890 set the membership table to contain only VLAN ID 0
891 hence remove vlans 1-4094 and add VLAN ID 0 */
892 if (((frameFilter & IX_ETH_DB_PRIORITY_TAGGED_FRAMES) != 0)
893 && ((frameFilter & IX_ETH_DB_VLAN_TAGGED_FRAMES) == 0))
895 result = ixEthDBPortVlanMembershipRangeChange(portID,
896 1, IX_ETH_DB_802_1Q_MAX_VLAN_ID, portInfo->vlanMembership, REMOVE_VLAN);
898 if (result == IX_ETH_DB_SUCCESS)
900 ixEthDBLocalVlanMembershipChange(0, portInfo->vlanMembership, ADD_VLAN);
901 result = ixEthDBVlanTableRangeUpdate(portID);
906 if (frameFilter == IX_ETH_DB_UNTAGGED_FRAMES)
908 portInfo->npeFrameFilter = 0x01;
912 if ((frameFilter & IX_ETH_DB_UNTAGGED_FRAMES) == 0)
914 portInfo->npeFrameFilter = 0x02;
917 if (result == IX_ETH_DB_SUCCESS)
919 result = ixEthDBIngressVlanModeUpdate(portID);
926 * @brief retrieves the acceptable frame type filter for a port
928 * @param portID ID of the port
929 * @param frameFilter location to store the frame filter
931 * Note that this function is documented in the main component
932 * header file, IxEthDB.h.
934 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
935 * or an appropriate error message otherwise
938 IxEthDBStatus ixEthDBAcceptableFrameTypeGet(IxEthDBPortId portID, IxEthDBFrameFilter *frameFilter)
940 IX_ETH_DB_CHECK_PORT(portID);
942 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
944 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
946 IX_ETH_DB_CHECK_REFERENCE(frameFilter);
948 *frameFilter = ixEthDBPortInfo[portID].frameFilter;
950 return IX_ETH_DB_SUCCESS;
954 * @brief sends an NPE the updated configuration related
955 * to one QoS priority (associated traffic class and AQM mapping)
957 * @param portID ID of the port
958 * @param classIndex QoS priority (traffic class index)
960 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
961 * or an appropriate error message otherwise
966 IxEthDBStatus ixEthDBUpdateTrafficClass(IxEthDBPortId portID, UINT32 classIndex)
968 IxNpeMhMessage message;
971 UINT32 trafficClass = ixEthDBPortInfo[portID].priorityTable[classIndex];
972 UINT32 aqmQueue = ixEthDBPortInfo[portID].ixEthDBTrafficClassAQMAssignments[trafficClass];
974 FILL_SETRXQOSENTRY(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID), classIndex, trafficClass, aqmQueue);
976 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
982 * @brief sets the priority mapping table
984 * @param portID ID of the port
985 * @param priorityTable new priority mapping table
987 * Note that this function is documented in the main component
988 * header file, IxEthDB.h.
990 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
991 * or an appropriate error message otherwise
994 IxEthDBStatus ixEthDBPriorityMappingTableSet(IxEthDBPortId portID, IxEthDBPriorityTable priorityTable)
998 IX_ETH_DB_CHECK_PORT(portID);
1000 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
1002 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
1004 IX_ETH_DB_CHECK_REFERENCE(priorityTable);
1006 for (classIndex = 0 ; classIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; classIndex++)
1009 if (priorityTable[classIndex] >= ixEthDBPortInfo[portID].ixEthDBTrafficClassCount)
1011 return IX_ETH_DB_INVALID_PRIORITY;
1015 /* set new traffic classes */
1016 for (classIndex = 0 ; classIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; classIndex++)
1018 ixEthDBPortInfo[portID].priorityTable[classIndex] = priorityTable[classIndex];
1020 if (ixEthDBUpdateTrafficClass(portID, classIndex) != IX_ETH_DB_SUCCESS)
1022 return IX_ETH_DB_FAIL;
1026 return IX_ETH_DB_SUCCESS;
1030 * @brief retrieves a port's priority mapping table
1032 * @param portID ID of the port
1033 * @param priorityTable location to store the priority table
1035 * Note that this function is documented in the main component
1036 * header file, IxEthDB.h.
1038 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1039 * or an appropriate error message otherwise
1042 IxEthDBStatus ixEthDBPriorityMappingTableGet(IxEthDBPortId portID, IxEthDBPriorityTable priorityTable)
1044 IX_ETH_DB_CHECK_PORT(portID);
1046 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
1048 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
1050 IX_ETH_DB_CHECK_REFERENCE(priorityTable);
1052 memcpy(priorityTable, ixEthDBPortInfo[portID].priorityTable, sizeof (IxEthDBPriorityTable));
1054 return IX_ETH_DB_SUCCESS;
1058 * @brief sets one QoS priority => traffic class mapping
1060 * @param portID ID of the port
1061 * @param userPriority QoS (user) priority
1062 * @param trafficClass associated traffic class
1064 * Note that this function is documented in the main component
1065 * header file, IxEthDB.h.
1067 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1068 * or an appropriate error message otherwise
1071 IxEthDBStatus ixEthDBPriorityMappingClassSet(IxEthDBPortId portID, IxEthDBPriority userPriority, IxEthDBPriority trafficClass)
1073 IX_ETH_DB_CHECK_PORT(portID);
1075 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
1077 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
1079 /* check ranges for userPriority and trafficClass */
1080 if (userPriority >= IX_IEEE802_1Q_QOS_PRIORITY_COUNT || trafficClass >= ixEthDBPortInfo[portID].ixEthDBTrafficClassCount)
1082 return IX_ETH_DB_INVALID_PRIORITY;
1085 ixEthDBPortInfo[portID].priorityTable[userPriority] = trafficClass;
1087 return ixEthDBUpdateTrafficClass(portID, userPriority);
1091 * @brief retrieves one QoS priority => traffic class mapping
1093 * @param portID ID of the port
1094 * @param userPriority QoS (user) priority
1095 * @param trafficClass location to store the associated traffic class
1097 * Note that this function is documented in the main component
1098 * header file, IxEthDB.h.
1100 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1101 * or an appropriate error message otherwise
1104 IxEthDBStatus ixEthDBPriorityMappingClassGet(IxEthDBPortId portID, IxEthDBPriority userPriority, IxEthDBPriority *trafficClass)
1106 IX_ETH_DB_CHECK_PORT(portID);
1108 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
1110 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
1112 IX_ETH_DB_CHECK_REFERENCE(trafficClass);
1114 /* check userPriority range */
1115 if (userPriority >= IX_IEEE802_1Q_QOS_PRIORITY_COUNT)
1117 return IX_ETH_DB_INVALID_PRIORITY;
1120 *trafficClass = ixEthDBPortInfo[portID].priorityTable[userPriority];
1122 return IX_ETH_DB_SUCCESS;
1126 * @brief enables or disables the source port extraction
1127 * from the VLAN TPID field
1129 * @param portID ID of the port
1130 * @param enable true to enable or false to disable
1132 * Note that this function is documented in the main component
1133 * header file, IxEthDB.h.
1135 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1136 * or an appropriate error message otherwise
1139 IxEthDBStatus ixEthDBVlanPortExtractionEnable(IxEthDBPortId portID, BOOL enable)
1141 IxNpeMhMessage message;
1144 IX_ETH_DB_CHECK_PORT(portID);
1146 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
1148 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS);
1150 FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable);
1152 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);