Lines Matching full:crc

5  * This file is a "template" that generates a CRC function optimized using the
7 * file must define the following parameters to specify the type of CRC:
9 * crc_t: the data type of the CRC, e.g. u32 for a 32-bit CRC
10 * LSB_CRC: 0 for a msb (most-significant-bit) first CRC, i.e. natural
12 * 1 for a lsb (least-significant-bit) first CRC, i.e. reflected
59 * polynomial whose bit order matches the CRC's bit order.
75 /* XOR @crc into the end of @msgpoly that represents the high-order terms. */
77 crc_clmul_prep(crc_t crc, unsigned long msgpoly) in crc_clmul_prep() argument
80 return msgpoly ^ crc; in crc_clmul_prep()
82 return msgpoly ^ ((unsigned long)crc << (BITS_PER_LONG - CRC_BITS)); in crc_clmul_prep()
88 * modulo the generator polynomial G. This gives the CRC of @msgpoly.
126 * crc := (msgpoly * x^n) + (G * floor((msgpoly * x^n) / G)) in crc_clmul_long()
133 * crc := ((G - x^n) * floor((msgpoly * x^n) / G)) mod x^n in crc_clmul_long()
136 * a shift, as the crc ends up in the physically low n bits from clmulr: in crc_clmul_long()
139 * crc := floor(product / x^(BITS_PER_LONG + 1 - n)) mod x^n in crc_clmul_long()
152 /* Update @crc with the data from @msgpoly. */
154 crc_clmul_update_long(crc_t crc, unsigned long msgpoly, in crc_clmul_update_long() argument
157 return crc_clmul_long(crc_clmul_prep(crc, msgpoly), consts); in crc_clmul_update_long()
160 /* Update @crc with 1 <= @len < sizeof(unsigned long) bytes of data. */
162 crc_clmul_update_partial(crc_t crc, const u8 *p, size_t len, in crc_clmul_update_partial() argument
180 msgpoly ^= (unsigned long)crc << (BITS_PER_LONG - 8*len); in crc_clmul_update_partial()
182 msgpoly ^= (unsigned long)crc << (8*len - CRC_BITS); in crc_clmul_update_partial()
187 msgpoly ^= (unsigned long)crc << (BITS_PER_LONG - 8*len); in crc_clmul_update_partial()
188 return crc_clmul_long(msgpoly, consts) ^ (crc >> (8*len)); in crc_clmul_update_partial()
190 msgpoly ^= crc >> (CRC_BITS - 8*len); in crc_clmul_update_partial()
191 return crc_clmul_long(msgpoly, consts) ^ (crc << (8*len)); in crc_clmul_update_partial()
196 crc_clmul(crc_t crc, const void *p, size_t len, in crc_clmul() argument
201 /* This implementation assumes that the CRC fits in an unsigned long. */ in crc_clmul()
208 crc = crc_clmul_update_partial(crc, p, align, consts); in crc_clmul()
216 m0 = crc_clmul_prep(crc, crc_load_long(p)); in crc_clmul()
251 crc = crc_clmul_long(m0, consts); in crc_clmul()
252 crc = crc_clmul_update_long(crc, m1, consts); in crc_clmul()
256 crc = crc_clmul_update_long(crc, crc_load_long(p), consts); in crc_clmul()
262 crc = crc_clmul_update_partial(crc, p, len, consts); in crc_clmul()
264 return crc; in crc_clmul()