Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2836829rda; Wed, 25 Oct 2023 13:53:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyh872cfuSMQrX86uFvHl2+tWjDlCHRilpTXr0dt+jIp0ocj0gkIvDJidfkBVeTQu7qrcj X-Received: by 2002:a05:6808:2201:b0:3a4:ccf:6a63 with SMTP id bd1-20020a056808220100b003a40ccf6a63mr23397692oib.55.1698267202409; Wed, 25 Oct 2023 13:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698267202; cv=none; d=google.com; s=arc-20160816; b=TkNey2NQRMLgV2vfJz5QHCjgOpOikWFykgSQrAe/pYk1Ce8eH9+fM2UsLlkmEauXUR HvcN5oDQmxfZiaiAlyWAl8n2we7pGd74vuqTTFgbxwQoM42/iC8h2guJbr6yFSA7cgho ee55iqNGJkZYest2YT9ap4DqYmh08PKvm+me4N9Og3IrUiXpyQgCxjJ6wpk/BddZ4BjB 4lWaGwUmmn85LqFxwY2J7pwG2OzrNbs/gdTuuIqtYfXXhdAesW+7sGmZfu611/J/G6vl S1TRDb877lhKeQjyZVphRMlI8WDVTJserTEEGhX53QMIuWZIAOYSgqnj0wNRN0H5SDS+ e13Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=Lwkm4by0Rki3JY+h6pP3hgKn84sTDYv48INvl6mOPx0=; fh=WFftwgp1cQcXbMJqIMVcKDb81YGarFo4zuwk9SSBnRE=; b=TByWXBTbSSC31Dxt8mVgVj/Q+2VBp/RQtdYjLFcqNau988wWuQ6AHfpzkhiHsJWigh UuTcxl+31qN5Eo4yLXmxwcsz/btPrQnRfKoSNvGe5AyMMYriFSoFMexbJQneMjcg6ZN3 HuhKd6RHB4haEes43Lc8Do/3qLZsJb2YXctwrlJK1WEBpTmZgc85si86FGtt4Yeeoth4 9kVPtOVNSbS/FhtejMwkeBVVYt3IkucjHGHrNiAcrk285bAcy02t0ntk5RWJHNKpbhwO U4hgJNLxaERvfLT2qw/1+UTUDzmyyxlZoU3gLKmTP3BHOsQJThSq0K1/WvzzdrHum1Ll u3OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=EVs5SINr; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=nYndhwyO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id n196-20020a25dacd000000b00d8180e24be4si12761858ybf.18.2023.10.25.13.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 13:53:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=EVs5SINr; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=nYndhwyO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0615F81DF0D3; Wed, 25 Oct 2023 13:53:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbjJYUw5 (ORCPT + 99 others); Wed, 25 Oct 2023 16:52:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJYUwt (ORCPT ); Wed, 25 Oct 2023 16:52:49 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E803181; Wed, 25 Oct 2023 13:52:47 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1688C5C010D; Wed, 25 Oct 2023 16:52:44 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Wed, 25 Oct 2023 16:52:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1698267164; x=1698353564; bh=Lw km4by0Rki3JY+h6pP3hgKn84sTDYv48INvl6mOPx0=; b=EVs5SINrDuZyr+FdoB /KT2yCpM/aCvcgrKTwKt82ffUgNjPCOaT4detltoHGvUR8aujlpORn8a0u8niErV Zx2WyilaDcWVHGLVy2GheqlfE8XS3UyMlknBPkfqii2hcZtAwQrFhVe+7+LvngBI eRt7qJoteMZvrkXivybaTeYAwBuCaZTLgeyDG89ptUzBsyt9jFo/Lsjg5oM4r7w+ mY36Bs5NZ1Bxxit7llkhrYpWRVYAxWbgAYvzfFcfeaYTe5bUe+BHmNeqH76hJhWQ +9OwQXlH+KcAICkD4KApf7elWDkAPZjUvogsrmoW1nlZCJtIZ1Hzk7muoj3ihij8 oRPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698267164; x=1698353564; bh=Lwkm4by0Rki3J Y+h6pP3hgKn84sTDYv48INvl6mOPx0=; b=nYndhwyOjJwKekFfaJQ96GLSjBtgR 6KDIyg3YBnVEpIIWHoTtGVhJBmMyFqpXAmOoxOTQkS0al7c6R4xZh509P6ZSaBJt g8heyn4Ke8YhmqvFsj/jtlyFLLYzul3dAnOqt1IVwjTThbDIut0ZfkYN+bYP8MxK Aehus9MxE5cqcd0PKTXSjQe5j1PXtxMAHWySXaa8XRg7MZz9QVB9ogmv8gBkSjB3 qgmlBJNxxH7GmYhja5rTWgBz8TqahESrgLNmHAW7hhBWRSgcI3MyUf0cX6DFlWDE ai7vFOv9anFePpue4GW5iPtM9AzmwqgVa5wnAPLhuzDcwETvbliU726fw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrledtgdduheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 773ABB60089; Wed, 25 Oct 2023 16:52:43 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1048-g9229b632c5-fm-20231019.001-g9229b632 MIME-Version: 1.0 Message-Id: <059f17e6-e240-40fa-8742-7844ad3b3502@app.fastmail.com> In-Reply-To: References: <20230919-optimize_checksum-v7-0-06c7d0ddd5d6@rivosinc.com> <20230919-optimize_checksum-v7-2-06c7d0ddd5d6@rivosinc.com> Date: Wed, 25 Oct 2023 22:52:22 +0200 From: "Arnd Bergmann" To: "Charlie Jenkins" , "Wang, Xiao W" Cc: Linux-Arch , "Albert Ou" , "linux-kernel@vger.kernel.org" , "Conor Dooley" , "David Laight" , "Palmer Dabbelt" , "Paul Walmsley" , "linux-riscv@lists.infradead.org" Subject: Re: [PATCH v7 2/4] riscv: Checksum header Content-Type: text/plain X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 13:53:17 -0700 (PDT) On Wed, Oct 25, 2023, at 22:37, Charlie Jenkins wrote: > On Wed, Oct 25, 2023 at 06:50:05AM +0000, Wang, Xiao W wrote: >> > + >> > +/* >> > + * 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 equal >> > to 5. >> > + * @iph is assumed to be word aligned. >> >> Not sure if the assumption is always true. It looks the implementation in "lib/checksum.c" doesn't take this assumption. >> The ip header can comes after a 14-Byte ether header, which may start from a word-aligned or DMA friendly address. > > While lib/checksum.c does not make this assumption, other architectures > (x86, ARM, powerpc, mips, arc) do make this assumption. Architectures > seem to only align the header on a word boundary in do_csum. I worry > that the benefit of aligning iph in this "fast" csum function would > disproportionately impact hardware that has fast misaligned accesses. Most architectures set NET_IP_ALIGN to '2', which is intended to have the IP header at a 32-bit aligned address, though some other targets don't bother: arch/arm64/include/asm/processor.h:#define NET_IP_ALIGN 0 arch/powerpc/include/asm/processor.h:#define NET_IP_ALIGN 0 arch/x86/include/asm/processor.h:#define NET_IP_ALIGN 0 include/linux/skbuff.h:#define NET_IP_ALIGN 2 I think it's considered a driver bug if an SKB ends up with a misaligned IP header, but it's also something that some of the more obscure drivers get wrong. Arnd