xref: /linux/arch/microblaze/include/asm/checksum.h (revision ead5d1f4d877e92c051e1a1ade623d0d30e71619)
1*4726dd60SMichal Simek /* SPDX-License-Identifier: GPL-2.0 */
2f11e044bSMichal Simek /*
3f11e044bSMichal Simek  * Copyright (C) 2008 Michal Simek <monstr@monstr.eu>
4f11e044bSMichal Simek  * Copyright (C) 2006 Atmark Techno, Inc.
5f11e044bSMichal Simek  */
6f11e044bSMichal Simek 
7f11e044bSMichal Simek #ifndef _ASM_MICROBLAZE_CHECKSUM_H
8f11e044bSMichal Simek #define _ASM_MICROBLAZE_CHECKSUM_H
9f11e044bSMichal Simek 
10f11e044bSMichal Simek /*
11f11e044bSMichal Simek  * computes the checksum of the TCP/UDP pseudo-header
12f11e044bSMichal Simek  * returns a 16-bit checksum, already complemented
13f11e044bSMichal Simek  */
1414f87389SRemis Lima Baima #define csum_tcpudp_nofold	csum_tcpudp_nofold
15f11e044bSMichal Simek static inline __wsum
csum_tcpudp_nofold(__be32 saddr,__be32 daddr,__u32 len,__u8 proto,__wsum sum)1601cfbad7SAlexander Duyck csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
1701cfbad7SAlexander Duyck 		   __u8 proto, __wsum sum)
18f11e044bSMichal Simek {
19f11e044bSMichal Simek 	__asm__("add %0, %0, %1\n\t"
20f11e044bSMichal Simek 		"addc %0, %0, %2\n\t"
21f11e044bSMichal Simek 		"addc %0, %0, %3\n\t"
22f11e044bSMichal Simek 		"addc %0, %0, r0\n\t"
23f11e044bSMichal Simek 		: "+&d" (sum)
2402b08045SMichal Simek 		: "d" (saddr), "d" (daddr),
2502b08045SMichal Simek #ifdef __MICROBLAZEEL__
2602b08045SMichal Simek 	"d" ((len + proto) << 8)
2702b08045SMichal Simek #else
2802b08045SMichal Simek 	"d" (len + proto)
2902b08045SMichal Simek #endif
3002b08045SMichal Simek );
31f11e044bSMichal Simek 	return sum;
32f11e044bSMichal Simek }
33f11e044bSMichal Simek 
3414f87389SRemis Lima Baima #include <asm-generic/checksum.h>
35f11e044bSMichal Simek 
36f11e044bSMichal Simek #endif /* _ASM_MICROBLAZE_CHECKSUM_H */
37