[v2] regex/mlx5: fix sq free check on enqueue

Message ID 1595988891-151622-1-git-send-email-yuvalav@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] regex/mlx5: fix sq free check on enqueue |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Yuval Avnery July 29, 2020, 2:14 a.m. UTC
  Free sq check had a bug, causing jobs to overwrite.

Fixes: 8740ba5fe57f ("regex/mlx5: add enqueue implementation")
Signed-off-by: Yuval Avnery <yuvalav@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
---
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
  

Comments

Thomas Monjalon July 29, 2020, 2:51 p.m. UTC | #1
29/07/2020 04:14, Yuval Avnery:
> Free sq check had a bug, causing jobs to overwrite.

Reworded with Ori's help:

    regex/mlx5: fix overrun on enqueueing
    
    When enqueueing a buffer the PMD check if there is room
    in its send queue (SQ).
    The current implementation did not take into account that
    queue indices are wrapping around, which may result in
    consumer index (sq->ci) can have bigger value than than
    the producer index (sq->pi).

> 
> Fixes: 8740ba5fe57f ("regex/mlx5: add enqueue implementation")

Fixes: 4d4e245ad637 ("regex/mlx5: support enqueue")

> Signed-off-by: Yuval Avnery <yuvalav@mellanox.com>
> Acked-by: Ori Kam <orika@mellanox.com>

Applied, thanks
  

Patch

diff --git a/drivers/regex/mlx5/mlx5_regex_fastpath.c b/drivers/regex/mlx5/mlx5_regex_fastpath.c
index fc5a7fc..4385d85 100644
--- a/drivers/regex/mlx5/mlx5_regex_fastpath.c
+++ b/drivers/regex/mlx5/mlx5_regex_fastpath.c
@@ -152,10 +152,7 @@  struct mlx5_regex_job {
 
 static inline int
 can_send(struct mlx5_regex_sq *sq) {
-	return unlikely(sq->ci > sq->pi) ?
-			MLX5_REGEX_MAX_WQE_INDEX + sq->pi - sq->ci <
-			sq_size_get(sq) :
-			sq->pi - sq->ci < sq_size_get(sq);
+	return ((uint16_t)(sq->pi - sq->ci) < sq_size_get(sq));
 }
 
 static inline uint32_t