patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Kevin Traynor <ktraynor@redhat.com>
Cc: <stable@dpdk.org>, Alex Vesker <valex@nvidia.com>
Subject: [PATCH 24.11] net/mlx5/hws: fix DV FT type convert
Date: Tue, 25 Mar 2025 12:10:32 +0100	[thread overview]
Message-ID: <20250325111032.70851-1-dsosnowski@nvidia.com> (raw)

From: Alex Vesker <valex@nvidia.com>

[ upstream commit 16ac8f980042da5c88860f1931789f3060caa38c ]

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")
Cc: stable@dpdk.org

Signed-off-by: Alex Vesker <valex@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_action.c | 65 +++++++++++++++++++++++-----
 1 file changed, 55 insertions(+), 10 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c
index b038ca6879..57491c0f48 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -1705,19 +1705,64 @@ 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);
+
+	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;
@@ -1734,9 +1779,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)
@@ -2075,9 +2120,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);

@@ -2467,7 +2512,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


             reply	other threads:[~2025-03-25 11:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25 11:10 Dariusz Sosnowski [this message]
2025-03-25 13:22 ` Kevin Traynor

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=20250325111032.70851-1-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=ktraynor@redhat.com \
    --cc=stable@dpdk.org \
    --cc=valex@nvidia.com \
    /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).