vlan.h 3.3 KB

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