From: Pablo de Lara Date: Thu, 5 Jul 2018 02:08:05 +0000 (+0100) Subject: cryptodev: check if symmetric sessions are supported X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=abd3c70525b296562d08c82ab12217bdd3dbf948;p=dpdk.git cryptodev: check if symmetric sessions are supported Since asymmetric functionality will be implemented soon, not all PMDs must support symmetric sessions. Therefore, a check is added if a device does not implement the symmetric functions, meaning that the device does not support symmetric operations. Signed-off-by: Pablo de Lara Acked-by: Akhil Goyal --- diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 9292f93bbe..0b20f3f700 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -1063,6 +1063,8 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, index = dev->driver_id; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_session_configure, -ENOTSUP); + if (sess->sess_private_data[index] == NULL) { ret = dev->dev_ops->sym_session_configure(dev, xforms, sess, mp); @@ -1107,6 +1109,8 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, if (dev == NULL || sess == NULL) return -EINVAL; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_session_clear, -ENOTSUP); + dev->dev_ops->sym_session_clear(dev, sess); return 0; diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 8fd3045249..94d4b26847 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -891,7 +891,8 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess); * @return * - On success, zero. * - -EINVAL if input parameters are invalid. - * - -ENOTSUP if crypto device does not support the crypto transform. + * - -ENOTSUP if crypto device does not support the crypto transform or + * does not support symmetric operations. * - -ENOMEM if the private session could not be allocated. */ int @@ -912,6 +913,7 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, * @return * - 0 if successful. * - -EINVAL if device is invalid or session is NULL. + * - -ENOTSUP if crypto device does not support symmetric operations. */ int rte_cryptodev_sym_session_clear(uint8_t dev_id,