summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSlawomir Mrozowicz <slawomirx.mrozowicz@intel.com>2017-07-05 06:26:17 +0100
committerPablo de Lara <pablo.de.lara.guarch@intel.com>2017-07-06 22:34:55 +0200
commitb3bbd9e5f265937164ed8c9c61d12f7543a745ea (patch)
treeb3a914718abcee6d937436c942f89b308aedf439 /test
parent7c110ce7aa4e8b9c48a64343c040367dca411602 (diff)
downloaddpdk-b3bbd9e5f265937164ed8c9c61d12f7543a745ea.zip
dpdk-b3bbd9e5f265937164ed8c9c61d12f7543a745ea.tar.gz
dpdk-b3bbd9e5f265937164ed8c9c61d12f7543a745ea.tar.xz
cryptodev: support device independent sessions
Change crypto device's session management to make it device independent and simplify architecture when session is intended to be used on more than one device. Sessions private data is agnostic to underlying device by adding an indirection in the sessions private data using the crypto driver identifier. A single session can contain indirections to multiple device types. New function rte_cryptodev_sym_session_init has been created, to initialize the driver private session data per driver to be used on a same session, and rte_cryptodev_sym_session_clear to clear this data before calling rte_cryptodev_sym_session_free. Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Acked-by: Declan Doherty <declan.doherty@intel.com> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Diffstat (limited to 'test')
-rw-r--r--test/test/test_cryptodev.c347
-rw-r--r--test/test/test_cryptodev_blockcipher.c18
-rw-r--r--test/test/test_cryptodev_blockcipher.h1
-rw-r--r--test/test/test_cryptodev_perf.c191
4 files changed, 391 insertions, 166 deletions
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index e5d6c07..745f261 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -68,7 +68,6 @@ struct crypto_testsuite_params {
struct rte_mempool *large_mbuf_pool;
struct rte_mempool *op_mpool;
struct rte_mempool *session_mpool;
- struct rte_mempool *slave_session_mpool;
struct rte_cryptodev_config conf;
struct rte_cryptodev_qp_conf qp_conf;
@@ -387,12 +386,15 @@ 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 = sizeof(struct rte_cryptodev_sym_session) +
- rte_cryptodev_get_private_session_size(dev_id);
+ unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
+ /*
+ * Create mempool with maximum number of sessions * 2,
+ * to include the session headers
+ */
ts_params->session_mpool = rte_mempool_create(
"test_sess_mp",
- info.sym.max_nb_sessions,
+ info.sym.max_nb_sessions * 2,
session_size,
0, 0, NULL, NULL, NULL,
NULL, SOCKET_ID_ANY,
@@ -439,11 +441,6 @@ testsuite_teardown(void)
rte_mempool_free(ts_params->session_mpool);
ts_params->session_mpool = NULL;
}
-
- if (ts_params->slave_session_mpool != NULL) {
- rte_mempool_free(ts_params->slave_session_mpool);
- ts_params->slave_session_mpool = NULL;
- }
}
static int
@@ -494,8 +491,9 @@ ut_teardown(void)
/* free crypto session structure */
if (ut_params->sess) {
- rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
+ rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
ut_params->sess);
+ rte_cryptodev_sym_session_free(ut_params->sess);
ut_params->sess = NULL;
}
@@ -1280,10 +1278,13 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
ut_params->auth_xform.auth.key.data = hmac_sha1_key;
ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
- /* Create crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0],
- &ut_params->cipher_xform);
+ ts_params->session_mpool);
+
+ /* Create crypto session*/
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->cipher_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
/* Generate crypto op data structure */
@@ -1496,7 +1497,9 @@ test_AES_cipheronly_mb_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1513,7 +1516,9 @@ test_AES_docsis_mb_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1530,7 +1535,9 @@ test_AES_docsis_qat_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
BLKCIPHER_AES_DOCSIS_TYPE);
@@ -1547,7 +1554,9 @@ test_DES_docsis_qat_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
BLKCIPHER_DES_DOCSIS_TYPE);
@@ -1564,7 +1573,9 @@ test_authonly_mb_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
BLKCIPHER_AUTHONLY_TYPE);
@@ -1581,7 +1592,9 @@ test_AES_chain_mb_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
BLKCIPHER_AES_CHAIN_TYPE);
@@ -1600,7 +1613,9 @@ test_AES_cipheronly_scheduler_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1617,7 +1632,9 @@ test_AES_chain_scheduler_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
BLKCIPHER_AES_CHAIN_TYPE);
@@ -1634,7 +1651,9 @@ test_authonly_scheduler_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
BLKCIPHER_AUTHONLY_TYPE);
@@ -1653,7 +1672,9 @@ test_AES_chain_openssl_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
BLKCIPHER_AES_CHAIN_TYPE);
@@ -1670,7 +1691,9 @@ test_AES_cipheronly_openssl_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1687,7 +1710,9 @@ test_AES_chain_qat_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
BLKCIPHER_AES_CHAIN_TYPE);
@@ -1704,7 +1729,9 @@ test_AES_cipheronly_qat_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1721,7 +1748,9 @@ test_AES_chain_dpaa2_sec_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
BLKCIPHER_AES_CHAIN_TYPE);
@@ -1738,7 +1767,9 @@ test_AES_cipheronly_dpaa2_sec_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
BLKCIPHER_AES_CIPHERONLY_TYPE);
@@ -1755,7 +1786,9 @@ test_authonly_dpaa2_sec_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(RTE_CRYPTODEV_DPAA2_SEC_PMD)),
BLKCIPHER_AUTHONLY_TYPE);
@@ -1772,7 +1805,9 @@ test_authonly_openssl_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
BLKCIPHER_AUTHONLY_TYPE);
@@ -1789,7 +1824,9 @@ test_AES_chain_armv8_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
BLKCIPHER_AES_CHAIN_TYPE);
@@ -1809,6 +1846,7 @@ create_wireless_algo_hash_session(uint8_t dev_id,
{
uint8_t hash_key[key_len];
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(hash_key, key, key_len);
@@ -1826,8 +1864,11 @@ create_wireless_algo_hash_session(uint8_t dev_id,
ut_params->auth_xform.auth.digest_length = auth_len;
ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
ut_params->auth_xform.auth.iv.length = iv_len;
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->auth_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->auth_xform, ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
return 0;
}
@@ -1841,6 +1882,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
{
uint8_t cipher_key[key_len];
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(cipher_key, key, key_len);
@@ -1859,9 +1901,11 @@ create_wireless_algo_cipher_session(uint8_t dev_id,
TEST_HEXDUMP(stdout, "key:", key, key_len);
/* Create Crypto session */
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->
- cipher_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->cipher_xform, ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
return 0;
}
@@ -1940,6 +1984,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
{
uint8_t cipher_auth_key[key_len];
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(cipher_auth_key, key, key_len);
@@ -1972,8 +2017,11 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
TEST_HEXDUMP(stdout, "key:", key, key_len);
/* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->cipher_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->cipher_xform, ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
return 0;
@@ -1990,6 +2038,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
const uint8_t key_len = tdata->key.len;
uint8_t cipher_auth_key[key_len];
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
const uint8_t *key = tdata->key.data;
const uint8_t auth_len = tdata->digest.len;
@@ -2027,8 +2076,11 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
TEST_HEXDUMP(stdout, "key:", key, key_len);
/* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->cipher_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->cipher_xform, ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
return 0;
@@ -2056,6 +2108,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
{
uint8_t auth_cipher_key[key_len];
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(auth_cipher_key, key, key_len);
@@ -2085,8 +2138,11 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
TEST_HEXDUMP(stdout, "key:", key, key_len);
/* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->auth_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->auth_xform, ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@@ -4536,7 +4592,9 @@ test_3DES_chain_qat_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4553,7 +4611,9 @@ test_DES_cipheronly_qat_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
BLKCIPHER_DES_CIPHERONLY_TYPE);
@@ -4570,7 +4630,9 @@ test_DES_docsis_openssl_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
BLKCIPHER_DES_DOCSIS_TYPE);
@@ -4587,7 +4649,9 @@ test_3DES_chain_dpaa2_sec_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4604,7 +4668,9 @@ test_3DES_cipheronly_dpaa2_sec_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4621,7 +4687,9 @@ test_3DES_cipheronly_qat_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4638,7 +4706,9 @@ test_3DES_chain_openssl_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
BLKCIPHER_3DES_CHAIN_TYPE);
@@ -4655,7 +4725,9 @@ test_3DES_cipheronly_openssl_all(void)
int status;
status = test_blockcipher_all_tests(ts_params->mbuf_pool,
- ts_params->op_mpool, ts_params->valid_devs[0],
+ ts_params->op_mpool,
+ ts_params->session_mpool,
+ ts_params->valid_devs[0],
rte_cryptodev_driver_id_get(
RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
BLKCIPHER_3DES_CIPHERONLY_TYPE);
@@ -4675,6 +4747,7 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
{
uint8_t aead_key[key_len];
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(aead_key, key, key_len);
@@ -4694,8 +4767,11 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
TEST_HEXDUMP(stdout, "key:", key, key_len);
/* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->aead_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->aead_xform, ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@@ -5656,7 +5732,11 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
ut_params->auth_xform.auth.key.data = key;
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->auth_xform);
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->auth_xform,
+ ts_params->session_mpool);
if (ut_params->sess == NULL)
return TEST_FAILED;
@@ -5831,9 +5911,13 @@ test_multi_session(void)
/* Create multiple crypto sessions*/
for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
+
sessions[i] = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0],
- &ut_params->auth_xform);
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ sessions[i], &ut_params->auth_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(sessions[i],
"Session creation failed at session number %u",
i);
@@ -5869,14 +5953,17 @@ test_multi_session(void)
}
/* Next session create should fail */
- sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
- &ut_params->auth_xform);
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ sessions[i], &ut_params->auth_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NULL(sessions[i],
"Session creation succeeded unexpectedly!");
- for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
- rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
+ for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
+ rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
sessions[i]);
+ rte_cryptodev_sym_session_free(sessions[i]);
+ }
rte_free(sessions);
@@ -5934,6 +6021,9 @@ test_multi_session_random_usage(void)
* dev_info.sym.max_nb_sessions) + 1, 0);
for (i = 0; i < MB_SESSION_NUMBER; i++) {
+ sessions[i] = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
sizeof(struct crypto_unittest_params));
@@ -5942,9 +6032,11 @@ test_multi_session_random_usage(void)
ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
/* Create multiple crypto sessions*/
- sessions[i] = rte_cryptodev_sym_session_create(
+ rte_cryptodev_sym_session_init(
ts_params->valid_devs[0],
- &ut_paramz[i].ut_params.auth_xform);
+ sessions[i],
+ &ut_paramz[i].ut_params.auth_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(sessions[i],
"Session creation failed at session number %u",
@@ -5987,9 +6079,11 @@ test_multi_session_random_usage(void)
}
}
- for (i = 0; i < MB_SESSION_NUMBER; i++)
- rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
+ for (i = 0; i < MB_SESSION_NUMBER; i++) {
+ rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
sessions[i]);
+ rte_cryptodev_sym_session_free(sessions[i]);
+ }
rte_free(sessions);
@@ -6013,9 +6107,14 @@ test_null_cipher_only_operation(void)
ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
- /* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->cipher_xform);
+ ts_params->session_mpool);
+
+ /* Create Crypto session*/
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess,
+ &ut_params->cipher_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
/* Generate Crypto op data structure */
@@ -6070,9 +6169,13 @@ test_null_auth_only_operation(void)
ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
- /* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->auth_xform);
+ ts_params->session_mpool);
+
+ /* Create Crypto session*/
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->auth_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
/* Generate Crypto op data structure */
@@ -6126,9 +6229,13 @@ test_null_cipher_auth_operation(void)
ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
- /* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->cipher_xform);
+ ts_params->session_mpool);
+
+ /* Create Crypto session*/
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->cipher_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
/* Generate Crypto op data structure */
@@ -6192,9 +6299,13 @@ test_null_auth_cipher_operation(void)
ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
- /* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->cipher_xform);
+ ts_params->session_mpool);
+
+ /* Create Crypto session*/
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->cipher_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
/* Generate Crypto op data structure */
@@ -6240,6 +6351,7 @@ test_null_invalid_operation(void)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
+ int ret;
/* Setup Cipher Parameters */
ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@@ -6248,10 +6360,14 @@ test_null_invalid_operation(void)
ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
- /* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->cipher_xform);
- TEST_ASSERT_NULL(ut_params->sess,
+ ts_params->session_mpool);
+
+ /* Create Crypto session*/
+ ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->cipher_xform,
+ ts_params->session_mpool);
+ TEST_ASSERT(ret == -1,
"Session creation succeeded unexpectedly");
@@ -6262,10 +6378,14 @@ test_null_invalid_operation(void)
ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
- /* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->auth_xform);
- TEST_ASSERT_NULL(ut_params->sess,
+ ts_params->session_mpool);
+
+ /* Create Crypto session*/
+ ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->auth_xform,
+ ts_params->session_mpool);
+ TEST_ASSERT(ret == -1,
"Session creation succeeded unexpectedly");
return TEST_SUCCESS;
@@ -6299,9 +6419,13 @@ test_null_burst_operation(void)
ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
- /* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(
- ts_params->valid_devs[0], &ut_params->cipher_xform);
+ ts_params->session_mpool);
+
+ /* Create Crypto session*/
+ rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
+ ut_params->sess, &ut_params->cipher_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
@@ -6414,6 +6538,7 @@ static int create_gmac_session(uint8_t dev_id,
{
uint8_t auth_key[tdata->key.len];
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(auth_key, tdata->key.data, tdata->key.len);
@@ -6430,8 +6555,12 @@ static int create_gmac_session(uint8_t dev_id,
ut_params->auth_xform.auth.iv.length = tdata->iv.len;
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->auth_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->auth_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@@ -6791,6 +6920,7 @@ create_auth_session(struct crypto_unittest_params *ut_params,
const struct test_crypto_vector *reference,
enum rte_crypto_auth_operation auth_op)
{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
uint8_t auth_key[reference->auth_key.len + 1];
memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
@@ -6805,8 +6935,12 @@ create_auth_session(struct crypto_unittest_params *ut_params,
ut_params->auth_xform.auth.digest_length = reference->digest.len;
/* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->auth_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->auth_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@@ -6820,6 +6954,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
enum rte_crypto_auth_operation auth_op,
enum rte_crypto_cipher_operation cipher_op)
{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
uint8_t cipher_key[reference->cipher_key.len + 1];
uint8_t auth_key[reference->auth_key.len + 1];
@@ -6853,8 +6988,12 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params,
}
/* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
- &ut_params->auth_xform);
+ ut_params->sess = rte_cryptodev_sym_session_create(
+ ts_params->session_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->auth_xform,
+ ts_params->session_mpool);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@@ -7710,30 +7849,32 @@ test_scheduler_attach_slave_op(void)
continue;
/*
- * Create a separate mempool for the slaves, as they need different
- * session size and then configure them to store the pointer
- * to this mempool
+ * Create the session mempool again, since now there are new devices
+ * to use the mempool.
*/
- unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
- rte_cryptodev_get_private_session_size(i);
+ if (ts_params->session_mpool) {
+ rte_mempool_free(ts_params->session_mpool);
+ ts_params->session_mpool = NULL;
+ }
+ unsigned int session_size = rte_cryptodev_get_private_session_size(i);
- if (ts_params->slave_session_mpool == NULL) {
- ts_params->slave_session_mpool = rte_mempool_create(
- "test_slave_sess_mp",
- info.sym.max_nb_sessions,
- session_size,
- 0, 0, NULL, NULL, NULL, NULL,
- SOCKET_ID_ANY, 0);
+ /*
+ * Create mempool with maximum number of sessions * 2,
+ * to include the session headers
+ */
+ if (ts_params->session_mpool == NULL) {
+ ts_params->session_mpool = rte_mempool_create(
+ "test_sess_mp",
+ info.sym.max_nb_sessions * 2,
+ session_size,
+ 0, 0, NULL, NULL, NULL,
+ NULL, SOCKET_ID_ANY,
+ 0);
- TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
+ TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
"session mempool allocation failed");
}
- TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
- &ts_params->conf, ts_params->slave_session_mpool),
- "Failed to configure cryptodev %u with %u qps",
- i, ts_params->conf.nb_queue_pairs);
-
ret = rte_cryptodev_scheduler_slave_attach(sched_id,
(uint8_t)i);
diff --git a/test/test/test_cryptodev_blockcipher.c b/test/test/test_cryptodev_blockcipher.c
index 0b512c2..e822c96 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -53,6 +53,7 @@ static int
test_blockcipher_one_case(const struct blockcipher_test_case *t,
struct rte_mempool *mbuf_pool,
struct rte_mempool *op_mpool,
+ struct rte_mempool *sess_mpool,
uint8_t dev_id,
int driver_id,
char *test_msg)
@@ -65,8 +66,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
struct rte_crypto_sym_xform *init_xform = NULL;
struct rte_crypto_sym_op *sym_op = NULL;
struct rte_crypto_op *op = NULL;
- struct rte_cryptodev_sym_session *sess = NULL;
struct rte_cryptodev_info dev_info;
+ struct rte_cryptodev_sym_session *sess = NULL;
int status = TEST_SUCCESS;
const struct blockcipher_test_data *tdata = t->test_data;
@@ -340,8 +341,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
/* create session for sessioned op */
if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
- sess = rte_cryptodev_sym_session_create(dev_id,
- init_xform);
+ sess = rte_cryptodev_sym_session_create(sess_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
+ sess_mpool);
if (!sess) {
snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
"FAILED: %s", __LINE__,
@@ -561,8 +564,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
error_exit:
if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
- if (sess)
- rte_cryptodev_sym_session_free(dev_id, sess);
+ if (sess) {
+ rte_cryptodev_sym_session_clear(dev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
+ }
if (cipher_xform)
rte_free(cipher_xform);
if (auth_xform)
@@ -584,6 +589,7 @@ error_exit:
int
test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
struct rte_mempool *op_mpool,
+ struct rte_mempool *sess_mpool,
uint8_t dev_id,
int driver_id,
enum blockcipher_test_type test_type)
@@ -675,7 +681,7 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
continue;
status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
- dev_id, driver_id, test_msg);
+ sess_mpool, dev_id, driver_id, test_msg);
printf(" %u) TestCase %s %s\n", test_index ++,
tc->test_descr, test_msg);
diff --git a/test/test/test_cryptodev_blockcipher.h b/test/test/test_cryptodev_blockcipher.h
index 22fb420..22b8d20 100644
--- a/test/test/test_cryptodev_blockcipher.h
+++ b/test/test/test_cryptodev_blockcipher.h
@@ -125,6 +125,7 @@ struct blockcipher_test_data {
int
test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
struct rte_mempool *op_mpool,
+ struct rte_mempool *sess_mpool,
uint8_t dev_id,
int driver_id,
enum blockcipher_test_type test_type);
diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index 9caba87..e21f5e7 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -108,6 +108,8 @@ struct symmetric_session_attrs {
uint32_t digest_len;
};
+static struct rte_cryptodev_sym_session *test_crypto_session;
+
#define ALIGN_POW2_ROUNDUP(num, align) \
(((num) + (align) - 1) & ~((align) - 1))
@@ -156,18 +158,18 @@ struct crypto_unittest_params {
uint8_t *digest;
};
-static struct rte_cryptodev_sym_session *
+static int
test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
enum rte_crypto_cipher_algorithm cipher_algo,
unsigned int cipher_key_len,
enum rte_crypto_auth_algorithm auth_algo);
-static struct rte_cryptodev_sym_session *
+static int
test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
enum rte_crypto_cipher_algorithm cipher_algo,
unsigned int cipher_key_len,
enum rte_crypto_auth_algorithm auth_algo,
enum rte_crypto_aead_algorithm aead_algo);
-static struct rte_cryptodev_sym_session *
+static int
test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
enum rte_crypto_cipher_algorithm cipher_algo,
unsigned int cipher_key_len,
@@ -487,9 +489,11 @@ ut_teardown(void)
unsigned i;
/* free crypto session structure */
- if (ut_params->sess)
- rte_cryptodev_sym_session_free(ts_params->dev_id,
+ if (ut_params->sess) {
+ rte_cryptodev_sym_session_clear(ts_params->dev_id,
ut_params->sess);
+ rte_cryptodev_sym_session_free(ut_params->sess);
+ }
/* free crypto operation structure */
if (ut_params->op)
@@ -1969,10 +1973,13 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
/* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(ts_params->dev_id,
- &ut_params->cipher_xform);
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+ test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
+ rte_cryptodev_sym_session_init(ts_params->dev_id, test_crypto_session,
+ &ut_params->cipher_xform, ts_params->sess_mp);
+
+ TEST_ASSERT_NOT_NULL(test_crypto_session, "Session creation failed");
/* Generate Crypto op data structure(s) */
for (i = 0; i < num_to_submit ; i++) {
@@ -1994,7 +2001,7 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
rte_crypto_op_alloc(ts_params->op_mpool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC);
- rte_crypto_op_attach_sym_session(op, ut_params->sess);
+ rte_crypto_op_attach_sym_session(op, test_crypto_session);
op->sym->auth.digest.data = ut_params->digest;
op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
@@ -2105,9 +2112,12 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
}
/* Create Crypto session*/
- sess = test_perf_create_snow3g_session(ts_params->dev_id,
+ if (test_perf_create_snow3g_session(ts_params->dev_id,
pparams->chain, pparams->cipher_algo,
- pparams->key_length, pparams->auth_algo);
+ pparams->key_length, pparams->auth_algo) == 0)
+ sess = test_crypto_session;
+ else
+ sess = NULL;
TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
/* Generate Crypto op data structure(s)*/
@@ -2211,7 +2221,10 @@ test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
rte_pktmbuf_free(c_ops[i]->sym->m_src);
rte_crypto_op_free(c_ops[i]);
}
- rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+
+ rte_cryptodev_sym_session_clear(ts_params->dev_id,
+ sess);
+ rte_cryptodev_sym_session_free(sess);
return TEST_SUCCESS;
}
@@ -2290,10 +2303,13 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
}
/* Create Crypto session*/
- sess = test_perf_create_openssl_session(ts_params->dev_id,
+ if (test_perf_create_openssl_session(ts_params->dev_id,
pparams->chain, pparams->cipher_algo,
pparams->key_length, pparams->auth_algo,
- pparams->aead_algo);
+ pparams->aead_algo) == 0)
+ sess = test_crypto_session;
+ else
+ sess = NULL;
TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
/* Generate Crypto op data structure(s)*/
@@ -2425,7 +2441,9 @@ test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
rte_pktmbuf_free(c_ops[i]->sym->m_src);
rte_crypto_op_free(c_ops[i]);
}
- rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
+
+ rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
return TEST_SUCCESS;
}
@@ -2452,10 +2470,12 @@ test_perf_armv8_optimise_cyclecount(struct perf_test_params *pparams)
}
/* Create Crypto session*/
- sess = test_perf_create_armv8_session(ts_params->dev_id,
+ if (test_perf_create_armv8_session(ts_params->dev_id,
pparams->chain, pparams->cipher_algo,
- pparams->key_length, pparams->auth_algo);
- TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
+ pparams->key_length, pparams->auth_algo) == 0)
+ sess = test_crypto_session;
+ else
+ sess = NULL;
/* Generate Crypto op data structure(s)*/
for (i = 0; i < num_to_submit ; i++) {
@@ -2672,12 +2692,13 @@ static uint8_t snow3g_hash_key[] = {
0x1E, 0x26, 0x98, 0xD2, 0xE2, 0x2A, 0xD5, 0x7E
};
-static struct rte_cryptodev_sym_session *
+static int
test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
enum rte_crypto_cipher_algorithm cipher_algo,
unsigned cipher_key_len,
enum rte_crypto_auth_algorithm auth_algo)
{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct rte_crypto_sym_xform cipher_xform = { 0 };
struct rte_crypto_sym_xform auth_xform = { 0 };
@@ -2701,33 +2722,42 @@ test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
auth_xform.auth.digest_length =
get_auth_digest_length(auth_algo);
}
+
+ test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
switch (chain) {
case CIPHER_HASH:
cipher_xform.next = &auth_xform;
auth_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &cipher_xform,
+ ts_params->sess_mp);
case HASH_CIPHER:
auth_xform.next = &cipher_xform;
cipher_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &auth_xform,
+ ts_params->sess_mp);
case CIPHER_ONLY:
cipher_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &cipher_xform,
+ ts_params->sess_mp);
default:
- return NULL;
+ return -1;
}
}
#define SNOW3G_CIPHER_IV_LENGTH 16
-static struct rte_cryptodev_sym_session *
+static int
test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
enum rte_crypto_cipher_algorithm cipher_algo, unsigned cipher_key_len,
enum rte_crypto_auth_algorithm auth_algo)
{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct rte_crypto_sym_xform cipher_xform = {0};
struct rte_crypto_sym_xform auth_xform = {0};
@@ -2755,37 +2785,47 @@ test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
auth_xform.auth.iv.offset = IV_OFFSET + SNOW3G_CIPHER_IV_LENGTH;
auth_xform.auth.iv.length = SNOW3G_CIPHER_IV_LENGTH;
+ test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
switch (chain) {
case CIPHER_HASH:
cipher_xform.next = &auth_xform;
auth_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &cipher_xform,
+ ts_params->sess_mp);
case HASH_CIPHER:
auth_xform.next = &cipher_xform;
cipher_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &auth_xform,
+ ts_params->sess_mp);
case CIPHER_ONLY:
cipher_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &cipher_xform,
+ ts_params->sess_mp);
case HASH_ONLY:
auth_xform.next = NULL;
/* Create Crypto session */
- return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &auth_xform,
+ ts_params->sess_mp);
default:
- return NULL;
+ return -1;
}
}
-static struct rte_cryptodev_sym_session *
+static int
test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
enum rte_crypto_cipher_algorithm cipher_algo,
unsigned int key_len,
enum rte_crypto_auth_algorithm auth_algo,
enum rte_crypto_aead_algorithm aead_algo)
{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct rte_crypto_sym_xform cipher_xform = { 0 };
struct rte_crypto_sym_xform auth_xform = { 0 };
struct rte_crypto_sym_xform aead_xform = { 0 };
@@ -2809,7 +2849,7 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
cipher_xform.cipher.iv.length = AES_CIPHER_IV_LENGTH;
break;
default:
- return NULL;
+ return -1;
}
cipher_xform.cipher.key.length = key_len;
@@ -2824,7 +2864,7 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
auth_xform.auth.key.data = hmac_sha_key;
break;
default:
- return NULL;
+ return -1;
}
auth_xform.auth.key.length = get_auth_key_max_length(auth_algo);
@@ -2844,37 +2884,45 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
aead_xform.aead.digest_length = get_aead_digest_length(aead_algo);
break;
default:
- return NULL;
+ return -1;
}
aead_xform.aead.key.length = key_len;
}
+ test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
switch (chain) {
case CIPHER_HASH:
cipher_xform.next = &auth_xform;
auth_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &cipher_xform,
+ ts_params->sess_mp);
case HASH_CIPHER:
auth_xform.next = &cipher_xform;
cipher_xform.next = NULL;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &auth_xform,
+ ts_params->sess_mp);
case AEAD:
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &aead_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &aead_xform,
+ ts_params->sess_mp);
default:
- return NULL;
+ return -1;
}
}
-static struct rte_cryptodev_sym_session *
+static int
test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
enum rte_crypto_cipher_algorithm cipher_algo,
unsigned int cipher_key_len,
enum rte_crypto_auth_algorithm auth_algo)
{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct rte_crypto_sym_xform cipher_xform = { 0 };
struct rte_crypto_sym_xform auth_xform = { 0 };
@@ -2887,7 +2935,7 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
cipher_xform.cipher.key.data = aes_cbc_128_key;
break;
default:
- return NULL;
+ return -1;
}
cipher_xform.cipher.key.length = cipher_key_len;
@@ -2901,6 +2949,8 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
+ rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
switch (chain) {
case CIPHER_HASH:
cipher_xform.next = &auth_xform;
@@ -2908,16 +2958,20 @@ test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
/* Encrypt and hash the result */
cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &cipher_xform,
+ ts_params->sess_mp);
case HASH_CIPHER:
auth_xform.next = &cipher_xform;
cipher_xform.next = NULL;
/* Hash encrypted message and decrypt */
cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
/* Create Crypto session*/
- return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
+ return rte_cryptodev_sym_session_init(dev_id,
+ test_crypto_session, &auth_xform,
+ ts_params->sess_mp);
default:
- return NULL;
+ return -1;
}
}
@@ -3167,9 +3221,12 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
}
/* Create Crypto session*/
- sess = test_perf_create_aes_sha_session(ts_params->dev_id,
+ if (test_perf_create_aes_sha_session(ts_params->dev_id,
pparams->chain, pparams->cipher_algo,
- pparams->key_length, pparams->auth_algo);
+ pparams->key_length, pparams->auth_algo) == 0)
+ sess = test_crypto_session;
+ else
+ sess = NULL;
TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
/* Generate a burst of crypto operations */
@@ -3264,7 +3321,9 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
rte_pktmbuf_free(mbufs[i]);
- rte_cryptodev_sym_session_free(dev_id, sess);
+
+ rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
printf("\n");
return TEST_SUCCESS;
@@ -3300,9 +3359,12 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
}
/* Create Crypto session*/
- sess = test_perf_create_snow3g_session(ts_params->dev_id,
+ if (test_perf_create_snow3g_session(ts_params->dev_id,
pparams->chain, pparams->cipher_algo,
- pparams->key_length, pparams->auth_algo);
+ pparams->key_length, pparams->auth_algo) == 0)
+ sess = test_crypto_session;
+ else
+ sess = NULL;
TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
/* Generate a burst of crypto operations */
@@ -3429,7 +3491,9 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
rte_pktmbuf_free(mbufs[i]);
- rte_cryptodev_sym_session_free(dev_id, sess);
+
+ rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
printf("\n");
return TEST_SUCCESS;
@@ -3486,10 +3550,13 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
}
/* Create Crypto session*/
- sess = test_perf_create_openssl_session(ts_params->dev_id,
+ if (test_perf_create_openssl_session(ts_params->dev_id,
pparams->chain, pparams->cipher_algo,
pparams->key_length, pparams->auth_algo,
- pparams->aead_algo);
+ pparams->aead_algo) == 0)
+ sess = test_crypto_session;
+ else
+ sess = NULL;
TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
/* Generate a burst of crypto operations */
@@ -3582,7 +3649,9 @@ test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
rte_pktmbuf_free(mbufs[i]);
- rte_cryptodev_sym_session_free(dev_id, sess);
+
+ rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
printf("\n");
return TEST_SUCCESS;
@@ -3617,9 +3686,12 @@ test_perf_armv8(uint8_t dev_id, uint16_t queue_id,
}
/* Create Crypto session*/
- sess = test_perf_create_armv8_session(ts_params->dev_id,
+ if (test_perf_create_armv8_session(ts_params->dev_id,
pparams->chain, pparams->cipher_algo,
- pparams->key_length, pparams->auth_algo);
+ pparams->key_length, pparams->auth_algo) == 0)
+ sess = test_crypto_session;
+ else
+ sess = NULL;
TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
/* Generate a burst of crypto operations */
@@ -4177,7 +4249,7 @@ test_perf_aes_cbc_vary_burst_size(void)
static struct rte_cryptodev_sym_session *
test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
{
- static struct rte_cryptodev_sym_session *sess;
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
struct rte_crypto_sym_xform aead_xform = { 0 };
uint8_t aead_key[pparams->session_attrs->key_aead_len];
@@ -4197,9 +4269,12 @@ test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
aead_xform.aead.add_auth_data_length = pparams->session_attrs->aad_len;
aead_xform.aead.digest_length = pparams->session_attrs->digest_len;
- sess = rte_cryptodev_sym_session_create(dev_id, &aead_xform);
+ test_crypto_session = rte_cryptodev_sym_session_create(ts_params->sess_mp);
+
+ rte_cryptodev_sym_session_init(dev_id, test_crypto_session,
+ &aead_xform, ts_params->sess_mp);
- return sess;
+ return test_crypto_session;
}
static inline struct rte_crypto_op *
@@ -4418,7 +4493,9 @@ perf_AES_GCM(uint8_t dev_id, uint16_t queue_id,
for (i = 0; i < burst; i++)
rte_pktmbuf_free(mbufs[i]);
- rte_cryptodev_sym_session_free(dev_id, sess);
+
+ rte_cryptodev_sym_session_clear(ts_params->dev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
return 0;
}