Lines Matching full:crc

3  * Unit tests and benchmarks for the CRC library functions
13 #include <linux/crc-t10dif.h>
29 * struct crc_variant - describes a CRC variant
30 * @bits: Number of bits in the CRC, 1 <= @bits <= 64.
31 * @le: true if it's a "little endian" CRC (reversed mapping between bits and
32 * polynomial coefficients in each byte), false if it's a "big endian" CRC
36 * @func: The function to compute a CRC. The type signature uses u64 so that it
37 * can fit any CRC up to CRC-64. The CRC is passed in, and is expected
39 * function is expected to *not* invert the CRC at the beginning and end.
45 u64 (*func)(u64 crc, const u8 *p, size_t len);
65 /* Reference implementation of any CRC variant */
67 u64 crc, const u8 *p, size_t len) in crc_ref()
74 crc ^= (p[i] >> j) & 1; in crc_ref()
75 crc = (crc >> 1) ^ ((crc & 1) ? v->poly : 0); in crc_ref()
77 crc ^= (u64)((p[i] >> (7 - j)) & 1) << in crc_ref()
79 if (crc & (1ULL << (v->bits - 1))) in crc_ref()
80 crc = ((crc << 1) ^ v->poly) & in crc_ref()
83 crc <<= 1; in crc_ref()
87 return crc; in crc_ref()
113 /* Generate a random initial CRC. */
156 * Compute the CRC of one of the test messages and verify that it matches the
157 * expected CRC from @state->expected_crcs. To increase the chance of detecting
220 * Compute the CRC, and verify that it equals the CRC computed in crc_test()
235 u64 (*crc_func)(u64 crc, const u8 *p, size_t len)) in crc_benchmark() argument
242 * The CRC value that this function computes in a series of calls to in crc_benchmark()
246 volatile u64 crc = 0; in crc_benchmark() local
254 crc = crc_func(crc, test_buffer, CRC_KUNIT_MAX_LEN); in crc_benchmark()
263 crc = crc_func(crc, test_buffer, len); in crc_benchmark()
273 static u64 crc7_be_wrapper(u64 crc, const u8 *p, size_t len) in crc7_be_wrapper() argument
276 * crc7_be() left-aligns the 7-bit CRC in a u8, whereas the test wants a in crc7_be_wrapper()
277 * right-aligned CRC (in a u64). Convert between the conventions. in crc7_be_wrapper()
279 return crc7_be(crc << 1, p, len) >> 1; in crc7_be_wrapper()
300 static u64 crc16_wrapper(u64 crc, const u8 *p, size_t len) in crc16_wrapper() argument
302 return crc16(crc, p, len); in crc16_wrapper()
324 static u64 crc_t10dif_wrapper(u64 crc, const u8 *p, size_t len) in crc_t10dif_wrapper() argument
326 return crc_t10dif_update(crc, p, len); in crc_t10dif_wrapper()
348 static u64 crc32_le_wrapper(u64 crc, const u8 *p, size_t len) in crc32_le_wrapper() argument
350 return crc32_le(crc, p, len); in crc32_le_wrapper()
372 static u64 crc32_be_wrapper(u64 crc, const u8 *p, size_t len) in crc32_be_wrapper() argument
374 return crc32_be(crc, p, len); in crc32_be_wrapper()
396 static u64 crc32c_wrapper(u64 crc, const u8 *p, size_t len) in crc32c_wrapper() argument
398 return crc32c(crc, p, len); in crc32c_wrapper()
420 static u64 crc64_be_wrapper(u64 crc, const u8 *p, size_t len) in crc64_be_wrapper() argument
422 return crc64_be(crc, p, len); in crc64_be_wrapper()
444 static u64 crc64_nvme_wrapper(u64 crc, const u8 *p, size_t len) in crc64_nvme_wrapper() argument
447 return ~crc64_nvme(~crc, p, len); in crc64_nvme_wrapper()
488 .name = "crc",
495 MODULE_DESCRIPTION("Unit tests and benchmarks for the CRC library functions");