DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nicolas Chautru <nicolas.chautru@intel.com>
To: dev@dpdk.org, maxime.coquelin@redhat.com
Cc: hernan.vargas@intel.com, stable@dpdk.org,
	Nicolas Chautru <nicolas.chautru@intel.com>
Subject: [PATCH v2 4/9] baseband/acc: prevent to dequeue more than requested
Date: Fri, 10 Feb 2023 17:58:36 +0000	[thread overview]
Message-ID: <20230210175841.303450-5-nicolas.chautru@intel.com> (raw)
In-Reply-To: <20230210175841.303450-1-nicolas.chautru@intel.com>

Add support for corner-case when more operations are
requested than expected, in the case of encoder muxing
operations.

Fixes: e640f6cdfa84 ("baseband/acc200: add LDPC processing")
Cc: stable@dpdk.org

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/baseband/acc/rte_vrb_pmd.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/baseband/acc/rte_vrb_pmd.c b/drivers/baseband/acc/rte_vrb_pmd.c
index b1134f244d..a7d0b1e33c 100644
--- a/drivers/baseband/acc/rte_vrb_pmd.c
+++ b/drivers/baseband/acc/rte_vrb_pmd.c
@@ -2640,7 +2640,8 @@ vrb_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
 /* Dequeue one encode operations from device in CB mode. */
 static inline int
 vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
-		uint16_t *dequeued_ops, uint32_t *aq_dequeued, uint16_t *dequeued_descs)
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued, uint16_t *dequeued_descs,
+		uint16_t max_requested_ops)
 {
 	union acc_dma_desc *desc, atom_desc;
 	union acc_dma_rsp_desc rsp;
@@ -2653,6 +2654,9 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 	desc = q->ring_addr + desc_idx;
 	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + desc->req.numCBs > max_requested_ops)
+		return -1;
+
 	/* Check fdone bit. */
 	if (!(atom_desc.rsp.val & ACC_FDONE))
 		return -1;
@@ -2694,7 +2698,7 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 static inline int
 vrb_dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 		uint16_t *dequeued_ops, uint32_t *aq_dequeued,
-		uint16_t *dequeued_descs)
+		uint16_t *dequeued_descs, uint16_t max_requested_ops)
 {
 	union acc_dma_desc *desc, *last_desc, atom_desc;
 	union acc_dma_rsp_desc rsp;
@@ -2705,6 +2709,9 @@ vrb_dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 	desc = acc_desc_tail(q, *dequeued_descs);
 	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + 1 > max_requested_ops)
+		return -1;
+
 	/* Check fdone bit. */
 	if (!(atom_desc.rsp.val & ACC_FDONE))
 		return -1;
@@ -2965,25 +2972,23 @@ vrb_dequeue_enc(struct rte_bbdev_queue_data *q_data,
 
 	cbm = op->turbo_enc.code_block_mode;
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < avail; i++) {
 		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
 			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		else
 			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		if (ret < 0)
 			break;
-		if (dequeued_ops >= num)
-			break;
 	}
 
 	q->aq_dequeued += aq_dequeued;
 	q->sw_ring_tail += dequeued_descs;
 
-	/* Update enqueue stats */
+	/* Update enqueue stats. */
 	q_data->queue_stats.dequeued_count += dequeued_ops;
 
 	return dequeued_ops;
@@ -3009,15 +3014,13 @@ vrb_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
 		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
 			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		else
 			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		if (ret < 0)
 			break;
-		if (dequeued_ops >= num)
-			break;
 	}
 
 	q->aq_dequeued += aq_dequeued;
-- 
2.34.1


  parent reply	other threads:[~2023-02-10 18:03 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 22:19 [PATCH v1 0/9] baseband/acc: VRB PMD fixes Nicolas Chautru
2023-02-09 22:19 ` [PATCH v1 1/9] baseband/acc: protection for TB negative scenario Nicolas Chautru
2023-02-10  8:17   ` Maxime Coquelin
2023-02-10 17:28     ` Chautru, Nicolas
2023-02-10 17:58   ` [PATCH v2 0/9] baseband/acc: VRB PMD fixes Nicolas Chautru
2023-02-10 17:58     ` [PATCH v2 1/9] baseband/acc: protection for TB negative scenario Nicolas Chautru
2023-02-23  8:56       ` Maxime Coquelin
2023-02-23 17:25         ` Chautru, Nicolas
2023-02-10 17:58     ` [PATCH v2 2/9] baseband/acc: remove interrupt support on VRB1 Nicolas Chautru
2023-02-10 17:58     ` [PATCH v2 3/9] baseband/acc: add explicit mbuf append for soft output Nicolas Chautru
2023-02-22 11:20       ` Maxime Coquelin
2023-02-10 17:58     ` Nicolas Chautru [this message]
2023-02-10 17:58     ` [PATCH v2 5/9] baseband/acc: fix iteration counter in TB mode Nicolas Chautru
2023-02-10 17:58     ` [PATCH v2 6/9] baseband/acc: fix potential arithmetic overflow Nicolas Chautru
2023-02-10 17:58     ` [PATCH v2 7/9] baseband/acc: add support for 4GUL CRC drop in VRB PMD Nicolas Chautru
2023-02-10 17:58     ` [PATCH v2 8/9] baseband/acc: add support for 4GUL with SO and TB Nicolas Chautru
2023-02-10 17:58     ` [PATCH v2 9/9] baseband/acc: remove printf from PMD function Nicolas Chautru
2023-02-23  9:28     ` [PATCH v2 0/9] baseband/acc: VRB PMD fixes Maxime Coquelin
2023-02-09 22:19 ` [PATCH v1 2/9] baseband/acc: add support for 4GUL with SO and TB Nicolas Chautru
2023-02-10  8:30   ` Maxime Coquelin
2023-02-10 17:29     ` Chautru, Nicolas
2023-02-09 22:19 ` [PATCH v1 3/9] baseband/acc: remove interrupt support on VRB1 Nicolas Chautru
2023-02-10  8:31   ` Maxime Coquelin
2023-02-09 22:19 ` [PATCH v1 4/9] baseband/acc: add explicit mbuf apend for soft output Nicolas Chautru
2023-02-10  8:40   ` Maxime Coquelin
2023-02-10 17:35     ` Chautru, Nicolas
2023-02-09 22:19 ` [PATCH v1 5/9] baseband/acc: prevent to dequeue more than requested Nicolas Chautru
2023-02-10  9:39   ` Maxime Coquelin
2023-02-09 22:19 ` [PATCH v1 6/9] baseband/acc: fix iteration counter in TB mode Nicolas Chautru
2023-02-10  9:40   ` Maxime Coquelin
2023-02-09 22:19 ` [PATCH v1 7/9] baseband/acc: fix potential arithmetic overflow Fix potential issue of overflow causing coverity warning Nicolas Chautru
2023-02-10  9:41   ` Maxime Coquelin
2023-02-09 22:19 ` [PATCH v1 8/9] baseband/acc: add support for 4GUL CRC drop in VRB PMD Nicolas Chautru
2023-02-10  9:43   ` Maxime Coquelin
2023-02-09 22:19 ` [PATCH v1 9/9] baseband/acc: remove printf from PMD function Nicolas Chautru
2023-02-10  9:45   ` Maxime Coquelin
2023-02-10 17:46     ` Chautru, Nicolas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230210175841.303450-5-nicolas.chautru@intel.com \
    --to=nicolas.chautru@intel.com \
    --cc=dev@dpdk.org \
    --cc=hernan.vargas@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).