Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (C) 2004 Microtronix Datacom Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef _ASM_NIOS_CHECKSUM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define _ASM_NIOS_CHECKSUM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /* Take these from lib/checksum.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern __wsum csum_partial(const void *buff, int len, __wsum sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) extern __sum16 ip_compute_csum(const void *buff, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * Fold a partial checksum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static inline __sum16 csum_fold(__wsum sum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	__asm__ __volatile__(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		"add	%0, %1, %0\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		"cmpltu	r8, %0, %1\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		"srli	%0, %0, 16\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		"add	%0, %0, r8\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		"nor	%0, %0, %0\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		: "=r" (sum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		: "r" (sum << 16), "0" (sum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		: "r8");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	return (__force __sum16) sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  * computes the checksum of the TCP/UDP pseudo-header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  * returns a 16-bit checksum, already complemented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define csum_tcpudp_nofold csum_tcpudp_nofold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 					__u32 len, __u8 proto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 					__wsum sum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	__asm__ __volatile__(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		"add	%0, %1, %0\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		"cmpltu	r8, %0, %1\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		"add	%0, %0, r8\n"	/* add carry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		"add	%0, %2, %0\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		"cmpltu	r8, %0, %2\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		"add	%0, %0, r8\n"	/* add carry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		"add	%0, %3, %0\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 		"cmpltu	r8, %0, %3\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		"add	%0, %0, r8\n"	/* add carry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		: "=r" (sum), "=r" (saddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		: "r" (daddr), "r" ((len + proto) << 8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		  "0" (sum),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		  "1" (saddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		: "r8");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	return sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 					__u32 len, __u8 proto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 					__wsum sum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #endif /* _ASM_NIOS_CHECKSUM_H */