1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_CRC_T10DIF_H
3 #define _LINUX_CRC_T10DIF_H
4
5 #include <linux/types.h>
6
7 #define CRC_T10DIF_DIGEST_SIZE 2
8 #define CRC_T10DIF_BLOCK_SIZE 1
9
10 u16 crc_t10dif_arch(u16 crc, const u8 *p, size_t len);
11 u16 crc_t10dif_generic(u16 crc, const u8 *p, size_t len);
12
crc_t10dif_update(u16 crc,const u8 * p,size_t len)13 static inline u16 crc_t10dif_update(u16 crc, const u8 *p, size_t len)
14 {
15 if (IS_ENABLED(CONFIG_CRC_T10DIF_ARCH))
16 return crc_t10dif_arch(crc, p, len);
17 return crc_t10dif_generic(crc, p, len);
18 }
19
crc_t10dif(const u8 * p,size_t len)20 static inline u16 crc_t10dif(const u8 *p, size_t len)
21 {
22 return crc_t10dif_update(0, p, len);
23 }
24
25 #if IS_ENABLED(CONFIG_CRC_T10DIF_ARCH)
26 bool crc_t10dif_is_optimized(void);
27 #else
crc_t10dif_is_optimized(void)28 static inline bool crc_t10dif_is_optimized(void)
29 {
30 return false;
31 }
32 #endif
33
34 #endif
35