]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
powerpc/crc: drop "glue" from filenames
authorEric Biggers <ebiggers@google.com>
Thu, 24 Apr 2025 00:20:34 +0000 (17:20 -0700)
committerEric Biggers <ebiggers@google.com>
Mon, 28 Apr 2025 16:07:19 +0000 (09:07 -0700)
The use of the term "glue" in filenames is a Crypto API-ism that rarely
shows up elsewhere in lib/ or arch/*/lib/.  I think adopting it there
was a mistake.  The library just uses standard functions, so the amount
of code that could be considered "glue" is quite small.  And while often
the C functions just wrap the assembly functions, there are also cases
like crc32c_arch() in arch/x86/lib/crc32-glue.c that blur the line by
in-lining the actual implementation into the C function.  That's not
"glue code", but rather the actual code.

Therefore, let's drop "glue" from the filenames and instead use e.g.
crc32.c instead of crc32-glue.c.

Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250424002038.179114-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
arch/powerpc/lib/Makefile
arch/powerpc/lib/crc-t10dif-glue.c [deleted file]
arch/powerpc/lib/crc-t10dif.c [new file with mode: 0644]
arch/powerpc/lib/crc32-glue.c [deleted file]
arch/powerpc/lib/crc32.c [new file with mode: 0644]

index dd8a4b52a0ccb34b9f8f6b9c456f6fa805f95779..27f8a01438603d1aee42e2f6786054bf60404696 100644 (file)
@@ -79,9 +79,9 @@ CFLAGS_xor_vmx.o += -mhard-float -maltivec $(call cc-option,-mabi=altivec)
 CFLAGS_xor_vmx.o += -isystem $(shell $(CC) -print-file-name=include)
 
 obj-$(CONFIG_CRC32_ARCH) += crc32-powerpc.o
-crc32-powerpc-y := crc32-glue.o crc32c-vpmsum_asm.o
+crc32-powerpc-y := crc32.o crc32c-vpmsum_asm.o
 
 obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-powerpc.o
-crc-t10dif-powerpc-y := crc-t10dif-glue.o crct10dif-vpmsum_asm.o
+crc-t10dif-powerpc-y := crc-t10dif.o crct10dif-vpmsum_asm.o
 
 obj-$(CONFIG_PPC64) += $(obj64-y)
diff --git a/arch/powerpc/lib/crc-t10dif-glue.c b/arch/powerpc/lib/crc-t10dif-glue.c
deleted file mode 100644 (file)
index ddd5c40..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Calculate a CRC T10-DIF with vpmsum acceleration
- *
- * Copyright 2017, Daniel Axtens, IBM Corporation.
- * [based on crc32c-vpmsum_glue.c]
- */
-
-#include <linux/crc-t10dif.h>
-#include <crypto/internal/simd.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/cpufeature.h>
-#include <asm/simd.h>
-#include <asm/switch_to.h>
-
-#define VMX_ALIGN              16
-#define VMX_ALIGN_MASK         (VMX_ALIGN-1)
-
-#define VECTOR_BREAKPOINT      64
-
-static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
-
-u32 __crct10dif_vpmsum(u32 crc, unsigned char const *p, size_t len);
-
-u16 crc_t10dif_arch(u16 crci, const u8 *p, size_t len)
-{
-       unsigned int prealign;
-       unsigned int tail;
-       u32 crc = crci;
-
-       if (len < (VECTOR_BREAKPOINT + VMX_ALIGN) ||
-           !static_branch_likely(&have_vec_crypto) || !crypto_simd_usable())
-               return crc_t10dif_generic(crc, p, len);
-
-       if ((unsigned long)p & VMX_ALIGN_MASK) {
-               prealign = VMX_ALIGN - ((unsigned long)p & VMX_ALIGN_MASK);
-               crc = crc_t10dif_generic(crc, p, prealign);
-               len -= prealign;
-               p += prealign;
-       }
-
-       if (len & ~VMX_ALIGN_MASK) {
-               crc <<= 16;
-               preempt_disable();
-               pagefault_disable();
-               enable_kernel_altivec();
-               crc = __crct10dif_vpmsum(crc, p, len & ~VMX_ALIGN_MASK);
-               disable_kernel_altivec();
-               pagefault_enable();
-               preempt_enable();
-               crc >>= 16;
-       }
-
-       tail = len & VMX_ALIGN_MASK;
-       if (tail) {
-               p += len & ~VMX_ALIGN_MASK;
-               crc = crc_t10dif_generic(crc, p, tail);
-       }
-
-       return crc & 0xffff;
-}
-EXPORT_SYMBOL(crc_t10dif_arch);
-
-static int __init crc_t10dif_powerpc_init(void)
-{
-       if (cpu_has_feature(CPU_FTR_ARCH_207S) &&
-           (cur_cpu_spec->cpu_user_features2 & PPC_FEATURE2_VEC_CRYPTO))
-               static_branch_enable(&have_vec_crypto);
-       return 0;
-}
-arch_initcall(crc_t10dif_powerpc_init);
-
-static void __exit crc_t10dif_powerpc_exit(void)
-{
-}
-module_exit(crc_t10dif_powerpc_exit);
-
-MODULE_AUTHOR("Daniel Axtens <dja@axtens.net>");
-MODULE_DESCRIPTION("CRCT10DIF using vector polynomial multiply-sum instructions");
-MODULE_LICENSE("GPL");
diff --git a/arch/powerpc/lib/crc-t10dif.c b/arch/powerpc/lib/crc-t10dif.c
new file mode 100644 (file)
index 0000000..ddd5c40
--- /dev/null
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Calculate a CRC T10-DIF with vpmsum acceleration
+ *
+ * Copyright 2017, Daniel Axtens, IBM Corporation.
+ * [based on crc32c-vpmsum_glue.c]
+ */
+
+#include <linux/crc-t10dif.h>
+#include <crypto/internal/simd.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/cpufeature.h>
+#include <asm/simd.h>
+#include <asm/switch_to.h>
+
+#define VMX_ALIGN              16
+#define VMX_ALIGN_MASK         (VMX_ALIGN-1)
+
+#define VECTOR_BREAKPOINT      64
+
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
+
+u32 __crct10dif_vpmsum(u32 crc, unsigned char const *p, size_t len);
+
+u16 crc_t10dif_arch(u16 crci, const u8 *p, size_t len)
+{
+       unsigned int prealign;
+       unsigned int tail;
+       u32 crc = crci;
+
+       if (len < (VECTOR_BREAKPOINT + VMX_ALIGN) ||
+           !static_branch_likely(&have_vec_crypto) || !crypto_simd_usable())
+               return crc_t10dif_generic(crc, p, len);
+
+       if ((unsigned long)p & VMX_ALIGN_MASK) {
+               prealign = VMX_ALIGN - ((unsigned long)p & VMX_ALIGN_MASK);
+               crc = crc_t10dif_generic(crc, p, prealign);
+               len -= prealign;
+               p += prealign;
+       }
+
+       if (len & ~VMX_ALIGN_MASK) {
+               crc <<= 16;
+               preempt_disable();
+               pagefault_disable();
+               enable_kernel_altivec();
+               crc = __crct10dif_vpmsum(crc, p, len & ~VMX_ALIGN_MASK);
+               disable_kernel_altivec();
+               pagefault_enable();
+               preempt_enable();
+               crc >>= 16;
+       }
+
+       tail = len & VMX_ALIGN_MASK;
+       if (tail) {
+               p += len & ~VMX_ALIGN_MASK;
+               crc = crc_t10dif_generic(crc, p, tail);
+       }
+
+       return crc & 0xffff;
+}
+EXPORT_SYMBOL(crc_t10dif_arch);
+
+static int __init crc_t10dif_powerpc_init(void)
+{
+       if (cpu_has_feature(CPU_FTR_ARCH_207S) &&
+           (cur_cpu_spec->cpu_user_features2 & PPC_FEATURE2_VEC_CRYPTO))
+               static_branch_enable(&have_vec_crypto);
+       return 0;
+}
+arch_initcall(crc_t10dif_powerpc_init);
+
+static void __exit crc_t10dif_powerpc_exit(void)
+{
+}
+module_exit(crc_t10dif_powerpc_exit);
+
+MODULE_AUTHOR("Daniel Axtens <dja@axtens.net>");
+MODULE_DESCRIPTION("CRCT10DIF using vector polynomial multiply-sum instructions");
+MODULE_LICENSE("GPL");
diff --git a/arch/powerpc/lib/crc32-glue.c b/arch/powerpc/lib/crc32-glue.c
deleted file mode 100644 (file)
index 42f2dd3..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-#include <linux/crc32.h>
-#include <crypto/internal/simd.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/cpufeature.h>
-#include <asm/simd.h>
-#include <asm/switch_to.h>
-
-#define VMX_ALIGN              16
-#define VMX_ALIGN_MASK         (VMX_ALIGN-1)
-
-#define VECTOR_BREAKPOINT      512
-
-static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
-
-u32 __crc32c_vpmsum(u32 crc, const u8 *p, size_t len);
-
-u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
-{
-       return crc32_le_base(crc, p, len);
-}
-EXPORT_SYMBOL(crc32_le_arch);
-
-u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
-{
-       unsigned int prealign;
-       unsigned int tail;
-
-       if (len < (VECTOR_BREAKPOINT + VMX_ALIGN) ||
-           !static_branch_likely(&have_vec_crypto) || !crypto_simd_usable())
-               return crc32c_base(crc, p, len);
-
-       if ((unsigned long)p & VMX_ALIGN_MASK) {
-               prealign = VMX_ALIGN - ((unsigned long)p & VMX_ALIGN_MASK);
-               crc = crc32c_base(crc, p, prealign);
-               len -= prealign;
-               p += prealign;
-       }
-
-       if (len & ~VMX_ALIGN_MASK) {
-               preempt_disable();
-               pagefault_disable();
-               enable_kernel_altivec();
-               crc = __crc32c_vpmsum(crc, p, len & ~VMX_ALIGN_MASK);
-               disable_kernel_altivec();
-               pagefault_enable();
-               preempt_enable();
-       }
-
-       tail = len & VMX_ALIGN_MASK;
-       if (tail) {
-               p += len & ~VMX_ALIGN_MASK;
-               crc = crc32c_base(crc, p, tail);
-       }
-
-       return crc;
-}
-EXPORT_SYMBOL(crc32c_arch);
-
-u32 crc32_be_arch(u32 crc, const u8 *p, size_t len)
-{
-       return crc32_be_base(crc, p, len);
-}
-EXPORT_SYMBOL(crc32_be_arch);
-
-static int __init crc32_powerpc_init(void)
-{
-       if (cpu_has_feature(CPU_FTR_ARCH_207S) &&
-           (cur_cpu_spec->cpu_user_features2 & PPC_FEATURE2_VEC_CRYPTO))
-               static_branch_enable(&have_vec_crypto);
-       return 0;
-}
-arch_initcall(crc32_powerpc_init);
-
-static void __exit crc32_powerpc_exit(void)
-{
-}
-module_exit(crc32_powerpc_exit);
-
-u32 crc32_optimizations(void)
-{
-       if (static_key_enabled(&have_vec_crypto))
-               return CRC32C_OPTIMIZATION;
-       return 0;
-}
-EXPORT_SYMBOL(crc32_optimizations);
-
-MODULE_AUTHOR("Anton Blanchard <anton@samba.org>");
-MODULE_DESCRIPTION("CRC32C using vector polynomial multiply-sum instructions");
-MODULE_LICENSE("GPL");
diff --git a/arch/powerpc/lib/crc32.c b/arch/powerpc/lib/crc32.c
new file mode 100644 (file)
index 0000000..42f2dd3
--- /dev/null
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/crc32.h>
+#include <crypto/internal/simd.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/cpufeature.h>
+#include <asm/simd.h>
+#include <asm/switch_to.h>
+
+#define VMX_ALIGN              16
+#define VMX_ALIGN_MASK         (VMX_ALIGN-1)
+
+#define VECTOR_BREAKPOINT      512
+
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
+
+u32 __crc32c_vpmsum(u32 crc, const u8 *p, size_t len);
+
+u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
+{
+       return crc32_le_base(crc, p, len);
+}
+EXPORT_SYMBOL(crc32_le_arch);
+
+u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
+{
+       unsigned int prealign;
+       unsigned int tail;
+
+       if (len < (VECTOR_BREAKPOINT + VMX_ALIGN) ||
+           !static_branch_likely(&have_vec_crypto) || !crypto_simd_usable())
+               return crc32c_base(crc, p, len);
+
+       if ((unsigned long)p & VMX_ALIGN_MASK) {
+               prealign = VMX_ALIGN - ((unsigned long)p & VMX_ALIGN_MASK);
+               crc = crc32c_base(crc, p, prealign);
+               len -= prealign;
+               p += prealign;
+       }
+
+       if (len & ~VMX_ALIGN_MASK) {
+               preempt_disable();
+               pagefault_disable();
+               enable_kernel_altivec();
+               crc = __crc32c_vpmsum(crc, p, len & ~VMX_ALIGN_MASK);
+               disable_kernel_altivec();
+               pagefault_enable();
+               preempt_enable();
+       }
+
+       tail = len & VMX_ALIGN_MASK;
+       if (tail) {
+               p += len & ~VMX_ALIGN_MASK;
+               crc = crc32c_base(crc, p, tail);
+       }
+
+       return crc;
+}
+EXPORT_SYMBOL(crc32c_arch);
+
+u32 crc32_be_arch(u32 crc, const u8 *p, size_t len)
+{
+       return crc32_be_base(crc, p, len);
+}
+EXPORT_SYMBOL(crc32_be_arch);
+
+static int __init crc32_powerpc_init(void)
+{
+       if (cpu_has_feature(CPU_FTR_ARCH_207S) &&
+           (cur_cpu_spec->cpu_user_features2 & PPC_FEATURE2_VEC_CRYPTO))
+               static_branch_enable(&have_vec_crypto);
+       return 0;
+}
+arch_initcall(crc32_powerpc_init);
+
+static void __exit crc32_powerpc_exit(void)
+{
+}
+module_exit(crc32_powerpc_exit);
+
+u32 crc32_optimizations(void)
+{
+       if (static_key_enabled(&have_vec_crypto))
+               return CRC32C_OPTIMIZATION;
+       return 0;
+}
+EXPORT_SYMBOL(crc32_optimizations);
+
+MODULE_AUTHOR("Anton Blanchard <anton@samba.org>");
+MODULE_DESCRIPTION("CRC32C using vector polynomial multiply-sum instructions");
+MODULE_LICENSE("GPL");