DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: pablo.de.lara.guarch@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 08/22] test/crypto-perf: move IV to crypto op private data
Date: Wed, 21 Jun 2017 08:47:17 +0100	[thread overview]
Message-ID: <20170621074731.45013-8-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <20170621074731.45013-1-pablo.de.lara.guarch@intel.com>

Usually, IV will change for each crypto operation.
Therefore, instead of pointing at the same location,
IV is copied after each crypto operation.

This will let the IV to be passed as an offset from
the beginning of the crypto operation, instead of
a pointer.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 test/test/test_cryptodev_perf.c | 112 +++++++++++++++++++++-------------------
 1 file changed, 60 insertions(+), 52 deletions(-)

diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index c03d60b..fb29112 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -110,7 +110,6 @@ struct symmetric_session_attrs {
 
 struct crypto_params {
 	uint8_t *aad;
-	uint8_t *iv;
 	uint8_t *digest;
 };
 
@@ -265,7 +264,8 @@ testsuite_setup(void)
 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 			NUM_MBUFS, MBUF_CACHE_SIZE,
 			DEFAULT_NUM_XFORMS *
-			sizeof(struct rte_crypto_sym_xform),
+			sizeof(struct rte_crypto_sym_xform) +
+			MAXIMUM_IV_LENGTH,
 			rte_socket_id());
 		if (ts_params->op_mpool == NULL) {
 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
@@ -1978,19 +1978,20 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
 				data_params[0].length);
 		op->sym->auth.digest.length = DIGEST_BYTE_LENGTH_SHA256;
 
-		op->sym->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
+		op->sym->auth.data.offset = 0;
 		op->sym->auth.data.length = data_params[0].length;
 
 
-		op->sym->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(m,
-				CIPHER_IV_LENGTH_AES_CBC);
-		op->sym->cipher.iv.phys_addr = rte_pktmbuf_mtophys(m);
+		op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
+				uint8_t *, IV_OFFSET);
+		op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
+				IV_OFFSET);
 		op->sym->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
 
 		rte_memcpy(op->sym->cipher.iv.data, aes_cbc_128_iv,
 				CIPHER_IV_LENGTH_AES_CBC);
 
-		op->sym->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
+		op->sym->cipher.data.offset = 0;
 		op->sym->cipher.data.length = data_params[0].length;
 
 		op->sym->m_src = m;
@@ -2887,23 +2888,25 @@ test_perf_set_crypto_op_aes(struct rte_crypto_op *op, struct rte_mbuf *m,
 		op->sym->auth.data.length = 0;
 	} else {
 		op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m,
-				 uint8_t *, AES_CIPHER_IV_LENGTH + data_len);
+				 uint8_t *, data_len);
 		op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
-				AES_CIPHER_IV_LENGTH + data_len);
+				data_len);
 		op->sym->auth.digest.length = digest_len;
-		op->sym->auth.data.offset = AES_CIPHER_IV_LENGTH;
+		op->sym->auth.data.offset = 0;
 		op->sym->auth.data.length = data_len;
 	}
 
 
 	/* Cipher Parameters */
-	op->sym->cipher.iv.data = rte_pktmbuf_mtod(m, uint8_t *);
-	op->sym->cipher.iv.phys_addr = rte_pktmbuf_mtophys(m);
+	op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
+			uint8_t *, IV_OFFSET);
+	op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	op->sym->cipher.iv.length = AES_CIPHER_IV_LENGTH;
 
 	rte_memcpy(op->sym->cipher.iv.data, aes_iv, AES_CIPHER_IV_LENGTH);
 
-	op->sym->cipher.data.offset = AES_CIPHER_IV_LENGTH;
+	op->sym->cipher.data.offset = 0;
 	op->sym->cipher.data.length = data_len;
 
 	op->sym->m_src = m;
