1 /* 2 * 802.1Q VLAN protocol definitions 3 * 4 * Copyright (C) 1999-2017, 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 * 25 * <<Broadcom-WL-IPTag/Open:>> 26 * 27 * $Id: vlan.h 700076 2017-05-17 14:42:22Z $ 28 */ 29 30 #ifndef _vlan_h_ 31 #define _vlan_h_ 32 33 #ifndef _TYPEDEFS_H_ 34 #include <typedefs.h> 35 #endif 36 37 /* This marks the start of a packed structure section. */ 38 #include <packed_section_start.h> 39 40 #ifndef VLAN_VID_MASK 41 #define VLAN_VID_MASK 0xfff /* low 12 bits are vlan id */ 42 #endif 43 44 #define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */ 45 #define VLAN_PRI_SHIFT 13 /* user priority */ 46 47 #define VLAN_PRI_MASK 7 /* 3 bits of priority */ 48 49 #define VLAN_TPID_OFFSET 12 /* offset of tag protocol id field */ 50 #define VLAN_TCI_OFFSET 14 /* offset of tag ctrl info field */ 51 52 #define VLAN_TAG_LEN 4 53 #define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN) /* offset in Ethernet II packet only */ 54 55 #define VLAN_TPID 0x8100 /* VLAN ethertype/Tag Protocol ID */ 56 57 struct vlan_header { 58 uint16 vlan_type; /* 0x8100 */ 59 uint16 vlan_tag; /* priority, cfi and vid */ 60 }; 61 62 struct ethervlan_header { 63 uint8 ether_dhost[ETHER_ADDR_LEN]; 64 uint8 ether_shost[ETHER_ADDR_LEN]; 65 uint16 vlan_type; /* 0x8100 */ 66 uint16 vlan_tag; /* priority, cfi and vid */ 67 uint16 ether_type; 68 }; 69 70 struct dot3_mac_llc_snapvlan_header { 71 uint8 ether_dhost[ETHER_ADDR_LEN]; /* dest mac */ 72 uint8 ether_shost[ETHER_ADDR_LEN]; /* src mac */ 73 uint16 length; /* frame length incl header */ 74 uint8 dsap; /* always 0xAA */ 75 uint8 ssap; /* always 0xAA */ 76 uint8 ctl; /* always 0x03 */ 77 uint8 oui[3]; /* RFC1042: 0x00 0x00 0x00 78 * Bridge-Tunnel: 0x00 0x00 0xF8 79 */ 80 uint16 vlan_type; /* 0x8100 */ 81 uint16 vlan_tag; /* priority, cfi and vid */ 82 uint16 ether_type; /* ethertype */ 83 }; 84 85 #define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN) 86 87 88 /* This marks the end of a packed structure section. */ 89 #include <packed_section_end.h> 90 91 #define ETHERVLAN_MOVE_HDR(d, s) \ 92 do { \ 93 struct ethervlan_header t; \ 94 t = *(struct ethervlan_header *)(s); \ 95 *(struct ethervlan_header *)(d) = t; \ 96 } while (0) 97 98 #endif /* _vlan_h_ */ 99