35 #include <linux/export.h>
38 #include <asm/byteorder.h>
41 static inline unsigned short from32to16(
unsigned int x)
44 x = (x & 0xffff) + (x >> 16);
46 x = (x & 0xffff) + (x >> 16);
50 static unsigned int do_csum(
const unsigned char *buff,
int len)
57 odd = 1 & (
unsigned long) buff;
59 #ifdef __LITTLE_ENDIAN
60 result += (*buff << 8);
68 if (2 & (
unsigned long) buff) {
69 result += *(
unsigned short *) buff;
74 const unsigned char *
end = buff + ((unsigned)len & ~3);
75 unsigned int carry = 0;
77 unsigned int w = *(
unsigned int *) buff;
84 result = (result & 0xffff) + (result >> 16);
87 result += *(
unsigned short *) buff;
92 #ifdef __LITTLE_ENDIAN
95 result += (*buff << 8);
97 result = from32to16(result);
99 result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
130 unsigned int result =
do_csum(buff, len);
161 memset(dst + len - missing, 0, missing);
181 #ifndef csum_tcpudp_nofold
184 unsigned short proto,
194 s += (proto + len) << 8;