From e2acaa0a456b3fc3ba4435b0e8742a8d47dd5ae4 Mon Sep 17 00:00:00 2001 From: Slawomir Mrozowicz Date: Wed, 5 Jul 2017 06:26:11 +0100 Subject: [PATCH] cryptodev: add private session size retrieval function Provide a function to get the private session size of any crypto device (specifically, to its crypto driver). This will be useful once the session mempool is created outside the library. Signed-off-by: Slawomir Mrozowicz Signed-off-by: Pablo de Lara Acked-by: Declan Doherty Acked-by: Akhil Goyal --- lib/librte_cryptodev/rte_cryptodev.c | 20 +++++++++++++++++++ lib/librte_cryptodev/rte_cryptodev.h | 12 +++++++++++ .../rte_cryptodev_version.map | 1 + 3 files changed, 33 insertions(+) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index cf444c0be7..5e9f823648 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -1278,6 +1278,26 @@ rte_cryptodev_sym_session_free(uint8_t dev_id, return NULL; } +unsigned int +rte_cryptodev_get_private_session_size(uint8_t dev_id) +{ + struct rte_cryptodev *dev; + unsigned int priv_sess_size; + + if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) + return 0; + + dev = rte_cryptodev_pmd_get_dev(dev_id); + + if (*dev->dev_ops->session_get_size == NULL) + return 0; + + priv_sess_size = (*dev->dev_ops->session_get_size)(dev); + + return priv_sess_size; + +} + /** Initialise rte_crypto_op mempool element */ static void rte_crypto_op_init(struct rte_mempool *mempool, diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 972a3087d7..f7d248b16c 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -941,6 +941,18 @@ extern struct rte_cryptodev_sym_session * rte_cryptodev_sym_session_free(uint8_t dev_id, struct rte_cryptodev_sym_session *session); +/** + * Get the size of the private session data for a device. + * + * @param dev_id The device identifier. + * + * @return + * - Size of the private data, if successful + * - 0 if device is invalid or does not have private session + */ +unsigned int +rte_cryptodev_get_private_session_size(uint8_t dev_id); + /** * Attach queue pair with sym session. * diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map index 3ad7581b63..d817421824 100644 --- a/lib/librte_cryptodev/rte_cryptodev_version.map +++ b/lib/librte_cryptodev/rte_cryptodev_version.map @@ -66,6 +66,7 @@ DPDK_17.08 { rte_cryptodev_driver_id_get; rte_cryptodev_driver_name_get; rte_cryptodev_get_aead_algo_enum; + rte_cryptodev_get_private_session_size; rte_cryptodev_pci_generic_probe; rte_cryptodev_pci_generic_remove; rte_cryptodev_sym_capability_check_aead; -- 2.20.1