[RFC] net: extend VXLAN header to support more extensions

Message ID 20240130093959.1918280-1-gavinl@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [RFC] net: extend VXLAN header to support more extensions |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional fail Functional issues

Commit Message

Gavin Li Jan. 30, 2024, 9:39 a.m. UTC
  Currently, DPDK supports VXLAN and VXLAN-GPE with similar header
structures and we are working on adding support for VXLAN-GBP which is
another extension to VXLAN. More extension of VXLAN may be added in the
future.

VXLAN and VXLAN-GBP use the same UDP port(4789) while VXLAN-GPE uses a
different one, 4790. The three protocols have the same header length and
overall 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 VXLAN-GPE and VXLAN-GBP extended VXLAN by redefining its reserved
bits, which means the packets can be processed with same pattern and most
of the code can be reused. Instead of adding more new items by
copying/pasting code for the VXLAN extensions in the future, it’s better
to use existing VXLAN infrastructure and add support code in it.

In this patch, all the VXLAN extension header will be merged with VXLAN as
union if the overlapped field has different format among protocols. The
existing VXLAN-GPE will be marked as deprecated and new extensions of
VXLAN should be added to VXLAN instead of a new RTE item.

Signed-off-by: Gavin Li <gavinl@nvidia.com>
---
 doc/guides/rel_notes/deprecation.rst |  5 +++
 lib/ethdev/rte_flow.h                | 13 +++++-
 lib/net/rte_vxlan.h                  | 63 ++++++++++++++++++++++++++--
 3 files changed, 76 insertions(+), 5 deletions(-)
  

Patch

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 81b93515cb..f9cf931b77 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -95,6 +95,11 @@  Deprecation Notices
   - ``rte_flow_item_pppoe``
   - ``rte_flow_item_pppoe_proto_id``
 
+* ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE`` is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
+  The item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``, the struct ``rte_flow_item_vxlan_gpe``, its mask ``rte_flow_item_vxlan_gpe_mask``,
+  and the header struct ``rte_vxlan_gpe_hdr`` with the macro ``RTE_ETHER_VXLAN_GPE_HLEN``
+  will be removed in DPDK 25.11.
+
 * ethdev: Queue specific stats fields will be removed from ``struct rte_eth_stats``.
   Mentioned fields are: ``q_ipackets``, ``q_opackets``, ``q_ibytes``, ``q_obytes``,
   ``q_errors``.
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 1267c146e5..a9943106d9 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -355,6 +355,7 @@  enum rte_flow_item_type {
 	RTE_FLOW_ITEM_TYPE_GENEVE,
 
 	/**
+	 * @deprecated Replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
 	 * Matches a VXLAN-GPE header.
 	 *
 	 * See struct rte_flow_item_vxlan_gpe.
@@ -1096,7 +1097,11 @@  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 {
@@ -1339,6 +1344,7 @@  static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
 #endif
 
 /**
+ * @deprecated Replaced with ``rte_flow_item_vxlan``.
  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
  *
  * Matches a VXLAN-GPE header.
@@ -1360,7 +1366,10 @@  struct rte_flow_item_vxlan_gpe {
 	};
 };
 
-/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
+/**
+ * @deprecated Replaced with ``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 997fc784fc..0e236b5529 100644
--- a/lib/net/rte_vxlan.h
+++ b/lib/net/rte_vxlan.h
@@ -38,8 +38,61 @@  struct rte_vxlan_hdr {
 			rte_be32_t vx_vni;   /**< VNI (24) + Reserved (8). */
 		};
 		struct {
-			uint8_t    flags;    /**< Should be 8 (I flag). */
-			uint8_t    rsvd0[3]; /**< Reserved. */
+			union {
+				uint8_t    flags;    /**< Should be 8 (I flag). */
+				/* Flag bits defined by GPE */
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+				uint8_t flag_o:1,
+					flag_b:1,
+					flag_p:1,
+					flag_i_gpe:1,
+					flag_ver:2,
+					rsvd_gpe:2;
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+				uint8_t rsvd_gpe:2,
+					flag_ver:2,
+					flag_i_gpe:1,
+					flag_p:1,
+					flag_b:1,
+					flag_o:1;
+#endif
+				/* Flag bits defined by GBP */
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+				uint8_t rsvd_gbp1:3,
+					flag_i_gbp:1,
+					rsvd_gbp2:3,
+					flag_g:1;
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+				uint8_t flag_g:1,
+					rsvd_gbp1:3,
+					flag_i_gbp:1,
+					rsvd_gbp2:3;
+#endif
+			};
+			union {
+				uint8_t    rsvd0[3]; /**< Reserved. */
+				/* Overlap with rte_vxlan_gpe_hdr which is deprecated.*/
+				struct {
+					uint8_t rsvd0_gpe[2]; /**< Reserved. */
+					uint8_t proto;	   /**< Next protocol. */
+				};
+				struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+					uint8_t rsvd0_gbp1:3,
+						policy_applied:1,
+						rsvd0_gbp2:2,
+						dont_learn:1,
+						rsvd0_gbp3:1;
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+					uint8_t rsvd0_gbp1:1,
+						dont_learn:1,
+						rsvd0_gbp2:2,
+						policy_applied:1,
+						rsvd0_gbp3:3;
+#endif
+					uint16_t policy_id;
+				};
+			};
 			uint8_t    vni[3];   /**< VXLAN identifier. */
 			uint8_t    rsvd1;    /**< Reserved. */
 		};
@@ -52,6 +105,7 @@  struct rte_vxlan_hdr {
 
 
 /**
+ * @deprecated Replaced with ``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).
@@ -75,7 +129,10 @@  struct rte_vxlan_gpe_hdr {
 	};
 } __rte_packed;
 
-/** VXLAN-GPE tunnel header length. */
+/**
+ * @deprecated Replaced with ``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))