From 60e686c22394677787411945fe17bfe18ac0e9c7 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Fri, 17 Feb 2017 12:01:00 +0000 Subject: [PATCH] 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. Signed-off-by: Fan Zhang Acked-by: Declan Doherty --- 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 | 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 +++- 14 files changed, 35 insertions(+), 19 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 1df3b461bb..6bf245d8bc 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -76,10 +76,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* 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 diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c index afeb4fb665..1fc047bef3 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c index 0f949191ac..d2bae19df5 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c index 0815fcb3aa..4d9ccbfbc0 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c +++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c index e27bc5cd44..62ebdbd2d5 100644 --- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c +++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c index 4a24537cac..12c946c989 100644 --- a/drivers/crypto/null/null_crypto_pmd_ops.c +++ b/drivers/crypto/null/null_crypto_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 1beba3a4bf..131a37c9b6 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c index 43e1d00f84..67cb8f89a5 100644 --- a/drivers/crypto/qat/qat_crypto.c +++ b/drivers/crypto/qat/qat_crypto.c @@ -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) diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h index 5766817b56..78bb2bcb7b 100644 --- a/drivers/crypto/qat/qat_crypto.h +++ b/drivers/crypto/qat/qat_crypto.h @@ -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); diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c index 287b2fb7de..d72266de9d 100644 --- a/drivers/crypto/scheduler/scheduler_pmd_ops.c +++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c index e0fb3cc028..7ce96be99c 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c @@ -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; } diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c index 0d98313ce3..e793459c75 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c +++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c @@ -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; } diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 0ac23ed855..114dd57127 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -957,6 +957,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); @@ -967,10 +969,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); } diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h index 1a417e22d4..8d95dac934 100644 --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h @@ -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. -- 2.20.1