1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <net/checksum.h>
21#include <net/module.h>
22
23#undef PROFILE_CHECKSUM
24
25#ifdef PROFILE_CHECKSUM
26
27#if 0
28#define BITOFF *((unsigned char *)0xb0000030) = 0xff
29#define BITON *((unsigned char *)0xb0000030) = 0x0
30#endif
31#include <asm/io.h>
32#define CBITON LED_ACTIVE_SET(1)
33#define CBITOFF LED_ACTIVE_SET(0)
34#define BITOFF
35#define BITON
36#else
37#define BITOFF
38#define BITON
39#define CBITOFF
40#define CBITON
41#endif
42
43
44
45
46
47#include <asm/delay.h>
48
49__wsum csum_partial(const void *p, int len, __wsum __sum)
50{
51 u32 sum = (__force u32)__sum;
52 const u16 *buff = p;
53
54
55
56
57 const void *endMarker = p + len;
58 const void *marker = endMarker - (len % 16);
59#if 0
60 if((int)buff & 0x3)
61 printk("unaligned buff %p\n", buff);
62 __delay(900);
63#endif
64 BITON;
65 while (buff < marker) {
66 sum += *buff++;
67 sum += *buff++;
68 sum += *buff++;
69 sum += *buff++;
70 sum += *buff++;
71 sum += *buff++;
72 sum += *buff++;
73 sum += *buff++;
74 }
75 marker = endMarker - (len % 2);
76 while (buff < marker)
77 sum += *buff++;
78
79 if (endMarker > buff)
80 sum += *(const u8 *)buff;
81
82 BITOFF;
83 return (__force __wsum)sum;
84}
85
86EXPORT_SYMBOL(csum_partial);
87