diff mbox series

[1/2] examples/ip_pipeline: fix crypto queue config

Message ID 20191211052534.14600-1-hemant.agrawal@nxp.com
State New
Headers show
Series [1/2] examples/ip_pipeline: fix crypto queue config | expand

Commit Message

Hemant Agrawal Dec. 11, 2019, 5:25 a.m. UTC
queue_conf need to have mempool details before pair setup.

Fixes: 261bbff75e34 ("examples: use separate crypto session mempools")
Cc: stable@dpdk.org

Signed-off-by: Jun Yang <jun.yang@nxp.com>

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
 examples/ip_pipeline/cryptodev.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

-- 
2.17.1

Comments

Zhang, Roy Fan Feb. 14, 2020, 10:52 a.m. UTC | #1
> -----Original Message-----

> From: dev <dev-bounces@dpdk.org> On Behalf Of Hemant Agrawal

> Sent: Wednesday, December 11, 2019 5:26 AM

> To: dev@dpdk.org

> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; stable@dpdk.org;

> Jun Yang <jun.yang@nxp.com>; Hemant Agrawal

> <hemant.agrawal@nxp.com>

> Subject: [dpdk-dev] [PATCH 1/2] examples/ip_pipeline: fix crypto queue

> config

> 

> queue_conf need to have mempool details before pair setup.

> 

> Fixes: 261bbff75e34 ("examples: use separate crypto session mempools")

> Cc: stable@dpdk.org

> 

> Signed-off-by: Jun Yang <jun.yang@nxp.com>

> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

> ---


Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Cristian Dumitrescu Feb. 14, 2020, 11:22 a.m. UTC | #2
> -----Original Message-----

> From: dev <dev-bounces@dpdk.org> On Behalf Of Hemant Agrawal

> Sent: Wednesday, December 11, 2019 5:26 AM

> To: dev@dpdk.org

> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; stable@dpdk.org;

> Jun Yang <jun.yang@nxp.com>; Hemant Agrawal

> <hemant.agrawal@nxp.com>

> Subject: [dpdk-dev] [PATCH 1/2] examples/ip_pipeline: fix crypto queue

> config

> 

> queue_conf need to have mempool details before pair setup.

> 

> Fixes: 261bbff75e34 ("examples: use separate crypto session mempools")

> Cc: stable@dpdk.org

> 

> Signed-off-by: Jun Yang <jun.yang@nxp.com>

> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

> ---

>  examples/ip_pipeline/cryptodev.c | 24 +++++++++++++-----------

>  1 file changed, 13 insertions(+), 11 deletions(-)

> 

> diff --git a/examples/ip_pipeline/cryptodev.c

> b/examples/ip_pipeline/cryptodev.c

> index b0d9f3d217..ae65a90859 100644

> --- a/examples/ip_pipeline/cryptodev.c

> +++ b/examples/ip_pipeline/cryptodev.c

> @@ -99,17 +99,6 @@ cryptodev_create(const char *name, struct

> cryptodev_params *params)

>  	if (status < 0)

>  		return NULL;

> 

> -	queue_conf.nb_descriptors = params->queue_size;

> -	for (i = 0; i < params->n_queues; i++) {

> -		status = rte_cryptodev_queue_pair_setup(dev_id, i,

> -				&queue_conf, socket_id);

> -		if (status < 0)

> -			return NULL;

> -	}

> -

> -	if (rte_cryptodev_start(dev_id) < 0)

> -		return NULL;

> -

>  	cryptodev = calloc(1, sizeof(struct cryptodev));

>  	if (cryptodev == NULL) {

>  		rte_cryptodev_stop(dev_id);

> @@ -149,6 +138,19 @@ cryptodev_create(const char *name, struct

> cryptodev_params *params)

> 

>  	TAILQ_INSERT_TAIL(&cryptodev_list, cryptodev, node);

> 

> +	queue_conf.nb_descriptors = params->queue_size;

> +	queue_conf.mp_session = cryptodev->mp_create;

> +	queue_conf.mp_session_private = cryptodev->mp_init;

> +	for (i = 0; i < params->n_queues; i++) {

> +		status = rte_cryptodev_queue_pair_setup(dev_id, i,

> +				&queue_conf, socket_id);

> +		if (status < 0)

> +			goto error_exit;

> +	}

> +

> +	if (rte_cryptodev_start(dev_id) < 0)

> +		goto error_exit;

> +

>  	return cryptodev;

> 

>  error_exit:

> --

> 2.17.1


Idea is correct, implementation is broken, so rework is needed.

The cryptodev->mp_create and cryptodev->mp_init are not valid at this point where you assign them to queue_conf.mp_session and queue_conf.mp_session_private, as they only get created later in this same function. Please fix.
diff mbox series

Patch

diff --git a/examples/ip_pipeline/cryptodev.c b/examples/ip_pipeline/cryptodev.c
index b0d9f3d217..ae65a90859 100644
--- a/examples/ip_pipeline/cryptodev.c
+++ b/examples/ip_pipeline/cryptodev.c
@@ -99,17 +99,6 @@  cryptodev_create(const char *name, struct cryptodev_params *params)
 	if (status < 0)
 		return NULL;
 
-	queue_conf.nb_descriptors = params->queue_size;
-	for (i = 0; i < params->n_queues; i++) {
-		status = rte_cryptodev_queue_pair_setup(dev_id, i,
-				&queue_conf, socket_id);
-		if (status < 0)
-			return NULL;
-	}
-
-	if (rte_cryptodev_start(dev_id) < 0)
-		return NULL;
-
 	cryptodev = calloc(1, sizeof(struct cryptodev));
 	if (cryptodev == NULL) {
 		rte_cryptodev_stop(dev_id);
@@ -149,6 +138,19 @@  cryptodev_create(const char *name, struct cryptodev_params *params)
 
 	TAILQ_INSERT_TAIL(&cryptodev_list, cryptodev, node);
 
+	queue_conf.nb_descriptors = params->queue_size;
+	queue_conf.mp_session = cryptodev->mp_create;
+	queue_conf.mp_session_private = cryptodev->mp_init;
+	for (i = 0; i < params->n_queues; i++) {
+		status = rte_cryptodev_queue_pair_setup(dev_id, i,
+				&queue_conf, socket_id);
+		if (status < 0)
+			goto error_exit;
+	}
+
+	if (rte_cryptodev_start(dev_id) < 0)
+		goto error_exit;
+
 	return cryptodev;
 
 error_exit: