patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Lior Margalit <lmargalit@nvidia.com>
To: Matan Azrad <matan@nvidia.com>
Cc: Lior Margalit <lmargalit@nvidia.com>, <stable@dpdk.org>
Subject: [PATCH 20.11 2/5] net/mlx5: fix RSS expansion for explicit graph node
Date: Tue, 30 Nov 2021 14:17:11 +0200	[thread overview]
Message-ID: <20211130121714.4170879-2-lmargalit@nvidia.com> (raw)
In-Reply-To: <20211130121714.4170879-1-lmargalit@nvidia.com>

[ upstream commit 69d268b4fff3791c3fea772a43abca1660982005 ]

The RSS expansion algorithm is using a graph to find the possible
expansion paths. A graph node with the 'explicit' flag will be skipped,
if it is not found in the flow pattern.

The current implementation misses the case where the node with the
explicit flag is in the middle of the expanded path.
For example:
testpmd> flow create 0 ingress pattern eth / ipv6 / udp / vxlan / end
actions rss level 2 types tcp end / end
The VLAN node has the explicit flag, so it is currently included in the
expanded flow:
ETH IPV6 UDP VXLAN END
ETH IPV6 UDP VXLAN ETH VLAN IPV4 TCP END
ETH IPV6 UDP VXLAN ETH VLAN IPV6 TCP END

The fix is to skip the nodes with the explicit flag while iterating over
the possible expansion paths. Using the above example, the flows will be:
ETH IPV6 UDP VXLAN END
ETH IPV6 UDP VXLAN ETH IPV4 TCP END
ETH IPV6 UDP VXLAN ETH IPV6 TCP END

Fixes: 3f02c7ff6815 ("net/mlx5: fix RSS expansion for inner tunnel VLAN")
Cc: stable@dpdk.org

Signed-off-by: Lior Margalit <lmargalit@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c | 44 ++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 2b916899e8..cacccd6cc8 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -282,6 +282,26 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item)
 	return ret;
 }
 
+static const int *
+mlx5_flow_expand_rss_skip_explicit(const struct mlx5_flow_expand_node graph[],
+		const int *next_node)
+{
+	const struct mlx5_flow_expand_node *node = NULL;
+	const int *next = next_node;
+
+	while (next && *next) {
+		/*
+		 * Skip the nodes with the MLX5_EXPANSION_NODE_EXPLICIT
+		 * flag set, because they were not found in the flow pattern.
+		 */
+		node = &graph[*next];
+		if (!(node->node_flags & MLX5_EXPANSION_NODE_EXPLICIT))
+			break;
+		next = node->next;
+	}
+	return next;
+}
+
 #define MLX5_RSS_EXP_ELT_N 16
 
 /**
@@ -414,17 +434,8 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		}
 	}
 	memset(flow_items, 0, sizeof(flow_items));
-	next_node = node->next;
-	while (next_node) {
-		/*
-		 * Skip the nodes with the MLX5_EXPANSION_NODE_EXPLICIT
-		 * flag set, because they were not found in the flow pattern.
-		 */
-		node = &graph[*next_node];
-		if (!(node->node_flags & MLX5_EXPANSION_NODE_EXPLICIT))
-			break;
-		next_node = node->next;
-	}
+	next_node = mlx5_flow_expand_rss_skip_explicit(graph,
+			node->next);
 	stack[stack_pos] = next_node;
 	node = next_node ? &graph[*next_node] : NULL;
 	while (node) {
@@ -461,7 +472,8 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 		/* Go deeper. */
 		if (!(node->node_flags & MLX5_EXPANSION_NODE_OPTIONAL) &&
 				node->next) {
-			next_node = node->next;
+			next_node = mlx5_flow_expand_rss_skip_explicit(graph,
+					node->next);
 			if (stack_pos++ == MLX5_RSS_EXP_ELT_N) {
 				rte_errno = E2BIG;
 				return -rte_errno;
@@ -469,15 +481,17 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
 			stack[stack_pos] = next_node;
 		} else if (*(next_node + 1)) {
 			/* Follow up with the next possibility. */
-			++next_node;
+			next_node = mlx5_flow_expand_rss_skip_explicit(graph,
+					++next_node);
 		} else {
 			/* Move to the next path. */
 			if (stack_pos)
 				next_node = stack[--stack_pos];
-			next_node++;
+			next_node = mlx5_flow_expand_rss_skip_explicit(graph,
+					++next_node);
 			stack[stack_pos] = next_node;
 		}
-		node = *next_node ? &graph[*next_node] : NULL;
+		node = next_node && *next_node ? &graph[*next_node] : NULL;
 	};
 	return lsize;
 }
-- 
2.25.1


  reply	other threads:[~2021-11-30 12:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 12:17 [PATCH 20.11 1/5] net/mlx5: fix RSS expansion for inner tunnel VLAN Lior Margalit
2021-11-30 12:17 ` Lior Margalit [this message]
2021-11-30 12:17 ` [PATCH 20.11 3/5] net/mlx5: fix RSS expansion traversal over next nodes Lior Margalit
2021-11-30 12:17 ` [PATCH 20.11 4/5] net/mlx5: fix RSS expansion for L2/L3 VXLAN Lior Margalit
2021-11-30 12:17 ` [PATCH 20.11 5/5] net/mlx5: fix RSS expansion with EtherType Lior Margalit
2021-11-30 13:55 ` [PATCH 20.11 1/5] net/mlx5: fix RSS expansion for inner tunnel VLAN Xueming(Steven) Li

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=20211130121714.4170879-2-lmargalit@nvidia.com \
    --to=lmargalit@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=stable@dpdk.org \
    /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).