Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Licensed under the GPL
0003  */
0004 
0005 #ifndef __UM_SYSDEP_CHECKSUM_H
0006 #define __UM_SYSDEP_CHECKSUM_H
0007 
0008 static inline __sum16 ip_compute_csum(const void *buff, int len)
0009 {
0010     return csum_fold (csum_partial(buff, len, 0));
0011 }
0012 
0013 #define _HAVE_ARCH_IPV6_CSUM
0014 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
0015                       const struct in6_addr *daddr,
0016                       __u32 len, __u8 proto,
0017                       __wsum sum)
0018 {
0019     __asm__(
0020         "addl 0(%1), %0     ;\n"
0021         "adcl 4(%1), %0     ;\n"
0022         "adcl 8(%1), %0     ;\n"
0023         "adcl 12(%1), %0    ;\n"
0024         "adcl 0(%2), %0     ;\n"
0025         "adcl 4(%2), %0     ;\n"
0026         "adcl 8(%2), %0     ;\n"
0027         "adcl 12(%2), %0    ;\n"
0028         "adcl %3, %0        ;\n"
0029         "adcl %4, %0        ;\n"
0030         "adcl $0, %0        ;\n"
0031         : "=&r" (sum)
0032         : "r" (saddr), "r" (daddr),
0033           "r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
0034 
0035     return csum_fold(sum);
0036 }
0037 
0038 #endif