[v7,3/7] ethdev: use VXLAN protocol struct for flow matching

Message ID 20230203164854.602595-4-ferruh.yigit@amd.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series start cleanup of rte_flow_item_* |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Ferruh Yigit Feb. 3, 2023, 4:48 p.m. UTC
  From: Thomas Monjalon <thomas@monjalon.net>

As announced in the deprecation notice, flow item structures
should re-use the protocol header definitions from the directory lib/net/.

In the case of VXLAN-GPE, the protocol struct is added
in an unnamed union, keeping old field names.

The VXLAN headers (including VXLAN-GPE) are used in apps and drivers
instead of the redundant fields in the flow items.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 app/test-flow-perf/actions_gen.c         |  2 +-
 app/test-flow-perf/items_gen.c           | 12 +++----
 app/test-pmd/cmdline_flow.c              | 10 +++---
 doc/guides/prog_guide/rte_flow.rst       | 11 ++-----
 doc/guides/rel_notes/deprecation.rst     |  1 -
 drivers/net/bnxt/bnxt_flow.c             | 12 ++++---
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 42 ++++++++++++------------
 drivers/net/hns3/hns3_flow.c             | 12 +++----
 drivers/net/i40e/i40e_flow.c             |  4 +--
 drivers/net/ice/ice_switch_filter.c      | 18 +++++-----
 drivers/net/ipn3ke/ipn3ke_flow.c         |  4 +--
 drivers/net/ixgbe/ixgbe_flow.c           | 18 +++++-----
 drivers/net/mlx5/mlx5_flow.c             | 16 ++++-----
 drivers/net/mlx5/mlx5_flow_dv.c          | 40 +++++++++++-----------
 drivers/net/mlx5/mlx5_flow_verbs.c       |  8 ++---
 drivers/net/sfc/sfc_flow.c               |  6 ++--
 drivers/net/sfc/sfc_mae.c                |  8 ++---
 lib/ethdev/rte_flow.h                    | 24 ++++++++++----
 18 files changed, 126 insertions(+), 122 deletions(-)
  

Patch

diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c
index 63f05d87fa86..f1d59313256d 100644
--- a/app/test-flow-perf/actions_gen.c
+++ b/app/test-flow-perf/actions_gen.c
@@ -874,7 +874,7 @@  add_vxlan_encap(struct rte_flow_action *actions,
 	items[2].type = RTE_FLOW_ITEM_TYPE_UDP;
 
 
-	item_vxlan.vni[2] = 1;
+	item_vxlan.hdr.vni[2] = 1;
 	items[3].spec = &item_vxlan;
 	items[3].mask = &item_vxlan;
 	items[3].type = RTE_FLOW_ITEM_TYPE_VXLAN;
diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c
index b7f51030a119..a58245239ba1 100644
--- a/app/test-flow-perf/items_gen.c
+++ b/app/test-flow-perf/items_gen.c
@@ -128,12 +128,12 @@  add_vxlan(struct rte_flow_item *items,
 
 	/* Set standard vxlan vni */
 	for (i = 0; i < 3; i++) {
-		vxlan_specs[ti].vni[2 - i] = vni_value >> (i * 8);
-		vxlan_masks[ti].vni[2 - i] = 0xff;
+		vxlan_specs[ti].hdr.vni[2 - i] = vni_value >> (i * 8);
+		vxlan_masks[ti].hdr.vni[2 - i] = 0xff;
 	}
 
 	/* Standard vxlan flags */
-	vxlan_specs[ti].flags = 0x8;
+	vxlan_specs[ti].hdr.flags = 0x8;
 
 	items[items_counter].type = RTE_FLOW_ITEM_TYPE_VXLAN;
 	items[items_counter].spec = &vxlan_specs[ti];
@@ -155,12 +155,12 @@  add_vxlan_gpe(struct rte_flow_item *items,
 
 	/* Set vxlan-gpe vni */
 	for (i = 0; i < 3; i++) {
-		vxlan_gpe_specs[ti].vni[2 - i] = vni_value >> (i * 8);
-		vxlan_gpe_masks[ti].vni[2 - i] = 0xff;
+		vxlan_gpe_specs[ti].hdr.vni[2 - i] = vni_value >> (i * 8);
+		vxlan_gpe_masks[ti].hdr.vni[2 - i] = 0xff;
 	}
 
 	/* vxlan-gpe flags */
-	vxlan_gpe_specs[ti].flags = 0x0c;
+	vxlan_gpe_specs[ti].hdr.flags = 0x0c;
 
 	items[items_counter].type = RTE_FLOW_ITEM_TYPE_VXLAN_GPE;
 	items[items_counter].spec = &vxlan_gpe_specs[ti];
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 694a7eb647c5..b904f8c3d45c 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -3984,7 +3984,7 @@  static const struct token token_list[] = {
 		.help = "VXLAN identifier",
 		.next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
 			     item_param),
-		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, hdr.vni)),
 	},
 	[ITEM_VXLAN_LAST_RSVD] = {
 		.name = "last_rsvd",
@@ -3992,7 +3992,7 @@  static const struct token token_list[] = {
 		.next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
 			     item_param),
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
-					     rsvd1)),
+					     hdr.rsvd1)),
 	},
 	[ITEM_E_TAG] = {
 		.name = "e_tag",
@@ -4210,7 +4210,7 @@  static const struct token token_list[] = {
 		.next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
 			     item_param),
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
-					     vni)),
+					     hdr.vni)),
 	},
 	[ITEM_ARP_ETH_IPV4] = {
 		.name = "arp_eth_ipv4",
@@ -7500,7 +7500,7 @@  parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_
 			.src_port = vxlan_encap_conf.udp_src,
 			.dst_port = vxlan_encap_conf.udp_dst,
 		},
