author | Florian Westphal <fw@strlen.de> |
Sun, 11 Jan 2009 20:20:11 +0100 | |
changeset 0 | aa628870c1d3 |
permissions | -rw-r--r-- |
0
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
1 |
/* |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
2 |
* Copyright 2002, 2003 Andi Kleen, SuSE Labs. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
3 |
* Subject to the GNU Public License v.2 |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
4 |
* |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
5 |
* Wrappers of assembly checksum functions for x86-64. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
6 |
*/ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
7 |
#include <asm/checksum.h> |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
8 |
#include <linux/module.h> |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
9 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
10 |
/** |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
11 |
* csum_partial_copy_from_user - Copy and checksum from user space. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
12 |
* @src: source address (user space) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
13 |
* @dst: destination address |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
14 |
* @len: number of bytes to be copied. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
15 |
* @isum: initial sum that is added into the result (32bit unfolded) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
16 |
* @errp: set to -EFAULT for an bad source address. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
17 |
* |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
18 |
* Returns an 32bit unfolded checksum of the buffer. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
19 |
* src and dst are best aligned to 64bits. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
20 |
*/ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
21 |
__wsum |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
22 |
csum_partial_copy_from_user(const void __user *src, void *dst, |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
23 |
int len, __wsum isum, int *errp) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
24 |
{ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
25 |
might_sleep(); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
26 |
*errp = 0; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
27 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
28 |
if (!likely(access_ok(VERIFY_READ, src, len))) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
29 |
goto out_err; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
30 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
31 |
/* |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
32 |
* Why 6, not 7? To handle odd addresses aligned we |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
33 |
* would need to do considerable complications to fix the |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
34 |
* checksum which is defined as an 16bit accumulator. The |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
35 |
* fix alignment code is primarily for performance |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
36 |
* compatibility with 32bit and that will handle odd |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
37 |
* addresses slowly too. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
38 |
*/ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
39 |
if (unlikely((unsigned long)src & 6)) { |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
40 |
while (((unsigned long)src & 6) && len >= 2) { |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
41 |
__u16 val16; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
42 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
43 |
*errp = __get_user(val16, (const __u16 __user *)src); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
44 |
if (*errp) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
45 |
return isum; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
46 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
47 |
*(__u16 *)dst = val16; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
48 |
isum = (__force __wsum)add32_with_carry( |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
49 |
(__force unsigned)isum, val16); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
50 |
src += 2; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
51 |
dst += 2; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
52 |
len -= 2; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
53 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
54 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
55 |
isum = csum_partial_copy_generic((__force const void *)src, |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
56 |
dst, len, isum, errp, NULL); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
57 |
if (unlikely(*errp)) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
58 |
goto out_err; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
59 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
60 |
return isum; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
61 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
62 |
out_err: |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
63 |
*errp = -EFAULT; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
64 |
memset(dst, 0, len); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
65 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
66 |
return isum; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
67 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
68 |
EXPORT_SYMBOL(csum_partial_copy_from_user); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
69 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
70 |
/** |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
71 |
* csum_partial_copy_to_user - Copy and checksum to user space. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
72 |
* @src: source address |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
73 |
* @dst: destination address (user space) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
74 |
* @len: number of bytes to be copied. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
75 |
* @isum: initial sum that is added into the result (32bit unfolded) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
76 |
* @errp: set to -EFAULT for an bad destination address. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
77 |
* |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
78 |
* Returns an 32bit unfolded checksum of the buffer. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
79 |
* src and dst are best aligned to 64bits. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
80 |
*/ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
81 |
__wsum |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
82 |
csum_partial_copy_to_user(const void *src, void __user *dst, |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
83 |
int len, __wsum isum, int *errp) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
84 |
{ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
85 |
might_sleep(); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
86 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
87 |
if (unlikely(!access_ok(VERIFY_WRITE, dst, len))) { |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
88 |
*errp = -EFAULT; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
89 |
return 0; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
90 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
91 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
92 |
if (unlikely((unsigned long)dst & 6)) { |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
93 |
while (((unsigned long)dst & 6) && len >= 2) { |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
94 |
__u16 val16 = *(__u16 *)src; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
95 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
96 |
isum = (__force __wsum)add32_with_carry( |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
97 |
(__force unsigned)isum, val16); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
98 |
*errp = __put_user(val16, (__u16 __user *)dst); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
99 |
if (*errp) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
100 |
return isum; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
101 |
src += 2; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
102 |
dst += 2; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
103 |
len -= 2; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
104 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
105 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
106 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
107 |
*errp = 0; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
108 |
return csum_partial_copy_generic(src, (void __force *)dst, |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
109 |
len, isum, NULL, errp); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
110 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
111 |
EXPORT_SYMBOL(csum_partial_copy_to_user); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
112 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
113 |
/** |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
114 |
* csum_partial_copy_nocheck - Copy and checksum. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
115 |
* @src: source address |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
116 |
* @dst: destination address |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
117 |
* @len: number of bytes to be copied. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
118 |
* @isum: initial sum that is added into the result (32bit unfolded) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
119 |
* |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
120 |
* Returns an 32bit unfolded checksum of the buffer. |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
121 |
*/ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
122 |
__wsum |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
123 |
csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
124 |
{ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
125 |
return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
126 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
127 |
EXPORT_SYMBOL(csum_partial_copy_nocheck); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
128 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
129 |
__sum16 csum_ipv6_magic(const struct in6_addr *saddr, |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
130 |
const struct in6_addr *daddr, |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
131 |
__u32 len, unsigned short proto, __wsum sum) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
132 |
{ |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
133 |
__u64 rest, sum64; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
134 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
135 |
rest = (__force __u64)htonl(len) + (__force __u64)htons(proto) + |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
136 |
(__force __u64)sum; |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
137 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
138 |
asm(" addq (%[saddr]),%[sum]\n" |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
139 |
" adcq 8(%[saddr]),%[sum]\n" |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
140 |
" adcq (%[daddr]),%[sum]\n" |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
141 |
" adcq 8(%[daddr]),%[sum]\n" |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
142 |
" adcq $0,%[sum]\n" |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
143 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
144 |
: [sum] "=r" (sum64) |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
145 |
: "[sum]" (rest), [saddr] "r" (saddr), [daddr] "r" (daddr)); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
146 |
|
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
147 |
return csum_fold( |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
148 |
(__force __wsum)add32_with_carry(sum64 & 0xffffffff, sum64>>32)); |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
149 |
} |
aa628870c1d3
Port of Linux 2.6.28 for use with network simulation cradle.
Florian Westphal <fw@strlen.de>
parents:
diff
changeset
|
150 |
EXPORT_SYMBOL(csum_ipv6_magic); |