patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Gregory Etelson <getelson@nvidia.com>
To: <stable@dpdk.org>, <getelson@nvidia.com>
Cc: <matan@nvidia.com>, <rasland@nvidia.com>,
	Shahaf Shuler <shahafs@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	"Dekel Peled" <dekelp@mellanox.com>
Subject: [dpdk-stable] [PATCH] [19.11] net/mlx5: fix implicit VLAN match in RSS expansions
Date: Wed, 13 Oct 2021 20:26:46 +0300	[thread overview]
Message-ID: <20211013172646.28303-1-getelson@nvidia.com> (raw)

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


                 reply	other threads:[~2021-10-13 17:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211013172646.28303-1-getelson@nvidia.com \
    --to=getelson@nvidia.com \
    --cc=dekelp@mellanox.com \
    --cc=matan@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=shahafs@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).