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 C146FA0C40; Fri, 25 Jun 2021 07:58:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A32540E46; Fri, 25 Jun 2021 07:57:56 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 8DADE40698 for ; Fri, 25 Jun 2021 07:57:54 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15P5vFNr018375; Thu, 24 Jun 2021 22:57:54 -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=izpZJg142OxW6FnhQI990AH1eDv/zyHRXgU1S8znj6U=; b=LgLmcBp9RIFEg6jpymm30y/l2LTNllSqi6jDwYGd9/xoxT7Uoh2nqS6NVx6x04mIQp/N o4KLo0YRS2awk7+QiMGJELBrq23J6hsE0TvoLgvO3g4x5Jv5ITZHv/XdrZhVHkY7FeQK fEsgYSPk8gz0zGA9b7hTiL9ViLcfCeey3fqK0q8gSXjgsTF7+nisX1UYDqd/TPVS5b4F fZV9WC50fv81Qd4/0xM+cCcKqeIut67am5hV0ih+QKq3Ih2O8Dy4gqSkCmssLt3ZVszt HIT8mY7R1znANLB8WfzTcCheVz+i3SgnP/MVtHvMOarNMy61HM2h9Hor/1gwcEh+oga1 kA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 39d241shud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 24 Jun 2021 22:57:53 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 24 Jun 2021 22:57:51 -0700 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.18 via Frontend Transport; Thu, 24 Jun 2021 22:57:51 -0700 Received: from HY-LT1002.marvell.com (HY-LT1002.marvell.com [10.28.176.218]) by maili.marvell.com (Postfix) with ESMTP id B61643F7041; Thu, 24 Jun 2021 22:57:48 -0700 (PDT) From: Anoob Joseph To: Akhil Goyal , Thomas Monjalon CC: Archana Muniganti , Jerin Jacob , Ankur Dwivedi , Tejasree Kondoj , , Anoob Joseph Date: Fri, 25 Jun 2021 11:26:21 +0530 Message-ID: <1624600591-29841-11-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1624600591-29841-1-git-send-email-anoobj@marvell.com> References: <1624600591-29841-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: fs3a2p5T8rXtTYIn8hb0ian3L9oIADv2 X-Proofpoint-ORIG-GUID: fs3a2p5T8rXtTYIn8hb0ian3L9oIADv2 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-25_02:2021-06-24, 2021-06-25 signatures=0 Subject: [dpdk-dev] [PATCH v2 10/20] crypto/cnxk: add aead operation in session 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 Sender: "dev" From: Archana Muniganti Add support for AEAD operations in session. Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Archana Muniganti Signed-off-by: Tejasree Kondoj --- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 3 ++ drivers/crypto/cnxk/cnxk_se.h | 64 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c index f2319df..acb9f1f 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c @@ -466,6 +466,9 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id, else ret = fill_sess_auth(xform, sess_priv); break; + case CNXK_CPT_AEAD: + ret = fill_sess_aead(xform, sess_priv); + break; default: ret = -1; } diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index 6e4b032..57bbd70 100644 --- a/drivers/crypto/cnxk/cnxk_se.h +++ b/drivers/crypto/cnxk/cnxk_se.h @@ -69,6 +69,70 @@ cpt_mac_len_verify(struct rte_crypto_auth_xform *auth) return ret; } +static __rte_always_inline int +fill_sess_aead(struct rte_crypto_sym_xform *xform, struct cnxk_se_sess *sess) +{ + struct rte_crypto_aead_xform *aead_form; + roc_se_cipher_type enc_type = 0; /* NULL Cipher type */ + roc_se_auth_type auth_type = 0; /* NULL Auth type */ + uint32_t cipher_key_len = 0; + uint8_t aes_gcm = 0; + aead_form = &xform->aead; + + if (aead_form->op == RTE_CRYPTO_AEAD_OP_ENCRYPT) { + sess->cpt_op |= ROC_SE_OP_CIPHER_ENCRYPT; + sess->cpt_op |= ROC_SE_OP_AUTH_GENERATE; + } else if (aead_form->op == RTE_CRYPTO_AEAD_OP_DECRYPT) { + sess->cpt_op |= ROC_SE_OP_CIPHER_DECRYPT; + sess->cpt_op |= ROC_SE_OP_AUTH_VERIFY; + } else { + plt_dp_err("Unknown aead operation\n"); + return -1; + } + switch (aead_form->algo) { + case RTE_CRYPTO_AEAD_AES_GCM: + enc_type = ROC_SE_AES_GCM; + cipher_key_len = 16; + aes_gcm = 1; + break; + case RTE_CRYPTO_AEAD_AES_CCM: + plt_dp_err("Crypto: Unsupported cipher algo %u", + aead_form->algo); + return -1; + case RTE_CRYPTO_AEAD_CHACHA20_POLY1305: + enc_type = ROC_SE_CHACHA20; + auth_type = ROC_SE_POLY1305; + cipher_key_len = 32; + sess->chacha_poly = 1; + break; + default: + plt_dp_err("Crypto: Undefined cipher algo %u specified", + aead_form->algo); + return -1; + } + if (aead_form->key.length < cipher_key_len) { + plt_dp_err("Invalid cipher params keylen %u", + aead_form->key.length); + return -1; + } + sess->zsk_flag = 0; + sess->aes_gcm = aes_gcm; + sess->mac_len = aead_form->digest_length; + sess->iv_offset = aead_form->iv.offset; + sess->iv_length = aead_form->iv.length; + sess->aad_length = aead_form->aad_length; + + if (unlikely(roc_se_ciph_key_set(&sess->roc_se_ctx, enc_type, + aead_form->key.data, + aead_form->key.length, NULL))) + return -1; + + if (unlikely(roc_se_auth_key_set(&sess->roc_se_ctx, auth_type, NULL, 0, + aead_form->digest_length))) + return -1; + + return 0; +} static __rte_always_inline int fill_sess_cipher(struct rte_crypto_sym_xform *xform, struct cnxk_se_sess *sess) -- 2.7.4