test/threads: add unit test
[dpdk.git] / app / test / test_cryptodev_asym.c
index 50ff5c7..573af2a 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,14 +310,14 @@ 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];
        uint8_t input[TEST_DATA_SIZE] = {0};
        uint8_t *result = NULL;
 
-       int status = TEST_SUCCESS;
+       int ret, status = TEST_SUCCESS;
 
        xform_tc.next = NULL;
        xform_tc.xform_type = data_tc->modex.xform_type;
@@ -452,22 +452,14 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params,
        }
 
        if (!sessionless) {
-               sess = rte_cryptodev_asym_session_create(ts_params->session_mpool);
-               if (!sess) {
+               ret = rte_cryptodev_asym_session_create(dev_id, &xform_tc,
+                               ts_params->session_mpool, &sess);
+               if (ret < 0) {
                        snprintf(test_msg, ASYM_TEST_MSG_LEN,
                                        "line %u "
                                        "FAILED: %s", __LINE__,
                                        "Session creation failed");
-                       status = TEST_FAILED;
-                       goto error_exit;
-               }
-
-               if (rte_cryptodev_asym_session_init(dev_id, sess, &xform_tc,
-                               ts_params->session_mpool) < 0) {
-                       snprintf(test_msg, ASYM_TEST_MSG_LEN,
-                                       "line %u FAILED: %s",
-                                       __LINE__, "unabled to config sym session");
-                       status = TEST_FAILED;
+                       status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                        goto error_exit;
                }
 
@@ -512,10 +504,8 @@ test_cryptodev_asym_op(struct crypto_testsuite_params_asym *ts_params,
                snprintf(test_msg, ASYM_TEST_MSG_LEN, "SESSIONLESS PASS");
 
 error_exit:
-               if (sess != NULL) {
-                       rte_cryptodev_asym_session_clear(dev_id, sess);
-                       rte_cryptodev_asym_session_free(sess);
-               }
+               if (sess != NULL)
+                       rte_cryptodev_asym_session_free(dev_id, sess);
 
                if (op != NULL)
                        rte_crypto_op_free(op);
@@ -559,7 +549,7 @@ test_one_case(const void *test_case, int sessionless)
                                                status = test_cryptodev_asym_op(
                                                        &testsuite_params,
                                                        &tc, test_msg, sessionless, i,
-                                                       RTE_RSA_KET_TYPE_QT);
+                                                       RTE_RSA_KEY_TYPE_QT);
                                        }
                                        if (status)
                                                break;
@@ -653,9 +643,9 @@ 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;
+       int ret, status = TEST_SUCCESS;
 
        /* Test case supports op with exponent key only,
         * Check in PMD feature flag for RSA exponent key type support.
@@ -668,28 +658,19 @@ test_rsa_sign_verify(void)
                return TEST_SKIPPED;
        }
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
+       ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
 
-       if (!sess) {
+       if (ret < 0) {
                RTE_LOG(ERR, USER1, "Session creation failed for "
                        "sign_verify\n");
-               return TEST_FAILED;
-       }
-
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
-                               sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1, "Unable to config asym session for "
-                       "sign_verify\n");
-               status = TEST_FAILED;
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
        status = queue_ops_rsa_sign_verify(sess);
 
 error_exit:
-
-       rte_cryptodev_asym_session_clear(dev_id, sess);
-       rte_cryptodev_asym_session_free(sess);
+       rte_cryptodev_asym_session_free(dev_id, sess);
 
        TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -702,9 +683,9 @@ 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;
+       int ret, status = TEST_SUCCESS;
 
        /* Test case supports op with exponent key only,
         * Check in PMD feature flag for RSA exponent key type support.
@@ -717,18 +698,11 @@ test_rsa_enc_dec(void)
                return TEST_SKIPPED;
        }
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
+       ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, &sess);
 
-       if (!sess) {
+       if (ret < 0) {
                RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n");
-               return TEST_FAILED;
-       }
-
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
-                               sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1, "Unable to config asym session for "
-                       "enc_dec\n");
-               status = TEST_FAILED;
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
@@ -736,8 +710,7 @@ test_rsa_enc_dec(void)
 
 error_exit:
 
-       rte_cryptodev_asym_session_clear(dev_id, sess);
-       rte_cryptodev_asym_session_free(sess);
+       rte_cryptodev_asym_session_free(dev_id, sess);
 
        TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -750,9 +723,9 @@ 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;
+       int ret, status = TEST_SUCCESS;
 
        /* Test case supports op with quintuple format key only,
         * Check im PMD feature flag for RSA quintuple key type support.
@@ -764,28 +737,20 @@ test_rsa_sign_verify_crt(void)
                return TEST_SKIPPED;
        }
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
+       ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform_crt, sess_mpool, &sess);
 
-       if (!sess) {
+       if (ret < 0) {
                RTE_LOG(ERR, USER1, "Session creation failed for "
                        "sign_verify_crt\n");
-               status = TEST_FAILED;
-               return status;
-       }
-
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
-                               sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1, "Unable to config asym session for "
-                       "sign_verify_crt\n");
-               status = TEST_FAILED;
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
+
        status = queue_ops_rsa_sign_verify(sess);
 
 error_exit:
 
-       rte_cryptodev_asym_session_clear(dev_id, sess);
-       rte_cryptodev_asym_session_free(sess);
+       rte_cryptodev_asym_session_free(dev_id, sess);
 
        TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -798,9 +763,9 @@ 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;
+       int ret, status = TEST_SUCCESS;
 
        /* Test case supports op with quintuple format key only,
         * Check in PMD feature flag for RSA quintuple key type support.
@@ -812,27 +777,20 @@ test_rsa_enc_dec_crt(void)
                return TEST_SKIPPED;
        }
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
+       ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform_crt, sess_mpool, &sess);
 
-       if (!sess) {
+       if (ret < 0) {
                RTE_LOG(ERR, USER1, "Session creation failed for "
                        "enc_dec_crt\n");
-               return TEST_FAILED;
-       }
-
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
-                               sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1, "Unable to config asym session for "
-                       "enc_dec_crt\n");
-               status = TEST_FAILED;
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
+
        status = queue_ops_rsa_enc_dec(sess);
 
 error_exit:
 
-       rte_cryptodev_asym_session_clear(dev_id, sess);
-       rte_cryptodev_asym_session_free(sess);
+       rte_cryptodev_asym_session_free(dev_id, sess);
 
        TEST_ASSERT_EQUAL(status, 0, "Test failed");
 
@@ -926,7 +884,6 @@ testsuite_setup(void)
        /* configure qp */
        ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
        ts_params->qp_conf.mp_session = ts_params->session_mpool;
-       ts_params->qp_conf.mp_session_private = ts_params->session_mpool;
        for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
                TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
                        dev_id, qp_id, &ts_params->qp_conf,
@@ -935,21 +892,9 @@ testsuite_setup(void)
                        qp_id, dev_id);
        }
 
