From patchwork Thu Mar 14 08:38:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vidya Sagar Velumuri X-Patchwork-Id: 138359 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 3139D43CAE; Thu, 14 Mar 2024 09:39:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B6FD42E7F; Thu, 14 Mar 2024 09:39:27 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7163342E5D for ; Thu, 14 Mar 2024 09:39:22 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42DNJPLL016325 for ; Thu, 14 Mar 2024 01:39:21 -0700 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=VIPg+7okUZS1neyczFUN8PoaQOacCWeqtySm5U0o4Gw=; b=Iy3 Ua0uHv0TT2O7KoJQI43aF+1YgkyQ/s71+iy2VmUK+Ml9lQBPc7648PctxUzA8Bw8 DCHkR8ul9bLBJ/YxkpksKlbLSc/MMsn/bj0Vm1ZOtvQnC3KMThRRPVzwBQvLcpKP MbzPpIC6aE0bnWb+6ueeF2XUSlKAbj7kLnaQmHBpAxb1mujxaIOAxDbJH+a+VR5c u5au/9E1yiYOMa7mIB/fm+ymGdw1S0W35zOHlshWeHkOAPe4o6LmLeEG/hdeN2uX SRePvKv6rLpUw5e1vkfrdNUpB+iepUYWuhbtfUZqMtVWff/PBimiWGGvkG/lrATw KHGIsbw243mdMTJGazw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wucg2uwue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Mar 2024 01:39:21 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Thu, 14 Mar 2024 01:39:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Thu, 14 Mar 2024 01:39:20 -0700 Received: from localhost.localdomain (unknown [10.28.36.179]) by maili.marvell.com (Postfix) with ESMTP id D9E7C5B692D; Thu, 14 Mar 2024 01:39:17 -0700 (PDT) From: Vidya Sagar Velumuri To: Ankur Dwivedi , Anoob Joseph , Tejasree Kondoj CC: , , , , Subject: [PATCH 06/12] crypto/cnxk: handle the extra len reported by microcode Date: Thu, 14 Mar 2024 01:38:38 -0700 Message-ID: <20240314083844.3319506-7-vvelumuri@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240314083844.3319506-1-vvelumuri@marvell.com> References: <20240314083844.3319506-1-vvelumuri@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Hbz5dzfQQk-ijPkfqNXOmd1pqF4Y6GOL X-Proofpoint-GUID: Hbz5dzfQQk-ijPkfqNXOmd1pqF4Y6GOL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-14_07,2024-03-13_01,2023-05-22_02 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 Microcode reports one extra byte in response len specifically for AES-GCM in TLS-1.3. Handle the extra byte in PMD by decreasing the length by 1 byte. Signed-off-by: Vidya Sagar Velumuri --- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 9 ++++++--- drivers/crypto/cnxk/cn10k_cryptodev_sec.h | 3 ++- drivers/crypto/cnxk/cn10k_tls.c | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c index 8991150c05..f385550f68 100644 --- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c @@ -989,12 +989,15 @@ cn10k_cpt_ipsec_post_process(struct rte_crypto_op *cop, struct cpt_cn10k_res_s * } static inline void -cn10k_cpt_tls_post_process(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *res) +cn10k_cpt_tls_post_process(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *res, + struct cn10k_sec_session *sess) { struct rte_mbuf *mbuf = cop->sym->m_src; - const uint16_t m_len = res->rlen; + uint16_t m_len = res->rlen; if (!res->uc_compcode) { + if ((sess->tls.tls_ver == RTE_SECURITY_VERSION_TLS_1_3) && (!sess->tls.is_write)) + m_len -= 1; if (mbuf->next == NULL) mbuf->data_len = m_len; mbuf->pkt_len = m_len; @@ -1015,7 +1018,7 @@ cn10k_cpt_sec_post_process(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *re if (sess->proto == RTE_SECURITY_PROTOCOL_IPSEC) cn10k_cpt_ipsec_post_process(cop, res); else if (sess->proto == RTE_SECURITY_PROTOCOL_TLS_RECORD) - cn10k_cpt_tls_post_process(cop, res); + cn10k_cpt_tls_post_process(cop, res, sess); } static inline void diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_sec.h b/drivers/crypto/cnxk/cn10k_cryptodev_sec.h index ec216b1187..7e175119c3 100644 --- a/drivers/crypto/cnxk/cn10k_cryptodev_sec.h +++ b/drivers/crypto/cnxk/cn10k_cryptodev_sec.h @@ -37,7 +37,8 @@ struct cn10k_sec_session { uint8_t enable_padding : 1; uint8_t tail_fetch_len : 2; uint8_t is_write : 1; - uint8_t rvsd : 4; + uint8_t tls_ver : 2; + uint8_t rvsd : 2; } tls; }; /** Queue pair */ diff --git a/drivers/crypto/cnxk/cn10k_tls.c b/drivers/crypto/cnxk/cn10k_tls.c index f501fe67ac..fe4da8d2a0 100644 --- a/drivers/crypto/cnxk/cn10k_tls.c +++ b/drivers/crypto/cnxk/cn10k_tls.c @@ -610,6 +610,7 @@ cn10k_tls_read_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, struct cn10k_sec_session *sec_sess) { struct roc_ie_ot_tls_read_sa *sa_dptr; + uint8_t tls_ver = tls_xfrm->ver; struct cn10k_tls_record *tls; union cpt_inst_w4 inst_w4; void *read_sa; @@ -659,6 +660,7 @@ cn10k_tls_read_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, ROC_IE_OT_TLS13_MAJOR_OP_RECORD_DEC | ROC_IE_OT_INPLACE_BIT; } + sec_sess->tls.tls_ver = tls_ver; sec_sess->inst.w4 = inst_w4.u64; sec_sess->inst.w7 = cpt_inst_w7_get(roc_cpt, read_sa); @@ -694,6 +696,7 @@ cn10k_tls_write_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, struct cn10k_sec_session *sec_sess) { struct roc_ie_ot_tls_write_sa *sa_dptr; + uint8_t tls_ver = tls_xfrm->ver; struct cn10k_tls_record *tls; union cpt_inst_w4 inst_w4; void *write_sa; @@ -727,6 +730,7 @@ cn10k_tls_write_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, sec_sess->iv_length = crypto_xfrm->next->cipher.iv.length; } + sec_sess->tls.tls_ver = tls_ver; sec_sess->tls.is_write = 1; sec_sess->tls.enable_padding = tls_xfrm->options.extra_padding_enable; sec_sess->max_extended_len = tls_write_rlens_get(tls_xfrm, crypto_xfrm);