blob: 0185cbefdda48a2770703709ed1d9701208362a0 [file] [log] [blame]
Michal Simekf11e0442009-03-27 14:25:22 +01001/*
2 * Copyright (C) 2008 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2006 Atmark Techno, Inc.
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
10#ifndef _ASM_MICROBLAZE_CHECKSUM_H
11#define _ASM_MICROBLAZE_CHECKSUM_H
12
Michal Simekf11e0442009-03-27 14:25:22 +010013/*
14 * computes the checksum of the TCP/UDP pseudo-header
15 * returns a 16-bit checksum, already complemented
16 */
Remis Lima Baima14f87382009-06-18 19:55:32 +020017#define csum_tcpudp_nofold csum_tcpudp_nofold
Michal Simekf11e0442009-03-27 14:25:22 +010018static inline __wsum
19csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
20 unsigned short proto, __wsum sum)
21{
22 __asm__("add %0, %0, %1\n\t"
23 "addc %0, %0, %2\n\t"
24 "addc %0, %0, %3\n\t"
25 "addc %0, %0, r0\n\t"
26 : "+&d" (sum)
Michal Simek02b08042010-09-28 16:04:14 +100027 : "d" (saddr), "d" (daddr),
28#ifdef __MICROBLAZEEL__
29 "d" ((len + proto) << 8)
30#else
31 "d" (len + proto)
32#endif
33);
Michal Simekf11e0442009-03-27 14:25:22 +010034 return sum;
35}
36
Remis Lima Baima14f87382009-06-18 19:55:32 +020037#include <asm-generic/checksum.h>
Michal Simekf11e0442009-03-27 14:25:22 +010038
39#endif /* _ASM_MICROBLAZE_CHECKSUM_H */