DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] fix non-template IPv6 RSS hash
@ 2024-06-17 14:07 Gregory Etelson
  2024-06-17 14:07 ` [PATCH 1/2] net/mlx5: refactor non-template RSS expansion Gregory Etelson
  2024-06-17 14:07 ` [PATCH 2/2] net/mlx5: fix non-template IPv6 RSS hash Gregory Etelson
  0 siblings, 2 replies; 3+ messages in thread
From: Gregory Etelson @ 2024-06-17 14:07 UTC (permalink / raw)
  To: dev; +Cc: getelson,  , rasland

Gregory Etelson (2):
  net/mlx5: refactor non-template RSS expansion
  net/mlx5: fix non-template IPv6 RSS hash

 drivers/net/mlx5/mlx5_flow_hw.c |  6 +-
 drivers/net/mlx5/mlx5_nta_rss.c | 99 ++++++++++++++++++++++++++++-----
 2 files changed, 85 insertions(+), 20 deletions(-)

 Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] net/mlx5: refactor non-template RSS expansion
  2024-06-17 14:07 [PATCH 0/2] fix non-template IPv6 RSS hash Gregory Etelson
@ 2024-06-17 14:07 ` Gregory Etelson
  2024-06-17 14:07 ` [PATCH 2/2] net/mlx5: fix non-template IPv6 RSS hash Gregory Etelson
  1 sibling, 0 replies; 3+ messages in thread
From: Gregory Etelson @ 2024-06-17 14:07 UTC (permalink / raw)
  To: dev
  Cc: getelson,  ,
	rasland, Dariusz Sosnowski, Viacheslav Ovsiienko, Ori Kam,
	Suanming Mou, Matan Azrad

The current PMD handled non-template RSS expansion in the
`flow_nta_handle_rss()` function.
The function returned flow handle for expanded RSS flow rule or
NULL if there was no RSS expansion.
The NULL result with non-zero rte_errno value pointed to an error
during RSS expansion.
If rte_errno value was 0, PMD resumed normal flow creation for the
RSS rule without expansion.

The patch changes `flow_nta_handle_rss()` behavior.
On success, the function always creates a flow handle.
The flow handle references multiple flows if RSS expansion was
required and single flow if no RSS expansion was not required.
The function returns NULL if it failed to create RSS flow.

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c |  6 +-----
 drivers/net/mlx5/mlx5_nta_rss.c | 24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index eb89dcf454..78b7014b73 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -13766,11 +13766,7 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,
 		flow = flow_nta_handle_rss(dev, attr, items, actions, rss_conf,
 					   item_flags, action_flags, external,
 					   type, error);
-		if (flow)
-			return (uintptr_t)flow;
-		if (error->type != RTE_FLOW_ERROR_TYPE_NONE)
-			return 0;
-		/* Fall Through to non-expanded RSS flow */
+		return (uintptr_t)flow;
 	}
 	/*TODO: Handle split/expand to num_flows. */
 
