Lines Matching full:crc
56 * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for
58 * @p: pointer to buffer over which CRC is run
61 u32 crc32_le(u32 crc, unsigned char const *p, size_t len);
69 u32 crc32_le(u32 crc, unsigned char const *p, size_t len) in crc32_le() argument
73 crc ^= *p++; in crc32_le()
75 crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); in crc32_le()
77 return crc; in crc32_le()
81 u32 crc32_le(u32 crc, unsigned char const *p, size_t len) in crc32_le() argument
88 # define DO_CRC(x) crc = tab[ (crc ^ (x)) & 255 ] ^ (crc>>8) in crc32_le()
90 # define DO_CRC(x) crc = tab[ ((crc >> 24) ^ (x)) & 255] ^ (crc<<8) in crc32_le()
92 /* printf("Crc32_le crc=%x\n",crc); */ in crc32_le()
93 crc = __cpu_to_le32(crc); in crc32_le()
108 crc ^= *++b; in crc32_le()
126 return __le32_to_cpu(crc); in crc32_le()
132 crc ^= *p++; in crc32_le()
133 crc = (crc >> 4) ^ crc32table_le[crc & 15]; in crc32_le()
134 crc = (crc >> 4) ^ crc32table_le[crc & 15]; in crc32_le()
136 return crc; in crc32_le()
139 crc ^= *p++; in crc32_le()
140 crc = (crc >> 2) ^ crc32table_le[crc & 3]; in crc32_le()
141 crc = (crc >> 2) ^ crc32table_le[crc & 3]; in crc32_le()
142 crc = (crc >> 2) ^ crc32table_le[crc & 3]; in crc32_le()
143 crc = (crc >> 2) ^ crc32table_le[crc & 3]; in crc32_le()
145 return crc; in crc32_le()
152 * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for
154 * @p: pointer to buffer over which CRC is run
157 u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len);
165 u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len) in crc32_be() argument
169 crc ^= *p++ << 24; in crc32_be()
171 crc = in crc32_be()
172 (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : in crc32_be()
175 return crc; in crc32_be()
179 u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len) in crc32_be() argument
186 # define DO_CRC(x) crc = tab[ (crc ^ (x)) & 255 ] ^ (crc>>8) in crc32_be()
188 # define DO_CRC(x) crc = tab[ ((crc >> 24) ^ (x)) & 255] ^ (crc<<8) in crc32_be()
191 crc = __cpu_to_be32(crc); in crc32_be()
206 crc ^= *++b; in crc32_be()
223 return __be32_to_cpu(crc); in crc32_be()
229 crc ^= *p++ << 24; in crc32_be()
230 crc = (crc << 4) ^ crc32table_be[crc >> 28]; in crc32_be()
231 crc = (crc << 4) ^ crc32table_be[crc >> 28]; in crc32_be()
233 return crc; in crc32_be()
236 crc ^= *p++ << 24; in crc32_be()
237 crc = (crc << 2) ^ crc32table_be[crc >> 30]; in crc32_be()
238 crc = (crc << 2) ^ crc32table_be[crc >> 30]; in crc32_be()
239 crc = (crc << 2) ^ crc32table_be[crc >> 30]; in crc32_be()
240 crc = (crc << 2) ^ crc32table_be[crc >> 30]; in crc32_be()
242 return crc; in crc32_be()
251 * A brief CRC tutorial.
253 * A CRC is a long-division remainder. You add the CRC to the message,
254 * and the whole thing (message+CRC) is a multiple of the given
255 * CRC polynomial. To check the CRC, you can either check that the
256 * CRC matches the recomputed value, *or* you can check that the
257 * remainder computed on the message+CRC is 0. This latter approach
259 * protocols put the end-of-frame flag after the CRC.
267 * A 32-bit CRC polynomial is actually 33 bits long. But since it's
268 * 33 bits long, bit 32 is always going to be set, so usually the CRC
272 * Note that a CRC is computed over a string of *bits*, so you have
277 * is sent last. And when appending a CRC word to a message, you should
281 * the divisor (the CRC polynomial) you're dividing by. Each step of the
288 * When computing a CRC, we don't care about the quotient, so we can
293 * A big-endian CRC written this way would be coded like:
304 * Also, to add the CRC to a message, we need a 32-bit-long hole for it at
310 * and merging in the final 32 zero bits to make room for the CRC can be
362 * generator polynomial. This is simply the CRC-32 of the given
367 * polynomial. To enable a CRC to detect this condition, it's common to
368 * invert the CRC before appending it. This makes the remainder of the
369 * message+crc come out not as zero, but some fixed non-zero value.
427 * This checks that CRC(buf + CRC(buf)) = 0, and that
428 * CRC commutes with bit-reversal. This has the side effect
430 * the CRC of the reversed buffer.
500 /* Now check that CRC(buf1 ^ buf2) = CRC(buf1) ^ CRC(buf2) */ in main()
503 printf("CRC XOR fail: 0x%08x != 0x%08x ^ 0x%08x\n", in main()