blob: 623cc7fb00bc0602871c905c5e14b164b726d4e2 [file] [log] [blame]
Robin Getz96f10502009-09-24 14:11:24 +00001/*
2 * Copyright 2004-2009 Analog Devices Inc.
3 * akbar.hussain@lineo.com
4 *
5 * Licensed under the GPL-2 or later.
6 */
7
Bryan Wu1394f032007-05-06 14:50:22 -07008#ifndef _BFIN_CHECKSUM_H
9#define _BFIN_CHECKSUM_H
10
11/*
Bryan Wu1394f032007-05-06 14:50:22 -070012 * computes the checksum of the TCP/UDP pseudo-header
13 * returns a 16-bit checksum, already complemented
14 */
15
Al Viro45b39472008-05-12 11:55:10 +080016static inline __wsum
Mike Frysingerddf9dda2009-06-13 07:42:58 -040017__csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
Al Viro45b39472008-05-12 11:55:10 +080018 unsigned short proto, __wsum sum)
Bryan Wu1394f032007-05-06 14:50:22 -070019{
Michael Hennerichaa9c33b2009-02-04 16:49:45 +080020 unsigned int carry;
Bryan Wu1394f032007-05-06 14:50:22 -070021
Michael Hennerichaa9c33b2009-02-04 16:49:45 +080022 __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 Wu1394f032007-05-06 14:50:22 -070037
38 return (sum);
39}
Mike Frysingerddf9dda2009-06-13 07:42:58 -040040#define csum_tcpudp_nofold __csum_tcpudp_nofold
Bryan Wu1394f032007-05-06 14:50:22 -070041
Mike Frysingerddf9dda2009-06-13 07:42:58 -040042#include <asm-generic/checksum.h>
Bryan Wu1394f032007-05-06 14:50:22 -070043
Mike Frysingerddf9dda2009-06-13 07:42:58 -040044#endif