aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh64/checksum.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-sh64/checksum.h')
-rw-r--r--include/asm-sh64/checksum.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/include/asm-sh64/checksum.h b/include/asm-sh64/checksum.h
new file mode 100644
index 000000000000..aa3911a99490
--- /dev/null
+++ b/include/asm-sh64/checksum.h
@@ -0,0 +1,95 @@
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#include <asm/registers.h>
16
17/*
18 * computes the checksum of a memory block at buff, length len,
19 * and adds in "sum" (32-bit)
20 *
21 * returns a 32-bit number suitable for feeding into itself
22 * or csum_tcpudp_magic
23 *
24 * this function must be called with even lengths, except
25 * for the last fragment, which may be odd
26 *
27 * it's best to have buff aligned on a 32-bit boundary
28 */
29asmlinkage unsigned int csum_partial(const unsigned char *buff, int len,
30 unsigned int sum);
31
32/*
33 * Note: when you get a NULL pointer exception here this means someone
34 * passed in an incorrect kernel address to one of these functions.
35 *
36 * If you use these functions directly please don't forget the
37 * verify_area().
38 */
39
40
41unsigned int csum_partial_copy_nocheck(const char *src, char *dst, int len,
42 unsigned int sum);
43
44unsigned int csum_partial_copy_from_user(const char *src, char *dst,
45 int len, int sum, int *err_ptr);
46
47/*
48 * These are the old (and unsafe) way of doing checksums, a warning message will be
49 * printed if they are used and an exeption occurs.
50 *
51 * these functions should go away after some time.
52 */
53
54#define csum_partial_copy_fromuser csum_partial_copy
55
56unsigned int csum_partial_copy(const char *src, char *dst, int len,
57 unsigned int sum);
58
59static inline unsigned short csum_fold(unsigned int sum)
60{
61 sum = (sum & 0xffff) + (sum >> 16);
62 sum = (sum & 0xffff) + (sum >> 16);
63 return ~(sum);
64}
65
66unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl);
67
68unsigned long csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
69 unsigned short len, unsigned short proto,
70 unsigned int sum);
71
72/*
73 * computes the checksum of the TCP/UDP pseudo-header
74 * returns a 16-bit checksum, already complemented
75 */
76static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
77 unsigned long daddr,
78 unsigned short len,
79 unsigned short proto,
80 unsigned int sum)
81{
82 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
83}
84
85/*
86 * this routine is used for miscellaneous IP-like checksums, mainly
87 * in icmp.c
88 */
89static inline unsigned short ip_compute_csum(unsigned char * buff, int len)
90{
91 return csum_fold(csum_partial(buff, len, 0));
92}
93
94#endif /* __ASM_SH64_CHECKSUM_H */
95