DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: akhil.goyal@nxp.com, Vakul Garg <vakul.garg@nxp.com>
Subject: [dpdk-dev] [PATCH 04/10] crypto/dpaa2_sec: enhance gcm descs to not skip aadt
Date: Fri, 11 Oct 2019 22:02:27 +0530	[thread overview]
Message-ID: <20191011163233.31017-5-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20191011163233.31017-1-hemant.agrawal@nxp.com>

From: Vakul Garg <vakul.garg@nxp.com>

The GCM descriptors needlessly skip auth_only_len bytes from output
buffer. Due to this, workarounds have to be made in dpseci driver code.
Also this leads to failing of one cryptodev test case for gcm. In this
patch, we change the descriptor construction and adjust dpseci driver
accordingly. The test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg
now passes.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 25 ++++++++-------------
 drivers/crypto/dpaa2_sec/hw/desc/algo.h     | 10 ---------
 drivers/crypto/dpaa_sec/dpaa_sec.c          | 14 +++++-------
 3 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 14f0c523c..8803e8d3c 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -350,14 +350,13 @@ build_authenc_gcm_sg_fd(dpaa2_sec_session *sess,
 		DPAA2_SET_FLE_INTERNAL_JD(op_fle, auth_only_len);
 
 	op_fle->length = (sess->dir == DIR_ENC) ?
-			(sym_op->aead.data.length + icv_len + auth_only_len) :
-			sym_op->aead.data.length + auth_only_len;
+			(sym_op->aead.data.length + icv_len) :
+			sym_op->aead.data.length;
 
 	/* Configure Output SGE for Encap/Decap */
 	DPAA2_SET_FLE_ADDR(sge, DPAA2_MBUF_VADDR_TO_IOVA(mbuf));
-	DPAA2_SET_FLE_OFFSET(sge, mbuf->data_off +
-			RTE_ALIGN_CEIL(auth_only_len, 16) - auth_only_len);
-	sge->length = mbuf->data_len - sym_op->aead.data.offset + auth_only_len;
+	DPAA2_SET_FLE_OFFSET(sge, mbuf->data_off + sym_op->aead.data.offset);
+	sge->length = mbuf->data_len - sym_op->aead.data.offset;
 
 	mbuf = mbuf->next;
 	/* o/p segs */
@@ -510,24 +509,21 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
 	if (auth_only_len)
 		DPAA2_SET_FLE_INTERNAL_JD(fle, auth_only_len);
 	fle->length = (sess->dir == DIR_ENC) ?
-			(sym_op->aead.data.length + icv_len + auth_only_len) :
-			sym_op->aead.data.length + auth_only_len;
+			(sym_op->aead.data.length + icv_len) :
+			sym_op->aead.data.length;
 
 	DPAA2_SET_FLE_SG_EXT(fle);
 
 	/* Configure Output SGE for Encap/Decap */
 	DPAA2_SET_FLE_ADDR(sge, DPAA2_MBUF_VADDR_TO_IOVA(dst));
-	DPAA2_SET_FLE_OFFSET(sge, dst->data_off +
-			RTE_ALIGN_CEIL(auth_only_len, 16) - auth_only_len);
-	sge->length = sym_op->aead.data.length + auth_only_len;
+	DPAA2_SET_FLE_OFFSET(sge, dst->data_off + sym_op->aead.data.offset);
+	sge->length = sym_op->aead.data.length;
 
 	if (sess->dir == DIR_ENC) {
 		sge++;
 		DPAA2_SET_FLE_ADDR(sge,
 				DPAA2_VADDR_TO_IOVA(sym_op->aead.digest.data));
 		sge->length = sess->digest_length;
-		DPAA2_SET_FD_LEN(fd, (sym_op->aead.data.length +
-					sess->iv.length + auth_only_len));
 	}
 	DPAA2_SET_FLE_FIN(sge);
 
@@ -566,10 +562,6 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
 		       sess->digest_length);
 		DPAA2_SET_FLE_ADDR(sge, DPAA2_VADDR_TO_IOVA(old_icv));
 		sge->length = sess->digest_length;
-		DPAA2_SET_FD_LEN(fd, (sym_op->aead.data.length +
-				 sess->digest_length +
-				 sess->iv.length +
-				 auth_only_len));
 	}
 	DPAA2_SET_FLE_FIN(sge);
 
@@ -578,6 +570,7 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
 		DPAA2_SET_FD_INTERNAL_JD(fd, auth_only_len);
 	}
 
+	DPAA2_SET_FD_LEN(fd, fle->length);
 	return 0;
 }
 