-		.item_vxlan.flags = 0,
+		.item_vxlan.hdr.flags = 0,
 	};
 	memcpy(action_vxlan_encap_data->item_eth.hdr.dst_addr.addr_bytes,
 	       vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
@@ -7554,7 +7554,7 @@  parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_
 							&ipv6_mask_tos;
 		}
 	}
-	memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
+	memcpy(action_vxlan_encap_data->item_vxlan.hdr.vni, vxlan_encap_conf.vni,
 	       RTE_DIM(vxlan_encap_conf.vni));
 	return 0;
 }
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 27c3780c4f17..116722351486 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -935,10 +935,7 @@  Item: ``VXLAN``
 
 Matches a VXLAN header (RFC 7348).
 
-- ``flags``: normally 0x08 (I flag).
-- ``rsvd0``: reserved, normally 0x000000.
-- ``vni``: VXLAN network identifier.
-- ``rsvd1``: reserved, normally 0x00.
+- ``hdr``:  header definition (``rte_vxlan.h``).
 - Default ``mask`` matches VNI only.
 
 Item: ``E_TAG``
@@ -1104,11 +1101,7 @@  Item: ``VXLAN-GPE``
 
 Matches a VXLAN-GPE header (draft-ietf-nvo3-vxlan-gpe-05).
 
-- ``flags``: normally 0x0C (I and P flags).
-- ``rsvd0``: reserved, normally 0x0000.
-- ``protocol``: protocol type.
-- ``vni``: VXLAN network identifier.
-- ``rsvd1``: reserved, normally 0x00.
+- ``hdr``:  header definition (``rte_vxlan.h``).
 - Default ``mask`` matches VNI only.
 
 Item: ``ARP_ETH_IPV4``
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 4782d2e680d3..df8b5bcb1b64 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -90,7 +90,6 @@  Deprecation Notices
   - ``rte_flow_item_pfcp``
   - ``rte_flow_item_pppoe``
   - ``rte_flow_item_pppoe_proto_id``
-  - ``rte_flow_item_vxlan_gpe``
 
 * ethdev: Queue specific stats fields will be removed from ``struct rte_eth_stats``.
   Mentioned fields are: ``q_ipackets``, ``q_opackets``, ``q_ibytes``, ``q_obytes``,
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 8f660493402c..4a107e81e955 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -563,9 +563,11 @@  bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,
 				break;
 			}
 
