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 64CE0A0559; Mon, 16 Mar 2020 14:22:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 490F81C02E; Mon, 16 Mar 2020 14:21:59 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 502B81C02D for ; Mon, 16 Mar 2020 14:21:57 +0100 (CET) IronPort-SDR: z7zyfAxHoV1c8vUKxNIHv3binJBD1KjE0NP3ycRm/wMhtOgCMC/lrYa0l8bARw+sqDrw6pN9+y bEdYCULoGatQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2020 06:21:56 -0700 IronPort-SDR: bqZxMg44JGYptyd8hUJBL2VWypaf9pE3zJtjRoWzeLRmXf7XBgDbrFGnyrsBKIWx5pUGOs7OGT XKj6i4t14rCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,560,1574150400"; d="scan'208";a="237950715" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by orsmga008.jf.intel.com with ESMTP; 16 Mar 2020 06:21:54 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com, declan.doherty@intel.com, Konstantin Ananyev Date: Mon, 16 Mar 2020 13:21:22 +0000 Message-Id: <20200316132122.4283-3-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200316132122.4283-1-konstantin.ananyev@intel.com> References: <20200316132122.4283-1-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [PATCH 2/2] test/crypto: add CPU crypto mode for AESNI MB 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 ability to run unit tests in cpu crypto mode for AESNI MB cryptodev. Signed-off-by: Konstantin Ananyev --- app/test/test_cryptodev.c | 146 ++++++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 31 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 7b1ef5c86..7235b701b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -143,7 +143,7 @@ ceil_byte_length(uint32_t num_bits) } static void -process_cpu_gmac_op(uint8_t dev_id, struct rte_crypto_op *op) +process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op) { int32_t n, st; void *iv; @@ -155,8 +155,8 @@ process_cpu_gmac_op(uint8_t dev_id, struct rte_crypto_op *op) sop = op->sym; - n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset, - sop->auth.data.length, vec, RTE_DIM(vec)); + n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset, + sop->aead.data.length, vec, RTE_DIM(vec)); if (n < 0 || n != sop->m_src->nb_segs) { op->status = RTE_CRYPTO_OP_STATUS_ERROR; @@ -168,8 +168,8 @@ process_cpu_gmac_op(uint8_t dev_id, struct rte_crypto_op *op) symvec.sgl = &sgl; iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET); symvec.iv = &iv; - symvec.aad = NULL; - symvec.digest = (void **)&sop->auth.digest.data; + symvec.aad = (void **)&sop->aead.aad.data; + symvec.digest = (void **)&sop->aead.digest.data; symvec.status = &st; symvec.num = 1; @@ -184,9 +184,8 @@ process_cpu_gmac_op(uint8_t dev_id, struct rte_crypto_op *op) op->status = RTE_CRYPTO_OP_STATUS_SUCCESS; } - static void -process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op) +process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op) { int32_t n, st; void *iv; @@ -198,8 +197,8 @@ process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op) sop = op->sym; - n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset, - sop->aead.data.length, vec, RTE_DIM(vec)); + n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset, + sop->auth.data.length, vec, RTE_DIM(vec)); if (n < 0 || n != sop->m_src->nb_segs) { op->status = RTE_CRYPTO_OP_STATUS_ERROR; @@ -212,11 +211,14 @@ process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op) iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET); symvec.iv = &iv; symvec.aad = (void **)&sop->aead.aad.data; - symvec.digest = (void **)&sop->aead.digest.data; + symvec.digest = (void **)&sop->auth.digest.data; symvec.status = &st; symvec.num = 1; ofs.raw = 0; + 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); n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs, &symvec); @@ -1538,8 +1540,14 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void) sym_op->cipher.data.length = QUOTE_512_BYTES; /* Process crypto operation */ - TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], - ut_params->op), "failed to process sym crypto op"); + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); + else + TEST_ASSERT_NOT_NULL( + process_crypto_request(ts_params->valid_devs[0], + ut_params->op), + "failed to process sym crypto op"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, "crypto op processing failed"); @@ -1689,8 +1697,14 @@ test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, sym_op->cipher.data.length = QUOTE_512_BYTES; /* Process crypto operation */ - TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], - ut_params->op), "failed to process sym crypto op"); + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); + else + TEST_ASSERT_NOT_NULL( + process_crypto_request(ts_params->valid_devs[0], + ut_params->op), + "failed to process sym crypto op"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, "crypto op processing failed"); @@ -2637,8 +2651,13 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata) if (retval < 0) return retval; - ut_params->op = process_crypto_request(ts_params->valid_devs[0], - ut_params->op); + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); + 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"); ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) @@ -8715,6 +8734,9 @@ test_stats(void) struct rte_cryptodev *dev; cryptodev_stats_get_t temp_pfn; + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + return -ENOTSUP; + /* Verify the capabilities */ struct rte_cryptodev_sym_capability_idx cap_idx; cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; @@ -8886,8 +8908,14 @@ test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case) if (MD5_HMAC_create_op(ut_params, test_case, &plaintext)) return TEST_FAILED; - TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], - ut_params->op), "failed to process sym crypto op"); + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); + else + TEST_ASSERT_NOT_NULL( + process_crypto_request(ts_params->valid_devs[0], + ut_params->op), + "failed to process sym crypto op"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, "crypto op processing failed"); @@ -8938,8 +8966,14 @@ test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case) if (MD5_HMAC_create_op(ut_params, test_case, &plaintext)) return TEST_FAILED; - TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], - ut_params->op), "failed to process sym crypto op"); + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); + else + TEST_ASSERT_NOT_NULL( + process_crypto_request(ts_params->valid_devs[0], + ut_params->op), + "failed to process sym crypto op"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, "HMAC_MD5 crypto op processing failed"); @@ -9852,7 +9886,8 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata) ut_params->op->sym->m_src = ut_params->ibuf; if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) - process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op); + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); else TEST_ASSERT_NOT_NULL( process_crypto_request(ts_params->valid_devs[0], @@ -9968,7 +10003,8 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata) ut_params->op->sym->m_src = ut_params->ibuf; if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) - process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op); + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); else TEST_ASSERT_NOT_NULL( process_crypto_request(ts_params->valid_devs[0], @@ -10528,10 +10564,17 @@ test_authentication_verify_fail_when_data_corruption( else tag_corruption(plaintext, reference->plaintext.len); - ut_params->op = process_crypto_request(ts_params->valid_devs[0], + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) { + process_cpu_crypt_auth_op(ts_params->valid_devs[0], ut_params->op); - - TEST_ASSERT_NULL(ut_params->op, "authentication not failed"); + TEST_ASSERT_NOT_EQUAL(ut_params->op->status, + RTE_CRYPTO_OP_STATUS_SUCCESS, + "authentication not failed"); + } else { + ut_params->op = process_crypto_request(ts_params->valid_devs[0], + ut_params->op); + TEST_ASSERT_NULL(ut_params->op, "authentication not failed"); + } return 0; } @@ -10593,7 +10636,8 @@ test_authentication_verify_GMAC_fail_when_corruption( tag_corruption(plaintext, reference->aad.len); if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) { - process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op); + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); TEST_ASSERT_NOT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, "authentication not failed"); @@ -10666,10 +10710,17 @@ test_authenticated_decryption_fail_when_corruption( else tag_corruption(ciphertext, reference->ciphertext.len); - ut_params->op = process_crypto_request(ts_params->valid_devs[0], + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) { + process_cpu_crypt_auth_op(ts_params->valid_devs[0], ut_params->op); - - TEST_ASSERT_NULL(ut_params->op, "authentication not failed"); + TEST_ASSERT_NOT_EQUAL(ut_params->op->status, + RTE_CRYPTO_OP_STATUS_SUCCESS, + "authentication not failed"); + } else { + ut_params->op = process_crypto_request(ts_params->valid_devs[0], + ut_params->op); + TEST_ASSERT_NULL(ut_params->op, "authentication not failed"); + } return 0; } @@ -10757,8 +10808,12 @@ test_authenticated_encryt_with_esn( if (retval < 0) return retval; - ut_params->op = process_crypto_request(ts_params->valid_devs[0], + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + process_cpu_crypt_auth_op(ts_params->valid_devs[0], ut_params->op); + else + ut_params->op = process_crypto_request( + ts_params->valid_devs[0], ut_params->op); TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned"); @@ -10873,7 +10928,11 @@ test_authenticated_decrypt_with_esn( if (retval < 0) return retval; - ut_params->op = process_crypto_request(ts_params->valid_devs[0], + if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) + process_cpu_crypt_auth_op(ts_params->valid_devs[0], + ut_params->op); + else + ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op); TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process"); @@ -13377,6 +13436,29 @@ test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) return unit_test_suite_runner(&cryptodev_testsuite); } +static int +test_cryptodev_cpu_aesni_mb(void) +{ + int32_t rc; + enum rte_security_session_action_type at; + + gbl_driver_id = rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); + + if (gbl_driver_id == -1) { + RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if " + "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled " + "in config file to run this testsuite.\n"); + return TEST_SKIPPED; + } + + at = gbl_action_type; + gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO; + rc = unit_test_suite_runner(&cryptodev_testsuite); + gbl_action_type = at; + return rc; +} + static int test_cryptodev_openssl(void) { @@ -13668,6 +13750,8 @@ test_cryptodev_nitrox(void) 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, + test_cryptodev_cpu_aesni_mb); REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl); REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm); REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest, -- 2.17.1