Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp16778rdb; Mon, 4 Dec 2023 18:25:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvWU08JyhFwnSh3paoLLbCkjgnzgGOKBSyu08PAU/rdxIwgEA5EjVJI/+ZybZJ/XOGKa8O X-Received: by 2002:a17:903:48b:b0:1d0:748d:eaa4 with SMTP id jj11-20020a170903048b00b001d0748deaa4mr2290896plb.91.1701743145116; Mon, 04 Dec 2023 18:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701743145; cv=none; d=google.com; s=arc-20160816; b=haOa0BHh9OiPlknP4R2JR/ptQVCsxdGetmM9/vxHA57dgFWfe4ut4UWrz0bqwhxnz6 n3hPpvjLUYJXyJoAiI5K4FIA79kqxrxZ1JAl0r25tgo4zNUntPMymxa2M/oUupftkcmJ ZUsOteik2X4hNlcB0o7p7XUXyzRgYg7K0SA3Ada5g9czmTZ91/dI54cVvMBbjrSCui3s FjZl0I3YubIfWyztt7XnF+mhQdPc8O+qT5iaacZYNd8/wfyle31dyd5jJm9DNwjxDK07 Qx1QrqaVy79uCFZZwxWQgJXsrqhCoVf3teZ90tQ/Wcdt9Uz3i/GR78wBzknj/mv4Cy8Z IvzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wU9rQ0WHNb7K2eVSmVt58rzaZ/jgSlXiNPhlH8JqqSU=; fh=DgGXwGbnyiv1Rvt/NkXbEKOXDvWVLBCb4IpCdacEJoI=; b=iTk6+4Nqo84zaN2z3iQ4gz61NS/z++w/36HvzRA3wZqvSYJFgtJiIR+TScfj5zt7la PO28fAgIjqtZm8DP1zbUlvPsc6AusoqmSfOW+scw8fxpaM0rIwHlZL82JO/WTfcGHK6+ /ufLni1dgJtKz5OHDtQV1MzLHt2zagMERxQo+6RmAFaKAPv4jF4slTUkTEiM8AykHEVC YzQNpnHclsWkl2Sj/oOYLOAhA8IcEaQrOqj0Nb2jWRWWOrQCaVE8Nwrlsa+8KB9qPdMs hRh5wlxAONA67WRn9O33SBKM9DPWNrpKPdobyoSRlI+X/FW/yPWOgjZRFeFD12Lu8MUv aObA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=CMNsJnAO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id jf3-20020a170903268300b001d07b6a0ae6si4238480plb.257.2023.12.04.18.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 18:25:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=CMNsJnAO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 176FB80A0E28; Mon, 4 Dec 2023 18:25:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343907AbjLECYi (ORCPT + 99 others); Mon, 4 Dec 2023 21:24:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343998AbjLECYR (ORCPT ); Mon, 4 Dec 2023 21:24:17 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B7BA124; Mon, 4 Dec 2023 18:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=wU9rQ0WHNb7K2eVSmVt58rzaZ/jgSlXiNPhlH8JqqSU=; b=CMNsJnAO5W5GUIm/GCGKdv1gnh AbtJE1nqZ29lQH0iAZEBT2kYC4PGP4YqaXvRId7cbLU1qWwjwN94UgtgAK33snpgWe6weYNB7uUqE N9ONXc0u75jYiCYa55Q0u/koNQA9Zp2BJOvY31JiafAdEOBZfGhXxPy69Lj3/jFpK7269yac9jSbv DeYCtUJv5CvXqLyw/1KYr5ER1yKNOQpfvPsD7iHygUhKaOvuf2UgrSjJkaWTcaFCalMf7LDI1ipfC e3B4G0YG7EhesWIrTJ5L/PqC8Qf8F5nOTgz6Z494KtIZ9ARBqV8zZ4teTdThh+QfyH/h48/bFV9II rUBBAwbA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rAL6k-00793P-1b; Tue, 05 Dec 2023 02:24:22 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: gus Gusenleitner Klaus , Al Viro , Thomas Gleixner , lkml , Ingo Molnar , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "David S. Miller" , "dsahern@kernel.org" , "kuba@kernel.org" , Paolo Abeni , Eric Dumazet Subject: [PATCH v2 11/18] x86: merge csum_fold() for 32bit and 64bit Date: Tue, 5 Dec 2023 02:24:11 +0000 Message-Id: <20231205022418.1703007-20-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231205022418.1703007-1-viro@zeniv.linux.org.uk> References: <20231205022100.GB1674809@ZenIV> <20231205022418.1703007-1-viro@zeniv.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Al Viro X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 04 Dec 2023 18:25:34 -0800 (PST) Identical. Signed-off-by: Al Viro --- arch/x86/include/asm/checksum.h | 22 ++++++++++++++++++++++ arch/x86/include/asm/checksum_32.h | 14 -------------- arch/x86/include/asm/checksum_64.h | 18 ------------------ 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/arch/x86/include/asm/checksum.h b/arch/x86/include/asm/checksum.h index 6df6ece8a28e..eaa5dda09bee 100644 --- a/arch/x86/include/asm/checksum.h +++ b/arch/x86/include/asm/checksum.h @@ -1,13 +1,35 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_CHECKSUM_H +#define _ASM_X86_CHECKSUM_H #ifdef CONFIG_GENERIC_CSUM # include #else # define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1 # define HAVE_CSUM_COPY_USER # define _HAVE_ARCH_CSUM_AND_COPY + +/** + * csum_fold - Fold and invert a 32bit checksum. + * sum: 32bit unfolded sum + * + * Fold a 32bit running checksum to 16bit and invert it. This is usually + * the last step before putting a checksum into a packet. + * Make sure not to mix with 64bit checksums. + */ +static inline __sum16 csum_fold(__wsum sum) +{ + asm(" addl %1,%0\n" + " adcl $0xffff,%0" + : "=r" (sum) + : "r" ((__force u32)sum << 16), + "0" ((__force u32)sum & 0xffff0000)); + return (__force __sum16)(~(__force u32)sum >> 16); +} + # ifdef CONFIG_X86_32 # include # else # include # endif #endif +#endif diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h index 7570bdff7dea..4e96d0473f88 100644 --- a/arch/x86/include/asm/checksum_32.h +++ b/arch/x86/include/asm/checksum_32.h @@ -92,20 +92,6 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) return (__force __sum16)sum; } -/* - * Fold a partial checksum - */ - -static inline __sum16 csum_fold(__wsum sum) -{ - asm("addl %1, %0 ;\n" - "adcl $0xffff, %0 ;\n" - : "=r" (sum) - : "r" ((__force u32)sum << 16), - "0" ((__force u32)sum & 0xffff0000)); - return (__force __sum16)(~(__force u32)sum >> 16); -} - static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len, __u8 proto, __wsum sum) diff --git a/arch/x86/include/asm/checksum_64.h b/arch/x86/include/asm/checksum_64.h index 2bd75710eea1..d261b4124ca6 100644 --- a/arch/x86/include/asm/checksum_64.h +++ b/arch/x86/include/asm/checksum_64.h @@ -11,24 +11,6 @@ #include #include -/** - * csum_fold - Fold and invert a 32bit checksum. - * sum: 32bit unfolded sum - * - * Fold a 32bit running checksum to 16bit and invert it. This is usually - * the last step before putting a checksum into a packet. - * Make sure not to mix with 64bit checksums. - */ -static inline __sum16 csum_fold(__wsum sum) -{ - asm(" addl %1,%0\n" - " adcl $0xffff,%0" - : "=r" (sum) - : "r" ((__force u32)sum << 16), - "0" ((__force u32)sum & 0xffff0000)); - return (__force __sum16)(~(__force u32)sum >> 16); -} - /* * This is a version of ip_compute_csum() optimized for IP headers, * which always checksum on 4 octet boundaries. -- 2.39.2