1 /* 1 2 * Copyright (C) 2010 Tobias Klauser <tklauser 3 * Copyright (C) 2004 Microtronix Datacom Ltd. 4 * 5 * This file is subject to the terms and condi 6 * License. See the file "COPYING" in the main 7 * for more details. 8 */ 9 10 #ifndef _ASM_NIOS_CHECKSUM_H 11 #define _ASM_NIOS_CHECKSUM_H 12 13 /* Take these from lib/checksum.c */ 14 extern __wsum csum_partial(const void *buff, i 15 extern __sum16 ip_fast_csum(const void *iph, u 16 extern __sum16 ip_compute_csum(const void *buf 17 18 /* 19 * Fold a partial checksum 20 */ 21 static inline __sum16 csum_fold(__wsum sum) 22 { 23 __asm__ __volatile__( 24 "add %0, %1, %0\n" 25 "cmpltu r8, %0, %1\n" 26 "srli %0, %0, 16\n" 27 "add %0, %0, r8\n" 28 "nor %0, %0, %0\n" 29 : "=r" (sum) 30 : "r" (sum << 16), "" (sum) 31 : "r8"); 32 return (__force __sum16) sum; 33 } 34 35 /* 36 * computes the checksum of the TCP/UDP pseudo 37 * returns a 16-bit checksum, already compleme 38 */ 39 #define csum_tcpudp_nofold csum_tcpudp_nofold 40 static inline __wsum csum_tcpudp_nofold(__be32 41 __u32 42 __wsum 43 { 44 __asm__ __volatile__( 45 "add %0, %1, %0\n" 46 "cmpltu r8, %0, %1\n" 47 "add %0, %0, r8\n" /* add 48 "add %0, %2, %0\n" 49 "cmpltu r8, %0, %2\n" 50 "add %0, %0, r8\n" /* add 51 "add %0, %3, %0\n" 52 "cmpltu r8, %0, %3\n" 53 "add %0, %0, r8\n" /* add 54 : "=r" (sum), "=r" (saddr) 55 : "r" (daddr), "r" ((len + pro 56 "" (sum), 57 "1" (saddr) 58 : "r8"); 59 60 return sum; 61 } 62 63 static inline __sum16 csum_tcpudp_magic(__be32 64 __u32 65 __wsum 66 { 67 return csum_fold(csum_tcpudp_nofold(sa 68 } 69 70 #endif /* _ASM_NIOS_CHECKSUM_H */ 71
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.