diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2006-11-15 00:19:44 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:23:13 -0500 |
commit | 9d3d41955845939cb41b87affb039db0bae03b65 (patch) | |
tree | 468f7564a834edb54a30e49dd678e583568c6933 /include/asm-v850/checksum.h | |
parent | abf419b809bed2333267e4b23dd2b3b4f10da88c (diff) |
[NET]: V850 checksum annotations and cleanups.
* sanitize prototypes, annotate
* collapse csum_partial_copy
* usual ntohs->shift
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-v850/checksum.h')
-rw-r--r-- | include/asm-v850/checksum.h | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/include/asm-v850/checksum.h b/include/asm-v850/checksum.h index 4df5e71098f9..d1dddd938262 100644 --- a/include/asm-v850/checksum.h +++ b/include/asm-v850/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 | extern unsigned int csum_partial (const unsigned char * buff, int len, | 29 | extern __wsum csum_partial(const void *buff, int len, __wsum sum); |
30 | unsigned int sum); | ||
31 | 30 | ||
32 | /* | 31 | /* |
33 | * the same as csum_partial, but copies from src while it | 32 | * the same as csum_partial, but copies from src while it |
@@ -36,8 +35,8 @@ extern unsigned int csum_partial (const unsigned char * buff, int len, | |||
36 | * here even more important to align src and dst on a 32-bit (or even | 35 | * here even more important to align src and dst on a 32-bit (or even |
37 | * better 64-bit) boundary | 36 | * better 64-bit) boundary |
38 | */ | 37 | */ |
39 | extern unsigned csum_partial_copy (const unsigned char *src, | 38 | extern __wsum csum_partial_copy_nocheck(const void *src, |
40 | unsigned char *dst, int len, unsigned sum); | 39 | void *dst, int len, __wsum sum); |
41 | 40 | ||
42 | 41 | ||
43 | /* | 42 | /* |
@@ -46,20 +45,17 @@ extern unsigned csum_partial_copy (const unsigned char *src, | |||
46 | * here even more important to align src and dst on a 32-bit (or even | 45 | * here even more important to align src and dst on a 32-bit (or even |
47 | * better 64-bit) boundary | 46 | * better 64-bit) boundary |
48 | */ | 47 | */ |
49 | extern unsigned csum_partial_copy_from_user (const unsigned char *src, | 48 | extern __wsum csum_partial_copy_from_user (const void *src, |
50 | unsigned char *dst, | 49 | void *dst, |
51 | int len, unsigned sum, | 50 | int len, __wsum sum, |
52 | int *csum_err); | 51 | int *csum_err); |
53 | 52 | ||
54 | #define csum_partial_copy_nocheck(src, dst, len, sum) \ | 53 | __sum16 ip_fast_csum(const void *iph, unsigned int ihl); |
55 | csum_partial_copy ((src), (dst), (len), (sum)) | ||
56 | |||
57 | unsigned short ip_fast_csum (unsigned char *iph, unsigned int ihl); | ||
58 | 54 | ||
59 | /* | 55 | /* |
60 | * Fold a partial checksum | 56 | * Fold a partial checksum |
61 | */ | 57 | */ |
62 | static inline unsigned int csum_fold (unsigned long sum) | 58 | static inline __sum16 csum_fold (__wsum sum) |
63 | { | 59 | { |
64 | unsigned int result; | 60 | unsigned int result; |
65 | /* | 61 | /* |
@@ -68,7 +64,7 @@ static inline unsigned int csum_fold (unsigned long sum) | |||
68 | add %1, %0 H L H+L+C H+L | 64 | add %1, %0 H L H+L+C H+L |
69 | */ | 65 | */ |
70 | asm ("hsw %1, %0; add %1, %0" : "=&r" (result) : "r" (sum)); | 66 | asm ("hsw %1, %0; add %1, %0" : "=&r" (result) : "r" (sum)); |
71 | return (~result) >> 16; | 67 | return (__force __sum16)(~result >> 16); |
72 | } | 68 | } |
73 | 69 | ||
74 | 70 | ||
@@ -76,10 +72,10 @@ static inline unsigned int csum_fold (unsigned long sum) | |||
76 | * computes the checksum of the TCP/UDP pseudo-header | 72 | * computes the checksum of the TCP/UDP pseudo-header |
77 | * returns a 16-bit checksum, already complemented | 73 | * returns a 16-bit checksum, already complemented |
78 | */ | 74 | */ |
79 | static inline unsigned int | 75 | static inline __wsum |
80 | csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr, | 76 | csum_tcpudp_nofold (__be32 saddr, __be32 daddr, |
81 | unsigned short len, | 77 | unsigned short len, |
82 | unsigned short proto, unsigned int sum) | 78 | unsigned short proto, __wsum sum) |
83 | { | 79 | { |
84 | int __carry; | 80 | int __carry; |
85 | __asm__ ("add %2, %0;" | 81 | __asm__ ("add %2, %0;" |
@@ -93,15 +89,15 @@ csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr, | |||
93 | "add %1, %0" | 89 | "add %1, %0" |
94 | : "=&r" (sum), "=&r" (__carry) | 90 | : "=&r" (sum), "=&r" (__carry) |
95 | : "r" (daddr), "r" (saddr), | 91 | : "r" (daddr), "r" (saddr), |
96 | "r" (ntohs (len) + (proto << 8)), | 92 | "r" ((len + proto) << 8), |
97 | "0" (sum)); | 93 | "0" (sum)); |
98 | return sum; | 94 | return sum; |
99 | } | 95 | } |
100 | 96 | ||
101 | static inline unsigned short int | 97 | static inline __sum16 |
102 | csum_tcpudp_magic (unsigned long saddr, unsigned long daddr, | 98 | csum_tcpudp_magic (__be32 saddr, __be32 daddr, |
103 | unsigned short len, | 99 | unsigned short len, |
104 | unsigned short proto, unsigned int sum) | 100 | unsigned short proto, __wsum sum) |
105 | { | 101 | { |
106 | return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum)); | 102 | return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum)); |
107 | } | 103 | } |
@@ -110,7 +106,7 @@ csum_tcpudp_magic (unsigned long saddr, unsigned long daddr, | |||
110 | * this routine is used for miscellaneous IP-like checksums, mainly | 106 | * this routine is used for miscellaneous IP-like checksums, mainly |
111 | * in icmp.c | 107 | * in icmp.c |
112 | */ | 108 | */ |
113 | extern unsigned short ip_compute_csum (const unsigned char * buff, int len); | 109 | extern __sum16 ip_compute_csum(const void *buff, int len); |
114 | 110 | ||
115 | 111 | ||
116 | #endif /* __V850_CHECKSUM_H__ */ | 112 | #endif /* __V850_CHECKSUM_H__ */ |