Skip to contentSkip to conversation

cryptodev: change device configuration API

PATCH Applied Fan Zhang 4 participants 10 messages Feb 17, 2017 – Mar 27, 2017 Crypto API

lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

cover cryptodev: change device configuration API

This patchset changes the cryptodev library's device configuration API and updates all crypto PMD to comply with this change.

Fan Zhang (3):
cryptodev: change device configuration API
crypto/scheduler: improve slave configuration
doc: remove deprecation notice

 app/test/test_cryptodev.c                      | 24 +-----------------------
 doc/guides/rel_notes/deprecation.rst           |  4 ----
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c   |  3 ++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c |  3 ++-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c       |  3 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c     |  3 ++-
 drivers/crypto/null/null_crypto_pmd_ops.c      |  3 ++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c   |  3 ++-
 drivers/crypto/qat/qat_crypto.c                |  5 +++--
 drivers/crypto/qat/qat_crypto.h                |  3 ++-
 drivers/crypto/scheduler/scheduler_pmd_ops.c   | 20 +++++++++++++++-----
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c     |  3 ++-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c           |  3 ++-
 lib/librte_cryptodev/rte_cryptodev.c           |  8 +++++++-
 lib/librte_cryptodev/rte_cryptodev_pmd.h       |  4 +++-
 15 files changed, 47 insertions(+), 45 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/3 cryptodev: change device configuration API

This patch changes the device configuration API for rte_cryptodev_ops function prototype, and update all cryptodev PMDs for this change.

---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c   | 3 ++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c | 3 ++-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c       | 3 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c     | 3 ++-
 drivers/crypto/null/null_crypto_pmd_ops.c      | 3 ++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c   | 3 ++-
 drivers/crypto/qat/qat_crypto.c                | 5 +++--
 drivers/crypto/qat/qat_crypto.h                | 3 ++-
 drivers/crypto/scheduler/scheduler_pmd_ops.c   | 6 ++++--
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c     | 3 ++-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c           | 3 ++-
 lib/librte_cryptodev/rte_cryptodev.c           | 8 +++++++-
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 4 +++-
 13 files changed, 35 insertions(+), 15 deletions(-)
drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c +2 -1
index 2362006..7e7e477 100644
@@ -114,7 +114,8 @@ static const struct rte_cryptodev_capabilities aesni_gcm_pmd_capabilities[] = {
 
 /** Configure device */
 static int
-aesni_gcm_pmd_config(__rte_unused struct rte_cryptodev *dev)
+aesni_gcm_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c +2 -1
index 3d49e2a..b08bf05 100644
@@ -233,7 +233,8 @@ static const struct rte_cryptodev_capabilities aesni_mb_pmd_capabilities[] = {
 
 /** Configure device */
 static int
-aesni_mb_pmd_config(__rte_unused struct rte_cryptodev *dev)
+aesni_mb_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
drivers/crypto/armv8/rte_armv8_pmd_ops.c +2 -1
index 2bf6475..78c0b4e 100644
@@ -111,7 +111,8 @@ static const struct rte_cryptodev_capabilities
 
 /** Configure device */
 static int
-armv8_crypto_pmd_config(__rte_unused struct rte_cryptodev *dev)
+armv8_crypto_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
drivers/crypto/kasumi/rte_kasumi_pmd_ops.c +2 -1
index b9285a4..40997d6 100644
@@ -89,7 +89,8 @@ static const struct rte_cryptodev_capabilities kasumi_pmd_capabilities[] = {
 
 /** Configure device */
 static int
-kasumi_pmd_config(__rte_unused struct rte_cryptodev *dev)
+kasumi_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
drivers/crypto/null/null_crypto_pmd_ops.c +2 -1
index 26ff631..801b5f9 100644
@@ -85,7 +85,8 @@ static const struct rte_cryptodev_capabilities null_crypto_pmd_capabilities[] =
 
 /** Configure device */
 static int
-null_crypto_pmd_config(__rte_unused struct rte_cryptodev *dev)
+null_crypto_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
drivers/crypto/openssl/rte_openssl_pmd_ops.c +2 -1
index 875550c..03b053e 100644
@@ -449,7 +449,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
 
 /** Configure device */
 static int
-openssl_pmd_config(__rte_unused struct rte_cryptodev *dev)
+openssl_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
drivers/crypto/qat/qat_crypto.c +3 -2
index 43e1d00..67cb8f8 100644
@@ -1326,10 +1326,11 @@ void qat_crypto_sym_session_init(struct rte_mempool *mp, void *sym_sess)
 		offsetof(struct rte_cryptodev_sym_session, _private);
 }
 
-int qat_dev_config(__rte_unused struct rte_cryptodev *dev)
+int qat_dev_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	PMD_INIT_FUNC_TRACE();
-	return -ENOTSUP;
+	return 0;
 }
 
 int qat_dev_start(__rte_unused struct rte_cryptodev *dev)
drivers/crypto/qat/qat_crypto.h +2 -1
index 5766817..78bb2bc 100644
@@ -85,7 +85,8 @@ struct qat_pmd_private {
 	/**< Max number of sessions supported by device */
 };
 
-int qat_dev_config(struct rte_cryptodev *dev);
+int qat_dev_config(struct rte_cryptodev *dev,
+		struct rte_cryptodev_config *config);
 int qat_dev_start(struct rte_cryptodev *dev);
 void qat_dev_stop(struct rte_cryptodev *dev);
 int qat_dev_close(struct rte_cryptodev *dev);
drivers/crypto/scheduler/scheduler_pmd_ops.c +4 -2
index 56624c7..79be119 100644
@@ -43,7 +43,8 @@
 
 /** Configure device */
 static int
-scheduler_pmd_config(struct rte_cryptodev *dev)
+scheduler_pmd_config(struct rte_cryptodev *dev,
+		struct rte_cryptodev_config *config)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	uint32_t i;
@@ -54,7 +55,8 @@ scheduler_pmd_config(struct rte_cryptodev *dev)
 		struct rte_cryptodev *slave_dev =
 				rte_cryptodev_pmd_get_dev(slave_dev_id);
 
-		ret = (*slave_dev->dev_ops->dev_configure)(slave_dev);
+		ret = (*slave_dev->dev_ops->dev_configure)(slave_dev,
+				config);
 		if (ret < 0)
 			break;
 	}
drivers/crypto/snow3g/rte_snow3g_pmd_ops.c +2 -1
index 4602dfd..14179c2 100644
@@ -89,7 +89,8 @@ static const struct rte_cryptodev_capabilities snow3g_pmd_capabilities[] = {
 
 /** Configure device */
 static int
-snow3g_pmd_config(__rte_unused struct rte_cryptodev *dev)
+snow3g_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
drivers/crypto/zuc/rte_zuc_pmd_ops.c +2 -1
index 2c886d5..1bd7dde 100644
@@ -89,7 +89,8 @@ static const struct rte_cryptodev_capabilities zuc_pmd_capabilities[] = {
 
 /** Configure device */
 static int
-zuc_pmd_config(__rte_unused struct rte_cryptodev *dev)
+zuc_pmd_config(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused struct rte_cryptodev_config *config)
 {
 	return 0;
 }
lib/librte_cryptodev/rte_cryptodev.c +7 -1
index a64320e..ff7deb9 100644
@@ -917,6 +917,8 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		return -EBUSY;
 	}
 
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
+
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
 			config->socket_id);
@@ -927,10 +929,14 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 	}
 
 	/* Setup Session mempool for device */
-	return rte_cryptodev_sym_session_pool_create(dev,
+	diag = rte_cryptodev_sym_session_pool_create(dev,
 			config->session_mp.nb_objs,
 			config->session_mp.cache_size,
 			config->socket_id);
+	if (diag != 0)
+		return diag;
+
+	return (*dev->dev_ops->dev_configure)(dev, config);
 }
 
 
