From: Anoob Joseph Date: Fri, 17 Dec 2021 09:20:01 +0000 (+0530) Subject: crypto/cnxk: fix inflight count calculation X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ec6ca0536e912d465a47d28ab90994d9ca576234;p=dpdk.git crypto/cnxk: fix inflight count calculation Inflight count calculation is updated to cover wrap around cases where head can become smaller than tail. Fixes: fd390896f4a3 ("crypto/cnxk: allow different cores in pending queue") Cc: stable@dpdk.org Reported-by: Kiran Kumar K Signed-off-by: Anoob Joseph Acked-by: Akhil Goyal --- diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h index ca363bba3a..0336ae102e 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h @@ -156,7 +156,11 @@ pending_queue_retreat(uint64_t *index, const uint64_t mask, uint64_t nb_entry) static __rte_always_inline uint64_t pending_queue_infl_cnt(uint64_t head, uint64_t tail, const uint64_t mask) { - return (head - tail) & mask; + /* + * Mask is nb_desc - 1. Add nb_desc to head and mask to account for + * cases when tail > head, which happens during wrap around. + */ + return ((head + mask + 1) - tail) & mask; } static __rte_always_inline uint64_t