xref: /titanic_41/usr/src/uts/common/sys/vlan.h (revision 1c42de6d020629af774dd9e9fc81be3f3ed9398e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * vlan.h header for common (non-media specific) VLAN declarations.
28  */
29 
30 #ifndef	_SYS_VLAN_H
31 #define	_SYS_VLAN_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	VLAN_TAGSZ	4
40 
41 #define	VLAN_ID_MASK	0x0fffu
42 #define	VLAN_ID_SIZE	12
43 #define	VLAN_ID_SHIFT	0
44 
45 #define	VLAN_CFI_MASK	0x0001u
46 #define	VLAN_CFI_SIZE	1
47 #define	VLAN_CFI_SHIFT	(VLAN_ID_SHIFT + VLAN_ID_SIZE)
48 
49 #define	VLAN_PRI_MASK	0x0007u
50 #define	VLAN_PRI_SIZE	3
51 #define	VLAN_PRI_SHIFT	(VLAN_CFI_SHIFT + VLAN_CFI_SIZE)
52 
53 #define	VLAN_ID_NONE	0
54 #define	VLAN_ID_MIN	1
55 #define	VLAN_ID_MAX	4094
56 
57 #define	VLAN_TCI(pri, cfi, vid) \
58 	(((pri) << VLAN_PRI_SHIFT) | \
59 	((cfi) << VLAN_CFI_SHIFT) | \
60 	((vid) << VLAN_ID_SHIFT))
61 
62 /*
63  * Deconstruct a VTAG ...
64  */
65 #define	VLAN_PRI(tci)	(((tci) >> VLAN_PRI_SHIFT) & VLAN_PRI_MASK)
66 #define	VLAN_CFI(tci)	(((tci) >> VLAN_CFI_SHIFT) & VLAN_CFI_MASK)
67 #define	VLAN_ID(tci)	(((tci) >> VLAN_ID_SHIFT) & VLAN_ID_MASK)
68 
69 #define	VLAN_BAND_MAP	32
70 
71 #define	VLAN_MBLKPRI(mp)				\
72 	((((mp)->b_band) / VLAN_BAND_MAP) > 7 ? 0 :	\
73 	(((mp)->b_band) / VLAN_BAND_MAP))
74 
75 #ifdef	__cplusplus
76 }
77 #endif
78 
79 #endif	/* _SYS_VLAN_H */
80