~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/nios2/include/asm/checksum.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
  3  * Copyright (C) 2004 Microtronix Datacom Ltd.
  4  *
  5  * This file is subject to the terms and conditions of the GNU General Public
  6  * License. See the file "COPYING" in the main directory of this archive
  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, int len, __wsum sum);
 15 extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
 16 extern __sum16 ip_compute_csum(const void *buff, int len);
 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-header
 37  * returns a 16-bit checksum, already complemented
 38  */
 39 #define csum_tcpudp_nofold csum_tcpudp_nofold
 40 static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
 41                                         __u32 len, __u8 proto,
 42                                         __wsum sum)
 43 {
 44         __asm__ __volatile__(
 45                 "add    %0, %1, %0\n"
 46                 "cmpltu r8, %0, %1\n"
 47                 "add    %0, %0, r8\n"   /* add carry */
 48                 "add    %0, %2, %0\n"
 49                 "cmpltu r8, %0, %2\n"
 50                 "add    %0, %0, r8\n"   /* add carry */
 51                 "add    %0, %3, %0\n"
 52                 "cmpltu r8, %0, %3\n"
 53                 "add    %0, %0, r8\n"   /* add carry */
 54                 : "=r" (sum), "=r" (saddr)
 55                 : "r" (daddr), "r" ((len + proto) << 8),
 56                   "" (sum),
 57                   "1" (saddr)
 58                 : "r8");
 59 
 60         return sum;
 61 }
 62 
 63 static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
 64                                         __u32 len, __u8 proto,
 65                                         __wsum sum)
 66 {
 67         return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
 68 }
 69 
 70 #endif /* _ASM_NIOS_CHECKSUM_H */
 71 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php