DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michael Savisko <michaelsav@nvidia.com>
To: <dev@dpdk.org>
Cc: <michaelsav@nvidia.com>, <orika@nvidia.com>,
	<viacheslavo@nvidia.com>, <asafp@nvidia.com>,
	Matan Azrad <matan@nvidia.com>,
	Ferruh Yigit <ferruh.yigit@amd.com>
Subject: [PATCH v2 4/4] net/mlx5: translation of rte flow send to kernel action
Date: Wed, 19 Oct 2022 21:40:07 +0300	[thread overview]
Message-ID: <20221019184007.1032874-5-michaelsav@nvidia.com> (raw)
In-Reply-To: <20221019184007.1032874-1-michaelsav@nvidia.com>

Introduce mlx5_get_send_to_kernel_priority() function which returns
value of priority which must be used to jump back to table 0 in order
to send traffic to kernel. This function returns lowest priority.

Add flow_dv_translate_action_send_to_kernel() function which
will allocate rdma-core send_to_kernel action object.
Called from flow_dv_translate().

Fail translation of RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL action in
HW steering.

Signed-off-by: Michael Savisko <michaelsav@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 doc/guides/nics/features/default.ini |  1 +
 doc/guides/nics/features/mlx5.ini    |  1 +
 drivers/net/mlx5/mlx5_flow.c         | 32 ++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h         |  1 +
 drivers/net/mlx5/mlx5_flow_dv.c      | 57 ++++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5_flow_hw.c      |  3 ++
 6 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index b450ef7e1a..5ed2b90843 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -198,3 +198,4 @@ set_ttl              =
 vf                   =
 vxlan_decap          =
 vxlan_encap          =
+send_to_kernel       =
diff --git a/doc/guides/nics/features/mlx5.ini b/doc/guides/nics/features/mlx5.ini
index e5974063c8..9f158ef171 100644
--- a/doc/guides/nics/features/mlx5.ini
+++ b/doc/guides/nics/features/mlx5.ini
@@ -128,3 +128,4 @@ set_tp_src           = Y
 set_ttl              = Y
 vxlan_decap          = Y
 vxlan_encap          = Y
+send_to_kernel       = Y
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e4744b0a67..de998a9720 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -10967,6 +10967,38 @@ mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	return  res;
 }
 
+/**
+ * Get the priority for sending traffic to kernel table.
+ *
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ *
+ * @return
+ *   On success: the value of priority for sending traffic to kernel table
+ *   On failure: -1
+ */
+uint32_t
+mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t res;
+
+	switch (priv->sh->flow_max_priority) {
+	case RTE_DIM(priority_map_5):
+		res = 15;
+		break;
+	case RTE_DIM(priority_map_3):
+		res = 7;
+		break;
+	default:
+		DRV_LOG(ERR,
+			"port %u maximum priority: %d expected 8/16",
+			dev->data->port_id, priv->sh->flow_max_priority);
+		res = (uint32_t)-1;
+	}
+	return res;
+}
+
 /**
  * Get the E-Switch Manager vport id.
  *
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 525db05969..8e97fa188a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1753,6 +1753,7 @@ uint32_t mlx5_get_lowest_priority(struct rte_eth_dev *dev,
 uint16_t mlx5_get_matcher_priority(struct rte_eth_dev *dev,
 				   const struct rte_flow_attr *attr,
 				   uint32_t subpriority, bool external);
+uint32_t mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev);
 int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
 				     enum mlx5_feature_name feature,
 				     uint32_t id,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index bcd9926b81..4bdcb1815b 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -12192,6 +12192,51 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static void *
+flow_dv_translate_action_send_to_kernel(struct rte_eth_dev *dev,
+					struct rte_flow_error *error)
+{
+	struct mlx5_flow_tbl_resource *tbl;
+	struct mlx5_dev_ctx_shared *sh;
+	uint32_t priority;
+	void *action;
+	int ret;
+
+	sh = MLX5_SH(dev);
+	if (sh->send_to_kernel_action.action)
+		return sh->send_to_kernel_action.action;
+	priority = mlx5_get_send_to_kernel_priority(dev);
+	if (priority == (uint32_t)-1) {
+		rte_flow_error_set(error, ENOTSUP,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "required priority is not available");
+		return NULL;
+	}
+	tbl = flow_dv_tbl_resource_get(dev, 0, 0, 0, false, NULL, 0, 0, 0,
+				       error);
+	if (!tbl) {
+		rte_flow_error_set(error, ENODATA,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "cannot find destination root table");
+		return NULL;
+	}
+	ret = mlx5_flow_os_create_flow_action_send_to_kernel(tbl->obj,
+				priority, &action);
+	if (ret) {
+		rte_flow_error_set(error, ENOMEM,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "cannot create action");
+		goto err;
+	}
+	MLX5_ASSERT(action);
+	sh->send_to_kernel_action.action = action;
+	sh->send_to_kernel_action.tbl = tbl;
+	return action;
+err:
+	flow_dv_tbl_resource_release(sh, tbl);
+	return NULL;
+}
+
 /**
  * Convert Sample action to DV specification.
  *
@@ -13697,9 +13742,15 @@ flow_dv_translate(struct rte_eth_dev *dev,
 			action_flags |= MLX5_FLOW_ACTION_CT;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
-			return rte_flow_error_set(error, ENOTSUP,
-				RTE_FLOW_ERROR_TYPE_ACTION,
-				NULL, "send to kernel action is not supported.");
+			dev_flow->dv.actions[actions_n] =
+				flow_dv_translate_action_send_to_kernel(dev,
+							error);
+			if (!dev_flow->dv.actions[actions_n])
+				return -rte_errno;
+			actions_n++;
+			action_flags |= MLX5_FLOW_ACTION_SEND_TO_KERNEL;
+			dev_flow->handle->fate_action =
+					MLX5_FLOW_FATE_SEND_TO_KERNEL;
 			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 12498794a5..b168ff9e7e 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -707,6 +707,9 @@ flow_hw_actions_translate(struct rte_eth_dev *dev,
 			reformat_pos = i++;
 			refmt_type = MLX5DR_ACTION_REFORMAT_TYPE_TNL_L2_TO_L2;
 			break;
+		case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
+			DRV_LOG(ERR, "send to kernel action is not supported in HW steering.");
+			goto err;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			break;
-- 
2.27.0


  parent reply	other threads:[~2022-10-19 18:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 18:40 [PATCH v2 0/4] net/mlx5: implement " Michael Savisko
2022-10-19 18:40 ` [PATCH v2 1/4] common/mlx5: new glue callback for " Michael Savisko
2022-10-19 18:40 ` [PATCH v2 2/4] net/mlx5: introduce new mlx5 action flag Michael Savisko
2022-10-20  8:23   ` Raslan Darawsheh
2022-10-19 18:40 ` [PATCH v2 3/4] net/mlx5: add send to kernel action resource holder Michael Savisko
2022-10-19 18:40 ` Michael Savisko [this message]
2022-10-20  8:25 ` [PATCH v2 0/4] net/mlx5: implement send to kernel action 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=20221019184007.1032874-5-michaelsav@nvidia.com \
    --to=michaelsav@nvidia.com \
    --cc=asafp@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=matan@nvidia.com \
    --cc=orika@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;
as well as URLs for NNTP newsgroup(s).