patch-2.1.99 linux/include/asm-sparc64/checksum.h
Next file: linux/include/linux/if_ec.h
Previous file: linux/include/asm-sparc/checksum.h
Back to the patch index
Back to the overall index
- Lines: 77
- Date:
Tue Apr 28 22:28:10 1998
- Orig file:
v2.1.98/linux/include/asm-sparc64/checksum.h
- Orig date:
Sat Aug 16 09:51:10 1997
diff -u --recursive --new-file v2.1.98/linux/include/asm-sparc64/checksum.h linux/include/asm-sparc64/checksum.h
@@ -1,4 +1,4 @@
-/* $Id: checksum.h,v 1.10 1997/08/09 18:09:03 jj Exp $ */
+/* $Id: checksum.h,v 1.11 1998/04/17 02:37:22 davem Exp $ */
#ifndef __SPARC64_CHECKSUM_H
#define __SPARC64_CHECKSUM_H
@@ -116,10 +116,23 @@
return sum;
}
-/* computes the checksum of the TCP/UDP pseudo-header
- * returns a 16-bit checksum, already complemented
- */
-extern __inline__ unsigned short csum_tcpudp_magic(unsigned long saddr,
+/* Fold a partial checksum without adding pseudo headers. */
+extern __inline__ unsigned short csum_fold(unsigned int sum)
+{
+ unsigned int tmp;
+
+ __asm__ __volatile__("
+ addcc %0, %1, %1
+ srl %1, 16, %1
+ addc %1, %%g0, %1
+ xnor %%g0, %1, %0
+" : "=&r" (sum), "=r" (tmp)
+ : "0" (sum), "1" (sum<<16)
+ : "cc");
+ return (sum & 0xffff);
+}
+
+extern __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
unsigned long daddr,
unsigned int len,
unsigned short proto,
@@ -130,31 +143,23 @@
addccc %2, %0, %0
addccc %3, %0, %0
addc %0, %%g0, %0
- sll %0, 16, %1
- addcc %1, %0, %0
- srl %0, 16, %0
- addc %0, %%g0, %0
- xnor %%g0, %0, %0
" : "=r" (sum), "=r" (saddr)
: "r" (daddr), "r" ((proto<<16)+len), "0" (sum), "1" (saddr)
: "cc");
- return (sum & 0xffff);
+ return sum;
}
-/* Fold a partial checksum without adding pseudo headers. */
-extern __inline__ unsigned short csum_fold(unsigned int sum)
+/*
+ * computes the checksum of the TCP/UDP pseudo-header
+ * returns a 16-bit checksum, already complemented
+ */
+static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
+ unsigned long daddr,
+ unsigned short len,
+ unsigned short proto,
+ unsigned int sum)
{
- unsigned int tmp;
-
- __asm__ __volatile__("
- addcc %0, %1, %1
- srl %1, 16, %1
- addc %1, %%g0, %1
- xnor %%g0, %1, %0
-" : "=&r" (sum), "=r" (tmp)
- : "0" (sum), "1" (sum<<16)
- : "cc");
- return (sum & 0xffff);
+ return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
}
#define _HAVE_ARCH_IPV6_CSUM
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov