summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Li <gavinl@nvidia.com>2024-06-05 11:09:52 +0300
committerFerruh Yigit <ferruh.yigit@amd.com>2024-06-11 15:55:33 +0200
commitfceadac8fec2167edfd616ae7fa136a3590764f9 (patch)
tree71cc31cb8c740d79aa6429906497ef8aa8dd1aab
parentaf3938ffc28731a89ee4aeeadae00ffea204f08e (diff)
net: extend VXLAN header to support more extensions
VXLAN and VXLAN-GPE were supported with similar header structures. In order to add VXLAN-GBP, which is another extension to VXLAN, both extensions are merged in the original VXLAN header structure for an easier usage. More VXLAN extensions may be added in the future in the same single structure. VXLAN and VXLAN-GBP use the same UDP port (4789), while VXLAN-GPE uses a different port (4790). The three protocols have the same header length and overall a similar header structure as below. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R|R|R|R|I|R|R|R| Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VXLAN Network Identifier (VNI) | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 1: VXLAN Header 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R|R|Ver|I|P|B|O| Reserved |Next Protocol | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VXLAN Network Identifier (VNI) | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 2: VXLAN-GPE Header 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |G|R|R|R|I|R|R|R|R|D|R|R|A|R|R|R| Group Policy ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VXLAN Network Identifier (VNI) | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 3: VXLAN-GBP Extension Both GPE and GBP are extending VXLAN by using some reserved bits. It means the packets can be processed with the same pattern and most of the code can be reused. The old field names are kept with the use of anonymous unions. The Group Policy ID (GBP) and the Next Protocol (GPE) fields are overlapping so they are in a union as well. Another improvement is defining and documenting each bit. Instead of adding flow items, a single VXLAN flow item is more flexible as it uses the same header anyway. GBP can be matches with the G bit. GPE can be matched with the UDP port number. VXLAN-GPE flow item and specific header are marked as deprecated. A removal of the deprecated structures and macros may be proposed later. Signed-off-by: Gavin Li <gavinl@nvidia.com> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
-rw-r--r--lib/ethdev/rte_flow.h20
-rw-r--r--lib/net/rte_vxlan.h79
2 files changed, 88 insertions, 11 deletions
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 74cf2e0f59..fb84992b61 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -355,6 +355,9 @@ enum rte_flow_item_type {
RTE_FLOW_ITEM_TYPE_GENEVE,
/**
+ * @deprecated
+ * @see RTE_FLOW_ITEM_TYPE_VXLAN
+ *
* Matches a VXLAN-GPE header.
*
* See struct rte_flow_item_vxlan_gpe.
@@ -1103,7 +1106,12 @@ static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
/**
* RTE_FLOW_ITEM_TYPE_VXLAN.
*
- * Matches a VXLAN header (RFC 7348).
+ * Matches a VXLAN header (RFC 7348),
+ * including GPE (draft-ietf-nvo3-vxlan-gpe-13.txt)
+ * and GBP (draft-smith-vxlan-group-policy-05.txt).
+ *
+ * GPE is distinguished with its UDP port.
+ * UDP port may be specified with ``rte_eth_dev_udp_tunnel_port_add()``.
*/
struct rte_flow_item_vxlan {
union {
@@ -1346,6 +1354,9 @@ static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
#endif
/**
+ * @deprecated
+ * @see rte_flow_item_vxlan
+ *
* RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
*
* Matches a VXLAN-GPE header.
@@ -1367,7 +1378,12 @@ struct rte_flow_item_vxlan_gpe {
};
};
-/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
+/**
+ * @deprecated
+ * @see rte_flow_item_vxlan_mask
+ *
+ * Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE.
+ */
#ifndef __cplusplus
static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
.hdr.vni = "\xff\xff\xff",
diff --git a/lib/net/rte_vxlan.h b/lib/net/rte_vxlan.h
index 57300fb442..140c1d589b 100644
--- a/lib/net/rte_vxlan.h
+++ b/lib/net/rte_vxlan.h
@@ -23,6 +23,7 @@ extern "C" {
/** VXLAN default port. */
#define RTE_VXLAN_DEFAULT_PORT 4789
+/** VXLAN GPE port. */
#define RTE_VXLAN_GPE_DEFAULT_PORT 4790
/**
@@ -33,20 +34,72 @@ extern "C" {
__extension__ /* no named member in struct */
struct rte_vxlan_hdr {
union {
+ rte_be32_t vx_flags; /**< flags (8 bits) + extensions (24 bits). */
struct {
- rte_be32_t vx_flags; /**< flags (8) + Reserved (24). */
- rte_be32_t vx_vni; /**< VNI (24) + Reserved (8). */
- };
+ union {
+ uint8_t flags; /**< Default is I bit, others are extensions. */
+ struct {
+#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+ uint8_t flag_g:1, /**< GBP bit. */
+ flag_rsvd:1, /* Reserved. */
+ flag_ver:2, /**< GPE Protocol Version. */
+ flag_i:1, /**< VNI bit. */
+ flag_p:1, /**< GPE Next Protocol bit. */
+ flag_b:1, /**< GPE Ingress-Replicated BUM. */
+ flag_o:1; /**< GPE OAM Packet bit. */
+#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+ uint8_t flag_o:1,
+ flag_b:1,
+ flag_p:1,
+ flag_i:1,
+ flag_ver:2,
+ flag_rsvd:1,
+ flag_g:1;
+#endif
+ } __rte_packed;
+ }; /* end of 1st byte */
+ union {
+ uint8_t rsvd0[3]; /* Reserved for extensions. */
+ struct {
+#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+ uint8_t rsvd0_gbp1:1, /* Reserved. */
+ flag_d:1, /**< GBP Don't Learn bit. */
+ rsvd0_gbp2:2, /* Reserved. */
+ flag_a:1, /**< GBP Applied bit. */
+ rsvd0_gbp3:3; /* Reserved. */
+#elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+ uint8_t rsvd0_gbp3:3,
+ flag_a:1,
+ rsvd0_gbp2:2,
+ flag_d:1,
+ rsvd0_gbp1:1;
+#endif
+ union {
+ uint16_t policy_id; /**< GBP Identifier. */
+ struct {
+ uint8_t rsvd0_gpe; /* Reserved. */
+ uint8_t proto; /**< GPE Next protocol. */
+ /* 0x01 : IPv4
+ * 0x02 : IPv6
+ * 0x03 : Ethernet
+ * 0x04 : Network Service Header
+ */
+ } __rte_packed;
+ };
+ } __rte_packed;
+ };
+ } __rte_packed;
+ }; /* end of 1st 32-bit word */
+ union {
+ rte_be32_t vx_vni; /**< VNI (24 bits) + reserved (8 bits). */
struct {
- uint8_t flags; /**< Should be 8 (I flag). */
- uint8_t rsvd0[3]; /**< Reserved. */
- uint8_t vni[3]; /**< VXLAN identifier. */
+ uint8_t vni[3]; /**< VXLAN Identifier. */
union {
uint8_t rsvd1; /**< Reserved. */
uint8_t last_rsvd; /**< Reserved. */
};
- };
- };
+ } __rte_packed;
+ }; /* end of 2nd 32-bit word */
} __rte_packed;
/** VXLAN tunnel header length. */
@@ -55,6 +108,9 @@ struct rte_vxlan_hdr {
/**
+ * @deprecated
+ * @see rte_vxlan_hdr
+ *
* VXLAN-GPE protocol header (draft-ietf-nvo3-vxlan-gpe-05).
* Contains the 8-bit flag, 8-bit next-protocol, 24-bit VXLAN Network
* Identifier and Reserved fields (16 bits and 8 bits).
@@ -78,7 +134,12 @@ struct rte_vxlan_gpe_hdr {
};
} __rte_packed;
-/** VXLAN-GPE tunnel header length. */
+/**
+ * @deprecated
+ * @see RTE_ETHER_VXLAN_HLEN
+ *
+ * VXLAN-GPE tunnel header length.
+ */
#define RTE_ETHER_VXLAN_GPE_HLEN (sizeof(struct rte_udp_hdr) + \
sizeof(struct rte_vxlan_gpe_hdr))