[dpdk-dev] aesni_mb: fix wrong return value

Message ID 1455554704-12435-1-git-send-email-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

De Lara Guarch, Pablo Feb. 15, 2016, 4:45 p.m. UTC
  cryptodev_aesni_mb_init was returning the device id of
the device just created, but rte_eal_vdev_init
(the function that calls the first one), was expecting 0 or
negative value.
This made impossible to create more than one aesni_mb device
from command line.

Fixes: 924e84f87306 ("aesni_mb: add driver for multi buffer based crypto")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c                  | 7 ++++---
 app/test/test_cryptodev_perf.c             | 5 +++--
 doc/guides/rel_notes/release_16_04.rst     | 6 ++++++
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 +-
 examples/l2fwd-crypto/main.c               | 4 ++--
 5 files changed, 16 insertions(+), 8 deletions(-)
  

Comments

Doherty, Declan Feb. 18, 2016, 3:39 p.m. UTC | #1
On 15/02/16 16:45, Pablo de Lara wrote:
> cryptodev_aesni_mb_init was returning the device id of
> the device just created, but rte_eal_vdev_init
> (the function that calls the first one), was expecting 0 or
> negative value.
> This made impossible to create more than one aesni_mb device
> from command line.
>
> Fixes: 924e84f87306 ("aesni_mb: add driver for multi buffer based crypto")
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>   app/test/test_cryptodev.c                  | 7 ++++---
>   app/test/test_cryptodev_perf.c             | 5 +++--
>   doc/guides/rel_notes/release_16_04.rst     | 6 ++++++
>   drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 +-
>   examples/l2fwd-crypto/main.c               | 4 ++--
>   5 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
> index fd5b7ec..62f8fb0 100644
> --- a/app/test/test_cryptodev.c
> +++ b/app/test/test_cryptodev.c
> @@ -143,7 +143,8 @@ testsuite_setup(void)
>   {
>   	struct crypto_testsuite_params *ts_params = &testsuite_params;
>   	struct rte_cryptodev_info info;
> -	unsigned i, nb_devs, dev_id = 0;
> +	unsigned i, nb_devs, dev_id;
> +	int ret;
>   	uint16_t qp_id;
>
>   	memset(ts_params, 0, sizeof(*ts_params));
> @@ -177,10 +178,10 @@ testsuite_setup(void)
>   				RTE_CRYPTODEV_AESNI_MB_PMD);
>   		if (nb_devs < 2) {
>   			for (i = nb_devs; i < 2; i++) {
> -				int dev_id = rte_eal_vdev_init(
> +				ret = rte_eal_vdev_init(
>   					CRYPTODEV_NAME_AESNI_MB_PMD, NULL);
>
> -				TEST_ASSERT(dev_id >= 0,
> +				TEST_ASSERT(ret == 0,
>   					"Failed to create instance %u of"
>   					" pmd : %s",
>   					i, CRYPTODEV_NAME_AESNI_MB_PMD);
> diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
> index 1744e13..728bcf0 100644
> --- a/app/test/test_cryptodev_perf.c
> +++ b/app/test/test_cryptodev_perf.c
> @@ -107,6 +107,7 @@ testsuite_setup(void)
>   	struct crypto_testsuite_params *ts_params = &testsuite_params;
>   	struct rte_cryptodev_info info;
>   	unsigned i, nb_devs, valid_dev_id = 0;
> +	int ret;
>   	uint16_t qp_id;
>
>   	ts_params->mbuf_mp = rte_mempool_lookup("CRYPTO_PERF_MBUFPOOL");
> @@ -138,10 +139,10 @@ testsuite_setup(void)
>   		nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_AESNI_MB_PMD);
>   		if (nb_devs < 2) {
>   			for (i = nb_devs; i < 2; i++) {
> -				int dev_id = rte_eal_vdev_init(
> +				ret = rte_eal_vdev_init(
>   					CRYPTODEV_NAME_AESNI_MB_PMD, NULL);
>
> -				TEST_ASSERT(dev_id >= 0,
> +				TEST_ASSERT(ret == 0,
>   					"Failed to create instance %u of pmd : %s",
>   					i, CRYPTODEV_NAME_AESNI_MB_PMD);
>   			}
> diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
> index 27fc624..123a6fd 100644
> --- a/doc/guides/rel_notes/release_16_04.rst
> +++ b/doc/guides/rel_notes/release_16_04.rst
> @@ -59,6 +59,12 @@ EAL
>   Drivers
>   ~~~~~~~
>
> +* **aesni_mb: Fixed wrong return value when creating a device.**
> +
> +  cryptodev_aesni_mb_init() was returning the device id of the device created,
> +  instead of 0 (when success), that rte_eal_vdev_init() expects.
> +  This made impossible the creation of more than one aesni_mb device
> +  from command line.
>
>   Libraries
>   ~~~~~~~~~
> diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
> index 2ede7c1..a655ed8 100644
> --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
> +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
> @@ -628,7 +628,7 @@ cryptodev_aesni_mb_create(const char *name, unsigned socket_id)
>   	internals->max_nb_queue_pairs = RTE_AESNI_MB_PMD_MAX_NB_QUEUE_PAIRS;
>   	internals->max_nb_sessions = RTE_AESNI_MB_PMD_MAX_NB_SESSIONS;
>
> -	return dev->data->dev_id;
> +	return 0;
>   init_error:
>   	MB_LOG_ERR("driver %s: cryptodev_aesni_create failed", name);
>
> diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
> index d70fc9a..3f53e4e 100644
> --- a/examples/l2fwd-crypto/main.c
> +++ b/examples/l2fwd-crypto/main.c
> @@ -1178,9 +1178,9 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports)
>   			return -1;
>   	} else if (options->cdev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
>   		for (i = 0; i < nb_ports; i++) {
> -			int id = rte_eal_vdev_init(CRYPTODEV_NAME_AESNI_MB_PMD,
> +			int retval = rte_eal_vdev_init(CRYPTODEV_NAME_AESNI_MB_PMD,
>   					NULL);
> -			if (id < 0)
> +			if (retval < 0)
>   				return -1;
>   		}
>   	}
>

Acked-by: Declan Doherty <declan.doherty@intel.com>
  
Thomas Monjalon Feb. 24, 2016, 2:03 p.m. UTC | #2
2016-02-18 15:39, Declan Doherty:
> On 15/02/16 16:45, Pablo de Lara wrote:
> > cryptodev_aesni_mb_init was returning the device id of
> > the device just created, but rte_eal_vdev_init
> > (the function that calls the first one), was expecting 0 or
> > negative value.
> > This made impossible to create more than one aesni_mb device
> > from command line.
> >
> > Fixes: 924e84f87306 ("aesni_mb: add driver for multi buffer based crypto")
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
> Acked-by: Declan Doherty <declan.doherty@intel.com>

Applied, thanks
  

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index fd5b7ec..62f8fb0 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -143,7 +143,8 @@  testsuite_setup(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_cryptodev_info info;
-	unsigned i, nb_devs, dev_id = 0;
+	unsigned i, nb_devs, dev_id;
+	int ret;
 	uint16_t qp_id;
 
 	memset(ts_params, 0, sizeof(*ts_params));
@@ -177,10 +178,10 @@  testsuite_setup(void)
 				RTE_CRYPTODEV_AESNI_MB_PMD);
 		if (nb_devs < 2) {
 			for (i = nb_devs; i < 2; i++) {
-				int dev_id = rte_eal_vdev_init(
+				ret = rte_eal_vdev_init(
 					CRYPTODEV_NAME_AESNI_MB_PMD, NULL);
 
-				TEST_ASSERT(dev_id >= 0,
+				TEST_ASSERT(ret == 0,
 					"Failed to create instance %u of"
 					" pmd : %s",
 					i, CRYPTODEV_NAME_AESNI_MB_PMD);
diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
index 1744e13..728bcf0 100644
--- a/app/test/test_cryptodev_perf.c
+++ b/app/test/test_cryptodev_perf.c
@@ -107,6 +107,7 @@  testsuite_setup(void)
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_cryptodev_info info;
 	unsigned i, nb_devs, valid_dev_id = 0;
+	int ret;
 	uint16_t qp_id;
 
 	ts_params->mbuf_mp = rte_mempool_lookup("CRYPTO_PERF_MBUFPOOL");
@@ -138,10 +139,10 @@  testsuite_setup(void)
 		nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_AESNI_MB_PMD);
 		if (nb_devs < 2) {
 			for (i = nb_devs; i < 2; i++) {
-				int dev_id = rte_eal_vdev_init(
+				ret = rte_eal_vdev_init(
 					CRYPTODEV_NAME_AESNI_MB_PMD, NULL);
 
-				TEST_ASSERT(dev_id >= 0,
+				TEST_ASSERT(ret == 0,
 					"Failed to create instance %u of pmd : %s",
 					i, CRYPTODEV_NAME_AESNI_MB_PMD);
 			}
diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
index 27fc624..123a6fd 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -59,6 +59,12 @@  EAL
 Drivers
 ~~~~~~~
 
+* **aesni_mb: Fixed wrong return value when creating a device.**
+
+  cryptodev_aesni_mb_init() was returning the device id of the device created,
+  instead of 0 (when success), that rte_eal_vdev_init() expects.
+  This made impossible the creation of more than one aesni_mb device
+  from command line.
 
 Libraries
 ~~~~~~~~~
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 2ede7c1..a655ed8 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -628,7 +628,7 @@  cryptodev_aesni_mb_create(const char *name, unsigned socket_id)
 	internals->max_nb_queue_pairs = RTE_AESNI_MB_PMD_MAX_NB_QUEUE_PAIRS;
 	internals->max_nb_sessions = RTE_AESNI_MB_PMD_MAX_NB_SESSIONS;
 
-	return dev->data->dev_id;
+	return 0;
 init_error:
 	MB_LOG_ERR("driver %s: cryptodev_aesni_create failed", name);
 
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index d70fc9a..3f53e4e 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1178,9 +1178,9 @@  initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports)
 			return -1;
 	} else if (options->cdev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
 		for (i = 0; i < nb_ports; i++) {
-			int id = rte_eal_vdev_init(CRYPTODEV_NAME_AESNI_MB_PMD,
+			int retval = rte_eal_vdev_init(CRYPTODEV_NAME_AESNI_MB_PMD,
 					NULL);
-			if (id < 0)
+			if (retval < 0)
 				return -1;
 		}
 	}