patch-pre2.0.5 linux/include/asm-m68k/checksum.h

Next file: linux/include/asm-m68k/delay.h
Previous file: linux/include/asm-m68k/cachectl.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file pre2.0.4/linux/include/asm-m68k/checksum.h linux/include/asm-m68k/checksum.h
@@ -62,6 +62,21 @@
 	return ~sum;
 }
 
+/*
+ *	Fold a partial checksum
+ */
+
+static inline unsigned int csum_fold(unsigned int sum)
+{
+	unsigned int tmp = sum;
+	__asm__("swap %1\n\t"
+		"addw %1, %0\n\t"
+		"clrw %1\n\t"
+		"addxw %1, %0"
+		: "=&d" (sum), "=&d" (tmp)
+		: "0" (sum), "1" (sum));
+	return ~sum;
+}
 
 
 /*
@@ -76,31 +91,12 @@
 	__asm__ ("addl  %1,%0\n\t"
 		 "addxl %4,%0\n\t"
 		 "addxl %5,%0\n\t"
-		 "movl  %0,%1\n\t"
-		 "swap  %1\n\t"
-		 "addxw %1,%0\n\t"
-		 "clrw  %1\n\t"
-		 "addxw %1,%0\n\t"
+		 "clrl %1\n\t"
+		 "addxl %1,%0"
 		 : "=&d" (sum), "=&d" (saddr)
 		 : "0" (daddr), "1" (saddr), "d" (len + proto),
 		   "d"(sum));
-	return ~sum;
-}
-
-/*
- *	Fold a partial checksum without adding pseudo headers
- */
-
-static inline unsigned int csum_fold(unsigned int sum)
-{
-	unsigned int tmp = sum;
-	__asm__("swap %1\n\t"
-		"addw %1, %0\n\t"
-		"clrw %1\n\t"
-		"addxw %1, %0"
-		: "=&d" (sum), "=&d" (tmp)
-		: "0" (sum), "1" (sum));
-	return ~sum;
+	return csum_fold(sum);
 }
 
 /*
@@ -111,17 +107,7 @@
 static inline unsigned short
 ip_compute_csum(unsigned char * buff, int len)
 {
-	unsigned int sum;
-	unsigned int scratch;
-
-	__asm__("movel %0,%1\n\t"
-		"swap  %1\n\t"
-		"addw  %1,%0\n\t"
-		"clrw  %1\n\t"
-		"addxw %1,%0\n\t"
-		: "=d" (sum), "=d" (scratch)
-		: "0" (csum_partial(buff, len, 0)));
-	return ~sum;
+	return csum_fold (csum_partial(buff, len, 0));
 }
 
 #endif /* _M68K_CHECKSUM_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this