-       /* setup asym session pool */
-       unsigned int session_size = RTE_MAX(
-               rte_cryptodev_asym_get_private_session_size(dev_id),
-               rte_cryptodev_asym_get_header_session_size());
-       /*
-        * Create mempool with TEST_NUM_SESSIONS * 2,
-        * to include the session headers
-        */
-       ts_params->session_mpool = rte_mempool_create(
-                               "test_asym_sess_mp",
-                               TEST_NUM_SESSIONS * 2,
-                               session_size,
-                               0, 0, NULL, NULL, NULL,
-                               NULL, SOCKET_ID_ANY,
-                               0);
+       ts_params->session_mpool = rte_cryptodev_asym_session_pool_create(
+                       "test_asym_sess_mp", TEST_NUM_SESSIONS, 0, 0,
+                       SOCKET_ID_ANY);
 
        TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
                        "session mempool allocation failed");
@@ -1100,20 +1045,12 @@ 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;
-       int status = TEST_SUCCESS;
+       void *sess = NULL;
+       int ret, status = TEST_SUCCESS;
        uint8_t output[TEST_DH_MOD_LEN];
        struct rte_crypto_asym_xform xform = *xfrm;
        uint8_t peer[] = "01234567890123456789012345678901234567890123456789";
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (sess == NULL) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s", __LINE__,
-                               "Session creation failed");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
        /* set up crypto op data structure */
        op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
        if (!op) {
@@ -1136,12 +1073,12 @@ test_dh_gen_shared_sec(struct rte_crypto_asym_xform *xfrm)
        asym_op->dh.shared_secret.data = output;
        asym_op->dh.shared_secret.length = sizeof(output);
 
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
-                       sess_mpool) < 0) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
-               status = TEST_FAILED;
+                               "line %u FAILED: %s", __LINE__,
+                               "Session creation failed");
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
@@ -1175,10 +1112,8 @@ test_dh_gen_shared_sec(struct rte_crypto_asym_xform *xfrm)
                        asym_op->dh.shared_secret.length);
 
 error_exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
        if (op != NULL)
                rte_crypto_op_free(op);
        return status;