-			if (vxlan_spec->rsvd1 || vxlan_spec->rsvd0[0] ||
-			    vxlan_spec->rsvd0[1] || vxlan_spec->rsvd0[2] ||
-			    vxlan_spec->flags != 0x8) {
+			if ((vxlan_spec->hdr.rsvd0[0] != 0) ||
+			    (vxlan_spec->hdr.rsvd0[1] != 0) ||
+			    (vxlan_spec->hdr.rsvd0[2] != 0) ||
+			    (vxlan_spec->hdr.rsvd1 != 0) ||
+			    (vxlan_spec->hdr.flags != 8)) {
 				rte_flow_error_set(error,
 						   EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -577,7 +579,7 @@  bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,
 			/* Check if VNI is masked. */
 			if (vxlan_mask != NULL) {
 				vni_masked =
-					!!memcmp(vxlan_mask->vni, vni_mask,
+					!!memcmp(vxlan_mask->hdr.vni, vni_mask,
 						 RTE_DIM(vni_mask));
 				if (vni_masked) {
 					rte_flow_error_set
@@ -590,7 +592,7 @@  bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,
 				}
 
 				rte_memcpy(((uint8_t *)&tenant_id_be + 1),
-					   vxlan_spec->vni, 3);
+					   vxlan_spec->hdr.vni, 3);
 				filter->vni =
 					rte_be_to_cpu_32(tenant_id_be);
 				filter->tunnel_type =
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index 2928598ced55..80869b79c3fe 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -1414,28 +1414,28 @@  ulp_rte_vxlan_hdr_handler(const struct rte_flow_item *item,
 	 * Copy the rte_flow_item for vxlan into hdr_field using vxlan
 	 * header fields
 	 */
-	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->flags);
+	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->hdr.flags);
 	ulp_rte_prsr_fld_mask(params, &idx, size,
-			      ulp_deference_struct(vxlan_spec, flags),
-			      ulp_deference_struct(vxlan_mask, flags),
+			      ulp_deference_struct(vxlan_spec, hdr.flags),
+			      ulp_deference_struct(vxlan_mask, hdr.flags),
 			      ULP_PRSR_ACT_DEFAULT);
 
-	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->rsvd0);
+	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->hdr.rsvd0);
 	ulp_rte_prsr_fld_mask(params, &idx, size,
-			      ulp_deference_struct(vxlan_spec, rsvd0),
-			      ulp_deference_struct(vxlan_mask, rsvd0),
+			      ulp_deference_struct(vxlan_spec, hdr.rsvd0),
+			      ulp_deference_struct(vxlan_mask, hdr.rsvd0),
 			      ULP_PRSR_ACT_DEFAULT);
 
-	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->vni);
+	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->hdr.vni);
 	ulp_rte_prsr_fld_mask(params, &idx, size,
-			      ulp_deference_struct(vxlan_spec, vni),
-			      ulp_deference_struct(vxlan_mask, vni),
+			      ulp_deference_struct(vxlan_spec, hdr.vni),
+			      ulp_deference_struct(vxlan_mask, hdr.vni),
 			      ULP_PRSR_ACT_DEFAULT);
 
-	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->rsvd1);
+	size = sizeof(((struct rte_flow_item_vxlan *)NULL)->hdr.rsvd1);
 	ulp_rte_prsr_fld_mask(params, &idx, size,
-			      ulp_deference_struct(vxlan_spec, rsvd1),
-			      ulp_deference_struct(vxlan_mask, rsvd1),
+			      ulp_deference_struct(vxlan_spec, hdr.rsvd1),
+			      ulp_deference_struct(vxlan_mask, hdr.rsvd1),
 			      ULP_PRSR_ACT_DEFAULT);
 
 	/* Update the hdr_bitmap with vxlan */
@@ -1827,17 +1827,17 @@  ulp_rte_enc_vxlan_hdr_handler(struct ulp_rte_parser_params *params,
 	uint32_t size;
 
 	field = &params->enc_field[BNXT_ULP_ENC_FIELD_VXLAN_FLAGS];
-	size = sizeof(vxlan_spec->flags);
-	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->flags, size);
+	size = sizeof(vxlan_spec->hdr.flags);
+	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->hdr.flags, size);
 
-	size = sizeof(vxlan_spec->rsvd0);
-	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->rsvd0, size);
+	size = sizeof(vxlan_spec->hdr.rsvd0);
+	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->hdr.rsvd0, size);
 
-	size = sizeof(vxlan_spec->vni);
-	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->vni, size);
+	size = sizeof(vxlan_spec->hdr.vni);
+	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->hdr.vni, size);
 
