2 * 802.1Q VLAN protocol definitions
4 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * $Id: vlan.h,v 9.7 2009-03-13 01:11:50 Exp $
28 /* This marks the start of a packed structure section. */
29 #include <packed_section_start.h>
31 #define VLAN_VID_MASK 0xfff /* low 12 bits are vlan id */
32 #define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
33 #define VLAN_PRI_SHIFT 13 /* user priority */
35 #define VLAN_PRI_MASK 7 /* 3 bits of priority */
37 #define VLAN_TAG_LEN 4
38 #define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN) /* offset in Ethernet II packet only */
40 #define VLAN_TPID 0x8100 /* VLAN ethertype/Tag Protocol ID */
42 struct ethervlan_header
{
43 uint8 ether_dhost
[ETHER_ADDR_LEN
];
44 uint8 ether_shost
[ETHER_ADDR_LEN
];
45 uint16 vlan_type
; /* 0x8100 */
46 uint16 vlan_tag
; /* priority, cfi and vid */
50 #define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN)
53 /* This marks the end of a packed structure section. */
54 #include <packed_section_end.h>
56 #define ETHERVLAN_MOVE_HDR(d, s) \
58 struct ethervlan_header t; \
59 t = *(struct ethervlan_header *)(s); \
60 *(struct ethervlan_header *)(d) = t; \