1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2016 ARM Ltd.
5 #ifndef __ASM_CHECKSUM_H
6 #define __ASM_CHECKSUM_H
8 #include <linux/types.h>
10 static inline __sum16
csum_fold(__wsum csum
)
12 u32 sum
= (__force u32
)csum
;
13 sum
+= (sum
>> 16) | (sum
<< 16);
14 return ~(__force __sum16
)(sum
>> 16);
16 #define csum_fold csum_fold
18 static inline __sum16
ip_fast_csum(const void *iph
, unsigned int ihl
)
23 tmp
= *(const __uint128_t
*)iph
;
26 tmp
+= ((tmp
>> 64) | (tmp
<< 64));
29 sum
+= *(const u32
*)iph
;
33 sum
+= ((sum
>> 32) | (sum
<< 32));
34 return csum_fold((__force u32
)(sum
>> 32));
36 #define ip_fast_csum ip_fast_csum
38 extern unsigned int do_csum(const unsigned char *buff
, int len
);
39 #define do_csum do_csum
41 #include <asm-generic/checksum.h>
43 #endif /* __ASM_CHECKSUM_H */