17 #include <linux/module.h>
18 #include <linux/types.h>
21 #include <asm/byteorder.h>
22 #include <asm/string.h>
23 #include <asm/uaccess.h>
26 __asm__ __volatile__ ( \
28 " addc %0, %%r0, %0\n" \
32 static inline unsigned short from32to16(
unsigned int x)
35 x = (x & 0xffff) + (x >> 16);
37 x = (x & 0xffff) + (x >> 16);
38 return (
unsigned short)
x;
41 static inline unsigned int do_csum(
const unsigned char * buff,
int len)
48 odd = 1 & (
unsigned long) buff;
56 if (2 & (
unsigned long) buff) {
57 result += *(
unsigned short *) buff;
66 r1 = *(
unsigned int *)(buff + 0);
67 r2 = *(
unsigned int *)(buff + 4);
68 r3 = *(
unsigned int *)(buff + 8);
69 r4 = *(
unsigned int *)(buff + 12);
78 unsigned int w = *(
unsigned int *) buff;
83 result = (result & 0xffff) + (result >> 16);
86 result += *(
unsigned short *) buff;
92 result = from32to16(result);
107 unsigned int result =
do_csum(buff, len);
143 memset(dst + len - missing, 0, missing);