This patch adds the QAT test to use cryptodev symmetric crypto
direct APIs.

Signed-off-by: Fan Zhang <roy.fan.zh...@intel.com>
---
 app/test/test_cryptodev.c             | 354 ++++++++++++++++++++++++--
 app/test/test_cryptodev.h             |   6 +
 app/test/test_cryptodev_blockcipher.c |  50 ++--
 3 files changed, 373 insertions(+), 37 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c..d6909984d 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -49,6 +49,8 @@
 #define VDEV_ARGS_SIZE 100
 #define MAX_NB_SESSIONS 4
 
+#define MAX_DRV_SERVICE_CTX_SIZE 256
+
 #define IN_PLACE 0
 #define OUT_OF_PLACE 1
 
@@ -57,6 +59,8 @@ static int gbl_driver_id;
 static enum rte_security_session_action_type gbl_action_type =
        RTE_SECURITY_ACTION_TYPE_NONE;
 
+int hw_dp_test;
+
 struct crypto_testsuite_params {
        struct rte_mempool *mbuf_pool;
        struct rte_mempool *large_mbuf_pool;
@@ -147,6 +151,153 @@ ceil_byte_length(uint32_t num_bits)
                return (num_bits >> 3);
 }
 
+void
+process_sym_hw_api_op(uint8_t dev_id, uint16_t qp_id, struct rte_crypto_op *op,
+               uint8_t is_cipher, uint8_t is_auth, uint8_t len_in_bits)
+{
+       int32_t n;
+       struct rte_crypto_sym_op *sop;
+       struct rte_crypto_op *ret_op = NULL;
+       struct rte_crypto_vec data_vec[UINT8_MAX];
+       struct rte_crypto_data iv_vec, aad_vec, digest_vec;
+       union rte_crypto_sym_ofs ofs;
+       int32_t status;
+       uint32_t min_ofs, max_len;
+       union rte_cryptodev_session_ctx sess;
+       enum rte_crypto_dp_service service_type;
+       uint32_t count = 0;
+       uint8_t service_data[MAX_DRV_SERVICE_CTX_SIZE] = {0};
+       struct rte_crypto_dp_service_ctx *ctx = (void *)service_data;
+       int ctx_service_size;
+
+       sop = op->sym;
+
+       sess.crypto_sess = sop->session;
+
+       if (is_cipher && is_auth) {
+               service_type = RTE_CRYPTO_DP_SYM_CHAIN;
+               min_ofs = RTE_MIN(sop->cipher.data.offset,
+                               sop->auth.data.offset);
+               max_len = RTE_MAX(sop->cipher.data.length,
+                               sop->auth.data.length);
+       } else if (is_cipher) {
+               service_type = RTE_CRYPTO_DP_SYM_CIPHER_ONLY;
+               min_ofs = sop->cipher.data.offset;
+               max_len = sop->cipher.data.length;
+       } else if (is_auth) {
+               service_type = RTE_CRYPTO_DP_SYM_AUTH_ONLY;
+               min_ofs = sop->auth.data.offset;
+               max_len = sop->auth.data.length;
+       } else { /* aead */
+               service_type = RTE_CRYPTO_DP_SYM_AEAD;
+               min_ofs = sop->aead.data.offset;
+               max_len = sop->aead.data.length;
+       }
+
+       if (len_in_bits) {
+               max_len = max_len >> 3;
+               min_ofs = min_ofs >> 3;
+       }
+
+       ctx_service_size = rte_cryptodev_get_dp_service_ctx_data_size(dev_id);
+       assert(ctx_service_size <= MAX_DRV_SERVICE_CTX_SIZE &&
+                       ctx_service_size > 0);
+
+       if (rte_cryptodev_dp_configure_service(dev_id, qp_id, service_type,
+                       RTE_CRYPTO_OP_WITH_SESSION, sess, ctx, 0) < 0) {
+               op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               return;
+       }
+
+       /* test update service */
+       if (rte_cryptodev_dp_configure_service(dev_id, qp_id, service_type,
+                       RTE_CRYPTO_OP_WITH_SESSION, sess, ctx, 1) < 0) {
+               op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               return;
+       }
+
+       n = rte_crypto_mbuf_to_vec(sop->m_src, 0, min_ofs + max_len,
+                       data_vec, RTE_DIM(data_vec));
+       if (n < 0 || n != sop->m_src->nb_segs) {
+               op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               return;
+       }
+
+       ofs.raw = 0;
+
+       iv_vec.base = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
+       iv_vec.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
+
+       switch (service_type) {
+       case RTE_CRYPTO_DP_SYM_AEAD:
+               ofs.ofs.cipher.head = sop->cipher.data.offset;
+               aad_vec.base = (void *)sop->aead.aad.data;
+               aad_vec.iova = sop->aead.aad.phys_addr;
+               digest_vec.base = (void *)sop->aead.digest.data;
+               digest_vec.iova = sop->aead.digest.phys_addr;
+               if (len_in_bits) {
+                       ofs.ofs.cipher.head >>= 3;
+                       ofs.ofs.cipher.tail >>= 3;
+               }
+               break;
+       case RTE_CRYPTO_DP_SYM_CIPHER_ONLY:
+               ofs.ofs.cipher.head = sop->cipher.data.offset;
+               if (len_in_bits) {
+                       ofs.ofs.cipher.head >>= 3;
+                       ofs.ofs.cipher.tail >>= 3;
+               }
+               break;
+       case RTE_CRYPTO_DP_SYM_AUTH_ONLY:
+               ofs.ofs.auth.head = sop->auth.data.offset;
+               digest_vec.base = (void *)sop->auth.digest.data;
+               digest_vec.iova = sop->auth.digest.phys_addr;
+               break;
+       case RTE_CRYPTO_DP_SYM_CHAIN:
+               ofs.ofs.cipher.head =
+                       sop->cipher.data.offset - sop->auth.data.offset;
+               ofs.ofs.cipher.tail =
+                       (sop->auth.data.offset + sop->auth.data.length) -
+                       (sop->cipher.data.offset + sop->cipher.data.length);
+               if (len_in_bits) {
+                       ofs.ofs.cipher.head >>= 3;
+                       ofs.ofs.cipher.tail >>= 3;
+               }
+               digest_vec.base = (void *)sop->auth.digest.data;
+               digest_vec.iova = sop->auth.digest.phys_addr;
+               break;
+       default:
+               break;
+       }
+
+       status = rte_cryptodev_dp_submit_single_job(ctx, data_vec, n, ofs,
+               &iv_vec, &digest_vec, &aad_vec, (void *)op);
+       if (status < 0) {
+               op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               return;
+       }
+
+       rte_cryptodev_dp_submit_done(ctx, 1);
+
+       status = -1;
+       while (count++ < 1024 && status == -1) {
+               status = rte_cryptodev_dp_sym_dequeue_single_job(ctx,
+                               (void **)&ret_op);
+               if (status == -1)
+                       rte_pause();
+       }
+
+       if (status != -1)
+               rte_cryptodev_dp_dequeue_done(ctx, 1);
+
+       if (count == 1025 || status != 1 || ret_op != op) {
+               op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               return;
+       }
+
+       op->status = status == 1 ? RTE_CRYPTO_OP_STATUS_SUCCESS :
+                       RTE_CRYPTO_OP_STATUS_ERROR;
+}
+
 static void
 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
 {
@@ -2470,7 +2621,11 @@ test_snow3g_authentication(const struct 
snow3g_hash_test_data *tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                ut_params->op);
        ut_params->obuf = ut_params->op->sym->m_src;
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -2549,7 +2704,11 @@ test_snow3g_authentication_verify(const struct 
snow3g_hash_test_data *tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
        ut_params->obuf = ut_params->op->sym->m_src;
@@ -2619,6 +2778,9 @@ test_kasumi_authentication(const struct 
kasumi_hash_test_data *tdata)
        if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
                process_cpu_crypt_auth_op(ts_params->valid_devs[0],
                        ut_params->op);
+       else if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 1, 1);
        else
                ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
@@ -2690,7 +2852,11 @@ test_kasumi_authentication_verify(const struct 
kasumi_hash_test_data *tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
        ut_params->obuf = ut_params->op->sym->m_src;
@@ -2897,8 +3063,12 @@ test_kasumi_encryption(const struct kasumi_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
-                                               ut_params->op);
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 0, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+                               ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 
        ut_params->obuf = ut_params->op->sym->m_dst;
@@ -2983,7 +3153,11 @@ test_kasumi_encryption_sgl(const struct kasumi_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 0, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 
@@ -3306,7 +3480,11 @@ test_kasumi_decryption(const struct kasumi_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 0, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 
@@ -3381,7 +3559,11 @@ test_snow3g_encryption(const struct snow3g_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 0, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 
@@ -3756,7 +3938,11 @@ static int test_snow3g_decryption(const struct 
snow3g_test_data *tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 0, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
        ut_params->obuf = ut_params->op->sym->m_dst;
@@ -3924,7 +4110,11 @@ test_zuc_cipher_auth(const struct wireless_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
        ut_params->obuf = ut_params->op->sym->m_src;
@@ -4019,7 +4209,11 @@ test_snow3g_cipher_auth(const struct snow3g_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
        ut_params->obuf = ut_params->op->sym->m_src;
@@ -4155,7 +4349,11 @@ test_snow3g_auth_cipher(const struct snow3g_test_data 
*tdata,
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
 
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -4344,7 +4542,11 @@ test_snow3g_auth_cipher_sgl(const struct 
snow3g_test_data *tdata,
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
 
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -4526,7 +4728,11 @@ test_kasumi_auth_cipher(const struct kasumi_test_data 
*tdata,
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
 
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -4716,7 +4922,11 @@ test_kasumi_auth_cipher_sgl(const struct 
kasumi_test_data *tdata,
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
 
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -4857,7 +5067,11 @@ test_kasumi_cipher_auth(const struct kasumi_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 
@@ -4944,7 +5158,11 @@ test_zuc_encryption(const struct wireless_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 0, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 
@@ -5031,7 +5249,11 @@ test_zuc_encryption_sgl(const struct wireless_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 0, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                                ut_params->op);
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
 
@@ -5119,7 +5341,11 @@ test_zuc_authentication(const struct wireless_test_data 
*tdata)
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                                ut_params->op);
        ut_params->obuf = ut_params->op->sym->m_src;
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -5251,7 +5477,11 @@ test_zuc_auth_cipher(const struct wireless_test_data 
*tdata,
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
 
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -5437,7 +5667,11 @@ test_zuc_auth_cipher_sgl(const struct wireless_test_data 
*tdata,
        if (retval < 0)
                return retval;
 
-       ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+       if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 1, 1, 1);
+       else
+               ut_params->op = process_crypto_request(ts_params->valid_devs[0],
                        ut_params->op);
 
        TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
@@ -7043,6 +7277,9 @@ test_authenticated_encryption(const struct aead_test_data 
*tdata)
        /* Process crypto operation */
        if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
                process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
+       else if (hw_dp_test)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 0, 0);
        else
                TEST_ASSERT_NOT_NULL(
                        process_crypto_request(ts_params->valid_devs[0],
@@ -8540,6 +8777,9 @@ test_authenticated_decryption(const struct aead_test_data 
*tdata)
        /* Process crypto operation */
        if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
                process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
+       else if (hw_dp_test == 1)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 0, 0);
        else
                TEST_ASSERT_NOT_NULL(
                        process_crypto_request(ts_params->valid_devs[0],
@@ -11480,6 +11720,9 @@ test_authenticated_encryption_SGL(const struct 
aead_test_data *tdata,
        if (oop == IN_PLACE &&
                        gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
                process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
+       else if (oop == IN_PLACE && hw_dp_test == 1)
+               process_sym_hw_api_op(ts_params->valid_devs[0], 0,
+                               ut_params->op, 0, 0, 0);
        else
                TEST_ASSERT_NOT_NULL(
                        process_crypto_request(ts_params->valid_devs[0],
@@ -13041,6 +13284,75 @@ test_cryptodev_nitrox(void)
        return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
 }
 
+static struct unit_test_suite cryptodev_sym_direct_api_testsuite = {
+       .suite_name = "Crypto Sym direct API Test Suite",
+       .setup = testsuite_setup,
+       .teardown = testsuite_teardown,
+       .unit_test_cases = {
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_snow3g_encryption_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_snow3g_decryption_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_snow3g_auth_cipher_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_snow3g_auth_cipher_verify_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_kasumi_hash_generate_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_kasumi_hash_verify_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_kasumi_encryption_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_kasumi_decryption_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
+               TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
+               TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_CCM_authenticated_encryption_test_case_128_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_CCM_authenticated_decryption_test_case_128_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_authenticated_encryption_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_authenticated_decryption_test_case_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_auth_encryption_test_case_192_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_auth_decryption_test_case_192_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_auth_encryption_test_case_256_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_auth_decryption_test_case_256_1),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
+               TEST_CASES_END() /**< NULL terminate unit test array */
+       }
+};
+
+static int
+test_qat_sym_direct_api(void /*argv __rte_unused, int argc __rte_unused*/)
+{
+       int ret;
+
+       gbl_driver_id = rte_cryptodev_driver_id_get(
+                       RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
+
+       if (gbl_driver_id == -1) {
+               RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
+               "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
+               "are enabled in config file to run this testsuite.\n");
+               return TEST_SKIPPED;
+       }
+
+       hw_dp_test = 1;
+       ret = unit_test_suite_runner(&cryptodev_sym_direct_api_testsuite);
+       hw_dp_test = 0;
+
+       return ret;
+}
+
+REGISTER_TEST_COMMAND(cryptodev_qat_sym_api_autotest, test_qat_sym_direct_api);
 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index 41542e055..c382c12c4 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -71,6 +71,8 @@
 #define CRYPTODEV_NAME_CAAM_JR_PMD     crypto_caam_jr
 #define CRYPTODEV_NAME_NITROX_PMD      crypto_nitrox_sym
 
+extern int hw_dp_test;
+
 /**
  * Write (spread) data from buffer to mbuf data
  *
@@ -209,4 +211,8 @@ create_segmented_mbuf(struct rte_mempool *mbuf_pool, int 
pkt_len,
        return NULL;
 }
 
+void
+process_sym_hw_api_op(uint8_t dev_id, uint16_t qp_id, struct rte_crypto_op *op,
+               uint8_t is_cipher, uint8_t is_auth, uint8_t len_in_bits);
+
 #endif /* TEST_CRYPTODEV_H_ */
diff --git a/app/test/test_cryptodev_blockcipher.c 
b/app/test/test_cryptodev_blockcipher.c
index 221262341..fc540e362 100644
--- a/app/test/test_cryptodev_blockcipher.c
+++ b/app/test/test_cryptodev_blockcipher.c
@@ -462,25 +462,43 @@ test_blockcipher_one_case(const struct 
blockcipher_test_case *t,
        }
 
        /* Process crypto operation */
-       if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-               snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
-                       "line %u FAILED: %s",
-                       __LINE__, "Error sending packet for encryption");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
+       if (hw_dp_test) {
+               uint8_t is_cipher = 0, is_auth = 0;
+
+               if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
+                       RTE_LOG(DEBUG, USER1,
+                       "QAT direct API does not support OOP, Test Skipped.\n");
+                       snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
+                       status = TEST_SUCCESS;
+                       goto error_exit;
+               }
+               if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
+                       is_cipher = 1;
+               if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
+                       is_auth = 1;
+
+               process_sym_hw_api_op(dev_id, 0, op, is_cipher, is_auth, 0);
+       } else {
+               if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+                       snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
+                               "line %u FAILED: %s",
+                               __LINE__, "Error sending packet for 
encryption");
+                       status = TEST_FAILED;
+                       goto error_exit;
+               }
 
-       op = NULL;
+               op = NULL;
 
-       while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
-               rte_pause();
+               while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
+                       rte_pause();
 
-       if (!op) {
-               snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
-                       "line %u FAILED: %s",
-                       __LINE__, "Failed to process sym crypto op");
-               status = TEST_FAILED;
-               goto error_exit;
+               if (!op) {
+                       snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
+                               "line %u FAILED: %s",
+                               __LINE__, "Failed to process sym crypto op");
+                       status = TEST_FAILED;
+                       goto error_exit;
+               }
        }
 
        debug_hexdump(stdout, "m_src(after):",
-- 
2.20.1

Reply via email to