DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL
@ 2017-04-18 14:34 Pablo de Lara
  2017-04-18 14:34 ` [dpdk-dev] [PATCH 2/2] drvers/crypto: do not create unique name internally Pablo de Lara
  2017-04-19  9:48 ` [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL Zhang, Roy Fan
  0 siblings, 2 replies; 6+ messages in thread
From: Pablo de Lara @ 2017-04-18 14:34 UTC (permalink / raw)
  To: dev
  Cc: zbigniew.bodek, jerin.jacob, declan.doherty, roy.fan.zhang,
	Pablo de Lara

Check if virtual device name is NULL,
to avoid possible segmentation faults.

Fixes: 5d2aa461cbca ("vdev: use generic vdev struct for probe and remove")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 2 ++
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 ++
 drivers/crypto/armv8/rte_armv8_pmd.c       | 2 ++
 drivers/crypto/kasumi/rte_kasumi_pmd.c     | 2 ++
 drivers/crypto/null/null_crypto_pmd.c      | 8 +++++---
 drivers/crypto/openssl/rte_openssl_pmd.c   | 2 ++
 drivers/crypto/scheduler/scheduler_pmd.c   | 7 ++++++-
 drivers/crypto/snow3g/rte_snow3g_pmd.c     | 2 ++
 drivers/crypto/zuc/rte_zuc_pmd.c           | 2 ++
 9 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index 1705896..f4dd1ae 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -501,6 +501,8 @@ aesni_gcm_probe(struct rte_vdev_device *vdev)
 	const char *input_args;
 
 	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 	input_args = rte_vdev_device_args(vdev);
 	rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
 
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 37b22ec..88b691e 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -768,6 +768,8 @@ cryptodev_aesni_mb_probe(struct rte_vdev_device *vdev)
 	const char *input_args;
 
 	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 	input_args = rte_vdev_device_args(vdev);
 	rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
 
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index bf56bc6..a8af4a3 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -864,6 +864,8 @@ cryptodev_armv8_crypto_init(struct rte_vdev_device *vdev)
 	const char *input_args;
 
 	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 	input_args = rte_vdev_device_args(vdev);
 	rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
 
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 42fdd33..b4476e8 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -624,6 +624,8 @@ cryptodev_kasumi_probe(struct rte_vdev_device *vdev)
 	const char *input_args;
 
 	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 	input_args = rte_vdev_device_args(vdev);
 
 	rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index a44c61a..3d131ca 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -226,12 +226,14 @@ cryptodev_null_probe(struct rte_vdev_device *dev)
 		rte_socket_id(),
 		{0}
 	};
+	const char *name;
 
-	rte_cryptodev_parse_vdev_init_params(&init_params,
-		rte_vdev_device_args(dev));
+	name = rte_vdev_device_name(dev);
+	if (name == NULL)
+		return -EINVAL;
 
 	RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n",
-		rte_vdev_device_name(dev), init_params.socket_id);
+		name, init_params.socket_id);
 	if (init_params.name[0] != '\0')
 		RTE_LOG(INFO, PMD, "  User defined name = %s\n",
 			init_params.name);
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index f3c8f83..9deead8 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1331,6 +1331,8 @@ cryptodev_openssl_probe(struct rte_vdev_device *vdev)
 	const char *input_args;
 
 	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 	input_args = rte_vdev_device_args(vdev);
 
 	rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index 7d9e376..74e1f26 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -429,12 +429,17 @@ cryptodev_scheduler_probe(struct rte_vdev_device *vdev)
 		.mode = CDEV_SCHED_MODE_NOT_SET,
 		.enable_ordering = 0
 	};
+	const char *name;
+
+	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 
 	scheduler_parse_init_params(&init_params,
 				    rte_vdev_device_args(vdev));
 
 	RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n",
-			rte_vdev_device_name(vdev),
+			name,
 			init_params.def_p.socket_id);
 	RTE_LOG(INFO, PMD, "  Max number of queue pairs = %d\n",
 			init_params.def_p.max_nb_queue_pairs);
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index a31eaa8..42b802b 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -613,6 +613,8 @@ cryptodev_snow3g_probe(struct rte_vdev_device *vdev)
 	const char *input_args;
 
 	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 	input_args = rte_vdev_device_args(vdev);
 
 	rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 5eec933..22bf8bf 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -513,6 +513,8 @@ cryptodev_zuc_probe(struct rte_vdev_device *vdev)
 	const char *input_args;
 
 	name = rte_vdev_device_name(vdev);