diff --git a/drivers/net/mlx5/mlx5_nta_rss.c b/drivers/net/mlx5/mlx5_nta_rss.c
index 1f0085ff06..bcba2f98ed 100644
--- a/drivers/net/mlx5/mlx5_nta_rss.c
+++ b/drivers/net/mlx5/mlx5_nta_rss.c
@@ -439,6 +439,7 @@ flow_nta_handle_rss(struct rte_eth_dev *dev,
 	struct rte_flow_action_rss ptype_rss_conf;
 	struct mlx5_nta_rss_ctx rss_ctx;
 	uint64_t rss_types = rte_eth_rss_hf_refine(rss_conf->types);
+	bool expand = true;
 	bool inner_rss = rss_conf->level > 1;
 	bool outer_rss = !inner_rss;
 	bool l3_item = (outer_rss && (item_flags & MLX5_FLOW_LAYER_OUTER_L3)) ||
@@ -484,28 +485,31 @@ flow_nta_handle_rss(struct rte_eth_dev *dev,
 		 * L4 is the maximal expansion level.
 		 * Original pattern does not need expansion.
 		 */
-		rte_flow_error_set(error, 0, RTE_FLOW_ERROR_TYPE_NONE, NULL, NULL);
-		return NULL;
-	}
-	if (!l4_hash) {
+		expand = false;
+	} else if (!l4_hash) {
 		if (!l3_hash) {
 			/*
 			 * RSS action was not configured to hash L3 or L4.
 			 * No expansion needed.
 			 */
-			rte_flow_error_set(error, 0, RTE_FLOW_ERROR_TYPE_NONE, NULL, NULL);
-			return NULL;
-		}
-		if (l3_item) {
+			expand = false;
+		} else if (l3_item) {
 			/*
 			 * Original flow pattern extended up to L3 level.
 			 * RSS action was not set for L4 hash.
 			 * Original pattern does not need expansion.
 			 */
-			rte_flow_error_set(error, 0, RTE_FLOW_ERROR_TYPE_NONE, NULL, NULL);
-			return NULL;
+			expand = false;
 		}
 	}
+	if (!expand) {
+		struct rte_flow_hw *flow = NULL;
+
+		flow_hw_create_flow(dev, flow_type, attr, items,
+				    actions, item_flags, action_flags,
+				    external, &flow, error);
+		return flow;
+	}
 	/* Create RSS expansions in dedicated PTYPE flow group */
 	ptype_attr.group = mlx5_hw_get_rss_ptype_group(dev);
 	if (!ptype_attr.group) {
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] net/mlx5: fix non-template IPv6 RSS hash
  2024-06-17 14:07 [PATCH 0/2] fix non-template IPv6 RSS hash Gregory Etelson
  2024-06-17 14:07 ` [PATCH 1/2] net/mlx5: refactor non-template RSS expansion Gregory Etelson
@ 2024-06-17 14:07 ` Gregory Etelson
  1 sibling, 0 replies; 3+ messages in thread
From: Gregory Etelson @ 2024-06-17 14:07 UTC (permalink / raw)
  To: dev
  Cc: getelson,  ,
	rasland, Dariusz Sosnowski, Viacheslav Ovsiienko, Ori Kam,
	Suanming Mou, Matan Azrad

MLX5 HW prioritizes IPv4 hash over IPv6 in TIR setup.
If TIR was configured to hash both IPv4 and IPv6 the MLX5 HW will
use IPv4 hash even if packet matched IPv6 flow item.

The patch removes IPv4 hash from RSS action configuration if flow rule
matched IPV6 item in the non-template PMD setup.

Fixes: 1ca9ec661a02 ("net/mlx5: support RSS expansion in non-template HWS setup")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_nta_rss.c | 91 ++++++++++++++++++++++++++++-----
 1 file changed, 78 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_nta_rss.c b/drivers/net/mlx5/mlx5_nta_rss.c
index bcba2f98ed..602df301ac 100644
--- a/drivers/net/mlx5/mlx5_nta_rss.c
+++ b/drivers/net/mlx5/mlx5_nta_rss.c
@@ -413,6 +413,54 @@ mlx5_nta_rss_init_ptype_ctx(struct mlx5_nta_rss_ctx *rss_ctx,
 	rss_ctx->external = external;
 }
 
+static struct rte_flow_hw *
+flow_nta_create_single(struct rte_eth_dev *dev,
+		       const struct rte_flow_attr *attr,
+		       const struct rte_flow_item items[],
+		       const struct rte_flow_action actions[],
+		       struct rte_flow_action_rss *rss_conf,
+		       int64_t item_flags, uint64_t action_flags,
+		       bool external, bool copy_actions,
+		       enum mlx5_flow_type flow_type,
+		       struct rte_flow_error *error)
+{
+	struct rte_flow_hw *flow = NULL;
+	struct rte_flow_action copy[MLX5_HW_MAX_ACTS];
+	const struct rte_flow_action *_actions;
+
+	if (copy_actions) {
+		int i;
+
+		_actions = copy;
+		for (i = 0; ; i++) {
+			copy[i] = actions[i];
+			switch (actions[i].type) {
+			case RTE_FLOW_ACTION_TYPE_RSS:
+				copy[i].conf = rss_conf;
+				break;
+			case RTE_FLOW_ACTION_TYPE_INDIRECT:
+				if (MLX5_INDIRECT_ACTION_TYPE_GET(actions[i].conf) ==
+					MLX5_INDIRECT_ACTION_TYPE_RSS) {
+					copy[i].type = RTE_FLOW_ACTION_TYPE_RSS;
+					copy[i].conf = rss_conf;
+				}
+				break;
+			case RTE_FLOW_ACTION_TYPE_END:
+				goto end;
+			default:
+				break;
+			}
+		}
+	} else {
+		_actions = actions;
+	}
+end:
+	flow_hw_create_flow(dev, flow_type, attr, items,
+			    _actions, item_flags, action_flags,
+			    external, &flow, error);
+	return flow;
+}
+
 /*
  * MLX5 HW hashes IPv4 and IPv6 L3 headers and UDP, TCP, ESP L4 headers.
  * RSS expansion is required when RSS action was configured to hash
@@ -436,10 +484,11 @@ flow_nta_handle_rss(struct rte_eth_dev *dev,
 		    struct rte_flow_error *error)
 {
 	struct rte_flow_hw *rss_base = NULL, *rss_next = NULL, *rss_miss = NULL;
-	struct rte_flow_action_rss ptype_rss_conf;
+	struct rte_flow_action_rss ptype_rss_conf = *rss_conf;
 	struct mlx5_nta_rss_ctx rss_ctx;
 	uint64_t rss_types = rte_eth_rss_hf_refine(rss_conf->types);
 	bool expand = true;
+	bool copy_actions = false;
 	bool inner_rss = rss_conf->level > 1;
 	bool outer_rss = !inner_rss;
 	bool l3_item = (outer_rss && (item_flags & MLX5_FLOW_LAYER_OUTER_L3)) ||
@@ -479,6 +528,7 @@ flow_nta_handle_rss(struct rte_eth_dev *dev,
 		[MLX5_RSS_PTYPE_ACTION_INDEX + 1] = { .type = RTE_FLOW_ACTION_TYPE_END }
 	};
 
+	ptype_rss_conf.types = rss_types;
 	if (l4_item) {
 		/*
 		 * Original flow pattern extended up to L4 level.
@@ -497,19 +547,35 @@ flow_nta_handle_rss(struct rte_eth_dev *dev,
 			/*
 			 * Original flow pattern extended up to L3 level.
 			 * RSS action was not set for L4 hash.
-			 * Original pattern does not need expansion.
 			 */
+			bool ip4_item =
+				(outer_rss && (item_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV4)) ||
+				(inner_rss && (item_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4));
+			bool ip6_item =
+				(outer_rss && (item_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV6)) ||
+				(inner_rss && (item_flags & MLX5_FLOW_LAYER_INNER_L3_IPV6));
+			bool ip4_hash = rss_types & MLX5_IPV4_LAYER_TYPES;
+			bool ip6_hash = rss_types & MLX5_IPV6_LAYER_TYPES;
+
 			expand = false;
+			if (ip4_item && ip4_hash) {
+				ptype_rss_conf.types &= ~MLX5_IPV6_LAYER_TYPES;
+				copy_actions = true;
+			} else if (ip6_item && ip6_hash) {
+				/*
+				 * MLX5 HW will not activate TIR IPv6 hash
+				 * if that TIR has also IPv4 hash
+				 */
+				ptype_rss_conf.types &= ~MLX5_IPV4_LAYER_TYPES;
+				copy_actions = true;
+			}
 		}
 	}
