1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * CRC constants generated by: 4 * 5 * ./scripts/gen-crc-consts.py riscv_clmul crc16_msb_0x8bb7,crc32_msb_0x04c11db7,crc32_lsb_0xedb88320,crc32_lsb_0x82f63b78,crc64_msb_0x42f0e1eba9ea3693,crc64_lsb_0x9a6c9329ac4bc9b5 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-16 using 19 * G(x) = x^16 + x^15 + x^11 + x^9 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 20 */ 21 static const struct crc_clmul_consts crc16_msb_0x8bb7_consts __maybe_unused = { 22 #ifdef CONFIG_64BIT 23 .fold_across_2_longs_const_hi = 0x0000000000001faa, /* x^192 mod G */ 24 .fold_across_2_longs_const_lo = 0x000000000000a010, /* x^128 mod G */ 25 .barrett_reduction_const_1 = 0xfb2d2bfc0e99d245, /* floor(x^79 / G) */ 26 .barrett_reduction_const_2 = 0x0000000000008bb7, /* G - x^16 */ 27 #else 28 .fold_across_2_longs_const_hi = 0x00005890, /* x^96 mod G */ 29 .fold_across_2_longs_const_lo = 0x0000f249, /* x^64 mod G */ 30 .barrett_reduction_const_1 = 0xfb2d2bfc, /* floor(x^47 / G) */ 31 .barrett_reduction_const_2 = 0x00008bb7, /* G - x^16 */ 32 #endif 33 }; 34 35 /* 36 * Constants generated for most-significant-bit-first CRC-32 using 37 * G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + 38 * x^5 + x^4 + x^2 + x^1 + x^0 39 */ 40 static const struct crc_clmul_consts crc32_msb_0x04c11db7_consts __maybe_unused = { 41 #ifdef CONFIG_64BIT 42 .fold_across_2_longs_const_hi = 0x00000000c5b9cd4c, /* x^192 mod G */ 43 .fold_across_2_longs_const_lo = 0x00000000e8a45605, /* x^128 mod G */ 44 .barrett_reduction_const_1 = 0x826880efa40da72d, /* floor(x^95 / G) */ 45 .barrett_reduction_const_2 = 0x0000000004c11db7, /* G - x^32 */ 46 #else 47 .fold_across_2_longs_const_hi = 0xf200aa66, /* x^96 mod G */ 48 .fold_across_2_longs_const_lo = 0x490d678d, /* x^64 mod G */ 49 .barrett_reduction_const_1 = 0x826880ef, /* floor(x^63 / G) */ 50 .barrett_reduction_const_2 = 0x04c11db7, /* G - x^32 */ 51 #endif 52 }; 53 54 /* 55 * Constants generated for least-significant-bit-first CRC-32 using 56 * G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + 57 * x^5 + x^4 + x^2 + x^1 + x^0 58 */ 59 static const struct crc_clmul_consts crc32_lsb_0xedb88320_consts __maybe_unused = { 60 #ifdef CONFIG_64BIT 61 .fold_across_2_longs_const_hi = 0x65673b4600000000, /* x^191 mod G */ 62 .fold_across_2_longs_const_lo = 0x9ba54c6f00000000, /* x^127 mod G */ 63 .barrett_reduction_const_1 = 0xb4e5b025f7011641, /* floor(x^95 / G) */ 64 .barrett_reduction_const_2 = 0x00000000edb88320, /* (G - x^32) * x^32 */ 65 #else 66 .fold_across_2_longs_const_hi = 0xccaa009e, /* x^95 mod G */ 67 .fold_across_2_longs_const_lo = 0xb8bc6765, /* x^63 mod G */ 68 .barrett_reduction_const_1 = 0xf7011641, /* floor(x^63 / G) */ 69 .barrett_reduction_const_2 = 0xedb88320, /* (G - x^32) * x^0 */ 70 #endif 71 }; 72 73 /* 74 * Constants generated for least-significant-bit-first CRC-32 using 75 * G(x) = x^32 + x^28 + x^27 + x^26 + x^25 + x^23 + x^22 + x^20 + x^19 + x^18 + 76 * x^14 + x^13 + x^11 + x^10 + x^9 + x^8 + x^6 + x^0 77 */ 78 static const struct crc_clmul_consts crc32_lsb_0x82f63b78_consts __maybe_unused = { 79 #ifdef CONFIG_64BIT 80 .fold_across_2_longs_const_hi = 0x3743f7bd00000000, /* x^191 mod G */ 81 .fold_across_2_longs_const_lo = 0x3171d43000000000, /* x^127 mod G */ 82 .barrett_reduction_const_1 = 0x4869ec38dea713f1, /* floor(x^95 / G) */ 83 .barrett_reduction_const_2 = 0x0000000082f63b78, /* (G - x^32) * x^32 */ 84 #else 85 .fold_across_2_longs_const_hi = 0x493c7d27, /* x^95 mod G */ 86 .fold_across_2_longs_const_lo = 0xdd45aab8, /* x^63 mod G */ 87 .barrett_reduction_const_1 = 0xdea713f1, /* floor(x^63 / G) */ 88 .barrett_reduction_const_2 = 0x82f63b78, /* (G - x^32) * x^0 */ 89 #endif 90 }; 91 92 /* 93 * Constants generated for most-significant-bit-first CRC-64 using 94 * G(x) = x^64 + x^62 + x^57 + x^55 + x^54 + x^53 + x^52 + x^47 + x^46 + x^45 + 95 * x^40 + x^39 + x^38 + x^37 + x^35 + x^33 + x^32 + x^31 + x^29 + x^27 + 96 * x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 + 97 * x^7 + x^4 + x^1 + x^0 98 */ 99 #ifdef CONFIG_64BIT 100 static const struct crc_clmul_consts crc64_msb_0x42f0e1eba9ea3693_consts __maybe_unused = { 101 .fold_across_2_longs_const_hi = 0x4eb938a7d257740e, /* x^192 mod G */ 102 .fold_across_2_longs_const_lo = 0x05f5c3c7eb52fab6, /* x^128 mod G */ 103 .barrett_reduction_const_1 = 0xabc694e836627c39, /* floor(x^127 / G) */ 104 .barrett_reduction_const_2 = 0x42f0e1eba9ea3693, /* G - x^64 */ 105 }; 106 #endif 107 108 /* 109 * Constants generated for least-significant-bit-first CRC-64 using 110 * G(x) = x^64 + x^63 + x^61 + x^59 + x^58 + x^56 + x^55 + x^52 + x^49 + x^48 + 111 * x^47 + x^46 + x^44 + x^41 + x^37 + x^36 + x^34 + x^32 + x^31 + x^28 + 112 * x^26 + x^23 + x^22 + x^19 + x^16 + x^13 + x^12 + x^10 + x^9 + x^6 + 113 * x^4 + x^3 + x^0 114 */ 115 #ifdef CONFIG_64BIT 116 static const struct crc_clmul_consts crc64_lsb_0x9a6c9329ac4bc9b5_consts __maybe_unused = { 117 .fold_across_2_longs_const_hi = 0xeadc41fd2ba3d420, /* x^191 mod G */ 118 .fold_across_2_longs_const_lo = 0x21e9761e252621ac, /* x^127 mod G */ 119 .barrett_reduction_const_1 = 0x27ecfa329aef9f77, /* floor(x^127 / G) */ 120 .barrett_reduction_const_2 = 0x9a6c9329ac4bc9b5, /* (G - x^64) * x^0 */ 121 }; 122 #endif 123