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