e7e7966c2dca8f2a528b20d740b3cdfedf9800ce
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / include / net / checksum.h
1 #ifndef __NET_CHECKSUM_WRAPPER_H
2 #define __NET_CHECKSUM_WRAPPER_H 1
3
4 #include_next <net/checksum.h>
5
6 #ifndef HAVE_CSUM_UNFOLD
7 static inline __wsum csum_unfold(__sum16 n)
8 {
9         return (__force __wsum)n;
10 }
11 #endif /* !HAVE_CSUM_UNFOLD */
12
13 /* Workaround for debugging included in certain versions of XenServer.  It only
14  * applies to 32-bit x86.
15  */
16 #if defined(HAVE_CSUM_COPY_DBG) && defined(CONFIG_X86_32)
17 #define csum_and_copy_to_user(src, dst, len, sum, err_ptr) \
18         csum_and_copy_to_user(src, dst, len, sum, NULL, err_ptr)
19 #endif
20
21 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
22 static inline void csum_replace4(__sum16 *sum, __be32 from, __be32 to)
23 {
24         __be32 diff[] = { ~from, to };
25
26         *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum)));
27 }
28
29 #define inet_proto_csum_replace2(sum, skb, from, to, pseudohdr) \
30         inet_proto_csum_replace4(sum, skb, (__force __be32)(from), \
31                                            (__force __be32)(to), pseudohdr)
32 #endif
33
34 #endif /* checksum.h */