DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/4] non-template fixes set
@ 2024-07-23  8:15 Bing Zhao
  2024-07-23  8:15 ` [PATCH 1/4] net/mlx5/hws: fix state detection of queue full in polling Bing Zhao
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Bing Zhao @ 2024-07-23  8:15 UTC (permalink / raw)
  To: dsosnowski, viacheslavo, dev, rasland; +Cc: orika, suanmingm, matan

A set for cumulative fixes of non-template API support.

Bing Zhao (4):
  net/mlx5/hws: fix state detection of queue full in polling
  net/mlx5: fix releasing order of compatible matcher
  net/mlx5: fix matcher mask translation
  net/mlx5: fix log error on non-template rule destroy

 drivers/net/mlx5/hws/mlx5dr_bwc.c |  4 +++-
 drivers/net/mlx5/hws/mlx5dr_bwc.h |  1 -
 drivers/net/mlx5/mlx5_flow_dv.c   |  1 +
 drivers/net/mlx5/mlx5_flow_hw.c   | 37 +++++++++++--------------------
 4 files changed, 17 insertions(+), 26 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] net/mlx5/hws: fix state detection of queue full in polling
  2024-07-23  8:15 [PATCH 0/4] non-template fixes set Bing Zhao
@ 2024-07-23  8:15 ` Bing Zhao
  2024-07-23  8:15 ` [PATCH 2/4] net/mlx5: fix releasing order of compatible matcher Bing Zhao
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bing Zhao @ 2024-07-23  8:15 UTC (permalink / raw)
  To: dsosnowski, viacheslavo, dev, rasland
  Cc: orika, suanmingm, matan, Yevgeny Kliteynik

The sending queue (SQ) size of BWC API is not fixed and the same as
that of other HWS rule insertion SQs. When checking the queue full
state, the number of queue entries and the used entries should be
used instead of the macro "MLX5DR_BWC_MATCHER_REHASH_QUEUE_SZ".

Or else, when resizing the matcher and moving the rules, sometimes
it would fail incorrectly. For example, once a hiccup of generating
CQE happened, the polling of CQ exited directly without any retry.
Then there was no enough room for the next rule to be moved.

Using the correct state of a SQ will solve this issue, the polling
of associative CQ will continue until a new CQE is generated.

Fixes: 87026d2e6601 ("net/mlx5/hws: support backward-compatible API")

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_bwc.c | 4 +++-
 drivers/net/mlx5/hws/mlx5dr_bwc.h | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_bwc.c b/drivers/net/mlx5/hws/mlx5dr_bwc.c
index e0b6390ed9..9233452118 100644
--- a/drivers/net/mlx5/hws/mlx5dr_bwc.c
+++ b/drivers/net/mlx5/hws/mlx5dr_bwc.c
@@ -181,10 +181,10 @@ mlx5dr_bwc_queue_poll(struct mlx5dr_context *ctx,
 		      uint32_t *pending_rules,
 		      bool drain)
 {
-	bool queue_full = *pending_rules == MLX5DR_BWC_MATCHER_REHASH_QUEUE_SZ;
 	struct rte_flow_op_result comp[MLX5DR_BWC_MATCHER_REHASH_BURST_TH];
 	uint16_t burst_th = mlx5dr_bwc_get_burst_th(ctx, queue_id);
 	bool got_comp = *pending_rules >= burst_th;
+	bool queue_full;
 	int err = 0;
 	int ret;
 	int i;
@@ -193,6 +193,8 @@ mlx5dr_bwc_queue_poll(struct mlx5dr_context *ctx,
 	if (!got_comp && !drain)
 		return 0;
 
+	/* The FULL state of a SQ is always a subcondition of the original 'got_comp'. */
+	queue_full = mlx5dr_send_engine_full(&ctx->send_queue[queue_id]);
 	while (queue_full || ((got_comp || drain) && *pending_rules)) {
 		ret = mlx5dr_send_queue_poll(ctx, queue_id, comp, burst_th);
 		if (unlikely(ret < 0)) {
diff --git a/drivers/net/mlx5/hws/mlx5dr_bwc.h b/drivers/net/mlx5/hws/mlx5dr_bwc.h
index 648443861b..8c3f721ac2 100644
--- a/drivers/net/mlx5/hws/mlx5dr_bwc.h
+++ b/drivers/net/mlx5/hws/mlx5dr_bwc.h
@@ -9,7 +9,6 @@
 #define MLX5DR_BWC_MATCHER_SIZE_LOG_STEP 1
 #define MLX5DR_BWC_MATCHER_REHASH_PERCENT_TH 70
 #define MLX5DR_BWC_MATCHER_REHASH_BURST_TH 32
-#define MLX5DR_BWC_MATCHER_REHASH_QUEUE_SZ 256
 #define MLX5DR_BWC_MATCHER_ATTACH_AT_NUM 255
 
 struct mlx5dr_bwc_matcher {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/4] net/mlx5: fix releasing order of compatible matcher
  2024-07-23  8:15 [PATCH 0/4] non-template fixes set Bing Zhao
  2024-07-23  8:15 ` [PATCH 1/4] net/mlx5/hws: fix state detection of queue full in polling Bing Zhao
