1b10749d8SEric Biggers /* SPDX-License-Identifier: GPL-2.0-or-later */ 2b10749d8SEric Biggers /* 3b10749d8SEric Biggers * CRC constants generated by: 4b10749d8SEric Biggers * 5*118da22eSEric Biggers * ./scripts/gen-crc-consts.py x86_pclmul crc16_msb_0x8bb7,crc32_lsb_0xedb88320,crc32_lsb_0x82f63b78,crc64_msb_0x42f0e1eba9ea3693,crc64_lsb_0x9a6c9329ac4bc9b5 6b10749d8SEric Biggers * 7b10749d8SEric Biggers * Do not edit manually. 8b10749d8SEric Biggers */ 9b10749d8SEric Biggers 10b10749d8SEric Biggers /* 11b10749d8SEric Biggers * CRC folding constants generated for most-significant-bit-first CRC-16 using 12b10749d8SEric Biggers * G(x) = x^16 + x^15 + x^11 + x^9 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 13b10749d8SEric Biggers */ 14b10749d8SEric Biggers static const struct { 15b10749d8SEric Biggers u8 bswap_mask[16]; 16b10749d8SEric Biggers u64 fold_across_2048_bits_consts[2]; 17b10749d8SEric Biggers u64 fold_across_1024_bits_consts[2]; 18b10749d8SEric Biggers u64 fold_across_512_bits_consts[2]; 19b10749d8SEric Biggers u64 fold_across_256_bits_consts[2]; 20b10749d8SEric Biggers u64 fold_across_128_bits_consts[2]; 21b10749d8SEric Biggers u8 shuf_table[48]; 22b10749d8SEric Biggers u64 barrett_reduction_consts[2]; 23b10749d8SEric Biggers } crc16_msb_0x8bb7_consts ____cacheline_aligned __maybe_unused = { 24b10749d8SEric Biggers .bswap_mask = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, 25b10749d8SEric Biggers .fold_across_2048_bits_consts = { 26b10749d8SEric Biggers 0xdccf000000000000, /* LO64_TERMS: (x^2000 mod G) * x^48 */ 27b10749d8SEric Biggers 0x4b0b000000000000, /* HI64_TERMS: (x^2064 mod G) * x^48 */ 28b10749d8SEric Biggers }, 29b10749d8SEric Biggers .fold_across_1024_bits_consts = { 30b10749d8SEric Biggers 0x9d9d000000000000, /* LO64_TERMS: (x^976 mod G) * x^48 */ 31b10749d8SEric Biggers 0x7cf5000000000000, /* HI64_TERMS: (x^1040 mod G) * x^48 */ 32b10749d8SEric Biggers }, 33b10749d8SEric Biggers .fold_across_512_bits_consts = { 34b10749d8SEric Biggers 0x044c000000000000, /* LO64_TERMS: (x^464 mod G) * x^48 */ 35b10749d8SEric Biggers 0xe658000000000000, /* HI64_TERMS: (x^528 mod G) * x^48 */ 36b10749d8SEric Biggers }, 37b10749d8SEric Biggers .fold_across_256_bits_consts = { 38b10749d8SEric Biggers 0x6ee3000000000000, /* LO64_TERMS: (x^208 mod G) * x^48 */ 39b10749d8SEric Biggers 0xe7b5000000000000, /* HI64_TERMS: (x^272 mod G) * x^48 */ 40b10749d8SEric Biggers }, 41b10749d8SEric Biggers .fold_across_128_bits_consts = { 42b10749d8SEric Biggers 0x2d56000000000000, /* LO64_TERMS: (x^80 mod G) * x^48 */ 43b10749d8SEric Biggers 0x06df000000000000, /* HI64_TERMS: (x^144 mod G) * x^48 */ 44b10749d8SEric Biggers }, 45b10749d8SEric Biggers .shuf_table = { 46b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47b10749d8SEric Biggers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 48b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 49b10749d8SEric Biggers }, 50b10749d8SEric Biggers .barrett_reduction_consts = { 51b10749d8SEric Biggers 0x8bb7000000000000, /* LO64_TERMS: (G - x^16) * x^48 */ 52b10749d8SEric Biggers 0xf65a57f81d33a48a, /* HI64_TERMS: (floor(x^79 / G) * x) - x^64 */ 53b10749d8SEric Biggers }, 54b10749d8SEric Biggers }; 55b10749d8SEric Biggers 56b10749d8SEric Biggers /* 57b10749d8SEric Biggers * CRC folding constants generated for least-significant-bit-first CRC-32 using 58b10749d8SEric Biggers * G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + 59b10749d8SEric Biggers * x^5 + x^4 + x^2 + x^1 + x^0 60b10749d8SEric Biggers */ 61b10749d8SEric Biggers static const struct { 62b10749d8SEric Biggers u64 fold_across_2048_bits_consts[2]; 63b10749d8SEric Biggers u64 fold_across_1024_bits_consts[2]; 64b10749d8SEric Biggers u64 fold_across_512_bits_consts[2]; 65b10749d8SEric Biggers u64 fold_across_256_bits_consts[2]; 66b10749d8SEric Biggers u64 fold_across_128_bits_consts[2]; 67b10749d8SEric Biggers u8 shuf_table[48]; 68b10749d8SEric Biggers u64 barrett_reduction_consts[2]; 69b10749d8SEric Biggers } crc32_lsb_0xedb88320_consts ____cacheline_aligned __maybe_unused = { 70b10749d8SEric Biggers .fold_across_2048_bits_consts = { 71b10749d8SEric Biggers 0x00000000ce3371cb, /* HI64_TERMS: (x^2079 mod G) * x^32 */ 72b10749d8SEric Biggers 0x00000000e95c1271, /* LO64_TERMS: (x^2015 mod G) * x^32 */ 73b10749d8SEric Biggers }, 74b10749d8SEric Biggers .fold_across_1024_bits_consts = { 75b10749d8SEric Biggers 0x0000000033fff533, /* HI64_TERMS: (x^1055 mod G) * x^32 */ 76b10749d8SEric Biggers 0x00000000910eeec1, /* LO64_TERMS: (x^991 mod G) * x^32 */ 77b10749d8SEric Biggers }, 78b10749d8SEric Biggers .fold_across_512_bits_consts = { 79b10749d8SEric Biggers 0x000000008f352d95, /* HI64_TERMS: (x^543 mod G) * x^32 */ 80b10749d8SEric Biggers 0x000000001d9513d7, /* LO64_TERMS: (x^479 mod G) * x^32 */ 81b10749d8SEric Biggers }, 82b10749d8SEric Biggers .fold_across_256_bits_consts = { 83b10749d8SEric Biggers 0x00000000f1da05aa, /* HI64_TERMS: (x^287 mod G) * x^32 */ 84b10749d8SEric Biggers 0x0000000081256527, /* LO64_TERMS: (x^223 mod G) * x^32 */ 85b10749d8SEric Biggers }, 86b10749d8SEric Biggers .fold_across_128_bits_consts = { 87b10749d8SEric Biggers 0x00000000ae689191, /* HI64_TERMS: (x^159 mod G) * x^32 */ 88b10749d8SEric Biggers 0x00000000ccaa009e, /* LO64_TERMS: (x^95 mod G) * x^32 */ 89b10749d8SEric Biggers }, 90b10749d8SEric Biggers .shuf_table = { 91b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 92b10749d8SEric Biggers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 93b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 94b10749d8SEric Biggers }, 95b10749d8SEric Biggers .barrett_reduction_consts = { 96b10749d8SEric Biggers 0xb4e5b025f7011641, /* HI64_TERMS: floor(x^95 / G) */ 97b10749d8SEric Biggers 0x00000001db710640, /* LO64_TERMS: (G - x^32) * x^31 */ 98b10749d8SEric Biggers }, 99b10749d8SEric Biggers }; 100b10749d8SEric Biggers 101b10749d8SEric Biggers /* 102*118da22eSEric Biggers * CRC folding constants generated for least-significant-bit-first CRC-32 using 103*118da22eSEric Biggers * G(x) = x^32 + x^28 + x^27 + x^26 + x^25 + x^23 + x^22 + x^20 + x^19 + x^18 + 104*118da22eSEric Biggers * x^14 + x^13 + x^11 + x^10 + x^9 + x^8 + x^6 + x^0 105*118da22eSEric Biggers */ 106*118da22eSEric Biggers static const struct { 107*118da22eSEric Biggers u64 fold_across_2048_bits_consts[2]; 108*118da22eSEric Biggers u64 fold_across_1024_bits_consts[2]; 109*118da22eSEric Biggers u64 fold_across_512_bits_consts[2]; 110*118da22eSEric Biggers u64 fold_across_256_bits_consts[2]; 111*118da22eSEric Biggers u64 fold_across_128_bits_consts[2]; 112*118da22eSEric Biggers u8 shuf_table[48]; 113*118da22eSEric Biggers u64 barrett_reduction_consts[2]; 114*118da22eSEric Biggers } crc32_lsb_0x82f63b78_consts ____cacheline_aligned __maybe_unused = { 115*118da22eSEric Biggers .fold_across_2048_bits_consts = { 116*118da22eSEric Biggers 0x00000000dcb17aa4, /* HI64_TERMS: (x^2079 mod G) * x^32 */ 117*118da22eSEric Biggers 0x00000000b9e02b86, /* LO64_TERMS: (x^2015 mod G) * x^32 */ 118*118da22eSEric Biggers }, 119*118da22eSEric Biggers .fold_across_1024_bits_consts = { 120*118da22eSEric Biggers 0x000000006992cea2, /* HI64_TERMS: (x^1055 mod G) * x^32 */ 121*118da22eSEric Biggers 0x000000000d3b6092, /* LO64_TERMS: (x^991 mod G) * x^32 */ 122*118da22eSEric Biggers }, 123*118da22eSEric Biggers .fold_across_512_bits_consts = { 124*118da22eSEric Biggers 0x00000000740eef02, /* HI64_TERMS: (x^543 mod G) * x^32 */ 125*118da22eSEric Biggers 0x000000009e4addf8, /* LO64_TERMS: (x^479 mod G) * x^32 */ 126*118da22eSEric Biggers }, 127*118da22eSEric Biggers .fold_across_256_bits_consts = { 128*118da22eSEric Biggers 0x000000003da6d0cb, /* HI64_TERMS: (x^287 mod G) * x^32 */ 129*118da22eSEric Biggers 0x00000000ba4fc28e, /* LO64_TERMS: (x^223 mod G) * x^32 */ 130*118da22eSEric Biggers }, 131*118da22eSEric Biggers .fold_across_128_bits_consts = { 132*118da22eSEric Biggers 0x00000000f20c0dfe, /* HI64_TERMS: (x^159 mod G) * x^32 */ 133*118da22eSEric Biggers 0x00000000493c7d27, /* LO64_TERMS: (x^95 mod G) * x^32 */ 134*118da22eSEric Biggers }, 135*118da22eSEric Biggers .shuf_table = { 136*118da22eSEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 137*118da22eSEric Biggers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 138*118da22eSEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 139*118da22eSEric Biggers }, 140*118da22eSEric Biggers .barrett_reduction_consts = { 141*118da22eSEric Biggers 0x4869ec38dea713f1, /* HI64_TERMS: floor(x^95 / G) */ 142*118da22eSEric Biggers 0x0000000105ec76f0, /* LO64_TERMS: (G - x^32) * x^31 */ 143*118da22eSEric Biggers }, 144*118da22eSEric Biggers }; 145*118da22eSEric Biggers 146*118da22eSEric Biggers /* 147b10749d8SEric Biggers * CRC folding constants generated for most-significant-bit-first CRC-64 using 148b10749d8SEric Biggers * G(x) = x^64 + x^62 + x^57 + x^55 + x^54 + x^53 + x^52 + x^47 + x^46 + x^45 + 149b10749d8SEric Biggers * x^40 + x^39 + x^38 + x^37 + x^35 + x^33 + x^32 + x^31 + x^29 + x^27 + 150b10749d8SEric Biggers * x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 + 151b10749d8SEric Biggers * x^7 + x^4 + x^1 + x^0 152b10749d8SEric Biggers */ 153b10749d8SEric Biggers static const struct { 154b10749d8SEric Biggers u8 bswap_mask[16]; 155b10749d8SEric Biggers u64 fold_across_2048_bits_consts[2]; 156b10749d8SEric Biggers u64 fold_across_1024_bits_consts[2]; 157b10749d8SEric Biggers u64 fold_across_512_bits_consts[2]; 158b10749d8SEric Biggers u64 fold_across_256_bits_consts[2]; 159b10749d8SEric Biggers u64 fold_across_128_bits_consts[2]; 160b10749d8SEric Biggers u8 shuf_table[48]; 161b10749d8SEric Biggers u64 barrett_reduction_consts[2]; 162b10749d8SEric Biggers } crc64_msb_0x42f0e1eba9ea3693_consts ____cacheline_aligned __maybe_unused = { 163b10749d8SEric Biggers .bswap_mask = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, 164b10749d8SEric Biggers .fold_across_2048_bits_consts = { 165b10749d8SEric Biggers 0x7f52691a60ddc70d, /* LO64_TERMS: (x^2048 mod G) * x^0 */ 166b10749d8SEric Biggers 0x7036b0389f6a0c82, /* HI64_TERMS: (x^2112 mod G) * x^0 */ 167b10749d8SEric Biggers }, 168b10749d8SEric Biggers .fold_across_1024_bits_consts = { 169b10749d8SEric Biggers 0x05cf79dea9ac37d6, /* LO64_TERMS: (x^1024 mod G) * x^0 */ 170b10749d8SEric Biggers 0x001067e571d7d5c2, /* HI64_TERMS: (x^1088 mod G) * x^0 */ 171b10749d8SEric Biggers }, 172b10749d8SEric Biggers .fold_across_512_bits_consts = { 173b10749d8SEric Biggers 0x5f6843ca540df020, /* LO64_TERMS: (x^512 mod G) * x^0 */ 174b10749d8SEric Biggers 0xddf4b6981205b83f, /* HI64_TERMS: (x^576 mod G) * x^0 */ 175b10749d8SEric Biggers }, 176b10749d8SEric Biggers .fold_across_256_bits_consts = { 177b10749d8SEric Biggers 0x571bee0a227ef92b, /* LO64_TERMS: (x^256 mod G) * x^0 */ 178b10749d8SEric Biggers 0x44bef2a201b5200c, /* HI64_TERMS: (x^320 mod G) * x^0 */ 179b10749d8SEric Biggers }, 180b10749d8SEric Biggers .fold_across_128_bits_consts = { 181b10749d8SEric Biggers 0x05f5c3c7eb52fab6, /* LO64_TERMS: (x^128 mod G) * x^0 */ 182b10749d8SEric Biggers 0x4eb938a7d257740e, /* HI64_TERMS: (x^192 mod G) * x^0 */ 183b10749d8SEric Biggers }, 184b10749d8SEric Biggers .shuf_table = { 185b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 186b10749d8SEric Biggers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 187b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 188b10749d8SEric Biggers }, 189b10749d8SEric Biggers .barrett_reduction_consts = { 190b10749d8SEric Biggers 0x42f0e1eba9ea3693, /* LO64_TERMS: (G - x^64) * x^0 */ 191b10749d8SEric Biggers 0x578d29d06cc4f872, /* HI64_TERMS: (floor(x^127 / G) * x) - x^64 */ 192b10749d8SEric Biggers }, 193b10749d8SEric Biggers }; 194b10749d8SEric Biggers 195b10749d8SEric Biggers /* 196b10749d8SEric Biggers * CRC folding constants generated for least-significant-bit-first CRC-64 using 197b10749d8SEric Biggers * G(x) = x^64 + x^63 + x^61 + x^59 + x^58 + x^56 + x^55 + x^52 + x^49 + x^48 + 198b10749d8SEric Biggers * x^47 + x^46 + x^44 + x^41 + x^37 + x^36 + x^34 + x^32 + x^31 + x^28 + 199b10749d8SEric Biggers * x^26 + x^23 + x^22 + x^19 + x^16 + x^13 + x^12 + x^10 + x^9 + x^6 + 200b10749d8SEric Biggers * x^4 + x^3 + x^0 201b10749d8SEric Biggers */ 202b10749d8SEric Biggers static const struct { 203b10749d8SEric Biggers u64 fold_across_2048_bits_consts[2]; 204b10749d8SEric Biggers u64 fold_across_1024_bits_consts[2]; 205b10749d8SEric Biggers u64 fold_across_512_bits_consts[2]; 206b10749d8SEric Biggers u64 fold_across_256_bits_consts[2]; 207b10749d8SEric Biggers u64 fold_across_128_bits_consts[2]; 208b10749d8SEric Biggers u8 shuf_table[48]; 209b10749d8SEric Biggers u64 barrett_reduction_consts[2]; 210b10749d8SEric Biggers } crc64_lsb_0x9a6c9329ac4bc9b5_consts ____cacheline_aligned __maybe_unused = { 211b10749d8SEric Biggers .fold_across_2048_bits_consts = { 212b10749d8SEric Biggers 0x37ccd3e14069cabc, /* HI64_TERMS: (x^2111 mod G) * x^0 */ 213b10749d8SEric Biggers 0xa043808c0f782663, /* LO64_TERMS: (x^2047 mod G) * x^0 */ 214b10749d8SEric Biggers }, 215b10749d8SEric Biggers .fold_across_1024_bits_consts = { 216b10749d8SEric Biggers 0xa1ca681e733f9c40, /* HI64_TERMS: (x^1087 mod G) * x^0 */ 217b10749d8SEric Biggers 0x5f852fb61e8d92dc, /* LO64_TERMS: (x^1023 mod G) * x^0 */ 218b10749d8SEric Biggers }, 219b10749d8SEric Biggers .fold_across_512_bits_consts = { 220b10749d8SEric Biggers 0x0c32cdb31e18a84a, /* HI64_TERMS: (x^575 mod G) * x^0 */ 221b10749d8SEric Biggers 0x62242240ace5045a, /* LO64_TERMS: (x^511 mod G) * x^0 */ 222b10749d8SEric Biggers }, 223b10749d8SEric Biggers .fold_across_256_bits_consts = { 224b10749d8SEric Biggers 0xb0bc2e589204f500, /* HI64_TERMS: (x^319 mod G) * x^0 */ 225b10749d8SEric Biggers 0xe1e0bb9d45d7a44c, /* LO64_TERMS: (x^255 mod G) * x^0 */ 226b10749d8SEric Biggers }, 227b10749d8SEric Biggers .fold_across_128_bits_consts = { 228b10749d8SEric Biggers 0xeadc41fd2ba3d420, /* HI64_TERMS: (x^191 mod G) * x^0 */ 229b10749d8SEric Biggers 0x21e9761e252621ac, /* LO64_TERMS: (x^127 mod G) * x^0 */ 230b10749d8SEric Biggers }, 231b10749d8SEric Biggers .shuf_table = { 232b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 233b10749d8SEric Biggers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 234b10749d8SEric Biggers -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 235b10749d8SEric Biggers }, 236b10749d8SEric Biggers .barrett_reduction_consts = { 237b10749d8SEric Biggers 0x27ecfa329aef9f77, /* HI64_TERMS: floor(x^127 / G) */ 238b10749d8SEric Biggers 0x34d926535897936a, /* LO64_TERMS: (G - x^64 - x^0) / x */ 239b10749d8SEric Biggers }, 240b10749d8SEric Biggers }; 241