diff --git a/drivers/crypto/dpaa2_sec/hw/desc/algo.h b/drivers/crypto/dpaa2_sec/hw/desc/algo.h
index 32ce787fa..c41cb2292 100644
--- a/drivers/crypto/dpaa2_sec/hw/desc/algo.h
+++ b/drivers/crypto/dpaa2_sec/hw/desc/algo.h
@@ -649,11 +649,6 @@ cnstr_shdsc_gcm_encap(uint32_t *descbuf, bool ps, bool swap,
 	MATHB(p, ZERO, ADD, MATH3, VSEQINSZ, 4, 0);
 	pzeroassocjump1 = JUMP(p, zeroassocjump1, LOCAL_JUMP, ALL_TRUE, MATH_Z);
 
-	MATHB(p, ZERO, ADD, MATH3, VSEQOUTSZ, 4, 0);
-
-	/* skip assoc data */
-	SEQFIFOSTORE(p, SKIP, 0, 0, VLF);
-
 	/* cryptlen = seqinlen - assoclen */
 	MATHB(p, SEQINSZ, SUB, MATH3, VSEQOUTSZ, 4, 0);
 
@@ -756,11 +751,6 @@ cnstr_shdsc_gcm_decap(uint32_t *descbuf, bool ps, bool swap,
 	MATHB(p, ZERO, ADD, MATH3, VSEQINSZ, 4, 0);
 	pzeroassocjump1 = JUMP(p, zeroassocjump1, LOCAL_JUMP, ALL_TRUE, MATH_Z);
 
-	MATHB(p, ZERO, ADD, MATH3, VSEQOUTSZ, 4, 0);
-
-	/* skip assoc data */
-	SEQFIFOSTORE(p, SKIP, 0, 0, VLF);
-
 	/* read assoc data */
 	SEQFIFOLOAD(p, AAD1, 0, CLASS1 | VLF | FLUSH1);
 
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index e89cbcefb..c1c6c054a 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -1180,10 +1180,9 @@ build_cipher_auth_gcm_sg(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	out_sg = &cf->sg[0];
 	out_sg->extension = 1;
 	if (is_encode(ses))
-		out_sg->length = sym->aead.data.length + ses->auth_only_len
-						+ ses->digest_length;
+		out_sg->length = sym->aead.data.length + ses->digest_length;
 	else
-		out_sg->length = sym->aead.data.length + ses->auth_only_len;
+		out_sg->length = sym->aead.data.length;
 
 	/* output sg entries */
 	sg = &cf->sg[2];
@@ -1192,9 +1191,8 @@ build_cipher_auth_gcm_sg(struct rte_crypto_op *op, dpaa_sec_session *ses)
 
 	/* 1st seg */
 	qm_sg_entry_set64(sg, rte_pktmbuf_mtophys(mbuf));
-	sg->length = mbuf->data_len - sym->aead.data.offset +
-					ses->auth_only_len;
-	sg->offset = sym->aead.data.offset - ses->auth_only_len;
+	sg->length = mbuf->data_len - sym->aead.data.offset;
+	sg->offset = sym->aead.data.offset;
 
 	/* Successive segs */
 	mbuf = mbuf->next;
@@ -1367,8 +1365,8 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	sg++;
 	qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop(sg));
 	qm_sg_entry_set64(sg,
-		dst_start_addr + sym->aead.data.offset - ses->auth_only_len);
-	sg->length = sym->aead.data.length + ses->auth_only_len;
+		dst_start_addr + sym->aead.data.offset);
+	sg->length = sym->aead.data.length;
 	length = sg->length;
 	if (is_encode(ses)) {
 		cpu_to_hw_sg(sg);
-- 
2.17.1


  parent reply	other threads:[~2019-10-11 16:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 16:32 [dpdk-dev] [PATCH 00/10] NXP DPAAx crypto fixes Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 01/10] test/crypto: fix PDCP test support Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 02/10] crypto/dpaa2_sec: fix ipv6 support Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 03/10] crypto/dpaa_sec: fix to check for aead as well Hemant Agrawal
2019-10-11 16:32 ` Hemant Agrawal [this message]
2019-10-11 16:32 ` [dpdk-dev] [PATCH 05/10] crypto/dpaa2_sec: add support of auth trailer in cipher-auth Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 06/10] test/crypto: increase test cases support for dpaax Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 07/10] test/crypto: add test to test ESN like case Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 08/10] crypto/dpaa_sec: add support for snow3G and ZUC Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 09/10] test/crypto: enable snow3G and zuc cases for dpaa Hemant Agrawal
2019-10-11 16:32 ` [dpdk-dev] [PATCH 10/10] crypto/dpaa_sec: code reorg for better session mgmt Hemant Agrawal
2019-10-11 19:03   ` Aaron Conole
2019-10-14  4:57     ` Hemant Agrawal
2019-10-14  6:53 ` [dpdk-dev] [PATCH v2 00/10] NXP DPAAx crypto fixes Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 01/10] test/crypto: fix PDCP test support Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 02/10] crypto/dpaa2_sec: fix ipv6 support Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 03/10] crypto/dpaa_sec: fix to check for aead as well Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 04/10] crypto/dpaa2_sec: enhance gcm descs to not skip aadt Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 05/10] crypto/dpaa2_sec: add support of auth trailer in cipher-auth Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 06/10] test/crypto: increase test cases support for dpaax Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 07/10] test/crypto: add test to test ESN like case Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 08/10] crypto/dpaa_sec: add support for snow3G and ZUC Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 09/10] test/crypto: enable snow3G and zuc cases for dpaa Hemant Agrawal
2019-10-14  6:53   ` [dpdk-dev] [PATCH v2 10/10] crypto/dpaa_sec: code reorg for better session mgmt Hemant Agrawal
2019-10-15 12:50   ` [dpdk-dev] [PATCH v2 00/10] NXP DPAAx crypto fixes Akhil Goyal
2019-10-15 12:51     ` Akhil Goyal
2019-10-15 13:30       ` Akhil Goyal

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=20191011163233.31017-5-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=vakul.garg@nxp.com \
    /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).