Skip to contentSkip to conversation

net/mlx5/hws: fix incorrect DV FT type convert

PATCH Superseded Dariusz Sosnowski 3 participants 4 messages Mar 5, 2025 – Mar 11, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5/hws: fix incorrect DV FT type convert

From: Alex Vesker <[email protected]>

When creating a root modify/reformat action it is created for a single specific table type, current code ignored this and used the first ft_type found in if, else.
Also added missing translation for non-root FDB action root dest.

Fixes f8c8a6d8440d ("net/mlx5/hws: add action object")
---
 drivers/net/mlx5/hws/mlx5dr_action.c | 68 ++++++++++++++++++++++++----
 1 file changed, 58 insertions(+), 10 deletions(-)
drivers/net/mlx5/hws/mlx5dr_action.c +58 -10
index c3e67f8a0b..5e2b845985 100644
@@ -1879,19 +1879,67 @@ mlx5dr_action_conv_reformat_to_verbs(uint32_t action_type,
 }
 
 static int
-mlx5dr_action_conv_flags_to_ft_type(uint32_t flags, enum mlx5dv_flow_table_type *ft_type)
+mlx5dr_action_conv_root_flags_to_dv_ft(uint32_t flags,
+				       enum mlx5dv_flow_table_type *ft_type)
 {
-	if (flags & (MLX5DR_ACTION_FLAG_ROOT_RX | MLX5DR_ACTION_FLAG_HWS_RX)) {
+	uint8_t is_rx, is_tx, is_fdb;
+
+	is_rx = !!(flags & MLX5DR_ACTION_FLAG_ROOT_RX);
+	is_tx = !!(flags & MLX5DR_ACTION_FLAG_ROOT_TX);
+	is_fdb = !!(flags & MLX5DR_ACTION_FLAG_ROOT_FDB);
+
+	if (is_rx + is_tx + is_fdb != 1) {
+		DR_LOG(ERR, "Root action flags must be converted to a single ft type");
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+
+	if (is_rx) {
+		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_RX;
+	} else if (is_tx) {
+		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_TX;
+#ifdef HAVE_MLX5DV_FLOW_MATCHER_FT_TYPE
+	} else if (is_fdb) {
+		*ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB;
+#endif
+	} else {
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+
+	return 0;
+}
+
+static int
+mlx5dr_action_conv_hws_flags_to_dv_ft(uint32_t flags,
+				     enum mlx5dv_flow_table_type *ft_type)
+{
+	uint8_t is_rx, is_tx, is_fdb;
+
+	is_rx = !!(flags & MLX5DR_ACTION_FLAG_HWS_RX);
+	is_tx = !!(flags & MLX5DR_ACTION_FLAG_HWS_TX);
+	is_fdb = !!(flags & (MLX5DR_ACTION_FLAG_HWS_FDB |
+			     MLX5DR_ACTION_FLAG_HWS_FDB_RX |
+			     MLX5DR_ACTION_FLAG_HWS_FDB_TX |
+			     MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED));
+
+	if (is_rx + is_tx + is_fdb != 1) {
+		DR_LOG(ERR, "Action flags must be converted to a single ft type");
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+
+	if (is_rx) {
 		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_RX;
-	} else if (flags & (MLX5DR_ACTION_FLAG_ROOT_TX | MLX5DR_ACTION_FLAG_HWS_TX)) {
+	} else if (is_tx) {
 		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_TX;
 #ifdef HAVE_MLX5DV_FLOW_MATCHER_FT_TYPE
-	} else if (flags & (MLX5DR_ACTION_FLAG_ROOT_FDB | MLX5DR_ACTION_FLAG_HWS_FDB)) {
+	} else if (is_fdb) {
 		*ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB;
 #endif
 	} else {
 		rte_errno = ENOTSUP;
-		return 1;
+		return -rte_errno;
 	}
 
 	return 0;
@@ -1908,9 +1956,9 @@ mlx5dr_action_create_reformat_root(struct mlx5dr_action *action,
 	int ret;
 
 	/* Convert action to FT type and verbs reformat type */
-	ret = mlx5dr_action_conv_flags_to_ft_type(action->flags, &ft_type);
+	ret = mlx5dr_action_conv_root_flags_to_dv_ft(action->flags, &ft_type);
 	if (ret)
-		return rte_errno;
+		return ret;
 
 	ret = mlx5dr_action_conv_reformat_to_verbs(action->type, &verb_reformat_type);
 	if (ret)
@@ -2249,9 +2297,9 @@ mlx5dr_action_create_modify_header_root(struct mlx5dr_action *action,
 	struct ibv_context *local_ibv_ctx;
 	int ret;
 
-	ret = mlx5dr_action_conv_flags_to_ft_type(action->flags, &ft_type);
+	ret = mlx5dr_action_conv_root_flags_to_dv_ft(action->flags, &ft_type);
 	if (ret)
-		return rte_errno;
+		return ret;
 
 	local_ibv_ctx = mlx5dr_context_get_local_ibv(action->ctx);
 
@@ -2655,7 +2703,7 @@ mlx5dr_action_create_dest_root(struct mlx5dr_context *ctx,
 		return NULL;
 	}
 
-	if (mlx5dr_action_conv_flags_to_ft_type(flags, &attr.ft_type))
+	if (mlx5dr_action_conv_hws_flags_to_dv_ft(flags, &attr.ft_type))
 		return NULL;
 
 	attr.priority = priority;
Signature · 1 line
2.39.5
#1 lore raw

Recheck-request: iol-intel-Performance

There was an infra failure with the Arm Grace server about 12 hours ago which caused this failure - sending a retest request.

#2 lore raw

PATCH v2 1/1 net/mlx5/hws: fix incorrect DV FT type convert

In reply to Dariusz Sosnowski

From: Alex Vesker <[email protected]>

When creating a root modify/reformat action it is created for a single specific table type, current code ignored this and used the first ft_type found in if, else.
Also added missing translation for non-root FDB action root dest.

Fixes f8c8a6d8440d ("net/mlx5/hws: add action object")

---

v2:
* Rebase on top of v25.03-rc2

 drivers/net/mlx5/hws/mlx5dr_action.c | 68 ++++++++++++++++++++++++----
 1 file changed, 58 insertions(+), 10 deletions(-)
drivers/net/mlx5/hws/mlx5dr_action.c +58 -10
index c3e67f8a0b..5e2b845985 100644
@@ -1879,19 +1879,67 @@ mlx5dr_action_conv_reformat_to_verbs(uint32_t action_type,
 }
 
 static int
-mlx5dr_action_conv_flags_to_ft_type(uint32_t flags, enum mlx5dv_flow_table_type *ft_type)
+mlx5dr_action_conv_root_flags_to_dv_ft(uint32_t flags,
+				       enum mlx5dv_flow_table_type *ft_type)
 {
-	if (flags & (MLX5DR_ACTION_FLAG_ROOT_RX | MLX5DR_ACTION_FLAG_HWS_RX)) {
+	uint8_t is_rx, is_tx, is_fdb;
+
+	is_rx = !!(flags & MLX5DR_ACTION_FLAG_ROOT_RX);
+	is_tx = !!(flags & MLX5DR_ACTION_FLAG_ROOT_TX);
+	is_fdb = !!(flags & MLX5DR_ACTION_FLAG_ROOT_FDB);
+
+	if (is_rx + is_tx + is_fdb != 1) {
+		DR_LOG(ERR, "Root action flags must be converted to a single ft type");
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+
+	if (is_rx) {
+		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_RX;
+	} else if (is_tx) {
+		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_TX;
+#ifdef HAVE_MLX5DV_FLOW_MATCHER_FT_TYPE
+	} else if (is_fdb) {
+		*ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB;
+#endif
+	} else {
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+
+	return 0;
+}
+
+static int
+mlx5dr_action_conv_hws_flags_to_dv_ft(uint32_t flags,
+				     enum mlx5dv_flow_table_type *ft_type)
+{
+	uint8_t is_rx, is_tx, is_fdb;
+
+	is_rx = !!(flags & MLX5DR_ACTION_FLAG_HWS_RX);
+	is_tx = !!(flags & MLX5DR_ACTION_FLAG_HWS_TX);
+	is_fdb = !!(flags & (MLX5DR_ACTION_FLAG_HWS_FDB |
+			     MLX5DR_ACTION_FLAG_HWS_FDB_RX |
+			     MLX5DR_ACTION_FLAG_HWS_FDB_TX |
+			     MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED));
+
+	if (is_rx + is_tx + is_fdb != 1) {
+		DR_LOG(ERR, "Action flags must be converted to a single ft type");
+		rte_errno = ENOTSUP;
+		return -rte_errno;
+	}
+
+	if (is_rx) {
 		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_RX;
-	} else if (flags & (MLX5DR_ACTION_FLAG_ROOT_TX | MLX5DR_ACTION_FLAG_HWS_TX)) {
+	} else if (is_tx) {
 		*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_TX;
 #ifdef HAVE_MLX5DV_FLOW_MATCHER_FT_TYPE
-	} else if (flags & (MLX5DR_ACTION_FLAG_ROOT_FDB | MLX5DR_ACTION_FLAG_HWS_FDB)) {
+	} else if (is_fdb) {
 		*ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB;
 #endif
 	} else {
 		rte_errno = ENOTSUP;
-		return 1;
+		return -rte_errno;
 	}
 
 	return 0;
@@ -1908,9 +1956,9 @@ mlx5dr_action_create_reformat_root(struct mlx5dr_action *action,
 	int ret;
 
 	/* Convert action to FT type and verbs reformat type */
-	ret = mlx5dr_action_conv_flags_to_ft_type(action->flags, &ft_type);
+	ret = mlx5dr_action_conv_root_flags_to_dv_ft(action->flags, &ft_type);
 	if (ret)
-		return rte_errno;
+		return ret;
 
 	ret = mlx5dr_action_conv_reformat_to_verbs(action->type, &verb_reformat_type);
 	if (ret)
@@ -2249,9 +2297,9 @@ mlx5dr_action_create_modify_header_root(struct mlx5dr_action *action,
 	struct ibv_context *local_ibv_ctx;
 	int ret;
 
-	ret = mlx5dr_action_conv_flags_to_ft_type(action->flags, &ft_type);
+	ret = mlx5dr_action_conv_root_flags_to_dv_ft(action->flags, &ft_type);
 	if (ret)
-		return rte_errno;
+		return ret;
 
 	local_ibv_ctx = mlx5dr_context_get_local_ibv(action->ctx);
 
@@ -2655,7 +2703,7 @@ mlx5dr_action_create_dest_root(struct mlx5dr_context *ctx,
 		return NULL;
 	}
 
-	if (mlx5dr_action_conv_flags_to_ft_type(flags, &attr.ft_type))
+	if (mlx5dr_action_conv_hws_flags_to_dv_ft(flags, &attr.ft_type))
 		return NULL;
 
 	attr.priority = priority;

--
2.39.5

Acked-by Dariusz Sosnowski on v1 1/1
#3 lore raw
In reply to Dariusz Sosnowski

Hi,

From: Dariusz Sosnowski <[email protected]>
Sent: Wednesday, March 5, 2025 3:23 PM
To: Slava Ovsiienko; Bing Zhao; Ori Kam; Suanming Mou; Matan Azrad; Erez Shitrit; Alex Vesker
Cc: [email protected]; [email protected]
Subject: [PATCH] net/mlx5/hws: fix incorrect DV FT type convert

From: Alex Vesker <[email protected]>

When creating a root modify/reformat action it is created for a single specific table type, current code ignored this and used the first ft_type found in if, else.
Also added missing translation for non-root FDB action root dest.

Fixes f8c8a6d8440d ("net/mlx5/hws: add action object")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh