Skip to contentSkip to conversation

Non template to HWS fixes

PATCH In review Maayan Kashani 2 participants 5 messages Jan 28, 2025 – Feb 6, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

cover Non template to HWS fixes

Few fixes for non template mode on top of HWS.

Maayan Kashani (3):
net/mlx5: fix limitation of actions per rule net/mlx5: fix crash in non template metadata split net/mlx5: fix flow flush for non-template flows

 drivers/net/mlx5/mlx5_flow.c      |  1 -
 drivers/net/mlx5/mlx5_flow.h      |  2 +-
 drivers/net/mlx5/mlx5_flow_hw.c   |  3 ---
 drivers/net/mlx5/mlx5_nta_split.c | 28 +++++++++++++++-------------
 4 files changed, 16 insertions(+), 18 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/3 net/mlx5: fix limitation of actions per rule

HWS implementation added a limitation of 16 actions per rule, which was incompatible with SWS limitation of 32 actions per rule.

Changing the hard coded limitation in PMD to 32.

Fixes f13fab23922b ("net/mlx5: add flow jump action")
---
 drivers/net/mlx5/mlx5_flow.h    | 2 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/net/mlx5/mlx5_flow.h +1 -1
index 93c2406abc9..445c9cdb4bf 100644
@@ -1583,7 +1583,7 @@ struct mlx5_hw_modify_header_action {
 };
 
 /* The maximum actions support in the flow. */
