Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757570AbbEVTcz (ORCPT ); Fri, 22 May 2015 15:32:55 -0400 Received: from mail-bn1on0112.outbound.protection.outlook.com ([157.56.110.112]:60976 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757201AbbEVTcx (ORCPT ); Fri, 22 May 2015 15:32:53 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=scottwood@freescale.com; Message-ID: <1432323162.27761.274.camel@freescale.com> Subject: Re: [PATCH v3 2/2] powerpc: add support for csum_add() From: Scott Wood To: David Laight CC: "'Christophe Leroy'" , Benjamin Herrenschmidt , Paul Mackerras , "Michael Ellerman" , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Date: Fri, 22 May 2015 14:32:42 -0500 In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CB3D471@AcuExch.aculab.com> References: <1d1362c8aa696e316d3ba97dce2342df6f6ee6cf.1432047904.git.christophe.leroy@c-s.fr> <063D6719AE5E284EB5DD2968C1650D6D1CB3D471@AcuExch.aculab.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [2601:2:5800:3f7:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: BLUPR02CA056.namprd02.prod.outlook.com (25.160.23.174) To CY1PR03MB1487.namprd03.prod.outlook.com (25.163.17.17) X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1487;2:0gj2AxcuivQGf18JBCyrkZjUqf10vWOJF9+bprB2vp+MEw5pSLWqIrjf369jP3iQ;2:12TUgLwvkl+y1EW5lVaQVt6gGgymqAU+llyolNuARaStoRAkiyTVPStzc/CNKd2e6y3W02pVGvJ5v2M4+Jm56FMrwZ6CFxff7+N8g3j+nd7nmUfznc8DKxWiSNqHSwl6zdOdHUBtqGYCFmhbHj0ITw==;6:rVBmAzxBwJctAm1+UssMlnf2U1MH5KIz8NNUcgzBlo7mIJgQEQdygpMnJxi8bn8HGgYo7sbbYOtr9gOKpsU/r+LK8W/7rVBgHjHoj7yMfx9pJ9aDBviha50Vk2Wcq3hUCJ5tAg31qlFVMKC4LrGvYmF6mgp6Y93W1DjHjhVUZEeiykYIeCUQfj+GnKsT0fQ0iSidvP44HgaJlvO6oQXTcXUECE7st6+6+gC6RCuLGVqtnURI4lJth3ACA8uite1bDhSZCivOZbVmgrfFox5Iebj4dBs3zzOP+hCzUhJv1KmnEM9WgKtuDLnORFekWRSmjYI5BI19NVjn5YwDrNuwO1whFpFDNijTZ+xmKICpthf6LhlrX5ALBba7oxH2PJP7GBGehSNccvUfFs4C7tlbTb1hnfLG/3CA13SPXtXsDk5UpGx+l0Z0Q+H77B//jlR+c/xNmcF5pQsr2ASGYFMklpgQaVcrBlIz3bjZfyB+zeVuaZ0432SOxXf1C28yqwgy X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1487; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520002)(3002001);SRVR:CY1PR03MB1487;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1487; X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1487;3:d7l8STNnKDvsbolme2y6EhZVxxZDHe9f2ftGEe01WpybGjg6loFsBojqluBGGcoL0AVcWh64FpgktICXqlBz2seWUJGnA2Asj09wIDTvg9Dm8Bo3nTw0Arj3MeTKI1NDSsNfZ0VwBOs07+JWRVbOsPD0+8LJoJzgH9BbJQQ0BnEC8ytd7rnDGDKd8vj/fZIqeBV+a6H6MCTqj4qrz1H9F+F4EJro/5gs39bJuNiGYuj+rs+aJL6E8kvP5lmmJAonvsMq2YYSPMN5OQ/a80MyPDdAGt67dR+ZpDBjdyP68MQBLu6kvNTdj/HG/EKHdGuf X-Forefront-PRVS: 058441C12A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(377424004)(199003)(51704005)(24454002)(189002)(92566002)(86362001)(33646002)(81156007)(2950100001)(68736005)(97736004)(36756003)(4001540100001)(77096005)(87976001)(103116003)(46102003)(50986999)(42186005)(50466002)(105586002)(47776003)(64706001)(106356001)(110136002)(23676002)(5820100001)(5001830100001)(77156002)(62966003)(40100003)(189998001)(76176999)(50226001)(101416001)(122386002)(5001960100002)(5001860100001)(99106002)(3826002)(5001840100002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR03MB1487;H:[IPv6:2601:2:5800:3f7:12bf:48ff:fe84:c9a0];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjAzTUIxNDg3Ozk6c2VPdmNrOFliaWJCM0F4R01UdU5YY0MraWFs?= =?utf-8?B?ZVBZYmpKQnRPVkVwakErRFkrcDhoc21YSC9XOUZqV0NOekljem1CNlRaWXp0?= =?utf-8?B?VWUrZ25YYzkxZzdWMEZLVUxMSFJmTlBsZ0RpeEFOTnBqMXAvSlE2RHptUVg1?= =?utf-8?B?MGMySGlyWmJUYi8xRk5wSDhQQjR6d2pLM01NbmNGRjJtUmtDRU9ncEpjSlJP?= =?utf-8?B?dzN5amFsL09QQWw1SE5Qc3FpUTk5T2FtQlplQ1dxOXhmUmI4VzJ2VFpyV0ZI?= =?utf-8?B?UUFkSWplWmRrQmxyZ0R5bitwYXdrOFN0dkJPRnU0cVluVlpjdVcraVJuUnYz?= =?utf-8?B?S1ZUT2trc1hVaCs5NkZTVlFENHROOWFNbTBZYm5sOWJ1STdXeFJhWWpZV2lQ?= =?utf-8?B?bzc2OVBWbng0Y0llRVRyYWNJMGRFTXFBRllCOE1yRHNOVldRUlBFQ2IyNmNP?= =?utf-8?B?UUY4azJ2SC8zS3pFdjVQajNLZ2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E8zSVpzL0hHMUlPbG9pdGVoanBEazNack1PWU5FMFNG?= =?utf-8?B?OTFZNGM1enJ6NGs5dVZ1aUZZZzlQeGZxRndrYldPbmN0NSsrR2NFeEMzYS8w?= =?utf-8?Q?8ERghKmhgA1EBnyPXu6Xo6Ac=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1487;3:hoOwqD6LU2VPZ1zN+GNoqVYIlSjYBWOhkwDn7oXbtacCe9dblfTkPptv1yhEkfnPNOUIux9C+plkB5lInfTX0hRmmIKbDnQskQu5l8VO5ktAquonEArKvaGdA3Om6F2G3wtMEKmgrr23Wva8+r5yAA==;10:Wpux3sTBTqq5QjiV2WVaDNVGimO6r2ugBEIPXgMIecqX9sgqLohVeFTTsMSfOXemPl4zEqDWgasWMXp8cZd3hY/SyItJ+GxdUvOwLC5odto=;6:ndB5TiDweEh4v2tCO40vul0P5HAxhXWtmAlT92jsbL2lMHskix5QKdnLTF20LebL X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2015 19:32:49.7394 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1487 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1788 Lines: 54 On Fri, 2015-05-22 at 15:57 +0000, David Laight wrote: > 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. Usually it's more readable to see "if (x) ... else ..." than "if (! x) ... else ..." and 64-bit is what has a symbol defined. > I'd also have thought that the 64bit C version above would be generally 'good'. It doesn't generate the addc/addze sequence. At least with GCC 4.8.2, it does something like: mr tmp0, csum li tmp1, 0 li tmp2, 0 addc tmp3, addend, tmp0 adde csum, tmp2, tmp1 add csum, csum, tmp3 -Scott -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/