.. | .. |
---|
26 | 26 | #include <linux/module.h> |
---|
27 | 27 | #include <linux/crc-t10dif.h> |
---|
28 | 28 | #include <crypto/internal/hash.h> |
---|
| 29 | +#include <crypto/internal/simd.h> |
---|
29 | 30 | #include <linux/init.h> |
---|
30 | 31 | #include <linux/string.h> |
---|
31 | 32 | #include <linux/kernel.h> |
---|
32 | | -#include <asm/fpu/api.h> |
---|
33 | 33 | #include <asm/cpufeatures.h> |
---|
34 | 34 | #include <asm/cpu_device_id.h> |
---|
| 35 | +#include <asm/simd.h> |
---|
35 | 36 | |
---|
36 | | -asmlinkage __u16 crc_t10dif_pcl(__u16 crc, const unsigned char *buf, |
---|
37 | | - size_t len); |
---|
| 37 | +asmlinkage u16 crc_t10dif_pcl(u16 init_crc, const u8 *buf, size_t len); |
---|
38 | 38 | |
---|
39 | 39 | struct chksum_desc_ctx { |
---|
40 | 40 | __u16 crc; |
---|
41 | 41 | }; |
---|
42 | | - |
---|
43 | | -/* |
---|
44 | | - * Steps through buffer one byte at at time, calculates reflected |
---|
45 | | - * crc using table. |
---|
46 | | - */ |
---|
47 | 42 | |
---|
48 | 43 | static int chksum_init(struct shash_desc *desc) |
---|
49 | 44 | { |
---|
.. | .. |
---|
59 | 54 | { |
---|
60 | 55 | struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); |
---|
61 | 56 | |
---|
62 | | - if (irq_fpu_usable()) { |
---|
| 57 | + if (length >= 16 && crypto_simd_usable()) { |
---|
63 | 58 | kernel_fpu_begin(); |
---|
64 | 59 | ctx->crc = crc_t10dif_pcl(ctx->crc, data, length); |
---|
65 | 60 | kernel_fpu_end(); |
---|
.. | .. |
---|
78 | 73 | |
---|
79 | 74 | static int __chksum_finup(__u16 crc, const u8 *data, unsigned int len, u8 *out) |
---|
80 | 75 | { |
---|
81 | | - if (irq_fpu_usable()) { |
---|
| 76 | + if (len >= 16 && crypto_simd_usable()) { |
---|
82 | 77 | kernel_fpu_begin(); |
---|
83 | 78 | *(__u16 *)out = crc_t10dif_pcl(crc, data, len); |
---|
84 | 79 | kernel_fpu_end(); |
---|
.. | .. |
---|
119 | 114 | }; |
---|
120 | 115 | |
---|
121 | 116 | static const struct x86_cpu_id crct10dif_cpu_id[] = { |
---|
122 | | - X86_FEATURE_MATCH(X86_FEATURE_PCLMULQDQ), |
---|
| 117 | + X86_MATCH_FEATURE(X86_FEATURE_PCLMULQDQ, NULL), |
---|
123 | 118 | {} |
---|
124 | 119 | }; |
---|
125 | 120 | MODULE_DEVICE_TABLE(x86cpu, crct10dif_cpu_id); |
---|