Skip to contentSkip to conversation

support VXLAN-GPE header fields(flags, rsvd0 and rsvd1) matching

RFC New Gavin Li 1 participant 6 messages Jan 11, 2024 Network drivers

lore
Share & tools
lore

Gavin Li

author
#0 lore raw

cover support VXLAN-GPE header fields(flags, rsvd0 and rsvd1) matching

Previously, VXLAN-GPE in DPDK only supports VNI and next protocol header fields. This patch series add support for flags and reserved field 0 and 1.

Below is the VXLAN-GPE header defined in the lasted draft.
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    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Gavin Li (5):
net/mlx5: support VXLAN-GPE flags matching app/testpmd: support VXLAN-GPE flags net/mlx5: support VXLAN-GPE reserved fields matching app/testpmd: support VXLAN-GPE reserved fields net/mlx5/hws: support VXLAN-GPE matching

 app/test-pmd/cmdline_flow.c                 |  30 +++++
 doc/guides/nics/mlx5.rst                    |   5 +
 doc/guides/rel_notes/release_24_03.rst      |   6 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   3 +
 drivers/net/mlx5/hws/mlx5dr_definer.c       | 117 ++++++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_definer.h       |  13 +++
 drivers/net/mlx5/mlx5_flow.c                |   6 +
 drivers/net/mlx5/mlx5_flow_dv.c             |  32 +++++-
 drivers/net/mlx5/mlx5_flow_hw.c             |   1 +
 9 files changed, 207 insertions(+), 6 deletions(-)
Signature · 1 line
2.39.1
author
#1 lore raw

RFC 1/5 net/mlx5: support VXLAN-GPE flags matching

This commit adds support for matching on the flags field of VXLAN-GPE header (the first 8-bits).

---
 drivers/net/mlx5/mlx5_flow.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5_flow.c +1 -0
index 85e8c77c81..ffa183dc1b 100644
@@ -3292,6 +3292,7 @@ mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
 	struct rte_flow_item_vxlan_gpe nic_mask = {
 		.vni = "\xff\xff\xff",
 		.protocol = 0xff,
+		.flags = 0xff,
 	};
 
 	if (!priv->sh->config.l3_vxlan_en)
Signature · 1 line
2.39.1
author
#2 lore raw

RFC 2/5 app/testpmd: support VXLAN-GPE flags

In reply to Gavin Li

Add support for VXLAN-GPE flags field in flow rule pattern to testpmd.

---
 app/test-pmd/cmdline_flow.c                 | 10 ++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
 2 files changed, 11 insertions(+)
app/test-pmd/cmdline_flow.c +10 -0
index ce71818705..deb2d80301 100644
@@ -401,6 +401,7 @@ enum index {
 	ITEM_VXLAN_GPE,
 	ITEM_VXLAN_GPE_VNI,
 	ITEM_VXLAN_GPE_PROTO,
+	ITEM_VXLAN_GPE_FLAGS,
 	ITEM_ARP_ETH_IPV4,
 	ITEM_ARP_ETH_IPV4_SHA,
 	ITEM_ARP_ETH_IPV4_SPA,
@@ -1789,6 +1790,7 @@ static const enum index item_geneve[] = {
 static const enum index item_vxlan_gpe[] = {
 	ITEM_VXLAN_GPE_VNI,
 	ITEM_VXLAN_GPE_PROTO,
+	ITEM_VXLAN_GPE_FLAGS,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -4936,6 +4938,14 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
 					     protocol)),
 	},
