diff options
Diffstat (limited to 'include/asm-mips/checksum.h')
-rw-r--r-- | include/asm-mips/checksum.h | 159 |
1 files changed, 81 insertions, 78 deletions
diff --git a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h index c1ea5a8714f3..b09f8971e95d 100644 --- a/include/asm-mips/checksum.h +++ b/include/asm-mips/checksum.h | |||
@@ -34,8 +34,9 @@ unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum); | |||
34 | * this is a new version of the above that records errors it finds in *errp, | 34 | * this is a new version of the above that records errors it finds in *errp, |
35 | * but continues and zeros the rest of the buffer. | 35 | * but continues and zeros the rest of the buffer. |
36 | */ | 36 | */ |
37 | unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, int len, | 37 | unsigned int csum_partial_copy_from_user(const unsigned char __user *src, |
38 | unsigned int sum, int *errp); | 38 | unsigned char *dst, int len, |
39 | unsigned int sum, int *errp); | ||
39 | 40 | ||
40 | /* | 41 | /* |
41 | * Copy and checksum to user | 42 | * Copy and checksum to user |
@@ -70,14 +71,15 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char * | |||
70 | static inline unsigned short int csum_fold(unsigned int sum) | 71 | static inline unsigned short int csum_fold(unsigned int sum) |
71 | { | 72 | { |
72 | __asm__( | 73 | __asm__( |
73 | ".set\tnoat\t\t\t# csum_fold\n\t" | 74 | " .set push # csum_fold\n" |
74 | "sll\t$1,%0,16\n\t" | 75 | " .set noat \n" |
75 | "addu\t%0,$1\n\t" | 76 | " sll $1, %0, 16 \n" |
76 | "sltu\t$1,%0,$1\n\t" | 77 | " addu %0, $1 \n" |
77 | "srl\t%0,%0,16\n\t" | 78 | " sltu $1, %0, $1 \n" |
78 | "addu\t%0,$1\n\t" | 79 | " srl %0, %0, 16 \n" |
79 | "xori\t%0,0xffff\n\t" | 80 | " addu %0, $1 \n" |
80 | ".set\tat" | 81 | " xori %0, 0xffff \n" |
82 | " .set pop" | ||
81 | : "=r" (sum) | 83 | : "=r" (sum) |
82 | : "0" (sum)); | 84 | : "0" (sum)); |
83 | 85 | ||
@@ -127,29 +129,30 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr, | |||
127 | unsigned int sum) | 129 | unsigned int sum) |
128 | { | 130 | { |
129 | __asm__( | 131 | __asm__( |
130 | ".set\tnoat\t\t\t# csum_tcpudp_nofold\n\t" | 132 | " .set push # csum_tcpudp_nofold\n" |
133 | " .set noat \n" | ||
131 | #ifdef CONFIG_32BIT | 134 | #ifdef CONFIG_32BIT |
132 | "addu\t%0, %2\n\t" | 135 | " addu %0, %2 \n" |
133 | "sltu\t$1, %0, %2\n\t" | 136 | " sltu $1, %0, %2 \n" |
134 | "addu\t%0, $1\n\t" | 137 | " addu %0, $1 \n" |
135 | 138 | ||
136 | "addu\t%0, %3\n\t" | 139 | " addu %0, %3 \n" |
137 | "sltu\t$1, %0, %3\n\t" | 140 | " sltu $1, %0, %3 \n" |
138 | "addu\t%0, $1\n\t" | 141 | " addu %0, $1 \n" |
139 | 142 | ||
140 | "addu\t%0, %4\n\t" | 143 | " addu %0, %4 \n" |
141 | "sltu\t$1, %0, %4\n\t" | 144 | " sltu $1, %0, %4 \n" |
142 | "addu\t%0, $1\n\t" | 145 | " addu %0, $1 \n" |
143 | #endif | 146 | #endif |
144 | #ifdef CONFIG_64BIT | 147 | #ifdef CONFIG_64BIT |
145 | "daddu\t%0, %2\n\t" | 148 | " daddu %0, %2 \n" |
146 | "daddu\t%0, %3\n\t" | 149 | " daddu %0, %3 \n" |
147 | "daddu\t%0, %4\n\t" | 150 | " daddu %0, %4 \n" |
148 | "dsll32\t$1, %0, 0\n\t" | 151 | " dsll32 $1, %0, 0 \n" |
149 | "daddu\t%0, $1\n\t" | 152 | " daddu %0, $1 \n" |
150 | "dsrl32\t%0, %0, 0\n\t" | 153 | " dsra32 %0, %0, 0 \n" |
151 | #endif | 154 | #endif |
152 | ".set\tat" | 155 | " .set pop" |
153 | : "=r" (sum) | 156 | : "=r" (sum) |
154 | : "0" (daddr), "r"(saddr), | 157 | : "0" (daddr), "r"(saddr), |
155 | #ifdef __MIPSEL__ | 158 | #ifdef __MIPSEL__ |
@@ -192,57 +195,57 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, | |||
192 | unsigned int sum) | 195 | unsigned int sum) |
193 | { | 196 | { |
194 | __asm__( | 197 | __asm__( |
195 | ".set\tpush\t\t\t# csum_ipv6_magic\n\t" | 198 | " .set push # csum_ipv6_magic\n" |
196 | ".set\tnoreorder\n\t" | 199 | " .set noreorder \n" |
197 | ".set\tnoat\n\t" | 200 | " .set noat \n" |
198 | "addu\t%0, %5\t\t\t# proto (long in network byte order)\n\t" | 201 | " addu %0, %5 # proto (long in network byte order)\n" |
199 | "sltu\t$1, %0, %5\n\t" | 202 | " sltu $1, %0, %5 \n" |
200 | "addu\t%0, $1\n\t" | 203 | " addu %0, $1 \n" |
201 | 204 | ||
202 | "addu\t%0, %6\t\t\t# csum\n\t" | 205 | " addu %0, %6 # csum\n" |
203 | "sltu\t$1, %0, %6\n\t" | 206 | " sltu $1, %0, %6 \n" |
204 | "lw\t%1, 0(%2)\t\t\t# four words source address\n\t" | 207 | " lw %1, 0(%2) # four words source address\n" |
205 | "addu\t%0, $1\n\t" | 208 | " addu %0, $1 \n" |
206 | "addu\t%0, %1\n\t" | 209 | " addu %0, %1 \n" |
207 | "sltu\t$1, %0, %1\n\t" | 210 | " sltu $1, %0, %1 \n" |
208 | 211 | ||
209 | "lw\t%1, 4(%2)\n\t" | 212 | " lw %1, 4(%2) \n" |
210 | "addu\t%0, $1\n\t" | 213 | " addu %0, $1 \n" |
211 | "addu\t%0, %1\n\t" | 214 | " addu %0, %1 \n" |
212 | "sltu\t$1, %0, %1\n\t" | 215 | " sltu $1, %0, %1 \n" |
213 | 216 | ||
214 | "lw\t%1, 8(%2)\n\t" | 217 | " lw %1, 8(%2) \n" |
215 | "addu\t%0, $1\n\t" | 218 | " addu %0, $1 \n" |
216 | "addu\t%0, %1\n\t" | 219 | " addu %0, %1 \n" |
217 | "sltu\t$1, %0, %1\n\t" | 220 | " sltu $1, %0, %1 \n" |
218 | 221 | ||
219 | "lw\t%1, 12(%2)\n\t" | 222 | " lw %1, 12(%2) \n" |
220 | "addu\t%0, $1\n\t" | 223 | " addu %0, $1 \n" |
221 | "addu\t%0, %1\n\t" | 224 | " addu %0, %1 \n" |
222 | "sltu\t$1, %0, %1\n\t" | 225 | " sltu $1, %0, %1 \n" |
223 | 226 | ||
224 | "lw\t%1, 0(%3)\n\t" | 227 | " lw %1, 0(%3) \n" |
225 | "addu\t%0, $1\n\t" | 228 | " addu %0, $1 \n" |
226 | "addu\t%0, %1\n\t" | 229 | " addu %0, %1 \n" |
227 | "sltu\t$1, %0, %1\n\t" | 230 | " sltu $1, %0, %1 \n" |
228 | 231 | ||
229 | "lw\t%1, 4(%3)\n\t" | 232 | " lw %1, 4(%3) \n" |
230 | "addu\t%0, $1\n\t" | 233 | " addu %0, $1 \n" |
231 | "addu\t%0, %1\n\t" | 234 | " addu %0, %1 \n" |
232 | "sltu\t$1, %0, %1\n\t" | 235 | " sltu $1, %0, %1 \n" |
233 | 236 | ||
234 | "lw\t%1, 8(%3)\n\t" | 237 | " lw %1, 8(%3) \n" |
235 | "addu\t%0, $1\n\t" | 238 | " addu %0, $1 \n" |
236 | "addu\t%0, %1\n\t" | 239 | " addu %0, %1 \n" |
237 | "sltu\t$1, %0, %1\n\t" | 240 | " sltu $1, %0, %1 \n" |
238 | 241 | ||
239 | "lw\t%1, 12(%3)\n\t" | 242 | " lw %1, 12(%3) \n" |
240 | "addu\t%0, $1\n\t" | 243 | " addu %0, $1 \n" |
241 | "addu\t%0, %1\n\t" | 244 | " addu %0, %1 \n" |
242 | "sltu\t$1, %0, %1\n\t" | 245 | " sltu $1, %0, %1 \n" |
243 | 246 | ||
244 | "addu\t%0, $1\t\t\t# Add final carry\n\t" | 247 | " addu %0, $1 # Add final carry\n" |
245 | ".set\tpop" | 248 | " .set pop" |
246 | : "=r" (sum), "=r" (proto) | 249 | : "=r" (sum), "=r" (proto) |
247 | : "r" (saddr), "r" (daddr), | 250 | : "r" (saddr), "r" (daddr), |
248 | "0" (htonl(len)), "1" (htonl(proto)), "r" (sum)); | 251 | "0" (htonl(len)), "1" (htonl(proto)), "r" (sum)); |