diff mbox series

[v2,13/32] raw/cnxk_bphy: support for dequeue operation

Message ID 20210615110345.11057-14-tduszynski@marvell.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series add support for baseband phy | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tomasz Duszynski June 15, 2021, 11:03 a.m. UTC
Add support for dequeueing responses to previously
enqueued messages.

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Signed-off-by: Jakub Palider <jpalider@marvell.com>
---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
index 637514406..a8eafae1b 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
@@ -157,6 +157,32 @@  cnxk_bphy_cgx_enqueue_bufs(struct rte_rawdev *dev,
 	return 1;
 }
 
+static int
+cnxk_bphy_cgx_dequeue_bufs(struct rte_rawdev *dev,
+			   struct rte_rawdev_buf **buffers, unsigned int count,
+			   rte_rawdev_obj_t context)
+{
+	struct cnxk_bphy_cgx *cgx = dev->dev_private;
+	unsigned int queue = (size_t)context;
+	struct cnxk_bphy_cgx_queue *qp;
+
+	if (queue >= cgx->num_queues)
+		return -EINVAL;
+
+	if (count == 0)
+		return 0;
+
+	qp = &cgx->queues[queue];
+	if (qp->rsp) {
+		buffers[0]->buf_addr = qp->rsp;
+		qp->rsp = NULL;
+
+		return 1;
+	}
+
+	return 0;
+}
+
 static uint16_t
 cnxk_bphy_cgx_queue_count(struct rte_rawdev *dev)
 {
@@ -168,6 +194,7 @@  cnxk_bphy_cgx_queue_count(struct rte_rawdev *dev)
 static const struct rte_rawdev_ops cnxk_bphy_cgx_rawdev_ops = {
 	.queue_def_conf = cnxk_bphy_cgx_queue_def_conf,
 	.enqueue_bufs = cnxk_bphy_cgx_enqueue_bufs,
+	.dequeue_bufs = cnxk_bphy_cgx_dequeue_bufs,
 	.queue_count = cnxk_bphy_cgx_queue_count,
 };