Lines Matching full:crc

3  * Unit tests and benchmarks for the CRC library functions
11 #include <linux/crc-t10dif.h>
27 * struct crc_variant - describes a CRC variant
28 * @bits: Number of bits in the CRC, 1 <= @bits <= 64.
29 * @le: true if it's a "little endian" CRC (reversed mapping between bits and
30 * polynomial coefficients in each byte), false if it's a "big endian" CRC
34 * @func: The function to compute a CRC. The type signature uses u64 so that it
35 * can fit any CRC up to CRC-64.
42 u64 (*func)(u64 crc, const u8 *p, size_t len);
63 /* Reference implementation of any CRC variant */
65 u64 crc, const u8 *p, size_t len) in crc_ref()
72 crc ^= (p[i] >> j) & 1; in crc_ref()
73 crc = (crc >> 1) ^ ((crc & 1) ? v->poly : 0); in crc_ref()
75 crc ^= (u64)((p[i] >> (7 - j)) & 1) << in crc_ref()
77 if (crc & (1ULL << (v->bits - 1))) in crc_ref()
78 crc = ((crc << 1) ^ v->poly) & in crc_ref()
81 crc <<= 1; in crc_ref()
85 return crc; in crc_ref()
111 /* Generate a random initial CRC. */
173 * Compute the CRC, and verify that it equals the CRC computed in crc_main_test()
188 /* Test that CRC(concat(A, B)) == combine_CRCs(CRC(A), CRC(B), len(B)). */
205 "CRC combination gave wrong result with len1=%zu len2=%zu\n", in crc_combine_test()
219 u64 (*crc_func)(u64 crc, const u8 *p, size_t len)) in crc_benchmark() argument
226 * Some of the CRC library functions are marked as __pure, so use in crc_benchmark()
229 volatile u64 crc = 0; in crc_benchmark() local
237 crc = crc_func(crc, test_buffer, CRC_KUNIT_MAX_LEN); in crc_benchmark()
246 crc = crc_func(crc, test_buffer, len); in crc_benchmark()
256 static u64 crc16_wrapper(u64 crc, const u8 *p, size_t len) in crc16_wrapper() argument
258 return crc16(crc, p, len); in crc16_wrapper()
280 static u64 crc_t10dif_wrapper(u64 crc, const u8 *p, size_t len) in crc_t10dif_wrapper() argument
282 return crc_t10dif_update(crc, p, len); in crc_t10dif_wrapper()
304 static u64 crc32_le_wrapper(u64 crc, const u8 *p, size_t len) in crc32_le_wrapper() argument
306 return crc32_le(crc, p, len); in crc32_le_wrapper()
334 static u64 crc32_be_wrapper(u64 crc, const u8 *p, size_t len) in crc32_be_wrapper() argument
336 return crc32_be(crc, p, len); in crc32_be_wrapper()
358 static u64 crc32c_wrapper(u64 crc, const u8 *p, size_t len) in crc32c_wrapper() argument
360 return crc32c(crc, p, len); in crc32c_wrapper()
388 static u64 crc64_be_wrapper(u64 crc, const u8 *p, size_t len) in crc64_be_wrapper() argument
390 return crc64_be(crc, p, len); in crc64_be_wrapper()
427 .name = "crc",
434 MODULE_DESCRIPTION("Unit tests and benchmarks for the CRC library functions");