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 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
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.
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
42 * -- End of Copyright Notice --
46 #include "IxEthDB_p.h"
48 /* forward prototypes */
50 IxEthDBStatus
ixEthDBUpdateTrafficClass(IxEthDBPortId portID
, UINT32 classIndex
);
52 IxEthDBStatus
ixEthDBVlanTableGet(IxEthDBPortId portID
, IxEthDBVlanSet portVlanTable
, IxEthDBVlanSet vlanSet
);
54 /* contants used by various functions as "action" parameter */
55 #define ADD_VLAN (0x1)
56 #define REMOVE_VLAN (0x2)
59 * @brief adds or removes a VLAN from a VLAN set
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
68 void ixEthDBLocalVlanMembershipChange(UINT32 vlanID
, IxEthDBVlanSet table
, UINT32 action
)
72 /* add/remove VID to membership table */
73 setOffset
= VLAN_SET_OFFSET(vlanID
); /* we need 9 bits to index the 512 byte membership array */
75 if (action
== ADD_VLAN
)
77 table
[setOffset
] |= 1 << VLAN_SET_MASK(vlanID
);
79 else if (action
== REMOVE_VLAN
)
81 table
[setOffset
] &= ~(1 << VLAN_SET_MASK(vlanID
));
86 * @brief updates a set of 8 VLANs in an NPE
88 * @param portID ID of the port
89 * @param setOffset offset of the 8 VLANs
91 * This function updates the VLAN membership table
92 * and Transmit Tagging Info table for 8 consecutive
93 * VLAN IDs indexed by setOffset.
95 * For example, a setOffset of 0 indexes VLAN IDs 0
96 * through 7, 1 indexes VLAN IDs 8 through 9 etc.
98 * @return IX_ETH_DB_SUCCESS if the operation completed
99 * successfully or an appropriate error message otherwise
104 IxEthDBStatus
ixEthDBVlanTableEntryUpdate(IxEthDBPortId portID
, UINT32 setOffset
)
106 PortInfo
*portInfo
= &ixEthDBPortInfo
[portID
];
107 IxNpeMhMessage message
;
110 FILL_SETPORTVLANTABLEENTRY_MSG(message
, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID
),
112 portInfo
->vlanMembership
[setOffset
],
113 portInfo
->transmitTaggingInfo
[setOffset
]);
115 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID
), message
, result
);
121 * @brief updates a VLAN range in an NPE
123 * @param portID ID of the port
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).
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.
134 * @return IX_ETH_DB_SUCCESS if the operation completed
135 * successfully or an appropriate error message otherwise
140 IxEthDBStatus
ixEthDBVlanTableRangeUpdate(IxEthDBPortId portID
)
142 PortInfo
*portInfo
= &ixEthDBPortInfo
[portID
];
143 UINT8
*vlanUpdateZone
= (UINT8
*) portInfo
->updateMethod
.vlanUpdateZone
;
144 IxNpeMhMessage message
;
148 /* copy membership info and transmit tagging into into exchange area */
149 for (setIndex
= 0 ; setIndex
< sizeof (portInfo
->vlanMembership
) ; setIndex
++)
151 /* membership and TTI data are interleaved */
152 vlanUpdateZone
[setIndex
* 2] = portInfo
->vlanMembership
[setIndex
];
153 vlanUpdateZone
[setIndex
* 2 + 1] = portInfo
->transmitTaggingInfo
[setIndex
];
156 IX_OSAL_CACHE_FLUSH(vlanUpdateZone
, FULL_VLAN_BYTE_SIZE
);
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
));
163 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID
), message
, result
);
169 * @brief adds or removes a VLAN from a port's VLAN membership table
170 * or Transmit Tagging Information table
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
177 * @return IX_ETH_DB_SUCCESS if the operation completed
178 * successfully or an appropriate error message otherwise
183 IxEthDBStatus
ixEthDBPortVlanMembershipChange(IxEthDBPortId portID
, IxEthDBVlanId vlanID
, IxEthDBVlanSet table
, UINT32 action
)
185 /* change VLAN in local membership table */
186 ixEthDBLocalVlanMembershipChange(vlanID
, table
, action
);
188 /* send updated entry to NPE */
189 return ixEthDBVlanTableEntryUpdate(portID
, VLAN_SET_OFFSET(vlanID
));
193 * @brief sets the default port VLAN tag (the lower 3 bytes are the PVID)
195 * @param portID ID of the port
196 * @param vlanTag port VLAN tag (802.1Q tag)
198 * Note that this function is documented in the main component
199 * header file, IxEthDB.h.
201 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
202 * or an appropriate error message otherwise
205 IxEthDBStatus
ixEthDBPortVlanTagSet(IxEthDBPortId portID
, IxEthDBVlanTag vlanTag
)
207 IxNpeMhMessage message
;
210 IX_ETH_DB_CHECK_PORT(portID
);
212 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
214 IX_ETH_DB_CHECK_VLAN_TAG(vlanTag
);
216 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
218 /* add VLAN ID to local membership table */
219 ixEthDBPortVlanMembershipChange(portID
,
220 vlanTag
& IX_ETH_DB_802_1Q_VLAN_MASK
,
221 ixEthDBPortInfo
[portID
].vlanMembership
,
224 /* set tag in portInfo */
225 ixEthDBPortInfo
[portID
].vlanTag
= vlanTag
;
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
,
233 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID
), message
, result
);
239 * @brief retrieves the default port VLAN tag (the lower 3 bytes are the PVID)
241 * @param portID ID of the port
242 * @param vlanTag address to write the port VLAN tag (802.1Q tag) into
244 * Note that this function is documented in the main component
245 * header file, IxEthDB.h.
247 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
248 * or an appropriate error message otherwise
251 IxEthDBStatus
ixEthDBPortVlanTagGet(IxEthDBPortId portID
, IxEthDBVlanTag
*vlanTag
)
253 IX_ETH_DB_CHECK_PORT(portID
);
255 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
257 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
259 IX_ETH_DB_CHECK_REFERENCE(vlanTag
);
261 *vlanTag
= ixEthDBPortInfo
[portID
].vlanTag
;
263 return IX_ETH_DB_SUCCESS
;
267 * @brief sets the VLAN tag (the lower 3 bytes are the PVID) of a
268 * database filtering record
270 * @param portID ID of the port
271 * @param vlanTag VLAN tag (802.1Q tag)
273 * Important: filtering records are automatically converted to
274 * IX_ETH_DB_FILTERING_VLAN record when added a VLAN tag.
276 * Note that this function is documented in the main component
277 * header file, IxEthDB.h.
279 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
280 * or an appropriate error message otherwise
283 IxEthDBStatus
ixEthDBVlanTagSet(IxEthDBMacAddr
*macAddr
, IxEthDBVlanTag vlanTag
)
285 HashNode
*searchResult
;
286 MacDescriptor
*descriptor
;
288 IX_ETH_DB_CHECK_REFERENCE(macAddr
);
290 IX_ETH_DB_CHECK_VLAN_TAG(vlanTag
);
292 searchResult
= ixEthDBSearch(macAddr
, IX_ETH_DB_ALL_FILTERING_RECORDS
);
294 if (searchResult
== NULL
)
296 return IX_ETH_DB_NO_SUCH_ADDR
;
299 descriptor
= (MacDescriptor
*) searchResult
->data
;
301 /* set record type to VLAN if not already set */
302 descriptor
->type
= IX_ETH_DB_FILTERING_VLAN_RECORD
;
305 descriptor
->recordData
.filteringVlanData
.ieee802_1qTag
= vlanTag
;
307 /* transaction completed */
308 ixEthDBReleaseHashNode(searchResult
);
310 return IX_ETH_DB_SUCCESS
;
314 * @brief retrieves the VLAN tag (the lower 3 bytes are the PVID) from a
315 * database VLAN filtering record
317 * @param portID ID of the port
318 * @param vlanTag address to write the VLAN tag (802.1Q tag) into
320 * Note that this function is documented in the main component
321 * header file, IxEthDB.h.
323 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
324 * or an appropriate error message otherwise
327 IxEthDBStatus
ixEthDBVlanTagGet(IxEthDBMacAddr
*macAddr
, IxEthDBVlanTag
*vlanTag
)
329 HashNode
*searchResult
;
330 MacDescriptor
*descriptor
;
332 IX_ETH_DB_CHECK_REFERENCE(macAddr
);
334 IX_ETH_DB_CHECK_REFERENCE(vlanTag
);
336 searchResult
= ixEthDBSearch(macAddr
, IX_ETH_DB_FILTERING_VLAN_RECORD
);
338 if (searchResult
== NULL
)
340 return IX_ETH_DB_NO_SUCH_ADDR
;
343 descriptor
= (MacDescriptor
*) searchResult
->data
;
346 *vlanTag
= descriptor
->recordData
.filteringVlanData
.ieee802_1qTag
;
348 /* transaction completed */
349 ixEthDBReleaseHashNode(searchResult
);
351 return IX_ETH_DB_SUCCESS
;
355 * @brief adds a VLAN to a port's VLAN membership table
357 * @param portID ID of the port
358 * @param vlanID VLAN ID to add
360 * Note that this function is documented in the main component
361 * header file, IxEthDB.h.
363 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
364 * or an appropriate error message otherwise
367 IxEthDBStatus
ixEthDBPortVlanMembershipAdd(IxEthDBPortId portID
, IxEthDBVlanId vlanID
)
369 IX_ETH_DB_CHECK_PORT(portID
);
371 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
373 IX_ETH_DB_CHECK_VLAN_ID(vlanID
);
375 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
377 return ixEthDBPortVlanMembershipChange(portID
, vlanID
, ixEthDBPortInfo
[portID
].vlanMembership
, ADD_VLAN
);
381 * @brief removes a VLAN from a port's VLAN membership table
383 * @param portID ID of the port
384 * @param vlanID VLAN ID to remove
386 * Note that this function is documented in the main component
387 * header file, IxEthDB.h.
389 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
390 * or an appropriate error message otherwise
393 IxEthDBStatus
ixEthDBPortVlanMembershipRemove(IxEthDBPortId portID
, IxEthDBVlanId vlanID
)
395 IX_ETH_DB_CHECK_PORT(portID
);
397 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
399 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
401 IX_ETH_DB_CHECK_VLAN_ID(vlanID
);
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
;
406 /* check we're not asked to remove the default port VID */
407 if (vlanID
== IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo
[portID
].vlanTag
))
409 return IX_ETH_DB_NO_PERMISSION
;
412 return ixEthDBPortVlanMembershipChange(portID
, vlanID
, ixEthDBPortInfo
[portID
].vlanMembership
, REMOVE_VLAN
);
416 * @brief adds or removes a VLAN range from a port's
417 * VLAN membership table or TTI table
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
425 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
426 * or an appropriate error message otherwise
431 IxEthDBStatus
ixEthDBPortVlanMembershipRangeChange(IxEthDBPortId portID
, IxEthDBVlanId vlanIDMin
, IxEthDBVlanId vlanIDMax
, IxEthDBVlanSet table
, UINT32 action
)
433 UINT32 setOffsetMin
, setOffsetMax
;
435 IX_ETH_DB_CHECK_PORT(portID
);
437 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
439 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
441 IX_ETH_DB_CHECK_VLAN_ID(vlanIDMin
);
443 IX_ETH_DB_CHECK_VLAN_ID(vlanIDMax
);
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
;
449 /* is this a range? */
450 if (vlanIDMax
< vlanIDMin
)
452 return IX_ETH_DB_INVALID_VLAN
;
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
)
458 return IX_ETH_DB_NO_PERMISSION
;
461 /* compute set offsets */
462 setOffsetMin
= VLAN_SET_OFFSET(vlanIDMin
);
463 setOffsetMax
= VLAN_SET_OFFSET(vlanIDMax
);
465 /* change VLAN range */
466 for (; vlanIDMin
<= vlanIDMax
; vlanIDMin
++)
468 /* change vlan in local membership table */
469 ixEthDBLocalVlanMembershipChange(vlanIDMin
, table
, action
);
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
)
475 /* send updated entry to NPE */
476 return ixEthDBVlanTableEntryUpdate(portID
, setOffsetMin
);
480 /* update a zone of the membership/transmit tag info table */
481 return ixEthDBVlanTableRangeUpdate(portID
);
486 * @brief adds a VLAN range to a port's VLAN membership table
488 * @param portID ID of the port
489 * @param vlanIDMin start of the VLAN range
490 * @param vlanIDMax end of the VLAN range
492 * Note that this function is documented in the main component
493 * header file, IxEthDB.h.
495 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
496 * or an appropriate error message otherwise
499 IxEthDBStatus
ixEthDBPortVlanMembershipRangeAdd(IxEthDBPortId portID
, IxEthDBVlanId vlanIDMin
, IxEthDBVlanId vlanIDMax
)
501 IX_ETH_DB_CHECK_PORT(portID
);
503 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
505 return ixEthDBPortVlanMembershipRangeChange(portID
, vlanIDMin
, vlanIDMax
, ixEthDBPortInfo
[portID
].vlanMembership
, ADD_VLAN
);
509 * @brief removes a VLAN range from a port's VLAN membership table
511 * @param portID ID of the port
512 * @param vlanIDMin start of the VLAN range
513 * @param vlanIDMax end of the VLAN range
515 * Note that this function is documented in the main component
516 * header file, IxEthDB.h.
518 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
519 * or an appropriate error message otherwise
522 IxEthDBStatus
ixEthDBPortVlanMembershipRangeRemove(IxEthDBPortId portID
, IxEthDBVlanId vlanIDMin
, IxEthDBVlanId vlanIDMax
)
524 IX_ETH_DB_CHECK_PORT(portID
);
526 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
528 return ixEthDBPortVlanMembershipRangeChange(portID
, vlanIDMin
, vlanIDMax
, ixEthDBPortInfo
[portID
].vlanMembership
, REMOVE_VLAN
);
532 * @brief sets a port's VLAN membership table or TTI table and
533 * updates the NPE VLAN configuration
535 * @param portID ID of the port
536 * @param portVlanTable port VLAN table to set
537 * @param vlanSet new set contents
539 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
540 * or an appropriate error message otherwise
545 IxEthDBStatus
ixEthDBPortVlanTableSet(IxEthDBPortId portID
, IxEthDBVlanSet portVlanTable
, IxEthDBVlanSet vlanSet
)
547 IX_ETH_DB_CHECK_PORT(portID
);
549 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
551 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
553 IX_ETH_DB_CHECK_REFERENCE(vlanSet
);
555 memcpy(portVlanTable
, vlanSet
, sizeof (IxEthDBVlanSet
));
557 return ixEthDBVlanTableRangeUpdate(portID
);
561 * @brief retireves a port's VLAN membership table or TTI table
563 * @param portID ID of the port
564 * @param portVlanTable port VLAN table to retrieve
565 * @param vlanSet address to
567 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
568 * or an appropriate error message otherwise
573 IxEthDBStatus
ixEthDBVlanTableGet(IxEthDBPortId portID
, IxEthDBVlanSet portVlanTable
, IxEthDBVlanSet vlanSet
)
575 IX_ETH_DB_CHECK_PORT(portID
);
577 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
579 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
581 IX_ETH_DB_CHECK_REFERENCE(vlanSet
);
583 memcpy(vlanSet
, portVlanTable
, sizeof (IxEthDBVlanSet
));
585 return IX_ETH_DB_SUCCESS
;
589 * @brief sets a port's VLAN membership table
591 * @param portID ID of the port
592 * @param vlanSet new VLAN membership table
594 * Note that this function is documented in the main component
595 * header file, IxEthDB.h.
597 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
598 * or an appropriate error message otherwise
601 IxEthDBStatus
ixEthDBPortVlanMembershipSet(IxEthDBPortId portID
, IxEthDBVlanSet vlanSet
)
603 IxEthDBVlanId vlanID
;
605 IX_ETH_DB_CHECK_PORT(portID
);
607 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
609 IX_ETH_DB_CHECK_REFERENCE(vlanSet
);
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
);
615 return ixEthDBPortVlanTableSet(portID
, ixEthDBPortInfo
[portID
].vlanMembership
, vlanSet
);
619 * @brief retrieves a port's VLAN membership table
621 * @param portID ID of the port
622 * @param vlanSet location to store the port's VLAN membership table
624 * Note that this function is documented in the main component
625 * header file, IxEthDB.h.
627 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
628 * or an appropriate error message otherwise
631 IxEthDBStatus
ixEthDBPortVlanMembershipGet(IxEthDBPortId portID
, IxEthDBVlanSet vlanSet
)
633 IX_ETH_DB_CHECK_PORT(portID
);
635 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
637 return ixEthDBVlanTableGet(portID
, ixEthDBPortInfo
[portID
].vlanMembership
, vlanSet
);
641 * @brief enables or disables Egress tagging for one VLAN ID
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
647 * Note that this function is documented in the main component
648 * header file, IxEthDB.h.
650 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
651 * or an appropriate error message otherwise
654 IxEthDBStatus
ixEthDBEgressVlanEntryTaggingEnabledSet(IxEthDBPortId portID
, IxEthDBVlanId vlanID
, BOOL enabled
)
656 IX_ETH_DB_CHECK_PORT(portID
);
658 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
660 IX_ETH_DB_CHECK_VLAN_ID(vlanID
);
662 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
664 return ixEthDBPortVlanMembershipChange(portID
, vlanID
, ixEthDBPortInfo
[portID
].transmitTaggingInfo
, enabled
? ADD_VLAN
: REMOVE_VLAN
);
668 * @brief retrieves the Egress tagging status for one VLAN ID
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)
675 * Note that this function is documented in the main component
676 * header file, IxEthDB.h.
678 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
679 * or an appropriate error message otherwise
682 IxEthDBStatus
ixEthDBEgressVlanEntryTaggingEnabledGet(IxEthDBPortId portID
, IxEthDBVlanId vlanID
, BOOL
*enabled
)
684 IX_ETH_DB_CHECK_PORT(portID
);
686 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
688 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
690 IX_ETH_DB_CHECK_REFERENCE(enabled
);
692 IX_ETH_DB_CHECK_VLAN_ID(vlanID
);
694 *enabled
= ((ixEthDBPortInfo
[portID
].transmitTaggingInfo
[VLAN_SET_OFFSET(vlanID
)] & (1 << VLAN_SET_MASK(vlanID
))) != 0);
696 return IX_ETH_DB_SUCCESS
;
700 * @brief enables or disables Egress VLAN tagging for a VLAN range
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
707 * Note that this function is documented in the main component
708 * header file, IxEthDB.h.
710 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
711 * or an appropriate error message otherwise
714 IxEthDBStatus
ixEthDBEgressVlanRangeTaggingEnabledSet(IxEthDBPortId portID
, IxEthDBVlanId vlanIDMin
, IxEthDBVlanId vlanIDMax
, BOOL enabled
)
716 IX_ETH_DB_CHECK_PORT(portID
);
718 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
720 return ixEthDBPortVlanMembershipRangeChange(portID
, vlanIDMin
, vlanIDMax
, ixEthDBPortInfo
[portID
].transmitTaggingInfo
, enabled
? ADD_VLAN
: REMOVE_VLAN
);
724 * @brief sets the Egress VLAN tagging table (the Transmit Tagging
727 * @param portID ID of the port
728 * @param vlanSet new TTI table
730 * Note that this function is documented in the main component
731 * header file, IxEthDB.h.
733 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
734 * or an appropriate error message otherwise
737 IxEthDBStatus
ixEthDBEgressVlanTaggingEnabledSet(IxEthDBPortId portID
, IxEthDBVlanSet vlanSet
)
739 IxEthDBVlanId vlanID
;
741 IX_ETH_DB_CHECK_PORT(portID
);
743 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
745 IX_ETH_DB_CHECK_REFERENCE(vlanSet
);
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
);
751 return ixEthDBPortVlanTableSet(portID
, ixEthDBPortInfo
[portID
].transmitTaggingInfo
, vlanSet
);
755 * @brief retrieves the Egress VLAN tagging table (the Transmit
756 * Tagging Information table)
758 * @param portID ID of the port
759 * @param vlanSet location to store the port's TTI table
761 * Note that this function is documented in the main component
762 * header file, IxEthDB.h.
764 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
765 * or an appropriate error message otherwise
768 IxEthDBStatus
ixEthDBEgressVlanTaggingEnabledGet(IxEthDBPortId portID
, IxEthDBVlanSet vlanSet
)
770 IX_ETH_DB_CHECK_PORT(portID
);
772 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
774 return ixEthDBVlanTableGet(portID
, ixEthDBPortInfo
[portID
].transmitTaggingInfo
, vlanSet
);
778 * @brief sends the NPE the updated frame filter and default
781 * @param portID ID of the port
783 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
784 * or an appropriate error message otherwise
789 IxEthDBStatus
ixEthDBIngressVlanModeUpdate(IxEthDBPortId portID
)
791 PortInfo
*portInfo
= &ixEthDBPortInfo
[portID
];
792 IxNpeMhMessage message
;
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
);
802 * @brief sets the default Ingress tagging behavior
804 * @param portID ID of the port
805 * @param taggingAction default tagging behavior
807 * Note that this function is documented in the main component
808 * header file, IxEthDB.h.
810 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
811 * or an appropriate error message otherwise
814 IxEthDBStatus
ixEthDBIngressVlanTaggingEnabledSet(IxEthDBPortId portID
, IxEthDBTaggingAction taggingAction
)
818 IX_ETH_DB_CHECK_PORT(portID
);
820 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
822 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
824 portInfo
= &ixEthDBPortInfo
[portID
];
826 if (taggingAction
== IX_ETH_DB_PASS_THROUGH
)
828 portInfo
->npeTaggingAction
= 0x00;
830 else if (taggingAction
== IX_ETH_DB_ADD_TAG
)
832 portInfo
->npeTaggingAction
= 0x02;
834 else if (taggingAction
== IX_ETH_DB_REMOVE_TAG
)
836 portInfo
->npeTaggingAction
= 0x01;
840 return IX_ETH_DB_INVALID_ARG
;
843 portInfo
->taggingAction
= taggingAction
;
845 return ixEthDBIngressVlanModeUpdate(portID
);
849 * @brief retrieves the default Ingress tagging behavior of a port
851 * @param portID ID of the port
852 * @param taggingAction location to save the default tagging behavior
854 * Note that this function is documented in the main component
855 * header file, IxEthDB.h.
857 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
858 * or an appropriate error message otherwise
861 IxEthDBStatus
ixEthDBIngressVlanTaggingEnabledGet(IxEthDBPortId portID
, IxEthDBTaggingAction
*taggingAction
)
863 IX_ETH_DB_CHECK_PORT(portID
);
865 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
867 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
869 IX_ETH_DB_CHECK_REFERENCE(taggingAction
);
871 *taggingAction
= ixEthDBPortInfo
[portID
].taggingAction
;
873 return IX_ETH_DB_SUCCESS
;
877 * @brief sets the Ingress acceptable frame type filter
879 * @param portID ID of the port
880 * @param frameFilter acceptable frame type filter
882 * Note that this function is documented in the main component
883 * header file, IxEthDB.h.
885 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
886 * or an appropriate error message otherwise
889 IxEthDBStatus
ixEthDBAcceptableFrameTypeSet(IxEthDBPortId portID
, IxEthDBFrameFilter frameFilter
)
892 IxEthDBStatus result
= IX_ETH_DB_SUCCESS
;
894 IX_ETH_DB_CHECK_PORT(portID
);
896 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
898 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
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)
905 return IX_ETH_DB_INVALID_ARG
;
908 portInfo
= &ixEthDBPortInfo
[portID
];
910 portInfo
->frameFilter
= frameFilter
;
911 portInfo
->npeFrameFilter
= 0; /* allow all by default */
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))
919 result
= ixEthDBPortVlanMembershipRangeChange(portID
,
920 1, IX_ETH_DB_802_1Q_MAX_VLAN_ID
, portInfo
->vlanMembership
, REMOVE_VLAN
);
922 if (result
== IX_ETH_DB_SUCCESS
)
924 ixEthDBLocalVlanMembershipChange(0, portInfo
->vlanMembership
, ADD_VLAN
);
925 result
= ixEthDBVlanTableRangeUpdate(portID
);
930 if (frameFilter
== IX_ETH_DB_UNTAGGED_FRAMES
)
932 portInfo
->npeFrameFilter
= 0x01;
936 if ((frameFilter
& IX_ETH_DB_UNTAGGED_FRAMES
) == 0)
938 portInfo
->npeFrameFilter
= 0x02;
941 if (result
== IX_ETH_DB_SUCCESS
)
943 result
= ixEthDBIngressVlanModeUpdate(portID
);
950 * @brief retrieves the acceptable frame type filter for a port
952 * @param portID ID of the port
953 * @param frameFilter location to store the frame filter
955 * Note that this function is documented in the main component
956 * header file, IxEthDB.h.
958 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
959 * or an appropriate error message otherwise
962 IxEthDBStatus
ixEthDBAcceptableFrameTypeGet(IxEthDBPortId portID
, IxEthDBFrameFilter
*frameFilter
)
964 IX_ETH_DB_CHECK_PORT(portID
);
966 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
968 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
970 IX_ETH_DB_CHECK_REFERENCE(frameFilter
);
972 *frameFilter
= ixEthDBPortInfo
[portID
].frameFilter
;
974 return IX_ETH_DB_SUCCESS
;
978 * @brief sends an NPE the updated configuration related
979 * to one QoS priority (associated traffic class and AQM mapping)
981 * @param portID ID of the port
982 * @param classIndex QoS priority (traffic class index)
984 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
985 * or an appropriate error message otherwise
990 IxEthDBStatus
ixEthDBUpdateTrafficClass(IxEthDBPortId portID
, UINT32 classIndex
)
992 IxNpeMhMessage message
;
995 UINT32 trafficClass
= ixEthDBPortInfo
[portID
].priorityTable
[classIndex
];
996 UINT32 aqmQueue
= ixEthDBPortInfo
[portID
].ixEthDBTrafficClassAQMAssignments
[trafficClass
];
998 FILL_SETRXQOSENTRY(message
, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID
), classIndex
, trafficClass
, aqmQueue
);
1000 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID
), message
, result
);
1006 * @brief sets the priority mapping table
1008 * @param portID ID of the port
1009 * @param priorityTable new priority mapping table
1011 * Note that this function is documented in the main component
1012 * header file, IxEthDB.h.
1014 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1015 * or an appropriate error message otherwise
1018 IxEthDBStatus
ixEthDBPriorityMappingTableSet(IxEthDBPortId portID
, IxEthDBPriorityTable priorityTable
)
1022 IX_ETH_DB_CHECK_PORT(portID
);
1024 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
1026 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
1028 IX_ETH_DB_CHECK_REFERENCE(priorityTable
);
1030 for (classIndex
= 0 ; classIndex
< IX_IEEE802_1Q_QOS_PRIORITY_COUNT
; classIndex
++)
1033 if (priorityTable
[classIndex
] >= ixEthDBPortInfo
[portID
].ixEthDBTrafficClassCount
)
1035 return IX_ETH_DB_INVALID_PRIORITY
;
1039 /* set new traffic classes */
1040 for (classIndex
= 0 ; classIndex
< IX_IEEE802_1Q_QOS_PRIORITY_COUNT
; classIndex
++)
1042 ixEthDBPortInfo
[portID
].priorityTable
[classIndex
] = priorityTable
[classIndex
];
1044 if (ixEthDBUpdateTrafficClass(portID
, classIndex
) != IX_ETH_DB_SUCCESS
)
1046 return IX_ETH_DB_FAIL
;
1050 return IX_ETH_DB_SUCCESS
;
1054 * @brief retrieves a port's priority mapping table
1056 * @param portID ID of the port
1057 * @param priorityTable location to store the priority table
1059 * Note that this function is documented in the main component
1060 * header file, IxEthDB.h.
1062 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1063 * or an appropriate error message otherwise
1066 IxEthDBStatus
ixEthDBPriorityMappingTableGet(IxEthDBPortId portID
, IxEthDBPriorityTable priorityTable
)
1068 IX_ETH_DB_CHECK_PORT(portID
);
1070 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
1072 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
1074 IX_ETH_DB_CHECK_REFERENCE(priorityTable
);
1076 memcpy(priorityTable
, ixEthDBPortInfo
[portID
].priorityTable
, sizeof (IxEthDBPriorityTable
));
1078 return IX_ETH_DB_SUCCESS
;
1082 * @brief sets one QoS priority => traffic class mapping
1084 * @param portID ID of the port
1085 * @param userPriority QoS (user) priority
1086 * @param trafficClass associated traffic class
1088 * Note that this function is documented in the main component
1089 * header file, IxEthDB.h.
1091 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1092 * or an appropriate error message otherwise
1095 IxEthDBStatus
ixEthDBPriorityMappingClassSet(IxEthDBPortId portID
, IxEthDBPriority userPriority
, IxEthDBPriority trafficClass
)
1097 IX_ETH_DB_CHECK_PORT(portID
);
1099 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
1101 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
1103 /* check ranges for userPriority and trafficClass */
1104 if (userPriority
>= IX_IEEE802_1Q_QOS_PRIORITY_COUNT
|| trafficClass
>= ixEthDBPortInfo
[portID
].ixEthDBTrafficClassCount
)
1106 return IX_ETH_DB_INVALID_PRIORITY
;
1109 ixEthDBPortInfo
[portID
].priorityTable
[userPriority
] = trafficClass
;
1111 return ixEthDBUpdateTrafficClass(portID
, userPriority
);
1115 * @brief retrieves one QoS priority => traffic class mapping
1117 * @param portID ID of the port
1118 * @param userPriority QoS (user) priority
1119 * @param trafficClass location to store the associated traffic class
1121 * Note that this function is documented in the main component
1122 * header file, IxEthDB.h.
1124 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1125 * or an appropriate error message otherwise
1128 IxEthDBStatus
ixEthDBPriorityMappingClassGet(IxEthDBPortId portID
, IxEthDBPriority userPriority
, IxEthDBPriority
*trafficClass
)
1130 IX_ETH_DB_CHECK_PORT(portID
);
1132 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
1134 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
1136 IX_ETH_DB_CHECK_REFERENCE(trafficClass
);
1138 /* check userPriority range */
1139 if (userPriority
>= IX_IEEE802_1Q_QOS_PRIORITY_COUNT
)
1141 return IX_ETH_DB_INVALID_PRIORITY
;
1144 *trafficClass
= ixEthDBPortInfo
[portID
].priorityTable
[userPriority
];
1146 return IX_ETH_DB_SUCCESS
;
1150 * @brief enables or disables the source port extraction
1151 * from the VLAN TPID field
1153 * @param portID ID of the port
1154 * @param enable TRUE to enable or FALSE to disable
1156 * Note that this function is documented in the main component
1157 * header file, IxEthDB.h.
1159 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
1160 * or an appropriate error message otherwise
1163 IxEthDBStatus
ixEthDBVlanPortExtractionEnable(IxEthDBPortId portID
, BOOL enable
)
1165 IxNpeMhMessage message
;
1168 IX_ETH_DB_CHECK_PORT(portID
);
1170 IX_ETH_DB_CHECK_SINGLE_NPE(portID
);
1172 IX_ETH_DB_CHECK_FEATURE(portID
, IX_ETH_DB_VLAN_QOS
);
1174 FILL_SETPORTIDEXTRACTIONMODE(message
, portID
, enable
);
1176 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID
), message
, result
);