11da177e4SLinus Torvalds /* 278dff418SBob Pearson * Aug 8, 2011 Bob Pearson with help from Joakim Tjernlund and George Spelvin 378dff418SBob Pearson * cleaned up code to current version of sparse and added the slicing-by-8 478dff418SBob Pearson * algorithm to the closely similar existing slicing-by-4 algorithm. 578dff418SBob Pearson * 61da177e4SLinus Torvalds * Oct 15, 2000 Matt Domsch <Matt_Domsch@dell.com> 71da177e4SLinus Torvalds * Nicer crc32 functions/docs submitted by linux@horizon.com. Thanks! 81da177e4SLinus Torvalds * Code was from the public domain, copyright abandoned. Code was 91da177e4SLinus Torvalds * subsequently included in the kernel, thus was re-licensed under the 101da177e4SLinus Torvalds * GNU GPL v2. 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * Oct 12, 2000 Matt Domsch <Matt_Domsch@dell.com> 131da177e4SLinus Torvalds * Same crc32 function was used in 5 other places in the kernel. 141da177e4SLinus Torvalds * I made one version, and deleted the others. 151da177e4SLinus Torvalds * There are various incantations of crc32(). Some use a seed of 0 or ~0. 161da177e4SLinus Torvalds * Some xor at the end with ~0. The generic crc32() function takes 171da177e4SLinus Torvalds * seed as an argument, and doesn't xor at the end. Then individual 181da177e4SLinus Torvalds * users can do whatever they need. 191da177e4SLinus Torvalds * drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0. 201da177e4SLinus Torvalds * fs/jffs2 uses seed 0, doesn't xor with ~0. 211da177e4SLinus Torvalds * fs/partitions/efi.c uses seed ~0, xor's with ~0. 221da177e4SLinus Torvalds * 231da177e4SLinus Torvalds * This source code is licensed under the GNU General Public License, 241da177e4SLinus Torvalds * Version 2. See the file COPYING for more details. 251da177e4SLinus Torvalds */ 261da177e4SLinus Torvalds 27*8e2a46a4SMauro Carvalho Chehab /* see: Documentation/staging/crc32.rst for a description of algorithms */ 28fbedceb1SBob Pearson 291da177e4SLinus Torvalds #include <linux/crc32.h> 301fb2e3f2SKrzysztof Kozlowski #include <linux/crc32poly.h> 311da177e4SLinus Torvalds #include <linux/module.h> 321da177e4SLinus Torvalds #include <linux/types.h> 33cc0ac199SDaniel Borkmann #include <linux/sched.h> 341da177e4SLinus Torvalds #include "crc32defs.h" 3560e58d5cSBob Pearson 369a1dbf6aSBob Pearson #if CRC_LE_BITS > 8 3738b4fe5fSFabian Frederick # define tole(x) ((__force u32) cpu_to_le32(x)) 381da177e4SLinus Torvalds #else 391da177e4SLinus Torvalds # define tole(x) (x) 404f2a9463SJoakim Tjernlund #endif 414f2a9463SJoakim Tjernlund 429a1dbf6aSBob Pearson #if CRC_BE_BITS > 8 4338b4fe5fSFabian Frederick # define tobe(x) ((__force u32) cpu_to_be32(x)) 444f2a9463SJoakim Tjernlund #else 451da177e4SLinus Torvalds # define tobe(x) (x) 461da177e4SLinus Torvalds #endif 4760e58d5cSBob Pearson 481da177e4SLinus Torvalds #include "crc32table.h" 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds MODULE_AUTHOR("Matt Domsch <Matt_Domsch@dell.com>"); 5146c5801eSDarrick J. Wong MODULE_DESCRIPTION("Various CRC32 calculations"); 521da177e4SLinus Torvalds MODULE_LICENSE("GPL"); 531da177e4SLinus Torvalds 549a1dbf6aSBob Pearson #if CRC_LE_BITS > 8 || CRC_BE_BITS > 8 55ddcaccbcSJoakim Tjernlund 56324eb0f1SBob Pearson /* implements slicing-by-4 or slicing-by-8 algorithm */ 57d8f1c477SGeorge Spelvin static inline u32 __pure 58836e2af9SJoakim Tjernlund crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) 59ddcaccbcSJoakim Tjernlund { 600d2daf5cSAndrew Morton # ifdef __LITTLE_ENDIAN 615742332dSJoakim Tjernlund # define DO_CRC(x) crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8) 62324eb0f1SBob Pearson # define DO_CRC4 (t3[(q) & 255] ^ t2[(q >> 8) & 255] ^ \ 63324eb0f1SBob Pearson t1[(q >> 16) & 255] ^ t0[(q >> 24) & 255]) 64324eb0f1SBob Pearson # define DO_CRC8 (t7[(q) & 255] ^ t6[(q >> 8) & 255] ^ \ 65324eb0f1SBob Pearson t5[(q >> 16) & 255] ^ t4[(q >> 24) & 255]) 66ddcaccbcSJoakim Tjernlund # else 675742332dSJoakim Tjernlund # define DO_CRC(x) crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8) 68324eb0f1SBob Pearson # define DO_CRC4 (t0[(q) & 255] ^ t1[(q >> 8) & 255] ^ \ 69324eb0f1SBob Pearson t2[(q >> 16) & 255] ^ t3[(q >> 24) & 255]) 70324eb0f1SBob Pearson # define DO_CRC8 (t4[(q) & 255] ^ t5[(q >> 8) & 255] ^ \ 71324eb0f1SBob Pearson t6[(q >> 16) & 255] ^ t7[(q >> 24) & 255]) 72ddcaccbcSJoakim Tjernlund # endif 734f2a9463SJoakim Tjernlund const u32 *b; 74ddcaccbcSJoakim Tjernlund size_t rem_len; 750292c497SBob Pearson # ifdef CONFIG_X86 760292c497SBob Pearson size_t i; 770292c497SBob Pearson # endif 785742332dSJoakim Tjernlund const u32 *t0=tab[0], *t1=tab[1], *t2=tab[2], *t3=tab[3]; 7949ac572bSThiago Rafael Becker # if CRC_LE_BITS != 32 80324eb0f1SBob Pearson const u32 *t4 = tab[4], *t5 = tab[5], *t6 = tab[6], *t7 = tab[7]; 8149ac572bSThiago Rafael Becker # endif 82324eb0f1SBob Pearson u32 q; 83ddcaccbcSJoakim Tjernlund 84ddcaccbcSJoakim Tjernlund /* Align it */ 854f2a9463SJoakim Tjernlund if (unlikely((long)buf & 3 && len)) { 86ddcaccbcSJoakim Tjernlund do { 874f2a9463SJoakim Tjernlund DO_CRC(*buf++); 884f2a9463SJoakim Tjernlund } while ((--len) && ((long)buf)&3); 89ddcaccbcSJoakim Tjernlund } 90324eb0f1SBob Pearson 91324eb0f1SBob Pearson # if CRC_LE_BITS == 32 92ddcaccbcSJoakim Tjernlund rem_len = len & 3; 93ddcaccbcSJoakim Tjernlund len = len >> 2; 94324eb0f1SBob Pearson # else 95324eb0f1SBob Pearson rem_len = len & 7; 96324eb0f1SBob Pearson len = len >> 3; 97324eb0f1SBob Pearson # endif 98324eb0f1SBob Pearson 994f2a9463SJoakim Tjernlund b = (const u32 *)buf; 1000292c497SBob Pearson # ifdef CONFIG_X86 1010292c497SBob Pearson --b; 1020292c497SBob Pearson for (i = 0; i < len; i++) { 1030292c497SBob Pearson # else 104ddcaccbcSJoakim Tjernlund for (--b; len; --len) { 1050292c497SBob Pearson # endif 106324eb0f1SBob Pearson q = crc ^ *++b; /* use pre increment for speed */ 107324eb0f1SBob Pearson # if CRC_LE_BITS == 32 108324eb0f1SBob Pearson crc = DO_CRC4; 109324eb0f1SBob Pearson # else 110324eb0f1SBob Pearson crc = DO_CRC8; 111324eb0f1SBob Pearson q = *++b; 112324eb0f1SBob Pearson crc ^= DO_CRC4; 113324eb0f1SBob Pearson # endif 114ddcaccbcSJoakim Tjernlund } 115ddcaccbcSJoakim Tjernlund len = rem_len; 116ddcaccbcSJoakim Tjernlund /* And the last few bytes */ 117ddcaccbcSJoakim Tjernlund if (len) { 118ddcaccbcSJoakim Tjernlund u8 *p = (u8 *)(b + 1) - 1; 1190292c497SBob Pearson # ifdef CONFIG_X86 1200292c497SBob Pearson for (i = 0; i < len; i++) 1210292c497SBob Pearson DO_CRC(*++p); /* use pre increment for speed */ 1220292c497SBob Pearson # else 123ddcaccbcSJoakim Tjernlund do { 124ddcaccbcSJoakim Tjernlund DO_CRC(*++p); /* use pre increment for speed */ 125ddcaccbcSJoakim Tjernlund } while (--len); 1260292c497SBob Pearson # endif 127ddcaccbcSJoakim Tjernlund } 128ddcaccbcSJoakim Tjernlund return crc; 1294f2a9463SJoakim Tjernlund #undef DO_CRC 130836e2af9SJoakim Tjernlund #undef DO_CRC4 131324eb0f1SBob Pearson #undef DO_CRC8 132ddcaccbcSJoakim Tjernlund } 133ddcaccbcSJoakim Tjernlund #endif 13460e58d5cSBob Pearson 1356e95fcaaSDaniel Borkmann 1362f72100cSRandy Dunlap /** 137f2e1d2acSGu Zheng * crc32_le_generic() - Calculate bitwise little-endian Ethernet AUTODIN II 138f2e1d2acSGu Zheng * CRC32/CRC32C 139f2e1d2acSGu Zheng * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for other 140f2e1d2acSGu Zheng * uses, or the previous crc32/crc32c value if computing incrementally. 141f2e1d2acSGu Zheng * @p: pointer to buffer over which CRC32/CRC32C is run 1422f72100cSRandy Dunlap * @len: length of buffer @p 143f2e1d2acSGu Zheng * @tab: little-endian Ethernet table 144f2e1d2acSGu Zheng * @polynomial: CRC32/CRC32c LE polynomial 1452f72100cSRandy Dunlap */ 14646c5801eSDarrick J. Wong static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p, 14746c5801eSDarrick J. Wong size_t len, const u32 (*tab)[256], 14846c5801eSDarrick J. Wong u32 polynomial) 1491da177e4SLinus Torvalds { 15060e58d5cSBob Pearson #if CRC_LE_BITS == 1 1511da177e4SLinus Torvalds int i; 1521da177e4SLinus Torvalds while (len--) { 1531da177e4SLinus Torvalds crc ^= *p++; 1541da177e4SLinus Torvalds for (i = 0; i < 8; i++) 15546c5801eSDarrick J. Wong crc = (crc >> 1) ^ ((crc & 1) ? polynomial : 0); 1561da177e4SLinus Torvalds } 15760e58d5cSBob Pearson # elif CRC_LE_BITS == 2 15860e58d5cSBob Pearson while (len--) { 15960e58d5cSBob Pearson crc ^= *p++; 16046c5801eSDarrick J. Wong crc = (crc >> 2) ^ tab[0][crc & 3]; 16146c5801eSDarrick J. Wong crc = (crc >> 2) ^ tab[0][crc & 3]; 16246c5801eSDarrick J. Wong crc = (crc >> 2) ^ tab[0][crc & 3]; 16346c5801eSDarrick J. Wong crc = (crc >> 2) ^ tab[0][crc & 3]; 1641da177e4SLinus Torvalds } 16560e58d5cSBob Pearson # elif CRC_LE_BITS == 4 16660e58d5cSBob Pearson while (len--) { 16760e58d5cSBob Pearson crc ^= *p++; 16846c5801eSDarrick J. Wong crc = (crc >> 4) ^ tab[0][crc & 15]; 16946c5801eSDarrick J. Wong crc = (crc >> 4) ^ tab[0][crc & 15]; 17060e58d5cSBob Pearson } 17160e58d5cSBob Pearson # elif CRC_LE_BITS == 8 1729a1dbf6aSBob Pearson /* aka Sarwate algorithm */ 1739a1dbf6aSBob Pearson while (len--) { 1749a1dbf6aSBob Pearson crc ^= *p++; 17546c5801eSDarrick J. Wong crc = (crc >> 8) ^ tab[0][crc & 255]; 1769a1dbf6aSBob Pearson } 1779a1dbf6aSBob Pearson # else 178ce4320ddSBob Pearson crc = (__force u32) __cpu_to_le32(crc); 179ddcaccbcSJoakim Tjernlund crc = crc32_body(crc, p, len, tab); 180ce4320ddSBob Pearson crc = __le32_to_cpu((__force __le32)crc); 1811da177e4SLinus Torvalds #endif 18260e58d5cSBob Pearson return crc; 1831da177e4SLinus Torvalds } 18446c5801eSDarrick J. Wong 18546c5801eSDarrick J. Wong #if CRC_LE_BITS == 1 1869784d82dSArd Biesheuvel u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len) 18746c5801eSDarrick J. Wong { 188e37f2f93SKrzysztof Kozlowski return crc32_le_generic(crc, p, len, NULL, CRC32_POLY_LE); 18946c5801eSDarrick J. Wong } 1909784d82dSArd Biesheuvel u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len) 19146c5801eSDarrick J. Wong { 19246c5801eSDarrick J. Wong return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE); 19346c5801eSDarrick J. Wong } 19446c5801eSDarrick J. Wong #else 1959784d82dSArd Biesheuvel u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len) 19646c5801eSDarrick J. Wong { 1978f243af4SJoe Mario return crc32_le_generic(crc, p, len, 198e37f2f93SKrzysztof Kozlowski (const u32 (*)[256])crc32table_le, CRC32_POLY_LE); 19946c5801eSDarrick J. Wong } 2009784d82dSArd Biesheuvel u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len) 20146c5801eSDarrick J. Wong { 2028f243af4SJoe Mario return crc32_le_generic(crc, p, len, 2038f243af4SJoe Mario (const u32 (*)[256])crc32ctable_le, CRC32C_POLY_LE); 20446c5801eSDarrick J. Wong } 20546c5801eSDarrick J. Wong #endif 2066d514b4eSGeorge Spelvin EXPORT_SYMBOL(crc32_le); 2076d514b4eSGeorge Spelvin EXPORT_SYMBOL(__crc32c_le); 2086d514b4eSGeorge Spelvin 209ff98e20eSMiguel Ojeda u32 __pure crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le); 210ff98e20eSMiguel Ojeda u32 __pure __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le); 2119784d82dSArd Biesheuvel 2126d514b4eSGeorge Spelvin /* 2136d514b4eSGeorge Spelvin * This multiplies the polynomials x and y modulo the given modulus. 2146d514b4eSGeorge Spelvin * This follows the "little-endian" CRC convention that the lsbit 2156d514b4eSGeorge Spelvin * represents the highest power of x, and the msbit represents x^0. 2166d514b4eSGeorge Spelvin */ 2176d514b4eSGeorge Spelvin static u32 __attribute_const__ gf2_multiply(u32 x, u32 y, u32 modulus) 2186e95fcaaSDaniel Borkmann { 2196d514b4eSGeorge Spelvin u32 product = x & 1 ? y : 0; 2206d514b4eSGeorge Spelvin int i; 2216d514b4eSGeorge Spelvin 2226d514b4eSGeorge Spelvin for (i = 0; i < 31; i++) { 2236d514b4eSGeorge Spelvin product = (product >> 1) ^ (product & 1 ? modulus : 0); 2246d514b4eSGeorge Spelvin x >>= 1; 2256d514b4eSGeorge Spelvin product ^= x & 1 ? y : 0; 2266e95fcaaSDaniel Borkmann } 2276e95fcaaSDaniel Borkmann 2286d514b4eSGeorge Spelvin return product; 2296e95fcaaSDaniel Borkmann } 2306d514b4eSGeorge Spelvin 2316d514b4eSGeorge Spelvin /** 2328a29896aSRandy Dunlap * crc32_generic_shift - Append @len 0 bytes to crc, in logarithmic time 2336d514b4eSGeorge Spelvin * @crc: The original little-endian CRC (i.e. lsbit is x^31 coefficient) 2346d514b4eSGeorge Spelvin * @len: The number of bytes. @crc is multiplied by x^(8*@len) 2356d514b4eSGeorge Spelvin * @polynomial: The modulus used to reduce the result to 32 bits. 2366d514b4eSGeorge Spelvin * 2376d514b4eSGeorge Spelvin * It's possible to parallelize CRC computations by computing a CRC 2386d514b4eSGeorge Spelvin * over separate ranges of a buffer, then summing them. 2396d514b4eSGeorge Spelvin * This shifts the given CRC by 8*len bits (i.e. produces the same effect 2406d514b4eSGeorge Spelvin * as appending len bytes of zero to the data), in time proportional 2416d514b4eSGeorge Spelvin * to log(len). 2426d514b4eSGeorge Spelvin */ 2436d514b4eSGeorge Spelvin static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len, 2446d514b4eSGeorge Spelvin u32 polynomial) 2456d514b4eSGeorge Spelvin { 2466d514b4eSGeorge Spelvin u32 power = polynomial; /* CRC of x^32 */ 2476d514b4eSGeorge Spelvin int i; 2486d514b4eSGeorge Spelvin 2496d514b4eSGeorge Spelvin /* Shift up to 32 bits in the simple linear way */ 2506d514b4eSGeorge Spelvin for (i = 0; i < 8 * (int)(len & 3); i++) 2516d514b4eSGeorge Spelvin crc = (crc >> 1) ^ (crc & 1 ? polynomial : 0); 2526d514b4eSGeorge Spelvin 2536d514b4eSGeorge Spelvin len >>= 2; 2546d514b4eSGeorge Spelvin if (!len) 2556d514b4eSGeorge Spelvin return crc; 2566d514b4eSGeorge Spelvin 2576d514b4eSGeorge Spelvin for (;;) { 2586d514b4eSGeorge Spelvin /* "power" is x^(2^i), modulo the polynomial */ 2596d514b4eSGeorge Spelvin if (len & 1) 2606d514b4eSGeorge Spelvin crc = gf2_multiply(crc, power, polynomial); 2616d514b4eSGeorge Spelvin 2626d514b4eSGeorge Spelvin len >>= 1; 2636d514b4eSGeorge Spelvin if (!len) 2646d514b4eSGeorge Spelvin break; 2656d514b4eSGeorge Spelvin 2666d514b4eSGeorge Spelvin /* Square power, advancing to x^(2^(i+1)) */ 2676d514b4eSGeorge Spelvin power = gf2_multiply(power, power, polynomial); 2686d514b4eSGeorge Spelvin } 2696d514b4eSGeorge Spelvin 2706d514b4eSGeorge Spelvin return crc; 2716d514b4eSGeorge Spelvin } 2726d514b4eSGeorge Spelvin 2736d514b4eSGeorge Spelvin u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len) 2746d514b4eSGeorge Spelvin { 275e37f2f93SKrzysztof Kozlowski return crc32_generic_shift(crc, len, CRC32_POLY_LE); 2766d514b4eSGeorge Spelvin } 2776d514b4eSGeorge Spelvin 2786d514b4eSGeorge Spelvin u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len) 2796d514b4eSGeorge Spelvin { 2806d514b4eSGeorge Spelvin return crc32_generic_shift(crc, len, CRC32C_POLY_LE); 2816d514b4eSGeorge Spelvin } 2826d514b4eSGeorge Spelvin EXPORT_SYMBOL(crc32_le_shift); 2836d514b4eSGeorge Spelvin EXPORT_SYMBOL(__crc32c_le_shift); 2841da177e4SLinus Torvalds 2852f72100cSRandy Dunlap /** 286f2e1d2acSGu Zheng * crc32_be_generic() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32 2872f72100cSRandy Dunlap * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for 2882f72100cSRandy Dunlap * other uses, or the previous crc32 value if computing incrementally. 289f2e1d2acSGu Zheng * @p: pointer to buffer over which CRC32 is run 2902f72100cSRandy Dunlap * @len: length of buffer @p 291f2e1d2acSGu Zheng * @tab: big-endian Ethernet table 292f2e1d2acSGu Zheng * @polynomial: CRC32 BE polynomial 2932f72100cSRandy Dunlap */ 29446c5801eSDarrick J. Wong static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p, 29546c5801eSDarrick J. Wong size_t len, const u32 (*tab)[256], 29646c5801eSDarrick J. Wong u32 polynomial) 2971da177e4SLinus Torvalds { 29860e58d5cSBob Pearson #if CRC_BE_BITS == 1 2991da177e4SLinus Torvalds int i; 3001da177e4SLinus Torvalds while (len--) { 3011da177e4SLinus Torvalds crc ^= *p++ << 24; 3021da177e4SLinus Torvalds for (i = 0; i < 8; i++) 3031da177e4SLinus Torvalds crc = 30446c5801eSDarrick J. Wong (crc << 1) ^ ((crc & 0x80000000) ? polynomial : 3051da177e4SLinus Torvalds 0); 3061da177e4SLinus Torvalds } 30760e58d5cSBob Pearson # elif CRC_BE_BITS == 2 30860e58d5cSBob Pearson while (len--) { 30960e58d5cSBob Pearson crc ^= *p++ << 24; 31046c5801eSDarrick J. Wong crc = (crc << 2) ^ tab[0][crc >> 30]; 31146c5801eSDarrick J. Wong crc = (crc << 2) ^ tab[0][crc >> 30]; 31246c5801eSDarrick J. Wong crc = (crc << 2) ^ tab[0][crc >> 30]; 31346c5801eSDarrick J. Wong crc = (crc << 2) ^ tab[0][crc >> 30]; 3141da177e4SLinus Torvalds } 31560e58d5cSBob Pearson # elif CRC_BE_BITS == 4 31660e58d5cSBob Pearson while (len--) { 31760e58d5cSBob Pearson crc ^= *p++ << 24; 31846c5801eSDarrick J. Wong crc = (crc << 4) ^ tab[0][crc >> 28]; 31946c5801eSDarrick J. Wong crc = (crc << 4) ^ tab[0][crc >> 28]; 32060e58d5cSBob Pearson } 32160e58d5cSBob Pearson # elif CRC_BE_BITS == 8 3229a1dbf6aSBob Pearson while (len--) { 3239a1dbf6aSBob Pearson crc ^= *p++ << 24; 32446c5801eSDarrick J. Wong crc = (crc << 8) ^ tab[0][crc >> 24]; 3259a1dbf6aSBob Pearson } 3269a1dbf6aSBob Pearson # else 327ce4320ddSBob Pearson crc = (__force u32) __cpu_to_be32(crc); 328ddcaccbcSJoakim Tjernlund crc = crc32_body(crc, p, len, tab); 329ce4320ddSBob Pearson crc = __be32_to_cpu((__force __be32)crc); 3301da177e4SLinus Torvalds # endif 33160e58d5cSBob Pearson return crc; 3321da177e4SLinus Torvalds } 33346c5801eSDarrick J. Wong 33446c5801eSDarrick J. Wong #if CRC_LE_BITS == 1 33546c5801eSDarrick J. Wong u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len) 33646c5801eSDarrick J. Wong { 337e37f2f93SKrzysztof Kozlowski return crc32_be_generic(crc, p, len, NULL, CRC32_POLY_BE); 33846c5801eSDarrick J. Wong } 33946c5801eSDarrick J. Wong #else 34046c5801eSDarrick J. Wong u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len) 34146c5801eSDarrick J. Wong { 3428f243af4SJoe Mario return crc32_be_generic(crc, p, len, 343e37f2f93SKrzysztof Kozlowski (const u32 (*)[256])crc32table_be, CRC32_POLY_BE); 34446c5801eSDarrick J. Wong } 34546c5801eSDarrick J. Wong #endif 3461da177e4SLinus Torvalds EXPORT_SYMBOL(crc32_be); 347