From a106fcce2cfed0fdee7922594e3199d28dfcce59 Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Mon, 21 May 2018 14:08:41 +0100 Subject: [PATCH] cryptodev: rename functions to get session size rte_cryptodev_get_header_session_size() and rte_cryptodev_get_private_session_size() functions are targeting symmetric sessions. With the future addition of asymmetric operations, these functions need to be renamed from *cryptodev_*_session_* to *cryptodev_sym_*_session_* to be symmetric specific. The two original functions are marked as deprecated and will be removed in 18.08, so applications can still use the functions in 18.05. Signed-off-by: Pablo de Lara Acked-by: Shally Verma Acked-by: Fiona Trahe Acked-by: Deepak Kumar Jain --- app/test-crypto-perf/main.c | 2 +- doc/guides/prog_guide/cryptodev_lib.rst | 6 ++--- doc/guides/rel_notes/deprecation.rst | 6 +++++ 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/openssl/rte_openssl_pmd.c | 2 +- drivers/crypto/snow3g/rte_snow3g_pmd.c | 2 +- drivers/crypto/zuc/rte_zuc_pmd.c | 2 +- examples/ipsec-secgw/ipsec-secgw.c | 2 +- examples/l2fwd-crypto/main.c | 2 +- examples/vhost_crypto/main.c | 2 +- lib/librte_cryptodev/rte_cryptodev.c | 12 +++++++++ lib/librte_cryptodev/rte_cryptodev.h | 27 +++++++++++++++++++ .../rte_cryptodev_version.map | 8 ++++++ test/test/test_cryptodev.c | 6 +++-- test/test/test_event_crypto_adapter.c | 2 +- 18 files changed, 72 insertions(+), 17 deletions(-) diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 26e78ff43a..4ae14390b1 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -97,7 +97,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs, uint32_t max_sess_size = 0, sess_size; for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) { - sess_size = rte_cryptodev_get_private_session_size(cdev_id); + sess_size = rte_cryptodev_sym_get_private_session_size(cdev_id); if (sess_size > max_sess_size) max_sess_size = sess_size; } diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst index b279a20e5f..30f0bcf7a8 100644 --- a/doc/guides/prog_guide/cryptodev_lib.rst +++ b/doc/guides/prog_guide/cryptodev_lib.rst @@ -454,12 +454,12 @@ mempool for all crypto devices (where the mempool object size is big enough to hold the private session of any crypto device), as well as having multiple session mempools of different sizes for better memory usage. -An application can use ``rte_cryptodev_get_private_session_size()`` to +An application can use ``rte_cryptodev_sym_get_private_session_size()`` to get the private session size of given crypto device. This function would allow an application to calculate the max device session size of all crypto devices to create a single session mempool. If instead an application creates multiple session mempools, the Crypto device -framework also provides ``rte_cryptodev_get_header_session_size`` to get +framework also provides ``rte_cryptodev_sym_get_header_session_size`` to get the size of an uninitialized session. Once the session mempools have been created, ``rte_cryptodev_sym_session_create()`` @@ -662,7 +662,7 @@ using one of the crypto PMDs available in DPDK. uint8_t cdev_id = rte_cryptodev_get_dev_id(crypto_name); /* Get private session data size. */ - session_size = rte_cryptodev_get_private_session_size(cdev_id); + session_size = rte_cryptodev_sym_get_private_session_size(cdev_id); /* * Create session mempool, with two objects per session, diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 2819b48644..1e2443c76d 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -90,3 +90,9 @@ Deprecation Notices with them. - Some feature flags such as ``RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER`` are ambiguous, so some will be replaced by more explicit flags. + - Function ``rte_cryptodev_get_header_session_size()`` will be deprecated + in 18.05, and it gets replaced with ``rte_cryptodev_sym_get_header_session_size()``. + It will be removed in 18.08. + - Function ``rte_cryptodev_get_private_session_size()`` will be deprecated + in 18.05, and it gets replaced with ``rte_cryptodev_sym_get_private_session_size()``. + It will be removed in 18.08. diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c index bc5ee1b73f..80360dd9c2 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c @@ -392,7 +392,7 @@ handle_completed_gcm_crypto_op(struct aesni_gcm_qp *qp, if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { memset(sess, 0, sizeof(struct aesni_gcm_session)); memset(op->sym->session, 0, - rte_cryptodev_get_header_session_size()); + rte_cryptodev_sym_get_header_session_size()); rte_mempool_put(qp->sess_mp, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c index 2e500784dd..bb35c66abb 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c @@ -682,7 +682,7 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job) if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { memset(sess, 0, sizeof(struct aesni_mb_session)); memset(op->sym->session, 0, - rte_cryptodev_get_header_session_size()); + rte_cryptodev_sym_get_header_session_size()); rte_mempool_put(qp->sess_mp, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c index 1fe82ccadc..fbb08f729a 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd.c +++ b/drivers/crypto/armv8/rte_armv8_pmd.c @@ -654,7 +654,7 @@ process_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op, if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { memset(sess, 0, sizeof(struct armv8_crypto_session)); memset(op->sym->session, 0, - rte_cryptodev_get_header_session_size()); + rte_cryptodev_sym_get_header_session_size()); rte_mempool_put(qp->sess_mp, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c index 08ee900511..205dc1de7d 100644 --- a/drivers/crypto/kasumi/rte_kasumi_pmd.c +++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c @@ -320,7 +320,7 @@ process_ops(struct rte_crypto_op **ops, struct kasumi_session *session, if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { memset(session, 0, sizeof(struct kasumi_session)); memset(ops[i]->sym->session, 0, - rte_cryptodev_get_header_session_size()); + rte_cryptodev_sym_get_header_session_size()); rte_mempool_put(qp->sess_mp, session); rte_mempool_put(qp->sess_mp, ops[i]->sym->session); ops[i]->sym->session = NULL; diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index f584d0d6f1..93c6d7e5df 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -1569,7 +1569,7 @@ process_op(struct openssl_qp *qp, struct rte_crypto_op *op, openssl_reset_session(sess); memset(sess, 0, sizeof(struct openssl_session)); memset(op->sym->session, 0, - rte_cryptodev_get_header_session_size()); + rte_cryptodev_sym_get_header_session_size()); rte_mempool_put(qp->sess_mp, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index 5edc0fa0fd..72751e35ef 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -339,7 +339,7 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session, if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { memset(session, 0, sizeof(struct snow3g_session)); memset(ops[i]->sym->session, 0, - rte_cryptodev_get_header_session_size()); + rte_cryptodev_sym_get_header_session_size()); rte_mempool_put(qp->sess_mp, session); rte_mempool_put(qp->sess_mp, ops[i]->sym->session); ops[i]->sym->session = NULL; diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c index cd38f30309..a805b22784 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd.c +++ b/drivers/crypto/zuc/rte_zuc_pmd.c @@ -327,7 +327,7 @@ process_ops(struct rte_crypto_op **ops, enum zuc_operation op_type, if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { memset(sessions[i], 0, sizeof(struct zuc_session)); memset(ops[i]->sym->session, 0, - rte_cryptodev_get_header_session_size()); + rte_cryptodev_sym_get_header_session_size()); rte_mempool_put(qp->sess_mp, sessions[i]); rte_mempool_put(qp->sess_mp, ops[i]->sym->session); ops[i]->sym->session = NULL; diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index c94118ef5b..a5da8b280a 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -1390,7 +1390,7 @@ cryptodevs_init(void) uint32_t max_sess_sz = 0, sess_sz; for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) { - sess_sz = rte_cryptodev_get_private_session_size(cdev_id); + sess_sz = rte_cryptodev_sym_get_private_session_size(cdev_id); if (sess_sz > max_sess_sz) max_sess_sz = sess_sz; } diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index f4e3e0b105..4bca87b194 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1982,7 +1982,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports, } for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) { - sess_sz = rte_cryptodev_get_private_session_size(cdev_id); + sess_sz = rte_cryptodev_sym_get_private_session_size(cdev_id); if (sess_sz > max_sess_sz) max_sess_sz = sess_sz; } diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c index 860200e294..f334d7123e 100644 --- a/examples/vhost_crypto/main.c +++ b/examples/vhost_crypto/main.c @@ -450,7 +450,7 @@ main(int argc, char *argv[]) snprintf(name, 127, "SESS_POOL_%u", worker_lcore); info.sess_pool = rte_mempool_create(name, SESSION_MAP_ENTRIES, - rte_cryptodev_get_private_session_size( + rte_cryptodev_sym_get_private_session_size( cryptodev_id), 64, 0, NULL, NULL, NULL, NULL, rte_lcore_to_socket_id(worker_lcore), 0); if (!info.sess_pool) { diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 2f97ce2e8f..7e58212464 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -1226,6 +1226,12 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) unsigned int rte_cryptodev_get_header_session_size(void) +{ + return rte_cryptodev_sym_get_header_session_size(); +} + +unsigned int +rte_cryptodev_sym_get_header_session_size(void) { /* * Header contains pointers to the private data @@ -1237,6 +1243,12 @@ rte_cryptodev_get_header_session_size(void) unsigned int rte_cryptodev_get_private_session_size(uint8_t dev_id) +{ + return rte_cryptodev_sym_get_private_session_size(dev_id); +} + +unsigned int +rte_cryptodev_sym_get_private_session_size(uint8_t dev_id) { struct rte_cryptodev *dev; unsigned int header_size = sizeof(void *) * nb_drivers; diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 972f11f72d..92ce6d49a2 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -972,15 +972,18 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, struct rte_cryptodev_sym_session *sess); /** + * @deprecated * Get the size of the header session, for all registered drivers. * * @return * Size of the header session. */ +__rte_deprecated unsigned int rte_cryptodev_get_header_session_size(void); /** + * @deprecated * Get the size of the private session data for a device. * * @param dev_id The device identifier. @@ -989,9 +992,33 @@ rte_cryptodev_get_header_session_size(void); * - Size of the private data, if successful * - 0 if device is invalid or does not have private session */ +__rte_deprecated unsigned int rte_cryptodev_get_private_session_size(uint8_t dev_id); +/** + * Get the size of the header session, for all registered drivers. + * + * @return + * Size of the symmetric eader session. + */ +unsigned int +rte_cryptodev_sym_get_header_session_size(void); + +/** + * Get the size of the private symmetric 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 + * symmetric session + */ +unsigned int +rte_cryptodev_sym_get_private_session_size(uint8_t dev_id); + /** * @deprecated * 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 da6905ee67..be8f4c1a70 100644 --- a/lib/librte_cryptodev/rte_cryptodev_version.map +++ b/lib/librte_cryptodev/rte_cryptodev_version.map @@ -86,6 +86,14 @@ DPDK_17.11 { } DPDK_17.08; +DPDK_18.05 { + global: + + rte_cryptodev_sym_get_header_session_size; + rte_cryptodev_sym_get_private_session_size; + +} DPDK_17.11; + EXPERIMENTAL { global: diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index 940e3378a1..389f79677d 100644 --- a/test/test/test_cryptodev.c +++ b/test/test/test_cryptodev.c @@ -428,7 +428,8 @@ testsuite_setup(void) ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs; ts_params->conf.socket_id = SOCKET_ID_ANY; - unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id); + unsigned int session_size = + rte_cryptodev_sym_get_private_session_size(dev_id); /* * Create mempool with maximum number of sessions * 2, @@ -8534,7 +8535,8 @@ test_scheduler_attach_slave_op(void) rte_mempool_free(ts_params->session_mpool); ts_params->session_mpool = NULL; } - unsigned int session_size = rte_cryptodev_get_private_session_size(i); + unsigned int session_size = + rte_cryptodev_sym_get_private_session_size(i); /* * Create mempool with maximum number of sessions * 2, diff --git a/test/test/test_event_crypto_adapter.c b/test/test/test_event_crypto_adapter.c index 6f0e794609..066b0adef1 100644 --- a/test/test/test_event_crypto_adapter.c +++ b/test/test/test_event_crypto_adapter.c @@ -523,7 +523,7 @@ configure_cryptodev(void) * Create mempool with maximum number of sessions * 2, * to include the session headers & private data */ - session_size = rte_cryptodev_get_private_session_size(TEST_CDEV_ID); + session_size = rte_cryptodev_sym_get_private_session_size(TEST_CDEV_ID); session_size += sizeof(union rte_event_crypto_metadata); params.session_mpool = rte_mempool_create( -- 2.20.1