@@ -2931,8 +2934,12 @@ test_perf_set_crypto_op_aes_gcm(struct rte_crypto_op *op, struct rte_mbuf *m,
 	op->sym->auth.aad.length = AES_GCM_AAD_LENGTH;
 
 	/* Cipher Parameters */
-	op->sym->cipher.iv.data = aes_iv;
+	op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
+			uint8_t *, IV_OFFSET);
+	op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	op->sym->cipher.iv.length = AES_CIPHER_IV_LENGTH;
+	rte_memcpy(op->sym->cipher.iv.data, aes_iv, AES_CIPHER_IV_LENGTH);
 
 	/* Data lengths/offsets Parameters */
 	op->sym->auth.data.offset = 0;
@@ -2951,22 +2958,31 @@ test_perf_set_crypto_op_snow3g(struct rte_crypto_op *op, struct rte_mbuf *m,
 		struct rte_cryptodev_sym_session *sess, unsigned data_len,
 		unsigned digest_len)
 {
+	uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op,
+			uint8_t *, IV_OFFSET);
+
 	if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
 		rte_crypto_op_free(op);
 		return NULL;
 	}
 
+	rte_memcpy(IV_ptr, snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
+
 	/* Authentication Parameters */
 	op->sym->auth.digest.data = (uint8_t *)m->buf_addr +
 						(m->data_off + data_len);
 	op->sym->auth.digest.phys_addr =
 				rte_pktmbuf_mtophys_offset(m, data_len);
 	op->sym->auth.digest.length = digest_len;
-	op->sym->auth.aad.data = snow3g_iv;
+	op->sym->auth.aad.data = IV_ptr;
+	op->sym->auth.aad.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	op->sym->auth.aad.length = SNOW3G_CIPHER_IV_LENGTH;
 
 	/* Cipher Parameters */
-	op->sym->cipher.iv.data = snow3g_iv;
+	op->sym->cipher.iv.data = IV_ptr;
+	op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	op->sym->cipher.iv.length = SNOW3G_CIPHER_IV_LENGTH;
 
 	/* Data lengths/offsets Parameters */
@@ -2993,12 +3009,14 @@ test_perf_set_crypto_op_snow3g_cipher(struct rte_crypto_op *op,
 	}
 
 	/* Cipher Parameters */
-	op->sym->cipher.iv.data = rte_pktmbuf_mtod(m, uint8_t *);
+	op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
+			uint8_t *, IV_OFFSET);
+	op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	op->sym->cipher.iv.length = SNOW3G_CIPHER_IV_LENGTH;
 	rte_memcpy(op->sym->cipher.iv.data, snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
-	op->sym->cipher.iv.phys_addr = rte_pktmbuf_mtophys(m);
 
-	op->sym->cipher.data.offset = SNOW3G_CIPHER_IV_LENGTH;
+	op->sym->cipher.data.offset = 0;
 	op->sym->cipher.data.length = data_len << 3;
 
 	op->sym->m_src = m;
@@ -3028,14 +3046,16 @@ test_perf_set_crypto_op_snow3g_hash(struct rte_crypto_op *op,
 				rte_pktmbuf_mtophys_offset(m, data_len +
 					SNOW3G_CIPHER_IV_LENGTH);
 	op->sym->auth.digest.length = digest_len;
-	op->sym->auth.aad.data = rte_pktmbuf_mtod(m, uint8_t *);
+	op->sym->auth.aad.data = rte_crypto_op_ctod_offset(op,
+			uint8_t *, IV_OFFSET);
+	op->sym->auth.aad.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	op->sym->auth.aad.length = SNOW3G_CIPHER_IV_LENGTH;
 	rte_memcpy(op->sym->auth.aad.data, snow3g_iv,
 			SNOW3G_CIPHER_IV_LENGTH);
-	op->sym->auth.aad.phys_addr = rte_pktmbuf_mtophys(m);
 
 	/* Data lengths/offsets Parameters */
-	op->sym->auth.data.offset = SNOW3G_CIPHER_IV_LENGTH;
+	op->sym->auth.data.offset = 0;
 	op->sym->auth.data.length = data_len << 3;
 
 	op->sym->m_src = m;
@@ -3060,12 +3080,15 @@ test_perf_set_crypto_op_3des(struct rte_crypto_op *op, struct rte_mbuf *m,
 	op->sym->auth.digest.phys_addr =
 				rte_pktmbuf_mtophys_offset(m, data_len);
 	op->sym->auth.digest.length = digest_len;
-	op->sym->auth.aad.data = triple_des_iv;
-	op->sym->auth.aad.length = TRIPLE_DES_CIPHER_IV_LENGTH;
 
 	/* Cipher Parameters */
-	op->sym->cipher.iv.data = triple_des_iv;
+	op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
+			uint8_t *, IV_OFFSET);
+	op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	op->sym->cipher.iv.length = TRIPLE_DES_CIPHER_IV_LENGTH;
+	rte_memcpy(op->sym->cipher.iv.data, triple_des_iv,
+			TRIPLE_DES_CIPHER_IV_LENGTH);
 
 	/* Data lengths/offsets Parameters */
 	op->sym->auth.data.offset = 0;
@@ -3131,10 +3154,9 @@ test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
 			return -1;
 		}
 
-		/* Make room for Digest and IV in mbuf */
+		/* Make room for Digest in mbuf */
 		if (pparams->chain != CIPHER_ONLY)
 			rte_pktmbuf_append(mbufs[i], digest_length);
-		rte_pktmbuf_prepend(mbufs[i], AES_CIPHER_IV_LENGTH);
 	}
 
 
