From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B8861A00C3; Thu, 3 Feb 2022 17:05:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28002411CB; Thu, 3 Feb 2022 17:05:39 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id DE9AD40151 for ; Thu, 3 Feb 2022 17:05:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643904338; x=1675440338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3bgkLAFpEZq2aXGsIezyDZKTHyv2xXsjHFc1vVi8W9c=; b=IxZOusks9U+yXA+fawWAINleXiEHmpxLxr+URsiXVSL/ojdMIf4RJwwW 3g7FbWgfYsmTPZDoKBhLNJfYE5LwNTCpvXm/j1RzGLCtMTw80e/8lgKQ0 bAOst/j7fx6xN6qikFG3T9Rr10OVb5QuafZudb73OKhERfXeMgRfCGWEB 9+WYD/12YPd9WKQcVuftoSE+yEvRpUwvfC6dLFUMl6RSKJpn0pnmWyZ/s RgiKWPrzyRjMhc5baC+57sB+qBHHyEOoAqSNpJvCt+lHp94LTfJERvU08 Lt6gj4HtFhhlPlJxImAuU0ZCObdidOgqa82xq6wbTBiVKA45ORxN44OBy Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="308902117" X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="308902117" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 08:05:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="523972065" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.222.49]) by orsmga007.jf.intel.com with ESMTP; 03 Feb 2022 08:05:34 -0800 From: Ciara Power To: dev@dpdk.org Cc: roy.fan.zhang@intel.com, gakhil@marvell.com, anoobj@marvell.com, mdr@ashroe.eu, Ciara Power , Declan Doherty Subject: [PATCH v3 2/4] crypto: hide asym session structure Date: Thu, 3 Feb 2022 16:04:47 +0000 Message-Id: <20220203160449.1638311-3-ciara.power@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220203160449.1638311-1-ciara.power@intel.com> References: <20220203160449.1638311-1-ciara.power@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The rte_cryptodev_asym_session structure is now moved to an internal header. This will no longer be used directly by apps, private session data can be accessed via get API. Signed-off-by: Ciara Power Acked-by: Fan Zhang --- v3: - Removed the incorrect use of void * for asym session in drivers, these are internal and can use the struct directly as before. - Fixed other internal functions and comments that were incorrectly changed to use void *sess. - Added documentation. --- app/test-crypto-perf/cperf_ops.c | 2 +- app/test/test_cryptodev_asym.c | 34 ++++++++++++------------- doc/guides/prog_guide/cryptodev_lib.rst | 7 +++-- doc/guides/rel_notes/release_22_03.rst | 3 ++- lib/cryptodev/cryptodev_pmd.h | 13 ++++++++++ lib/cryptodev/rte_cryptodev.c | 7 +++-- lib/cryptodev/rte_cryptodev.h | 17 +++---------- lib/cryptodev/rte_cryptodev_trace.h | 4 +-- 8 files changed, 46 insertions(+), 41 deletions(-) diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index bdc5dc9544..948dc0f608 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -21,7 +21,7 @@ cperf_set_ops_asym(struct rte_crypto_op **ops, uint64_t *tsc_start __rte_unused) { uint16_t i; - struct rte_cryptodev_asym_session *asym_sess = (void *)sess; + void *asym_sess = (void *)sess; for (i = 0; i < nb_ops; i++) { struct rte_crypto_asym_op *asym_op = ops[i]->asym; diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index f7c2fd2588..f93f39af42 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -44,7 +44,7 @@ struct crypto_testsuite_params_asym { }; struct crypto_unittest_params { - struct rte_cryptodev_asym_session *sess; + void *sess; struct rte_crypto_op *op; }; @@ -65,7 +65,7 @@ static uint32_t test_index; static struct crypto_testsuite_params_asym testsuite_params = { NULL }; static int -queue_ops_rsa_sign_verify(struct rte_cryptodev_asym_session *sess) +queue_ops_rsa_sign_verify(void *sess) { struct crypto_testsuite_params_asym *ts_params = &testsuite_params; struct rte_mempool *op_mpool = ts_params->op_mpool; @@ -156,7 +156,7 @@ queue_ops_rsa_sign_verify(struct rte_cryptodev_asym_session *sess) } static int -queue_ops_rsa_enc_dec(struct rte_cryptodev_asym_session *sess) +queue_ops_rsa_enc_dec(void *sess) { struct crypto_testsuite_params_asym *ts_params = &testsuite_params; struct rte_mempool *op_mpool = ts_params->op_mpool; @@ -308,7 +308,7 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params, struct rte_crypto_op *op = NULL; struct rte_crypto_op *result_op = NULL; struct rte_crypto_asym_xform xform_tc; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; struct rte_cryptodev_asym_capability_idx cap_idx; const struct rte_cryptodev_asymmetric_xform_capability *capability; uint8_t dev_id = ts_params->valid_devs[0]; @@ -644,7 +644,7 @@ test_rsa_sign_verify(void) struct crypto_testsuite_params_asym *ts_params = &testsuite_params; struct rte_mempool *sess_mpool = ts_params->session_mpool; uint8_t dev_id = ts_params->valid_devs[0]; - struct rte_cryptodev_asym_session *sess; + void *sess; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -685,7 +685,7 @@ test_rsa_enc_dec(void) struct crypto_testsuite_params_asym *ts_params = &testsuite_params; struct rte_mempool *sess_mpool = ts_params->session_mpool; uint8_t dev_id = ts_params->valid_devs[0]; - struct rte_cryptodev_asym_session *sess; + void *sess; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -726,7 +726,7 @@ test_rsa_sign_verify_crt(void) struct crypto_testsuite_params_asym *ts_params = &testsuite_params; struct rte_mempool *sess_mpool = ts_params->session_mpool; uint8_t dev_id = ts_params->valid_devs[0]; - struct rte_cryptodev_asym_session *sess; + void *sess; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -767,7 +767,7 @@ test_rsa_enc_dec_crt(void) struct crypto_testsuite_params_asym *ts_params = &testsuite_params; struct rte_mempool *sess_mpool = ts_params->session_mpool; uint8_t dev_id = ts_params->valid_devs[0]; - struct rte_cryptodev_asym_session *sess; + void *sess; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -1049,7 +1049,7 @@ test_dh_gen_shared_sec(struct rte_crypto_asym_xform *xfrm) uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_asym_op *asym_op = NULL; struct rte_crypto_op *op = NULL, *result_op = NULL; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; uint8_t output[TEST_DH_MOD_LEN]; struct rte_crypto_asym_xform xform = *xfrm; @@ -1134,7 +1134,7 @@ test_dh_gen_priv_key(struct rte_crypto_asym_xform *xfrm) uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_asym_op *asym_op = NULL; struct rte_crypto_op *op = NULL, *result_op = NULL; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; uint8_t output[TEST_DH_MOD_LEN]; struct rte_crypto_asym_xform xform = *xfrm; @@ -1217,7 +1217,7 @@ test_dh_gen_pub_key(struct rte_crypto_asym_xform *xfrm) uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_asym_op *asym_op = NULL; struct rte_crypto_op *op = NULL, *result_op = NULL; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; uint8_t output[TEST_DH_MOD_LEN]; struct rte_crypto_asym_xform xform = *xfrm; @@ -1308,7 +1308,7 @@ test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm) uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_asym_op *asym_op = NULL; struct rte_crypto_op *op = NULL, *result_op = NULL; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; uint8_t out_pub_key[TEST_DH_MOD_LEN]; uint8_t out_prv_key[TEST_DH_MOD_LEN]; @@ -1397,7 +1397,7 @@ test_mod_inv(void) uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_asym_op *asym_op = NULL; struct rte_crypto_op *op = NULL, *result_op = NULL; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; struct rte_cryptodev_asym_capability_idx cap_idx; const struct rte_cryptodev_asymmetric_xform_capability *capability; @@ -1512,7 +1512,7 @@ test_mod_exp(void) uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_asym_op *asym_op = NULL; struct rte_crypto_op *op = NULL, *result_op = NULL; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; struct rte_cryptodev_asym_capability_idx cap_idx; const struct rte_cryptodev_asymmetric_xform_capability *capability; @@ -1663,7 +1663,7 @@ test_dsa_sign(void) uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_asym_op *asym_op = NULL; struct rte_crypto_op *op = NULL, *result_op = NULL; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; uint8_t r[TEST_DH_MOD_LEN]; uint8_t s[TEST_DH_MOD_LEN]; @@ -1796,7 +1796,7 @@ test_ecdsa_sign_verify(enum curve curve_id) struct rte_mempool *sess_mpool = ts_params->session_mpool; struct rte_mempool *op_mpool = ts_params->op_mpool; struct crypto_testsuite_ecdsa_params input_params; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_op *result_op = NULL; uint8_t output_buf_r[TEST_DATA_SIZE]; @@ -2000,7 +2000,7 @@ test_ecpm(enum curve curve_id) struct rte_mempool *sess_mpool = ts_params->session_mpool; struct rte_mempool *op_mpool = ts_params->op_mpool; struct crypto_testsuite_ecpm_params input_params; - struct rte_cryptodev_asym_session *sess = NULL; + void *sess = NULL; uint8_t dev_id = ts_params->valid_devs[0]; struct rte_crypto_op *result_op = NULL; uint8_t output_buf_x[TEST_DATA_SIZE]; diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst index f8f8562f4c..56b19da3ae 100644 --- a/doc/guides/prog_guide/cryptodev_lib.rst +++ b/doc/guides/prog_guide/cryptodev_lib.rst @@ -1213,8 +1213,11 @@ crypto operations is similar except change to respective op and xform setup). } } }; - /* Create asym crypto session and initialize it for the crypto device. */ - struct rte_cryptodev_asym_session *asym_session; + /* + * Create asym crypto session and initialize it for the crypto device. + * The session structure is hidden from the app, so void * is used. + */ + void *asym_session; asym_session = rte_cryptodev_asym_session_create(asym_session_pool, cdev_id, &modex_xform); if (asym_session == NULL) diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index de8d8ce4e9..c4a25f54cd 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -100,7 +100,8 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= -* cryptodev: The asym session handling was modified to use a single buffer. +* cryptodev: The asym session handling was modified to use a single buffer, + and moved to ``cryptodev_pmd.h``, hiding it from applications. A ``rte_cryptodev_asym_session_pool_create`` function was added to create a mempool with element size to hold the generic asym session header, along with the max size for a device private session data. diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index 474d447496..d21db89837 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -627,6 +627,19 @@ set_sym_session_private_data(struct rte_cryptodev_sym_session *sess, sess->sess_data[driver_id].data = private_data; } +/** + * @internal + * Cryptodev asymmetric crypto session. + */ +__extension__ struct rte_cryptodev_asym_session { + uint8_t driver_id; + /**< Session driver ID. */ + uint16_t max_priv_session_sz; + /**< Size of private session data used when creating mempool */ + uint8_t padding[5]; + uint8_t sess_private_data[0]; +}; + static inline void * get_asym_session_private_data(struct rte_cryptodev_asym_session *sess) { diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index d260f79bbc..a839abe34d 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -1908,7 +1908,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp) return sess; } -struct rte_cryptodev_asym_session * +void * rte_cryptodev_asym_session_create(struct rte_mempool *mp, uint8_t dev_id, struct rte_crypto_asym_xform *xforms) { @@ -2015,8 +2015,7 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, } int -rte_cryptodev_asym_session_clear(uint8_t dev_id, - struct rte_cryptodev_asym_session *sess) +rte_cryptodev_asym_session_clear(uint8_t dev_id, void *sess) { struct rte_cryptodev *dev; @@ -2062,7 +2061,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) } int -rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess) +rte_cryptodev_asym_session_free(void *sess) { struct rte_mempool *sess_mp; diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index 8bd85f1575..af328de896 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -918,16 +918,6 @@ struct rte_cryptodev_sym_session { /**< Driver specific session material, variable size */ }; -/** Cryptodev asymmetric crypto session */ -__extension__ struct rte_cryptodev_asym_session { - uint8_t driver_id; - /**< Session driver ID. */ - uint16_t max_priv_session_sz; - /**< Size of private session data used when creating mempool */ - uint8_t padding[5]; - uint8_t sess_private_data[0]; -}; - /** * Create a symmetric session mempool. * @@ -1008,7 +998,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mempool); * - On failure returns NULL */ __rte_experimental -struct rte_cryptodev_asym_session * +void * rte_cryptodev_asym_session_create(struct rte_mempool *mempool, uint8_t dev_id, struct rte_crypto_asym_xform *xforms); @@ -1039,7 +1029,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess); */ __rte_experimental int -rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess); +rte_cryptodev_asym_session_free(void *sess); /** * Fill out private data for the device id, based on its device type. @@ -1092,8 +1082,7 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, */ __rte_experimental int -rte_cryptodev_asym_session_clear(uint8_t dev_id, - struct rte_cryptodev_asym_session *sess); +rte_cryptodev_asym_session_clear(uint8_t dev_id, void *sess); /** * Get the size of the header session, for all registered drivers excluding diff --git a/lib/cryptodev/rte_cryptodev_trace.h b/lib/cryptodev/rte_cryptodev_trace.h index befbaf7f44..82ef876c72 100644 --- a/lib/cryptodev/rte_cryptodev_trace.h +++ b/lib/cryptodev/rte_cryptodev_trace.h @@ -96,7 +96,7 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_cryptodev_trace_asym_session_create, RTE_TRACE_POINT_ARGS(void *mempool, - struct rte_cryptodev_asym_session *sess), + void *sess), rte_trace_point_emit_ptr(mempool); rte_trace_point_emit_ptr(sess); ) @@ -109,7 +109,7 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_cryptodev_trace_asym_session_free, - RTE_TRACE_POINT_ARGS(struct rte_cryptodev_asym_session *sess), + RTE_TRACE_POINT_ARGS(void *sess), rte_trace_point_emit_ptr(sess); ) -- 2.25.1