diff options
Diffstat (limited to 'include/asm-sh/checksum.h')
-rw-r--r-- | include/asm-sh/checksum.h | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/include/asm-sh/checksum.h b/include/asm-sh/checksum.h index d44344c88e73..4bc8357e8892 100644 --- a/include/asm-sh/checksum.h +++ b/include/asm-sh/checksum.h | |||
@@ -34,25 +34,26 @@ asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum); | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst, | 36 | asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst, |
37 | int len, __wsum sum, int *src_err_ptr, int *dst_err_ptr); | 37 | int len, __wsum sum, |
38 | int *src_err_ptr, int *dst_err_ptr); | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Note: when you get a NULL pointer exception here this means someone | 41 | * Note: when you get a NULL pointer exception here this means someone |
41 | * passed in an incorrect kernel address to one of these functions. | 42 | * passed in an incorrect kernel address to one of these functions. |
42 | * | 43 | * |
43 | * If you use these functions directly please don't forget the | 44 | * If you use these functions directly please don't forget the |
44 | * access_ok(). | 45 | * access_ok(). |
45 | */ | 46 | */ |
46 | static __inline__ | 47 | static inline |
47 | __wsum csum_partial_copy_nocheck(const void *src, void *dst, | 48 | __wsum csum_partial_copy_nocheck(const void *src, void *dst, |
48 | int len, __wsum sum) | 49 | int len, __wsum sum) |
49 | { | 50 | { |
50 | return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); | 51 | return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL); |
51 | } | 52 | } |
52 | 53 | ||
53 | static __inline__ | 54 | static inline |
54 | __wsum csum_partial_copy_from_user(const void __user *src, void *dst, | 55 | __wsum csum_partial_copy_from_user(const void __user *src, void *dst, |
55 | int len, __wsum sum, int *err_ptr) | 56 | int len, __wsum sum, int *err_ptr) |
56 | { | 57 | { |
57 | return csum_partial_copy_generic((__force const void *)src, dst, | 58 | return csum_partial_copy_generic((__force const void *)src, dst, |
58 | len, sum, err_ptr, NULL); | 59 | len, sum, err_ptr, NULL); |
@@ -62,7 +63,7 @@ __wsum csum_partial_copy_from_user(const void __user *src, void *dst, | |||
62 | * Fold a partial checksum | 63 | * Fold a partial checksum |
63 | */ | 64 | */ |
64 | 65 | ||
65 | static __inline__ __sum16 csum_fold(__wsum sum) | 66 | static inline __sum16 csum_fold(__wsum sum) |
66 | { | 67 | { |
67 | unsigned int __dummy; | 68 | unsigned int __dummy; |
68 | __asm__("swap.w %0, %1\n\t" | 69 | __asm__("swap.w %0, %1\n\t" |
@@ -85,7 +86,7 @@ static __inline__ __sum16 csum_fold(__wsum sum) | |||
85 | * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted | 86 | * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted |
86 | * for linux by * Arnt Gulbrandsen. | 87 | * for linux by * Arnt Gulbrandsen. |
87 | */ | 88 | */ |
88 | static __inline__ __sum16 ip_fast_csum(const void *iph, unsigned int ihl) | 89 | static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) |
89 | { | 90 | { |
90 | unsigned int sum, __dummy0, __dummy1; | 91 | unsigned int sum, __dummy0, __dummy1; |
91 | 92 | ||
@@ -113,10 +114,10 @@ static __inline__ __sum16 ip_fast_csum(const void *iph, unsigned int ihl) | |||
113 | return csum_fold(sum); | 114 | return csum_fold(sum); |
114 | } | 115 | } |
115 | 116 | ||
116 | static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, | 117 | static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, |
117 | unsigned short len, | 118 | unsigned short len, |
118 | unsigned short proto, | 119 | unsigned short proto, |
119 | __wsum sum) | 120 | __wsum sum) |
120 | { | 121 | { |
121 | #ifdef __LITTLE_ENDIAN__ | 122 | #ifdef __LITTLE_ENDIAN__ |
122 | unsigned long len_proto = (proto + len) << 8; | 123 | unsigned long len_proto = (proto + len) << 8; |
@@ -132,6 +133,7 @@ static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, | |||
132 | : "=r" (sum), "=r" (len_proto) | 133 | : "=r" (sum), "=r" (len_proto) |
133 | : "r" (daddr), "r" (saddr), "1" (len_proto), "0" (sum) | 134 | : "r" (daddr), "r" (saddr), "1" (len_proto), "0" (sum) |
134 | : "t"); | 135 | : "t"); |
136 | |||
135 | return sum; | 137 | return sum; |
136 | } | 138 | } |
137 | 139 | ||
@@ -139,30 +141,28 @@ static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, | |||
139 | * computes the checksum of the TCP/UDP pseudo-header | 141 | * computes the checksum of the TCP/UDP pseudo-header |
140 | * returns a 16-bit checksum, already complemented | 142 | * returns a 16-bit checksum, already complemented |
141 | */ | 143 | */ |
142 | static __inline__ __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, | 144 | static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, |
143 | unsigned short len, | 145 | unsigned short len, |
144 | unsigned short proto, | 146 | unsigned short proto, |
145 | __wsum sum) | 147 | __wsum sum) |
146 | { | 148 | { |
147 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | 149 | return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); |
148 | } | 150 | } |
149 | 151 | ||
150 | /* | 152 | /* |
151 | * this routine is used for miscellaneous IP-like checksums, mainly | 153 | * this routine is used for miscellaneous IP-like checksums, mainly |
152 | * in icmp.c | 154 | * in icmp.c |
153 | */ | 155 | */ |
154 | 156 | static inline __sum16 ip_compute_csum(const void *buff, int len) | |
155 | static __inline__ __sum16 ip_compute_csum(const void *buff, int len) | ||
156 | { | 157 | { |
157 | return csum_fold (csum_partial(buff, len, 0)); | 158 | return csum_fold(csum_partial(buff, len, 0)); |
158 | } | 159 | } |
159 | 160 | ||
160 | #define _HAVE_ARCH_IPV6_CSUM | 161 | #define _HAVE_ARCH_IPV6_CSUM |
161 | #ifdef CONFIG_IPV6 | 162 | static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr, |
162 | static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, | 163 | const struct in6_addr *daddr, |
163 | const struct in6_addr *daddr, | 164 | __u32 len, unsigned short proto, |
164 | __u32 len, unsigned short proto, | 165 | __wsum sum) |
165 | __wsum sum) | ||
166 | { | 166 | { |
167 | unsigned int __dummy; | 167 | unsigned int __dummy; |
168 | __asm__("clrt\n\t" | 168 | __asm__("clrt\n\t" |
@@ -187,22 +187,21 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, | |||
187 | "movt %1\n\t" | 187 | "movt %1\n\t" |
188 | "add %1, %0\n" | 188 | "add %1, %0\n" |
189 | : "=r" (sum), "=&r" (__dummy) | 189 | : "=r" (sum), "=&r" (__dummy) |
190 | : "r" (saddr), "r" (daddr), | 190 | : "r" (saddr), "r" (daddr), |
191 | "r" (htonl(len)), "r" (htonl(proto)), "0" (sum) | 191 | "r" (htonl(len)), "r" (htonl(proto)), "0" (sum) |
192 | : "t"); | 192 | : "t"); |
193 | 193 | ||
194 | return csum_fold(sum); | 194 | return csum_fold(sum); |
195 | } | 195 | } |
196 | #endif | ||
197 | 196 | ||
198 | /* | 197 | /* |
199 | * Copy and checksum to user | 198 | * Copy and checksum to user |
200 | */ | 199 | */ |
201 | #define HAVE_CSUM_COPY_USER | 200 | #define HAVE_CSUM_COPY_USER |
202 | static __inline__ __wsum csum_and_copy_to_user (const void *src, | 201 | static inline __wsum csum_and_copy_to_user(const void *src, |
203 | void __user *dst, | 202 | void __user *dst, |
204 | int len, __wsum sum, | 203 | int len, __wsum sum, |
205 | int *err_ptr) | 204 | int *err_ptr) |
206 | { | 205 | { |
207 | if (access_ok(VERIFY_WRITE, dst, len)) | 206 | if (access_ok(VERIFY_WRITE, dst, len)) |
208 | return csum_partial_copy_generic((__force const void *)src, | 207 | return csum_partial_copy_generic((__force const void *)src, |