• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * 802.1Q VLAN protocol definitions
3  *
4  * Copyright (C) 1999-2013, Broadcom Corporation
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *      Notwithstanding the above, under no circumstances may you combine this
21  * software in any way with any other Broadcom software provided under a license
22  * other than the GPL, without Broadcom's express prior written consent.
23  *
24  * $Id: vlan.h 382883 2013-02-04 23:26:09Z $
25  */
26 
27 #ifndef _vlan_h_
28 #define _vlan_h_
29 
30 #ifndef _TYPEDEFS_H_
31 #include <typedefs.h>
32 #endif
33 
34 /* This marks the start of a packed structure section. */
35 #include <packed_section_start.h>
36 
37 #ifndef	 VLAN_VID_MASK
38 #define VLAN_VID_MASK		0xfff	/* low 12 bits are vlan id */
39 #endif
40 
41 #define	VLAN_CFI_SHIFT		12	/* canonical format indicator bit */
42 #define VLAN_PRI_SHIFT		13	/* user priority */
43 
44 #define VLAN_PRI_MASK		7	/* 3 bits of priority */
45 
46 #define	VLAN_TPID_OFFSET	12	/* offset of tag protocol id field */
47 #define	VLAN_TCI_OFFSET		14	/* offset of tag ctrl info field */
48 
49 #define	VLAN_TAG_LEN		4
50 #define	VLAN_TAG_OFFSET		(2 * ETHER_ADDR_LEN)	/* offset in Ethernet II packet only */
51 
52 #define VLAN_TPID		0x8100	/* VLAN ethertype/Tag Protocol ID */
53 
54 struct vlan_header {
55 	uint16	vlan_type;		/* 0x8100 */
56 	uint16	vlan_tag;		/* priority, cfi and vid */
57 };
58 
59 struct ethervlan_header {
60 	uint8	ether_dhost[ETHER_ADDR_LEN];
61 	uint8	ether_shost[ETHER_ADDR_LEN];
62 	uint16	vlan_type;		/* 0x8100 */
63 	uint16	vlan_tag;		/* priority, cfi and vid */
64 	uint16	ether_type;
65 };
66 
67 struct dot3_mac_llc_snapvlan_header {
68 	uint8	ether_dhost[ETHER_ADDR_LEN];	/* dest mac */
69 	uint8	ether_shost[ETHER_ADDR_LEN];	/* src mac */
70 	uint16	length;				/* frame length incl header */
71 	uint8	dsap;				/* always 0xAA */
72 	uint8	ssap;				/* always 0xAA */
73 	uint8	ctl;				/* always 0x03 */
74 	uint8	oui[3];				/* RFC1042: 0x00 0x00 0x00
75 						 * Bridge-Tunnel: 0x00 0x00 0xF8
76 						 */
77 	uint16	vlan_type;			/* 0x8100 */
78 	uint16	vlan_tag;			/* priority, cfi and vid */
79 	uint16	ether_type;			/* ethertype */
80 };
81 
82 #define	ETHERVLAN_HDR_LEN	(ETHER_HDR_LEN + VLAN_TAG_LEN)
83 
84 
85 /* This marks the end of a packed structure section. */
86 #include <packed_section_end.h>
87 
88 #define ETHERVLAN_MOVE_HDR(d, s) \
89 do { \
90 	struct ethervlan_header t; \
91 	t = *(struct ethervlan_header *)(s); \
92 	*(struct ethervlan_header *)(d) = t; \
93 } while (0)
94 
95 #endif /* _vlan_h_ */
96