From patchwork Tue Dec 20 14:32:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejasree Kondoj X-Patchwork-Id: 121085 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 074E1A0545; Tue, 20 Dec 2022 15:34:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 74B7B42D4D; Tue, 20 Dec 2022 15:33:10 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A552C42D47 for ; Tue, 20 Dec 2022 15:33:09 +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 2BKEN2CW016597 for ; Tue, 20 Dec 2022 06:33:09 -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=DFognEOZ37pLd91l+YgjfTEyIJ/KAyVs0g59TIEcNSs=; b=KcsHrBRpiJBj9I+vm395MO0oty+1QEnmPtnRteJk6ftFMVIV2Wc7SV7XeRjOAybAQzLI kWdlSKV8pg15mYGdQUy+WYNBH2m8AxjVUQdYD4JK/cOKLpWg7pSQZ0LjyfeujUnMXxrx K9NYvg8kOmxwB3qPNOpd91GoDTs6Z0sW7goEe5capAhn2XbzUxYliqjD5gA8x7f+l5p9 UtG1UyzZP8pu+art5o3ZlE8kYWPS1Vo1sNxZot/j0UrqnJ9AX/2PMeqRcdL1BIHDx+Si 70Oo3VQ8yhraWrIsoZUcS2R1pJA7GG3N8sKJtIddGmq67f4KquqlAp3NW4ESDA1SMqOx fw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3mhe5rnb5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Dec 2022 06:33:08 -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:33:06 -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:33:06 -0800 Received: from hyd1554.marvell.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id 73FE43F7063; Tue, 20 Dec 2022 06:33:04 -0800 (PST) From: Tejasree Kondoj To: Akhil Goyal CC: Volodymyr Fialko , Anoob Joseph , Vidya Sagar Velumuri , Gowrishankar Muthukrishnan , Aakash Sasidharan , Subject: [PATCH 11/17] common/cnxk: skip hmac hash precomputation Date: Tue, 20 Dec 2022 20:02:26 +0530 Message-ID: <20221220143232.2519650-12-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: pul0wjJlbcRBhTL-b8YoVfuXZOSYcf2R X-Proofpoint-ORIG-GUID: pul0wjJlbcRBhTL-b8YoVfuXZOSYcf2R 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: Volodymyr Fialko Operations with FC opcode requires precomputed ipad and opad hashes, but for auth only (HMAC opcode) this is not required, thus could be skipped. Signed-off-by: Volodymyr Fialko --- drivers/common/cnxk/roc_se.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/common/cnxk/roc_se.c b/drivers/common/cnxk/roc_se.c index 22df61f5f0..aba7f9416d 100644 --- a/drivers/common/cnxk/roc_se.c +++ b/drivers/common/cnxk/roc_se.c @@ -308,6 +308,7 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, struct roc_se_context *fctx; uint8_t opcode_minor; uint8_t pdcp_alg; + bool chained_op; int ret; if (se_ctx == NULL) @@ -318,12 +319,12 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, k_ctx = &se_ctx->se_ctx.k_ctx; fctx = &se_ctx->se_ctx.fctx; + chained_op = se_ctx->ciph_then_auth || se_ctx->auth_then_ciph; + if ((type >= ROC_SE_ZUC_EIA3) && (type <= ROC_SE_KASUMI_F9_ECB)) { uint8_t *zuc_const; uint32_t keyx[4]; uint8_t *ci_key; - bool chained_op = - se_ctx->ciph_then_auth || se_ctx->auth_then_ciph; if (!key_len) return -1; @@ -470,19 +471,25 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, se_ctx->mac_len = mac_len; if (key_len) { - se_ctx->hmac = 1; - - se_ctx->auth_key = plt_zmalloc(key_len, 8); - if (se_ctx->auth_key == NULL) - return -1; + /* + * Chained operation (FC opcode) requires precomputed ipad and opad hashes, but for + * auth only (HMAC opcode) this is not required + */ + if (chained_op) { + memset(fctx->hmac.ipad, 0, sizeof(fctx->hmac.ipad)); + memset(fctx->hmac.opad, 0, sizeof(fctx->hmac.opad)); + cpt_hmac_opad_ipad_gen(type, key, key_len, &fctx->hmac); + fctx->enc.auth_input_type = 0; + } else { + se_ctx->hmac = 1; - memcpy(se_ctx->auth_key, key, key_len); - se_ctx->auth_key_len = key_len; - memset(fctx->hmac.ipad, 0, sizeof(fctx->hmac.ipad)); - memset(fctx->hmac.opad, 0, sizeof(fctx->hmac.opad)); + se_ctx->auth_key = plt_zmalloc(key_len, 8); + if (se_ctx->auth_key == NULL) + return -1; - cpt_hmac_opad_ipad_gen(type, key, key_len, &fctx->hmac); - fctx->enc.auth_input_type = 0; + memcpy(se_ctx->auth_key, key, key_len); + se_ctx->auth_key_len = key_len; + } } return 0; }