10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 #include <linux/module.h>
14 #include <linux/string.h>
15 #include <linux/kernel.h>
33 u32 *mctx = crypto_shash_ctx(hash);
35 if (keylen !=
sizeof(
u32)) {
45 u32 *mctx = crypto_shash_ctx(desc->
tfm);
46 u32 *crcp = shash_desc_ctx(desc);
55 static void crc32c_compute(
u32 *crcp,
const u64 *
data,
unsigned int len)
66 *crcp =
__crc32c_le(*crcp, (
const unsigned char *) data, len);
72 u32 *crcp = shash_desc_ctx(desc);
74 crc32c_compute(crcp, (
const u64 *) data, len);
79 static int __crc32c_sparc64_finup(
u32 *crcp,
const u8 *data,
unsigned int len,
84 crc32c_compute(&tmp, (
const u64 *) data, len);
90 static int crc32c_sparc64_finup(
struct shash_desc *desc,
const u8 *data,
91 unsigned int len,
u8 *out)
93 return __crc32c_sparc64_finup(shash_desc_ctx(desc), data, len, out);
96 static int crc32c_sparc64_final(
struct shash_desc *desc,
u8 *out)
98 u32 *crcp = shash_desc_ctx(desc);
104 static int crc32c_sparc64_digest(
struct shash_desc *desc,
const u8 *data,
105 unsigned int len,
u8 *out)
107 return __crc32c_sparc64_finup(crypto_shash_ctx(desc->
tfm), data, len,
111 static int crc32c_sparc64_cra_init(
struct crypto_tfm *tfm)
113 u32 *
key = crypto_tfm_ctx(tfm);
120 #define CHKSUM_BLOCK_SIZE 1
121 #define CHKSUM_DIGEST_SIZE 4
124 .setkey = crc32c_sparc64_setkey,
125 .init = crc32c_sparc64_init,
126 .update = crc32c_sparc64_update,
127 .final = crc32c_sparc64_final,
128 .finup = crc32c_sparc64_finup,
129 .digest = crc32c_sparc64_digest,
130 .descsize =
sizeof(
u32),
133 .cra_name =
"crc32c",
134 .cra_driver_name =
"crc32c-sparc64",
137 .cra_ctxsize =
sizeof(
u32),
140 .cra_init = crc32c_sparc64_cra_init,
144 static bool __init sparc64_has_crc32c_opcode(
void)
151 __asm__ __volatile__(
"rd %%asr26, %0" :
"=r" (cfr));
158 static int __init crc32c_sparc64_mod_init(
void)
160 if (sparc64_has_crc32c_opcode()) {
161 pr_info(
"Using sparc64 crc32c opcode optimized CRC32C implementation\n");
164 pr_info(
"sparc64 crc32c opcode not available.\n");
168 static void __exit crc32c_sparc64_mod_fini(
void)