aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-m68k/checksum.h
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-11-15 00:17:19 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:23:07 -0500
commit2061acaaae0e165f0104ec9d327a02addbcabd62 (patch)
treed1d469373e549e335e7a2923a2214db04dd5296e /include/asm-m68k/checksum.h
parent85d20dee20f0958df1615e73698f6b0c525812f7 (diff)
[NET]: M68K checksum annotations and cleanups.
* sanitize prototypes, annotate Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-m68k/checksum.h')
-rw-r--r--include/asm-m68k/checksum.h46
1 files changed, 22 insertions, 24 deletions
diff --git a/include/asm-m68k/checksum.h b/include/asm-m68k/checksum.h
index 17280ef719f5..494f9aec37ea 100644
--- a/include/asm-m68k/checksum.h
+++ b/include/asm-m68k/checksum.h
@@ -15,7 +15,7 @@
15 * 15 *
16 * it's best to have buff aligned on a 32-bit boundary 16 * it's best to have buff aligned on a 32-bit boundary
17 */ 17 */
18unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 18__wsum csum_partial(const void *buff, int len, __wsum sum);
19 19
20/* 20/*
21 * the same as csum_partial, but copies from src while it 21 * the same as csum_partial, but copies from src while it
@@ -25,22 +25,21 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
25 * better 64-bit) boundary 25 * better 64-bit) boundary
26 */ 26 */
27 27
28extern unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 28extern __wsum csum_partial_copy_from_user(const void __user *src,
29 unsigned char *dst, 29 void *dst,
30 int len, int sum, 30 int len, __wsum sum,
31 int *csum_err); 31 int *csum_err);
32 32
33extern unsigned int csum_partial_copy_nocheck(const unsigned char *src, 33extern __wsum csum_partial_copy_nocheck(const void *src,
34 unsigned char *dst, int len, 34 void *dst, int len,
35 int sum); 35 __wsum sum);
36 36
37/* 37/*
38 * This is a version of ip_compute_csum() optimized for IP headers, 38 * This is a version of ip_compute_csum() optimized for IP headers,
39 * which always checksum on 4 octet boundaries. 39 * which always checksum on 4 octet boundaries.
40 * 40 *
41 */ 41 */
42static inline unsigned short 42static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
43ip_fast_csum(unsigned char *iph, unsigned int ihl)
44{ 43{
45 unsigned int sum = 0; 44 unsigned int sum = 0;
46 unsigned long tmp; 45 unsigned long tmp;
@@ -58,29 +57,29 @@ ip_fast_csum(unsigned char *iph, unsigned int ihl)
58 : "=d" (sum), "=&a" (iph), "=&d" (ihl), "=&d" (tmp) 57 : "=d" (sum), "=&a" (iph), "=&d" (ihl), "=&d" (tmp)
59 : "0" (sum), "1" (iph), "2" (ihl) 58 : "0" (sum), "1" (iph), "2" (ihl)
60 : "memory"); 59 : "memory");
61 return ~sum; 60 return (__force __sum16)~sum;
62} 61}
63 62
64/* 63/*
65 * Fold a partial checksum 64 * Fold a partial checksum
66 */ 65 */
67 66
68static inline unsigned int csum_fold(unsigned int sum) 67static inline __sum16 csum_fold(__wsum sum)
69{ 68{
70 unsigned int tmp = sum; 69 unsigned int tmp = (__force u32)sum;
71 __asm__("swap %1\n\t" 70 __asm__("swap %1\n\t"
72 "addw %1, %0\n\t" 71 "addw %1, %0\n\t"
73 "clrw %1\n\t" 72 "clrw %1\n\t"
74 "addxw %1, %0" 73 "addxw %1, %0"
75 : "=&d" (sum), "=&d" (tmp) 74 : "=&d" (sum), "=&d" (tmp)
76 : "0" (sum), "1" (tmp)); 75 : "0" (sum), "1" (tmp));
77 return ~sum; 76 return (__force __sum16)~sum;
78} 77}
79 78
80 79
81static inline unsigned int 80static inline __wsum
82csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 81csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
83 unsigned short proto, unsigned int sum) 82 unsigned short proto, __wsum sum)
84{ 83{
85 __asm__ ("addl %2,%0\n\t" 84 __asm__ ("addl %2,%0\n\t"
86 "addxl %3,%0\n\t" 85 "addxl %3,%0\n\t"
@@ -98,9 +97,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
98 * computes the checksum of the TCP/UDP pseudo-header 97 * computes the checksum of the TCP/UDP pseudo-header
99 * returns a 16-bit checksum, already complemented 98 * returns a 16-bit checksum, already complemented
100 */ 99 */
101static inline unsigned short int 100static inline __sum16
102csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 101csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
103 unsigned short proto, unsigned int sum) 102 unsigned short proto, __wsum sum)
104{ 103{
105 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 104 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
106} 105}
@@ -110,16 +109,15 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
110 * in icmp.c 109 * in icmp.c
111 */ 110 */
112 111
113static inline unsigned short 112static inline __sum16 ip_compute_csum(const void *buff, int len)
114ip_compute_csum(unsigned char * buff, int len)
115{ 113{
116 return csum_fold (csum_partial(buff, len, 0)); 114 return csum_fold (csum_partial(buff, len, 0));
117} 115}
118 116
119#define _HAVE_ARCH_IPV6_CSUM 117#define _HAVE_ARCH_IPV6_CSUM
120static __inline__ unsigned short int 118static __inline__ __sum16
121csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, 119csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
122 __u32 len, unsigned short proto, unsigned int sum) 120 __u32 len, unsigned short proto, __wsum sum)
123{ 121{
124 register unsigned long tmp; 122 register unsigned long tmp;
125 __asm__("addl %2@,%0\n\t" 123 __asm__("addl %2@,%0\n\t"