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>, Yevgeny Kliteynik <kliteyn@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 27/34] net/mlx5/hws: bwc - make burst threshold dynamic
Date: Mon, 3 Jun 2024 11:25:55 +0300	[thread overview]
Message-ID: <20240603082601.4173-2-mkashani@nvidia.com> (raw)
In-Reply-To: <20240603082601.4173-1-mkashani@nvidia.com>

From: Yevgeny Kliteynik <kliteyn@nvidia.com>

BWC rules rehash process has burst threshold, where the rule
requires completion. This threshold was constant number, and
it can cause rehash fail if this threshold is actually bigger
than the queue size - the queue would end up full.
This patch fixes the threshold to be dynamic and to take into
consideration queue size.

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_bwc.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_bwc.c b/drivers/net/mlx5/hws/mlx5dr_bwc.c
index eef3053ee0..bfc7dbf100 100644
--- a/drivers/net/mlx5/hws/mlx5dr_bwc.c
+++ b/drivers/net/mlx5/hws/mlx5dr_bwc.c
@@ -22,6 +22,13 @@ mlx5dr_bwc_get_queue_id(struct mlx5dr_context *ctx, uint16_t idx)
 	return idx + mlx5dr_bwc_queues(ctx);
 }
 
+static uint16_t
+mlx5dr_bwc_get_burst_th(struct mlx5dr_context *ctx, uint16_t queue_id)
+{
+	return RTE_MIN(ctx->send_queue[queue_id].num_entries / 2,
+		       MLX5DR_BWC_MATCHER_REHASH_BURST_TH);
+}
+
 static rte_spinlock_t *
 mlx5dr_bwc_get_queue_lock(struct mlx5dr_context *ctx, uint16_t idx)
 {
@@ -175,8 +182,9 @@ mlx5dr_bwc_queue_poll(struct mlx5dr_context *ctx,
 		      bool drain)
 {
 	bool queue_full = *pending_rules == MLX5DR_BWC_MATCHER_REHASH_QUEUE_SZ;
-	bool got_comp = *pending_rules >= MLX5DR_BWC_MATCHER_REHASH_BURST_TH;
 	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;
 	int ret;
 	int i;
 
@@ -185,8 +193,7 @@ mlx5dr_bwc_queue_poll(struct mlx5dr_context *ctx,
 		return 0;
 
 	while (queue_full || ((got_comp || drain) && *pending_rules)) {
-		ret = mlx5dr_send_queue_poll(ctx, queue_id, comp,
-					     MLX5DR_BWC_MATCHER_REHASH_BURST_TH);
+		ret = mlx5dr_send_queue_poll(ctx, queue_id, comp, burst_th);
 		if (unlikely(ret < 0)) {
 			DR_LOG(ERR, "Rehash error: polling queue %d returned %d\n",
 			       queue_id, ret);
@@ -583,6 +590,7 @@ mlx5dr_bwc_matcher_move_all(struct mlx5dr_bwc_matcher *bwc_matcher)
 	struct mlx5dr_bwc_rule **bwc_rules;
 	struct mlx5dr_rule_attr rule_attr;
 	uint32_t *pending_rules;
+	uint16_t burst_th;
 	bool all_done;
 	int i, j, ret;
 
@@ -617,9 +625,10 @@ mlx5dr_bwc_matcher_move_all(struct mlx5dr_bwc_matcher *bwc_matcher)
 
 		for (i = 0; i < bwc_queues; i++) {
 			rule_attr.queue_id = mlx5dr_bwc_get_queue_id(ctx, i);
+			burst_th = mlx5dr_bwc_get_burst_th(ctx, rule_attr.queue_id);
 
-			for (j = 0; j < MLX5DR_BWC_MATCHER_REHASH_BURST_TH && bwc_rules[i]; j++) {
-				rule_attr.burst = !!((j + 1) % MLX5DR_BWC_MATCHER_REHASH_BURST_TH);
+			for (j = 0; j < burst_th && bwc_rules[i]; j++) {
+				rule_attr.burst = !!((j + 1) % burst_th);
 				ret = mlx5dr_matcher_resize_rule_move(bwc_matcher->matcher,
 								      bwc_rules[i]->rule,
 								      &rule_attr);
-- 
2.25.1


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

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-02 10:29 [PATCH 1/7] net/mlx5/hws: fix bug in matcher disconnect error flow Maayan Kashani
2024-06-03  8:25 ` [PATCH v2 26/34] " Maayan Kashani
2024-06-03  8:25   ` Maayan Kashani [this message]
2024-06-03  8:25   ` [PATCH v2 28/34] net/mlx5/hws: bwc - adding rules with larger action template Maayan Kashani
2024-06-03  8:25   ` [PATCH v2 29/34] net/mlx5/hws: bwc - abort rehash on completion with error Maayan Kashani
2024-06-03  8:25   ` [PATCH v2 30/34] net/mlx5/hws: bwc - go through all the resized matchers Maayan Kashani
2024-06-03  8:25   ` [PATCH v2 31/34] net/mlx5/hws: bwc - reorg rule resize struct Maayan Kashani
2024-06-03  8:26   ` [PATCH v2 32/34] net/mlx5/hws: bwc - fix deleting action stes Maayan Kashani
2024-06-03 10:56 ` [PATCH v3 1/7] net/mlx5/hws: fix bug in matcher disconnect error flow Maayan Kashani
2024-06-03 10:56   ` [PATCH v3 2/7] net/mlx5/hws: bwc - make burst threshold dynamic Maayan Kashani
2024-06-03 10:56   ` [PATCH v3 3/7] net/mlx5/hws: bwc - adding rules with larger action template Maayan Kashani
2024-06-03 10:56   ` [PATCH v3 4/7] net/mlx5/hws: bwc - abort rehash on completion with error Maayan Kashani
2024-06-03 10:56   ` [PATCH v3 5/7] net/mlx5/hws: bwc - go through all the resized matchers Maayan Kashani
2024-06-03 10:56   ` [PATCH v3 6/7] net/mlx5/hws: bwc - reorg rule resize struct Maayan Kashani
2024-06-03 10:56   ` [PATCH v3 7/7] net/mlx5/hws: bwc - fix deleting action stes Maayan Kashani
2024-06-06  9:55   ` [PATCH v4 0/7] HWS non-template fixes Maayan Kashani
2024-06-06  9:55     ` [PATCH v4 1/7] net/mlx5/hws: fix bug in matcher disconnect error flow Maayan Kashani
2024-06-06  9:55     ` [PATCH v4 2/7] net/mlx5/hws: bwc - make burst threshold dynamic Maayan Kashani
2024-06-06  9:55     ` [PATCH v4 3/7] net/mlx5/hws: bwc - adding rules with larger action template Maayan Kashani
2024-06-06  9:55     ` [PATCH v4 4/7] net/mlx5/hws: bwc - abort rehash on completion with error Maayan Kashani
2024-06-06  9:55     ` [PATCH v4 5/7] net/mlx5/hws: bwc - go through all the resized matchers Maayan Kashani
2024-06-06  9:55     ` [PATCH v4 6/7] net/mlx5/hws: bwc - reorg rule resize struct Maayan Kashani
2024-06-06  9:55     ` [PATCH v4 7/7] net/mlx5/hws: bwc - fix deleting action stes Maayan Kashani
2024-06-11 11:18     ` [PATCH v4 0/7] HWS non-template fixes 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=20240603082601.4173-2-mkashani@nvidia.com \
    --to=mkashani@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=kliteyn@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).