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