diff options
-rw-r--r-- | arch/sh64/kernel/sh_ksyms.c | 2 | ||||
-rw-r--r-- | arch/sh64/lib/c-checksum.c | 49 | ||||
-rw-r--r-- | include/asm-sh64/checksum.h | 41 |
3 files changed, 32 insertions, 60 deletions
diff --git a/arch/sh64/kernel/sh_ksyms.c b/arch/sh64/kernel/sh_ksyms.c index 4b2df7247b59..7aa4b4f7bc5e 100644 --- a/arch/sh64/kernel/sh_ksyms.c +++ b/arch/sh64/kernel/sh_ksyms.c | |||
@@ -38,7 +38,7 @@ EXPORT_SYMBOL(disable_irq); | |||
38 | EXPORT_SYMBOL(kernel_thread); | 38 | EXPORT_SYMBOL(kernel_thread); |
39 | 39 | ||
40 | /* Networking helper routines. */ | 40 | /* Networking helper routines. */ |
41 | EXPORT_SYMBOL(csum_partial_copy); | 41 | EXPORT_SYMBOL(csum_partial_copy_nocheck); |
42 | 42 | ||
43 | EXPORT_SYMBOL(strstr); | 43 | EXPORT_SYMBOL(strstr); |
44 | 44 | ||
diff --git a/arch/sh64/lib/c-checksum.c b/arch/sh64/lib/c-checksum.c index 0e8a742abf8c..4b2676380deb 100644 --- a/arch/sh64/lib/c-checksum.c +++ b/arch/sh64/lib/c-checksum.c | |||
@@ -118,24 +118,24 @@ static unsigned long do_csum(const unsigned char *buff, int len) | |||
118 | 118 | ||
119 | /* computes the checksum of a memory block at buff, length len, | 119 | /* computes the checksum of a memory block at buff, length len, |
120 | and adds in "sum" (32-bit) */ | 120 | and adds in "sum" (32-bit) */ |
121 | unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) | 121 | __wsum csum_partial(const void *buff, int len, __wsum sum) |
122 | { | 122 | { |
123 | unsigned long long result = do_csum(buff, len); | 123 | unsigned long long result = do_csum(buff, len); |
124 | 124 | ||
125 | /* add in old sum, and carry.. */ | 125 | /* add in old sum, and carry.. */ |
126 | result += sum; | 126 | result += (__force u32)sum; |
127 | /* 32+c bits -> 32 bits */ | 127 | /* 32+c bits -> 32 bits */ |
128 | result = (result & 0xffffffff) + (result >> 32); | 128 | result = (result & 0xffffffff) + (result >> 32); |
129 | 129 | ||
130 | pr_debug("csum_partial, buff %p len %d sum 0x%x result=0x%016Lx\n", | 130 | pr_debug("csum_partial, buff %p len %d sum 0x%x result=0x%016Lx\n", |
131 | buff, len, sum, result); | 131 | buff, len, sum, result); |
132 | 132 | ||
133 | return result; | 133 | return (__force __wsum)result; |
134 | } | 134 | } |
135 | 135 | ||
136 | /* Copy while checksumming, otherwise like csum_partial. */ | 136 | /* Copy while checksumming, otherwise like csum_partial. */ |
137 | unsigned int | 137 | __wsum |
138 | csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, unsigned int sum) | 138 | csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum) |
139 | { | 139 | { |
140 | sum = csum_partial(src, len, sum); | 140 | sum = csum_partial(src, len, sum); |
141 | memcpy(dst, src, len); | 141 | memcpy(dst, src, len); |
@@ -145,9 +145,9 @@ csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, unsigne | |||
145 | 145 | ||
146 | /* Copy from userspace and compute checksum. If we catch an exception | 146 | /* Copy from userspace and compute checksum. If we catch an exception |
147 | then zero the rest of the buffer. */ | 147 | then zero the rest of the buffer. */ |
148 | unsigned int | 148 | __wsum |
149 | csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, int len, | 149 | csum_partial_copy_from_user(const void __user *src, void *dst, int len, |
150 | unsigned int sum, int *err_ptr) | 150 | __wsum sum, int *err_ptr) |
151 | { | 151 | { |
152 | int missing; | 152 | int missing; |
153 | 153 | ||
@@ -166,9 +166,9 @@ csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, int le | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /* Copy to userspace and compute checksum. */ | 168 | /* Copy to userspace and compute checksum. */ |
169 | unsigned int | 169 | __wsum |
170 | csum_partial_copy_to_user(const unsigned char *src, unsigned char *dst, int len, | 170 | csum_partial_copy_to_user(const unsigned char *src, unsigned char *dst, int len, |
171 | unsigned int sum, int *err_ptr) | 171 | __wsum sum, int *err_ptr) |
172 | { | 172 | { |
173 | sum = csum_partial(src, len, sum); | 173 | sum = csum_partial(src, len, sum); |
174 | 174 | ||
@@ -182,28 +182,24 @@ csum_partial_copy_to_user(const unsigned char *src, unsigned char *dst, int len, | |||
182 | * This is a version of ip_compute_csum() optimized for IP headers, | 182 | * This is a version of ip_compute_csum() optimized for IP headers, |
183 | * which always checksum on 4 octet boundaries. | 183 | * which always checksum on 4 octet boundaries. |
184 | */ | 184 | */ |
185 | unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) | 185 | __sum16 ip_fast_csum(const void *iph, unsigned int ihl) |
186 | { | 186 | { |
187 | pr_debug("ip_fast_csum %p,%d\n", iph, ihl); | 187 | pr_debug("ip_fast_csum %p,%d\n", iph, ihl); |
188 | 188 | ||
189 | return ~do_csum(iph, ihl * 4); | 189 | return (__force __sum16)~do_csum(iph, ihl * 4); |
190 | } | 190 | } |
191 | 191 | ||
192 | unsigned int csum_tcpudp_nofold(unsigned long saddr, | 192 | __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, |
193 | unsigned long daddr, | ||
194 | unsigned short len, | 193 | unsigned short len, |
195 | unsigned short proto, unsigned int sum) | 194 | unsigned short proto, __wsum sum) |
196 | { | 195 | { |
197 | unsigned long long result; | 196 | unsigned long long result; |
198 | 197 | ||
199 | pr_debug("ntohs(0x%x)=0x%x\n", 0xdead, ntohs(0xdead)); | 198 | pr_debug("ntohs(0x%x)=0x%x\n", 0xdead, ntohs(0xdead)); |
200 | pr_debug("htons(0x%x)=0x%x\n", 0xdead, htons(0xdead)); | 199 | pr_debug("htons(0x%x)=0x%x\n", 0xdead, htons(0xdead)); |
201 | 200 | ||
202 | result = ((unsigned long long) saddr + | 201 | result = (__force u64) saddr + (__force u64) daddr + |
203 | (unsigned long long) daddr + | 202 | (__force u64) sum + ((len + proto) << 8); |
204 | (unsigned long long) sum + | ||
205 | ((unsigned long long) ntohs(len) << 16) + | ||
206 | ((unsigned long long) proto << 8)); | ||
207 | 203 | ||
208 | /* Fold down to 32-bits so we don't loose in the typedef-less | 204 | /* Fold down to 32-bits so we don't loose in the typedef-less |
209 | network stack. */ | 205 | network stack. */ |
@@ -215,16 +211,5 @@ unsigned int csum_tcpudp_nofold(unsigned long saddr, | |||
215 | pr_debug("%s saddr %x daddr %x len %x proto %x sum %x result %08Lx\n", | 211 | pr_debug("%s saddr %x daddr %x len %x proto %x sum %x result %08Lx\n", |
216 | __FUNCTION__, saddr, daddr, len, proto, sum, result); | 212 | __FUNCTION__, saddr, daddr, len, proto, sum, result); |
217 | 213 | ||
218 | return result; | 214 | return (__wsum)result; |
219 | } | ||
220 | |||
221 | // Post SIM: | ||
222 | unsigned int | ||
223 | csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, int len, unsigned int sum) | ||
224 | { | ||
225 | // unsigned dummy; | ||
226 | pr_debug("csum_partial_copy_nocheck src %p dst %p len %d\n", src, dst, | ||
227 | len); | ||
228 | |||
229 | return csum_partial_copy(src, dst, len, sum); | ||
230 | } | 215 | } |
diff --git a/include/asm-sh64/checksum.h b/include/asm-sh64/checksum.h index fd034e9ae6e3..ba594ccb42e5 100644 --- a/include/asm-sh64/checksum.h +++ b/include/asm-sh64/checksum.h | |||
@@ -26,8 +26,7 @@ | |||
26 | * | 26 | * |
27 | * it's best to have buff aligned on a 32-bit boundary | 27 | * it's best to have buff aligned on a 32-bit boundary |
28 | */ | 28 | */ |
29 | asmlinkage unsigned int csum_partial(const unsigned char *buff, int len, | 29 | asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum); |
30 | unsigned int sum); | ||
31 | 30 | ||
32 | /* | 31 | /* |
33 | * Note: when you get a NULL pointer exception here this means someone | 32 | * Note: when you get a NULL pointer exception here this means someone |
@@ -38,46 +37,34 @@ asmlinkage unsigned int csum_partial(const unsigned char *buff, int len, | |||
38 | */ | 37 | */ |
39 | 38 | ||
40 | 39 | ||
41 | unsigned int csum_partial_copy_nocheck(const char *src, char *dst, int len, | 40 | __wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, |
42 | unsigned int sum); | 41 | __wsum sum); |
43 | 42 | ||
44 | unsigned int csum_partial_copy_from_user(const char *src, char *dst, | 43 | __wsum csum_partial_copy_from_user(const void __user *src, void *dst, |
45 | int len, int sum, int *err_ptr); | 44 | int len, __wsum sum, int *err_ptr); |
46 | 45 | ||
47 | /* | 46 | static inline __sum16 csum_fold(__wsum csum) |
48 | * These are the old (and unsafe) way of doing checksums, a warning message will be | ||
49 | * printed if they are used and an exeption occurs. | ||
50 | * | ||
51 | * these functions should go away after some time. | ||
52 | */ | ||
53 | |||
54 | #define csum_partial_copy_fromuser csum_partial_copy | ||
55 | |||
56 | unsigned int csum_partial_copy(const char *src, char *dst, int len, | ||
57 | unsigned int sum); | ||
58 | |||
59 | static inline unsigned short csum_fold(unsigned int sum) | ||
60 | { | 47 | { |
48 | u32 sum = (__force u32)csum; | ||
61 | sum = (sum & 0xffff) + (sum >> 16); | 49 | sum = (sum & 0xffff) + (sum >> 16); |
62 | sum = (sum & 0xffff) + (sum >> 16); | 50 | sum = (sum & 0xffff) + (sum >> 16); |
63 | return ~(sum); | 51 | return (__force __sum16)~sum; |
64 | } | 52 | } |
65 | 53 | ||
66 | unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl); | 54 | __sum16 ip_fast_csum(const void *iph, unsigned int ihl); |
67 | 55 | ||
68 | unsigned long csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, | 56 | __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, |
69 | unsigned short len, unsigned short proto, | 57 | unsigned short len, unsigned short proto, |
70 | unsigned int sum); | 58 | __wsum sum); |
71 | 59 | ||
72 | /* | 60 | /* |
73 | * computes the checksum of the TCP/UDP pseudo-header | 61 | * computes the checksum of the TCP/UDP pseudo-header |
74 | * returns a 16-bit checksum, already complemented | 62 | * returns a 16-bit checksum, already complemented |
75 | */ | 63 | */ |
76 | static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, | 64 | static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, |
77 | unsigned long daddr, | ||
78 | unsigned short len, | 65 | unsigned short len, |
79 | unsigned short proto, | 66 | unsigned short proto, |
80 | unsigned int sum) | 67 | __wsum sum) |
81 | { | 68 | { |
82 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | 69 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); |
83 | } | 70 | } |
@@ -86,7 +73,7 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, | |||
86 | * this routine is used for miscellaneous IP-like checksums, mainly | 73 | * this routine is used for miscellaneous IP-like checksums, mainly |
87 | * in icmp.c | 74 | * in icmp.c |
88 | */ | 75 | */ |
89 | static inline unsigned short ip_compute_csum(unsigned char * buff, int len) | 76 | static inline __sum16 ip_compute_csum(const void *buff, int len) |
90 | { | 77 | { |
91 | return csum_fold(csum_partial(buff, len, 0)); | 78 | return csum_fold(csum_partial(buff, len, 0)); |
92 | } | 79 | } |