1*511484faSEric Biggers // SPDX-License-Identifier: GPL-2.0-or-later 2*511484faSEric Biggers /* 3*511484faSEric Biggers * RISC-V optimized CRC64 functions 4*511484faSEric Biggers * 5*511484faSEric Biggers * Copyright 2025 Google LLC 6*511484faSEric Biggers */ 7*511484faSEric Biggers 8*511484faSEric Biggers #include <asm/hwcap.h> 9*511484faSEric Biggers #include <asm/alternative-macros.h> 10*511484faSEric Biggers #include <linux/crc64.h> 11*511484faSEric Biggers #include <linux/module.h> 12*511484faSEric Biggers 13*511484faSEric Biggers #include "crc-clmul.h" 14*511484faSEric Biggers 15*511484faSEric Biggers u64 crc64_be_arch(u64 crc, const u8 *p, size_t len) 16*511484faSEric Biggers { 17*511484faSEric Biggers if (riscv_has_extension_likely(RISCV_ISA_EXT_ZBC)) 18*511484faSEric Biggers return crc64_msb_clmul(crc, p, len, 19*511484faSEric Biggers &crc64_msb_0x42f0e1eba9ea3693_consts); 20*511484faSEric Biggers return crc64_be_generic(crc, p, len); 21*511484faSEric Biggers } 22*511484faSEric Biggers EXPORT_SYMBOL(crc64_be_arch); 23*511484faSEric Biggers 24*511484faSEric Biggers u64 crc64_nvme_arch(u64 crc, const u8 *p, size_t len) 25*511484faSEric Biggers { 26*511484faSEric Biggers if (riscv_has_extension_likely(RISCV_ISA_EXT_ZBC)) 27*511484faSEric Biggers return crc64_lsb_clmul(crc, p, len, 28*511484faSEric Biggers &crc64_lsb_0x9a6c9329ac4bc9b5_consts); 29*511484faSEric Biggers return crc64_nvme_generic(crc, p, len); 30*511484faSEric Biggers } 31*511484faSEric Biggers EXPORT_SYMBOL(crc64_nvme_arch); 32*511484faSEric Biggers 33*511484faSEric Biggers MODULE_DESCRIPTION("RISC-V optimized CRC64 functions"); 34*511484faSEric Biggers MODULE_LICENSE("GPL"); 35