+	[ITEM_VXLAN_GPE_FLAGS] = {
+		.name = "flags",
+		.help = "VXLAN-GPE flags",
+		.next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
+					     flags)),
+	},
 	[ITEM_ARP_ETH_IPV4] = {
 		.name = "arp_eth_ipv4",
 		.help = "match ARP header for Ethernet/IPv4",
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
index 447e28e694..9c6b04442f 100644
@@ -3703,6 +3703,7 @@ This section lists supported pattern items and their attributes, if any.
 - ``vxlan-gpe``: match VXLAN-GPE header.
 
   - ``vni {unsigned}``: VXLAN-GPE identifier.
+  - ``flags {unsigned}``: VXLAN-GPE flags.
 
 - ``arp_eth_ipv4``: match ARP header for Ethernet/IPv4.
 
Signature · 1 line
2.39.1
author
#3 lore raw

RFC 3/5 net/mlx5: support VXLAN-GPE reserved fields matching

In reply to Gavin Li

This adds matching on the reserved fields of VXLAN-GPE header (the 16-bits before Next Protocol and the last 8-bits).

To support all the header fields, tunnel_header_0_1 should be supported by FW and misc5_cap is set.

If one of the reserved fields is matched on, misc5 is used for matching. Otherwise, keep using misc3

---
 doc/guides/nics/mlx5.rst        |  5 +++++
 drivers/net/mlx5/mlx5_flow.c    |  5 +++++
 drivers/net/mlx5/mlx5_flow_dv.c | 32 ++++++++++++++++++++++++++------
 3 files changed, 36 insertions(+), 6 deletions(-)
doc/guides/nics/mlx5.rst +5 -0
index 7bfd6c6aeb..27384d5a86 100644
@@ -311,6 +311,11 @@ Limitations
   Group zero's behavior may differ which depends on FW.
   Matching value equals 0 (value & mask) is not supported.
 
+- Matching on VXLAN-GPE header fields:
+
+     - ``rsvd0``/``rsvd1`` matching support depends on FW version when using DV flow
+       engine (``dv_flow_en`` = 1).
+
 - L3 VXLAN and VXLAN-GPE tunnels cannot be supported together with MPLSoGRE and MPLSoUDP.
 
 - MPLSoGRE is not supported in HW steering (``dv_flow_en`` = 2).
drivers/net/mlx5/mlx5_flow.c +5 -0
index ffa183dc1b..9b6f483d3f 100644
@@ -3316,6 +3316,11 @@ mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
 					  "no outer UDP layer found");
 	if (!mask)
 		mask = &rte_flow_item_vxlan_gpe_mask;
