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