@@ -1193,19 +1128,11 @@ 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;
-       int status = TEST_SUCCESS;
+       void *sess = NULL;
+       int ret, status = TEST_SUCCESS;
        uint8_t output[TEST_DH_MOD_LEN];
        struct rte_crypto_asym_xform xform = *xfrm;
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (sess == NULL) {
-               RTE_LOG(ERR, USER1,
-                                "line %u FAILED: %s", __LINE__,
-                               "Session creation failed");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
        /* set up crypto op data structure */
        op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
        if (!op) {
@@ -1224,12 +1151,12 @@ test_dh_gen_priv_key(struct rte_crypto_asym_xform *xfrm)
        asym_op->dh.priv_key.data = output;
        asym_op->dh.priv_key.length = sizeof(output);
 
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
-                       sess_mpool) < 0) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
-               status = TEST_FAILED;
+                               "line %u FAILED: %s", __LINE__,
+                               "Session creation failed");
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
@@ -1264,10 +1191,8 @@ test_dh_gen_priv_key(struct rte_crypto_asym_xform *xfrm)
 
 
 error_exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
        if (op != NULL)
                rte_crypto_op_free(op);
 
@@ -1284,19 +1209,11 @@ 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;
-       int status = TEST_SUCCESS;
+       void *sess = NULL;
+       int ret, status = TEST_SUCCESS;
        uint8_t output[TEST_DH_MOD_LEN];
        struct rte_crypto_asym_xform xform = *xfrm;
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (sess == NULL) {
-               RTE_LOG(ERR, USER1,
-                                "line %u FAILED: %s", __LINE__,
-                               "Session creation failed");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
        /* set up crypto op data structure */
        op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
        if (!op) {
@@ -1323,12 +1240,12 @@ test_dh_gen_pub_key(struct rte_crypto_asym_xform *xfrm)
                                        0);
        asym_op->dh.priv_key = dh_test_params.priv_key;
 
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
-                       sess_mpool) < 0) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
-               status = TEST_FAILED;
+                               "line %u FAILED: %s", __LINE__,
+                               "Session creation failed");
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
@@ -1364,10 +1281,8 @@ test_dh_gen_pub_key(struct rte_crypto_asym_xform *xfrm)
                        asym_op->dh.priv_key.data, asym_op->dh.priv_key.length);
 
 error_exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
        if (op != NULL)
                rte_crypto_op_free(op);
 
@@ -1383,22 +1298,13 @@ 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;
-       int status = TEST_SUCCESS;
+       void *sess = NULL;
+       int ret, status = TEST_SUCCESS;
        uint8_t out_pub_key[TEST_DH_MOD_LEN];
        uint8_t out_prv_key[TEST_DH_MOD_LEN];
        struct rte_crypto_asym_xform pub_key_xform;
        struct rte_crypto_asym_xform xform = *xfrm;
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (sess == NULL) {
-               RTE_LOG(ERR, USER1,
-                                "line %u FAILED: %s", __LINE__,
-                               "Session creation failed");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
-
        /* set up crypto op data structure */
        op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
        if (!op) {
@@ -1422,12 +1328,13 @@ test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm)
        asym_op->dh.pub_key.length = sizeof(out_pub_key);
        asym_op->dh.priv_key.data = out_prv_key;
        asym_op->dh.priv_key.length = sizeof(out_prv_key);
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
-                       sess_mpool) < 0) {
+
+       ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
-               status = TEST_FAILED;
+                               "line %u FAILED: %s", __LINE__,
+                               "Session creation failed");
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
@@ -1461,10 +1368,8 @@ test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm)
                        out_pub_key, asym_op->dh.pub_key.length);
 
 error_exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
        if (op != NULL)
                rte_crypto_op_free(op);
 
@@ -1480,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;
@@ -1513,21 +1418,12 @@ test_mod_inv(void)
                                return TEST_SKIPPED;
                }
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (!sess) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &modinv_xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1, "line %u "
                                "FAILED: %s", __LINE__,
                                "Session creation failed");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
-
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &modinv_xform,
-                       sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
-               status = TEST_FAILED;
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
@@ -1582,10 +1478,8 @@ test_mod_inv(void)
        }
 
 error_exit:
-       if (sess) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess)
+               rte_cryptodev_asym_session_free(dev_id, sess);
 
        if (op)
                rte_crypto_op_free(op);
@@ -1604,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;
@@ -1648,22 +1542,13 @@ test_mod_exp(void)
                goto error_exit;
        }
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (!sess) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &modex_xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
                                 "line %u "
                                "FAILED: %s", __LINE__,
                                "Session creation failed");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
-
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &modex_xform,
-                       sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
-               status = TEST_FAILED;
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
 
