From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 26 Jan 2017 17:11:16 +0100 (CET) Received: from localhost.localdomain ([127.0.0.1]:44754 "EHLO linux-mips.org" rhost-flags-OK-OK-OK-FAIL) by eddie.linux-mips.org with ESMTP id S23993894AbdAZQLHs1rrJ (ORCPT ); Thu, 26 Jan 2017 17:11:07 +0100 Received: from h7.dl5rb.org.uk (localhost [127.0.0.1]) by h7.dl5rb.org.uk (8.15.2/8.14.8) with ESMTP id v0QGB3Hm015823; Thu, 26 Jan 2017 17:11:03 +0100 Received: (from ralf@localhost) by h7.dl5rb.org.uk (8.15.2/8.15.2/Submit) id v0QGB0gt015821; Thu, 26 Jan 2017 17:11:00 +0100 Date: Thu, 26 Jan 2017 17:11:00 +0100 From: Ralf Baechle To: Alexander Duyck Cc: Mark Zhang , David Miller , Alexander Duyck , linux-mips@linux-mips.org, "linux-kernel@vger.kernel.org" Subject: Re: [Bug fix]mips 64bits checksum error -- csum_tcpudp_nofold Message-ID: <20170126161100.GJ21568@linux-mips.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 56520 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: ralf@linux-mips.org Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips On Thu, Jan 26, 2017 at 07:57:49AM -0800, Alexander Duyck wrote: > Date: Thu, 26 Jan 2017 07:57:49 -0800 > From: Alexander Duyck > To: Mark Zhang > Cc: Ralf Baechle , David Miller , > Alexander Duyck , linux-mips@linux-mips.org, > "linux-kernel@vger.kernel.org" > Subject: Re: [Bug fix]mips 64bits checksum error -- csum_tcpudp_nofold > Content-Type: text/plain; charset=UTF-8 > > On Wed, Jan 25, 2017 at 6:33 PM, Mark Zhang wrote: > > Hi Alex, > > > > Thanks for your reply. > > I tested your correction. The result is correct. > > The C language will cause this function(csum_tcpudp_nofold) become > > 176 MIPS instructions. The assemble code is 150 MIPS instruction. > > If the MIPS CPU is running as 1GHz, C language cause more 60 nano > > seconds during send/receive each tcp/udp packet. I'm not sure whether > > it will cause any negative result if the frequency of CPU was lower. > > MIPS arch is usually used in networking equipments. > > I think Ralf's correction is better. > > > > - Mark > > > > Signed-off-by: Ralf Baechle > > > > arch/mips/include/asm/checksum.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h > > index 5c585c5..08b6ba3 100644 > > --- a/arch/mips/include/asm/checksum.h > > +++ b/arch/mips/include/asm/checksum.h > > @@ -186,7 +186,9 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, > > " daddu %0, %4 \n" > > " dsll32 $1, %0, 0 \n" > > " daddu %0, $1 \n" > > + " sltu $1, %0, $1 \n" > > " dsra32 %0, %0, 0 \n" > > + " daddu %0, $1 \n" > > #endif > > " .set pop" > > : "=r" (sum) > > > > This looks good to me. > > Acked-by: Alexander Duyck I've actually checked in a slightly different version that this which uses an ADDU rather than a DADDU for the second instruction added. This is because the DSRA32 ensures the 32 bit result in %0 is properly signed extended to 64 bit as required by the MIPS architecture and the ADDU then simply operates on that 32 bit %0. Ralf