[1/7] common/cpt: fix encryption offset

Message ID 1591853907-2501-2-git-send-email-adwivedi@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: akhil goyal
Headers
Series test/crypto: use generic crypto auto test framework |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Ankur Dwivedi June 11, 2020, 5:38 a.m. UTC
  In case of gmac auth the encryption offset should be set to zero.

Fixes: b74652f3a91f ("common/cpt: add microcode interface for encryption")
Fixes: 177b41ceee61 ("common/cpt: add microcode interface for decryption")

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
 drivers/common/cpt/cpt_ucode.h | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
  

Comments

Akhil Goyal July 1, 2020, 8:24 p.m. UTC | #1
> 
> In case of gmac auth the encryption offset should be set to zero.
> 
> Fixes: b74652f3a91f ("common/cpt: add microcode interface for encryption")
> Fixes: 177b41ceee61 ("common/cpt: add microcode interface for decryption")
> 
> Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
I believe this should be backported to stable as well.
  
Ankur Dwivedi July 2, 2020, 1:18 p.m. UTC | #2
Hi Akhil,

Please see my response inline.

Thanks
Ankur

>-----Original Message-----
>From: Akhil Goyal <akhil.goyal@nxp.com>
>Sent: Thursday, July 2, 2020 1:54 AM
>To: Ankur Dwivedi <adwivedi@marvell.com>; dev@dpdk.org
>Cc: declan.doherty@intel.com; Anoob Joseph <anoobj@marvell.com>
>Subject: [EXT] RE: [PATCH 1/7] common/cpt: fix encryption offset
>
>External Email
>
>----------------------------------------------------------------------
>>
>> In case of gmac auth the encryption offset should be set to zero.
>>
>> Fixes: b74652f3a91f ("common/cpt: add microcode interface for
>encryption")
>> Fixes: 177b41ceee61 ("common/cpt: add microcode interface for
>decryption")
>>
>> Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
>I believe this should be backported to stable as well.
[Ankur] Will address this in v2.
  

Patch

diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index 34ccd08..ab595eb 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -682,9 +682,6 @@ 
 	m_vaddr = (uint8_t *)m_vaddr + size;
 	m_dma += size;
 
-	if (hash_type == GMAC_TYPE)
-		encr_data_len = 0;
-
 	if (unlikely(!(flags & VALID_IV_BUF))) {
 		iv_len = 0;
 		iv_offset = ENCR_IV_OFFSET(d_offs);
@@ -716,6 +713,11 @@ 
 	opcode.s.major = CPT_MAJOR_OP_FC;
 	opcode.s.minor = 0;
 
+	if (hash_type == GMAC_TYPE) {
+		encr_offset = 0;
+		encr_data_len = 0;
+	}
+
 	auth_dlen = auth_offset + auth_data_len;
 	enc_dlen = encr_data_len + encr_offset;
 	if (unlikely(encr_data_len & 0xf)) {
@@ -726,11 +728,6 @@ 
 			enc_dlen = ROUNDUP16(encr_data_len) + encr_offset;
 	}
 
-	if (unlikely(hash_type == GMAC_TYPE)) {
-		encr_offset = auth_dlen;
-		enc_dlen = 0;
-	}
-
 	if (unlikely(auth_dlen > enc_dlen)) {
 		inputlen = auth_dlen;
 		outputlen = auth_dlen + mac_len;
@@ -1033,9 +1030,6 @@ 
 	hash_type = cpt_ctx->hash_type;
 	mac_len = cpt_ctx->mac_len;
 
-	if (hash_type == GMAC_TYPE)
-		encr_data_len = 0;
-
 	if (unlikely(!(flags & VALID_IV_BUF))) {
 		iv_len = 0;
 		iv_offset = ENCR_IV_OFFSET(d_offs);
@@ -1092,6 +1086,11 @@ 
 	opcode.s.major = CPT_MAJOR_OP_FC;
 	opcode.s.minor = 1;
 
+	if (hash_type == GMAC_TYPE) {
+		encr_offset = 0;
+		encr_data_len = 0;
+	}
+
 	enc_dlen = encr_offset + encr_data_len;
 	auth_dlen = auth_offset + auth_data_len;
 
@@ -1103,9 +1102,6 @@ 
 		outputlen = enc_dlen;
 	}
 
-	if (hash_type == GMAC_TYPE)
-		encr_offset = inputlen;
-
 	vq_cmd_w0.u64 = 0;
 	vq_cmd_w0.s.param1 = encr_data_len;
 	vq_cmd_w0.s.param2 = auth_data_len;