1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef __ASM_CSKY_CHECKSUM_H 4 #define __ASM_CSKY_CHECKSUM_H 5 6 #include <linux/in6.h> 7 #include <asm/byteorder.h> 8 9 static inline __sum16 csum_fold(__wsum csum) 10 { 11 u32 tmp; 12 13 asm volatile( 14 "mov %1, %0\n" 15 "rori %0, 16\n" 16 "addu %0, %1\n" 17 "lsri %0, 16\n" 18 : "=r"(csum), "=r"(tmp) 19 : "0"(csum)); 20 21 return (__force __sum16) ~csum; 22 } 23 #define csum_fold csum_fold 24 25 static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, 26 unsigned short len, unsigned short proto, __wsum sum) 27 { 28 asm volatile( 29 "clrc\n" 30 "addc %0, %1\n" 31 "addc %0, %2\n" 32 "addc %0, %3\n" 33 "inct %0\n" 34 : "=r"(sum) 35 : "r"((__force u32)saddr), "r"((__force u32)daddr), 36 #ifdef __BIG_ENDIAN 37 "r"(proto + len), 38 #else 39 "r"((proto + len) << 8), 40 #endif 41 "0" ((__force unsigned long)sum) 42 : "cc"); 43 return sum; 44 } 45 #define csum_tcpudp_nofold csum_tcpudp_nofold 46 47 #include <asm-generic/checksum.h> 48 49 #endif /* __ASM_CSKY_CHECKSUM_H */ 50