From patchwork Tue Dec 20 14:32:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejasree Kondoj X-Patchwork-Id: 121086 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 E7550A0545; Tue, 20 Dec 2022 15:34:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 94A1342D56; Tue, 20 Dec 2022 15:33:13 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 734F642D47 for ; Tue, 20 Dec 2022 15:33:12 +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 2BKEOVhI019007 for ; Tue, 20 Dec 2022 06:33:11 -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=W1LY99sygzDd49+Vbeqe2mXOauUw7TCBGZWva1zjg88=; b=Eg97wOuDOC9kYNk4BGzzbvyos1bPGMgbgYLTEilKIrZ+dkJSdF0D5ZBYWo5NbAhEcGfN 71j0N59BNGRC2P52tukH++BxUaNZ1GilebfVQIPhqpKnqc/ZBRQmuN8qY+Hrhs+1LPJE 3NlbCDlUQVuLA7bPG+JnTTtnth+Z12EhbbV7zNkHoSv26CB8l7UpyyIIuI79A0E9LOm6 jL2onJXEg7w3dPpQlYuVWoSizDPj+k4kMwfBb9BoRKW+3XN2TnZ9iWZU9TPUCTJYC0Vn wVGSOjKQk1v3RXpNcNQc8zS8y63rCKg3h+JzoiNmo1O+FRIWTB3ABhQIGyHUNBPlYtNi EQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3mhe5rnb5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Dec 2022 06:33:11 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) 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:09 -0800 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.42 via Frontend Transport; Tue, 20 Dec 2022 06:33:09 -0800 Received: from hyd1554.marvell.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id 223F53F7070; Tue, 20 Dec 2022 06:33:06 -0800 (PST) From: Tejasree Kondoj To: Akhil Goyal CC: Anoob Joseph , Vidya Sagar Velumuri , Gowrishankar Muthukrishnan , Volodymyr Fialko , "Aakash Sasidharan" , Subject: [PATCH 12/17] crypto/octeontx: support truncated digest size Date: Tue, 20 Dec 2022 20:02:27 +0530 Message-ID: <20221220143232.2519650-13-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: JTI9hHhDCJYnf_GQbllPfrAr64HQgHoo X-Proofpoint-ORIG-GUID: JTI9hHhDCJYnf_GQbllPfrAr64HQgHoo 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 Support truncated digest size for auth only mode. Signed-off-by: Tejasree Kondoj --- drivers/common/cpt/cpt_ucode.h | 17 ++++--- .../octeontx/otx_cryptodev_capabilities.c | 48 +++++++++---------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index 22aabab6ac..b393be4cf6 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -41,30 +41,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; @@ -523,7 +526,7 @@ cpt_digest_gen_prep(uint32_t flags, /*GP op header */ vq_cmd_w0.s.opcode.minor = 0; - vq_cmd_w0.s.param2 = ((uint16_t)hash_type << 8); + vq_cmd_w0.s.param2 = ((uint16_t)hash_type << 8) | mac_len; if (ctx->hmac) { vq_cmd_w0.s.opcode.major = CPT_MAJOR_OP_HMAC | CPT_DMA_MODE; vq_cmd_w0.s.param1 = key_len; diff --git a/drivers/crypto/octeontx/otx_cryptodev_capabilities.c b/drivers/crypto/octeontx/otx_cryptodev_capabilities.c index 3f734b232c..80a9fe2123 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_capabilities.c +++ b/drivers/crypto/octeontx/otx_cryptodev_capabilities.c @@ -86,9 +86,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 0 }, .digest_size = { - .min = 16, + .min = 1, .max = 16, - .increment = 0 + .increment = 1 }, }, } }, } @@ -106,9 +106,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 8 }, .digest_size = { - .min = 16, + .min = 1, .max = 16, - .increment = 0 + .increment = 1 }, }, } }, } @@ -126,9 +126,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 0 }, .digest_size = { - .min = 20, + .min = 1, .max = 20, - .increment = 0 + .increment = 1 }, }, } }, } @@ -146,9 +146,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 1 }, .digest_size = { - .min = 20, + .min = 1, .max = 20, - .increment = 0 + .increment = 1 }, }, } }, } @@ -166,9 +166,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 0 }, .digest_size = { - .min = 28, + .min = 1, .max = 28, - .increment = 0 + .increment = 1 }, }, } }, } @@ -186,9 +186,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 1 }, .digest_size = { - .min = 28, + .min = 1, .max = 28, - .increment = 0 + .increment = 1 }, }, } }, } @@ -206,9 +206,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 0 }, .digest_size = { - .min = 32, + .min = 1, .max = 32, - .increment = 0 + .increment = 1 }, }, } }, } @@ -226,9 +226,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 1 }, .digest_size = { - .min = 32, + .min = 1, .max = 32, - .increment = 0 + .increment = 1 }, }, } }, } @@ -246,9 +246,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 0 }, .digest_size = { - .min = 48, + .min = 1, .max = 48, - .increment = 0 + .increment = 1 }, }, } }, } @@ -266,9 +266,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 1 }, .digest_size = { - .min = 48, + .min = 1, .max = 48, - .increment = 0 + .increment = 1 }, }, } }, } @@ -286,9 +286,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 0 }, .digest_size = { - .min = 64, + .min = 1, .max = 64, - .increment = 0 + .increment = 1 }, }, } }, } @@ -306,9 +306,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .increment = 1 }, .digest_size = { - .min = 64, + .min = 1, .max = 64, - .increment = 0 + .increment = 1 }, }, } }, }