DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jiawei Wang <jiaweiw@nvidia.com>
To: <suanmingm@nvidia.com>, <orika@nvidia.com>, <thomas@monjalon.net>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>
Subject: [PATCH 2/3] net/mlx5: extend hws send to kernel action support
Date: Fri, 8 Sep 2023 12:20:59 +0300	[thread overview]
Message-ID: <20230908092100.38587-3-jiaweiw@nvidia.com> (raw)
In-Reply-To: <20230908092100.38587-1-jiaweiw@nvidia.com>

The hws send to kernel action was supported in NIC and FDB tables,
Currently, the send to kernel action is created in NIC RX only.

This patch adds the FDB and NIC-TX tables support for sending to the kernel
action for HWS.

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
---
 drivers/net/mlx5/mlx5.h         |  2 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 45 +++++++++++++++++++++++----------
 2 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 6960a07d40..d49b81a360 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1858,7 +1858,7 @@ struct mlx5_priv {
 	/* HW steering global tag action. */
 	struct mlx5dr_action *hw_tag[2];
 	/* HW steering global send to kernel action. */
-	struct mlx5dr_action *hw_send_to_kernel;
+	struct mlx5dr_action *hw_send_to_kernel[MLX5DR_TABLE_TYPE_MAX];
 	/* HW steering create ongoing rte flow table list header. */
 	LIST_HEAD(flow_hw_tbl_ongo, rte_flow_template_table) flow_hw_tbl_ongo;
 	struct mlx5_indexed_pool *acts_ipool; /* Action data indexed pool. */
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 92a5c92669..84d869a686 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -1439,6 +1439,7 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev,
 	uint32_t ct_idx;
 	int err;
 	uint32_t target_grp = 0;
+	int table_type;
 
 	flow_hw_modify_field_init(&mhdr, at);
 	if (attr->transfer)
@@ -1635,7 +1636,10 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev,
 						"Send to kernel action on root table is not supported in HW steering mode");
 			}
 			action_pos = at->actions_off[actions - at->actions];
-			acts->rule_acts[action_pos].action = priv->hw_send_to_kernel;
+			table_type = attr->ingress ? MLX5DR_TABLE_TYPE_NIC_RX :
+				     ((attr->egress) ? MLX5DR_TABLE_TYPE_NIC_TX :
+				     MLX5DR_TABLE_TYPE_FDB);
+			acts->rule_acts[action_pos].action = priv->hw_send_to_kernel[table_type];
 			break;
 		case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD:
 			err = flow_hw_modify_field_compile(dev, attr, action_start,
@@ -4345,8 +4349,11 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev,
 	const struct rte_flow_action_count *count_mask = NULL;
 	bool fixed_cnt = false;
 	uint64_t action_flags = 0;
-	uint16_t i;
 	bool actions_end = false;
+#ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
+	int table_type;
+#endif
+	uint16_t i;
 	int ret;
 
 	/* FDB actions are only valid to proxy port. */
@@ -4397,7 +4404,10 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev,
 							  RTE_FLOW_ERROR_TYPE_ACTION,
 							  action,
 							  "action not supported in guest port");
-			if (!priv->hw_send_to_kernel)
+			table_type = attr->ingress ? MLX5DR_TABLE_TYPE_NIC_RX :
+				     ((attr->egress) ? MLX5DR_TABLE_TYPE_NIC_TX :
+				     MLX5DR_TABLE_TYPE_FDB);
+			if (!priv->hw_send_to_kernel[table_type])
 				return rte_flow_error_set(error, ENOTSUP,
 							  RTE_FLOW_ERROR_TYPE_ACTION,
 							  action,
@@ -5955,13 +5965,19 @@ static void
 flow_hw_create_send_to_kernel_actions(struct mlx5_priv *priv __rte_unused)
 {
 #ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
-	priv->hw_send_to_kernel =
-			mlx5dr_action_create_dest_root(priv->dr_ctx,
-						       MLX5_HW_LOWEST_PRIO_ROOT,
-						       MLX5DR_ACTION_FLAG_HWS_RX);
-	if (!priv->hw_send_to_kernel) {
-		DRV_LOG(WARNING, "Unable to create HWS send to kernel action");
-		return;
+	int action_flag;
+	int i;
+
+	for (i = MLX5DR_TABLE_TYPE_NIC_RX; i < MLX5DR_TABLE_TYPE_MAX; i++) {
+		action_flag = mlx5_hw_act_flag[1][i];
+		priv->hw_send_to_kernel[i] =
+				mlx5dr_action_create_dest_root(priv->dr_ctx,
+							MLX5_HW_LOWEST_PRIO_ROOT,
+							action_flag);
+		if (!priv->hw_send_to_kernel[i]) {
+			DRV_LOG(WARNING, "Unable to create HWS send to kernel action");
+			return;
+		}
 	}
 #endif
 }
@@ -5969,9 +5985,12 @@ flow_hw_create_send_to_kernel_actions(struct mlx5_priv *priv __rte_unused)
 static void
 flow_hw_destroy_send_to_kernel_action(struct mlx5_priv *priv)
 {
-	if (priv->hw_send_to_kernel) {
-		mlx5dr_action_destroy(priv->hw_send_to_kernel);
-		priv->hw_send_to_kernel = NULL;
+	int i;
+	for (i = MLX5DR_TABLE_TYPE_NIC_RX; i < MLX5DR_TABLE_TYPE_MAX; i++) {
+		if (priv->hw_send_to_kernel[i]) {
+			mlx5dr_action_destroy(priv->hw_send_to_kernel[i]);
+			priv->hw_send_to_kernel[i] = NULL;
+		}
 	}
 }
 
-- 
2.18.1


  parent reply	other threads:[~2023-09-08  9:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08  9:20 [PATCH 0/3] net/mlx5: extend " Jiawei Wang
2023-09-08  9:20 ` [PATCH 1/3] " Jiawei Wang
2023-09-08  9:35   ` Suanming Mou
2023-09-18 12:52   ` Raslan Darawsheh
2023-09-08  9:20 ` Jiawei Wang [this message]
2023-09-08  9:35   ` [PATCH 2/3] net/mlx5: extend hws " Suanming Mou
2023-09-08  9:21 ` [PATCH 3/3] doc: adds the description for send to kernel Jiawei Wang

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=20230908092100.38587-3-jiaweiw@nvidia.com \
    --to=jiaweiw@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    /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).