From patchwork Tue Dec 20 14:32:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejasree Kondoj X-Patchwork-Id: 121079 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 BCD1EA0545; Tue, 20 Dec 2022 15:33:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A83D542D29; Tue, 20 Dec 2022 15:32:54 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 1E60042D29 for ; Tue, 20 Dec 2022 15:32:53 +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 2BKEOPTL018983 for ; Tue, 20 Dec 2022 06:32:52 -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=dpRwqrMVDbpvPS+whSmo6Abyt17fjULTTPK5XJaZL3o=; b=iZOS7rbQUK7p1ySFPRLZvjaCWc91kI2S9L/2E0TTSVtXvTNEhJySU8kQ8P9YJzPORrnR keITX9uXJe9G+OyjT3NBiLPe4rz+YPglpwcODZe4MUeEQPVnp6oLxrt/1hk7P1EVf+rV 1avej4ioCG27iDsK9bwG9QDvADtd4icTrO+6QGFpnP4z8J5zgQ3XSZIoKHF4A+h8eq/C YytWA2CEFAsnv4EU6tfeZGfpjbskGU0IZogcfjdsXlSiO7KWqanYzr9OsLiD6MVcfk2L mD4q6nhXh7T9BBrL5VFUtqgC+Im4WhtD4OuZL9X+UiWHL2JbpUyL2J/mHQIqMUx+4pAK 6w== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3mhe5rnb5b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Dec 2022 06:32:52 -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:50 -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:50 -0800 Received: from hyd1554.marvell.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id D5D7B3F704C; Tue, 20 Dec 2022 06:32:47 -0800 (PST) From: Tejasree Kondoj To: Akhil Goyal CC: Anoob Joseph , Vidya Sagar Velumuri , Gowrishankar Muthukrishnan , Volodymyr Fialko , "Aakash Sasidharan" , Subject: [PATCH 05/17] crypto/cnxk: support truncated digest length Date: Tue, 20 Dec 2022 20:02:20 +0530 Message-ID: <20221220143232.2519650-6-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: UdstAe4pVNvZOcQT5BHu84Yl7tLC8yZg X-Proofpoint-ORIG-GUID: UdstAe4pVNvZOcQT5BHu84Yl7tLC8yZg 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 Adding truncated digest length support. Signed-off-by: Tejasree Kondoj --- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 48 +++++++++---------- drivers/crypto/cnxk/cnxk_se.h | 19 ++++---- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c index 6c28f8942e..9dfbf875ec 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c @@ -108,9 +108,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 0 }, .digest_size = { - .min = 20, + .min = 1, .max = 20, - .increment = 0 + .increment = 1 }, }, } }, } @@ -128,9 +128,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 1 }, .digest_size = { - .min = 12, + .min = 1, .max = 20, - .increment = 8 + .increment = 1 }, }, } }, } @@ -148,9 +148,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 0 }, .digest_size = { - .min = 28, + .min = 1, .max = 28, - .increment = 0 + .increment = 1 }, }, } }, } @@ -168,9 +168,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 1 }, .digest_size = { - .min = 28, + .min = 1, .max = 28, - .increment = 0 + .increment = 1 }, }, } }, } @@ -188,9 +188,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 0 }, .digest_size = { - .min = 32, + .min = 1, .max = 32, - .increment = 0 + .increment = 1 }, }, } }, } @@ -208,9 +208,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 1 }, .digest_size = { - .min = 16, + .min = 1, .max = 32, - .increment = 16 + .increment = 1 }, }, } }, } @@ -228,9 +228,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 0 }, .digest_size = { - .min = 48, + .min = 1, .max = 48, - .increment = 0 + .increment = 1 }, }, } }, } @@ -248,9 +248,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 1 }, .digest_size = { - .min = 24, + .min = 1, .max = 48, - .increment = 24 + .increment = 1 }, }, } }, } @@ -268,9 +268,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 0 }, .digest_size = { - .min = 64, + .min = 1, .max = 64, - .increment = 0 + .increment = 1 }, }, } }, } @@ -288,9 +288,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 1 }, .digest_size = { - .min = 32, + .min = 1, .max = 64, - .increment = 32 + .increment = 1 }, }, } }, } @@ -308,9 +308,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 0 }, .digest_size = { - .min = 16, + .min = 1, .max = 16, - .increment = 0 + .increment = 1 }, }, } }, } @@ -328,9 +328,9 @@ static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = { .increment = 8 }, .digest_size = { - .min = 12, + .min = 1, .max = 16, - .increment = 4 + .increment = 1 }, }, } }, } diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index b07fc22858..ce4c2bb585 100644 --- a/drivers/crypto/cnxk/cnxk_se.h +++ b/drivers/crypto/cnxk/cnxk_se.h @@ -148,30 +148,33 @@ cpt_mac_len_verify(struct rte_crypto_auth_xform *auth) uint16_t mac_len = auth->digest_length; int ret; + if ((auth->algo != RTE_CRYPTO_AUTH_NULL) && (mac_len == 0)) + return -1; + switch (auth->algo) { case RTE_CRYPTO_AUTH_MD5: case RTE_CRYPTO_AUTH_MD5_HMAC: - ret = (mac_len == 16) ? 0 : -1; + ret = (mac_len <= 16) ? 0 : -1; break; case RTE_CRYPTO_AUTH_SHA1: case RTE_CRYPTO_AUTH_SHA1_HMAC: - ret = (mac_len == 20) ? 0 : -1; + ret = (mac_len <= 20) ? 0 : -1; break; case RTE_CRYPTO_AUTH_SHA224: case RTE_CRYPTO_AUTH_SHA224_HMAC: - ret = (mac_len == 28) ? 0 : -1; + ret = (mac_len <= 28) ? 0 : -1; break; case RTE_CRYPTO_AUTH_SHA256: case RTE_CRYPTO_AUTH_SHA256_HMAC: - ret = (mac_len == 32) ? 0 : -1; + ret = (mac_len <= 32) ? 0 : -1; break; case RTE_CRYPTO_AUTH_SHA384: case RTE_CRYPTO_AUTH_SHA384_HMAC: - ret = (mac_len == 48) ? 0 : -1; + ret = (mac_len <= 48) ? 0 : -1; break; case RTE_CRYPTO_AUTH_SHA512: case RTE_CRYPTO_AUTH_SHA512_HMAC: - ret = (mac_len == 64) ? 0 : -1; + ret = (mac_len <= 64) ? 0 : -1; break; case RTE_CRYPTO_AUTH_NULL: ret = 0; @@ -838,7 +841,7 @@ cpt_digest_gen_sg_ver1_prep(uint32_t flags, uint64_t d_lens, struct roc_se_fc_pa /*GP op header */ cpt_inst_w4.s.opcode_minor = 0; - cpt_inst_w4.s.param2 = ((uint16_t)hash_type << 8); + cpt_inst_w4.s.param2 = ((uint16_t)hash_type << 8) | mac_len; if (ctx->hmac) { cpt_inst_w4.s.opcode_major = ROC_SE_MAJOR_OP_HMAC | ROC_SE_DMA_MODE; @@ -969,7 +972,7 @@ cpt_digest_gen_sg_ver2_prep(uint32_t flags, uint64_t d_lens, struct roc_se_fc_pa /*GP op header */ cpt_inst_w4.s.opcode_minor = 0; - cpt_inst_w4.s.param2 = ((uint16_t)hash_type << 8); + cpt_inst_w4.s.param2 = ((uint16_t)hash_type << 8) | mac_len; if (ctx->hmac) { cpt_inst_w4.s.opcode_major = ROC_SE_MAJOR_OP_HMAC; cpt_inst_w4.s.param1 = key_len;