Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992435AbbEVP7P (ORCPT ); Fri, 22 May 2015 11:59:15 -0400 Received: from smtp-out6.electric.net ([192.162.217.184]:50854 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757309AbbEVP7L (ORCPT ); Fri, 22 May 2015 11:59:11 -0400 From: David Laight To: "'Christophe Leroy'" , Benjamin Herrenschmidt , Paul Mackerras , "Michael Ellerman" , "scottwood@freescale.com" CC: "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v3 2/2] powerpc: add support for csum_add() Thread-Topic: [PATCH v3 2/2] powerpc: add support for csum_add() Thread-Index: AQHQkkqkelEqw9QfvkW74vO+INevup2IKrZg Date: Fri, 22 May 2015 15:57:38 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CB3D471@AcuExch.aculab.com> References: <1d1362c8aa696e316d3ba97dce2342df6f6ee6cf.1432047904.git.christophe.leroy@c-s.fr> In-Reply-To: <1d1362c8aa696e316d3ba97dce2342df6f6ee6cf.1432047904.git.christophe.leroy@c-s.fr> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id t4MFxKK3028872 Content-Length: 1254 Lines: 35 From: Linuxppc-dev Christophe Leroy > Sent: 19 May 2015 16:19 ... > diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h > index 5e43d2d..e8d9ef4 100644 > --- a/arch/powerpc/include/asm/checksum.h > +++ b/arch/powerpc/include/asm/checksum.h > @@ -130,6 +130,22 @@ static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, > return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); > } > > +#define HAVE_ARCH_CSUM_ADD > +static inline __wsum csum_add(__wsum csum, __wsum addend) > +{ > +#ifdef __powerpc64__ > + u64 res = (__force u64)csum; > + > + res += (__force u64)addend; > + return (__force __wsum)((u32)res + (res >> 32)); > +#else > + asm("addc %0,%0,%1;" > + "addze %0,%0;" > + : "+r" (csum) : "r" (addend)); > + return csum; > +#endif I'd have thought it better to test for the cpu type where you want the 'asm' variant, and then fall back on the C version for all others. I know (well suspect) there are only two cases here. I'd also have thought that the 64bit C version above would be generally 'good'. David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?