checksum.h 899 字节
Newer Older
1 2 3 4 5 6 7
/*
 * Copyright 2004-2009 Analog Devices Inc.
 *                     akbar.hussain@lineo.com
 *
 * Licensed under the GPL-2 or later.
 */

B
Bryan Wu 已提交
8 9 10 11 12 13 14 15
#ifndef _BFIN_CHECKSUM_H
#define _BFIN_CHECKSUM_H

/*
 * computes the checksum of the TCP/UDP pseudo-header
 * returns a 16-bit checksum, already complemented
 */

16
static inline __wsum
17 18
__csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
		     __u8 proto, __wsum sum)
B
Bryan Wu 已提交
19
{
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
	unsigned int carry;

	__asm__ ("%0 = %0 + %2;\n\t"
		"CC = AC0;\n\t"
		"%1 = CC;\n\t"
		"%0 = %0 + %1;\n\t"
		"%0 = %0 + %3;\n\t"
		"CC = AC0;\n\t"
		"%1 = CC;\n\t"
		"%0 = %0 + %1;\n\t"
		"%0 = %0 + %4;\n\t"
		"CC = AC0;\n\t"
		"%1 = CC;\n\t"
		"%0 = %0 + %1;\n\t"
		: "=d" (sum), "=&d" (carry)
		: "d" (daddr), "d" (saddr), "d" ((len + proto) << 8), "0"(sum)
		: "CC");
B
Bryan Wu 已提交
37 38 39

	return (sum);
}
40
#define csum_tcpudp_nofold __csum_tcpudp_nofold
B
Bryan Wu 已提交
41

42
#include <asm-generic/checksum.h>
B
Bryan Wu 已提交
43

44
#endif