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