This source file includes following definitions.
- csum_fold
- ip_fast_csum
- csum_tcpudp_nofold
- csum_tcpudp_magic
- ip_compute_csum
- csum_ipv6_magic
1
2
3
4
5
6
7
8
9
10 #ifndef __ASM_ARM_CHECKSUM_H
11 #define __ASM_ARM_CHECKSUM_H
12
13 #include <linux/in6.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27 __wsum csum_partial(const void *buff, int len, __wsum sum);
28
29
30
31
32
33
34
35
36
37 __wsum
38 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
39
40 __wsum
41 csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
42
43
44
45
46 static inline __sum16 csum_fold(__wsum sum)
47 {
48 __asm__(
49 "add %0, %1, %1, ror #16 @ csum_fold"
50 : "=r" (sum)
51 : "r" (sum)
52 : "cc");
53 return (__force __sum16)(~(__force u32)sum >> 16);
54 }
55
56
57
58
59
60 static inline __sum16
61 ip_fast_csum(const void *iph, unsigned int ihl)
62 {
63 unsigned int tmp1;
64 __wsum sum;
65
66 __asm__ __volatile__(
67 "ldr %0, [%1], #4 @ ip_fast_csum \n\
68 ldr %3, [%1], #4 \n\
69 sub %2, %2, #5 \n\
70 adds %0, %0, %3 \n\
71 ldr %3, [%1], #4 \n\
72 adcs %0, %0, %3 \n\
73 ldr %3, [%1], #4 \n\
74 1: adcs %0, %0, %3 \n\
75 ldr %3, [%1], #4 \n\
76 tst %2, #15 @ do this carefully \n\
77 subne %2, %2, #1 @ without destroying \n\
78 bne 1b @ the carry flag \n\
79 adcs %0, %0, %3 \n\
80 adc %0, %0, #0"
81 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1)
82 : "1" (iph), "2" (ihl)
83 : "cc", "memory");
84 return csum_fold(sum);
85 }
86
87 static inline __wsum
88 csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
89 __u8 proto, __wsum sum)
90 {
91 u32 lenprot = len + proto;
92 if (__builtin_constant_p(sum) && sum == 0) {
93 __asm__(
94 "adds %0, %1, %2 @ csum_tcpudp_nofold0 \n\t"
95 #ifdef __ARMEB__
96 "adcs %0, %0, %3 \n\t"
97 #else
98 "adcs %0, %0, %3, ror #8 \n\t"
99 #endif
100 "adc %0, %0, #0"
101 : "=&r" (sum)
102 : "r" (daddr), "r" (saddr), "r" (lenprot)
103 : "cc");
104 } else {
105 __asm__(
106 "adds %0, %1, %2 @ csum_tcpudp_nofold \n\t"
107 "adcs %0, %0, %3 \n\t"
108 #ifdef __ARMEB__
109 "adcs %0, %0, %4 \n\t"
110 #else
111 "adcs %0, %0, %4, ror #8 \n\t"
112 #endif
113 "adc %0, %0, #0"
114 : "=&r"(sum)
115 : "r" (sum), "r" (daddr), "r" (saddr), "r" (lenprot)
116 : "cc");
117 }
118 return sum;
119 }
120
121
122
123
124 static inline __sum16
125 csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
126 __u8 proto, __wsum sum)
127 {
128 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
129 }
130
131
132
133
134
135
136 static inline __sum16
137 ip_compute_csum(const void *buff, int len)
138 {
139 return csum_fold(csum_partial(buff, len, 0));
140 }
141
142 #define _HAVE_ARCH_IPV6_CSUM
143 extern __wsum
144 __csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __be32 len,
145 __be32 proto, __wsum sum);
146
147 static inline __sum16
148 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
149 __u32 len, __u8 proto, __wsum sum)
150 {
151 return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
152 htonl(proto), sum));
153 }
154 #endif