From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 09A33A0350; Thu, 25 Jun 2020 15:32:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C3B01BEB5; Thu, 25 Jun 2020 15:31:49 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 46EE41BE80 for ; Thu, 25 Jun 2020 15:31:45 +0200 (CEST) IronPort-SDR: 65jR6je8m6zvvl4fCwf9MySqXAHoFac0pb1XCZMfvkV9iDuidPb6RpU3Lk2E/3wWLTPxMIUj9L chrCHMnf0YAA== X-IronPort-AV: E=McAfee;i="6000,8403,9662"; a="143114210" X-IronPort-AV: E=Sophos;i="5.75,279,1589266800"; d="scan'208";a="143114210" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2020 06:31:44 -0700 IronPort-SDR: nyObBhsRDNN9QKqi42KeGPNw41k9KHUDwk/6aV0z5QSdu+sXzkQ2wiwqiAuyVRfud0mGVm8RS0 iBFFUevfFzOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,279,1589266800"; d="scan'208";a="293877769" Received: from silpixa00398673.ir.intel.com (HELO silpixa00398673.ger.corp.intel.com) ([10.237.223.136]) by orsmga002.jf.intel.com with ESMTP; 25 Jun 2020 06:31:43 -0700 From: Fan Zhang To: dev@dpdk.org Cc: fiona.trahe@intel.com, akhil.goyal@nxp.com, Fan Zhang Date: Thu, 25 Jun 2020 14:31:37 +0100 Message-Id: <20200625133138.42827-3-roy.fan.zhang@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200625133138.42827-1-roy.fan.zhang@intel.com> References: <20200612143940.52851-1-roy.fan.zhang@intel.com> <20200625133138.42827-1-roy.fan.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [dpdk-dev v2 2/3] test/crypto: add unit-test for QAT direct APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds the test to use QAT symmetric crypto direct APIs. The test will be enabled only when QAT Sym PMD is built. Signed-off-by: Fan Zhang --- app/test/Makefile | 4 + app/test/meson.build | 1 + app/test/test_cryptodev.c | 371 ++++++++++++++++++++++++-- app/test/test_cryptodev.h | 6 + app/test/test_cryptodev_blockcipher.c | 50 ++-- 5 files changed, 395 insertions(+), 37 deletions(-) diff --git a/app/test/Makefile b/app/test/Makefile index 5b119aa61..da5c7648b 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -296,6 +296,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER),y) LDLIBS += -lrte_pmd_crypto_scheduler endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_QAT_SYM),y) +LDLIBS += -lrte_pmd_qat +endif + endif ifeq ($(CONFIG_RTE_APP_TEST_RESOURCE_TAR),y) diff --git a/app/test/meson.build b/app/test/meson.build index 1715ddbcb..f99395b6b 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -310,6 +310,7 @@ driver_test_names = [ 'cryptodev_sw_mvsam_autotest', 'cryptodev_sw_snow3g_autotest', 'cryptodev_sw_zuc_autotest', + 'cryptodev_qat_sym_api_autotest', 'eventdev_selftest_octeontx', 'eventdev_selftest_sw', 'rawdev_autotest', diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 8f631468b..9ac97e777 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -17,6 +17,10 @@ #include #include +#ifdef RTE_LIBRTE_PMD_QAT_SYM +#include +#endif + #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER #include #include @@ -55,6 +59,8 @@ static int gbl_driver_id; static enum rte_security_session_action_type gbl_action_type = RTE_SECURITY_ACTION_TYPE_NONE; +int qat_api_test; + struct crypto_testsuite_params { struct rte_mempool *mbuf_pool; struct rte_mempool *large_mbuf_pool; @@ -142,6 +148,164 @@ ceil_byte_length(uint32_t num_bits) return (num_bits >> 3); } +#ifdef RTE_LIBRTE_PMD_QAT_SYM +static uint32_t +get_qat_api_n_elts(void __rte_unused * frame) +{ + return 1; +} + +void +process_qat_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_op *op_ret; + void *qp = qat_sym_get_qp(dev_id, qp_id); + struct rte_crypto_sym_op *sop; + struct qat_sym_job job; + struct rte_crypto_sgl sgl; + struct rte_crypto_vec vec[UINT8_MAX] = { {0} }; + int ret; + uint32_t min_ofs = 0, max_len = 0; + uint32_t tail; + enum { + cipher = 0, + auth, + chain, + aead + } qat_api_test_type; + uint32_t count = 0; + + if (!qp) { + op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; + return; + } + + memset(&job, 0, sizeof(job)); + + sop = op->sym; + + if (is_cipher && is_auth) { + qat_api_test_type = 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) { + qat_api_test_type = cipher; + min_ofs = sop->cipher.data.offset; + max_len = sop->cipher.data.length; + } else if (is_auth) { + qat_api_test_type = auth; + min_ofs = sop->auth.data.offset; + max_len = sop->auth.data.length; + } else { /* aead */ + qat_api_test_type = 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; + } + + n = rte_crypto_mbuf_to_vec(sop->m_src, min_ofs, max_len, + vec, RTE_DIM(vec)); + if (n < 0 || n != sop->m_src->nb_segs) { + op->status = RTE_CRYPTO_OP_STATUS_ERROR; + return; + } + + if (n > 1) { + sgl.vec = vec; + sgl.num = n; + job.flags |= QAT_SYM_DESC_FLAG_IS_SGL; + job.sgl = &sgl; + } else + job.data_iova = rte_pktmbuf_iova(sop->m_src); + + + switch (qat_api_test_type) { + case aead: + job.iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET); + job.iv_iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET); + job.aead.aead_ofs = min_ofs; + job.aead.aead_len = max_len; + job.aead.aad = sop->aead.aad.data; + job.aead.aad_iova = sop->aead.aad.phys_addr; + job.aead.tag_iova = sop->aead.digest.phys_addr; + ret = qat_sym_enqueue_frame_aead(qp, sop->session, &job, + &tail, 1, 1, (void *)op); + break; + case cipher: + job.iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET); + job.cipher_only.cipher_ofs = min_ofs; + job.cipher_only.cipher_len = max_len; + ret = qat_sym_enqueue_frame_cipher(qp, sop->session, &job, + &tail, 1, 1, (void *)op); + break; + case auth: + job.auth_only.auth_ofs = min_ofs; + job.auth_only.auth_len = max_len; + job.auth_only.digest_iova = sop->auth.digest.phys_addr; + ret = qat_sym_enqueue_frame_auth(qp, sop->session, &job, + &tail, 1, 1, (void *)op); + break; + case chain: + job.iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET); + job.iv_iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET); + job.chain.cipher_ofs = sop->cipher.data.offset; + job.chain.cipher_len = sop->cipher.data.length; + if (len_in_bits) { + job.chain.cipher_len = job.chain.cipher_len >> 3; + job.chain.cipher_ofs = job.chain.cipher_ofs >> 3; + } + job.chain.auth_ofs = sop->auth.data.offset; + job.chain.auth_len = sop->auth.data.length; + if (len_in_bits) { + job.chain.auth_len = job.chain.auth_len >> 3; + job.chain.auth_ofs = job.chain.auth_ofs >> 3; + } + job.chain.digest_iova = sop->auth.digest.phys_addr; + ret = qat_sym_enqueue_frame_chain(qp, sop->session, &job, + &tail, 1, 1, (void *)op); + break; + } + + if (ret < 0) { + op->status = RTE_CRYPTO_OP_STATUS_ERROR; + return; + } + + ret = -1; + while (ret != 0 && count++ < 1024) { + ret = qat_sym_dequeue_frame(qp, (void **)&op_ret, + get_qat_api_n_elts, + offsetof(struct rte_crypto_op, status), + sizeof(struct rte_crypto_op) + + sizeof(struct rte_crypto_sym_op), + RTE_CRYPTO_OP_STATUS_SUCCESS, + RTE_CRYPTO_OP_STATUS_ERROR); + if (!op_ret) + rte_delay_ms(1); + } + if (ret < 0 || count >= 1024) + op->status = RTE_CRYPTO_OP_STATUS_ERROR; +} +#else +void +process_qat_api_op(__rte_unused uint8_t dev_id, + __rte_unused uint16_t qp_id, struct rte_crypto_op *op, + __rte_unused uint8_t is_cipher, __rte_unused uint8_t is_auth, + __rte_unused uint8_t len_in_bits) +{ + RTE_LOG(ERR, USER1, "QAT SYM is not enabled\n"); + op->status = RTE_CRYPTO_OP_STATUS_ERROR; +} +#endif + static void process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op) { @@ -2451,7 +2615,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 (qat_api_test) + process_qat_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"); @@ -2530,7 +2698,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 (qat_api_test) + process_qat_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; @@ -2600,6 +2772,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 (qat_api_test) + process_qat_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); @@ -2671,7 +2846,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 (qat_api_test) + process_qat_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; @@ -2878,8 +3057,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 (qat_api_test) + process_qat_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; @@ -2964,7 +3147,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 (qat_api_test) + process_qat_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"); @@ -3287,7 +3474,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 (qat_api_test) + process_qat_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"); @@ -3362,7 +3553,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 (qat_api_test) + process_qat_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"); @@ -3737,7 +3932,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 (qat_api_test) + process_qat_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; @@ -3905,7 +4104,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 (qat_api_test) + process_qat_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; @@ -4000,7 +4203,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 (qat_api_test) + process_qat_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; @@ -4136,7 +4343,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 (qat_api_test) + process_qat_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"); @@ -4325,7 +4536,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 (qat_api_test) + process_qat_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"); @@ -4507,7 +4722,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 (qat_api_test) + process_qat_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"); @@ -4697,7 +4916,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 (qat_api_test) + process_qat_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"); @@ -4838,7 +5061,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 (qat_api_test) + process_qat_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"); @@ -4925,7 +5152,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 (qat_api_test) + process_qat_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"); @@ -5012,7 +5243,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 (qat_api_test) + process_qat_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"); @@ -5100,7 +5335,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 (qat_api_test) + process_qat_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"); @@ -5232,7 +5471,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 (qat_api_test) + process_qat_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"); @@ -5418,7 +5661,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 (qat_api_test) + process_qat_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"); @@ -7024,6 +7271,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 (qat_api_test) + process_qat_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], @@ -7993,6 +8243,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 (qat_api_test == 1) + process_qat_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], @@ -11284,6 +11537,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 && qat_api_test == 1) + process_qat_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], @@ -13241,6 +13497,79 @@ test_cryptodev_nitrox(void) return unit_test_suite_runner(&cryptodev_nitrox_testsuite); } +#ifdef RTE_LIBRTE_PMD_QAT_SYM +static struct unit_test_suite qat_direct_api_testsuite = { + .suite_name = "Crypto QAT 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; + } + + qat_api_test = 1; + ret = unit_test_suite_runner(&qat_direct_api_testsuite); + qat_api_test = 0; + + return ret; +} + +REGISTER_TEST_COMMAND(cryptodev_qat_sym_api_autotest, test_qat_sym_direct_api); + +#endif /* RTE_LIBRTE_PMD_QAT_SYM */ + 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..6acc3f4ee 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 qat_api_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_qat_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 642b54971..0fa6895eb 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -461,25 +461,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 (qat_api_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_qat_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