diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-mips/checksum.h | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h index c5f9d20c7..01dbbb986 100644 --- a/include/asm-mips/checksum.h +++ b/include/asm-mips/checksum.h @@ -5,7 +5,9 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1995 by Ralf Baechle + * Copyright (C) 1995, 1996, 1997 by Ralf Baechle + * + * $Id:$ */ #ifndef __ASM_MIPS_CHECKSUM_H #define __ASM_MIPS_CHECKSUM_H @@ -52,23 +54,20 @@ unsigned int csum_partial_copy_from_user(const char *src, char *dst, int len, un */ static inline unsigned short int csum_fold(unsigned int sum) { - unsigned int __res; - - __asm__(" - .set noat - srl $1,%0,16 - andi %0,0xffff - addu $1,%0 - srl %0,$1,16 # addup halfword carry - andi $1,0xffff - addu $1,%0 - nor %0,$0,$1 + __asm__(" + .set noat + sll $1,%0,16 + addu %0,$1 + sltu $1,%0,$1 + srl %0,%0,16 + addu %0,$1 + xori %0,0xffff .set at" - : "=r"(__res) + : "=r" (sum) : "0" (sum) : "$1"); - return __res; + return sum; } /* @@ -140,20 +139,14 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, addu %0,%2 sltu $1,%0,%2 addu %0,$1 + addu %0,%3 sltu $1,%0,%3 addu %0,$1 + addu %0,%4 sltu $1,%0,%4 addu %0,$1 - - srl $1,%0,16 - andi %0,0xffff - addu %0,$1 - srl $1,%0,16 # addup halfword carry - andi %0,0xffff - addu %0,$1 - nor %0,$0,%0 .set at" : "=r" (sum) : "0" (daddr), "r"(saddr), @@ -165,7 +158,7 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, "r"(sum) : "$1"); - return (unsigned short)sum; + return csum_fold(sum); } /* @@ -174,22 +167,10 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, */ static inline unsigned short ip_compute_csum(unsigned char * buff, int len) { - unsigned short int sum; - - __asm__(" - .set noat - srl $1,%0,16 - andi %0,0xffff - addu %0,$1 - sltu $1,%0,$1 - addu %0,$1 - nor %0,$0,%0 - .set at" - : "=r"(sum) - : "0" (csum_partial(buff, len, 0)) - : "$1"); + unsigned int sum; - return sum; + sum = csum_partial(buff, len, 0); + return csum_fold(sum); } #define _HAVE_ARCH_IPV6_CSUM |