DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] regex/mlx5: utilize all available QPs
@ 2023-02-21  7:47 Gerry Gribbon
  2023-03-10 18:02 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Gerry Gribbon @ 2023-02-21  7:47 UTC (permalink / raw)
  To: dev; +Cc: stable, Ori Kam

Fix overflow of free QP mask.
Regex used 64 QPs and used a bitmask to select a free QP for use.
The bitmask in use was only 32 bits so did not allow half of the QPs
to be utilised.
Upgraded to 64 bit mask and using ffsll now instead of ffs.

Fixes: 270032608503 ("regex/mlx5: refactor HW queue objects")
Cc: stable@dpdk.org

Signed-off-by: Gerry Gribbon <ggribbon@nvidia.com>
---
 drivers/regex/mlx5/mlx5_regex.h          |  2 +-
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h
index b8554fd1cf..481f6fc59f 100644
--- a/drivers/regex/mlx5/mlx5_regex.h
+++ b/drivers/regex/mlx5/mlx5_regex.h
@@ -37,7 +37,7 @@ struct mlx5_regex_qp {
 	struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
 	uint16_t nb_obj; /* Number of qp objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
-	uint32_t free_qps;
+	uint64_t free_qps;
 	struct mlx5_regex_job *jobs;
 	struct ibv_mr *metadata;
 	struct ibv_mr *outputs;
diff --git a/drivers/regex/mlx5/mlx5_regex_fastpath.c b/drivers/regex/mlx5/mlx5_regex_fastpath.c
index 143c7d7cdf..6c87afa923 100644
--- a/drivers/regex/mlx5/mlx5_regex_fastpath.c
+++ b/drivers/regex/mlx5/mlx5_regex_fastpath.c
@@ -417,7 +417,7 @@ mlx5_regexdev_enqueue_gga(struct rte_regexdev *dev, uint16_t qp_id,
 		return 0;
 #endif
 
-	while ((hw_qpid = ffs(queue->free_qps))) {
+	while ((hw_qpid = ffsll(queue->free_qps))) {
 		hw_qpid--; /* ffs returns 1 for bit 0 */
 		qp_obj = &queue->qps[hw_qpid];
 		nb_desc = get_free(qp_obj, priv->has_umr);
@@ -426,7 +426,7 @@ mlx5_regexdev_enqueue_gga(struct rte_regexdev *dev, uint16_t qp_id,
 			if (nb_desc > nb_left)
 				nb_desc = nb_left;
 			else
-				queue->free_qps &= ~(1 << hw_qpid);
+				queue->free_qps &= ~(1ULL << hw_qpid);
 			prep_regex_umr_wqe_set(priv, queue, qp_obj, ops,
 				nb_desc);
 			send_doorbell(priv, qp_obj);
@@ -456,7 +456,7 @@ mlx5_regexdev_enqueue(struct rte_regexdev *dev, uint16_t qp_id,
 		return 0;
 #endif
 
-	while ((hw_qpid = ffs(queue->free_qps))) {
+	while ((hw_qpid = ffsll(queue->free_qps))) {
 		hw_qpid--; /* ffs returns 1 for bit 0 */
 		qp_obj = &queue->qps[hw_qpid];
 		while (get_free(qp_obj, priv->has_umr)) {
@@ -470,7 +470,7 @@ mlx5_regexdev_enqueue(struct rte_regexdev *dev, uint16_t qp_id,
 				goto out;
 			}
 		}
-		queue->free_qps &= ~(1 << hw_qpid);
+		queue->free_qps &= ~(1ULL << hw_qpid);
 		send_doorbell(priv, qp_obj);
 	}
 
@@ -603,7 +603,7 @@ mlx5_regexdev_dequeue(struct rte_regexdev *dev, uint16_t qp_id,
 		cq->ci = (cq->ci + 1) & 0xffffff;
 		rte_wmb();
 		cq->cq_obj.db_rec[0] = rte_cpu_to_be_32(cq->ci);
-		queue->free_qps |= (1 << hw_qpid);
+		queue->free_qps |= (1ULL << hw_qpid);
 	}
 
 out:
@@ -642,7 +642,7 @@ setup_qps(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *queue)
 				     (uintptr_t)job->output);
 			wqe += 64;
 		}
-		queue->free_qps |= 1 << hw_qpid;
+		queue->free_qps |= 1ULL << hw_qpid;
 	}
 }
 
-- 
2.25.1


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

* Re: [PATCH] regex/mlx5: utilize all available QPs
  2023-02-21  7:47 [PATCH] regex/mlx5: utilize all available QPs Gerry Gribbon
@ 2023-03-10 18:02 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2023-03-10 18:02 UTC (permalink / raw)
  To: Gerry Gribbon; +Cc: dev, stable, Ori Kam

21/02/2023 08:47, Gerry Gribbon:
> Fix overflow of free QP mask.
> Regex used 64 QPs and used a bitmask to select a free QP for use.
> The bitmask in use was only 32 bits so did not allow half of the QPs
> to be utilised.
> Upgraded to 64 bit mask and using ffsll now instead of ffs.
> 
> Fixes: 270032608503 ("regex/mlx5: refactor HW queue objects")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gerry Gribbon <ggribbon@nvidia.com>

Applied, thanks.




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

end of thread, other threads:[~2023-03-10 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21  7:47 [PATCH] regex/mlx5: utilize all available QPs Gerry Gribbon
2023-03-10 18:02 ` Thomas Monjalon

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