@@ -1705,10 +1590,8 @@ test_mod_exp(void)
        }
 
 error_exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
 
        if (op != NULL)
                rte_crypto_op_free(op);
@@ -1764,18 +1647,19 @@ 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];
        uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
+       int ret;
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (sess == NULL) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &dsa_xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
                                 "line %u FAILED: %s", __LINE__,
                                "Session creation failed");
-               status = TEST_FAILED;
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto error_exit;
        }
        /* set up crypto op data structure */
@@ -1799,15 +1683,6 @@ test_dsa_sign(void)
        debug_hexdump(stdout, "priv_key: ", dsa_xform.dsa.x.data,
                        dsa_xform.dsa.x.length);
 
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &dsa_xform,
-                               sess_mpool) < 0) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s",
-                               __LINE__, "unabled to config sym session");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
-
        /* attach asymmetric crypto session to crypto operations */
        rte_crypto_op_attach_asym_session(op, sess);
        asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
@@ -1881,10 +1756,8 @@ test_dsa_sign(void)
                status = TEST_FAILED;
        }
 error_exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
        if (op != NULL)
                rte_crypto_op_free(op);
        return status;
@@ -1906,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];
@@ -1915,7 +1788,7 @@ test_ecdsa_sign_verify(enum curve curve_id)
        struct rte_crypto_asym_op *asym_op;
        struct rte_cryptodev_info dev_info;
        struct rte_crypto_op *op = NULL;
-       int status = TEST_SUCCESS, ret;
+       int ret, status = TEST_SUCCESS;
 
        switch (curve_id) {
        case SECP192R1:
@@ -1943,15 +1816,6 @@ test_ecdsa_sign_verify(enum curve curve_id)
 
        rte_cryptodev_info_get(dev_id, &dev_info);
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (sess == NULL) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s", __LINE__,
-                               "Session creation failed\n");
-               status = TEST_FAILED;
-               goto exit;
-       }
-
        /* Setup crypto op data structure */
        op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
        if (op == NULL) {
@@ -1969,12 +1833,12 @@ test_ecdsa_sign_verify(enum curve curve_id)
        xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
        xform.ec.curve_id = input_params.curve;
 
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
-                               sess_mpool) < 0) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
                                "line %u FAILED: %s", __LINE__,
-                               "Unable to config asym session\n");
-               status = TEST_FAILED;
+                               "Session creation failed\n");
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto exit;
        }
 
@@ -2081,10 +1945,8 @@ test_ecdsa_sign_verify(enum curve curve_id)
        }
 
 exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
        if (op != NULL)
                rte_crypto_op_free(op);
        return status;
@@ -2119,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];
@@ -2128,7 +1990,7 @@ test_ecpm(enum curve curve_id)
        struct rte_crypto_asym_op *asym_op;
        struct rte_cryptodev_info dev_info;
        struct rte_crypto_op *op = NULL;
-       int status = TEST_SUCCESS, ret;
+       int ret, status = TEST_SUCCESS;
 
        switch (curve_id) {
        case SECP192R1:
@@ -2156,15 +2018,6 @@ test_ecpm(enum curve curve_id)
 
        rte_cryptodev_info_get(dev_id, &dev_info);
 
-       sess = rte_cryptodev_asym_session_create(sess_mpool);
-       if (sess == NULL) {
-               RTE_LOG(ERR, USER1,
-                               "line %u FAILED: %s", __LINE__,
-                               "Session creation failed\n");
-               status = TEST_FAILED;
-               goto exit;
-       }
-
        /* Setup crypto op data structure */
        op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
        if (op == NULL) {
@@ -2182,12 +2035,12 @@ test_ecpm(enum curve curve_id)
        xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECPM;
        xform.ec.curve_id = input_params.curve;
 
-       if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
-                               sess_mpool) < 0) {
+       ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
+       if (ret < 0) {
                RTE_LOG(ERR, USER1,
                                "line %u FAILED: %s", __LINE__,
-                               "Unable to config asym session\n");
-               status = TEST_FAILED;
+                               "Session creation failed\n");
+               status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
                goto exit;
        }
 
@@ -2254,10 +2107,8 @@ test_ecpm(enum curve curve_id)
        }
 
 exit:
-       if (sess != NULL) {
-               rte_cryptodev_asym_session_clear(dev_id, sess);
-               rte_cryptodev_asym_session_free(sess);
-       }
+       if (sess != NULL)
+               rte_cryptodev_asym_session_free(dev_id, sess);
        if (op != NULL)
                rte_crypto_op_free(op);
        return status;