+	if (name == NULL)
+		return -EINVAL;
 	input_args = rte_vdev_device_args(vdev);
 
 	rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH 2/2] drvers/crypto: do not create unique name internally
  2017-04-18 14:34 [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL Pablo de Lara
@ 2017-04-18 14:34 ` Pablo de Lara
  2017-04-19 10:05   ` Zhang, Roy Fan
  2017-04-19  9:48 ` [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL Zhang, Roy Fan
  1 sibling, 1 reply; 6+ messages in thread
From: Pablo de Lara @ 2017-04-18 14:34 UTC (permalink / raw)
  To: dev
  Cc: zbigniew.bodek, jerin.jacob, declan.doherty, roy.fan.zhang,
	Pablo de Lara

Crypto devices of the same type could be initialized
with the same name, since internally this name was suffixed
with an index.

Since commit <dda987315ca2> ("vdev: make virtual bus use its
device struct"), this is not allowed anymore.

Therefore, there is no need to create an unique name
at device initialization.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 20 +++++++-------------
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 20 +++++++-------------
 drivers/crypto/armv8/rte_armv8_pmd.c       | 21 +++++++--------------
 drivers/crypto/kasumi/rte_kasumi_pmd.c     | 18 ++++++------------
 drivers/crypto/null/null_crypto_pmd.c      | 19 ++++++-------------
 drivers/crypto/openssl/rte_openssl_pmd.c   | 20 +++++++-------------
 drivers/crypto/scheduler/scheduler_pmd.c   | 24 +++++++-----------------
 drivers/crypto/snow3g/rte_snow3g_pmd.c     | 18 ++++++------------
 drivers/crypto/zuc/rte_zuc_pmd.c           | 20 +++++++-------------
 9 files changed, 60 insertions(+), 120 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index f4dd1ae..101ef98 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -432,22 +432,16 @@ aesni_gcm_pmd_enqueue_burst(void *queue_pair,
 static int aesni_gcm_remove(struct rte_vdev_device *vdev);
 
 static int
-aesni_gcm_create(struct rte_vdev_device *vdev,
-		 struct rte_crypto_vdev_init_params *init_params)
+aesni_gcm_create(const char *name,
+		struct rte_vdev_device *vdev,
+		struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct aesni_gcm_private *internals;
 
-	if (init_params->name[0] == '\0') {
-		int ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
-
-		if (ret < 0) {
-			GCM_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	/* Check CPU for support for AES instruction set */
 	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AES)) {
@@ -516,7 +510,7 @@ aesni_gcm_probe(struct rte_vdev_device *vdev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return aesni_gcm_create(vdev, &init_params);
+	return aesni_gcm_create(name, vdev, &init_params);
 }
 
 static int
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 88b691e..45b25c9 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -672,23 +672,17 @@ aesni_mb_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
 static int cryptodev_aesni_mb_remove(struct rte_vdev_device *vdev);
 
 static int
-cryptodev_aesni_mb_create(struct rte_vdev_device *vdev,
-			  struct rte_crypto_vdev_init_params *init_params)
+cryptodev_aesni_mb_create(const char *name,
+			struct rte_vdev_device *vdev,
+			struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct aesni_mb_private *internals;
 	enum aesni_mb_vector_mode vector_mode;
 
-	if (init_params->name[0] == '\0') {
-		int ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
-
-		if (ret < 0) {
-			MB_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	/* Check CPU for supported vector instruction set */
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
@@ -783,7 +777,7 @@ cryptodev_aesni_mb_probe(struct rte_vdev_device *vdev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return cryptodev_aesni_mb_create(vdev, &init_params);
+	return cryptodev_aesni_mb_create(name, vdev, &init_params);
 }
 
 static int
diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c
index a8af4a3..3d603a5 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -773,12 +773,12 @@ armv8_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
 
 /** Create ARMv8 crypto device */
 static int
-cryptodev_armv8_crypto_create(struct rte_vdev_device *vdev,
-			      struct rte_crypto_vdev_init_params *init_params)
+cryptodev_armv8_crypto_create(const char *name,
+			struct rte_vdev_device *vdev,
+			struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct armv8_crypto_private *internals;
-	int ret;
 
 	/* Check CPU for support for AES instruction set */
 	if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AES)) {
@@ -802,16 +802,9 @@ cryptodev_armv8_crypto_create(struct rte_vdev_device *vdev,
 		return -EFAULT;
 	}
 
-	if (init_params->name[0] == '\0') {
-		ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
-
-		if (ret < 0) {
-			ARMV8_CRYPTO_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
 				sizeof(struct armv8_crypto_private),
@@ -880,7 +873,7 @@ cryptodev_armv8_crypto_init(struct rte_vdev_device *vdev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return cryptodev_armv8_crypto_create(vdev, &init_params);
+	return cryptodev_armv8_crypto_create(name, vdev, &init_params);
 }
 
 /** Uninitialise ARMv8 crypto device */
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index b4476e8..9da9e89 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -551,23 +551,17 @@ kasumi_pmd_dequeue_burst(void *queue_pair,
 static int cryptodev_kasumi_remove(struct rte_vdev_device *vdev);
 
 static int
-cryptodev_kasumi_create(struct rte_vdev_device *vdev,
+cryptodev_kasumi_create(const char *name,
+			struct rte_vdev_device *vdev,
 			struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct kasumi_private *internals;
 	uint64_t cpu_flags = 0;
 
-	if (init_params->name[0] == '\0') {
-		int ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
-
-		if (ret < 0) {
-			KASUMI_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	/* Check CPU for supported vector instruction set */
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
@@ -640,7 +634,7 @@ cryptodev_kasumi_probe(struct rte_vdev_device *vdev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return cryptodev_kasumi_create(vdev, &init_params);
+	return cryptodev_kasumi_create(name, vdev, &init_params);
 }
 
 static int
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 3d131ca..023450a 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -165,22 +165,15 @@ static int cryptodev_null_remove(const char *name);
 
 /** Create crypto device */
 static int
-cryptodev_null_create(struct rte_crypto_vdev_init_params *init_params)
+cryptodev_null_create(const char *name,
+		struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct null_crypto_private *internals;
 
-	if (init_params->name[0] == '\0') {
-		int ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_NULL_PMD));
-
-		if (ret < 0) {
-			NULL_CRYPTO_LOG_ERR("failed to create unique "
-					"name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
 			sizeof(struct null_crypto_private),
@@ -242,7 +235,7 @@ cryptodev_null_probe(struct rte_vdev_device *dev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return cryptodev_null_create(&init_params);
+	return cryptodev_null_create(name, &init_params);
 }
 
 /** Uninitialise null crypto device */
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 9deead8..f0c5ca3 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1264,22 +1264,16 @@ openssl_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
 
 /** Create OPENSSL crypto device */
 static int
-cryptodev_openssl_create(struct rte_vdev_device *vdev,
-			 struct rte_crypto_vdev_init_params *init_params)
+cryptodev_openssl_create(const char *name,
+			struct rte_vdev_device *vdev,
+			struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct openssl_private *internals;
 
-	if (init_params->name[0] == '\0') {
-		int ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
-
-		if (ret < 0) {
-			OPENSSL_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
 			sizeof(struct openssl_private),
@@ -1347,7 +1341,7 @@ cryptodev_openssl_probe(struct rte_vdev_device *vdev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return cryptodev_openssl_create(vdev, &init_params);
+	return cryptodev_openssl_create(name, vdev, &init_params);
 }
 
 /** Uninitialise OPENSSL crypto device */
diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index 74e1f26..c27d985 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -114,27 +114,17 @@ static int
 cryptodev_scheduler_create(const char *name,
 	struct scheduler_init_params *init_params)
 {
-	char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN] = {0};
 	struct rte_cryptodev *dev;
 	struct scheduler_ctx *sched_ctx;
 	uint32_t i;
 	int ret;
 
-	if (init_params->def_p.name[0] == '\0') {
-		ret = rte_cryptodev_pmd_create_dev_name(
-				crypto_dev_name,
-				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
+	if (init_params->def_p.name[0] == '\0')
+		snprintf(init_params->def_p.name,
+				sizeof(init_params->def_p.name),
+				"%s", name);
 
-		if (ret < 0) {
-			CS_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	} else {
-		strncpy(crypto_dev_name, init_params->def_p.name,
-				RTE_CRYPTODEV_NAME_MAX_LEN - 1);
-	}
-
-	dev = rte_cryptodev_pmd_virtual_dev_init(crypto_dev_name,
+	dev = rte_cryptodev_pmd_virtual_dev_init(init_params->def_p.name,
 			sizeof(struct scheduler_ctx),
 			init_params->def_p.socket_id);
 	if (dev == NULL) {
@@ -449,8 +439,8 @@ cryptodev_scheduler_probe(struct rte_vdev_device *vdev)
 		RTE_LOG(INFO, PMD, "  User defined name = %s\n",
 			init_params.def_p.name);
 
-	return cryptodev_scheduler_create(rte_vdev_device_name(vdev),
-					  &init_params);
+	return cryptodev_scheduler_create(name,
+					&init_params);
 }
 
 static struct rte_vdev_driver cryptodev_scheduler_pmd_drv = {
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 42b802b..960956c 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -542,23 +542,17 @@ snow3g_pmd_dequeue_burst(void *queue_pair,
 static int cryptodev_snow3g_remove(struct rte_vdev_device *vdev);
 
 static int
-cryptodev_snow3g_create(struct rte_vdev_device *vdev,
+cryptodev_snow3g_create(const char *name,
+			struct rte_vdev_device *vdev,
 			struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct snow3g_private *internals;
 	uint64_t cpu_flags = 0;
 
-	if (init_params->name[0] == '\0') {
-		int ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
-
-		if (ret < 0) {
-			SNOW3G_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	/* Check CPU for supported vector instruction set */
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
@@ -629,7 +623,7 @@ cryptodev_snow3g_probe(struct rte_vdev_device *vdev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return cryptodev_snow3g_create(vdev, &init_params);
+	return cryptodev_snow3g_create(name, vdev, &init_params);
 }
 
 static int
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index 22bf8bf..1020544 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -442,23 +442,17 @@ zuc_pmd_dequeue_burst(void *queue_pair,
 static int cryptodev_zuc_remove(struct rte_vdev_device *vdev);
 
 static int
-cryptodev_zuc_create(struct rte_vdev_device *vdev,
-		     struct rte_crypto_vdev_init_params *init_params)
+cryptodev_zuc_create(const char *name,
+		struct rte_vdev_device *vdev,
+		struct rte_crypto_vdev_init_params *init_params)
 {
 	struct rte_cryptodev *dev;
 	struct zuc_private *internals;
 	uint64_t cpu_flags = 0;
 
-	if (init_params->name[0] == '\0') {
-		int ret = rte_cryptodev_pmd_create_dev_name(
-				init_params->name,
-				RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
-
-		if (ret < 0) {
-			ZUC_LOG_ERR("failed to create unique name");
-			return ret;
-		}
-	}
+	if (init_params->name[0] == '\0')
+		snprintf(init_params->name, sizeof(init_params->name),
+				"%s", name);
 
 	/* Check CPU for supported vector instruction set */
 	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
@@ -529,7 +523,7 @@ cryptodev_zuc_probe(struct rte_vdev_device *vdev)
 	RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
 			init_params.max_nb_sessions);
 
-	return cryptodev_zuc_create(vdev, &init_params);
+	return cryptodev_zuc_create(name, vdev, &init_params);
 }
 
 static int
-- 
2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL
  2017-04-18 14:34 [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL Pablo de Lara
  2017-04-18 14:34 ` [dpdk-dev] [PATCH 2/2] drvers/crypto: do not create unique name internally Pablo de Lara
@ 2017-04-19  9:48 ` Zhang, Roy Fan
  2017-04-19 15:55   ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 6+ messages in thread
From: Zhang, Roy Fan @ 2017-04-19  9:48 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev; +Cc: zbigniew.bodek, jerin.jacob, Doherty, Declan



> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Tuesday, April 18, 2017 3:34 PM
> To: dev@dpdk.org
> Cc: zbigniew.bodek@caviumnetworks.com;
> jerin.jacob@caviumnetworks.com; Doherty, Declan
> <declan.doherty@intel.com>; Zhang, Roy Fan <roy.fan.zhang@intel.com>;
> De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH 1/2] drivers/crypto: check if name is NULL
> 
> Check if virtual device name is NULL,
> to avoid possible segmentation faults.
> 
> Fixes: 5d2aa461cbca ("vdev: use generic vdev struct for probe and remove")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] drvers/crypto: do not create unique name internally
  2017-04-18 14:34 ` [dpdk-dev] [PATCH 2/2] drvers/crypto: do not create unique name internally Pablo de Lara
@ 2017-04-19 10:05   ` Zhang, Roy Fan
  2017-04-19 15:55     ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Roy Fan @ 2017-04-19 10:05 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev; +Cc: zbigniew.bodek, jerin.jacob, Doherty, Declan


> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Tuesday, April 18, 2017 3:34 PM
> To: dev@dpdk.org
> Cc: zbigniew.bodek@caviumnetworks.com;
> jerin.jacob@caviumnetworks.com; Doherty, Declan
> <declan.doherty@intel.com>; Zhang, Roy Fan <roy.fan.zhang@intel.com>;
> De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH 2/2] drvers/crypto: do not create unique name internally
> 
> Crypto devices of the same type could be initialized with the same name,
> since internally this name was suffixed with an index.
> 
> Since commit <dda987315ca2> ("vdev: make virtual bus use its device struct"),
> this is not allowed anymore.
> 
> Therefore, there is no need to create an unique name at device initialization.
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Hi Pablo,

Typo in the title :-), should be drivers/crypto instead of drvers/crypto. Apart from that, everything is fine by me.

Regards,
Fan

Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] drvers/crypto: do not create unique name internally
  2017-04-19 10:05   ` Zhang, Roy Fan
@ 2017-04-19 15:55     ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2017-04-19 15:55 UTC (permalink / raw)
  To: Zhang, Roy Fan, dev; +Cc: zbigniew.bodek, jerin.jacob, Doherty, Declan



> -----Original Message-----
> From: Zhang, Roy Fan
> Sent: Wednesday, April 19, 2017 11:06 AM
> To: De Lara Guarch, Pablo; dev@dpdk.org
> Cc: zbigniew.bodek@caviumnetworks.com;
> jerin.jacob@caviumnetworks.com; Doherty, Declan
> Subject: RE: [PATCH 2/2] drvers/crypto: do not create unique name
> internally
> 
> 
> > -----Original Message-----
> > From: De Lara Guarch, Pablo
> > Sent: Tuesday, April 18, 2017 3:34 PM
> > To: dev@dpdk.org
> > Cc: zbigniew.bodek@caviumnetworks.com;
> > jerin.jacob@caviumnetworks.com; Doherty, Declan
> > <declan.doherty@intel.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>;
> > De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> > Subject: [PATCH 2/2] drvers/crypto: do not create unique name internally
> >
> > Crypto devices of the same type could be initialized with the same name,
> > since internally this name was suffixed with an index.
> >
> > Since commit <dda987315ca2> ("vdev: make virtual bus use its device
> struct"),
> > this is not allowed anymore.
> >
> > Therefore, there is no need to create an unique name at device
> initialization.
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
> Hi Pablo,
> 
> Typo in the title :-), should be drivers/crypto instead of drvers/crypto. Apart
> from that, everything is fine by me.
> 
> Regards,
> Fan
> 
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

Title fixed, thanks!

Applied to dpdk-next-crypto.

Pablo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL
  2017-04-19  9:48 ` [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL Zhang, Roy Fan
@ 2017-04-19 15:55   ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2017-04-19 15:55 UTC (permalink / raw)
  To: Zhang, Roy Fan, dev; +Cc: zbigniew.bodek, jerin.jacob, Doherty, Declan



> -----Original Message-----
> From: Zhang, Roy Fan
> Sent: Wednesday, April 19, 2017 10:48 AM
> To: De Lara Guarch, Pablo; dev@dpdk.org
> Cc: zbigniew.bodek@caviumnetworks.com;
> jerin.jacob@caviumnetworks.com; Doherty, Declan
> Subject: RE: [PATCH 1/2] drivers/crypto: check if name is NULL
> 
> 
> 
> > -----Original Message-----
> > From: De Lara Guarch, Pablo
> > Sent: Tuesday, April 18, 2017 3:34 PM
> > To: dev@dpdk.org
> > Cc: zbigniew.bodek@caviumnetworks.com;
> > jerin.jacob@caviumnetworks.com; Doherty, Declan
> > <declan.doherty@intel.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>;
> > De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> > Subject: [PATCH 1/2] drivers/crypto: check if name is NULL
> >
> > Check if virtual device name is NULL,
> > to avoid possible segmentation faults.
> >
> > Fixes: 5d2aa461cbca ("vdev: use generic vdev struct for probe and
> remove")
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

Applied to dpdk-next-crypto.

Pablo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-19 15:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-18 14:34 [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL Pablo de Lara
2017-04-18 14:34 ` [dpdk-dev] [PATCH 2/2] drvers/crypto: do not create unique name internally Pablo de Lara
2017-04-19 10:05   ` Zhang, Roy Fan
2017-04-19 15:55     ` De Lara Guarch, Pablo
2017-04-19  9:48 ` [dpdk-dev] [PATCH 1/2] drivers/crypto: check if name is NULL Zhang, Roy Fan
2017-04-19 15:55   ` De Lara Guarch, Pablo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).