-#define MLX5_HW_MAX_ACTS 16
+#define MLX5_HW_MAX_ACTS 32
 
 /* DR action set struct. */
 struct mlx5_hw_actions {
drivers/net/mlx5/mlx5_flow_hw.c +0 -3
index 2b627114131..501bf33f941 100644
@@ -21,9 +21,6 @@
 /** Fast path async flow API functions. */
 static struct rte_flow_fp_ops mlx5_flow_hw_fp_ops;
 
-/* The maximum actions support in the flow. */
-#define MLX5_HW_MAX_ACTS 16
-
 /*
  * The default ipool threshold value indicates which per_core_cache
  * value to set.
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/3 net/mlx5: fix crash in non template metadata split

In reply to Maayan Kashani

For switch dev mode, there is a rule split in case of using mark action. First rule will have the mark action, tag it with rule ID number and jump to the second rule that matches the tag and perform the rest of the actions (like RSS or queue).

First, fix the crash when accessing RSS queue[0] instead of queue index, same as for queue action handling for hairpin RX queue check.
Second, set tag action is not supported in HWS, so, replaced set tag action with modify field action. Used same tag index for both action and matching.

Fixes 821a6a5cc495 ("net/mlx5: add metadata split for compatibility")
---
 drivers/net/mlx5/mlx5_nta_split.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5_nta_split.c +15 -13
index b26f305bcab..6a85ab7fd12 100644
@@ -13,6 +13,8 @@
 
 #ifdef HAVE_MLX5_HWS_SUPPORT
 
+#define BITS_PER_BYTE	8
+
 /*
  * Generate new actions lists for prefix and suffix flows.
  *
@@ -44,11 +46,10 @@ mlx5_flow_nta_split_qrss_actions_prep(struct rte_eth_dev *dev,
 				      struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	struct mlx5_rte_flow_action_set_tag *set_tag;
+	struct rte_flow_action_modify_field *set_tag;
 	struct rte_flow_action_jump *jump;
 	const int qrss_idx = qrss - actions;
 	uint32_t flow_id = 0;
-	int ret = 0;
 
 	/* Allocate the new subflow ID and used to be matched later. */
 	mlx5_ipool_malloc(priv->sh->ipool[MLX5_IPOOL_RSS_EXPANTION_FLOW_ID], &flow_id);
@@ -67,16 +68,16 @@ mlx5_flow_nta_split_qrss_actions_prep(struct rte_eth_dev *dev,
 	/* Count MLX5_RTE_FLOW_ACTION_TYPE_TAG. */
 	actions_n++;
 	set_tag = (void *)(prefix_act + actions_n);
-	/* Reuse ASO reg, should always succeed. Consider to use REG_C_6. */
-	ret = flow_hw_get_reg_id_by_domain(dev, RTE_FLOW_ITEM_TYPE_METER_COLOR,
-					   MLX5DR_TABLE_TYPE_NIC_RX, 0);
-	MLX5_ASSERT(ret != (int)REG_NON);
-	set_tag->id = (enum modify_reg)ret;
 	/* Internal SET_TAG action to set flow ID. */
-	set_tag->data = flow_id;
+	set_tag->operation = RTE_FLOW_MODIFY_SET;
+	set_tag->width = sizeof(flow_id) * BITS_PER_BYTE;
+	set_tag->src.field = RTE_FLOW_FIELD_VALUE;
+	memcpy(&set_tag->src.value, &flow_id, sizeof(flow_id));
+	set_tag->dst.field = RTE_FLOW_FIELD_TAG;
+	set_tag->dst.tag_index = RTE_PMD_MLX5_LINEAR_HASH_TAG_INDEX;
 	/* Construct new actions array and replace QUEUE/RSS action. */
 	prefix_act[qrss_idx] = (struct rte_flow_action) {
-		.type = (enum rte_flow_action_type)MLX5_RTE_FLOW_ACTION_TYPE_TAG,
+		.type = RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
 		.conf = set_tag,
 	};
 	/* JUMP action to jump to mreg copy table (CP_TBL). */
@@ -132,8 +133,9 @@ mlx5_flow_nta_split_qrss_items_prep(struct rte_eth_dev *dev,
 	split_items[1].type = RTE_FLOW_ITEM_TYPE_END;
 	q_tag_spec->data = qrss_id;
 	q_tag_spec->id = (enum modify_reg)
-			 flow_hw_get_reg_id_by_domain(dev, RTE_FLOW_ITEM_TYPE_METER_COLOR,
-						      MLX5DR_TABLE_TYPE_NIC_RX, 0);
+			 flow_hw_get_reg_id_by_domain(dev, RTE_FLOW_ITEM_TYPE_TAG,
+						      MLX5DR_TABLE_TYPE_NIC_RX,
+						      RTE_PMD_MLX5_LINEAR_HASH_TAG_INDEX);
 	MLX5_ASSERT(q_tag_spec->id != REG_NON);
 }
 
@@ -211,12 +213,12 @@ mlx5_flow_nta_split_metadata(struct rte_eth_dev *dev,
 			return 0;
 	} else if (action_flags & MLX5_FLOW_ACTION_RSS) {
 		rss = (const struct rte_flow_action_rss *)actions->conf;
-		if (mlx5_rxq_is_hairpin(dev, rss->queue[0]))
+		if (mlx5_rxq_is_hairpin(dev, rss->queue_num))
 			return 0;
 	}
 	/* The prefix and suffix flows' actions. */
 	pefx_act_size = sizeof(struct rte_flow_action) * (actions_n + 1) +
-			sizeof(struct rte_flow_action_set_tag) +
+			sizeof(struct rte_flow_action_modify_field) +
 			sizeof(struct rte_flow_action_jump);
 	sfx_act_size = sizeof(struct rte_flow_action) * 2;
 	/* The suffix attribute. */
Signature · 1 line
2.21.0
#3 lore raw

PATCH 3/3 net/mlx5: fix flow flush for non-template flows

In reply to Maayan Kashani

Fix flow flush for non template flows on top of HWS,
in another fix it was added return after releasing template flows. Need to drop the return in order to release non template list of flows.

Fixes 1ea333d2de22 ("net/mlx5: fix Rx queue reference count in flushing flows")
---
 drivers/net/mlx5/mlx5_flow.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/mlx5/mlx5_flow.c +0 -1
index 9203643300d..3d3b422f057 100644
@@ -8121,7 +8121,6 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,
 		priv->hws_rule_flushing = true;
 		flow_hw_q_flow_flush(dev, NULL);
 		priv->hws_rule_flushing = false;
-		return;
 	}
 #endif
 	MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) {
Signature · 1 line
2.21.0
#4 lore raw
In reply to Maayan Kashani

Hi,

From: Maayan Kashani <[email protected]>
Sent: Tuesday, January 28, 2025 9:54 AM
To: [email protected]
Cc: Maayan Kashani; Dariusz Sosnowski; Raslan Darawsheh
Subject: [PATCH 0/3] Non template to HWS fixes

Few fixes for non template mode on top of HWS.

Maayan Kashani (3):
net/mlx5: fix limitation of actions per rule net/mlx5: fix crash in non template metadata split net/mlx5: fix flow flush for non-template flows

 drivers/net/mlx5/mlx5_flow.c      |  1 -
 drivers/net/mlx5/mlx5_flow.h      |  2 +-
 drivers/net/mlx5/mlx5_flow_hw.c   |  3 ---
 drivers/net/mlx5/mlx5_nta_split.c | 28 +++++++++++++++-------------
 4 files changed, 16 insertions(+), 18 deletions(-)

--
2.21.0

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

________________________________________