platform/x86: intel-vbtn: Report switch events when event wakes device
[linux/fpc-iii.git] / arch / arm / crypto / crct10dif-ce-glue.c
blob14c19c70a8416bec170eebef2ee7f3fb1fb6b7ba
1 /*
2 * Accelerated CRC-T10DIF using ARM NEON and Crypto Extensions instructions
4 * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/crc-t10dif.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/string.h>
17 #include <crypto/internal/hash.h>
19 #include <asm/neon.h>
20 #include <asm/simd.h>
22 #define CRC_T10DIF_PMULL_CHUNK_SIZE 16U
24 asmlinkage u16 crc_t10dif_pmull(u16 init_crc, const u8 buf[], u32 len);
26 static int crct10dif_init(struct shash_desc *desc)
28 u16 *crc = shash_desc_ctx(desc);
30 *crc = 0;
31 return 0;
34 static int crct10dif_update(struct shash_desc *desc, const u8 *data,
35 unsigned int length)
37 u16 *crc = shash_desc_ctx(desc);
39 if (length >= CRC_T10DIF_PMULL_CHUNK_SIZE && may_use_simd()) {
40 kernel_neon_begin();
41 *crc = crc_t10dif_pmull(*crc, data, length);
42 kernel_neon_end();
43 } else {
44 *crc = crc_t10dif_generic(*crc, data, length);
47 return 0;
50 static int crct10dif_final(struct shash_desc *desc, u8 *out)
52 u16 *crc = shash_desc_ctx(desc);
54 *(u16 *)out = *crc;
55 return 0;
58 static struct shash_alg crc_t10dif_alg = {
59 .digestsize = CRC_T10DIF_DIGEST_SIZE,
60 .init = crct10dif_init,
61 .update = crct10dif_update,
62 .final = crct10dif_final,
63 .descsize = CRC_T10DIF_DIGEST_SIZE,
65 .base.cra_name = "crct10dif",
66 .base.cra_driver_name = "crct10dif-arm-ce",
67 .base.cra_priority = 200,
68 .base.cra_blocksize = CRC_T10DIF_BLOCK_SIZE,
69 .base.cra_module = THIS_MODULE,
72 static int __init crc_t10dif_mod_init(void)
74 if (!(elf_hwcap2 & HWCAP2_PMULL))
75 return -ENODEV;
77 return crypto_register_shash(&crc_t10dif_alg);
80 static void __exit crc_t10dif_mod_exit(void)
82 crypto_unregister_shash(&crc_t10dif_alg);
85 module_init(crc_t10dif_mod_init);
86 module_exit(crc_t10dif_mod_exit);
88 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
89 MODULE_LICENSE("GPL v2");
90 MODULE_ALIAS_CRYPTO("crct10dif");