diff mbox series

[v2,2/5] cryptodev: allocate max space for internal qp array

Message ID 20211011124309.4066491-3-gakhil@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers show
Series cryptodev: hide internal structures | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Akhil Goyal Oct. 11, 2021, 12:43 p.m. UTC
At queue_pair config stage, allocate memory for maximum
number of queue pair pointers that a device can support.

This will allow fast path APIs(enqueue_burst/dequeue_burst) to
refer pointer to internal QP data without checking for currently
configured QPs.
This is required to hide the rte_cryptodev and rte_cryptodev_data
structure from user.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 lib/cryptodev/rte_cryptodev.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

Comments

Zhang, Roy Fan Oct. 11, 2021, 2:51 p.m. UTC | #1
> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Monday, October 11, 2021 1:43 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> hemant.agrawal@nxp.com; anoobj@marvell.com; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Trahe, Fiona <fiona.trahe@intel.com>;
> Doherty, Declan <declan.doherty@intel.com>; matan@nvidia.com;
> g.singh@nxp.com; Zhang, Roy Fan <roy.fan.zhang@intel.com>;
> jianjay.zhou@huawei.com; asomalap@amd.com; ruifeng.wang@arm.com;
> Ananyev, Konstantin <konstantin.ananyev@intel.com>; Nicolau, Radu
> <radu.nicolau@intel.com>; ajit.khaparde@broadcom.com;
> rnagadheeraj@marvell.com; adwivedi@marvell.com; Power, Ciara
> <ciara.power@intel.com>; Akhil Goyal <gakhil@marvell.com>
> Subject: [PATCH v2 2/5] cryptodev: allocate max space for internal qp array
> 
> At queue_pair config stage, allocate memory for maximum
> number of queue pair pointers that a device can support.
> 
> This will allow fast path APIs(enqueue_burst/dequeue_burst) to
> refer pointer to internal QP data without checking for currently
> configured QPs.
> This is required to hide the rte_cryptodev and rte_cryptodev_data
> structure from user.
> 
> Signed-off-by: Akhil Goyal <gakhil@marvell.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
diff mbox series

Patch

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index b913c434c5..eb86e629aa 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -978,7 +978,8 @@  rte_cryptodev_queue_pairs_config(struct rte_cryptodev *dev, uint16_t nb_qpairs,
 	if (dev->data->queue_pairs == NULL) { /* first time configuration */
 		dev->data->queue_pairs = rte_zmalloc_socket(
 				"cryptodev->queue_pairs",
-				sizeof(dev->data->queue_pairs[0]) * nb_qpairs,
+				sizeof(dev->data->queue_pairs[0]) *
+				dev_info.max_nb_queue_pairs,
 				RTE_CACHE_LINE_SIZE, socket_id);
 
 		if (dev->data->queue_pairs == NULL) {
@@ -1001,25 +1002,9 @@  rte_cryptodev_queue_pairs_config(struct rte_cryptodev *dev, uint16_t nb_qpairs,
 			ret = (*dev->dev_ops->queue_pair_release)(dev, i);
 			if (ret < 0)
 				return ret;
+			qp[i] = NULL;
 		}
 
-		qp = rte_realloc(qp, sizeof(qp[0]) * nb_qpairs,
-				RTE_CACHE_LINE_SIZE);
-		if (qp == NULL) {
-			CDEV_LOG_ERR("failed to realloc qp meta data,"
-						" nb_queues %u", nb_qpairs);
-			return -(ENOMEM);
-		}
-
-		if (nb_qpairs > old_nb_queues) {
-			uint16_t new_qs = nb_qpairs - old_nb_queues;
-
-			memset(qp + old_nb_queues, 0,
-				sizeof(qp[0]) * new_qs);
-		}
-
-		dev->data->queue_pairs = qp;
-
 	}
 	dev->data->nb_queue_pairs = nb_qpairs;
 	return 0;