aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-mips')
-rw-r--r--include/asm-mips/checksum.h55
1 files changed, 26 insertions, 29 deletions
diff --git a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h
index a5e6050ec0f..9b768c3b96b 100644
--- a/include/asm-mips/checksum.h
+++ b/include/asm-mips/checksum.h
@@ -27,23 +27,22 @@
27 * 27 *
28 * it's best to have buff aligned on a 32-bit boundary 28 * it's best to have buff aligned on a 32-bit boundary
29 */ 29 */
30unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum); 30__wsum csum_partial(const void *buff, int len, __wsum sum);
31 31
32/* 32/*
33 * this is a new version of the above that records errors it finds in *errp, 33 * this is a new version of the above that records errors it finds in *errp,
34 * but continues and zeros the rest of the buffer. 34 * but continues and zeros the rest of the buffer.
35 */ 35 */
36unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 36__wsum csum_partial_copy_from_user(const void __user *src,
37 unsigned char *dst, int len, 37 void *dst, int len,
38 unsigned int sum, int *errp); 38 __wsum sum, int *errp);
39 39
40/* 40/*
41 * Copy and checksum to user 41 * Copy and checksum to user
42 */ 42 */
43#define HAVE_CSUM_COPY_USER 43#define HAVE_CSUM_COPY_USER
44static inline unsigned int csum_and_copy_to_user (const unsigned char *src, 44static inline __wsum csum_and_copy_to_user (const void *src, void __user *dst,
45 unsigned char __user *dst, 45 int len, __wsum sum,
46 int len, int sum,
47 int *err_ptr) 46 int *err_ptr)
48{ 47{
49 might_sleep(); 48 might_sleep();
@@ -51,7 +50,7 @@ static inline unsigned int csum_and_copy_to_user (const unsigned char *src,
51 50
52 if (copy_to_user(dst, src, len)) { 51 if (copy_to_user(dst, src, len)) {
53 *err_ptr = -EFAULT; 52 *err_ptr = -EFAULT;
54 return -1; 53 return (__force __wsum)-1;
55 } 54 }
56 55
57 return sum; 56 return sum;
@@ -61,13 +60,13 @@ static inline unsigned int csum_and_copy_to_user (const unsigned char *src,
61 * the same as csum_partial, but copies from user space (but on MIPS 60 * the same as csum_partial, but copies from user space (but on MIPS
62 * we have just one address space, so this is identical to the above) 61 * we have just one address space, so this is identical to the above)
63 */ 62 */
64unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, 63__wsum csum_partial_copy_nocheck(const void *src, void *dst,
65 int len, unsigned int sum); 64 int len, __wsum sum);
66 65
67/* 66/*
68 * Fold a partial checksum without adding pseudo headers 67 * Fold a partial checksum without adding pseudo headers
69 */ 68 */
70static inline unsigned short int csum_fold(unsigned int sum) 69static inline __sum16 csum_fold(__wsum sum)
71{ 70{
72 __asm__( 71 __asm__(
73 " .set push # csum_fold\n" 72 " .set push # csum_fold\n"
@@ -82,7 +81,7 @@ static inline unsigned short int csum_fold(unsigned int sum)
82 : "=r" (sum) 81 : "=r" (sum)
83 : "0" (sum)); 82 : "0" (sum));
84 83
85 return sum; 84 return (__force __sum16)sum;
86} 85}
87 86
88/* 87/*
@@ -92,10 +91,10 @@ static inline unsigned short int csum_fold(unsigned int sum)
92 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by 91 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
93 * Arnt Gulbrandsen. 92 * Arnt Gulbrandsen.
94 */ 93 */
95static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) 94static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
96{ 95{
97 unsigned int *word = (unsigned int *) iph; 96 const unsigned int *word = iph;
98 unsigned int *stop = word + ihl; 97 const unsigned int *stop = word + ihl;
99 unsigned int csum; 98 unsigned int csum;
100 int carry; 99 int carry;
101 100
@@ -123,9 +122,9 @@ static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
123 return csum_fold(csum); 122 return csum_fold(csum);
124} 123}
125 124
126static inline unsigned int csum_tcpudp_nofold(unsigned long saddr, 125static inline __wsum csum_tcpudp_nofold(__be32 saddr,
127 unsigned long daddr, unsigned short len, unsigned short proto, 126 __be32 daddr, unsigned short len, unsigned short proto,
128 unsigned int sum) 127 __wsum sum)
129{ 128{
130 __asm__( 129 __asm__(
131 " .set push # csum_tcpudp_nofold\n" 130 " .set push # csum_tcpudp_nofold\n"
@@ -155,9 +154,9 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
155 : "=r" (sum) 154 : "=r" (sum)
156 : "0" (daddr), "r"(saddr), 155 : "0" (daddr), "r"(saddr),
157#ifdef __MIPSEL__ 156#ifdef __MIPSEL__
158 "r" (((unsigned long)htons(len)<<16) + proto*256), 157 "r" ((proto + len) << 8),
159#else 158#else
160 "r" (((unsigned long)(proto)<<16) + len), 159 "r" (proto + len),
161#endif 160#endif
162 "r" (sum)); 161 "r" (sum));
163 162
@@ -168,11 +167,10 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
168 * computes the checksum of the TCP/UDP pseudo-header 167 * computes the checksum of the TCP/UDP pseudo-header
169 * returns a 16-bit checksum, already complemented 168 * returns a 16-bit checksum, already complemented
170 */ 169 */
171static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 170static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
172 unsigned long daddr,
173 unsigned short len, 171 unsigned short len,
174 unsigned short proto, 172 unsigned short proto,
175 unsigned int sum) 173 __wsum sum)
176{ 174{
177 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); 175 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
178} 176}
@@ -181,17 +179,16 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
181 * this routine is used for miscellaneous IP-like checksums, mainly 179 * this routine is used for miscellaneous IP-like checksums, mainly
182 * in icmp.c 180 * in icmp.c
183 */ 181 */
184static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 182static inline __sum16 ip_compute_csum(const void *buff, int len)
185{ 183{
186 return csum_fold(csum_partial(buff, len, 0)); 184 return csum_fold(csum_partial(buff, len, 0));
187} 185}
188 186
189#define _HAVE_ARCH_IPV6_CSUM 187#define _HAVE_ARCH_IPV6_CSUM
190static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 188static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
191 struct in6_addr *daddr, 189 const struct in6_addr *daddr,
192 __u32 len, 190 __u32 len, unsigned short proto,
193 unsigned short proto, 191 __wsum sum)
194 unsigned int sum)
195{ 192{
196 __asm__( 193 __asm__(
197 " .set push # csum_ipv6_magic\n" 194 " .set push # csum_ipv6_magic\n"