lib/librte_cryptodev/rte_cryptodev_pmd.h +3 -1
index 1a417e2..8d95dac 100644
@@ -201,10 +201,12 @@ extern struct rte_cryptodev *rte_cryptodevs;
  *	Function used to configure device.
  *
  * @param	dev	Crypto device pointer
+ *		config	Crypto device configurations
  *
  * @return	Returns 0 on success
  */
-typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev);
+typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev,
+		struct rte_cryptodev_config *config);
 
 /**
  * Function used to start a configured device.
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 2/3 crypto/scheduler: improve slave configuration

In reply to Fan Zhang

Since the new device configuration API is updated, we can make use of this feature to the crypto scheduler PMD to configure its slaves automatically with the same configurations it got. As originally the slaves have to be manually configured one by one, this patch should help reducing the coding complexity.

---
 app/test/test_cryptodev.c                    | 24 +-----------------------
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 28 deletions(-)
app/test/test_cryptodev.c +1 -23
index 357a92e..6fe5362 100644
@@ -7382,17 +7382,8 @@ test_scheduler_attach_slave_op(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t sched_id = ts_params->valid_devs[0];
-	uint32_t nb_devs, qp_id, i, nb_devs_attached = 0;
+	uint32_t nb_devs, i, nb_devs_attached = 0;
 	int ret;
-	struct rte_cryptodev_config config = {
-			.nb_queue_pairs = 8,
-			.socket_id = SOCKET_ID_ANY,
-			.session_mp = {
-				.nb_objs = 2048,
-				.cache_size = 256
-			}
-	};
-	struct rte_cryptodev_qp_conf qp_conf = {2048};
 
 	/* create 2 AESNI_MB if necessary */
 	nb_devs = rte_cryptodev_count_devtype(
@@ -7418,19 +7409,6 @@ test_scheduler_attach_slave_op(void)
 		if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
 			continue;
 
-		ret = rte_cryptodev_configure(i, &config);
-		TEST_ASSERT(ret == 0,
-			"Failed to configure device %u of pmd : %s", i,
-			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
-
-		for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
-			TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
-				i, qp_id, &qp_conf,
-				rte_cryptodev_socket_id(i)),
-				"Failed to setup queue pair %u on "
-				"cryptodev %u", qp_id, i);
-		}
-
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
drivers/crypto/scheduler/scheduler_pmd_ops.c +13 -5
index 79be119..ea755e0 100644
@@ -52,11 +52,8 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
-		struct rte_cryptodev *slave_dev =
-				rte_cryptodev_pmd_get_dev(slave_dev_id);
 
-		ret = (*slave_dev->dev_ops->dev_configure)(slave_dev,
-				config);
+		ret = rte_cryptodev_configure(slave_dev_id, config);
 		if (ret < 0)
 			break;
 	}
@@ -340,11 +337,13 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 /** Setup a queue pair */
 static int
 scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
-	__rte_unused const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	struct scheduler_qp_ctx *qp_ctx;
 	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	uint32_t i;
+	int ret;
 
 	if (snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN,
 			"CRYTO_SCHE PMD %u QP %u",
@@ -357,6 +356,15 @@ scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (dev->data->queue_pairs[qp_id] != NULL)
 		scheduler_pmd_qp_release(dev, qp_id);
 
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		uint8_t slave_id = sched_ctx->slaves[i].dev_id;
+
+		ret = rte_cryptodev_queue_pair_setup(slave_id, qp_id,
+				qp_conf, socket_id);
+		if (ret < 0)
+			return ret;
+	}
+
 	/* Allocate the queue pair data structure. */
 	qp_ctx = rte_zmalloc_socket(name, sizeof(*qp_ctx), RTE_CACHE_LINE_SIZE,
 			socket_id);
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH 3/3 doc: remove deprecation notice

In reply to Fan Zhang
---
 doc/guides/rel_notes/deprecation.rst | 4 ----
 1 file changed, 4 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -4
