diff mbox series

[v2,09/11] mempool/cnxk: add cn10k batch enqueue op

Message ID 20210403141751.215926-9-asekhar@marvell.com (mailing list archive)
State Changes Requested
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 mempool batch enqueue 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(-)

Comments

Jerin Jacob April 3, 2021, 2:31 p.m. UTC | #1
On Sat, Apr 3, 2021 at 7:49 PM Ashwin Sekhar T K <asekhar@marvell.com> wrote:
>
> Add the implementation for Marvell CN10k mempool batch enqueue 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 --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
> index d34041528a..2e3ec414da 100644
> --- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
> +++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
> @@ -112,6 +112,32 @@ batch_op_fini(struct rte_mempool *mp)
>         BATCH_OP_DATA_SET(mp->pool_id, NULL);
>  }
>
> +static int __rte_hot
> +cn10k_mempool_enq(struct rte_mempool *mp, void *const *obj_table,
> +                 unsigned int n)
> +{
> +       const uint64_t *ptr = (const uint64_t *)obj_table;
> +       uint64_t lmt_addr = 0, lmt_id = 0;

Please check the initialization to zero is required or not.

> +       struct batch_op_data *op_data;
> +
> +       /* Ensure mbuf init changes are written before the free pointers are
> +        * enqueued to the stack.
> +        */
> +       rte_io_wmb();
> +
> +       if (n == 1) {
> +               roc_npa_aura_op_free(mp->pool_id, 1, ptr[0]);
> +               return 0;
> +       }
> +
> +       op_data = BATCH_OP_DATA_GET(mp->pool_id);
> +       lmt_addr = op_data->lmt_addr;
> +       ROC_LMT_BASE_ID_GET(lmt_addr, lmt_id);
> +       roc_npa_aura_op_batch_free(mp->pool_id, ptr, n, 1, lmt_addr, lmt_id);
> +
> +       return 0;
> +}
> +
>  static int
>  cn10k_mempool_alloc(struct rte_mempool *mp)
>  {
> @@ -162,7 +188,7 @@ static struct rte_mempool_ops cn10k_mempool_ops = {
>         .name = "cn10k_mempool_ops",
>         .alloc = cn10k_mempool_alloc,
>         .free = cn10k_mempool_free,
> -       .enqueue = cnxk_mempool_enq,
> +       .enqueue = cn10k_mempool_enq,
>         .dequeue = cnxk_mempool_deq,
>         .get_count = cnxk_mempool_get_count,
>         .calc_mem_size = cnxk_mempool_calc_mem_size,
> --
> 2.31.0
>
diff mbox series

Patch

diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
index d34041528a..2e3ec414da 100644
--- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
+++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
@@ -112,6 +112,32 @@  batch_op_fini(struct rte_mempool *mp)
 	BATCH_OP_DATA_SET(mp->pool_id, NULL);
 }
 
+static int __rte_hot
+cn10k_mempool_enq(struct rte_mempool *mp, void *const *obj_table,
+		  unsigned int n)
+{
+	const uint64_t *ptr = (const uint64_t *)obj_table;
+	uint64_t lmt_addr = 0, lmt_id = 0;
+	struct batch_op_data *op_data;
+
+	/* Ensure mbuf init changes are written before the free pointers are
+	 * enqueued to the stack.
+	 */
+	rte_io_wmb();
+
+	if (n == 1) {
+		roc_npa_aura_op_free(mp->pool_id, 1, ptr[0]);
+		return 0;
+	}
+
+	op_data = BATCH_OP_DATA_GET(mp->pool_id);
+	lmt_addr = op_data->lmt_addr;
+	ROC_LMT_BASE_ID_GET(lmt_addr, lmt_id);
+	roc_npa_aura_op_batch_free(mp->pool_id, ptr, n, 1, lmt_addr, lmt_id);
+
+	return 0;
+}
+
 static int
 cn10k_mempool_alloc(struct rte_mempool *mp)
 {
@@ -162,7 +188,7 @@  static struct rte_mempool_ops cn10k_mempool_ops = {
 	.name = "cn10k_mempool_ops",
 	.alloc = cn10k_mempool_alloc,
 	.free = cn10k_mempool_free,
-	.enqueue = cnxk_mempool_enq,
+	.enqueue = cn10k_mempool_enq,
 	.dequeue = cnxk_mempool_deq,
 	.get_count = cnxk_mempool_get_count,
 	.calc_mem_size = cnxk_mempool_calc_mem_size,