12 #include <linux/module.h>
13 #include <linux/string.h>
15 #include <asm/byteorder.h>
17 static inline unsigned short from64to16(
unsigned long x)
29 tmp_v.ul = (
unsigned long) in_v.ui[0] + (
unsigned long) in_v.ui[1];
33 out_v.ul = (
unsigned long) tmp_v.us[0] + (
unsigned long) tmp_v.us[1]
34 + (
unsigned long) tmp_v.us[2];
37 return out_v.us[0] + out_v.us[1];
51 (
__force u64)sum + ((len + proto) << 8));
67 result = (result & 0xffffffff) + (result >> 32);
69 result = (result & 0xffffffff) + (result >> 32);
81 static inline unsigned long do_csum(
const unsigned char * buff,
int len)
88 odd = 1 & (
unsigned long) buff;
96 if (2 & (
unsigned long) buff) {
97 result += *(
unsigned short *) buff;
104 if (4 & (
unsigned long) buff) {
105 result += *(
unsigned int *) buff;
112 unsigned long carry = 0;
114 unsigned long w = *(
unsigned long *) buff;
122 result = (result & 0xffffffff) + (result >> 32);
125 result += *(
unsigned int *) buff;
130 result += *(
unsigned short *) buff;
136 result = from64to16(result);
138 result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
166 unsigned long result =
do_csum(buff, len);
171 result = (result & 0xffffffff) + (result >> 32);