From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A8E7C433F5 for ; Thu, 10 Feb 2022 15:54:31 +0000 (UTC) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D342242772; Thu, 10 Feb 2022 16:54:20 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 53ACE42768 for ; Thu, 10 Feb 2022 16:54:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644508458; x=1676044458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tq7j35G7h6wgHmIHZ+mJCopjRXGxsckvZR4rwiuQlgk=; b=CZPbzs3Ew3GbOeZtklFNuBS+jeUf6bTCxTCe8sBCa7Zvm9Noudx2K03T ZtoEt+nmwxzV85lyLGQPdZuuEAoG18olkCd3EyFLRheg3ihfwNqmGEqJM I5ci4mL/KJrpQnzqjGVtwZxF+rsP3XRTVMQxIAaoRb23KyN+JSDPT6JHo m3jXxizv6pt1Axtrpb8bD/twrLtBi8G27lCJBgNWInSbVnqqiFLQh/ACE DCwPmvw4OgMpd+7YK0tKmQz2Wkj/mKYN+JKbI8JpqqfLb8vGbcLrWrkYO Az6ZpgrJQ9D+26jAGq0ZPfEITntqSCyqhbjEXqP9ZczgQotST9rfmxkOJ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10254"; a="229486800" X-IronPort-AV: E=Sophos;i="5.88,359,1635231600"; d="scan'208";a="229486800" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 07:54:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,359,1635231600"; d="scan'208";a="541658632" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.222.49]) by orsmga008.jf.intel.com with ESMTP; 10 Feb 2022 07:54:15 -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 v6 3/5] crypto: hide asym session structure Date: Thu, 10 Feb 2022 15:54:02 +0000 Message-Id: <20220210155404.3598576-4-ciara.power@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210155404.3598576-1-ciara.power@intel.com> References: <20220209153854.2740455-1-ciara.power@intel.com> <20220210155404.3598576-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 Acked-by: Anoob Joseph --- v4: - Initialised session variables as NULL. - Removed docs code additions, these are included due to patch 1 changing sample doc to use literal includes. 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 | 4 +++ doc/guides/rel_notes/release_22_03.rst | 2 ++ lib/cryptodev/cryptodev_pmd.h | 13 ++++++++++ lib/cryptodev/rte_cryptodev.c | 5 ++-- lib/cryptodev/rte_cryptodev.h | 15 ++--------- lib/cryptodev/rte_cryptodev_trace.h | 3 +-- 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index b125c699de..b8f590b397 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 88433faf1c..929d6efb24 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -46,7 +46,7 @@ struct crypto_testsuite_params_asym { }; struct crypto_unittest_params { - struct rte_cryptodev_asym_session *sess; + void *sess; struct rte_crypto_op *op; }; @@ -67,7 +67,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; @@ -158,7 +158,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; @@ -310,7 +310,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 = NULL; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -684,7 +684,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 = NULL; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -724,7 +724,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 = NULL; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -764,7 +764,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 = NULL; struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; @@ -1046,7 +1046,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; @@ -1129,7 +1129,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; @@ -1210,7 +1210,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; @@ -1299,7 +1299,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]; @@ -1386,7 +1386,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; @@ -1499,7 +1499,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; @@ -1648,7 +1648,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]; @@ -1779,7 +1779,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]; @@ -1981,7 +1981,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 b4dbd384bf..2607a9a7d7 100644 --- a/doc/guides/prog_guide/cryptodev_lib.rst +++ b/doc/guides/prog_guide/cryptodev_lib.rst @@ -1155,6 +1155,10 @@ Generate crypto op, create and attach a session, then process packets. :end-before: >8 End of create op, create session, and process packets section. :dedent: 1 +.. note:: + The ``rte_cryptodev_asym_session`` struct is hidden from the application. + The ``sess`` pointer used above is a void pointer. + Asymmetric Crypto Device API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index ea4c5309a0..459b15bdde 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -116,6 +116,8 @@ API Changes mempool object. An API ``rte_cryptodev_asym_session_pool_create`` was added to create a mempool with element size big enough to hold the generic asymmetric session header and max size for a device private session data. + The session structure was moved to ``cryptodev_pmd.h``, + hiding it from applications. The API ``rte_cryptodev_asym_session_init`` was removed as the initialization is now moved to ``rte_cryptodev_asym_session_create``. diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index 142bfb7c66..63f9cf5427 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -625,4 +625,17 @@ set_sym_session_private_data(struct rte_cryptodev_sym_session *sess, sess->sess_data[driver_id].data = private_data; } +/** + * @internal + * Cryptodev asymmetric crypto session. + */ +RTE_STD_C11 struct rte_cryptodev_asym_session { + uint8_t driver_id; + /**< Session driver ID. */ + uint16_t max_priv_data_sz; + /**< Size of private data used when creating mempool */ + uint8_t padding[5]; + uint8_t sess_private_data[0]; +}; + #endif /* _CRYPTODEV_PMD_H_ */ diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index b056d88ac2..562cb4a2c4 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(uint8_t dev_id, struct rte_crypto_asym_xform *xforms, struct rte_mempool *mp) { @@ -2035,8 +2035,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) } int -rte_cryptodev_asym_session_free(uint8_t dev_id, - struct rte_cryptodev_asym_session *sess) +rte_cryptodev_asym_session_free(uint8_t dev_id, void *sess) { struct rte_mempool *sess_mp; struct rte_cryptodev *dev; diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index 90e764017d..4cf3f6c9d7 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 */ -RTE_STD_C11 struct rte_cryptodev_asym_session { - uint8_t driver_id; - /**< Session driver ID. */ - uint16_t max_priv_data_sz; - /**< Size of private data used when creating mempool */ - uint8_t padding[5]; - uint8_t sess_private_data[0]; -}; - /** * Create a symmetric session mempool. * @@ -1009,7 +999,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(uint8_t dev_id, struct rte_crypto_asym_xform *xforms, struct rte_mempool *mp); @@ -1041,8 +1031,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess); */ __rte_experimental int -rte_cryptodev_asym_session_free(uint8_t dev_id, - struct rte_cryptodev_asym_session *sess); +rte_cryptodev_asym_session_free(uint8_t dev_id, void *sess); /** * Fill out private data for the device id, based on its device type. diff --git a/lib/cryptodev/rte_cryptodev_trace.h b/lib/cryptodev/rte_cryptodev_trace.h index a4fa9e8c7e..4b48c66199 100644 --- a/lib/cryptodev/rte_cryptodev_trace.h +++ b/lib/cryptodev/rte_cryptodev_trace.h @@ -109,8 +109,7 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_cryptodev_trace_asym_session_free, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, - struct rte_cryptodev_asym_session *sess), + RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess), rte_trace_point_emit_u8(dev_id); rte_trace_point_emit_ptr(sess); ) -- 2.25.1