From patchwork Fri Sep 22 07:55:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "De Lara Guarch, Pablo" X-Patchwork-Id: 29116 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A8091B160; Fri, 22 Sep 2017 17:55:08 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E60957D04 for ; Fri, 22 Sep 2017 17:55:02 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Sep 2017 08:54:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,427,1500966000"; d="scan'208";a="154395810" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by fmsmga005.fm.intel.com with ESMTP; 22 Sep 2017 08:54:57 -0700 From: Pablo de Lara To: declan.doherty@intel.com, akhil.goyal@nxp.com Cc: dev@dpdk.org, Pablo de Lara Date: Fri, 22 Sep 2017 08:55:13 +0100 Message-Id: <20170922075519.28342-2-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170922075519.28342-1-pablo.de.lara.guarch@intel.com> References: <20170913072026.29734-1-pablo.de.lara.guarch@intel.com> <20170922075519.28342-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v3 1/7] app/crypto-perf: set AAD after the crypto operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- app/test-crypto-perf/cperf_ops.c | 16 ++++++++++++---- app/test-crypto-perf/cperf_test_latency.c | 16 ++++------------ app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 16 +++------------- app/test-crypto-perf/cperf_test_throughput.c | 15 +++------------ app/test-crypto-perf/cperf_test_verify.c | 20 ++++++-------------- 5 files changed, 28 insertions(+), 55 deletions(-) diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index 88fb972..5be20d9 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_latency.c b/app/test-crypto-perf/cperf_test_latency.c index 58b21ab..2a46af9 100644 --- a/app/test-crypto-perf/cperf_test_latency.c +++ b/app/test-crypto-perf/cperf_test_latency.c @@ -174,16 +174,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) @@ -289,10 +279,12 @@ cperf_latency_test_constructor(struct rte_mempool *sess_mp, snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d", dev_id); - uint16_t priv_size = sizeof(struct priv_op_data) + + uint16_t priv_size = RTE_ALIGN_CEIL(sizeof(struct priv_op_data) + test_vector->cipher_iv.length + test_vector->auth_iv.length + - test_vector->aead_iv.length; + test_vector->aead_iv.length, 16) + + RTE_ALIGN_CEIL(options->aead_aad_sz, 16); + ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 512, priv_size, rte_socket_id()); diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c index 0c949f0..ef1aa7e 100644 --- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c +++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c @@ -191,16 +191,6 @@ cperf_mbuf_create(struct rte_mempool *mempool, uint32_t segments_nb, 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) @@ -301,9 +291,9 @@ cperf_pmd_cyclecount_test_constructor(struct rte_mempool *sess_mp, snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d", dev_id); - uint16_t priv_size = test_vector->cipher_iv.length + - test_vector->auth_iv.length + - test_vector->aead_iv.length; + uint16_t priv_size = RTE_ALIGN_CEIL(test_vector->cipher_iv.length + + test_vector->auth_iv.length + test_vector->aead_iv.length, 16) + + RTE_ALIGN_CEIL(options->aead_aad_sz, 16); ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 512, diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c index 3bb1cb0..07aea6a 100644 --- a/app/test-crypto-perf/cperf_test_throughput.c +++ b/app/test-crypto-perf/cperf_test_throughput.c @@ -158,16 +158,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) @@ -270,8 +260,9 @@ cperf_throughput_test_constructor(struct rte_mempool *sess_mp, snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d", dev_id); - uint16_t priv_size = test_vector->cipher_iv.length + - test_vector->auth_iv.length + test_vector->aead_iv.length; + uint16_t priv_size = RTE_ALIGN_CEIL(test_vector->cipher_iv.length + + test_vector->auth_iv.length + test_vector->aead_iv.length, 16) + + RTE_ALIGN_CEIL(options->aead_aad_sz, 16); ctx->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 a314646..bc07eb6 100644 --- a/app/test-crypto-perf/cperf_test_verify.c +++ b/app/test-crypto-perf/cperf_test_verify.c @@ -162,16 +162,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) @@ -274,8 +264,10 @@ cperf_verify_test_constructor(struct rte_mempool *sess_mp, snprintf(pool_name, sizeof(pool_name), "cperf_op_pool_cdev_%d", dev_id); - uint16_t priv_size = test_vector->cipher_iv.length + - test_vector->auth_iv.length + test_vector->aead_iv.length; + uint16_t priv_size = RTE_ALIGN_CEIL(test_vector->cipher_iv.length + + test_vector->auth_iv.length + test_vector->aead_iv.length, 16) + + RTE_ALIGN_CEIL(options->aead_aad_sz, 16); + ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 512, priv_size, rte_socket_id()); @@ -362,9 +354,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; }