Hi,
On 8/20/22 04:31, Hernan Vargas wrote:
Refactor of the queue availability computation to prevent the
application to dequeue more than what may have been enqueued.
That sounds like a fix, is it?
If so, it should have the Fixes tag, so that existing application can
get the fix without having to upgrade to a newer DPDK version that may
have introduced API/ABI changes.
Signed-off-by: Hernan Vargas <hernan.var...@intel.com>
---
drivers/baseband/acc100/rte_acc100_pmd.c | 39 ++++++++++++++++--------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/drivers/baseband/acc100/rte_acc100_pmd.c
b/drivers/baseband/acc100/rte_acc100_pmd.c
index 7f698ec3d2..0598d33582 100644
--- a/drivers/baseband/acc100/rte_acc100_pmd.c
+++ b/drivers/baseband/acc100/rte_acc100_pmd.c
@@ -3465,13 +3465,27 @@ acc100_enqueue_queue_full(struct rte_bbdev_queue_data
*q_data)
acc100_enqueue_status(q_data, RTE_BBDEV_ENQ_STATUS_QUEUE_FULL);
}
+/* Number of available descriptor in ring to enqueue */
s/descriptor/descriptors/
+static uint32_t
+acc100_ring_avail_enq(struct acc100_queue *q)
+{
+ return (q->sw_ring_depth - 1 + q->sw_ring_tail - q->sw_ring_head) %
q->sw_ring_depth;
+}
+
+/* Number of available descriptor in ring to dequeue */
s/descriptor/descriptors/
+static uint32_t
+acc100_ring_avail_deq(struct acc100_queue *q)
+{
+ return (q->sw_ring_depth + q->sw_ring_head - q->sw_ring_tail) %
q->sw_ring_depth;
+}
+
/* Enqueue encode operations for ACC100 device in CB mode. */
static uint16_t
acc100_enqueue_enc_cb(struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_enc_op **ops, uint16_t num)
{
struct acc100_queue *q = q_data->queue_private;
- int32_t avail = q->sw_ring_depth + q->sw_ring_tail - q->sw_ring_head;
+ int32_t avail = acc100_ring_avail_enq(q);
acc100_ring_avail_enq returns an uint32_t, but avail is an int32_t.
I think avail should be a uint32_t and underflow check should be changed to:
if (unlikely(avail == 0)) {
Same comment applies in other places.
Maxime