|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | +/* |
| 3 | + * CRC constants generated by: |
| 4 | + * |
| 5 | + * ./scripts/gen-crc-consts.py riscv_clmul crc32_msb_0x04c11db7,crc32_lsb_0xedb88320,crc32_lsb_0x82f63b78 |
| 6 | + * |
| 7 | + * Do not edit manually. |
| 8 | + */ |
| 9 | + |
| 10 | +struct crc_clmul_consts { |
| 11 | + unsigned long fold_across_2_longs_const_hi; |
| 12 | + unsigned long fold_across_2_longs_const_lo; |
| 13 | + unsigned long barrett_reduction_const_1; |
| 14 | + unsigned long barrett_reduction_const_2; |
| 15 | +}; |
| 16 | + |
| 17 | +/* |
| 18 | + * Constants generated for most-significant-bit-first CRC-32 using |
| 19 | + * G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + |
| 20 | + * x^5 + x^4 + x^2 + x^1 + x^0 |
| 21 | + */ |
| 22 | +static const struct crc_clmul_consts crc32_msb_0x04c11db7_consts __maybe_unused = { |
| 23 | +#ifdef CONFIG_64BIT |
| 24 | + .fold_across_2_longs_const_hi = 0x00000000c5b9cd4c, /* x^192 mod G */ |
| 25 | + .fold_across_2_longs_const_lo = 0x00000000e8a45605, /* x^128 mod G */ |
| 26 | + .barrett_reduction_const_1 = 0x826880efa40da72d, /* floor(x^95 / G) */ |
| 27 | + .barrett_reduction_const_2 = 0x0000000004c11db7, /* G - x^32 */ |
| 28 | +#else |
| 29 | + .fold_across_2_longs_const_hi = 0xf200aa66, /* x^96 mod G */ |
| 30 | + .fold_across_2_longs_const_lo = 0x490d678d, /* x^64 mod G */ |
| 31 | + .barrett_reduction_const_1 = 0x826880ef, /* floor(x^63 / G) */ |
| 32 | + .barrett_reduction_const_2 = 0x04c11db7, /* G - x^32 */ |
| 33 | +#endif |
| 34 | +}; |
| 35 | + |
| 36 | +/* |
| 37 | + * Constants generated for least-significant-bit-first CRC-32 using |
| 38 | + * G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + |
| 39 | + * x^5 + x^4 + x^2 + x^1 + x^0 |
| 40 | + */ |
| 41 | +static const struct crc_clmul_consts crc32_lsb_0xedb88320_consts __maybe_unused = { |
| 42 | +#ifdef CONFIG_64BIT |
| 43 | + .fold_across_2_longs_const_hi = 0x65673b4600000000, /* x^191 mod G */ |
| 44 | + .fold_across_2_longs_const_lo = 0x9ba54c6f00000000, /* x^127 mod G */ |
| 45 | + .barrett_reduction_const_1 = 0xb4e5b025f7011641, /* floor(x^95 / G) */ |
| 46 | + .barrett_reduction_const_2 = 0x00000000edb88320, /* (G - x^32) * x^32 */ |
| 47 | +#else |
| 48 | + .fold_across_2_longs_const_hi = 0xccaa009e, /* x^95 mod G */ |
| 49 | + .fold_across_2_longs_const_lo = 0xb8bc6765, /* x^63 mod G */ |
| 50 | + .barrett_reduction_const_1 = 0xf7011641, /* floor(x^63 / G) */ |
| 51 | + .barrett_reduction_const_2 = 0xedb88320, /* (G - x^32) * x^0 */ |
| 52 | +#endif |
| 53 | +}; |
| 54 | + |
| 55 | +/* |
| 56 | + * Constants generated for least-significant-bit-first CRC-32 using |
| 57 | + * G(x) = x^32 + x^28 + x^27 + x^26 + x^25 + x^23 + x^22 + x^20 + x^19 + x^18 + |
| 58 | + * x^14 + x^13 + x^11 + x^10 + x^9 + x^8 + x^6 + x^0 |
| 59 | + */ |
| 60 | +static const struct crc_clmul_consts crc32_lsb_0x82f63b78_consts __maybe_unused = { |
| 61 | +#ifdef CONFIG_64BIT |
| 62 | + .fold_across_2_longs_const_hi = 0x3743f7bd00000000, /* x^191 mod G */ |
| 63 | + .fold_across_2_longs_const_lo = 0x3171d43000000000, /* x^127 mod G */ |
| 64 | + .barrett_reduction_const_1 = 0x4869ec38dea713f1, /* floor(x^95 / G) */ |
| 65 | + .barrett_reduction_const_2 = 0x0000000082f63b78, /* (G - x^32) * x^32 */ |
| 66 | +#else |
| 67 | + .fold_across_2_longs_const_hi = 0x493c7d27, /* x^95 mod G */ |
| 68 | + .fold_across_2_longs_const_lo = 0xdd45aab8, /* x^63 mod G */ |
| 69 | + .barrett_reduction_const_1 = 0xdea713f1, /* floor(x^63 / G) */ |
| 70 | + .barrett_reduction_const_2 = 0x82f63b78, /* (G - x^32) * x^0 */ |
| 71 | +#endif |
| 72 | +}; |
0 commit comments