cryptodev: hide asymmetric session structure
authorCiara Power <ciara.power@intel.com>
Fri, 11 Feb 2022 09:29:07 +0000 (09:29 +0000)
committerAkhil Goyal <gakhil@marvell.com>
Sat, 12 Feb 2022 09:26:39 +0000 (10:26 +0100)
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 <ciara.power@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
app/test-crypto-perf/cperf_ops.c
app/test/test_cryptodev_asym.c
doc/guides/prog_guide/cryptodev_lib.rst
doc/guides/rel_notes/release_22_03.rst
lib/cryptodev/cryptodev_pmd.h
lib/cryptodev/rte_cryptodev.c
lib/cryptodev/rte_cryptodev.h
lib/cryptodev/rte_cryptodev_trace.h

index b125c69..b8f590b 100644 (file)
@@ -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;
index 283b38e..d8906c6 100644 (file)
@@ -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 @@ error_exit:
 }
 
 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];
@@ -643,7 +643,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;
 
@@ -683,7 +683,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;
 
@@ -723,7 +723,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;
 
@@ -763,7 +763,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;
 
@@ -1045,7 +1045,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;
@@ -1128,7 +1128,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;
@@ -1209,7 +1209,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;
@@ -1298,7 +1298,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];
@@ -1385,7 +1385,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;
@@ -1498,7 +1498,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;
@@ -1647,7 +1647,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];
@@ -1778,7 +1778,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];
@@ -1980,7 +1980,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];
index b4dbd38..2607a9a 100644 (file)
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index cdfabdc..697fe47 100644 (file)
@@ -187,6 +187,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``.
 
index 142bfb7..63f9cf5 100644 (file)
@@ -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_ */
index b056d88..562cb4a 100644 (file)
@@ -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;
index 90e7640..4cf3f6c 100644 (file)
@@ -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.
index a4fa9e8..4b48c66 100644 (file)
@@ -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);
 )