From: Eric Biggers <ebiggers@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
x86@kernel.org, Zhihang Shao <zhihang.shao.iscas@gmail.com>,
Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH 02/11] lib/crc-t10dif: add support for arch overrides
Date: Sat, 16 Nov 2024 16:22:35 -0800 [thread overview]
Message-ID: <20241117002244.105200-3-ebiggers@kernel.org> (raw)
In-Reply-To: <20241117002244.105200-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
Following what was done for CRC32, add support for architecture-specific
override of the CRC-T10DIF library. This will allow the CRC-T10DIF
library functions to access architecture-optimized code directly.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
include/linux/crc-t10dif.h | 12 ++++++++++++
lib/Kconfig | 32 ++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/include/linux/crc-t10dif.h b/include/linux/crc-t10dif.h
index 206ba2305483..16787c1cee21 100644
--- a/include/linux/crc-t10dif.h
+++ b/include/linux/crc-t10dif.h
@@ -5,18 +5,30 @@
#include <linux/types.h>
#define CRC_T10DIF_DIGEST_SIZE 2
#define CRC_T10DIF_BLOCK_SIZE 1
+u16 crc_t10dif_arch(u16 crc, const u8 *p, size_t len);
u16 crc_t10dif_generic(u16 crc, const u8 *p, size_t len);
static inline u16 crc_t10dif_update(u16 crc, const u8 *p, size_t len)
{
+ if (IS_ENABLED(CONFIG_CRC_T10DIF_ARCH))
+ return crc_t10dif_arch(crc, p, len);
return crc_t10dif_generic(crc, p, len);
}
static inline u16 crc_t10dif(const u8 *p, size_t len)
{
return crc_t10dif_update(0, p, len);
}
+#if IS_ENABLED(CONFIG_CRC_T10DIF_ARCH)
+bool crc_t10dif_is_optimized(void);
+#else
+static inline bool crc_t10dif_is_optimized(void)
+{
+ return false;
+}
+#endif
+
#endif
diff --git a/lib/Kconfig b/lib/Kconfig
index eb6c7a023be9..b84aa06ade30 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -147,10 +147,42 @@ config CRC_T10DIF
help
This option is only needed if a module that's not in the
kernel tree needs to calculate CRC checks for use with the
SCSI data integrity subsystem.
+config ARCH_HAS_CRC_T10DIF
+ bool
+
+choice
+ prompt "CRC-T10DIF implementation"
+ depends on CRC_T10DIF
+ default CRC_T10DIF_IMPL_ARCH if ARCH_HAS_CRC_T10DIF
+ default CRC_T10DIF_IMPL_GENERIC if !ARCH_HAS_CRC_T10DIF
+ help
+ This option allows you to override the default choice of CRC-T10DIF
+ implementation.
+
+config CRC_T10DIF_IMPL_ARCH
+ bool "Architecture-optimized" if ARCH_HAS_CRC_T10DIF
+ help
+ Use the optimized implementation of CRC-T10DIF for the selected
+ architecture. It is recommended to keep this enabled, as it can
+ greatly improve CRC-T10DIF performance.
+
+config CRC_T10DIF_IMPL_GENERIC
+ bool "Generic implementation"
+ help
+ Use the generic table-based implementation of CRC-T10DIF. Selecting
+ this will reduce code size slightly but can greatly reduce CRC-T10DIF
+ performance.
+
+endchoice
+
+config CRC_T10DIF_ARCH
+ tristate
+ default CRC_T10DIF if CRC_T10DIF_IMPL_ARCH
+
config CRC64_ROCKSOFT
tristate "CRC calculation for the Rocksoft model CRC64"
select CRC64
select CRYPTO
select CRYPTO_CRC64_ROCKSOFT
--
2.47.0
next prev parent reply other threads:[~2024-11-17 0:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-17 0:22 [PATCH 00/11] Wire up CRC-T10DIF library functions to arch-optimized code Eric Biggers
2024-11-17 0:22 ` [PATCH 01/11] lib/crc-t10dif: stop wrapping the crypto API Eric Biggers
2024-11-17 0:22 ` Eric Biggers [this message]
2024-11-17 0:22 ` [PATCH 03/11] crypto: crct10dif - expose arch-optimized lib function Eric Biggers
2024-11-17 0:22 ` [PATCH 04/11] x86/crc-t10dif: expose CRC-T10DIF function through lib Eric Biggers
2024-11-17 0:22 ` [PATCH 05/11] arm/crc-t10dif: " Eric Biggers
2024-11-17 0:22 ` [PATCH 06/11] arm64/crc-t10dif: " Eric Biggers
2024-11-17 0:22 ` [PATCH 07/11] powerpc/crc-t10dif: " Eric Biggers
2024-11-17 0:22 ` [PATCH 08/11] lib/crc_kunit.c: add KUnit test suite for CRC library functions Eric Biggers
2024-11-17 0:22 ` [PATCH 09/11] lib/crc32test: delete obsolete crc32test.c Eric Biggers
2024-11-17 0:22 ` [PATCH 10/11] powerpc/crc: delete obsolete crc-vpmsum_test.c Eric Biggers
2024-11-17 0:22 ` [PATCH 11/11] MAINTAINERS: add entry for CRC library Eric Biggers
2024-11-19 1:33 ` [PATCH 00/11] Wire up CRC-T10DIF library functions to arch-optimized code Martin K. Petersen
2024-11-19 8:59 ` Ard Biesheuvel
2024-11-19 17:46 ` Eric Biggers
2024-11-19 10:05 ` Zhihang Shao
2024-11-19 17:53 ` Eric Biggers
2024-11-19 10:29 ` Zhihang Shao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241117002244.105200-3-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=ardb@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=x86@kernel.org \
--cc=zhihang.shao.iscas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.