-	if (!expand) {
-		struct rte_flow_hw *flow = NULL;
-
-		flow_hw_create_flow(dev, flow_type, attr, items,
-				    actions, item_flags, action_flags,
-				    external, &flow, error);
-		return flow;
-	}
+	if (!expand)
+		return flow_nta_create_single(dev, attr, items, actions,
+					      &ptype_rss_conf, item_flags,
+					      action_flags, external,
+					      copy_actions, flow_type, error);
 	/* Create RSS expansions in dedicated PTYPE flow group */
 	ptype_attr.group = mlx5_hw_get_rss_ptype_group(dev);
 	if (!ptype_attr.group) {
@@ -517,11 +583,10 @@ flow_nta_handle_rss(struct rte_eth_dev *dev,
 				   NULL, "cannot get RSS PTYPE group");
 		return NULL;
 	}
-	ptype_rss_conf = *rss_conf;
 	mlx5_nta_rss_init_ptype_ctx(&rss_ctx, dev, &ptype_attr, ptype_pattern,
-				    ptype_actions, rss_conf, &expansion_head,
+				    ptype_actions, &ptype_rss_conf, &expansion_head,
 				    error, item_flags, flow_type, external);
-	rss_miss = mlx5_hw_rss_ptype_create_miss_flow(dev, rss_conf, ptype_attr.group,
+	rss_miss = mlx5_hw_rss_ptype_create_miss_flow(dev, &ptype_rss_conf, ptype_attr.group,
 						      external, error);
 	if (!rss_miss)
 		goto error;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-17 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-17 14:07 [PATCH 0/2] fix non-template IPv6 RSS hash Gregory Etelson
2024-06-17 14:07 ` [PATCH 1/2] net/mlx5: refactor non-template RSS expansion Gregory Etelson
2024-06-17 14:07 ` [PATCH 2/2] net/mlx5: fix non-template IPv6 RSS hash Gregory Etelson

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).