X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Ftest_cryptodev_blockcipher.c;h=da87368a78aa2c9cf861a7e6eb89b3379787d4cf;hb=dd0eedb1cfcf0cb7423d859177c5bc6f931eaf8a;hp=f1fe624317fecfc71b447fed0b365bbcd592805f;hpb=e2a7fdce6deb6de81a71cfa7c6f2245c52d8e39b;p=dpdk.git diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index f1fe624317..da87368a78 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2015-2016 Intel Corporation. All rights reserved. + * 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 @@ -41,6 +41,7 @@ #include #include "test.h" +#include "test_cryptodev.h" #include "test_cryptodev_blockcipher.h" #include "test_cryptodev_aes_test_vectors.h" #include "test_cryptodev_des_test_vectors.h" @@ -64,6 +65,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, struct rte_crypto_sym_op *sym_op = NULL; struct rte_crypto_op *op = NULL; struct rte_cryptodev_sym_session *sess = NULL; + struct rte_cryptodev_info dev_info; int status = TEST_SUCCESS; const struct blockcipher_test_data *tdata = t->test_data; @@ -77,6 +79,19 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, uint8_t tmp_src_buf[MBUF_SIZE]; uint8_t tmp_dst_buf[MBUF_SIZE]; + int nb_segs = 1; + + if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) { + rte_cryptodev_info_get(dev_id, &dev_info); + if (!(dev_info.feature_flags & + RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) { + printf("Device doesn't support scatter-gather. " + "Test Skipped.\n"); + return 0; + } + nb_segs = 3; + } + if (tdata->cipher_key.len) memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len); @@ -87,9 +102,11 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, switch (cryptodev_type) { case RTE_CRYPTODEV_QAT_SYM_PMD: case RTE_CRYPTODEV_OPENSSL_PMD: + case RTE_CRYPTODEV_ARMV8_PMD: /* Fall through */ digest_len = tdata->digest.len; break; case RTE_CRYPTODEV_AESNI_MB_PMD: + case RTE_CRYPTODEV_SCHEDULER_PMD: digest_len = tdata->digest.truncated_len; break; default: @@ -101,49 +118,38 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, } /* preparing data */ - ibuf = rte_pktmbuf_alloc(mbuf_pool); - if (!ibuf) { - snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, - "line %u FAILED: %s", - __LINE__, "Allocation of rte_mbuf failed"); - status = TEST_FAILED; - goto error_exit; - } - memset(ibuf->buf_addr, src_pattern, ibuf->buf_len); - if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) buf_len += tdata->iv.len; if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) buf_len += digest_len; - buf_p = rte_pktmbuf_append(ibuf, buf_len); - if (!buf_p) { + /* for contiguous mbuf, nb_segs is 1 */ + ibuf = create_segmented_mbuf(mbuf_pool, + tdata->ciphertext.len, nb_segs, src_pattern); + if (ibuf == NULL) { snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u FAILED: %s", - __LINE__, "No room to append mbuf"); + __LINE__, "Cannot create source mbuf"); status = TEST_FAILED; goto error_exit; } - if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) { - rte_memcpy(buf_p, tdata->iv.data, tdata->iv.len); - buf_p += tdata->iv.len; - } - /* only encryption requires plaintext.data input, * decryption/(digest gen)/(digest verify) use ciphertext.data * to be computed */ - if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) { - rte_memcpy(buf_p, tdata->plaintext.data, - tdata->plaintext.len); - buf_p += tdata->plaintext.len; - } else { - rte_memcpy(buf_p, tdata->ciphertext.data, - tdata->ciphertext.len); - buf_p += tdata->ciphertext.len; - } + if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) + pktmbuf_write(ibuf, 0, tdata->plaintext.len, + tdata->plaintext.data); + else + pktmbuf_write(ibuf, 0, tdata->ciphertext.len, + tdata->ciphertext.data); + if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) { + rte_memcpy(rte_pktmbuf_prepend(ibuf, tdata->iv.len), + tdata->iv.data, tdata->iv.len); + } + buf_p = rte_pktmbuf_append(ibuf, digest_len); if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) rte_memcpy(buf_p, tdata->digest.data, digest_len); else @@ -314,17 +320,17 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) { auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; - sym_op->auth.digest.data = rte_pktmbuf_mtod_offset - (iobuf, uint8_t *, digest_offset); + sym_op->auth.digest.data = pktmbuf_mtod_offset + (iobuf, digest_offset); sym_op->auth.digest.phys_addr = - rte_pktmbuf_mtophys_offset(iobuf, + pktmbuf_mtophys_offset(iobuf, digest_offset); } else { auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY; - sym_op->auth.digest.data = rte_pktmbuf_mtod_offset - (sym_op->m_src, uint8_t *, digest_offset); + sym_op->auth.digest.data = pktmbuf_mtod_offset + (sym_op->m_src, digest_offset); sym_op->auth.digest.phys_addr = - rte_pktmbuf_mtophys_offset(sym_op->m_src, + pktmbuf_mtophys_offset(sym_op->m_src, digest_offset); } @@ -403,13 +409,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, } if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) { - uint8_t *crypto_res; + uint8_t buffer[2048]; const uint8_t *compare_ref; uint32_t compare_len; - crypto_res = rte_pktmbuf_mtod_offset(iobuf, uint8_t *, - tdata->iv.len); - if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) { compare_ref = tdata->ciphertext.data; compare_len = tdata->ciphertext.len; @@ -418,7 +421,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, compare_len = tdata->plaintext.len; } - if (memcmp(crypto_res, compare_ref, compare_len)) { + if (memcmp(rte_pktmbuf_read(iobuf, tdata->iv.len, compare_len, + buffer), compare_ref, compare_len)) { snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u " "FAILED: %s", __LINE__, "Crypto data not as expected"); @@ -431,12 +435,11 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, uint8_t *auth_res; if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) - auth_res = rte_pktmbuf_mtod_offset(iobuf, - uint8_t *, - tdata->iv.len + tdata->ciphertext.len); + auth_res = pktmbuf_mtod_offset(iobuf, + tdata->iv.len + tdata->ciphertext.len); else - auth_res = rte_pktmbuf_mtod_offset(iobuf, - uint8_t *, tdata->ciphertext.len); + auth_res = pktmbuf_mtod_offset(iobuf, + tdata->ciphertext.len); if (memcmp(auth_res, tdata->digest.data, digest_len)) { snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u " @@ -644,6 +647,12 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool, case RTE_CRYPTODEV_OPENSSL_PMD: target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL; break; + case RTE_CRYPTODEV_ARMV8_PMD: + target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8; + break; + case RTE_CRYPTODEV_SCHEDULER_PMD: + target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER; + break; default: TEST_ASSERT(0, "Unrecognized cryptodev type"); break;