From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5C14542D07; Tue, 20 Jun 2023 12:21:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1189542D2C; Tue, 20 Jun 2023 12:21:22 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5F42F42D20 for ; Tue, 20 Jun 2023 12:21:20 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35K4hQdU027049 for ; Tue, 20 Jun 2023 03:21:19 -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=2wE2FMQkR8MSrjSND/GFoeAA+dv7/d18L/fvWUggSrI=; b=bcDrIBSSq3FOvJTYXRsZVAHLcvM9DWqMLmhRf/yUnSoPDlILHFz5b5NgNa/pFEy0tjqx bFdHczGOm04TNEMU5Q9prlqNctUqmgpmoGeubu5d4pSmD7r0Rj+p10li/cNvSK2It78c MPF0IQeEQ/Ofk0JEEzahkSr9g4sNFVBeyiKs75QA8tMFLoHlA0z8xvqzyab8/ZulX59h bjhvVz8ZjkqScg1DAFVRFEd7LcRv+/I+c1LbDUGsso4Ofwp+wxLq+1+jStfP3oyHfE62 tVzY5ulcFV8qkCPNguLDMiZz48CO3imO9NuO+4NUt+UogUOrPD6PgSo7+UrqbqZeYcT4 6Q== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3rb5b312s2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Jun 2023 03:21:19 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 20 Jun 2023 03:21:17 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 20 Jun 2023 03:21:17 -0700 Received: from hyd1554.marvell.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id BEF7E3F7071; Tue, 20 Jun 2023 03:21:14 -0700 (PDT) From: Tejasree Kondoj To: Akhil Goyal CC: Aakash Sasidharan , Anoob Joseph , Gowrishankar Muthukrishnan , Vidya Sagar Velumuri , Subject: [PATCH v3 3/8] crypto/cnxk: use pt inst for null cipher with null auth Date: Tue, 20 Jun 2023 15:51:01 +0530 Message-ID: <20230620102106.3970544-4-ktejasree@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230620102106.3970544-1-ktejasree@marvell.com> References: <20230620102106.3970544-1-ktejasree@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: IAU3ebN5KAGx6ombqeoyKYK-oo5vIxd4 X-Proofpoint-ORIG-GUID: IAU3ebN5KAGx6ombqeoyKYK-oo5vIxd4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-20_06,2023-06-16_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 From: Aakash Sasidharan Use passthrough instruction for NULL cipher with NULL auth combination. Signed-off-by: Aakash Sasidharan --- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 20 ++++---- drivers/crypto/cnxk/cnxk_se.h | 59 ++++++++++++++++-------- 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c index d405786668..2018b0eba5 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c @@ -526,16 +526,13 @@ cnxk_sess_fill(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xform, return -EINVAL; } - if ((c_xfrm == NULL || c_xfrm->cipher.algo == RTE_CRYPTO_CIPHER_NULL) && - a_xfrm != NULL && a_xfrm->auth.algo == RTE_CRYPTO_AUTH_NULL && - a_xfrm->auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) { - plt_dp_err("Null cipher + null auth verify is not supported"); - return -ENOTSUP; - } + if ((aead_xfrm == NULL) && + (c_xfrm == NULL || c_xfrm->cipher.algo == RTE_CRYPTO_CIPHER_NULL) && + (a_xfrm == NULL || a_xfrm->auth.algo == RTE_CRYPTO_AUTH_NULL)) + sess->passthrough = 1; /* Cipher only */ - if (c_xfrm != NULL && - (a_xfrm == NULL || a_xfrm->auth.algo == RTE_CRYPTO_AUTH_NULL)) { + if (c_xfrm != NULL && (a_xfrm == NULL || a_xfrm->auth.algo == RTE_CRYPTO_AUTH_NULL)) { if (fill_sess_cipher(c_xfrm, sess)) return -ENOTSUP; else @@ -662,7 +659,8 @@ cnxk_cpt_inst_w7_get(struct cnxk_se_sess *sess, struct roc_cpt *roc_cpt) inst_w7.s.cptr += 8; /* Set the engine group */ - if (sess->zsk_flag || sess->aes_ctr_eea2 || sess->is_sha3 || sess->is_sm3) + if (sess->zsk_flag || sess->aes_ctr_eea2 || sess->is_sha3 || sess->is_sm3 || + sess->passthrough) inst_w7.s.egrp = roc_cpt->eng_grp[CPT_ENG_TYPE_SE]; else inst_w7.s.egrp = roc_cpt->eng_grp[CPT_ENG_TYPE_IE]; @@ -687,7 +685,9 @@ sym_session_configure(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xfor sess_priv->lf = roc_cpt->lf[0]; - if (sess_priv->cpt_op & ROC_SE_OP_CIPHER_MASK) { + if (sess_priv->passthrough) + thr_type = CPT_DP_THREAD_TYPE_PT; + else if (sess_priv->cpt_op & ROC_SE_OP_CIPHER_MASK) { switch (sess_priv->roc_se_ctx.fc_type) { case ROC_SE_FC_GEN: if (sess_priv->aes_gcm || sess_priv->aes_ccm || sess_priv->chacha_poly) diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index 87414eb131..ceb50fa3b6 100644 --- a/drivers/crypto/cnxk/cnxk_se.h +++ b/drivers/crypto/cnxk/cnxk_se.h @@ -24,6 +24,8 @@ enum cpt_dp_thread_type { CPT_DP_THREAD_TYPE_PDCP_CHAIN, CPT_DP_THREAD_TYPE_KASUMI, CPT_DP_THREAD_AUTH_ONLY, + CPT_DP_THREAD_GENERIC, + CPT_DP_THREAD_TYPE_PT, }; struct cnxk_se_sess { @@ -46,7 +48,8 @@ struct cnxk_se_sess { uint8_t is_sha3 : 1; uint8_t short_iv : 1; uint8_t is_sm3 : 1; - uint8_t rsvd : 5; + uint8_t passthrough : 1; + uint8_t rsvd : 4; uint8_t mac_len; uint8_t iv_length; uint8_t auth_iv_length; @@ -636,15 +639,6 @@ cpt_digest_gen_sg_ver1_prep(uint32_t flags, uint64_t d_lens, struct roc_se_fc_pa cpt_inst_w4.s.dlen = data_len; } - /* Null auth only case enters the if */ - if (unlikely(!hash_type && !ctx->enc_cipher)) { - cpt_inst_w4.s.opcode_major = ROC_SE_MAJOR_OP_MISC; - /* Minor op is passthrough */ - cpt_inst_w4.s.opcode_minor = 0x03; - /* Send out completion code only */ - cpt_inst_w4.s.param2 = 0x1; - } - /* DPTR has SG list */ in_buffer = m_vaddr; @@ -758,15 +752,6 @@ cpt_digest_gen_sg_ver2_prep(uint32_t flags, uint64_t d_lens, struct roc_se_fc_pa cpt_inst_w4.s.dlen = data_len; } - /* Null auth only case enters the if */ - if (unlikely(!hash_type && !ctx->enc_cipher)) { - cpt_inst_w4.s.opcode_major = ROC_SE_MAJOR_OP_MISC; - /* Minor op is passthrough */ - cpt_inst_w4.s.opcode_minor = 0x03; - /* Send out completion code only */ - cpt_inst_w4.s.param2 = 0x1; - } - /* DPTR has SG list */ /* TODO Add error check if space will be sufficient */ @@ -2376,6 +2361,7 @@ prepare_iov_from_pkt_inplace(struct rte_mbuf *pkt, iovec->buf_cnt = index; return; } + static __rte_always_inline int fill_fc_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, struct cpt_qp_meta_info *m_info, struct cpt_inflight_req *infl_req, @@ -2592,6 +2578,38 @@ fill_fc_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, return ret; } +static inline int +fill_passthrough_params(struct rte_crypto_op *cop, struct cpt_inst_s *inst) +{ + struct rte_crypto_sym_op *sym_op = cop->sym; + struct rte_mbuf *m_src, *m_dst; + + const union cpt_inst_w4 w4 = { + .s.opcode_major = ROC_SE_MAJOR_OP_MISC, + .s.opcode_minor = ROC_SE_MISC_MINOR_OP_PASSTHROUGH, + .s.param1 = 1, + .s.param2 = 1, + .s.dlen = 0, + }; + + m_src = sym_op->m_src; + m_dst = sym_op->m_dst; + + if (unlikely(m_dst != NULL && m_dst != m_src)) { + void *src = rte_pktmbuf_mtod_offset(m_src, void *, cop->sym->cipher.data.offset); + void *dst = rte_pktmbuf_mtod(m_dst, void *); + int data_len = cop->sym->cipher.data.length; + + rte_memcpy(dst, src, data_len); + } + + inst->w0.u64 = 0; + inst->w5.u64 = 0; + inst->w4.u64 = w4.u64; + + return 0; +} + static __rte_always_inline int fill_pdcp_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, struct cpt_qp_meta_info *m_info, struct cpt_inflight_req *infl_req, @@ -3012,6 +3030,9 @@ cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op, struct cnxk_ int ret; switch (sess->dp_thr_type) { + case CPT_DP_THREAD_TYPE_PT: + ret = fill_passthrough_params(op, inst); + break; case CPT_DP_THREAD_TYPE_PDCP: ret = fill_pdcp_params(op, sess, &qp->meta_info, infl_req, inst, is_sg_ver2); break; -- 2.25.1