XenevaOS
Loading...
Searching...
No Matches
crc32.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-only */
2#ifndef _LINUX_CRC32_H
3#define _LINUX_CRC32_H
4
5#include <linux/types.h>
6#include <linux/bitrev.h>
7
31u32 crc32_le(u32 crc, const void *p, size_t len);
32
33/* This is just an alias for crc32_le(). */
34static inline u32 crc32(u32 crc, const void *p, size_t len)
35{
36 return crc32_le(crc, p, len);
37}
38
59u32 crc32_be(u32 crc, const void *p, size_t len);
60
82u32 crc32c(u32 crc, const void *p, size_t len);
83
84/*
85 * crc32_optimizations() returns flags that indicate which CRC32 library
86 * functions are using architecture-specific optimizations. Unlike
87 * IS_ENABLED(CONFIG_CRC32_ARCH) it takes into account the different CRC32
88 * variants and also whether any needed CPU features are available at runtime.
89 */
90#define CRC32_LE_OPTIMIZATION BIT(0) /* crc32_le() is optimized */
91#define CRC32_BE_OPTIMIZATION BIT(1) /* crc32_be() is optimized */
92#define CRC32C_OPTIMIZATION BIT(2) /* crc32c() is optimized */
93#if IS_ENABLED(CONFIG_CRC32_ARCH)
94u32 crc32_optimizations(void);
95#else
96static inline u32 crc32_optimizations(void) { return 0; }
97#endif
98
99/*
100 * Helpers for hash table generation of ethernet nics:
101 *
102 * Ethernet sends the least significant bit of a byte first, thus crc32_le
103 * is used. The output of crc32_le is bit reversed [most significant bit
104 * is in bit nr 0], thus it must be reversed before use. Except for
105 * nics that bit swap the result internally...
106 */
107#define ether_crc(length, data) bitrev32(crc32_le(~0, data, length))
108#define ether_crc_le(length, data) crc32_le(~0, data, length)
109
110#endif /* _LINUX_CRC32_H */
u32 crc32_be(u32 crc, const void *p, size_t len)
u32 crc32_le(u32 crc, const void *p, size_t len)
u32 crc32c(u32 crc, const void *p, size_t len)
size_t len
Definition initial.c:23
uint32_t u32
Definition kernel.h:16
#define crc32
Definition miniz.h:508