This source file includes following definitions.
- ip_fast_csum
- csum_tcpudp_magic
- csum_fold
- ip_compute_csum
1 #ifndef _M68K_CHECKSUM_H
2 #define _M68K_CHECKSUM_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16 unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
17
18
19
20
21
22
23
24
25
26 unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
27
28
29
30
31
32
33
34
35
36 unsigned int csum_partial_copy_fromuser(const char *src, char *dst, int len, int sum);
37
38
39
40
41
42
43
44 static inline unsigned short
45 ip_fast_csum(unsigned char *iph, unsigned int ihl)
46 {
47 unsigned int sum = 0;
48
49 __asm__ ("subqw #1,%2\n"
50 "1:\t"
51 "movel %1@+,%/d0\n\t"
52 "addxl %/d0,%0\n\t"
53 "dbra %2,1b\n\t"
54 "movel %0,%/d0\n\t"
55 "swap %/d0\n\t"
56 "addxw %/d0,%0\n\t"
57 "clrw %/d0\n\t"
58 "addxw %/d0,%0\n\t"
59 : "=d" (sum), "=a" (iph), "=d" (ihl)
60 : "0" (sum), "1" (iph), "2" (ihl)
61 : "d0");
62 return ~sum;
63 }
64
65
66
67
68
69
70
71
72 static inline unsigned short int
73 csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
74 unsigned short proto, unsigned int sum)
75 {
76 __asm__ ("addl %1,%0\n\t"
77 "addxl %4,%0\n\t"
78 "addxl %5,%0\n\t"
79 "movl %0,%1\n\t"
80 "swap %1\n\t"
81 "addxw %1,%0\n\t"
82 "clrw %1\n\t"
83 "addxw %1,%0\n\t"
84 : "=&d" (sum), "=&d" (saddr)
85 : "0" (daddr), "1" (saddr), "d" (len + proto),
86 "d"(sum));
87 return ~sum;
88 }
89
90
91
92
93
94 static inline unsigned int csum_fold(unsigned int sum)
95 {
96 unsigned int tmp = sum;
97 __asm__("swap %1\n\t"
98 "addw %1, %0\n\t"
99 "clrw %1\n\t"
100 "addxw %1, %0"
101 : "=&d" (sum), "=&d" (tmp)
102 : "0" (sum), "1" (sum));
103 return ~sum;
104 }
105
106
107
108
109
110
111 static inline unsigned short
112 ip_compute_csum(unsigned char * buff, int len)
113 {
114 unsigned int sum;
115 unsigned int scratch;
116
117 __asm__("movel %0,%1\n\t"
118 "swap %1\n\t"
119 "addw %1,%0\n\t"
120 "clrw %1\n\t"
121 "addxw %1,%0\n\t"
122 : "=d" (sum), "=d" (scratch)
123 : "0" (csum_partial(buff, len, 0)));
124 return ~sum;
125 }
126
127 #endif