@ 2024-07-23  8:15 ` Bing Zhao
  2024-07-23  8:15 ` [PATCH 3/4] net/mlx5: fix matcher mask translation Bing Zhao
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bing Zhao @ 2024-07-23  8:15 UTC (permalink / raw)
  To: dsosnowski, viacheslavo, dev, rasland
  Cc: orika, suanmingm, matan, Maayan Kashani

The matchers are created and organized in groups, and the groups are
managed by a hash list in shared object.

The creation order:
  1. If no group, create the group and register it into the
     hash list. And create the list to save matchers.
  2. If no matcher is found, register the matcher and increase the
     reference count of group.
  3. If the matcher exists and can be reused, increase the reference
     counts of its group and itself.

When dereferencing a matcher, the orders should be reversed.
  1. Dereference the matcher and release it when not being used.
  2. Dereference the group and release it when not being used.

When the last flow rule on some group was trying to be destroyed,
the matcher resource would also be freed in group dereference stage.
The `group` information should be saved locally to get rid of the
UAF issue in both stages.

Coverity issue: 426423

Fixes: b2845d51c748 ("net/mlx5: support FDB in non-template flow")

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index d243b59b71..470919fe8a 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -13471,22 +13471,16 @@ 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;
+	struct mlx5_flow_group *group = matcher->group;
+	int ret = 0;
 
-	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;
-		}
+	if (group) {
+		if (matcher->matcher_object)
+			ret |= mlx5_list_unregister(group->matchers, &matcher->entry);
+		ret |= mlx5_hlist_unregister(priv->sh->groups, &group->entry);
 	}
-	return 0;
-error:
-	return -EINVAL;
+	return ret;
 }
 
 static int flow_hw_register_matcher(struct rte_eth_dev *dev,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/4] net/mlx5: fix matcher mask translation
  2024-07-23  8:15 [PATCH 0/4] non-template fixes set Bing Zhao
  2024-07-23  8:15 ` [PATCH 1/4] net/mlx5/hws: fix state detection of queue full in polling Bing Zhao
  2024-07-23  8:15 ` [PATCH 2/4] net/mlx5: fix releasing order of compatible matcher Bing Zhao