@@ -3255,12 +3277,12 @@ test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
 	/* Generate a burst of crypto operations */
 	for (i = 0; i < (pparams->burst_size * NUM_MBUF_SETS); i++) {
 		/*
-		 * Buffer size + iv/aad len is allocated, for perf tests they
+		 * Buffer size is allocated, for perf tests they
 		 * are equal + digest len.
 		 */
 		mbufs[i] = test_perf_create_pktmbuf(
 				ts_params->mbuf_mp,
-				pparams->buf_size + SNOW3G_CIPHER_IV_LENGTH +
+				pparams->buf_size  +
 				digest_length);
 
 		if (mbufs[i] == NULL) {
@@ -4162,28 +4184,25 @@ perf_gcm_set_crypto_op(struct rte_crypto_op *op, struct rte_mbuf *m,
 		return NULL;
 	}
 
-	uint16_t iv_pad_len = ALIGN_POW2_ROUNDUP(params->symmetric_op->iv_len,
-						 16);
-
 	op->sym->auth.digest.data = m_hlp->digest;
 	op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
 					  m,
 					  params->symmetric_op->aad_len +
-					  iv_pad_len +
 					  params->symmetric_op->p_len);
 
 	op->sym->auth.digest.length = params->symmetric_op->t_len;
 
 	op->sym->auth.aad.data = m_hlp->aad;
 	op->sym->auth.aad.length = params->symmetric_op->aad_len;
-	op->sym->auth.aad.phys_addr = rte_pktmbuf_mtophys_offset(
-					  m,
-					  iv_pad_len);
+	op->sym->auth.aad.phys_addr = rte_pktmbuf_mtophys(m);
 
 	rte_memcpy(op->sym->auth.aad.data, params->symmetric_op->aad_data,
 		       params->symmetric_op->aad_len);
 
-	op->sym->cipher.iv.data = m_hlp->iv;
+	op->sym->cipher.iv.data = rte_crypto_op_ctod_offset(op,
+			uint8_t *, IV_OFFSET);
+	op->sym->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(op,
+			IV_OFFSET);
 	rte_memcpy(op->sym->cipher.iv.data, params->symmetric_op->iv_data,
 		       params->symmetric_op->iv_len);
 	if (params->symmetric_op->iv_len == 12)
@@ -4192,11 +4211,11 @@ perf_gcm_set_crypto_op(struct rte_crypto_op *op, struct rte_mbuf *m,
 	op->sym->cipher.iv.length = params->symmetric_op->iv_len;
 
 	op->sym->auth.data.offset =
-			iv_pad_len + params->symmetric_op->aad_len;
+			params->symmetric_op->aad_len;
 	op->sym->auth.data.length = params->symmetric_op->p_len;
 
 	op->sym->cipher.data.offset =
-			iv_pad_len + params->symmetric_op->aad_len;
+			params->symmetric_op->aad_len;
 	op->sym->cipher.data.length = params->symmetric_op->p_len;
 
 	op->sym->m_src = m;
@@ -4210,8 +4229,6 @@ test_perf_create_pktmbuf_fill(struct rte_mempool *mpool,
 		unsigned buf_sz, struct crypto_params *m_hlp)
 {
 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
-	uint16_t iv_pad_len =
-			ALIGN_POW2_ROUNDUP(params->symmetric_op->iv_len, 16);
 	uint16_t aad_len = params->symmetric_op->aad_len;
 	uint16_t digest_size = params->symmetric_op->t_len;
 	char *p;
@@ -4223,13 +4240,6 @@ test_perf_create_pktmbuf_fill(struct rte_mempool *mpool,
 	}
 	m_hlp->aad = (uint8_t *)p;
 
-	p = rte_pktmbuf_append(m, iv_pad_len);
-	if (p == NULL) {
-		rte_pktmbuf_free(m);
-		return NULL;
-	}
-	m_hlp->iv = (uint8_t *)p;
-
 	p = rte_pktmbuf_append(m, buf_sz);
 	if (p == NULL) {
 		rte_pktmbuf_free(m);
@@ -4348,22 +4358,20 @@ perf_AES_GCM(uint8_t dev_id, uint16_t queue_id,
 
 		for (m = 0; m < burst_dequeued; m++) {
 			if (test_ops) {
-				uint16_t iv_pad_len = ALIGN_POW2_ROUNDUP
-					(pparams->symmetric_op->iv_len, 16);
 				uint8_t *pkt = rte_pktmbuf_mtod(
 					proc_ops[m]->sym->m_src,
 					uint8_t *);
 
 				TEST_ASSERT_BUFFERS_ARE_EQUAL(
 					pparams->symmetric_op->c_data,
-					pkt + iv_pad_len +
+					pkt +
 					pparams->symmetric_op->aad_len,
 					pparams->symmetric_op->c_len,
 					"GCM Ciphertext data not as expected");
 
 				TEST_ASSERT_BUFFERS_ARE_EQUAL(
 					pparams->symmetric_op->t_data,
-					pkt + iv_pad_len +
+					pkt +
 					pparams->symmetric_op->aad_len +
 					pparams->symmetric_op->c_len,
 					pparams->symmetric_op->t_len,
-- 
2.9.4

  parent reply	other threads:[~2017-06-21 15:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21  7:47 [dpdk-dev] [PATCH 01/22] cryptodev: move session type to generic crypto op Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 02/22] cryptodev: replace enums with 1-byte variables Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 03/22] cryptodev: remove opaque data pointer in crypto op Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 04/22] cryptodev: do not store pointer to op specific params Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 05/22] cryptodev: add crypto op helper macros Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 06/22] crypto/qat: fix auth parameters for KASUMI Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 07/22] test/crypto: move IV to crypto op private data Pablo de Lara
2017-06-21  7:47 ` Pablo de Lara [this message]
2017-06-21  7:47 ` [dpdk-dev] [PATCH 09/22] app/crypto-perf: " Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 10/22] examples/l2fwd-crypto: " Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 11/22] examples/ipsec-secgw: " Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 12/22] cryptodev: pass IV as offset Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 13/22] cryptodev: move IV parameters to crypto session Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 14/22] cryptodev: add auth IV Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 15/22] cryptodev: do not use AAD in wireless algorithms Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 16/22] cryptodev: remove AAD length from crypto op Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 17/22] cryptodev: remove digest " Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 18/22] cryptodev: set AES-GMAC as auth-only algo Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 19/22] cryptodev: add AEAD specific data Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 20/22] cryptodev: add AEAD parameters in crypto operation Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 21/22] cryptodev: use AES-GCM/CCM as AEAD algorithms Pablo de Lara
2017-06-21  7:47 ` [dpdk-dev] [PATCH 22/22] cryptodev: remove AAD from authentication structure Pablo de Lara
2017-06-21 16:29 ` [dpdk-dev] [PATCH 01/22] cryptodev: move session type to generic crypto op De Lara Guarch, Pablo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170621074731.45013-8-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).