1 #ifndef __ASM_SH64_CHECKSUM_H
2 #define __ASM_SH64_CHECKSUM_H
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
9 * include/asm-sh64/checksum.h
11 * Copyright (C) 2000, 2001 Paolo Alberelli
15 #include <asm/registers.h>
18 * computes the checksum of a memory block at buff, length len,
19 * and adds in "sum" (32-bit)
21 * returns a 32-bit number suitable for feeding into itself
22 * or csum_tcpudp_magic
24 * this function must be called with even lengths, except
25 * for the last fragment, which may be odd
27 * it's best to have buff aligned on a 32-bit boundary
29 asmlinkage
unsigned int csum_partial(const unsigned char *buff
, int len
,
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.
36 * If you use these functions directly please don't forget the
41 unsigned int csum_partial_copy_nocheck(const char *src
, char *dst
, int len
,
44 unsigned int csum_partial_copy_from_user(const char *src
, char *dst
,
45 int len
, int sum
, int *err_ptr
);
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.
51 * these functions should go away after some time.
54 #define csum_partial_copy_fromuser csum_partial_copy
56 unsigned int csum_partial_copy(const char *src
, char *dst
, int len
,
59 static inline unsigned short csum_fold(unsigned int sum
)
61 sum
= (sum
& 0xffff) + (sum
>> 16);
62 sum
= (sum
& 0xffff) + (sum
>> 16);
66 unsigned short ip_fast_csum(unsigned char * iph
, unsigned int ihl
);
68 unsigned long csum_tcpudp_nofold(unsigned long saddr
, unsigned long daddr
,
69 unsigned short len
, unsigned short proto
,
73 * computes the checksum of the TCP/UDP pseudo-header
74 * returns a 16-bit checksum, already complemented
76 static inline unsigned short int csum_tcpudp_magic(unsigned long saddr
,
82 return csum_fold(csum_tcpudp_nofold(saddr
,daddr
,len
,proto
,sum
));
86 * this routine is used for miscellaneous IP-like checksums, mainly
89 static inline unsigned short ip_compute_csum(unsigned char * buff
, int len
)
91 return csum_fold(csum_partial(buff
, len
, 0));
94 #endif /* __ASM_SH64_CHECKSUM_H */