@ 2024-07-23  8:15 ` Bing Zhao
  2024-07-23  8:15 ` [PATCH 4/4] net/mlx5: fix log error on non-template rule destroy Bing Zhao
  2024-08-29  8:59 ` [PATCH 0/4] non-template fixes set Raslan Darawsheh
  4 siblings, 0 replies; 6+ messages in thread
From: Bing Zhao @ 2024-07-23  8:15 UTC (permalink / raw)
  To: dsosnowski, viacheslavo, dev, rasland; +Cc: orika, suanmingm, matan

In non-template API implementation on HWS, the matcher mask is
translated using DV item translation. This is used to find and
reuse the same matcher in the PMD for rules insertion when possible.

The flags calculated previously for items should not be passed to
avoid incorrectly recognizing the layers. In the meanwhile, unlike
in template API, the group information is also needed for the mask
translation.

Fixes: 27d171b88031 ("net/mlx5: abstract flow action and enable reconfigure")

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 1 +
 drivers/net/mlx5/mlx5_flow_hw.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 89057edbcf..a51d4dd1a4 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -14538,6 +14538,7 @@ __flow_dv_translate_items_hws(const struct rte_flow_item *items,
 		.next_protocol = 0xff,
 		.attr = &rattr,
 		.rss_desc = &rss_desc,
+		.group = attr->group,
 	};
 	int ret = 0;
 
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 470919fe8a..46f6665846 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -13682,7 +13682,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,
 		.rss_level = 0,
 		.act_flags = action_flags,
 		.tbl_type = 0,
-		};
+	};
 
 	memset(&hw_act, 0, sizeof(hw_act));
 	if (attr->transfer)
@@ -13702,7 +13702,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,
 	(*flow)->nt_rule = true;
 	(*flow)->nt2hws->matcher = &matcher;
 	ret = flow_dv_translate_items_hws(items, &flow_attr, &matcher.mask.buf,
-					MLX5_SET_MATCHER_HS_M, &item_flags,
+					MLX5_SET_MATCHER_HS_M, NULL,
 					NULL, error);
 
 	if (ret)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/4] net/mlx5: fix log error on non-template rule destroy
  2024-07-23  8:15 [PATCH 0/4] non-template fixes set Bing Zhao
                   ` (2 preceding siblings ...)
  2024-07-23  8:15 ` [PATCH 3/4] net/mlx5: fix matcher mask translation Bing Zhao
@ 2024-07-23  8:15 ` Bing Zhao
  2024-08-29  8:59 ` [PATCH 0/4] non-template fixes set Raslan Darawsheh
  4 siblings, 0 replies; 6+ messages in thread
From: Bing Zhao @ 2024-07-23  8:15 UTC (permalink / raw)
  To: dsosnowski, viacheslavo, dev, rasland
  Cc: orika, suanmingm, matan, Maayan Kashani

Log error message is raised on port stop when using same encap
action with two different rules.

It is a false alarm, checking return value not equals zero from
hlist unregister function was wrong since it returns 1 if the object
is still referenced.

Remove the check for return value for encap, decap, modify header and
matcher resource release under flow destroy cause all uses list/hlist
with return value 0/1.

Fixes: ff4064d5b1fe ("net/mlx5: support bulk actions in non-template flow")

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Signed-off-by: Bing Zhao <bingz@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 46f6665846..8a59d3c013 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -13792,17 +13792,12 @@ flow_hw_destroy(struct rte_eth_dev *dev, struct rte_flow_hw *flow)
 	if (flow->nt2hws->flow_aux)
 		mlx5_free(flow->nt2hws->flow_aux);
 
-	if (flow->nt2hws->rix_encap_decap) {
-		ret = flow_encap_decap_resource_release(dev, flow->nt2hws->rix_encap_decap);
-		if (ret)
-			DRV_LOG(ERR, "failed to release encap decap.");
-	}
+	if (flow->nt2hws->rix_encap_decap)
+		flow_encap_decap_resource_release(dev, flow->nt2hws->rix_encap_decap);
 	if (flow->nt2hws->modify_hdr) {
 		MLX5_ASSERT(flow->nt2hws->modify_hdr->action);
-		ret = mlx5_hlist_unregister(priv->sh->modify_cmds,
-			&flow->nt2hws->modify_hdr->entry);
-		if (ret)
-			DRV_LOG(ERR, "failed to release modify action.");
+		mlx5_hlist_unregister(priv->sh->modify_cmds,
+				      &flow->nt2hws->modify_hdr->entry);
 	}
 	if (flow->nt2hws->matcher)
 		flow_hw_unregister_matcher(dev, flow->nt2hws->matcher);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] non-template fixes set
  2024-07-23  8:15 [PATCH 0/4] non-template fixes set Bing Zhao
                   ` (3 preceding siblings ...)
  2024-07-23  8:15 ` [PATCH 4/4] net/mlx5: fix log error on non-template rule destroy Bing Zhao
@ 2024-08-29  8:59 ` Raslan Darawsheh
  4 siblings, 0 replies; 6+ messages in thread
From: Raslan Darawsheh @ 2024-08-29  8:59 UTC (permalink / raw)
  To: Bing Zhao, Dariusz Sosnowski, Slava Ovsiienko, dev
  Cc: Ori Kam, Suanming Mou, Matan Azrad

Hi,

From: Bing Zhao <bingz@nvidia.com>
Sent: Tuesday, July 23, 2024 11:15 AM
To: Dariusz Sosnowski; Slava Ovsiienko; dev@dpdk.org; Raslan Darawsheh
Cc: Ori Kam; Suanming Mou; Matan Azrad
Subject: [PATCH 0/4] non-template fixes set

A set for cumulative fixes of non-template API support.

Bing Zhao (4):
  net/mlx5/hws: fix state detection of queue full in polling
  net/mlx5: fix releasing order of compatible matcher
  net/mlx5: fix matcher mask translation
  net/mlx5: fix log error on non-template rule destroy

 drivers/net/mlx5/hws/mlx5dr_bwc.c |  4 +++-
 drivers/net/mlx5/hws/mlx5dr_bwc.h |  1 -
 drivers/net/mlx5/mlx5_flow_dv.c   |  1 +
 drivers/net/mlx5/mlx5_flow_hw.c   | 37 +++++++++++--------------------
 4 files changed, 17 insertions(+), 26 deletions(-)

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-29  8:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-23  8:15 [PATCH 0/4] non-template fixes set Bing Zhao
2024-07-23  8:15 ` [PATCH 1/4] net/mlx5/hws: fix state detection of queue full in polling Bing Zhao
2024-07-23  8:15 ` [PATCH 2/4] net/mlx5: fix releasing order of compatible matcher Bing Zhao
2024-07-23  8:15 ` [PATCH 3/4] net/mlx5: fix matcher mask translation Bing Zhao
2024-07-23  8:15 ` [PATCH 4/4] net/mlx5: fix log error on non-template rule destroy Bing Zhao
2024-08-29  8:59 ` [PATCH 0/4] non-template fixes set Raslan Darawsheh

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).