|
XenevaOS
|

Go to the source code of this file.
Macros | |
| #define | CRC32_LE_OPTIMIZATION BIT(0) /* crc32_le() is optimized */ |
| #define | CRC32_BE_OPTIMIZATION BIT(1) /* crc32_be() is optimized */ |
| #define | CRC32C_OPTIMIZATION BIT(2) /* crc32c() is optimized */ |
| #define | ether_crc(length, data) bitrev32(crc32_le(~0, data, length)) |
| #define | ether_crc_le(length, data) crc32_le(~0, data, length) |
Functions | |
| u32 | crc32_le (u32 crc, const void *p, size_t len) |
| u32 | crc32_be (u32 crc, const void *p, size_t len) |
| u32 | crc32c (u32 crc, const void *p, size_t len) |
crc32_be() - Compute most-significant-bit-first IEEE CRC-32 @crc: Initial CRC value. ~0 (recommended) or 0 for a new CRC computation, or the previous CRC value if computing incrementally. : Pointer to the data buffer @len: Length of data in bytes
crc32_be() is the same as crc32_le() except that crc32_be() computes the most-significant-bit-first variant of the CRC. I.e., within each byte, the most significant bit is processed first (treated as highest order polynomial coefficient). The same bit order is also used for the CRC value itself:
Context: Any context Return: The new CRC value
crc32_le() - Compute least-significant-bit-first IEEE CRC-32 @crc: Initial CRC value. ~0 (recommended) or 0 for a new CRC computation, or the previous CRC value if computing incrementally. : Pointer to the data buffer @len: Length of data in bytes
This implements the CRC variant that is often known as the IEEE CRC-32, or simply CRC-32, and is widely used in Ethernet and other applications:
This does not invert the CRC at the beginning or end. The caller is expected to do that if it needs to. Inverting at both ends is recommended.
For new applications, prefer to use CRC-32C instead. See crc32c().
Context: Any context Return: The new CRC value
crc32c() - Compute CRC-32C @crc: Initial CRC value. ~0 (recommended) or 0 for a new CRC computation, or the previous CRC value if computing incrementally. : Pointer to the data buffer @len: Length of data in bytes
This implements CRC-32C, i.e. the Castagnoli CRC. This is the recommended CRC variant to use in new applications that want a 32-bit CRC.
This does not invert the CRC at the beginning or end. The caller is expected to do that if it needs to. Inverting at both ends is recommended.
Context: Any context Return: The new CRC value