From patchwork Tue Dec 20 14:32:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejasree Kondoj X-Patchwork-Id: 121082 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E96BFA0545; Tue, 20 Dec 2022 15:33:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEAF841141; Tue, 20 Dec 2022 15:33:01 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 12E9342D3C for ; Tue, 20 Dec 2022 15:33:00 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BKEJKMU010037 for ; Tue, 20 Dec 2022 06:33:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=KT/L8du9s3g+qUhvbYqFxCCoZcEUCGA0FokxbMlY3GE=; b=HBxA5XdECh2Im6nOINr+nhumXsKs2Ol6fn1eADZkKTZfG8KDaUXYAnEC1Mvv0KRkwwra 16fC417PQPlc0Q9V1uhhpzKPfyU3o+GT1Tx0GTTTwnpVE28nt0sipHeORp5Z3D5RLttQ 69OR7eeRwAU6eRXtf2GameGOj/bzRvgJI+P+izQtyFOawJKXuwmsI/wFB1151l6eP435 nPYIJNooYmLjcHwKForYfEOwtIwiVFPlfvSnTOgTpJLknrlTuSAKHYwqY32MwUwL6ktb UjYLHxYSHQhp2bnTBXzCVMQKnlZVpiHwEVv3zSejIpFA5uRhydwx3sHNN/nnSsk/ECap kA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3mhe5rnb5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Dec 2022 06:33:00 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 20 Dec 2022 06:32:58 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Tue, 20 Dec 2022 06:32:58 -0800 Received: from hyd1554.marvell.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id F0B763F7063; Tue, 20 Dec 2022 06:32:55 -0800 (PST) From: Tejasree Kondoj To: Akhil Goyal CC: Gowrishankar Muthukrishnan , Anoob Joseph , Vidya Sagar Velumuri , "Volodymyr Fialko" , Aakash Sasidharan , Subject: [PATCH 08/17] crypto/cnxk: fix incorrect digest for an empty input data Date: Tue, 20 Dec 2022 20:02:23 +0530 Message-ID: <20221220143232.2519650-9-ktejasree@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221220143232.2519650-1-ktejasree@marvell.com> References: <20221220143232.2519650-1-ktejasree@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: h3pVg56NRCLogYDkZpC9zyNlAqD0saw- X-Proofpoint-ORIG-GUID: h3pVg56NRCLogYDkZpC9zyNlAqD0saw- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-20_05,2022-12-20_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Gowrishankar Muthukrishnan For an empty input data, digest value is incorrectly generated from previous auth op, in case executed. This is due to incorrect gather component used. Fixes: 7c19abdd0cf1 ("common/cnxk: support 103XX CPT") Signed-off-by: Anoob Joseph Signed-off-by: Gowrishankar Muthukrishnan --- drivers/crypto/cnxk/cnxk_se.h | 46 ++++++++++++++--------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index ce4c2bb585..2944d3c287 100644 --- a/drivers/crypto/cnxk/cnxk_se.h +++ b/drivers/crypto/cnxk/cnxk_se.h @@ -247,7 +247,7 @@ fill_sg_comp_from_iov(struct roc_se_sglist_comp *list, uint32_t i, uint32_t extra_len = extra_buf ? extra_buf->size : 0; uint32_t size = *psize; - for (j = 0; (j < from->buf_cnt) && size; j++) { + for (j = 0; j < from->buf_cnt; j++) { struct roc_se_sglist_comp *to = &list[i >> 2]; uint32_t buf_sz = from->bufs[j].size; void *vaddr = from->bufs[j].vaddr; @@ -314,6 +314,9 @@ fill_sg_comp_from_iov(struct roc_se_sglist_comp *list, uint32_t i, if (extra_offset) extra_offset -= size; i++; + + if (unlikely(!size)) + break; } *psize = size; @@ -370,7 +373,9 @@ fill_sg2_comp_from_iov(struct roc_se_sg2list_comp *list, uint32_t i, struct roc_ uint32_t extra_len = extra_buf ? extra_buf->size : 0; uint32_t size = *psize; - for (j = 0; (j < from->buf_cnt) && size; j++) { + rte_prefetch2(psize); + + for (j = 0; j < from->buf_cnt; j++) { struct roc_se_sg2list_comp *to = &list[i / 3]; uint32_t buf_sz = from->bufs[j].size; void *vaddr = from->bufs[j].vaddr; @@ -436,6 +441,9 @@ fill_sg2_comp_from_iov(struct roc_se_sg2list_comp *list, uint32_t i, struct roc_ if (extra_offset) extra_offset -= size; i++; + + if (unlikely(!size)) + break; } *psize = size; @@ -887,20 +895,10 @@ cpt_digest_gen_sg_ver1_prep(uint32_t flags, uint64_t d_lens, struct roc_se_fc_pa /* input data */ size = data_len; - if (size) { - i = fill_sg_comp_from_iov(gather_comp, i, params->src_iov, 0, - &size, NULL, 0); - if (unlikely(size)) { - plt_dp_err("Insufficient dst IOV size, short by %dB", - size); - return -1; - } - } else { - /* - * Looks like we need to support zero data - * gather ptr in case of hash & hmac - */ - i++; + i = fill_sg_comp_from_iov(gather_comp, i, params->src_iov, 0, &size, NULL, 0); + if (unlikely(size)) { + plt_dp_err("Insufficient dst IOV size, short by %dB", size); + return -1; } ((uint16_t *)in_buffer)[2] = rte_cpu_to_be_16(i); g_size_bytes = ((i + 3) / 4) * sizeof(struct roc_se_sglist_comp); @@ -1011,18 +1009,10 @@ cpt_digest_gen_sg_ver2_prep(uint32_t flags, uint64_t d_lens, struct roc_se_fc_pa /* input data */ size = data_len; - if (size) { - i = fill_sg2_comp_from_iov(gather_comp, i, params->src_iov, 0, &size, NULL, 0); - if (unlikely(size)) { - plt_dp_err("Insufficient dst IOV size, short by %dB", size); - return -1; - } - } else { - /* - * Looks like we need to support zero data - * gather ptr in case of hash & hmac - */ - i++; + i = fill_sg2_comp_from_iov(gather_comp, i, params->src_iov, 0, &size, NULL, 0); + if (unlikely(size)) { + plt_dp_err("Insufficient dst IOV size, short by %dB", size); + return -1; } cpt_inst_w5.s.gather_sz = ((i + 2) / 3);