aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh/checksum_64.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-sh/checksum_64.h')
-rw-r--r--include/asm-sh/checksum_64.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/include/asm-sh/checksum_64.h b/include/asm-sh/checksum_64.h
new file mode 100644
index 000000000000..ec79b92e6bdc
--- /dev/null
+++ b/include/asm-sh/checksum_64.h
@@ -0,0 +1,80 @@
1#ifndef __ASM_SH64_CHECKSUM_H
2#define __ASM_SH64_CHECKSUM_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/checksum.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/*
16 * computes the checksum of a memory block at buff, length len,
17 * and adds in "sum" (32-bit)
18 *
19 * returns a 32-bit number suitable for feeding into itself
20 * or csum_tcpudp_magic
21 *
22 * this function must be called with even lengths, except
23 * for the last fragment, which may be odd
24 *
25 * it's best to have buff aligned on a 32-bit boundary
26 */
27asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
28
29/*
30 * Note: when you get a NULL pointer exception here this means someone
31 * passed in an incorrect kernel address to one of these functions.
32 *
33 * If you use these functions directly please don't forget the
34 * access_ok().
35 */
36
37
38__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len,
39 __wsum sum);
40
41__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
42 int len, __wsum sum, int *err_ptr);
43
44static inline __sum16 csum_fold(__wsum csum)
45{
46 u32 sum = (__force u32)csum;
47 sum = (sum & 0xffff) + (sum >> 16);
48 sum = (sum & 0xffff) + (sum >> 16);
49 return (__force __sum16)~sum;
50}
51
52__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
53
54__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
55 unsigned short len, unsigned short proto,
56 __wsum sum);
57
58/*
59 * computes the checksum of the TCP/UDP pseudo-header
60 * returns a 16-bit checksum, already complemented
61 */
62static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
63 unsigned short len,
64 unsigned short proto,
65 __wsum sum)
66{
67 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
68}
69
70/*
71 * this routine is used for miscellaneous IP-like checksums, mainly
72 * in icmp.c
73 */
74static inline __sum16 ip_compute_csum(const void *buff, int len)
75{
76 return csum_fold(csum_partial(buff, len, 0));
77}
78
79#endif /* __ASM_SH64_CHECKSUM_H */
80