index 9d4dfcc..3e17b20 100644
@@ -119,10 +119,6 @@ Deprecation Notices
   or VHOST feature, but KNI_VHOST which is a KNI feature enabled via a compile
   time option, and disabled by default.
 
-* ABI changes are planned for 17.05 in the ``rte_cryptodev_ops`` structure.
-  A pointer to a rte_cryptodev_config structure will be added to the
-  function prototype ``cryptodev_configure_t``, as a new parameter.
-
 * cryptodev: A new parameter ``max_nb_sessions_per_qp`` will be added to
   ``rte_cryptodev_info.sym``. Some drivers may support limited number of
   sessions per queue_pair. With this new parameter application will know
Signature · 1 line
2.7.4
Acked-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] crypto/scheduler: improve slave configuration

In reply to Fan Zhang
Quoted 8 lines · Fan Zhang

Since the new device configuration API is updated, we can make use of this feature to the crypto scheduler PMD to configure its slaves automatically with the same configurations it got. As originally the slaves have to be manually configured one by one, this patch should help reducing the coding complexity.

---

...

Quoted 1 line
#5 lore raw

Re: [PATCH 2/3] crypto/scheduler: improve slave configuration

In reply to Fan Zhang
Quoted 8 lines · Fan Zhang

Since the new device configuration API is updated, we can make use of this feature to the crypto scheduler PMD to configure its slaves automatically with the same configurations it got. As originally the slaves have to be manually configured one by one, this patch should help reducing the coding complexity.

---

...

Quoted 1 line

This patch needs to rebased due to the movement of app/test/ to test/test

#6 lore raw

Re: [PATCH 2/3] crypto/scheduler: improve slave configuration

Quoted 17 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Thursday, March 23, 2017 3:10 PM
To: Zhang, Roy Fan; [email protected]
Cc: De Lara Guarch, Pablo
Subject: Re: [dpdk-dev] [PATCH 2/3] crypto/scheduler: improve slave configuration

Quoted 6 lines · Fan Zhang

Since the new device configuration API is updated, we can make use of this feature to the crypto scheduler PMD to configure its slaves automatically with the same configurations it got. As originally the slaves have to be manually configured one by one, this patch should help reducing the coding complexity.

Quoted 6 lines
Quoted 2 lines

---

...

Quoted 1 line

This patch needs to rebased due to the movement of app/test/ to test/test

If there are no reworks required, I can do that myself when merging.

#9 lore raw
In reply to Fan Zhang
Quoted 35 lines

-----Original Message-----
From: Zhang, Roy Fan
Sent: Friday, February 17, 2017 12:01 PM
To: [email protected]
Cc: De Lara Guarch, Pablo
Subject: [PATCH 0/3] cryptodev: change device configuration API

This patchset changes the cryptodev library's device configuration API and updates all crypto PMD to comply with this change.

Fan Zhang (3):
cryptodev: change device configuration API
crypto/scheduler: improve slave configuration
doc: remove deprecation notice

 app/test/test_cryptodev.c                      | 24 +-----------------------
 doc/guides/rel_notes/deprecation.rst           |  4 ----
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c   |  3 ++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c |  3 ++-
 drivers/crypto/armv8/rte_armv8_pmd_ops.c       |  3 ++-
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c     |  3 ++-
 drivers/crypto/null/null_crypto_pmd_ops.c      |  3 ++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c   |  3 ++-
 drivers/crypto/qat/qat_crypto.c                |  5 +++--
 drivers/crypto/qat/qat_crypto.h                |  3 ++-
 drivers/crypto/scheduler/scheduler_pmd_ops.c   | 20 +++++++++++++++--
---
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c     |  3 ++-
 drivers/crypto/zuc/rte_zuc_pmd_ops.c           |  3 ++-
 lib/librte_cryptodev/rte_cryptodev.c           |  8 +++++++-
 lib/librte_cryptodev/rte_cryptodev_pmd.h       |  4 +++-
 15 files changed, 47 insertions(+), 45 deletions(-)
Quoted 2 lines

--
2.7.4

Applied to dpdk-next-crypto.
Thanks,

Pablo