X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=test%2Ftest%2Ftest_cryptodev.c;h=cbbdb1518531dc93759649bf463c2c18536e8b6a;hb=84aaaf8e628ab53869c35430013a19e872b77e69;hp=72988c5610eec56334eae9511a36882962a0c920;hpb=a389434efc1b6846dd345def27178d9be24cb914;p=dpdk.git diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index 72988c5610..cbbdb15185 100644 --- a/test/test/test_cryptodev.c +++ b/test/test/test_cryptodev.c @@ -1,41 +1,16 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2015-2017 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015-2017 Intel Corporation */ +#include + #include #include #include #include #include #include +#include #include #include @@ -46,6 +21,8 @@ #include #endif +#include + #include "test.h" #include "test_cryptodev.h" @@ -61,6 +38,9 @@ #include "test_cryptodev_aead_test_vectors.h" #include "test_cryptodev_hmac_test_vectors.h" +#define VDEV_ARGS_SIZE 100 +#define MAX_NB_SESSIONS 4 + static int gbl_driver_id; struct crypto_testsuite_params { @@ -341,40 +321,81 @@ testsuite_setup(void) } } - /* Create a MRVL device if required */ + /* Create a MVSAM device if required */ if (gbl_driver_id == rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_MRVL_PMD))) { -#ifndef RTE_LIBRTE_PMD_MRVL_CRYPTO - RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO must be" - " enabled in config file to run this testsuite.\n"); - return TEST_FAILED; -#endif + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) { nb_devs = rte_cryptodev_device_count_by_driver( rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD))); + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))); if (nb_devs < 1) { ret = rte_vdev_init( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD), NULL); TEST_ASSERT(ret == 0, "Failed to create " "instance of pmd : %s", - RTE_STR(CRYPTODEV_NAME_MRVL_PMD)); + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)); + } + } + + /* Create an CCP device if required */ + if (gbl_driver_id == rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD))) { + nb_devs = rte_cryptodev_device_count_by_driver( + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD))); + if (nb_devs < 1) { + ret = rte_vdev_init( + RTE_STR(CRYPTODEV_NAME_CCP_PMD), + NULL); + + TEST_ASSERT(ret == 0, "Failed to create " + "instance of pmd : %s", + RTE_STR(CRYPTODEV_NAME_CCP_PMD)); } } #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER + char vdev_args[VDEV_ARGS_SIZE] = {""}; + char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core," + "ordering=enable,name=cryptodev_test_scheduler,corelist="}; + uint16_t slave_core_count = 0; + uint16_t socket_id = 0; + if (gbl_driver_id == rte_cryptodev_driver_id_get( RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) { + /* Identify the Slave Cores + * Use 2 slave cores for the device args + */ + RTE_LCORE_FOREACH_SLAVE(i) { + if (slave_core_count > 1) + break; + snprintf(vdev_args, sizeof(vdev_args), + "%s%d", temp_str, i); + strcpy(temp_str, vdev_args); + strcat(temp_str, ";"); + slave_core_count++; + socket_id = lcore_config[i].socket_id; + } + if (slave_core_count != 2) { + RTE_LOG(ERR, USER1, + "Cryptodev scheduler test require at least " + "two slave cores to run. " + "Please use the correct coremask.\n"); + return TEST_FAILED; + } + strcpy(temp_str, vdev_args); + snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d", + temp_str, socket_id); + RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args); nb_devs = rte_cryptodev_device_count_by_driver( rte_cryptodev_driver_id_get( RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))); if (nb_devs < 1) { ret = rte_vdev_init( RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD), - NULL); - + vdev_args); TEST_ASSERT(ret == 0, "Failed to create instance %u of" " pmd : %s", @@ -408,15 +429,24 @@ testsuite_setup(void) ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs; ts_params->conf.socket_id = SOCKET_ID_ANY; - unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id); + unsigned int session_size = + rte_cryptodev_sym_get_private_session_size(dev_id); /* * Create mempool with maximum number of sessions * 2, * to include the session headers */ + if (info.sym.max_nb_sessions != 0 && + info.sym.max_nb_sessions < MAX_NB_SESSIONS) { + RTE_LOG(ERR, USER1, "Device does not support " + "at least %u sessions\n", + MAX_NB_SESSIONS); + return TEST_FAILED; + } + ts_params->session_mpool = rte_mempool_create( "test_sess_mp", - info.sym.max_nb_sessions * 2, + MAX_NB_SESSIONS * 2, session_size, 0, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, @@ -564,7 +594,7 @@ test_device_configure_invalid_dev_id(void) dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1]; /* Stop the device in case it's started so it can be configured */ - rte_cryptodev_stop(ts_params->valid_devs[dev_id]); + rte_cryptodev_stop(dev_id); TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf), "Failed test for rte_cryptodev_configure: " @@ -1332,7 +1362,7 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void) /* Set crypto operation authentication parameters */ sym_op->auth.digest.data = ut_params->digest; - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, QUOTE_512_BYTES); sym_op->auth.data.offset = 0; @@ -1484,7 +1514,7 @@ test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, sym_op->m_src = ut_params->ibuf; sym_op->auth.digest.data = ut_params->digest; - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, QUOTE_512_BYTES); sym_op->auth.data.offset = 0; @@ -1751,6 +1781,44 @@ test_AES_cipheronly_openssl_all(void) return TEST_SUCCESS; } +static int +test_AES_chain_ccp_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->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD)), + BLKCIPHER_AES_CHAIN_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + +static int +test_AES_cipheronly_ccp_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->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD)), + BLKCIPHER_AES_CIPHERONLY_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + static int test_AES_chain_qat_all(void) { @@ -1789,6 +1857,25 @@ test_AES_cipheronly_qat_all(void) return TEST_SUCCESS; } +static int +test_AES_cipheronly_virtio_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->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)), + BLKCIPHER_AES_CIPHERONLY_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + static int test_AES_chain_dpaa_sec_all(void) { @@ -1922,6 +2009,25 @@ test_authonly_openssl_all(void) return TEST_SUCCESS; } +static int +test_authonly_ccp_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->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD)), + BLKCIPHER_AUTHONLY_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + static int test_AES_chain_armv8_all(void) { @@ -1952,7 +2058,7 @@ test_AES_chain_mrvl_all(void) ts_params->session_mpool, ts_params->valid_devs[0], rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD)), + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), BLKCIPHER_AES_CHAIN_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -1971,7 +2077,7 @@ test_AES_cipheronly_mrvl_all(void) ts_params->session_mpool, ts_params->valid_devs[0], rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD)), + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), BLKCIPHER_AES_CIPHERONLY_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -1990,7 +2096,7 @@ test_authonly_mrvl_all(void) ts_params->session_mpool, ts_params->valid_devs[0], rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD)), + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), BLKCIPHER_AUTHONLY_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -2009,7 +2115,7 @@ test_3DES_chain_mrvl_all(void) ts_params->session_mpool, ts_params->valid_devs[0], rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD)), + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), BLKCIPHER_3DES_CHAIN_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -2028,7 +2134,7 @@ test_3DES_cipheronly_mrvl_all(void) ts_params->session_mpool, ts_params->valid_devs[0], rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD)), + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), BLKCIPHER_3DES_CIPHERONLY_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -2051,7 +2157,7 @@ create_wireless_algo_hash_session(uint8_t dev_id, memcpy(hash_key, key, key_len); - TEST_HEXDUMP(stdout, "key:", key, key_len); + debug_hexdump(stdout, "key:", key, key_len); /* Setup Authentication Parameters */ ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; @@ -2098,7 +2204,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id, ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; ut_params->cipher_xform.cipher.iv.length = iv_len; - TEST_HEXDUMP(stdout, "key:", key, key_len); + debug_hexdump(stdout, "key:", key, key_len); /* Create Crypto session */ ut_params->sess = rte_cryptodev_sym_session_create( @@ -2214,7 +2320,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id, ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; - TEST_HEXDUMP(stdout, "key:", key, key_len); + debug_hexdump(stdout, "key:", key, key_len); /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( @@ -2273,7 +2379,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id, ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; - TEST_HEXDUMP(stdout, "key:", key, key_len); + debug_hexdump(stdout, "key:", key, key_len); /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( @@ -2335,7 +2441,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id, ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; - TEST_HEXDUMP(stdout, "key:", key, key_len); + debug_hexdump(stdout, "key:", key, key_len); /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( @@ -2385,14 +2491,14 @@ create_wireless_algo_hash_operation(const uint8_t *auth_tag, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append auth tag"); ut_params->digest = sym_op->auth.digest.data; - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, data_pad_len); if (op == RTE_CRYPTO_AUTH_OP_GENERATE) memset(sym_op->auth.digest.data, 0, auth_tag_len); else rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, auth_tag_len); @@ -2441,14 +2547,14 @@ create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append auth tag"); ut_params->digest = sym_op->auth.digest.data; - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, data_pad_len); if (op == RTE_CRYPTO_AUTH_OP_GENERATE) memset(sym_op->auth.digest.data, 0, auth_tag_len); else rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, auth_tag_len); @@ -2508,14 +2614,14 @@ create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append auth tag"); ut_params->digest = sym_op->auth.digest.data; - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, data_pad_len); if (op == RTE_CRYPTO_AUTH_OP_GENERATE) memset(sym_op->auth.digest.data, 0, auth_tag_len); else rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, auth_tag_len); @@ -2566,12 +2672,12 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append auth tag"); - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, data_pad_len); memset(sym_op->auth.digest.data, 0, auth_tag_len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, auth_tag_len); @@ -3004,7 +3110,7 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, @@ -3024,7 +3130,7 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata) else ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); const uint8_t *reference_ciphertext = tdata->ciphertext.data + (tdata->validCipherOffsetInBits.len >> 3); @@ -3054,8 +3160,11 @@ test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata) struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); - if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) { - printf("Device doesn't support scatter-gather. " + + uint64_t feat_flags = dev_info.feature_flags; + + if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { + printf("Device doesn't support in-place scatter-gather. " "Test Skipped.\n"); return 0; } @@ -3104,7 +3213,7 @@ test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata) plaintext_len, buffer); /* Validate obuf */ - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); const uint8_t *reference_ciphertext = tdata->ciphertext.data + (tdata->validCipherOffsetInBits.len >> 3); @@ -3153,7 +3262,7 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata) rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, @@ -3173,7 +3282,7 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata) else ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); const uint8_t *reference_ciphertext = tdata->ciphertext.data + (tdata->validCipherOffsetInBits.len >> 3); @@ -3202,8 +3311,11 @@ test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata) struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); - if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) { - printf("Device doesn't support scatter-gather. " + + uint64_t feat_flags = dev_info.feature_flags; + if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { + printf("Device doesn't support out-of-place scatter-gather " + "in both input and output mbufs. " "Test Skipped.\n"); return 0; } @@ -3300,7 +3412,7 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata) rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, @@ -3320,7 +3432,7 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata) else plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); + debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); const uint8_t *reference_plaintext = tdata->plaintext.data + (tdata->validCipherOffsetInBits.len >> 3); @@ -3367,7 +3479,7 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata) ciphertext_pad_len); memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, @@ -3387,7 +3499,7 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata) else plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); + debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); const uint8_t *reference_plaintext = tdata->plaintext.data + (tdata->validCipherOffsetInBits.len >> 3); @@ -3434,7 +3546,7 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW 3G operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, @@ -3454,7 +3566,7 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -3507,7 +3619,7 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW 3G operation */ retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, @@ -3527,7 +3639,7 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -3553,8 +3665,12 @@ test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata) struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); - if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) { - printf("Device doesn't support scatter-gather. " + + uint64_t feat_flags = dev_info.feature_flags; + + if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { + printf("Device doesn't support out-of-place scatter-gather " + "in both input and output mbufs. " "Test Skipped.\n"); return 0; } @@ -3605,7 +3721,7 @@ test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata) ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, plaintext_len, buffer); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -3763,7 +3879,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata) ciphertext_pad_len); memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create SNOW 3G operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, @@ -3782,7 +3898,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata) else plaintext = ciphertext; - TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); + debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, @@ -3836,7 +3952,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create SNOW 3G operation */ retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, @@ -3855,7 +3971,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) else plaintext = ciphertext; - TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); + debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, @@ -3915,7 +4031,7 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create ZUC operation */ retval = create_zuc_cipher_hash_generate_operation(tdata); @@ -3931,7 +4047,7 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, @@ -3988,7 +4104,7 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW 3G operation */ retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data, @@ -4013,7 +4129,7 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, @@ -4070,7 +4186,7 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW 3G operation */ retval = create_wireless_algo_auth_cipher_operation( @@ -4097,7 +4213,7 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) + plaintext_pad_len; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -4153,7 +4269,7 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create KASUMI operation */ retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len, @@ -4239,7 +4355,7 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create KASUMI operation */ retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data, @@ -4331,7 +4447,7 @@ test_zuc_encryption(const struct wireless_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); + debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); /* Create ZUC operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, @@ -4351,7 +4467,7 @@ test_zuc_encryption(const struct wireless_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -4387,10 +4503,13 @@ test_zuc_encryption_sgl(const struct wireless_test_data *tdata) return -ENOTSUP; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); - if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) { - printf("Device doesn't support scatter-gather. " + + uint64_t feat_flags = dev_info.feature_flags; + + if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { + printf("Device doesn't support in-place scatter-gather. " "Test Skipped.\n"); - return -ENOTSUP; + return 0; } plaintext_len = ceil_byte_length(tdata->plaintext.len); @@ -4438,7 +4557,7 @@ test_zuc_encryption_sgl(const struct wireless_test_data *tdata) 0, plaintext_len, ciphertext_buffer); /* Validate obuf */ - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -4997,6 +5116,44 @@ test_3DES_cipheronly_dpaa2_sec_all(void) return TEST_SUCCESS; } +static int +test_3DES_chain_ccp_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->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD)), + BLKCIPHER_3DES_CHAIN_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + +static int +test_3DES_cipheronly_ccp_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->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD)), + BLKCIPHER_3DES_CIPHERONLY_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + static int test_3DES_cipheronly_qat_all(void) { @@ -5082,7 +5239,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, ut_params->aead_xform.aead.digest_length = auth_len; ut_params->aead_xform.aead.aad_length = aad_len; - TEST_HEXDUMP(stdout, "key:", key, key_len); + debug_hexdump(stdout, "key:", key, key_len); /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( @@ -5121,7 +5278,7 @@ create_aead_xform(struct rte_crypto_op *op, sym_op->xform->aead.digest_length = auth_len; sym_op->xform->aead.aad_length = aad_len; - TEST_HEXDUMP(stdout, "key:", key, key_len); + debug_hexdump(stdout, "key:", key, key_len); return 0; } @@ -5153,10 +5310,10 @@ create_aead_operation(enum rte_crypto_aead_operation op, "no room to append aad"); sym_op->aead.aad.phys_addr = - rte_pktmbuf_mtophys(ut_params->ibuf); + rte_pktmbuf_iova(ut_params->ibuf); /* Copy AAD 18 bytes after the AAD pointer, according to the API */ memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len); - TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data, + debug_hexdump(stdout, "aad:", sym_op->aead.aad.data, tdata->aad.len); /* Append IV at the end of the crypto operation*/ @@ -5165,7 +5322,7 @@ create_aead_operation(enum rte_crypto_aead_operation op, /* Copy IV 1 byte after the IV pointer, according to the API */ rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len); - TEST_HEXDUMP(stdout, "iv:", iv_ptr, + debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len); } else { aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16); @@ -5175,9 +5332,9 @@ create_aead_operation(enum rte_crypto_aead_operation op, "no room to append aad"); sym_op->aead.aad.phys_addr = - rte_pktmbuf_mtophys(ut_params->ibuf); + rte_pktmbuf_iova(ut_params->ibuf); memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len); - TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data, + debug_hexdump(stdout, "aad:", sym_op->aead.aad.data, tdata->aad.len); /* Append IV at the end of the crypto operation*/ @@ -5185,7 +5342,7 @@ create_aead_operation(enum rte_crypto_aead_operation op, uint8_t *, IV_OFFSET); rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len); - TEST_HEXDUMP(stdout, "iv:", iv_ptr, + debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len); } @@ -5197,7 +5354,7 @@ create_aead_operation(enum rte_crypto_aead_operation op, TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, + debug_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len); if (ut_params->obuf) { @@ -5219,7 +5376,7 @@ create_aead_operation(enum rte_crypto_aead_operation op, memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, + debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); if (ut_params->obuf) { @@ -5243,7 +5400,7 @@ create_aead_operation(enum rte_crypto_aead_operation op, TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data, "no room to append digest"); memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len); - sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->obuf ? ut_params->obuf : ut_params->ibuf, plaintext_pad_len + @@ -5253,13 +5410,13 @@ create_aead_operation(enum rte_crypto_aead_operation op, ut_params->ibuf, tdata->auth_tag.len); TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data, "no room to append digest"); - sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, plaintext_pad_len + aad_pad_len); rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data, tdata->auth_tag.len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->aead.digest.data, tdata->auth_tag.len); } @@ -5333,8 +5490,8 @@ test_authenticated_encryption(const struct aead_test_data *tdata) auth_tag = ciphertext + plaintext_pad_len; } - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); - TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); + debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -5547,7 +5704,7 @@ test_authenticated_decryption(const struct aead_test_data *tdata) uint8_t *, ut_params->op->sym->cipher.data.offset); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len); + debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -5752,8 +5909,8 @@ test_authenticated_encryption_oop(const struct aead_test_data *tdata) ut_params->op->sym->cipher.data.offset); auth_tag = ciphertext + plaintext_pad_len; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); - TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); + debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -5826,7 +5983,7 @@ test_authenticated_decryption_oop(const struct aead_test_data *tdata) plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *, ut_params->op->sym->cipher.data.offset); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len); + debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -5902,8 +6059,8 @@ test_authenticated_encryption_sessionless( ut_params->op->sym->cipher.data.offset); auth_tag = ciphertext + plaintext_pad_len; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); - TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); + debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -5980,7 +6137,7 @@ test_authenticated_decryption_sessionless( plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, ut_params->op->sym->cipher.data.offset); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len); + debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL( @@ -6226,7 +6383,7 @@ static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params, ut_params->ibuf, MD5_DIGEST_LEN); TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append digest"); - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, plaintext_pad_len); if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) { @@ -6364,10 +6521,10 @@ test_multi_session(void) sessions = rte_malloc(NULL, (sizeof(struct rte_cryptodev_sym_session *) * - dev_info.sym.max_nb_sessions) + 1, 0); + MAX_NB_SESSIONS) + 1, 0); /* Create multiple crypto sessions*/ - for (i = 0; i < dev_info.sym.max_nb_sessions; i++) { + for (i = 0; i < MAX_NB_SESSIONS; i++) { sessions[i] = rte_cryptodev_sym_session_create( ts_params->session_mpool); @@ -6416,7 +6573,7 @@ test_multi_session(void) TEST_ASSERT_NULL(sessions[i], "Session creation succeeded unexpectedly!"); - for (i = 0; i < dev_info.sym.max_nb_sessions; i++) { + for (i = 0; i < MAX_NB_SESSIONS; i++) { rte_cryptodev_sym_session_clear(ts_params->valid_devs[0], sessions[i]); rte_cryptodev_sym_session_free(sessions[i]); @@ -6475,13 +6632,13 @@ test_multi_session_random_usage(void) sessions = rte_malloc(NULL, (sizeof(struct rte_cryptodev_sym_session *) - * dev_info.sym.max_nb_sessions) + 1, 0); + * MAX_NB_SESSIONS) + 1, 0); for (i = 0; i < MB_SESSION_NUMBER; i++) { sessions[i] = rte_cryptodev_sym_session_create( ts_params->session_mpool); - rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params, + rte_memcpy(&ut_paramz[i].ut_params, &unittest_params, sizeof(struct crypto_unittest_params)); test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( @@ -6608,17 +6765,29 @@ test_null_cipher_only_operation(void) return TEST_SUCCESS; } - +uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab}; static int test_null_auth_only_operation(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; + uint8_t *digest; /* Generate test mbuf data and space for digest */ ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0); + /* create a pointer for digest, but don't expect anything to be written + * here in a NULL auth algo so no mbuf append done. + */ + digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, + QUOTE_512_BYTES); + /* prefill the memory pointed to by digest */ + memcpy(digest, orig_data, sizeof(orig_data)); + /* Setup HMAC Parameters */ ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; ut_params->auth_xform.next = NULL; @@ -6650,6 +6819,9 @@ test_null_auth_only_operation(void) sym_op->auth.data.offset = 0; sym_op->auth.data.length = QUOTE_512_BYTES; + sym_op->auth.digest.data = digest; + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf, + QUOTE_512_BYTES); /* Process crypto operation */ ut_params->op = process_crypto_request(ts_params->valid_devs[0], @@ -6658,20 +6830,36 @@ test_null_auth_only_operation(void) TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, "crypto operation processing failed"); + /* Make sure memory pointed to by digest hasn't been overwritten */ + TEST_ASSERT_BUFFERS_ARE_EQUAL( + orig_data, + digest, + sizeof(orig_data), + "Memory at digest ptr overwritten unexpectedly"); return TEST_SUCCESS; } + static int test_null_cipher_auth_operation(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; + uint8_t *digest; /* Generate test mbuf data and space for digest */ ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0); + /* create a pointer for digest, but don't expect anything to be written + * here in a NULL auth algo so no mbuf append done. + */ + digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, + QUOTE_512_BYTES); + /* prefill the memory pointed to by digest */ + memcpy(digest, orig_data, sizeof(orig_data)); + /* Setup Cipher Parameters */ ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; ut_params->cipher_xform.next = &ut_params->auth_xform; @@ -6713,6 +6901,9 @@ test_null_cipher_auth_operation(void) sym_op->auth.data.offset = 0; sym_op->auth.data.length = QUOTE_512_BYTES; + sym_op->auth.digest.data = digest; + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf, + QUOTE_512_BYTES); /* Process crypto operation */ ut_params->op = process_crypto_request(ts_params->valid_devs[0], @@ -6728,6 +6919,12 @@ test_null_cipher_auth_operation(void) catch_22_quote, QUOTE_512_BYTES, "Ciphertext data not as expected"); + /* Make sure memory pointed to by digest hasn't been overwritten */ + TEST_ASSERT_BUFFERS_ARE_EQUAL( + orig_data, + digest, + sizeof(orig_data), + "Memory at digest ptr overwritten unexpectedly"); return TEST_SUCCESS; } @@ -6737,11 +6934,20 @@ test_null_auth_cipher_operation(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; + uint8_t *digest; - /* Generate test mbuf data and space for digest */ + /* Generate test mbuf data */ ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0); + /* create a pointer for digest, but don't expect anything to be written + * here in a NULL auth algo so no mbuf append done. + */ + digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, + QUOTE_512_BYTES); + /* prefill the memory pointed to by digest */ + memcpy(digest, orig_data, sizeof(orig_data)); + /* Setup Cipher Parameters */ ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; ut_params->cipher_xform.next = NULL; @@ -6783,6 +6989,9 @@ test_null_auth_cipher_operation(void) sym_op->auth.data.offset = 0; sym_op->auth.data.length = QUOTE_512_BYTES; + sym_op->auth.digest.data = digest; + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf, + QUOTE_512_BYTES); /* Process crypto operation */ ut_params->op = process_crypto_request(ts_params->valid_devs[0], @@ -6798,6 +7007,12 @@ test_null_auth_cipher_operation(void) catch_22_quote, QUOTE_512_BYTES, "Ciphertext data not as expected"); + /* Make sure memory pointed to by digest hasn't been overwritten */ + TEST_ASSERT_BUFFERS_ARE_EQUAL( + orig_data, + digest, + sizeof(orig_data), + "Memory at digest ptr overwritten unexpectedly"); return TEST_SUCCESS; } @@ -6962,13 +7177,13 @@ create_gmac_operation(enum rte_crypto_auth_operation op, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append digest"); - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, plaintext_pad_len); if (op == RTE_CRYPTO_AUTH_OP_VERIFY) { rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data, tdata->gmac_tag.len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, tdata->gmac_tag.len); } @@ -6978,7 +7193,7 @@ create_gmac_operation(enum rte_crypto_auth_operation op, rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len); - TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len); + debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len); sym_op->cipher.data.length = 0; sym_op->cipher.data.offset = 0; @@ -7068,7 +7283,7 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata) TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, + debug_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len); retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE, @@ -7094,7 +7309,7 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata) auth_tag = plaintext + plaintext_pad_len; } - TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len); + debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len); TEST_ASSERT_BUFFERS_ARE_EQUAL( auth_tag, @@ -7172,7 +7387,7 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata) TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, + debug_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len); retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY, @@ -7484,7 +7699,7 @@ create_auth_operation(struct crypto_testsuite_params *ts_params, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append auth tag"); - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, reference->plaintext.len); if (auth_generate) @@ -7494,7 +7709,7 @@ create_auth_operation(struct crypto_testsuite_params *ts_params, reference->digest.data, reference->digest.len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, reference->digest.len); @@ -7531,7 +7746,7 @@ create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append auth tag"); - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, reference->ciphertext.len); if (auth_generate) @@ -7541,7 +7756,7 @@ create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params, reference->digest.data, reference->digest.len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, reference->digest.len); @@ -7584,7 +7799,7 @@ create_cipher_auth_operation(struct crypto_testsuite_params *ts_params, TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, "no room to append auth tag"); - sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( + sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( ut_params->ibuf, reference->ciphertext.len); if (auth_generate) @@ -7594,7 +7809,7 @@ create_cipher_auth_operation(struct crypto_testsuite_params *ts_params, reference->digest.data, reference->digest.len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->auth.digest.data, reference->digest.len); @@ -7667,7 +7882,8 @@ test_authentication_verify_fail_when_data_corruption( TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); memcpy(plaintext, reference->plaintext.data, reference->plaintext.len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len); + debug_hexdump(stdout, "plaintext:", plaintext, + reference->plaintext.len); /* Create operation */ retval = create_auth_verify_operation(ts_params, ut_params, reference); @@ -7725,7 +7941,8 @@ test_authentication_verify_GMAC_fail_when_corruption( TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); memcpy(plaintext, reference->plaintext.data, reference->plaintext.len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len); + debug_hexdump(stdout, "plaintext:", plaintext, + reference->plaintext.len); /* Create operation */ retval = create_auth_verify_GMAC_operation(ts_params, @@ -7844,7 +8061,7 @@ create_aead_operation_SGL(enum rte_crypto_aead_operation op, if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) { rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data, auth_tag_len); - TEST_HEXDUMP(stdout, "digest:", + debug_hexdump(stdout, "digest:", sym_op->aead.digest.data, auth_tag_len); } @@ -7863,15 +8080,15 @@ create_aead_operation_SGL(enum rte_crypto_aead_operation op, ut_params->ibuf, aad_len); TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data, "no room to prepend aad"); - sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys( + sym_op->aead.aad.phys_addr = rte_pktmbuf_iova( ut_params->ibuf); memset(sym_op->aead.aad.data, 0, aad_len); /* Copy AAD 18 bytes after the AAD pointer, according to the API */ rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len); - TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len); - TEST_HEXDUMP(stdout, "aad:", + debug_hexdump(stdout, "iv:", iv_ptr, iv_len); + debug_hexdump(stdout, "aad:", sym_op->aead.aad.data, aad_len); } else { uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, @@ -7883,14 +8100,14 @@ create_aead_operation_SGL(enum rte_crypto_aead_operation op, ut_params->ibuf, aad_len); TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data, "no room to prepend aad"); - sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys( + sym_op->aead.aad.phys_addr = rte_pktmbuf_iova( ut_params->ibuf); memset(sym_op->aead.aad.data, 0, aad_len); rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len); - TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len); - TEST_HEXDUMP(stdout, "aad:", + debug_hexdump(stdout, "iv:", iv_ptr, iv_len); + debug_hexdump(stdout, "aad:", sym_op->aead.aad.data, aad_len); } @@ -8030,7 +8247,7 @@ test_authenticated_encryption_SGL(const struct aead_test_data *tdata, digest_mem = rte_pktmbuf_append(ut_params->obuf, tdata->auth_tag.len); - digest_phys = rte_pktmbuf_mtophys_offset( + digest_phys = rte_pktmbuf_iova_offset( ut_params->obuf, tdata->plaintext.len + prepend_len); } @@ -8068,14 +8285,14 @@ test_authenticated_encryption_SGL(const struct aead_test_data *tdata, * Place digest at the end of the last buffer */ if (!digest_phys) - digest_phys = rte_pktmbuf_mtophys(buf) + to_trn; + digest_phys = rte_pktmbuf_iova(buf) + to_trn; if (oop && buf_last_oop) - digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn; + digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn; if (!digest_mem && !oop) { digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, + tdata->auth_tag.len); - digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf, + digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf, tdata->plaintext.len); } @@ -8340,8 +8557,17 @@ test_scheduler_attach_slave_op(void) rte_mempool_free(ts_params->session_mpool); ts_params->session_mpool = NULL; } - unsigned int session_size = rte_cryptodev_get_private_session_size(i); + unsigned int session_size = + rte_cryptodev_sym_get_private_session_size(i); + if (info.sym.max_nb_sessions != 0 && + info.sym.max_nb_sessions < MAX_NB_SESSIONS) { + RTE_LOG(ERR, USER1, + "Device does not support " + "at least %u sessions\n", + MAX_NB_SESSIONS); + return TEST_FAILED; + } /* * Create mempool with maximum number of sessions * 2, * to include the session headers @@ -8349,7 +8575,7 @@ test_scheduler_attach_slave_op(void) if (ts_params->session_mpool == NULL) { ts_params->session_mpool = rte_mempool_create( "test_sess_mp", - info.sym.max_nb_sessions * 2, + MAX_NB_SESSIONS * 2, session_size, 0, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, @@ -8393,33 +8619,47 @@ test_scheduler_detach_slave_op(void) } static int -test_scheduler_mode_op(void) +test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode) { struct crypto_testsuite_params *ts_params = &testsuite_params; uint8_t sched_id = ts_params->valid_devs[0]; - struct rte_cryptodev_scheduler_ops op = {0}; - struct rte_cryptodev_scheduler dummy_scheduler = { - .description = "dummy scheduler to test mode", - .name = "dummy scheduler", - .mode = CDEV_SCHED_MODE_USERDEFINED, - .ops = &op - }; - int ret; + /* set mode */ + return rte_cryptodev_scheduler_mode_set(sched_id, + scheduler_mode); +} + +static int +test_scheduler_mode_roundrobin_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) == + 0, "Failed to set roundrobin mode"); + return 0; + +} + +static int +test_scheduler_mode_multicore_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) == + 0, "Failed to set multicore mode"); + + return 0; +} - /* set user defined mode */ - ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id, - &dummy_scheduler); - TEST_ASSERT(ret == 0, - "Failed to set cdev %u to user defined mode", sched_id); - - /* set round robin mode */ - ret = rte_cryptodev_scheduler_mode_set(sched_id, - CDEV_SCHED_MODE_ROUNDROBIN); - TEST_ASSERT(ret == 0, - "Failed to set cdev %u to round-robin mode", sched_id); - TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) == - CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode " - "not match"); +static int +test_scheduler_mode_failover_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) == + 0, "Failed to set failover mode"); + + return 0; +} + +static int +test_scheduler_mode_pkt_size_distr_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) == + 0, "Failed to set pktsize mode"); return 0; } @@ -8429,8 +8669,20 @@ static struct unit_test_suite cryptodev_scheduler_testsuite = { .setup = testsuite_setup, .teardown = testsuite_teardown, .unit_test_cases = { + /* Multi Core */ + TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_chain_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_authonly_scheduler_all), + TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + + /* Round Robin */ TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), - TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op), TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_scheduler_all), TEST_CASE_ST(ut_setup, ut_teardown, @@ -8438,6 +8690,29 @@ static struct unit_test_suite cryptodev_scheduler_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_scheduler_all), TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + + /* Fail over */ + TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_chain_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_authonly_scheduler_all), + TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + + /* PKT SIZE */ + TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_chain_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_authonly_scheduler_all), + TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; @@ -8732,6 +9007,18 @@ static struct unit_test_suite cryptodev_qat_testsuite = { } }; +static struct unit_test_suite cryptodev_virtio_testsuite = { + .suite_name = "Crypto VIRTIO Unit Test Suite", + .setup = testsuite_setup, + .teardown = testsuite_teardown, + .unit_test_cases = { + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_virtio_all), + + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + static struct unit_test_suite cryptodev_aesni_mb_testsuite = { .suite_name = "Crypto Device AESNI MB Unit Test Suite", .setup = testsuite_setup, @@ -8745,6 +9032,18 @@ static struct unit_test_suite cryptodev_aesni_mb_testsuite = { test_DES_cipheronly_mb_all), TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_mb_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_CCM_authenticated_encryption_test_case_128_2), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_CCM_authenticated_decryption_test_case_128_2), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_CCM_authenticated_encryption_test_case_128_3), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_CCM_authenticated_decryption_test_case_128_3), TEST_CASES_END() /**< NULL terminate unit test array */ } @@ -9376,6 +9675,16 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_AES_GCM_authenticated_decryption_oop_test_case_1), + /** Scatter-Gather */ + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_in_place_1500B), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; @@ -9503,6 +9812,16 @@ static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_AES_GCM_authenticated_decryption_oop_test_case_1), + /** Scatter-Gather */ + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_in_place_1500B), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; @@ -9579,6 +9898,38 @@ static struct unit_test_suite cryptodev_mrvl_testsuite = { } }; +static struct unit_test_suite cryptodev_ccp_testsuite = { + .suite_name = "Crypto Device CCP Unit Test Suite", + .setup = testsuite_setup, + .teardown = testsuite_teardown, + .unit_test_cases = { + TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session), + TEST_CASE_ST(ut_setup, ut_teardown, + test_multi_session_random_usage), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_chain_ccp_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_ccp_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_3DES_chain_ccp_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_3DES_cipheronly_ccp_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_authonly_ccp_all), + + /** 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, + 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 */ + } +}; static int test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) @@ -9587,13 +9938,29 @@ test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)); if (gbl_driver_id == -1) { - RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if " - "CONFIG_RTE_LIBRTE_PMD_QAT is enabled " + 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; + } + + return unit_test_suite_runner(&cryptodev_qat_testsuite); +} + +static int +test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/) +{ + gbl_driver_id = rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)); + + if (gbl_driver_id == -1) { + RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if " + "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled " "in config file to run this testsuite.\n"); return TEST_FAILED; } - return unit_test_suite_runner(&cryptodev_qat_testsuite); + return unit_test_suite_runner(&cryptodev_virtio_testsuite); } static int @@ -9606,7 +9973,7 @@ test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) 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_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite); @@ -9622,7 +9989,7 @@ test_cryptodev_openssl(void) RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_openssl_testsuite); @@ -9638,7 +10005,7 @@ test_cryptodev_aesni_gcm(void) RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite); @@ -9654,7 +10021,7 @@ test_cryptodev_null(void) RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_NULL is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_null_testsuite); @@ -9670,7 +10037,7 @@ test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/) RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite); @@ -9686,7 +10053,7 @@ test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/) RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite); @@ -9702,7 +10069,7 @@ test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/) RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite); @@ -9718,7 +10085,7 @@ test_cryptodev_armv8(void) RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_armv8_testsuite); @@ -9728,13 +10095,13 @@ static int test_cryptodev_mrvl(void) { gbl_driver_id = rte_cryptodev_driver_id_get( - RTE_STR(CRYPTODEV_NAME_MRVL_PMD)); + RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)); if (gbl_driver_id == -1) { - RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if " - "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled " + RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if " + "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_mrvl_testsuite); @@ -9752,14 +10119,14 @@ test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/) RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } if (rte_cryptodev_driver_id_get( RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) { RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be" " enabled in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_scheduler_testsuite); } @@ -9778,7 +10145,7 @@ test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/) RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite); @@ -9794,12 +10161,28 @@ test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/) RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if " "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled " "in config file to run this testsuite.\n"); - return TEST_FAILED; + return TEST_SKIPPED; } return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite); } +static int +test_cryptodev_ccp(void) +{ + gbl_driver_id = rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_CCP_PMD)); + + if (gbl_driver_id == -1) { + RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if " + "CONFIG_RTE_LIBRTE_PMD_CCP is enabled " + "in config file to run this testsuite.\n"); + return TEST_FAILED; + } + + return unit_test_suite_runner(&cryptodev_ccp_testsuite); +} + REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat); REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb); REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl); @@ -9809,6 +10192,8 @@ REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g); REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi); REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc); REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8); -REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl); +REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl); REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec); REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec); +REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp); +REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);