-	size = sizeof(vxlan_spec->rsvd1);
-	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->rsvd1, size);
+	size = sizeof(vxlan_spec->hdr.rsvd1);
+	field = ulp_rte_parser_fld_copy(field, &vxlan_spec->hdr.rsvd1, size);
 
 	ULP_BITMAP_SET(params->enc_hdr_bitmap.bits, BNXT_ULP_HDR_BIT_T_VXLAN);
 }
@@ -1989,7 +1989,7 @@  ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item,
 	vxlan_size = sizeof(struct rte_flow_item_vxlan);
 	/* copy the vxlan details */
 	memcpy(&vxlan_spec, item->spec, vxlan_size);
-	vxlan_spec.flags = 0x08;
+	vxlan_spec.hdr.flags = 0x08;
 	vxlan_size = tfp_cpu_to_be_32(vxlan_size);
 	memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN_SZ],
 	       &vxlan_size, sizeof(uint32_t));
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index ef1832982dee..e88f9b7e452b 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -933,23 +933,23 @@  hns3_parse_vxlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 	vxlan_mask = item->mask;
 	vxlan_spec = item->spec;
 
-	if (vxlan_mask->flags)
+	if (vxlan_mask->hdr.flags)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, item,
 					  "Flags is not supported in VxLAN");
 
 	/* VNI must be totally masked or not. */
-	if (memcmp(vxlan_mask->vni, full_mask, VNI_OR_TNI_LEN) &&
-	    memcmp(vxlan_mask->vni, zero_mask, VNI_OR_TNI_LEN))
+	if (memcmp(vxlan_mask->hdr.vni, full_mask, VNI_OR_TNI_LEN) &&
+	    memcmp(vxlan_mask->hdr.vni, zero_mask, VNI_OR_TNI_LEN))
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, item,
 					  "VNI must be totally masked or not in VxLAN");
