From 8be94df6e9f5f70516cb86d82dd04fefaa0fe8b3 Mon Sep 17 00:00:00 2001 From: Ricardo Salveti Date: Mon, 18 Jul 2016 15:30:06 -0300 Subject: Imported Upstream version 16.07-rc2 Change-Id: Ie9e8ec528a2a0dace085c5e44aa7fa3b489d4ba0 Signed-off-by: Ricardo Salveti Signed-off-by: Christian Ehrhardt --- app/test/test_cryptodev.c | 45 +++++++++++++++++++++--------------------- app/test/test_cryptodev_perf.c | 18 ++++++++--------- app/test/test_hash.c | 42 +++++++++++++++++++++++++++++++++++++++ app/test/test_red.c | 42 +-------------------------------------- 4 files changed, 75 insertions(+), 72 deletions(-) (limited to 'app/test') diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index fbfe1d0d..33325a8b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -186,12 +186,12 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { ret = rte_eal_vdev_init( - CRYPTODEV_NAME_AESNI_MB_PMD, NULL); + RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL); TEST_ASSERT(ret == 0, "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_AESNI_MB_PMD); + i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); } } } @@ -203,10 +203,10 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { TEST_ASSERT_SUCCESS(rte_eal_vdev_init( - CRYPTODEV_NAME_AESNI_GCM_PMD, NULL), + RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL), "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_AESNI_GCM_PMD); + i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)); } } } @@ -217,10 +217,10 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { TEST_ASSERT_SUCCESS(rte_eal_vdev_init( - CRYPTODEV_NAME_SNOW3G_PMD, NULL), + RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL), "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_SNOW3G_PMD); + i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)); } } } @@ -231,10 +231,10 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { TEST_ASSERT_SUCCESS(rte_eal_vdev_init( - CRYPTODEV_NAME_KASUMI_PMD, NULL), + RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL), "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_KASUMI_PMD); + i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)); } } } @@ -246,12 +246,12 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { int dev_id = rte_eal_vdev_init( - CRYPTODEV_NAME_NULL_PMD, NULL); + RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL); TEST_ASSERT(dev_id >= 0, "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_NULL_PMD); + i, RTE_STR(CRYPTODEV_NAME_NULL_PMD)); } } } @@ -2295,7 +2295,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, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len, @@ -2316,7 +2316,7 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -2368,7 +2368,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, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data, @@ -2390,7 +2390,7 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -2549,7 +2549,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, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len, @@ -2569,7 +2569,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata) else plaintext = ciphertext; - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, @@ -2622,7 +2622,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, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data, @@ -2643,7 +2643,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) else plaintext = ciphertext; - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, @@ -2689,7 +2689,7 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_hash_operation(tdata->digest.data, @@ -2717,7 +2717,7 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -2774,7 +2774,7 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_auth_cipher_operation( @@ -2805,7 +2805,7 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) + plaintext_pad_len + tdata->aad.len + tdata->iv.len; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -3002,6 +3002,7 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op, ut_params->cipher_xform.next = NULL; ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM; + ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; ut_params->cipher_xform.cipher.op = op; ut_params->cipher_xform.cipher.key.data = cipher_key; ut_params->cipher_xform.cipher.key.length = key_len; diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c index d7282112..815c41ff 100644 --- a/app/test/test_cryptodev_perf.c +++ b/app/test/test_cryptodev_perf.c @@ -120,15 +120,15 @@ static const char *chain_mode_name(enum chain_mode mode) static const char *pmd_name(enum rte_cryptodev_type pmd) { switch (pmd) { - case RTE_CRYPTODEV_NULL_PMD: return CRYPTODEV_NAME_NULL_PMD; break; + case RTE_CRYPTODEV_NULL_PMD: return RTE_STR(CRYPTODEV_NAME_NULL_PMD); break; case RTE_CRYPTODEV_AESNI_GCM_PMD: - return CRYPTODEV_NAME_AESNI_GCM_PMD; + return RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD); case RTE_CRYPTODEV_AESNI_MB_PMD: - return CRYPTODEV_NAME_AESNI_MB_PMD; + return RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD); case RTE_CRYPTODEV_QAT_SYM_PMD: - return CRYPTODEV_NAME_QAT_SYM_PMD; + return RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD); case RTE_CRYPTODEV_SNOW3G_PMD: - return CRYPTODEV_NAME_SNOW3G_PMD; + return RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD); default: return ""; } @@ -249,11 +249,11 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { ret = rte_eal_vdev_init( - CRYPTODEV_NAME_AESNI_MB_PMD, NULL); + RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL); TEST_ASSERT(ret == 0, "Failed to create instance %u of pmd : %s", - i, CRYPTODEV_NAME_AESNI_MB_PMD); + i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); } } } @@ -264,11 +264,11 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { ret = rte_eal_vdev_init( - CRYPTODEV_NAME_SNOW3G_PMD, NULL); + RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL); TEST_ASSERT(ret == 0, "Failed to create instance %u of pmd : %s", - i, CRYPTODEV_NAME_SNOW3G_PMD); + i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)); } } } diff --git a/app/test/test_hash.c b/app/test/test_hash.c index 7e41725a..29abcd9e 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -420,6 +420,46 @@ static int test_add_update_delete(void) return 0; } +/* + * Sequence of operations for retrieving a key with its position + * + * - create table + * - add key + * - get the key with its position: hit + * - delete key + * - try to get the deleted key: miss + * + */ +static int test_hash_get_key_with_position(void) +{ + struct rte_hash *handle = NULL; + int pos, expectedPos, result; + void *key; + + ut_params.name = "hash_get_key_w_pos"; + handle = rte_hash_create(&ut_params); + RETURN_IF_ERROR(handle == NULL, "hash creation failed"); + + pos = rte_hash_add_key(handle, &keys[0]); + print_key_info("Add", &keys[0], pos); + RETURN_IF_ERROR(pos < 0, "failed to add key (pos0=%d)", pos); + expectedPos = pos; + + result = rte_hash_get_key_with_position(handle, pos, &key); + RETURN_IF_ERROR(result != 0, "error retrieving a key"); + + pos = rte_hash_del_key(handle, &keys[0]); + print_key_info("Del", &keys[0], pos); + RETURN_IF_ERROR(pos != expectedPos, + "failed to delete key (pos0=%d)", pos); + + result = rte_hash_get_key_with_position(handle, pos, &key); + RETURN_IF_ERROR(result != -ENOENT, "non valid key retrieved"); + + rte_hash_free(handle); + return 0; +} + /* * Sequence of operations for find existing hash table * @@ -1442,6 +1482,8 @@ test_hash(void) return -1; if (test_hash_add_delete_jhash_3word() < 0) return -1; + if (test_hash_get_key_with_position() < 0) + return -1; if (test_hash_find_existing() < 0) return -1; if (test_add_update_delete() < 0) diff --git a/app/test/test_red.c b/app/test/test_red.c index 2384c556..7d1c32c4 100644 --- a/app/test/test_red.c +++ b/app/test/test_red.c @@ -273,46 +273,6 @@ static int check_avg(double *diff, double avg, double exp_avg, double tolerance) return ret; } -/** - * get the clk frequency in Hz - */ -static uint64_t get_machclk_freq(void) -{ - uint64_t start = 0; - uint64_t end = 0; - uint64_t diff = 0; - static uint64_t clk_freq_hz; - struct timespec tv_start = {0, 0}, tv_end = {0, 0}; - struct timespec req = {0, 0}; - - if (clk_freq_hz != 0) - return clk_freq_hz; - - req.tv_sec = 0; - req.tv_nsec = NSEC_PER_SEC / 4; - - clock_gettime(CLOCK_REALTIME, &tv_start); - start = rte_rdtsc(); - - if (nanosleep(&req, NULL) != 0) { - perror("get_machclk_freq()"); - exit(EXIT_FAILURE); - } - - clock_gettime(CLOCK_REALTIME, &tv_end); - end = rte_rdtsc(); - - diff = (uint64_t)(tv_end.tv_sec - tv_start.tv_sec) * USEC_PER_SEC - + ((tv_end.tv_nsec - tv_start.tv_nsec + TEST_NSEC_MARGIN) / - USEC_PER_MSEC); /**< diff is in micro secs */ - - if (diff == 0) - return 0; - - clk_freq_hz = ((end - start) * USEC_PER_SEC / diff); - return clk_freq_hz; -} - /** * initialize the test rte_red config */ @@ -321,7 +281,7 @@ test_rte_red_init(struct test_config *tcfg) { unsigned i = 0; - tcfg->tvar->clk_freq = get_machclk_freq(); + tcfg->tvar->clk_freq = rte_get_timer_hz(); init_port_ts( tcfg->tvar->clk_freq ); for (i = 0; i < tcfg->tconfig->num_cfg; i++) { -- cgit 1.2.3-korg