Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004-2009 Analog Devices Inc. |
| 3 | * akbar.hussain@lineo.com |
| 4 | * |
| 5 | * Licensed under the GPL-2 or later. |
| 6 | */ |
| 7 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 8 | #ifndef _BFIN_CHECKSUM_H |
| 9 | #define _BFIN_CHECKSUM_H |
| 10 | |
| 11 | /* |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 12 | * computes the checksum of the TCP/UDP pseudo-header |
| 13 | * returns a 16-bit checksum, already complemented |
| 14 | */ |
| 15 | |
Al Viro | 45b3947 | 2008-05-12 11:55:10 +0800 | [diff] [blame] | 16 | static inline __wsum |
Mike Frysinger | ddf9dda | 2009-06-13 07:42:58 -0400 | [diff] [blame] | 17 | __csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, |
Al Viro | 45b3947 | 2008-05-12 11:55:10 +0800 | [diff] [blame] | 18 | unsigned short proto, __wsum sum) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 19 | { |
Michael Hennerich | aa9c33b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 20 | unsigned int carry; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 21 | |
Michael Hennerich | aa9c33b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 22 | __asm__ ("%0 = %0 + %2;\n\t" |
| 23 | "CC = AC0;\n\t" |
| 24 | "%1 = CC;\n\t" |
| 25 | "%0 = %0 + %1;\n\t" |
| 26 | "%0 = %0 + %3;\n\t" |
| 27 | "CC = AC0;\n\t" |
| 28 | "%1 = CC;\n\t" |
| 29 | "%0 = %0 + %1;\n\t" |
| 30 | "%0 = %0 + %4;\n\t" |
| 31 | "CC = AC0;\n\t" |
| 32 | "%1 = CC;\n\t" |
| 33 | "%0 = %0 + %1;\n\t" |
| 34 | : "=d" (sum), "=&d" (carry) |
| 35 | : "d" (daddr), "d" (saddr), "d" ((len + proto) << 8), "0"(sum) |
| 36 | : "CC"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 37 | |
| 38 | return (sum); |
| 39 | } |
Mike Frysinger | ddf9dda | 2009-06-13 07:42:58 -0400 | [diff] [blame] | 40 | #define csum_tcpudp_nofold __csum_tcpudp_nofold |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 41 | |
Mike Frysinger | ddf9dda | 2009-06-13 07:42:58 -0400 | [diff] [blame] | 42 | #include <asm-generic/checksum.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 43 | |
Mike Frysinger | ddf9dda | 2009-06-13 07:42:58 -0400 | [diff] [blame] | 44 | #endif |