+	if (priv->sh->misc5_cap && priv->sh->tunnel_header_0_1) {
+		nic_mask.rsvd0[0] = 0xff;
+		nic_mask.rsvd0[1] = 0xff;
+		nic_mask.rsvd1 = 0xff;
+	}
 	ret = mlx5_flow_item_acceptable
 		(item, (const uint8_t *)mask,
 		 (const uint8_t *)&nic_mask,
drivers/net/mlx5/mlx5_flow_dv.c +26 -6
index 97f55003c3..f3589da654 100644
@@ -9813,14 +9813,10 @@ flow_dv_translate_item_vxlan_gpe(void *key, const struct rte_flow_item *item,
 		vxlan_v = vxlan_m;
 	else if (key_type == MLX5_SET_MATCHER_HS_V)
 		vxlan_m = vxlan_v;
-	for (i = 0; i < size; ++i)
-		vni_v[i] = vxlan_m->hdr.vni[i] & vxlan_v->hdr.vni[i];
 	if (vxlan_m->hdr.flags) {
 		flags_m = vxlan_m->hdr.flags;
 		flags_v = vxlan_v->hdr.flags;
 	}
-	MLX5_SET(fte_match_set_misc3, misc_v, outer_vxlan_gpe_flags,
-		 flags_m & flags_v);
 	m_protocol = vxlan_m->hdr.protocol;
 	v_protocol = vxlan_v->hdr.protocol;
 	if (!m_protocol) {
@@ -9839,8 +9835,32 @@ flow_dv_translate_item_vxlan_gpe(void *key, const struct rte_flow_item *item,
 		if (key_type & MLX5_SET_MATCHER_M)
 			v_protocol = m_protocol;
 	}
-	MLX5_SET(fte_match_set_misc3, misc_v,
-		 outer_vxlan_gpe_next_protocol, m_protocol & v_protocol);
+	/*
+	 * If only match flags/protocol/vni field, keep using misc3 for matching.
+	 * If need to match rsvd0 or rsvd1, using misc5 and do not need using misc3.
+	 */
+	if (!(vxlan_m->hdr.rsvd0[0] || vxlan_m->hdr.rsvd0[1] || vxlan_m->hdr.rsvd1)) {
+		for (i = 0; i < size; ++i)
+			vni_v[i] = vxlan_m->hdr.vni[i] & vxlan_v->hdr.vni[i];
+		MLX5_SET(fte_match_set_misc3, misc_v, outer_vxlan_gpe_flags,
+			 flags_m & flags_v);
+		MLX5_SET(fte_match_set_misc3, misc_v,
+			 outer_vxlan_gpe_next_protocol, m_protocol & v_protocol);
+	} else {
+		uint32_t tunnel_v;
+		void *misc5_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_5);
+
+		tunnel_v = (flags_m & flags_v) << 24 |
+			   (vxlan_v->hdr.rsvd0[0] & vxlan_m->hdr.rsvd0[0]) << 16 |
+			   (vxlan_v->hdr.rsvd0[1] & vxlan_m->hdr.rsvd0[1]) << 8 |
+			   (m_protocol & v_protocol);
+		MLX5_SET(fte_match_set_misc5, misc5_v, tunnel_header_0, tunnel_v);
+		tunnel_v = (vxlan_v->hdr.vni[0] & vxlan_m->hdr.vni[0]) << 24 |
+			   (vxlan_v->hdr.vni[1] & vxlan_m->hdr.vni[1]) << 16 |
+			   (vxlan_v->hdr.vni[2] & vxlan_m->hdr.vni[2]) << 8 |
+			   (vxlan_v->hdr.rsvd1 & vxlan_m->hdr.rsvd1);
+		MLX5_SET(fte_match_set_misc5, misc5_v, tunnel_header_1, tunnel_v);
+	}
 }
 
 /**
Signature · 1 line
2.39.1
author
#4 lore raw

RFC 4/5 app/testpmd: support VXLAN-GPE reserved fields

In reply to Gavin Li

Add support for VXLAN-GPE rsvd0 and rsvd1 fields in flow rule pattern to testpmd

---
 app/test-pmd/cmdline_flow.c                 | 20 ++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
 2 files changed, 22 insertions(+)
app/test-pmd/cmdline_flow.c +20 -0
index deb2d80301..1d726835e7 100644
@@ -402,6 +402,8 @@ enum index {
 	ITEM_VXLAN_GPE_VNI,
 	ITEM_VXLAN_GPE_PROTO,
 	ITEM_VXLAN_GPE_FLAGS,
+	ITEM_VXLAN_GPE_RSVD0,
+	ITEM_VXLAN_GPE_RSVD1,
 	ITEM_ARP_ETH_IPV4,
 	ITEM_ARP_ETH_IPV4_SHA,
 	ITEM_ARP_ETH_IPV4_SPA,
@@ -1791,6 +1793,8 @@ static const enum index item_vxlan_gpe[] = {
 	ITEM_VXLAN_GPE_VNI,
 	ITEM_VXLAN_GPE_PROTO,
 	ITEM_VXLAN_GPE_FLAGS,
+	ITEM_VXLAN_GPE_RSVD0,
+	ITEM_VXLAN_GPE_RSVD1,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -4946,6 +4950,22 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
 					     flags)),
 	},
+	[ITEM_VXLAN_GPE_RSVD0] = {
+		.name = "rsvd0",
+		.help = "VXLAN-GPE rsvd0",
+		.next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
+					     rsvd0)),
+	},
+	[ITEM_VXLAN_GPE_RSVD1] = {
+		.name = "rsvd1",
+		.help = "VXLAN-GPE rsvd1",
+		.next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
+					     rsvd1)),
+	},
 	[ITEM_ARP_ETH_IPV4] = {
 		.name = "arp_eth_ipv4",
 		.help = "match ARP header for Ethernet/IPv4",
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2 -0
index 9c6b04442f..50fad11fce 100644
@@ -3704,6 +3704,8 @@ This section lists supported pattern items and their attributes, if any.
 
   - ``vni {unsigned}``: VXLAN-GPE identifier.
   - ``flags {unsigned}``: VXLAN-GPE flags.
+  - ``rsvd0 {unsigned}``: VXLAN-GPE reserved field 0.
+  - ``rsvd1 {unsigned}``: VXLAN-GPE reserved field 1.
 
 - ``arp_eth_ipv4``: match ARP header for Ethernet/IPv4.
 
Signature · 1 line
2.39.1
author
#5 lore raw

RFC 5/5 net/mlx5/hws: support VXLAN-GPE matching

In reply to Gavin Li

Add support for matching VXLAN-GPE tunnel header.

---
 doc/guides/rel_notes/release_24_03.rst |   6 ++
 drivers/net/mlx5/hws/mlx5dr_definer.c  | 117 +++++++++++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_definer.h  |  13 +++
 drivers/net/mlx5/mlx5_flow_hw.c        |   1 +
 4 files changed, 137 insertions(+)
doc/guides/rel_notes/release_24_03.rst +6 -0
index 2c0e2930cc..d5e1b1ad37 100644
@@ -59,6 +59,12 @@ New Features
 
   * Added support for accumulating from src field to dst field.
 
+  * Added support for VXLAN-GPE flags/rsvd0/rsvd fields matching in DV flow
+    engine (``dv_flow_en`` = 1).
+
+  * Added support for VXLAN-GPE matching in HW Steering flow engine
+    (``dv_flow_en`` = 2).
+
 
 Removed Items
 -------------
drivers/net/mlx5/hws/mlx5dr_definer.c +117 -0

147 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_definer.h +13 -0
index 6f1c99e37a..3dc5f4438d 100644
@@ -91,6 +91,11 @@ enum mlx5dr_definer_fname {
 	MLX5DR_DEFINER_FNAME_VPORT_REG_C_0,
 	MLX5DR_DEFINER_FNAME_VXLAN_FLAGS,
 	MLX5DR_DEFINER_FNAME_VXLAN_VNI,
+	MLX5DR_DEFINER_FNAME_VXLAN_GPE_FLAGS,
+	MLX5DR_DEFINER_FNAME_VXLAN_GPE_RSVD0,
+	MLX5DR_DEFINER_FNAME_VXLAN_GPE_PROTO,
+	MLX5DR_DEFINER_FNAME_VXLAN_GPE_VNI,
+	MLX5DR_DEFINER_FNAME_VXLAN_GPE_RSVD1,
 	MLX5DR_DEFINER_FNAME_SOURCE_QP,
 	MLX5DR_DEFINER_FNAME_REG_0,
 	MLX5DR_DEFINER_FNAME_REG_1,
@@ -593,6 +598,14 @@ struct mlx5_ifc_header_vxlan_bits {
 	u8 reserved2[0x8];
 };
 
+struct mlx5_ifc_header_vxlan_gpe_bits {
+	u8 flags[0x8];
+	u8 rsvd0[0x10];
+	u8 protocol[0x8];
+	u8 vni[0x18];
+	u8 rsvd1[0x8];
+};
+
 struct mlx5_ifc_header_gre_bits {
 	union {
 		u8 c_rsvd0_ver[0x10];
drivers/net/mlx5/mlx5_flow_hw.c +1 -0
index c4a90a3690..6d8f4f8f8b 100644
@@ -6827,6 +6827,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
 		case RTE_FLOW_ITEM_TYPE_GTP:
 		case RTE_FLOW_ITEM_TYPE_GTP_PSC:
 		case RTE_FLOW_ITEM_TYPE_VXLAN:
+		case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
 		case RTE_FLOW_ITEM_TYPE_MPLS:
 		case MLX5_RTE_FLOW_ITEM_TYPE_SQ:
 		case RTE_FLOW_ITEM_TYPE_GRE:
Signature · 1 line
2.39.1