]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/microblaze/include/asm/checksum.h
2 * Copyright (C) 2008 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2006 Atmark Techno, Inc.
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
10 #ifndef _ASM_MICROBLAZE_CHECKSUM_H
11 #define _ASM_MICROBLAZE_CHECKSUM_H
13 #include <linux/in6.h>
16 * computes the checksum of the TCP/UDP pseudo-header
17 * returns a 16-bit checksum, already complemented
20 csum_tcpudp_nofold(__be32 saddr
, __be32 daddr
, unsigned short len
,
21 unsigned short proto
, __wsum sum
)
23 __asm__("add %0, %0, %1\n\t"
28 : "d" (saddr
), "d" (daddr
), "d" (len
+ proto
));
34 * computes the checksum of a memory block at buff, length len,
35 * and adds in "sum" (32-bit)
37 * returns a 32-bit number suitable for feeding into itself
38 * or csum_tcpudp_magic
40 * this function must be called with even lengths, except
41 * for the last fragment, which may be odd
43 * it's best to have buff aligned on a 32-bit boundary
45 extern __wsum
csum_partial(const void *buff
, int len
, __wsum sum
);
48 * the same as csum_partial, but copies from src while it
51 * here even more important to align src and dst on a 32-bit (or even
52 * better 64-bit) boundary
54 extern __wsum
csum_partial_copy(const char *src
, char *dst
, int len
, int sum
);
57 * the same as csum_partial_copy, but copies from user space.
59 * here even more important to align src and dst on a 32-bit (or even
60 * better 64-bit) boundary
62 extern __wsum
csum_partial_copy_from_user(const char *src
, char *dst
,
63 int len
, int sum
, int *csum_err
);
65 #define csum_partial_copy_nocheck(src, dst, len, sum) \
66 csum_partial_copy((src), (dst), (len), (sum))
69 * This is a version of ip_compute_csum() optimized for IP headers,
70 * which always checksum on 4 octet boundaries.
73 extern __sum16
ip_fast_csum(const void *iph
, unsigned int ihl
);
76 * Fold a partial checksum
78 static inline __sum16
csum_fold(unsigned int sum
)
80 sum
= (sum
& 0xffff) + (sum
>> 16);
81 sum
= (sum
& 0xffff) + (sum
>> 16);
86 csum_tcpudp_magic(__be32 saddr
, __be32 daddr
, unsigned short len
,
87 unsigned short proto
, __wsum sum
)
89 return csum_fold(csum_tcpudp_nofold(saddr
, daddr
, len
, proto
, sum
));
93 * this routine is used for miscellaneous IP-like checksums, mainly
96 extern __sum16
ip_compute_csum(const unsigned char *buff
, int len
);
98 #endif /* _ASM_MICROBLAZE_CHECKSUM_H */