From: Yuval Avnery Date: Wed, 29 Jul 2020 02:14:51 +0000 (+0000) Subject: regex/mlx5: fix overrun on enqueueing X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=76e821a303fd566c937f8e60c03a4f5803cc00ed 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: 4d4e245ad637 ("regex/mlx5: support enqueue") Signed-off-by: Yuval Avnery Acked-by: Ori Kam --- diff --git a/drivers/regex/mlx5/mlx5_regex_fastpath.c b/drivers/regex/mlx5/mlx5_regex_fastpath.c index d8af2bf96e..2c6c9e15a4 100644 --- a/drivers/regex/mlx5/mlx5_regex_fastpath.c +++ b/drivers/regex/mlx5/mlx5_regex_fastpath.c @@ -145,10 +145,7 @@ send_doorbell(struct mlx5dv_devx_uar *uar, struct mlx5_regex_sq *sq) 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