test/crypto: fix dpaa2 sec macros and definitions
[dpdk.git] / test / test / test_cryptodev_blockcipher.c
index 0b512c2..89b02e5 100644 (file)
 #include "test_cryptodev_aes_test_vectors.h"
 #include "test_cryptodev_des_test_vectors.h"
 #include "test_cryptodev_hash_test_vectors.h"
-#include "test_cryptodev.h"
 
 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 +65,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 +340,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__,
@@ -450,25 +452,13 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
        if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
                struct rte_mbuf *mbuf;
                uint8_t value;
-               uint32_t head_unchanged_len = 0, changed_len = 0;
+               uint32_t head_unchanged_len, changed_len = 0;
                uint32_t i;
 
                mbuf = sym_op->m_src;
-               if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) {
-                       /* white-box test: PMDs use some of the
-                        * tailroom as temp storage in verify case
-                        */
-                       head_unchanged_len = rte_pktmbuf_headroom(mbuf)
-                                       + rte_pktmbuf_data_len(mbuf);
-                       changed_len = digest_len;
-               } else {
-                       head_unchanged_len = mbuf->buf_len;
-                       changed_len = 0;
-               }
+               head_unchanged_len = mbuf->buf_len;
 
                for (i = 0; i < mbuf->buf_len; i++) {
-                       if (i == head_unchanged_len)
-                               i += changed_len;
                        value = *((uint8_t *)(mbuf->buf_addr)+i);
                        if (value != tmp_src_buf[i]) {
                                snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
@@ -529,19 +519,6 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
                if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
                        changed_len += digest_len;
 
-               if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) {
-                       /* white-box test: PMDs use some of the
-                        * tailroom as temp storage in verify case
-                        */
-                       if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
-                               /* This is simplified, not checking digest*/
-                               changed_len += digest_len*2;
-                       } else {
-                               head_unchanged_len += digest_len;
-                               changed_len += digest_len;
-                       }
-               }
-
                for (i = 0; i < mbuf->buf_len; i++) {
                        if (i == head_unchanged_len)
                                i += changed_len;
@@ -561,8 +538,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 +563,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)
@@ -597,7 +577,7 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
 
        int openssl_pmd = rte_cryptodev_driver_id_get(
                        RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
-       int dpaa2_pmd = rte_cryptodev_driver_id_get(
+       int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
                        RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
        int scheduler_pmd = rte_cryptodev_driver_id_get(
                        RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
@@ -663,7 +643,7 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
                target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8;
        else if (driver_id == scheduler_pmd)
                target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER;
-       else if (driver_id == dpaa2_pmd)
+       else if (driver_id == dpaa2_sec_pmd)
                target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC;
        else
                TEST_ASSERT(0, "Unrecognized cryptodev type");
@@ -675,7 +655,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);