···1414 * which always checksum on 4 octet boundaries. ihl is the number1515 * of 32-bit words and is always >= 5.1616 */1717-extern unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl);1717+extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);18181919/*2020 * computes the checksum of the TCP/UDP pseudo-header2121 * returns a 16-bit checksum, already complemented2222 */2323-extern unsigned short csum_tcpudp_magic(unsigned long saddr,2424- unsigned long daddr,2323+extern __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,2524 unsigned short len,2625 unsigned short proto,2727- unsigned int sum);2626+ __wsum sum);28272928/*3029 * computes the checksum of a memory block at buff, length len,···3738 *3839 * it's best to have buff aligned on a 32-bit boundary3940 */4040-extern unsigned int csum_partial(const unsigned char * buff, int len,4141- unsigned int sum);4141+extern __wsum csum_partial(const void *buff, int len, __wsum sum);42424343/*4444 * Computes the checksum of a memory block at src, length len,···4951 * Like csum_partial, this must be called with even lengths,5052 * except for the last fragment.5153 */5252-extern unsigned int csum_partial_copy_generic(const char *src, char *dst,5353- int len, unsigned int sum,5454+extern __wsum csum_partial_copy_generic(const void *src, void *dst,5555+ int len, __wsum sum,5456 int *src_err, int *dst_err);5557/*5658 * the same as csum_partial, but copies from src to dst while it5759 * checksums.5860 */5959-unsigned int csum_partial_copy_nocheck(const char *src, 6060- char *dst, 6161- int len, 6262- unsigned int sum);6363-6461#define csum_partial_copy_from_user(src, dst, len, sum, errp) \6565- csum_partial_copy_generic((src), (dst), (len), (sum), (errp), NULL)6262+ csum_partial_copy_generic((__force const void *)(src), (dst), (len), (sum), (errp), NULL)66636764#define csum_partial_copy_nocheck(src, dst, len, sum) \6865 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL)···6774 * turns a 32-bit partial checksum (e.g. from csum_partial) into a6875 * 1's complement 16-bit checksum.6976 */7070-static inline unsigned int csum_fold(unsigned int sum)7777+static inline __sum16 csum_fold(__wsum sum)7178{7279 unsigned int tmp;7380···7683 /* if there is a carry from adding the two 16-bit halves,7784 it will carry from the lower half into the upper half,7885 giving us the correct sum in the upper half. */7979- sum = ~(sum + tmp) >> 16;8080- return sum;8686+ return (__force __sum16)(~((__force u32)sum + tmp) >> 16);8187}82888389/*8490 * this routine is used for miscellaneous IP-like checksums, mainly8591 * in icmp.c8692 */8787-static inline unsigned short ip_compute_csum(unsigned char * buff, int len)9393+static inline __sum16 ip_compute_csum(const void *buff, int len)8894{8995 return csum_fold(csum_partial(buff, len, 0));9096}91979292-#ifdef __powerpc64__9393-static inline u32 csum_tcpudp_nofold(u32 saddr,9494- u32 daddr,9898+static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,9599 unsigned short len,96100 unsigned short proto,9797- unsigned int sum)101101+ __wsum sum)98102{9999- unsigned long s = sum;103103+#ifdef __powerpc64__104104+ unsigned long s = (__force u32)sum;100105101101- s += saddr;102102- s += daddr;103103- s += (proto << 16) + len;106106+ s += (__force u32)saddr;107107+ s += (__force u32)daddr;108108+ s += proto + len;104109 s += (s >> 32);105105- return (u32) s;106106-}110110+ return (__force __wsum) s;107111#else108108-static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,109109- unsigned long daddr,110110- unsigned short len,111111- unsigned short proto,112112- unsigned int sum)113113-{114112 __asm__("\n\115113 addc %0,%0,%1 \n\116114 adde %0,%0,%2 \n\···109125 addze %0,%0 \n\110126 "111127 : "=r" (sum)112112- : "r" (daddr), "r"(saddr), "r"((proto<<16)+len), "0"(sum));113113- return sum;114114-}115115-128128+ : "r" (daddr), "r"(saddr), "r"(proto + len), "0"(sum));129129+ return sum;116130#endif131131+}117132#endif /* __KERNEL__ */118133#endif