DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <dsosnowski@nvidia.com>,
	<rasland@nvidia.com>, Gregory Etelson <getelson@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Subject: [PATCH v2 21/34] net/mlx5: support FDB in non-template mode
Date: Mon, 3 Jun 2024 11:10:42 +0300	[thread overview]
Message-ID: <20240603081042.3109-6-mkashani@nvidia.com> (raw)
In-Reply-To: <20240603081042.3109-1-mkashani@nvidia.com>

From: Gregory Etelson <getelson@nvidia.com>

Support non-template flows API in FDB mode:

dpdk-testpmd -a $PCI,dv_flow_en=2,representor=vf0-1 -- -i

testpmd> flow create 0 group 0 transfer \
              pattern eth / end \
              actions count / drop / end

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 46 +++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 66e0b46f9b..43bcaab592 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -12614,6 +12614,28 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev,
 	return ret;
 }
 
+static int
+flow_hw_unregister_matcher(struct rte_eth_dev *dev,
+			   struct mlx5_flow_dv_matcher *matcher)
+{
+	int ret;
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	if (matcher->matcher_object) {
+		ret = mlx5_hlist_unregister(priv->sh->groups, &matcher->group->entry);
+		if (ret)
+			goto error;
+		if (matcher->group) {
+			ret = mlx5_list_unregister(matcher->group->matchers, &matcher->entry);
+			if (ret)
+				goto error;
+		}
+	}
+	return 0;
+error:
+	return -EINVAL;
+}
+
 static int flow_hw_register_matcher(struct rte_eth_dev *dev,
 				    const struct rte_flow_attr *attr,
 				    const struct rte_flow_item items[],
@@ -12640,24 +12662,23 @@ static int flow_hw_register_matcher(struct rte_eth_dev *dev,
 		.data = matcher,
 		.data2 = items_ptr,
 	};
-	struct mlx5_list_entry *group_entry;
-	struct mlx5_list_entry *matcher_entry;
+	struct mlx5_list_entry *group_entry = NULL;
+	struct mlx5_list_entry *matcher_entry = NULL;
 	struct mlx5_flow_dv_matcher *resource;
 	struct mlx5_list *matchers_list;
 	struct mlx5_flow_group *flow_group;
-	uint32_t group = 0;
 	int ret;
 
 
 	matcher->crc = rte_raw_cksum((const void *)matcher->mask.buf,
 				    matcher->mask.size);
 	matcher->priority = attr->priority;
-	ret = __translate_group(dev, attr, external, attr->group, &group, error);
+	ret = __translate_group(dev, attr, external, attr->group, &flow_attr.group, error);
 	if (ret)
 		return ret;
 
 	/* Register the flow group. */
-	group_entry = mlx5_hlist_register(priv->sh->groups, group, &ctx);
+	group_entry = mlx5_hlist_register(priv->sh->groups, flow_attr.group, &ctx);
 	if (!group_entry)
 		goto error;
 	flow_group = container_of(group_entry, struct mlx5_flow_group, entry);
@@ -12668,15 +12689,16 @@ static int flow_hw_register_matcher(struct rte_eth_dev *dev,
 	if (!matcher_entry)
 		goto error;
 	resource = container_of(matcher_entry, typeof(*resource), entry);
-	if (!resource)
-		goto error;
 	flow->nt2hws->matcher = resource;
 	return 0;
 
 error:
-	if (error)
+	if (group_entry)
+		mlx5_hlist_unregister(priv->sh->groups, group_entry);
+	if (error) {
 		if (sub_error.type != RTE_FLOW_ERROR_TYPE_NONE)
 			rte_memcpy(error, &sub_error, sizeof(sub_error));
+	}
 	return rte_flow_error_set(error, ENOMEM,
 					RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
 					NULL, "fail to register matcher");
@@ -12899,6 +12921,12 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,
 		mlx5_free(hw_act.push_remove);
 	if (hw_act.mhdr)
 		mlx5_free(hw_act.mhdr);
+	if (ret) {
+		/* release after actual error */
+		if ((*flow)->nt2hws && (*flow)->nt2hws->matcher)
+			flow_hw_unregister_matcher(dev,
+						   (*flow)->nt2hws->matcher);
+	}
 	return ret;
 }
 #endif
@@ -12945,6 +12973,8 @@ flow_hw_destroy(struct rte_eth_dev *dev, struct rte_flow_hw *flow)
 		if (ret)
 			DRV_LOG(ERR, "failed to release modify action.");
 	}
+	if (flow->nt2hws->matcher)
+		flow_hw_unregister_matcher(dev, flow->nt2hws->matcher);
 }
 
 #ifdef HAVE_MLX5_HWS_SUPPORT
-- 
2.25.1


  parent reply	other threads:[~2024-06-03  8:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-02 10:28 [PATCH 1/6] net/mlx5: update NTA rule pattern and actions flags Maayan Kashani
2024-06-03  8:10 ` [PATCH v2 16/34] " Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 17/34] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 18/34] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 19/34] net/mlx5: update ASO resources " Maayan Kashani
2024-06-03  8:10   ` [PATCH v2 20/34] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-03  8:10   ` Maayan Kashani [this message]
2024-06-03 10:52 ` [PATCH v3 1/6] net/mlx5: update NTA rule pattern and actions flags Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 2/6] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 3/6] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 4/6] net/mlx5: update ASO resources " Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 5/6] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-03 10:52   ` [PATCH v3 6/6] net/mlx5: support FDB in non-template mode Maayan Kashani
2024-06-06 10:12   ` [PATCH v4 0/6] non-template pmd advanced Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 1/6] net/mlx5: update NTA rule pattern and actions flags Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 2/6] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 3/6] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 4/6] net/mlx5: update ASO resources " Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 5/6] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-06 10:12     ` [PATCH v4 6/6] net/mlx5: support FDB in non-template mode Maayan Kashani
2024-06-10  8:50     ` [PATCH v5 1/6] net/mlx5: update NTA rule pattern and actions flags Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 2/6] net/mlx5: support RSS expansion in non-template HWS setup Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 3/6] net/mlx5: support indirect actions in non-template setup Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 4/6] net/mlx5: update ASO resources " Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 5/6] net/mlx5: update HWS ASO actions validation Maayan Kashani
2024-06-10  8:50       ` [PATCH v5 6/6] net/mlx5: support FDB in non-template mode Maayan Kashani
2024-06-11 11:20       ` [PATCH v5 1/6] net/mlx5: update NTA rule pattern and actions flags 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=20240603081042.3109-6-mkashani@nvidia.com \
    --to=mkashani@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=getelson@nvidia.com \
    --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;
as well as URLs for NNTP newsgroup(s).