diff options
Diffstat (limited to 'arch/alpha/lib/checksum.c')
-rw-r--r-- | arch/alpha/lib/checksum.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/arch/alpha/lib/checksum.c b/arch/alpha/lib/checksum.c index 89044e6385fe..ab3761c437a8 100644 --- a/arch/alpha/lib/checksum.c +++ b/arch/alpha/lib/checksum.c | |||
@@ -41,28 +41,25 @@ static inline unsigned short from64to16(unsigned long x) | |||
41 | * computes the checksum of the TCP/UDP pseudo-header | 41 | * computes the checksum of the TCP/UDP pseudo-header |
42 | * returns a 16-bit checksum, already complemented. | 42 | * returns a 16-bit checksum, already complemented. |
43 | */ | 43 | */ |
44 | unsigned short int csum_tcpudp_magic(unsigned long saddr, | 44 | __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, |
45 | unsigned long daddr, | ||
46 | unsigned short len, | 45 | unsigned short len, |
47 | unsigned short proto, | 46 | unsigned short proto, |
48 | unsigned int sum) | 47 | __wsum sum) |
49 | { | 48 | { |
50 | return ~from64to16(saddr + daddr + sum + | 49 | return (__force __sum16)~from64to16( |
51 | ((unsigned long) ntohs(len) << 16) + | 50 | (__force u64)saddr + (__force u64)daddr + |
52 | ((unsigned long) proto << 8)); | 51 | (__force u64)sum + ((len + proto) << 8)); |
53 | } | 52 | } |
54 | 53 | ||
55 | unsigned int csum_tcpudp_nofold(unsigned long saddr, | 54 | __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, |
56 | unsigned long daddr, | ||
57 | unsigned short len, | 55 | unsigned short len, |
58 | unsigned short proto, | 56 | unsigned short proto, |
59 | unsigned int sum) | 57 | __wsum sum) |
60 | { | 58 | { |
61 | unsigned long result; | 59 | unsigned long result; |
62 | 60 | ||
63 | result = (saddr + daddr + sum + | 61 | result = (__force u64)saddr + (__force u64)daddr + |
64 | ((unsigned long) ntohs(len) << 16) + | 62 | (__force u64)sum + ((len + proto) << 8); |
65 | ((unsigned long) proto << 8)); | ||
66 | 63 | ||
67 | /* Fold down to 32-bits so we don't lose in the typedef-less | 64 | /* Fold down to 32-bits so we don't lose in the typedef-less |
68 | network stack. */ | 65 | network stack. */ |
@@ -70,7 +67,7 @@ unsigned int csum_tcpudp_nofold(unsigned long saddr, | |||
70 | result = (result & 0xffffffff) + (result >> 32); | 67 | result = (result & 0xffffffff) + (result >> 32); |
71 | /* 33 to 32 */ | 68 | /* 33 to 32 */ |
72 | result = (result & 0xffffffff) + (result >> 32); | 69 | result = (result & 0xffffffff) + (result >> 32); |
73 | return result; | 70 | return (__force __wsum)result; |
74 | } | 71 | } |
75 | 72 | ||
76 | /* | 73 | /* |
@@ -146,9 +143,9 @@ out: | |||
146 | * This is a version of ip_compute_csum() optimized for IP headers, | 143 | * This is a version of ip_compute_csum() optimized for IP headers, |
147 | * which always checksum on 4 octet boundaries. | 144 | * which always checksum on 4 octet boundaries. |
148 | */ | 145 | */ |
149 | unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) | 146 | __sum16 ip_fast_csum(const void *iph, unsigned int ihl) |
150 | { | 147 | { |
151 | return ~do_csum(iph,ihl*4); | 148 | return (__force __sum16)~do_csum(iph,ihl*4); |
152 | } | 149 | } |
153 | 150 | ||
154 | /* | 151 | /* |
@@ -163,15 +160,15 @@ unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) | |||
163 | * | 160 | * |
164 | * it's best to have buff aligned on a 32-bit boundary | 161 | * it's best to have buff aligned on a 32-bit boundary |
165 | */ | 162 | */ |
166 | unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) | 163 | __wsum csum_partial(const void *buff, int len, __wsum sum) |
167 | { | 164 | { |
168 | unsigned long result = do_csum(buff, len); | 165 | unsigned long result = do_csum(buff, len); |
169 | 166 | ||
170 | /* add in old sum, and carry.. */ | 167 | /* add in old sum, and carry.. */ |
171 | result += sum; | 168 | result += (__force u32)sum; |
172 | /* 32+c bits -> 32 bits */ | 169 | /* 32+c bits -> 32 bits */ |
173 | result = (result & 0xffffffff) + (result >> 32); | 170 | result = (result & 0xffffffff) + (result >> 32); |
174 | return result; | 171 | return (__force __wsum)result; |
175 | } | 172 | } |
176 | 173 | ||
177 | EXPORT_SYMBOL(csum_partial); | 174 | EXPORT_SYMBOL(csum_partial); |
@@ -180,7 +177,7 @@ EXPORT_SYMBOL(csum_partial); | |||
180 | * this routine is used for miscellaneous IP-like checksums, mainly | 177 | * this routine is used for miscellaneous IP-like checksums, mainly |
181 | * in icmp.c | 178 | * in icmp.c |
182 | */ | 179 | */ |
183 | unsigned short ip_compute_csum(unsigned char * buff, int len) | 180 | __sum16 ip_compute_csum(const void *buff, int len) |
184 | { | 181 | { |
185 | return ~from64to16(do_csum(buff,len)); | 182 | return (__force __sum16)~from64to16(do_csum(buff,len)); |
186 | } | 183 | } |