public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
	Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>, Raslan Darawsheh <rasland@nvidia.com>
Subject: [PATCH 2/9] net/mlx5/hws: add table type to action flags conversion
Date: Wed, 25 Feb 2026 12:59:10 +0100	[thread overview]
Message-ID: <20260225115918.233843-3-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20260225115918.233843-1-dsosnowski@nvidia.com>

Add function for converting HWS table type to corresponding
HWS action flag for both root and non-root tables.

Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr.h       | 16 ++++++
 drivers/net/mlx5/hws/mlx5dr_table.c | 75 +++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+)

diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h
index d358178e5b..078740a530 100644
--- a/drivers/net/mlx5/hws/mlx5dr.h
+++ b/drivers/net/mlx5/hws/mlx5dr.h
@@ -369,6 +369,22 @@ mlx5dr_context_open(struct ibv_context *ibv_ctx,
  */
 int mlx5dr_context_close(struct mlx5dr_context *ctx);
 
+/**
+ * Convert given table type to corresponding action type.
+ *
+ * @param[in] table_type
+ *	Table type.
+ * @param[in] is_root
+ *	Whether table should be considered root or not.
+ * @param[out] action_flags
+ *	Corresponding action flags will be written here.
+ * @return
+ *	0 on success. Negative errno and rte_errno is set otherwise.
+ */
+int mlx5dr_table_type_to_action_flags(const enum mlx5dr_table_type table_type,
+				      const bool is_root,
+				      enum mlx5dr_action_flags *action_flags);
+
 /* Create a new direct rule table. Each table can contain multiple matchers.
  *
  * @param[in] ctx
diff --git a/drivers/net/mlx5/hws/mlx5dr_table.c b/drivers/net/mlx5/hws/mlx5dr_table.c
index c1c60b4e52..41ffaa19e3 100644
--- a/drivers/net/mlx5/hws/mlx5dr_table.c
+++ b/drivers/net/mlx5/hws/mlx5dr_table.c
@@ -4,6 +4,81 @@
 
 #include "mlx5dr_internal.h"
 
+static int
+table_type_to_root_action_flags(enum mlx5dr_table_type table_type,
+				enum mlx5dr_action_flags *out)
+{
+	switch (table_type) {
+	case MLX5DR_TABLE_TYPE_NIC_RX:
+		*out = MLX5DR_ACTION_FLAG_ROOT_RX;
+		break;
+	case MLX5DR_TABLE_TYPE_NIC_TX:
+		*out = MLX5DR_ACTION_FLAG_ROOT_TX;
+		break;
+	case MLX5DR_TABLE_TYPE_FDB:
+		*out = MLX5DR_ACTION_FLAG_ROOT_FDB;
+		break;
+	default:
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
+
+	return 0;
+}
+
+static int
+table_type_to_nonroot_action_flags(enum mlx5dr_table_type table_type,
+				   enum mlx5dr_action_flags *out)
+{
+	switch (table_type) {
+	case MLX5DR_TABLE_TYPE_NIC_RX:
+		*out = MLX5DR_ACTION_FLAG_HWS_RX;
+		break;
+	case MLX5DR_TABLE_TYPE_NIC_TX:
+		*out = MLX5DR_ACTION_FLAG_HWS_TX;
+		break;
+	case MLX5DR_TABLE_TYPE_FDB:
+		*out = MLX5DR_ACTION_FLAG_HWS_FDB;
+		break;
+	case MLX5DR_TABLE_TYPE_FDB_RX:
+		*out = MLX5DR_ACTION_FLAG_HWS_FDB_RX;
+		break;
+	case MLX5DR_TABLE_TYPE_FDB_TX:
+		*out = MLX5DR_ACTION_FLAG_HWS_FDB_TX;
+		break;
+	case MLX5DR_TABLE_TYPE_FDB_UNIFIED:
+		*out = MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED;
+		break;
+	default:
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
+
+	return 0;
+}
+
+int
+mlx5dr_table_type_to_action_flags(const enum mlx5dr_table_type table_type,
+				  const bool is_root,
+				  enum mlx5dr_action_flags *action_flags)
+{
+	int ret = 0;
+
+	if (is_root) {
+		ret = table_type_to_root_action_flags(table_type, action_flags);
+		if (ret < 0)
+			DR_LOG(ERR, "Cannot convert table type %d to action flags for root table",
+			       table_type);
+	} else {
+		ret = table_type_to_nonroot_action_flags(table_type, action_flags);
+		if (ret < 0)
+			DR_LOG(ERR, "Cannot convert table type %d to action flags for HWS table",
+			       table_type);
+	}
+
+	return ret;
+}
+
 static void mlx5dr_table_init_next_ft_attr(struct mlx5dr_table *tbl,
 					   struct mlx5dr_cmd_ft_create_attr *ft_attr)
 {
-- 
2.47.3


  parent reply	other threads:[~2026-02-25 12:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 11:59 [PATCH 0/9] net/mlx5: lazily allocate HWS actions Dariusz Sosnowski
2026-02-25 11:59 ` [PATCH 1/9] net/mlx5: use DPDK be64 type in modify header pattern Dariusz Sosnowski
2026-02-25 11:59 ` Dariusz Sosnowski [this message]
2026-02-25 11:59 ` [PATCH 3/9] net/mlx5: lazily allocate drop HWS action Dariusz Sosnowski
2026-02-25 11:59 ` [PATCH 4/9] net/mlx5: lazily allocate tag " Dariusz Sosnowski
2026-02-25 11:59 ` [PATCH 5/9] net/mlx5: lazily allocate HWS pop VLAN action Dariusz Sosnowski
2026-02-25 11:59 ` [PATCH 6/9] net/mlx5: lazily allocate HWS push " Dariusz Sosnowski
2026-02-25 11:59 ` [PATCH 7/9] net/mlx5: lazily allocate HWS send to kernel action Dariusz Sosnowski
2026-02-25 11:59 ` [PATCH 8/9] net/mlx5: lazily allocate HWS NAT64 action Dariusz Sosnowski
2026-02-25 11:59 ` [PATCH 9/9] net/mlx5: lazily allocate HWS default miss action Dariusz Sosnowski
2026-03-02 11:22 ` [PATCH 0/9] net/mlx5: lazily allocate HWS actions Raslan Darawsheh

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=20260225115918.233843-3-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@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