Lines Matching full:crc

58 crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256])  argument
61 # define DO_CRC(x) crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8)
67 # define DO_CRC(x) crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)
106 q = crc ^ *++b; /* use pre increment for speed */
108 crc = DO_CRC4;
110 crc = DO_CRC8;
112 crc ^= DO_CRC4;
128 return crc;
139 * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for other
146 static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p, argument
153 crc ^= *p++;
155 crc = (crc >> 1) ^ ((crc & 1) ? polynomial : 0);
159 crc ^= *p++;
160 crc = (crc >> 2) ^ tab[0][crc & 3];
161 crc = (crc >> 2) ^ tab[0][crc & 3];
162 crc = (crc >> 2) ^ tab[0][crc & 3];
163 crc = (crc >> 2) ^ tab[0][crc & 3];
167 crc ^= *p++;
168 crc = (crc >> 4) ^ tab[0][crc & 15];
169 crc = (crc >> 4) ^ tab[0][crc & 15];
174 crc ^= *p++;
175 crc = (crc >> 8) ^ tab[0][crc & 255];
178 crc = (__force u32) __cpu_to_le32(crc);
179 crc = crc32_body(crc, p, len, tab);
180 crc = __le32_to_cpu((__force __le32)crc);
182 return crc;
186 u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len) argument
188 return crc32_le_generic(crc, p, len, NULL, CRC32_POLY_LE);
190 u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len) argument
192 return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE);
195 u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len) argument
197 return crc32_le_generic(crc, p, len, crc32table_le, CRC32_POLY_LE);
199 u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len) argument
201 return crc32_le_generic(crc, p, len, crc32ctable_le, CRC32C_POLY_LE);
213 * This follows the "little-endian" CRC convention that the lsbit
231 * crc32_generic_shift - Append @len 0 bytes to crc, in logarithmic time
232 * @crc: The original little-endian CRC (i.e. lsbit is x^31 coefficient)
233 * @len: The number of bytes. @crc is multiplied by x^(8*@len)
236 * It's possible to parallelize CRC computations by computing a CRC
238 * This shifts the given CRC by 8*len bits (i.e. produces the same effect
242 static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len, argument
245 u32 power = polynomial; /* CRC of x^32 */
250 crc = (crc >> 1) ^ (crc & 1 ? polynomial : 0);
254 return crc;
259 crc = gf2_multiply(crc, power, polynomial);
269 return crc;
272 u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len) argument
274 return crc32_generic_shift(crc, len, CRC32_POLY_LE);
277 u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len) argument
279 return crc32_generic_shift(crc, len, CRC32C_POLY_LE);
286 * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for
293 static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p, argument
300 crc ^= *p++ << 24;
302 crc =
303 (crc << 1) ^ ((crc & 0x80000000) ? polynomial :
308 crc ^= *p++ << 24;
309 crc = (crc << 2) ^ tab[0][crc >> 30];
310 crc = (crc << 2) ^ tab[0][crc >> 30];
311 crc = (crc << 2) ^ tab[0][crc >> 30];
312 crc = (crc << 2) ^ tab[0][crc >> 30];
316 crc ^= *p++ << 24;
317 crc = (crc << 4) ^ tab[0][crc >> 28];
318 crc = (crc << 4) ^ tab[0][crc >> 28];
322 crc ^= *p++ << 24;
323 crc = (crc << 8) ^ tab[0][crc >> 24];
326 crc = (__force u32) __cpu_to_be32(crc);
327 crc = crc32_body(crc, p, len, tab);
328 crc = __be32_to_cpu((__force __be32)crc);
330 return crc;
334 u32 __pure __weak crc32_be(u32 crc, unsigned char const *p, size_t len) argument
336 return crc32_be_generic(crc, p, len, NULL, CRC32_POLY_BE);
339 u32 __pure __weak crc32_be(u32 crc, unsigned char const *p, size_t len) argument
341 return crc32_be_generic(crc, p, len, crc32table_be, CRC32_POLY_BE);