diff options
Diffstat (limited to 'include/asm-i386/checksum.h')
-rw-r--r-- | include/asm-i386/checksum.h | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/include/asm-i386/checksum.h b/include/asm-i386/checksum.h index 67d3630c4e89..75194abbe8ee 100644 --- a/include/asm-i386/checksum.h +++ b/include/asm-i386/checksum.h | |||
@@ -17,7 +17,7 @@ | |||
17 | * | 17 | * |
18 | * it's best to have buff aligned on a 32-bit boundary | 18 | * it's best to have buff aligned on a 32-bit boundary |
19 | */ | 19 | */ |
20 | asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); | 20 | asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum); |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * the same as csum_partial, but copies from src while it | 23 | * the same as csum_partial, but copies from src while it |
@@ -27,8 +27,8 @@ asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsign | |||
27 | * better 64-bit) boundary | 27 | * better 64-bit) boundary |
28 | */ | 28 | */ |
29 | 29 | ||
30 | asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsigned char *dst, | 30 | asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst, |
31 | int len, int sum, int *src_err_ptr, int *dst_err_ptr); | 31 | int len, __wsum sum, int *src_err_ptr, int *dst_err_ptr); |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Note: when you get a NULL pointer exception here this means someone | 34 | * Note: when you get a NULL pointer exception here this means someone |
@@ -38,18 +38,18 @@ asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsi | |||
38 | * access_ok(). | 38 | * access_ok(). |
39 | */ | 39 | */ |
40 | static __inline__ | 40 | static __inline__ |
41 | unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, | 41 | __wsum csum_partial_copy_nocheck (const void *src, void *dst, |
42 | int len, int sum) | 42 | int len, __wsum sum) |
43 | { | 43 | { |
44 | return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); | 44 | return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); |
45 | } | 45 | } |
46 | 46 | ||
47 | static __inline__ | 47 | static __inline__ |
48 | unsigned int csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst, | 48 | __wsum csum_partial_copy_from_user(const void __user *src, void *dst, |
49 | int len, int sum, int *err_ptr) | 49 | int len, __wsum sum, int *err_ptr) |
50 | { | 50 | { |
51 | might_sleep(); | 51 | might_sleep(); |
52 | return csum_partial_copy_generic((__force unsigned char *)src, dst, | 52 | return csum_partial_copy_generic((__force void *)src, dst, |
53 | len, sum, err_ptr, NULL); | 53 | len, sum, err_ptr, NULL); |
54 | } | 54 | } |
55 | 55 | ||
@@ -60,8 +60,7 @@ unsigned int csum_partial_copy_from_user(const unsigned char __user *src, unsign | |||
60 | * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by | 60 | * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by |
61 | * Arnt Gulbrandsen. | 61 | * Arnt Gulbrandsen. |
62 | */ | 62 | */ |
63 | static inline unsigned short ip_fast_csum(unsigned char * iph, | 63 | static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) |
64 | unsigned int ihl) | ||
65 | { | 64 | { |
66 | unsigned int sum; | 65 | unsigned int sum; |
67 | 66 | ||
@@ -89,29 +88,29 @@ static inline unsigned short ip_fast_csum(unsigned char * iph, | |||
89 | : "=r" (sum), "=r" (iph), "=r" (ihl) | 88 | : "=r" (sum), "=r" (iph), "=r" (ihl) |
90 | : "1" (iph), "2" (ihl) | 89 | : "1" (iph), "2" (ihl) |
91 | : "memory"); | 90 | : "memory"); |
92 | return(sum); | 91 | return (__force __sum16)sum; |
93 | } | 92 | } |
94 | 93 | ||
95 | /* | 94 | /* |
96 | * Fold a partial checksum | 95 | * Fold a partial checksum |
97 | */ | 96 | */ |
98 | 97 | ||
99 | static inline unsigned int csum_fold(unsigned int sum) | 98 | static inline __sum16 csum_fold(__wsum sum) |
100 | { | 99 | { |
101 | __asm__( | 100 | __asm__( |
102 | "addl %1, %0 ;\n" | 101 | "addl %1, %0 ;\n" |
103 | "adcl $0xffff, %0 ;\n" | 102 | "adcl $0xffff, %0 ;\n" |
104 | : "=r" (sum) | 103 | : "=r" (sum) |
105 | : "r" (sum << 16), "0" (sum & 0xffff0000) | 104 | : "r" ((__force u32)sum << 16), |
105 | "0" ((__force u32)sum & 0xffff0000) | ||
106 | ); | 106 | ); |
107 | return (~sum) >> 16; | 107 | return (__force __sum16)(~(__force u32)sum >> 16); |
108 | } | 108 | } |
109 | 109 | ||
110 | static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, | 110 | static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, |
111 | unsigned long daddr, | 111 | unsigned short len, |
112 | unsigned short len, | 112 | unsigned short proto, |
113 | unsigned short proto, | 113 | __wsum sum) |
114 | unsigned int sum) | ||
115 | { | 114 | { |
116 | __asm__( | 115 | __asm__( |
117 | "addl %1, %0 ;\n" | 116 | "addl %1, %0 ;\n" |
@@ -119,7 +118,7 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, | |||
119 | "adcl %3, %0 ;\n" | 118 | "adcl %3, %0 ;\n" |
120 | "adcl $0, %0 ;\n" | 119 | "adcl $0, %0 ;\n" |
121 | : "=r" (sum) | 120 | : "=r" (sum) |
122 | : "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum)); | 121 | : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum)); |
123 | return sum; | 122 | return sum; |
124 | } | 123 | } |
125 | 124 | ||
@@ -127,11 +126,10 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, | |||
127 | * computes the checksum of the TCP/UDP pseudo-header | 126 | * computes the checksum of the TCP/UDP pseudo-header |
128 | * returns a 16-bit checksum, already complemented | 127 | * returns a 16-bit checksum, already complemented |
129 | */ | 128 | */ |
130 | static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, | 129 | static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, |
131 | unsigned long daddr, | ||
132 | unsigned short len, | 130 | unsigned short len, |
133 | unsigned short proto, | 131 | unsigned short proto, |
134 | unsigned int sum) | 132 | __wsum sum) |
135 | { | 133 | { |
136 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | 134 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); |
137 | } | 135 | } |
@@ -141,17 +139,16 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, | |||
141 | * in icmp.c | 139 | * in icmp.c |
142 | */ | 140 | */ |
143 | 141 | ||
144 | static inline unsigned short ip_compute_csum(unsigned char * buff, int len) | 142 | static inline __sum16 ip_compute_csum(const void *buff, int len) |
145 | { | 143 | { |
146 | return csum_fold (csum_partial(buff, len, 0)); | 144 | return csum_fold (csum_partial(buff, len, 0)); |
147 | } | 145 | } |
148 | 146 | ||
149 | #define _HAVE_ARCH_IPV6_CSUM | 147 | #define _HAVE_ARCH_IPV6_CSUM |
150 | static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, | 148 | static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, |
151 | struct in6_addr *daddr, | 149 | const struct in6_addr *daddr, |
152 | __u32 len, | 150 | __u32 len, unsigned short proto, |
153 | unsigned short proto, | 151 | __wsum sum) |
154 | unsigned int sum) | ||
155 | { | 152 | { |
156 | __asm__( | 153 | __asm__( |
157 | "addl 0(%1), %0 ;\n" | 154 | "addl 0(%1), %0 ;\n" |
@@ -176,19 +173,19 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, | |||
176 | * Copy and checksum to user | 173 | * Copy and checksum to user |
177 | */ | 174 | */ |
178 | #define HAVE_CSUM_COPY_USER | 175 | #define HAVE_CSUM_COPY_USER |
179 | static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src, | 176 | static __inline__ __wsum csum_and_copy_to_user(const void *src, |
180 | unsigned char __user *dst, | 177 | void __user *dst, |
181 | int len, int sum, | 178 | int len, __wsum sum, |
182 | int *err_ptr) | 179 | int *err_ptr) |
183 | { | 180 | { |
184 | might_sleep(); | 181 | might_sleep(); |
185 | if (access_ok(VERIFY_WRITE, dst, len)) | 182 | if (access_ok(VERIFY_WRITE, dst, len)) |
186 | return csum_partial_copy_generic(src, (__force unsigned char *)dst, len, sum, NULL, err_ptr); | 183 | return csum_partial_copy_generic(src, (__force void *)dst, len, sum, NULL, err_ptr); |
187 | 184 | ||
188 | if (len) | 185 | if (len) |
189 | *err_ptr = -EFAULT; | 186 | *err_ptr = -EFAULT; |
190 | 187 | ||
191 | return -1; /* invalid checksum */ | 188 | return (__force __wsum)-1; /* invalid checksum */ |
192 | } | 189 | } |
193 | 190 | ||
194 | #endif | 191 | #endif |