X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=app%2Ftest%2Ftest_cryptodev.c;h=872f8b431eafc6ed56850f33dafff17603082e01;hb=c6a1d9b5abcec20ab8018c1093cc230a708a814c;hp=63317bb3c6143eb9d7e6640e7108784a879d493d;hpb=8cad932e2509203667303976ddb3f49d846c18c1;p=dpdk.git diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 63317bb3c6..872f8b431e 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -60,6 +60,7 @@ static enum rte_cryptodev_type gbl_cryptodev_type; struct crypto_testsuite_params { struct rte_mempool *mbuf_pool; + struct rte_mempool *large_mbuf_pool; struct rte_mempool *op_mpool; struct rte_cryptodev_config conf; struct rte_cryptodev_qp_conf qp_conf; @@ -169,7 +170,7 @@ testsuite_setup(void) /* Not already created so create */ ts_params->mbuf_pool = rte_pktmbuf_pool_create( "CRYPTO_MBUFPOOL", - NUM_MBUFS, MBUF_CACHE_SIZE, 0, UINT16_MAX, + NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE, rte_socket_id()); if (ts_params->mbuf_pool == NULL) { RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n"); @@ -177,6 +178,21 @@ testsuite_setup(void) } } + ts_params->large_mbuf_pool = rte_mempool_lookup( + "CRYPTO_LARGE_MBUFPOOL"); + if (ts_params->large_mbuf_pool == NULL) { + /* Not already created so create */ + ts_params->large_mbuf_pool = rte_pktmbuf_pool_create( + "CRYPTO_LARGE_MBUFPOOL", + 1, 0, 0, UINT16_MAX, + rte_socket_id()); + if (ts_params->large_mbuf_pool == NULL) { + RTE_LOG(ERR, USER1, + "Can't create CRYPTO_LARGE_MBUFPOOL\n"); + return TEST_FAILED; + } + } + ts_params->op_mpool = rte_crypto_op_pool_create( "MBUF_CRYPTO_SYM_OP_POOL", RTE_CRYPTO_OP_TYPE_SYMMETRIC, @@ -310,24 +326,24 @@ testsuite_setup(void) } } - /* Create 2 LIBCRYPTO devices if required */ - if (gbl_cryptodev_type == RTE_CRYPTODEV_LIBCRYPTO_PMD) { -#ifndef RTE_LIBRTE_PMD_LIBCRYPTO - RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_LIBCRYPTO must be" + /* Create 2 OPENSSL devices if required */ + if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) { +#ifndef RTE_LIBRTE_PMD_OPENSSL + RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be" " enabled in config file to run this testsuite.\n"); return TEST_FAILED; #endif nb_devs = rte_cryptodev_count_devtype( - RTE_CRYPTODEV_LIBCRYPTO_PMD); + RTE_CRYPTODEV_OPENSSL_PMD); if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { ret = rte_eal_vdev_init( - RTE_STR(CRYPTODEV_NAME_LIBCRYPTO_PMD), + RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), NULL); TEST_ASSERT(ret == 0, "Failed to create " "instance %u of pmd : %s", i, - RTE_STR(CRYPTODEV_NAME_LIBCRYPTO_PMD)); + RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)); } } } @@ -413,7 +429,6 @@ ut_setup(void) memset(ut_params, 0, sizeof(*ut_params)); /* Reconfigure device to default parameters */ - ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE; ts_params->conf.socket_id = SOCKET_ID_ANY; ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT; @@ -525,6 +540,7 @@ static int test_device_configure_invalid_queue_pair_ids(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; + uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs; /* Stop the device in case it's started so it can be configured */ rte_cryptodev_stop(ts_params->valid_devs[0]); @@ -579,6 +595,9 @@ test_device_configure_invalid_queue_pair_ids(void) ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs); + /* revert to original testsuite value */ + ts_params->conf.nb_queue_pairs = orig_nb_qps; + return TEST_SUCCESS; } @@ -1463,14 +1482,14 @@ test_AES_chain_mb_all(void) } static int -test_AES_chain_libcrypto_all(void) +test_AES_chain_openssl_all(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; int status; status = test_blockcipher_all_tests(ts_params->mbuf_pool, ts_params->op_mpool, ts_params->valid_devs[0], - RTE_CRYPTODEV_LIBCRYPTO_PMD, + RTE_CRYPTODEV_OPENSSL_PMD, BLKCIPHER_AES_CHAIN_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -1479,14 +1498,14 @@ test_AES_chain_libcrypto_all(void) } static int -test_AES_cipheronly_libcrypto_all(void) +test_AES_cipheronly_openssl_all(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; int status; status = test_blockcipher_all_tests(ts_params->mbuf_pool, ts_params->op_mpool, ts_params->valid_devs[0], - RTE_CRYPTODEV_LIBCRYPTO_PMD, + RTE_CRYPTODEV_OPENSSL_PMD, BLKCIPHER_AES_CIPHERONLY_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -1511,14 +1530,14 @@ test_AES_chain_qat_all(void) } static int -test_authonly_libcrypto_all(void) +test_authonly_openssl_all(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; int status; status = test_blockcipher_all_tests(ts_params->mbuf_pool, ts_params->op_mpool, ts_params->valid_devs[0], - RTE_CRYPTODEV_LIBCRYPTO_PMD, + RTE_CRYPTODEV_OPENSSL_PMD, BLKCIPHER_AUTHONLY_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -3810,14 +3829,14 @@ test_3DES_cipheronly_qat_all(void) } static int -test_3DES_chain_libcrypto_all(void) +test_3DES_chain_openssl_all(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; int status; status = test_blockcipher_all_tests(ts_params->mbuf_pool, ts_params->op_mpool, ts_params->valid_devs[0], - RTE_CRYPTODEV_LIBCRYPTO_PMD, + RTE_CRYPTODEV_OPENSSL_PMD, BLKCIPHER_3DES_CHAIN_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -3826,14 +3845,14 @@ test_3DES_chain_libcrypto_all(void) } static int -test_3DES_cipheronly_libcrypto_all(void) +test_3DES_cipheronly_openssl_all(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; int status; status = test_blockcipher_all_tests(ts_params->mbuf_pool, ts_params->op_mpool, ts_params->valid_devs[0], - RTE_CRYPTODEV_LIBCRYPTO_PMD, + RTE_CRYPTODEV_OPENSSL_PMD, BLKCIPHER_3DES_CIPHERONLY_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -5146,7 +5165,12 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata) if (retval < 0) return retval; - ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + if (tdata->aad.len > MBUF_SIZE) + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); + else + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + TEST_ASSERT_NOT_NULL(ut_params->ibuf, + "Failed to allocate input buffer in mempool"); memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); @@ -5230,7 +5254,12 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata) if (retval < 0) return retval; - ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + if (tdata->aad.len > MBUF_SIZE) + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); + else + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + TEST_ASSERT_NOT_NULL(ut_params->ibuf, + "Failed to allocate input buffer in mempool"); memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); @@ -6132,6 +6161,20 @@ static struct unit_test_suite cryptodev_qat_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_kasumi_cipher_auth_test_case_1), + /** Negative tests */ + TEST_CASE_ST(ut_setup, ut_teardown, + authentication_verify_HMAC_SHA1_fail_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + authentication_verify_HMAC_SHA1_fail_tag_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + authentication_verify_AES128_GMAC_fail_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + authentication_verify_AES128_GMAC_fail_tag_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; @@ -6147,8 +6190,8 @@ static struct unit_test_suite cryptodev_aesni_mb_testsuite = { } }; -static struct unit_test_suite cryptodev_libcrypto_testsuite = { - .suite_name = "Crypto Device LIBCRYPTO Unit Test Suite", +static struct unit_test_suite cryptodev_openssl_testsuite = { + .suite_name = "Crypto Device OPENSSL Unit Test Suite", .setup = testsuite_setup, .teardown = testsuite_teardown, .unit_test_cases = { @@ -6156,15 +6199,15 @@ static struct unit_test_suite cryptodev_libcrypto_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session_random_usage), TEST_CASE_ST(ut_setup, ut_teardown, - test_AES_chain_libcrypto_all), + test_AES_chain_openssl_all), TEST_CASE_ST(ut_setup, ut_teardown, - test_AES_cipheronly_libcrypto_all), + test_AES_cipheronly_openssl_all), TEST_CASE_ST(ut_setup, ut_teardown, - test_3DES_chain_libcrypto_all), + test_3DES_chain_openssl_all), TEST_CASE_ST(ut_setup, ut_teardown, - test_3DES_cipheronly_libcrypto_all), + test_3DES_cipheronly_openssl_all), TEST_CASE_ST(ut_setup, ut_teardown, - test_authonly_libcrypto_all), + test_authonly_openssl_all), /** AES GCM Authenticated Encryption */ TEST_CASE_ST(ut_setup, ut_teardown, @@ -6477,11 +6520,11 @@ test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) } static int -test_cryptodev_libcrypto(void) +test_cryptodev_openssl(void) { - gbl_cryptodev_type = RTE_CRYPTODEV_LIBCRYPTO_PMD; + gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD; - return unit_test_suite_runner(&cryptodev_libcrypto_testsuite); + return unit_test_suite_runner(&cryptodev_openssl_testsuite); } static int @@ -6526,7 +6569,7 @@ test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/) REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat); REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb); -REGISTER_TEST_COMMAND(cryptodev_libcrypto_autotest, test_cryptodev_libcrypto); +REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl); REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm); REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null); REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);