diff mbox series

[v2,10/11] mempool/cnxk: add cn10k get count op

Message ID 20210403141751.215926-10-asekhar@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers show
Series [v2,01/11] mempool/cnxk: add build infra and doc | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ashwin Sekhar T K April 3, 2021, 2:17 p.m. UTC
Add the implementation for Marvell CN10k get count op.

Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
---
 drivers/mempool/cnxk/cn10k_mempool_ops.c | 28 +++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
index 2e3ec414da..16b2f6697f 100644
--- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
+++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
@@ -138,6 +138,32 @@  cn10k_mempool_enq(struct rte_mempool *mp, void *const *obj_table,
 	return 0;
 }
 
+static unsigned int
+cn10k_mempool_get_count(const struct rte_mempool *mp)
+{
+	struct batch_op_data *op_data;
+	unsigned int count = 0;
+	int i;
+
+	op_data = BATCH_OP_DATA_GET(mp->pool_id);
+
+	rte_wmb();
+	for (i = 0; i < RTE_MAX_LCORE; i++) {
+		struct batch_op_mem *mem = &op_data->mem[i];
+
+		if (mem->status == BATCH_ALLOC_OP_ISSUED)
+			count += roc_npa_aura_batch_alloc_count(mem->objs,
+								BATCH_ALLOC_SZ);
+
+		if (mem->status == BATCH_ALLOC_OP_DONE)
+			count += mem->sz;
+	}
+
+	count += cnxk_mempool_get_count(mp);
+
+	return count;
+}
+
 static int
 cn10k_mempool_alloc(struct rte_mempool *mp)
 {
@@ -190,7 +216,7 @@  static struct rte_mempool_ops cn10k_mempool_ops = {
 	.free = cn10k_mempool_free,
 	.enqueue = cn10k_mempool_enq,
 	.dequeue = cnxk_mempool_deq,
-	.get_count = cnxk_mempool_get_count,
+	.get_count = cn10k_mempool_get_count,
 	.calc_mem_size = cnxk_mempool_calc_mem_size,
 	.populate = cnxk_mempool_populate,
 };