Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp365395rdg; Thu, 12 Oct 2023 07:54:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFeGC6N+WdUEXRB/7uF1633sensCyWqIeFH1Cw9Epqlv0/ihxk/GKe7SSG7VQ4vR6tPiIU+ X-Received: by 2002:a05:6a20:e117:b0:175:59b5:5a61 with SMTP id kr23-20020a056a20e11700b0017559b55a61mr1769141pzb.60.1697122475325; Thu, 12 Oct 2023 07:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697122475; cv=none; d=google.com; s=arc-20160816; b=q/PuMmSyrqmYXW7hp2vejhaXH7Yw4aRdcXTcZ6igrJ8l7n0rL7yptZcbT8eq16O18l nXJaxXDfGP93CWmSipuC5TIBclvYLc1KDmlGD/ZGIHdFK39Q7qlETmffmg8IEj/kttn0 dgsEzfes7l8E5JYlxg+LL5gibFQujNg5k+xdCKDTqgJlASa3oQt8fTJn7xfrRiIuBL2E U3uC9uamsRIEhmxbPsYB54xrppgvbWmV6oo1+1pQVjWM72j7+wdAFNi4ukJudD5lrJxf uYKObm/9E6HTEOraZnwZMa6Xe3U4Hg895ItFQya7X7wU6l03unALuXozvRRiIwgb9YFb D+tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FFivrREyYN4u8wssy8Vzal1w2IHu19BuIws/jsdWC50=; fh=tO/lcMJ3vGu8ZcXExs9o7YHAcRH2d2ZInzY70+XfvRQ=; b=C6e7ubthMt2B3B6tswxr8GjY1yxVb8Jwnxv767lowAPCMUzKiSyYGrqyZ6ExXok7V7 vJwAhtFoEjpfo/VSEBf5Sk6IP06IvsDeytN5zeny06fV2c+foPNQ97jxsQViVvKVCP5s NPX6uNpVnbZcP/D9VMD0S07cwzSH/c0XW2g7GMrnZQVpETQOfPmm1Wcp792S2Mg2kGoM MtY0q4WVwzEmA5xrbZs6h0CFBNGb558j4ZDGWEXsHH0aZ3Nc/CiCfgDMvFgE1L0w7EeY znByGeEX9Wwci/CFtyynqtMxtEoVUeRy4wKmQ93n05+N4OB8tbPoWbTvOy6WxdSYQ4us YDMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iqiaPRzY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id gp9-20020a17090adf0900b0027d1b42875bsi2227961pjb.64.2023.10.12.07.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 07:54:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iqiaPRzY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DEC06803FF81; Thu, 12 Oct 2023 07:54:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379155AbjJLOyZ (ORCPT + 99 others); Thu, 12 Oct 2023 10:54:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbjJLOyX (ORCPT ); Thu, 12 Oct 2023 10:54:23 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EF0BD7; Thu, 12 Oct 2023 07:54:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96553C433C7; Thu, 12 Oct 2023 14:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697122461; bh=+ojXCG56gMjVZw+vx9Pj6zEubeSQNGY9Yfj0hYNQrvU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iqiaPRzY62d+KCn53LW4SeKoB5rJrf8XYH/0uzqIfa+WEd6tvkNAvImgd25Eql9wm z9SfRMb3GsqCHUZiyrFhNSSR9eOR9DWiBiJALphEf+A+CboBiAb8nis1weMnpwdvZa mQEeZBoedIqE1bXF3we+nYFkHweXsTDXK6AnC6i1vyuCJvN0UEShPSfclDBRB/zTmK A7Rx/IhBWKziaV8gjoOEa1V6QyZyYYFqLiaKiSGBqKRWV1hFYRvJ38h1BCceYQtOn8 RdYbxGhpJlllcCDQYeSXQGXbiTwQS+NoB6f+ktAc8O2hFHaWBZd9V16tJZWUC01r8u kH7rHVW6l27mg== Date: Thu, 12 Oct 2023 15:54:17 +0100 From: Conor Dooley To: Charlie Jenkins Cc: Palmer Dabbelt , Samuel Holland , David Laight , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Paul Walmsley , Albert Ou , Arnd Bergmann Subject: Re: [PATCH v7 2/4] riscv: Checksum header Message-ID: <20231012-directory-drapery-fec6c7e2419d@spud> References: <20230919-optimize_checksum-v7-0-06c7d0ddd5d6@rivosinc.com> <20230919-optimize_checksum-v7-2-06c7d0ddd5d6@rivosinc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="/uRjsvow0K0+ny7V" Content-Disposition: inline In-Reply-To: <20230919-optimize_checksum-v7-2-06c7d0ddd5d6@rivosinc.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 12 Oct 2023 07:54:33 -0700 (PDT) --/uRjsvow0K0+ny7V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 19, 2023 at 11:44:31AM -0700, Charlie Jenkins wrote: > Provide checksum algorithms that have been designed to leverage riscv > instructions such as rotate. In 64-bit, can take advantage of the larger > register to avoid some overflow checking. >=20 > Signed-off-by: Charlie Jenkins Same here, Acked-by: Conor Dooley I think there are some "issues" attributed to this patch by the automation - but they spurious. This diff here could not cause a drivers/block/drbd/drbd_bitmap.c:1271: warning: Function parameter or membe= r 'peer_device' not described in 'drbd_bm_write_copy_pages' after all. Cheers, Conor. > --- > arch/riscv/include/asm/checksum.h | 79 +++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 79 insertions(+) >=20 > diff --git a/arch/riscv/include/asm/checksum.h b/arch/riscv/include/asm/c= hecksum.h > new file mode 100644 > index 000000000000..dc0dd89f2a13 > --- /dev/null > +++ b/arch/riscv/include/asm/checksum.h > @@ -0,0 +1,79 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * IP checksum routines > + * > + * Copyright (C) 2023 Rivos Inc. > + */ > +#ifndef __ASM_RISCV_CHECKSUM_H > +#define __ASM_RISCV_CHECKSUM_H > + > +#include > +#include > + > +#define ip_fast_csum ip_fast_csum > + > +#include > + > +/* > + * Quickly compute an IP checksum with the assumption that IPv4 headers = will > + * always be in multiples of 32-bits, and have an ihl of at least 5. > + * @ihl is the number of 32 bit segments and must be greater than or equ= al to 5. > + * @iph is assumed to be word aligned. > + */ > +static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) > +{ > + unsigned long csum =3D 0; > + int pos =3D 0; > + > + do { > + csum +=3D ((const unsigned int *)iph)[pos]; > + if (IS_ENABLED(CONFIG_32BIT)) > + csum +=3D csum < ((const unsigned int *)iph)[pos]; > + } while (++pos < ihl); > + > + /* > + * ZBB only saves three instructions on 32-bit and five on 64-bit so not > + * worth checking if supported without Alternatives. > + */ > + if (IS_ENABLED(CONFIG_RISCV_ISA_ZBB) && > + IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) { > + unsigned long fold_temp; > + > + asm_volatile_goto(ALTERNATIVE("j %l[no_zbb]", "nop", 0, > + RISCV_ISA_EXT_ZBB, 1) > + : > + : > + : > + : no_zbb); > + > + if (IS_ENABLED(CONFIG_32BIT)) { > + asm(".option push \n\ > + .option arch,+zbb \n\ > + not %[fold_temp], %[csum] \n\ > + rori %[csum], %[csum], 16 \n\ > + sub %[csum], %[fold_temp], %[csum] \n\ > + .option pop" > + : [csum] "+r" (csum), [fold_temp] "=3D&r" (fold_temp)); > + } else { > + asm(".option push \n\ > + .option arch,+zbb \n\ > + rori %[fold_temp], %[csum], 32 \n\ > + add %[csum], %[fold_temp], %[csum] \n\ > + srli %[csum], %[csum], 32 \n\ > + not %[fold_temp], %[csum] \n\ > + roriw %[csum], %[csum], 16 \n\ > + subw %[csum], %[fold_temp], %[csum] \n\ > + .option pop" > + : [csum] "+r" (csum), [fold_temp] "=3D&r" (fold_temp)); > + } > + return csum >> 16; > + } > +no_zbb: > +#ifndef CONFIG_32BIT > + csum +=3D (csum >> 32) | (csum << 32); > + csum >>=3D 32; > +#endif > + return csum_fold((__force __wsum)csum); > +} > + > +#endif // __ASM_RISCV_CHECKSUM_H >=20 > --=20 > 2.42.0 >=20 --/uRjsvow0K0+ny7V Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZSgImQAKCRB4tDGHoIJi 0vbVAPwKRp4UXBThl9GOTew5j0FmY9XGj3v2k798QY2F9FGN2QEA6p0JzpE5uOBn UP4ZzpdYbI/4Col0rf3CIiy6hz1TkA8= =R5LB -----END PGP SIGNATURE----- --/uRjsvow0K0+ny7V--