patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] [19.11] net/mlx5: fix implicit VLAN match in RSS expansions
@ 2021-10-13 17:26 Gregory Etelson
  0 siblings, 0 replies; only message in thread
From: Gregory Etelson @ 2021-10-13 17:26 UTC (permalink / raw)
  To: stable, getelson
  Cc: matan, rasland, Shahaf Shuler, Viacheslav Ovsiienko, Dekel Peled

RSS flow rules with patterns expanded from ETH item only,
do not reference VLAN header after ETH. In the expanded patterns,
ETH header is followed by L3.
As the result, packets with VLAN header did not match.
The patch allows VLAN header after ETH in RSS expanded rules.

Cc: stable@dpdk.org

Fixes: 2d85e1f ("net/mlx5: fix VLAN match for DV mode")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c    | 28 ++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h    |  3 +++
 drivers/net/mlx5/mlx5_flow_dv.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 0805bdb8c9..afcf8a1b72 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -34,6 +34,9 @@
 #include "mlx5_prm.h"
 #include "mlx5_rxtx.h"
 
+static void
+mlx5_dbg__print_pattern(const struct rte_flow_item *item);
+
 /* Dev ops structure defined in mlx5.c */
 extern const struct eth_dev_ops mlx5_dev_ops;
 extern const struct eth_dev_ops mlx5_dev_ops_isolate;
@@ -4317,6 +4320,11 @@ flow_list_create(struct rte_eth_dev *dev, struct mlx5_flows *list,
 					  graph_root);
 		assert(ret > 0 &&
 		       (unsigned int)ret < sizeof(expand_buffer.buffer));
+		if (rte_log_get_level(mlx5_logtype) >= (int)RTE_LOG_DEBUG) {
+			for (i = 0; i < buf->entries; ++i)
+				mlx5_dbg__print_pattern(buf->entry[i].pattern);
+		}
+
 	} else {
 		buf->entries = 1;
 		buf->entry[0].pattern = (void *)(uintptr_t)items;
@@ -4327,6 +4335,7 @@ flow_list_create(struct rte_eth_dev *dev, struct mlx5_flows *list,
 		 * depending on configuration. In the simplest
 		 * case it just creates unmodified original flow.
 		 */
+		flow->rss_first_exp = !!(buf->entries > 1 && (i == 0));
 		ret = flow_create_split_outer(dev, flow, attr,
 					      buf->entry[i].pattern,
 					      p_actions_rx, external,
@@ -5810,3 +5819,22 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev)
 		config->flow_mreg_c[n] = REG_NONE;
 	return 0;
 }
+
+static void
+mlx5_dbg__print_pattern(const struct rte_flow_item *item)
+{
+	int ret;
+	struct rte_flow_error error;
+
+	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
+		char *item_name;
+		ret = rte_flow_conv(RTE_FLOW_CONV_OP_ITEM_NAME_PTR, &item_name,
+				    sizeof(item_name),
+				    (void *)(uintptr_t)item->type, &error);
+		if (ret > 0)
+			printf("%s ", item_name);
+		else
+			printf("%d\n", (int)item->type);
+	}
+	printf("END\n");
+}
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index caf6afd4d8..83e1bbfbbd 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -689,6 +689,9 @@ struct rte_flow {
 	struct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */
 	uint32_t hairpin_flow_id; /**< The flow id used for hairpin. */
 	uint32_t copy_applied:1; /**< The MARK copy Flow os applied. */
+	uint32_t rss_first_exp:1; /**< First flow in RSS expansion */
+	uint32_t vlan_m:1; /**< VLAN matcher mask */
+	uint32_t vlan_v:1; /**< VLAN matcher value */
 };
 
 typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f8ca36b1c6..3323c5f8df 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -7870,6 +7870,36 @@ __flow_dv_translate(struct rte_eth_dev *dev,
 	}
 	assert(!flow_dv_check_valid_spec(matcher.mask.buf,
 					 dev_flow->dv.value.buf));
+	if (dev_flow->actions & MLX5_FLOW_ACTION_RSS) {
+		void *headers_m, *headers_v;
+
+		if (flow->rss.level > 1) {
+			headers_m = MLX5_ADDR_OF(fte_match_param, match_mask,
+						 inner_headers);
+			headers_v = MLX5_ADDR_OF(fte_match_param, match_value,
+						 inner_headers);
+		} else {
+			headers_m = MLX5_ADDR_OF(fte_match_param, match_mask,
+						 outer_headers);
+			headers_v = MLX5_ADDR_OF(fte_match_param, match_value,
+						 outer_headers);
+		}
+		/* The first flow in RSS expansion series has the original
+		 * pattern.
+		 * RSS expansion matchers will use these values.
+		 */
+		if (flow->rss_first_exp) {
+			flow->vlan_m = MLX5_GET(fte_match_set_lyr_2_4,
+						headers_m, cvlan_tag);
+			flow->vlan_v = MLX5_GET(fte_match_set_lyr_2_4,
+						headers_v, cvlan_tag);
+		} else {
+			MLX5_SET(fte_match_set_lyr_2_4, headers_m,
+				 cvlan_tag, flow->vlan_m);
+			MLX5_SET(fte_match_set_lyr_2_4, headers_v,
+				 cvlan_tag, flow->vlan_v);
+		}
+	}
 	/*
 	 * Layers may be already initialized from prefix flow if this dev_flow
 	 * is the suffix flow.
-- 
2.33.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-13 17:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 17:26 [dpdk-stable] [PATCH] [19.11] net/mlx5: fix implicit VLAN match in RSS expansions Gregory Etelson

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git