From patchwork Mon Jan 27 19:33:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andre Muezerie X-Patchwork-Id: 150553 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 019E04613B; Mon, 27 Jan 2025 20:33:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2622D40B8D; Mon, 27 Jan 2025 20:33:19 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 29A354028F; Mon, 27 Jan 2025 20:33:18 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 51CC12037164; Mon, 27 Jan 2025 11:33:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 51CC12037164 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738006397; bh=BMU3VR41cMaPgPDtQKo5r6E4gy9BFqITsGxwlz26r4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wf9yEOAA6w2esvo52aCqDjwRVB07UrgNbiP84meKMslJTb2LkGgnNh3tBVIK2bNiS 5G09elvuIBHsmtUZgMkEN9HR1TQ14orHHAMxh1qtlqz+5QCd9uJB4oSW3XgsokjWSB 6Vi/zKqoBQ9V5P8GbU81ytPMKZjtFUgWchmLsllA= From: Andre Muezerie To: andremue@linux.microsoft.com Cc: dev@dpdk.org, fanzhang.oss@gmail.com, gakhil@marvell.com, mb@smartsharesystems.com, stable@dpdk.org Subject: [PATCH v3 1/3] lib/cryptodev: avoid implicit conversion to 64 bit number Date: Mon, 27 Jan 2025 11:33:07 -0800 Message-Id: <1738006389-17193-1-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> MIME-Version: 1.0 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 MSVC issues the warning below: ../lib/cryptodev/rte_cryptodev.c(623): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) The code would be better off by using 64 bit numbers to begin with. That eliminates the need for a conversion to 64 bits later. This patch actually fixes a bug present in previous DPDK versions because the last of the hash enums RTE_CRYPTO_AUTH_SM3_HMAC in rte_crypto_auth_algorithm has value 32. Fixes: 6f8ef8b68edb ("cryptodev: add hash algorithms in asymmetric capability") Cc: stable@dpdk.org Signed-off-by: Andre Muezerie Acked-by: Akhil Goyal Reviewed-by: Morten Brørup --- lib/cryptodev/rte_cryptodev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 85a4b46ac9..a49b0662f3 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -620,7 +620,7 @@ rte_cryptodev_asym_xform_capability_check_hash( { bool ret = false; - if (capability->hash_algos & (1 << hash)) + if (capability->hash_algos & RTE_BIT64(hash)) ret = true; rte_cryptodev_trace_asym_xform_capability_check_hash( From patchwork Mon Jan 27 19:33:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andre Muezerie X-Patchwork-Id: 150554 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 272C24613B; Mon, 27 Jan 2025 20:33:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C62B40B9A; Mon, 27 Jan 2025 20:33:20 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 3F08240A72 for ; Mon, 27 Jan 2025 20:33:18 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 5FBAC2037169; Mon, 27 Jan 2025 11:33:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5FBAC2037169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738006397; bh=I4QUXro6OvpR//vJkNvDVRpdATmGstYR3LVYmdmgiPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OsiTk0/heiiBEKiapjeXYGOaPrj9/myOEyzhmyCPrV2FfOECB30EGf3ueIA1izWpM GIWULpqftfB66mDMCnIKVhrLE8fQkFkHnn44bEQMHyiaAb/4GyPqMjkUm0ihYr0dCU dR7mIQAdayiAeWgIRAJNokYgJXep3gM1w6YsNOe0= From: Andre Muezerie To: andremue@linux.microsoft.com Cc: dev@dpdk.org, fanzhang.oss@gmail.com, gakhil@marvell.com, mb@smartsharesystems.com Subject: [PATCH v3 2/3] lib/hash: avoid implicit conversion to 64 bit number Date: Mon, 27 Jan 2025 11:33:08 -0800 Message-Id: <1738006389-17193-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1738006389-17193-1-git-send-email-andremue@linux.microsoft.com> References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> <1738006389-17193-1-git-send-email-andremue@linux.microsoft.com> MIME-Version: 1.0 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 MSVC issues the warnings below: 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) The code would be better off by using 64 bit numbers to begin with. That eliminates the need for a conversion to 64 bits later. 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) Instead of multiplying sizeof(uint32_t) by the result of shifting "1", sizeof(uint32_t) can be shifted directly. Signed-off-by: Andre Muezerie Acked-by: Vladimir Medvedkin Acked-by: Bruce Richardson Reviewed-by: Morten Brørup --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 336c228e64..429b895d6c 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, offset; ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) + - sizeof(uint32_t) * (1 << ctx->reta_sz_log), + (sizeof(uint32_t) << ctx->reta_sz_log), RTE_CACHE_LINE_SIZE); if (ent == NULL) return -ENOMEM; diff --git a/lib/hash/rte_thash_gf2_poly_math.c b/lib/hash/rte_thash_gf2_poly_math.c index 1c62974e71..a28f2495a5 100644 --- a/lib/hash/rte_thash_gf2_poly_math.c +++ b/lib/hash/rte_thash_gf2_poly_math.c @@ -118,16 +118,16 @@ static uint32_t gf2_mul(uint32_t a, uint32_t b, uint32_t r, int degree) { uint64_t product = 0; - uint64_t r_poly = r|(1ULL << degree); + uint64_t r_poly = r | RTE_BIT64(degree); for (; b; b &= (b - 1)) product ^= (uint64_t)a << (rte_bsf32(b)); for (int i = degree * 2 - 1; i >= degree; i--) - if (product & (1 << i)) + if (product & RTE_BIT64(i)) product ^= r_poly << (i - degree); - return product; + return (uint32_t)product; } static uint32_t From patchwork Mon Jan 27 19:33:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andre Muezerie X-Patchwork-Id: 150555 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 ED1944613B; Mon, 27 Jan 2025 20:33:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5663E40BA0; Mon, 27 Jan 2025 20:33:21 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4287140A89 for ; Mon, 27 Jan 2025 20:33:18 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 6C16B203716A; Mon, 27 Jan 2025 11:33:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6C16B203716A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738006397; bh=xW9qlGemEiAhpqWPMnfjLwnBLlb4/AKZ+PFYZxmjUQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fNzx9VNwYmU/8RW7GErpGroF0fKHvsEGbTWXTegLfZ4DJKDEoNc9I68RYng2TeyXS ihWMRfxM5RWer6RzYmKDJSch2Asje3nEzHnxoWzK2D0inZtgZkON2CMLepVg8u5YHE aWdtrlVoi/2IQyZ5rmGjD6RThS9NbpNG51BUTW1g= From: Andre Muezerie To: andremue@linux.microsoft.com Cc: dev@dpdk.org, fanzhang.oss@gmail.com, gakhil@marvell.com, mb@smartsharesystems.com Subject: [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos Date: Mon, 27 Jan 2025 11:33:09 -0800 Message-Id: <1738006389-17193-3-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1738006389-17193-1-git-send-email-andremue@linux.microsoft.com> References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> <1738006389-17193-1-git-send-email-andremue@linux.microsoft.com> 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 This was found during code review of similar issues. Signed-off-by: Andre Muezerie Reviewed-by: Morten Brørup Acked-by: Anoob Joseph --- drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 4 ++-- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c index 4394513002..e78bc37c37 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c @@ -1207,8 +1207,8 @@ static const struct rte_cryptodev_capabilities caps_eddsa[] = { {.asym = { .xform_capa = { .xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA, - .hash_algos = (1 << RTE_CRYPTO_AUTH_SHA512 | - 1 << RTE_CRYPTO_AUTH_SHAKE_256), + .hash_algos = (RTE_BIT64(RTE_CRYPTO_AUTH_SHA512) | + RTE_BIT64(RTE_CRYPTO_AUTH_SHAKE_256)), .op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) | (1 << RTE_CRYPTO_ASYM_OP_VERIFY)) } diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 18f096abfd..04e018f3df 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -630,8 +630,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = { {.asym = { .xform_capa = { .xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA, - .hash_algos = (1 << RTE_CRYPTO_AUTH_SHA512 | - 1 << RTE_CRYPTO_AUTH_SHAKE_256), + .hash_algos = (RTE_BIT64(RTE_CRYPTO_AUTH_SHA512) | + RTE_BIT64(RTE_CRYPTO_AUTH_SHAKE_256)), .op_types = ((1<