-	if (vxlan_mask->vni[0]) {
+	if (vxlan_mask->hdr.vni[0]) {
 		hns3_set_bit(rule->input_set, OUTER_TUN_VNI, 1);
-		memcpy(rule->key_conf.mask.outer_tun_vni, vxlan_mask->vni,
+		memcpy(rule->key_conf.mask.outer_tun_vni, vxlan_mask->hdr.vni,
 			   VNI_OR_TNI_LEN);
 	}
-	memcpy(rule->key_conf.spec.outer_tun_vni, vxlan_spec->vni,
+	memcpy(rule->key_conf.spec.outer_tun_vni, vxlan_spec->hdr.vni,
 		   VNI_OR_TNI_LEN);
 	return 0;
 }
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 0acbd5a061e0..2855b14fe679 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -3009,7 +3009,7 @@  i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			/* Check if VNI is masked. */
 			if (vxlan_spec && vxlan_mask) {
 				is_vni_masked =
-					!!memcmp(vxlan_mask->vni, vni_mask,
+					!!memcmp(vxlan_mask->hdr.vni, vni_mask,
 						 RTE_DIM(vni_mask));
 				if (is_vni_masked) {
 					rte_flow_error_set(error, EINVAL,
@@ -3020,7 +3020,7 @@  i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 				}
 
 				rte_memcpy(((uint8_t *)&tenant_id_be + 1),
-					   vxlan_spec->vni, 3);
+					   vxlan_spec->hdr.vni, 3);
 				filter->tenant_id =
 					rte_be_to_cpu_32(tenant_id_be);
 				filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c
index d84061340e6c..7cb20fa0b4f8 100644
--- a/drivers/net/ice/ice_switch_filter.c
+++ b/drivers/net/ice/ice_switch_filter.c
@@ -990,17 +990,17 @@  ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 			input = &inner_input_set;
 			if (vxlan_spec && vxlan_mask) {
 				list[t].type = ICE_VXLAN;
-				if (vxlan_mask->vni[0] ||
-					vxlan_mask->vni[1] ||
-					vxlan_mask->vni[2]) {
+				if (vxlan_mask->hdr.vni[0] ||
+					vxlan_mask->hdr.vni[1] ||
+					vxlan_mask->hdr.vni[2]) {
 					list[t].h_u.tnl_hdr.vni =
-						(vxlan_spec->vni[2] << 16) |
-						(vxlan_spec->vni[1] << 8) |
-						vxlan_spec->vni[0];
+						(vxlan_spec->hdr.vni[2] << 16) |
+						(vxlan_spec->hdr.vni[1] << 8) |
+						vxlan_spec->hdr.vni[0];
 					list[t].m_u.tnl_hdr.vni =
-						(vxlan_mask->vni[2] << 16) |
-						(vxlan_mask->vni[1] << 8) |
-						vxlan_mask->vni[0];
+						(vxlan_mask->hdr.vni[2] << 16) |
+						(vxlan_mask->hdr.vni[1] << 8) |
+						vxlan_mask->hdr.vni[0];
 					*input |= ICE_INSET_VXLAN_VNI;
 					input_set_byte += 2;
 				}
diff --git a/drivers/net/ipn3ke/ipn3ke_flow.c b/drivers/net/ipn3ke/ipn3ke_flow.c
index ee56d0f43d93..d20a29b9a2d6 100644
--- a/drivers/net/ipn3ke/ipn3ke_flow.c
+++ b/drivers/net/ipn3ke/ipn3ke_flow.c
@@ -108,7 +108,7 @@  ipn3ke_pattern_vxlan(const struct rte_flow_item patterns[],
 		case RTE_FLOW_ITEM_TYPE_VXLAN:
 			vxlan = item->spec;
 
-			rte_memcpy(&parser->key[6], vxlan->vni, 3);
+			rte_memcpy(&parser->key[6], vxlan->hdr.vni, 3);
 			break;
 
 		default:
@@ -576,7 +576,7 @@  ipn3ke_pattern_vxlan_ip_udp(const struct rte_flow_item patterns[],
 		case RTE_FLOW_ITEM_TYPE_VXLAN:
 			vxlan = item->spec;
 
-			rte_memcpy(&parser->key[0], vxlan->vni, 3);
+			rte_memcpy(&parser->key[0], vxlan->hdr.vni, 3);
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV4:
diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c
index a11da3dc8beb..fe710b79008d 100644
--- a/drivers/net/ixgbe/ixgbe_flow.c
+++ b/drivers/net/ixgbe/ixgbe_flow.c
@@ -2481,7 +2481,7 @@  ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
 		rule->mask.tunnel_type_mask = 1;
 
 		vxlan_mask = item->mask;
-		if (vxlan_mask->flags) {
+		if (vxlan_mask->hdr.flags) {
 			memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 			rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ITEM,
@@ -2489,11 +2489,11 @@  ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
 			return -rte_errno;
 		}
 		/* VNI must be totally masked or not. */
-		if ((vxlan_mask->vni[0] || vxlan_mask->vni[1] ||
-			vxlan_mask->vni[2]) &&
-			((vxlan_mask->vni[0] != 0xFF) ||
-			(vxlan_mask->vni[1] != 0xFF) ||
-				(vxlan_mask->vni[2] != 0xFF))) {
+		if ((vxlan_mask->hdr.vni[0] || vxlan_mask->hdr.vni[1] ||
+			vxlan_mask->hdr.vni[2]) &&
+			((vxlan_mask->hdr.vni[0] != 0xFF) ||
+			(vxlan_mask->hdr.vni[1] != 0xFF) ||
+				(vxlan_mask->hdr.vni[2] != 0xFF))) {
 			memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 			rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ITEM,
@@ -2501,15 +2501,15 @@  ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
 			return -rte_errno;
 		}
 
-		rte_memcpy(&rule->mask.tunnel_id_mask, vxlan_mask->vni,
-			RTE_DIM(vxlan_mask->vni));
+		rte_memcpy(&rule->mask.tunnel_id_mask, vxlan_mask->hdr.vni,
+			RTE_DIM(vxlan_mask->hdr.vni));
 
 		if (item->spec) {
 			rule->b_spec = TRUE;
 			vxlan_spec = item->spec;
 			rte_memcpy(((uint8_t *)
 				&rule->ixgbe_fdir.formatted.tni_vni),
-				vxlan_spec->vni, RTE_DIM(vxlan_spec->vni));
+				vxlan_spec->hdr.vni, RTE_DIM(vxlan_spec->hdr.vni));
 		}
 	}
 
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 2512d6b52db9..ff08a629e2c6 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -333,7 +333,7 @@  mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item)
 		ret = mlx5_ethertype_to_item_type(spec, mask, true);
 		break;
 	case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
-		MLX5_XSET_ITEM_MASK_SPEC(vxlan_gpe, protocol);
+		MLX5_XSET_ITEM_MASK_SPEC(vxlan_gpe, hdr.proto);
 		ret = mlx5_nsh_proto_to_item_type(spec, mask);
 		break;
 	default:
@@ -2919,8 +2919,8 @@  mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev,
 		uint8_t vni[4];
 	} id = { .vlan_id = 0, };
 	const struct rte_flow_item_vxlan nic_mask = {
-		.vni = "\xff\xff\xff",
-		.rsvd1 = 0xff,
+		.hdr.vni = "\xff\xff\xff",
+		.hdr.rsvd1 = 0xff,
 	};
 	const struct rte_flow_item_vxlan *valid_mask;
 
@@ -2959,8 +2959,8 @@  mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev,
 	if (ret < 0)
 		return ret;
 	if (spec) {
-		memcpy(&id.vni[1], spec->vni, 3);
-		memcpy(&id.vni[1], mask->vni, 3);
+		memcpy(&id.vni[1], spec->hdr.vni, 3);
+		memcpy(&id.vni[1], mask->hdr.vni, 3);
 	}
 	if (!(item_flags & MLX5_FLOW_LAYER_OUTER))
 		return rte_flow_error_set(error, ENOTSUP,
@@ -3030,14 +3030,14 @@  mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
 	if (ret < 0)
 		return ret;
 	if (spec) {
-		if (spec->protocol)
+		if (spec->hdr.proto)
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ITEM,
 						  item,
 						  "VxLAN-GPE protocol"
 						  " not supported");
-		memcpy(&id.vni[1], spec->vni, 3);
-		memcpy(&id.vni[1], mask->vni, 3);
+		memcpy(&id.vni[1], spec->hdr.vni, 3);
+		memcpy(&id.vni[1], mask->hdr.vni, 3);
 	}
 	if (!(item_flags & MLX5_FLOW_LAYER_OUTER))
 		return rte_flow_error_set(error, ENOTSUP,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ff915183b7cc..261c60a5c33a 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -9235,8 +9235,8 @@  flow_dv_translate_item_vxlan(struct rte_eth_dev *dev,
 	int i;
 	struct mlx5_priv *priv = dev->data->dev_private;
 	const struct rte_flow_item_vxlan nic_mask = {
-		.vni = "\xff\xff\xff",
-		.rsvd1 = 0xff,
+		.hdr.vni = "\xff\xff\xff",
+		.hdr.rsvd1 = 0xff,
 	};
 
 	misc5_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_5);
@@ -9274,29 +9274,29 @@  flow_dv_translate_item_vxlan(struct rte_eth_dev *dev,
 	    ((attr->group || (attr->transfer && priv->fdb_def_rule)) &&
 	    !priv->sh->misc5_cap)) {
 		misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters);
-		size = sizeof(vxlan_m->vni);
+		size = sizeof(vxlan_m->hdr.vni);
 		vni_v = MLX5_ADDR_OF(fte_match_set_misc, misc_v, vxlan_vni);
 		for (i = 0; i < size; ++i)
-			vni_v[i] = vxlan_m->vni[i] & vxlan_v->vni[i];
+			vni_v[i] = vxlan_m->hdr.vni[i] & vxlan_v->hdr.vni[i];
 		return;
 	}
 	tunnel_header_v = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5,
 						   misc5_v,
 						   tunnel_header_1);
-	tunnel_v = (vxlan_v->vni[0] & vxlan_m->vni[0]) |
-		   (vxlan_v->vni[1] & vxlan_m->vni[1]) << 8 |
-		   (vxlan_v->vni[2] & vxlan_m->vni[2]) << 16;
+	tunnel_v = (vxlan_v->hdr.vni[0] & vxlan_m->hdr.vni[0]) |
+		   (vxlan_v->hdr.vni[1] & vxlan_m->hdr.vni[1]) << 8 |
+		   (vxlan_v->hdr.vni[2] & vxlan_m->hdr.vni[2]) << 16;
 	*tunnel_header_v = tunnel_v;
 	if (key_type == MLX5_SET_MATCHER_SW_M) {
-		tunnel_v = (vxlan_vv->vni[0] & vxlan_m->vni[0]) |
-			   (vxlan_vv->vni[1] & vxlan_m->vni[1]) << 8 |
-			   (vxlan_vv->vni[2] & vxlan_m->vni[2]) << 16;
+		tunnel_v = (vxlan_vv->hdr.vni[0] & vxlan_m->hdr.vni[0]) |
+			   (vxlan_vv->hdr.vni[1] & vxlan_m->hdr.vni[1]) << 8 |
+			   (vxlan_vv->hdr.vni[2] & vxlan_m->hdr.vni[2]) << 16;
 		if (!tunnel_v)
 			*tunnel_header_v = 0x0;
-		if (vxlan_vv->rsvd1 & vxlan_m->rsvd1)
-			*tunnel_header_v |= vxlan_v->rsvd1 << 24;
+		if (vxlan_vv->hdr.rsvd1 & vxlan_m->hdr.rsvd1)
+			*tunnel_header_v |= vxlan_v->hdr.rsvd1 << 24;
 	} else {
-		*tunnel_header_v |= (vxlan_v->rsvd1 & vxlan_m->rsvd1) << 24;
+		*tunnel_header_v |= (vxlan_v->hdr.rsvd1 & vxlan_m->hdr.rsvd1) << 24;
 	}
 }
 
@@ -9327,7 +9327,7 @@  flow_dv_translate_item_vxlan_gpe(void *key, const struct rte_flow_item *item,
 		MLX5_ADDR_OF(fte_match_param, key, misc_parameters_3);
 	char *vni_v =
 		MLX5_ADDR_OF(fte_match_set_misc3, misc_v, outer_vxlan_gpe_vni);
-	int i, size = sizeof(vxlan_m->vni);
+	int i, size = sizeof(vxlan_m->hdr.vni);
 	uint8_t flags_m = 0xff;
 	uint8_t flags_v = 0xc;
 	uint8_t m_protocol, v_protocol;
@@ -9352,15 +9352,15 @@  flow_dv_translate_item_vxlan_gpe(void *key, const struct rte_flow_item *item,
 	else if (key_type == MLX5_SET_MATCHER_HS_V)
 		vxlan_m = vxlan_v;
 	for (i = 0; i < size; ++i)
-		vni_v[i] = vxlan_m->vni[i] & vxlan_v->vni[i];
-	if (vxlan_m->flags) {
-		flags_m = vxlan_m->flags;
-		flags_v = vxlan_v->flags;
+		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->protocol;
-	v_protocol = vxlan_v->protocol;
+	m_protocol = vxlan_m->hdr.protocol;
+	v_protocol = vxlan_v->hdr.protocol;
 	if (!m_protocol) {
 		/* Force next protocol to ensure next headers parsing. */
 		if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2)
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 1902b97ec6d4..4ef4f3044515 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -765,9 +765,9 @@  flow_verbs_translate_item_vxlan(struct mlx5_flow *dev_flow,
 	if (!mask)
 		mask = &rte_flow_item_vxlan_mask;
 	if (spec) {
-		memcpy(&id.vni[1], spec->vni, 3);
+		memcpy(&id.vni[1], spec->hdr.vni, 3);
 		vxlan.val.tunnel_id = id.vlan_id;
-		memcpy(&id.vni[1], mask->vni, 3);
+		memcpy(&id.vni[1], mask->hdr.vni, 3);
 		vxlan.mask.tunnel_id = id.vlan_id;
 		/* Remove unwanted bits from values. */
 		vxlan.val.tunnel_id &= vxlan.mask.tunnel_id;
@@ -807,9 +807,9 @@  flow_verbs_translate_item_vxlan_gpe(struct mlx5_flow *dev_flow,
 	if (!mask)
 		mask = &rte_flow_item_vxlan_gpe_mask;
 	if (spec) {
-		memcpy(&id.vni[1], spec->vni, 3);
+		memcpy(&id.vni[1], spec->hdr.vni, 3);
 		vxlan_gpe.val.tunnel_id = id.vlan_id;
-		memcpy(&id.vni[1], mask->vni, 3);
+		memcpy(&id.vni[1], mask->hdr.vni, 3);
 		vxlan_gpe.mask.tunnel_id = id.vlan_id;
 		/* Remove unwanted bits from values. */
 		vxlan_gpe.val.tunnel_id &= vxlan_gpe.mask.tunnel_id;
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index f098edc6eb33..fe1f5ba55f86 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -921,7 +921,7 @@  sfc_flow_parse_vxlan(const struct rte_flow_item *item,
 	const struct rte_flow_item_vxlan *spec = NULL;
 	const struct rte_flow_item_vxlan *mask = NULL;
 	const struct rte_flow_item_vxlan supp_mask = {
-		.vni = { 0xff, 0xff, 0xff }
+		.hdr.vni = { 0xff, 0xff, 0xff }
 	};
 
 	rc = sfc_flow_parse_init(item,
@@ -945,8 +945,8 @@  sfc_flow_parse_vxlan(const struct rte_flow_item *item,
 	if (spec == NULL)
 		return 0;
 
-	rc = sfc_flow_set_efx_spec_vni_or_vsid(efx_spec, spec->vni,
-					       mask->vni, item, error);
+	rc = sfc_flow_set_efx_spec_vni_or_vsid(efx_spec, spec->hdr.vni,
+					       mask->hdr.vni, item, error);
 
 	return rc;
 }
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index 710d04be13af..aab697b204c2 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -2223,8 +2223,8 @@  static const struct sfc_mae_field_locator flocs_tunnel[] = {
 		 * The size and offset values are relevant
 		 * for Geneve and NVGRE, too.
 		 */
-		.size = RTE_SIZEOF_FIELD(struct rte_flow_item_vxlan, vni),
-		.ofst = offsetof(struct rte_flow_item_vxlan, vni),
+		.size = RTE_SIZEOF_FIELD(struct rte_flow_item_vxlan, hdr.vni),
+		.ofst = offsetof(struct rte_flow_item_vxlan, hdr.vni),
 	},
 };
 
@@ -2359,10 +2359,10 @@  sfc_mae_rule_parse_item_tunnel(const struct rte_flow_item *item,
 	 * The extra byte is 0 both in the mask and in the value.
 	 */
 	vxp = (const struct rte_flow_item_vxlan *)spec;
-	memcpy(vnet_id_v + 1, &vxp->vni, sizeof(vxp->vni));
+	memcpy(vnet_id_v + 1, &vxp->hdr.vni, sizeof(vxp->hdr.vni));
 
 	vxp = (const struct rte_flow_item_vxlan *)mask;
-	memcpy(vnet_id_m + 1, &vxp->vni, sizeof(vxp->vni));
+	memcpy(vnet_id_m + 1, &vxp->hdr.vni, sizeof(vxp->hdr.vni));
 
 	rc = efx_mae_match_spec_field_set(ctx_mae->match_spec,
 					  EFX_MAE_FIELD_ENC_VNET_ID_BE,
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index b60987db4b4f..e2364823d622 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -988,7 +988,7 @@  struct rte_flow_item_vxlan {
 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
 #ifndef __cplusplus
 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
-	.hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
+	.hdr.vni = "\xff\xff\xff",
 };
 #endif
 
@@ -1205,18 +1205,28 @@  static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
  *
  * Matches a VXLAN-GPE header.
  */
+RTE_STD_C11
 struct rte_flow_item_vxlan_gpe {
-	uint8_t flags; /**< Normally 0x0c (I and P flags). */
-	uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
-	uint8_t protocol; /**< Protocol type. */
-	uint8_t vni[3]; /**< VXLAN identifier. */
-	uint8_t rsvd1; /**< Reserved, normally 0x00. */
+	union {
+		struct {
+			/*
+			 * These are old fields kept for compatibility.
+			 * Please prefer hdr field below.
+			 */
+			uint8_t flags; /**< Normally 0x0c (I and P flags). */
+			uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
+			uint8_t protocol; /**< Protocol type. */
+			uint8_t vni[3]; /**< VXLAN identifier. */
+			uint8_t rsvd1; /**< Reserved, normally 0x00. */
+		};
+		struct rte_vxlan_gpe_hdr hdr;
+	};
 };
 
 /** 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 = {
-	.vni = "\xff\xff\xff",
+	.hdr.vni = "\xff\xff\xff",
 };
 #endif