From: Pablo de Lara Date: Wed, 4 Oct 2017 03:46:07 +0000 (+0100) Subject: app/crypto-perf: set AAD after the crypto operation X-Git-Tag: spdx-start~1415 X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=0b242422d3858d5167c71ca543b2b743453be5cc app/crypto-perf: set AAD after the crypto operation Instead of prepending the AAD (Additional Authenticated Data) in the mbuf, it is easier to set after the crypto operation, as it is a read-only value, like the IV, and then it is not restricted to the size of the mbuf headroom. Signed-off-by: Pablo de Lara Acked-by: Akhil Goyal --- diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index 88fb97258f..5be20d9495 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -307,6 +307,8 @@ cperf_set_ops_aead(struct rte_crypto_op **ops, uint16_t iv_offset) { uint16_t i; + uint16_t aad_offset = iv_offset + + RTE_ALIGN_CEIL(test_vector->aead_iv.length, 16); for (i = 0; i < nb_ops; i++) { struct rte_crypto_sym_op *sym_op = ops[i]->sym; @@ -318,11 +320,12 @@ cperf_set_ops_aead(struct rte_crypto_op **ops, /* AEAD parameters */ sym_op->aead.data.length = options->test_buffer_size; - sym_op->aead.data.offset = - RTE_ALIGN_CEIL(options->aead_aad_sz, 16); + sym_op->aead.data.offset = 0; - sym_op->aead.aad.data = rte_pktmbuf_mtod(bufs_in[i], uint8_t *); - sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(bufs_in[i]); + sym_op->aead.aad.data = rte_crypto_op_ctod_offset(ops[i], + uint8_t *, aad_offset); + sym_op->aead.aad.phys_addr = rte_crypto_op_ctophys_offset(ops[i], + aad_offset); if (options->aead_op == RTE_CRYPTO_AEAD_OP_DECRYPT) { sym_op->aead.digest.data = test_vector->digest.data; @@ -360,6 +363,11 @@ cperf_set_ops_aead(struct rte_crypto_op **ops, memcpy(iv_ptr, test_vector->aead_iv.data, test_vector->aead_iv.length); + + /* Copy AAD after the IV */ + memcpy(ops[i]->sym->aead.aad.data, + test_vector->aad.data, + test_vector->aad.length); } } diff --git a/app/test-crypto-perf/cperf_test_common.c b/app/test-crypto-perf/cperf_test_common.c index a87d27eb30..ddf5641245 100644 --- a/app/test-crypto-perf/cperf_test_common.c +++ b/app/test-crypto-perf/cperf_test_common.c @@ -94,16 +94,6 @@ cperf_mbuf_create(struct rte_mempool *mempool, goto error; } - if (options->op_type == CPERF_AEAD) { - uint8_t *aead = (uint8_t *)rte_pktmbuf_prepend(mbuf, - RTE_ALIGN_CEIL(options->aead_aad_sz, 16)); - - if (aead == NULL) - goto error; - - memcpy(aead, test_vector->aad.data, test_vector->aad.length); - } - return mbuf; error: if (mbuf != NULL) @@ -183,9 +173,10 @@ cperf_alloc_common_memory(const struct cperf_options *options, snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d", dev_id); - uint16_t priv_size = test_vector->cipher_iv.length + + uint16_t priv_size = RTE_ALIGN_CEIL(test_vector->cipher_iv.length + test_vector->auth_iv.length + test_vector->aead_iv.length + - extra_op_priv_size; + extra_op_priv_size, 16) + + RTE_ALIGN_CEIL(options->aead_aad_sz, 16); *crypto_op_pool = rte_crypto_op_pool_create(pool_name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c index b8814b6bcb..ca9947c8f4 100644 --- a/app/test-crypto-perf/cperf_test_verify.c +++ b/app/test-crypto-perf/cperf_test_verify.c @@ -197,9 +197,9 @@ cperf_verify_op(struct rte_crypto_op *op, break; case CPERF_AEAD: cipher = 1; - cipher_offset = vector->aad.length; + cipher_offset = 0; auth = 1; - auth_offset = vector->aad.length + options->test_buffer_size; + auth_offset = options->test_buffer_size; break; default: res = 1;