[1/2] net/mlx5: refactor non-template RSS expansion

Message ID 20240617140747.169197-2-getelson@nvidia.com (mailing list archive)
State Awaiting Upstream
Delegated to: Raslan Darawsheh
Headers
Series fix non-template IPv6 RSS hash |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gregory Etelson June 17, 2024, 2:07 p.m. UTC
  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(-)
  

Patch

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