1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018-2019 Intel Corporation 3 */ 4 5 #ifndef _RTE_VXLAN_H_ 6 #define _RTE_VXLAN_H_ 7 8 /** 9 * @file 10 * 11 * VXLAN-related definitions 12 */ 13 14 #include <stdint.h> 15 16 #include <rte_byteorder.h> 17 #include <rte_udp.h> 18 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /** VXLAN default port. */ 25 #define RTE_VXLAN_DEFAULT_PORT 4789 26 #define RTE_VXLAN_GPE_DEFAULT_PORT 4790 27 28 /** 29 * VXLAN protocol header. 30 * Contains the 8-bit flag, 24-bit VXLAN Network Identifier and 31 * Reserved fields (24 bits and 8 bits) 32 */ 33 __extension__ /* no named member in struct */ 34 struct rte_vxlan_hdr { 35 union { 36 struct { 37 rte_be32_t vx_flags; /**< flags (8) + Reserved (24). */ 38 rte_be32_t vx_vni; /**< VNI (24) + Reserved (8). */ 39 }; 40 struct { 41 uint8_t flags; /**< Should be 8 (I flag). */ 42 uint8_t rsvd0[3]; /**< Reserved. */ 43 uint8_t vni[3]; /**< VXLAN identifier. */ 44 uint8_t rsvd1; /**< Reserved. */ 45 }; 46 }; 47 } __rte_packed; 48 49 /** VXLAN tunnel header length. */ 50 #define RTE_ETHER_VXLAN_HLEN \ 51 (sizeof(struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr)) 52 53 54 /** 55 * VXLAN-GPE protocol header (draft-ietf-nvo3-vxlan-gpe-05). 56 * Contains the 8-bit flag, 8-bit next-protocol, 24-bit VXLAN Network 57 * Identifier and Reserved fields (16 bits and 8 bits). 58 */ 59 __extension__ /* no named member in struct */ 60 struct rte_vxlan_gpe_hdr { 61 union { 62 struct { 63 uint8_t vx_flags; /**< flag (8). */ 64 uint8_t reserved[2]; /**< Reserved (16). */ 65 uint8_t protocol; /**< next-protocol (8). */ 66 rte_be32_t vx_vni; /**< VNI (24) + Reserved (8). */ 67 }; 68 struct { 69 uint8_t flags; /**< Flags. */ 70 uint8_t rsvd0[2]; /**< Reserved. */ 71 uint8_t proto; /**< Next protocol. */ 72 uint8_t vni[3]; /**< VXLAN identifier. */ 73 uint8_t rsvd1; /**< Reserved. */ 74 }; 75 }; 76 } __rte_packed; 77 78 /** VXLAN-GPE tunnel header length. */ 79 #define RTE_ETHER_VXLAN_GPE_HLEN (sizeof(struct rte_udp_hdr) + \ 80 sizeof(struct rte_vxlan_gpe_hdr)) 81 82 /* VXLAN-GPE next protocol types */ 83 #define RTE_VXLAN_GPE_TYPE_IPV4 1 /**< IPv4 Protocol. */ 84 #define RTE_VXLAN_GPE_TYPE_IPV6 2 /**< IPv6 Protocol. */ 85 #define RTE_VXLAN_GPE_TYPE_ETH 3 /**< Ethernet Protocol. */ 86 #define RTE_VXLAN_GPE_TYPE_NSH 4 /**< NSH Protocol. */ 87 #define RTE_VXLAN_GPE_TYPE_MPLS 5 /**< MPLS Protocol. */ 88 #define RTE_VXLAN_GPE_TYPE_GBP 6 /**< GBP Protocol. */ 89 #define RTE_VXLAN_GPE_TYPE_VBNG 7 /**< vBNG Protocol. */ 90 91 92 #ifdef __cplusplus 93 } 94 #endif 95 96 #endif /* RTE_VXLAN_H_ */ 97