patch-2.4.22 linux-2.4.22/include/asm-mips64/checksum.h
Next file: linux-2.4.22/include/asm-mips64/cpu.h
Previous file: linux-2.4.22/include/asm-mips64/cacheops.h
Back to the patch index
Back to the overall index
- Lines: 106
- Date:
2003-08-25 04:44:44.000000000 -0700
- Orig file:
linux-2.4.21/include/asm-mips64/checksum.h
- Orig date:
2002-11-28 15:53:15.000000000 -0800
diff -urN linux-2.4.21/include/asm-mips64/checksum.h linux-2.4.22/include/asm-mips64/checksum.h
@@ -85,7 +85,7 @@
: "=r" (sum)
: "0" (sum));
- return sum;
+ return sum;
}
/*
@@ -95,49 +95,35 @@
* By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
* Arnt Gulbrandsen.
*/
-static inline unsigned short ip_fast_csum(unsigned char *iph,
- unsigned int ihl)
+static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
{
- unsigned int sum;
- unsigned long dummy;
-
- /*
- * This is for 32-bit processors ... but works just fine for 64-bit
- * processors for now ... XXX
- */
- __asm__ __volatile__(
- ".set\tnoreorder\t\t\t# ip_fast_csum\n\t"
- ".set\tnoat\n\t"
- "lw\t%0, (%1)\n\t"
- "subu\t%2, 4\n\t"
- "dsll\t%2, 2\n\t"
- "lw\t%3, 4(%1)\n\t"
- "daddu\t%2, %1\n\t"
- "addu\t%0, %3\n\t"
- "sltu\t$1, %0, %3\n\t"
- "lw\t%3, 8(%1)\n\t"
- "addu\t%0, $1\n\t"
- "addu\t%0, %3\n\t"
- "sltu\t$1, %0, %3\n\t"
- "lw\t%3, 12(%1)\n\t"
- "addu\t%0, $1\n\t"
- "addu\t%0, %3\n\t"
- "sltu\t$1, %0, %3\n\t"
- "addu\t%0, $1\n"
-
- "1:\tlw\t%3, 16(%1)\n\t"
- "daddiu\t%1, 4\n"
- "addu\t%0, %3\n\t"
- "sltu\t$1, %0, %3\n\t"
- "bne\t%2, %1, 1b\n\t"
- " addu\t%0, $1\n"
-
- "2:\t.set\tat\n\t"
- ".set\treorder"
- : "=&r" (sum), "=&r" (iph), "=&r" (ihl), "=&r" (dummy)
- : "1" (iph), "2" (ihl));
+ unsigned int *word = (unsigned int *) iph;
+ unsigned int *stop = word + ihl;
+ unsigned int csum;
+ int carry;
+
+ csum = word[0];
+ csum += word[1];
+ carry = (csum < word[1]);
+ csum += carry;
+
+ csum += word[2];
+ carry = (csum < word[2]);
+ csum += carry;
+
+ csum += word[3];
+ carry = (csum < word[3]);
+ csum += carry;
+
+ word += 4;
+ do {
+ csum += *word;
+ carry = (csum < *word);
+ csum += carry;
+ word++;
+ } while (word != stop);
- return csum_fold(sum);
+ return csum_fold(csum);
}
/*
@@ -205,7 +191,8 @@
unsigned int sum)
{
__asm__(
- ".set\tnoreorder\t\t\t# csum_ipv6_magic\n\t"
+ ".set\tpush\t\t\t# csum_ipv6_magic\n\t"
+ ".set\tnoreorder\n\t"
".set\tnoat\n\t"
"addu\t%0, %5\t\t\t# proto (long in network byte order)\n\t"
"sltu\t$1, %0, %5\n\t"
@@ -254,8 +241,7 @@
"sltu\t$1, %0, %1\n\t"
"addu\t%0, $1\t\t\t# Add final carry\n\t"
- ".set\tnoat\n\t"
- ".set\tnoreorder"
+ ".set\tpop"
: "=&r" (sum), "=&r" (proto)
: "r" (saddr), "r" (daddr),
"0" (htonl(len)), "1" (htonl(proto)), "r" (sum));
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)