From patchwork Thu Feb 22 02:37:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13566665 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53DEE12E4A for ; Thu, 22 Feb 2024 02:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569456; cv=none; b=FXApV792ha6O5KEeR1AA4NwVVc39yh16qbVnJgiMnXkgqBv7CifEFaFChX5gy73rLExDVkyAjBxqrpYKozkNEPk434ssO5wGp2QjGITNLtkVFgsvQi6wZQ+xeQL2A1Bw3uQAzIoHzBTzEY990xVLG+w2LywbNT+opDzNaj4zUVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569456; c=relaxed/simple; bh=sNekCmUtLWlwQH/XsGvAEvEx2UjQ+qNezBis71mVY4E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VpwnqayG9PygNRItdtJTP0WpiObKZ25IidB/3T2XY8+T8X6xHJIFVZpRQcx+Ehjo4s2cQEQ4leTu+WPClFDWNOSArCbXPzRrpVH+4YGYDzZg6Jn0+o94zrdAjnhrTP60mp9r34oQPU2Zvc+03QvncruCXXbUUFHsppCHVaalftg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=n2S1A4KI; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="n2S1A4KI" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e46dcd8feaso2398959b3a.2 for ; Wed, 21 Feb 2024 18:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1708569453; x=1709174253; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VbWwM7zPic1o2n8E79ikwcyfydTfqLLzWcN1NjJT53s=; b=n2S1A4KI4xKCMwYeYxrEQa4nzp2ZiNEv2cCqdoud4K9FNa5ZsAkcltDavzafgVQLYK DLmvmFCaJPyxeJAEy2fsUV06b0Pbyi2QDgI7bkp31JIMIQnH1Z/AjkDhUaXgPeig203V gIpadKz8m5LIz8JVXyvIIX9a2Q/rsI8TnfZTDh343Unb7wWAEoaUCVGKYJ8ApvXG5bLC sodA37sAzLXTDbwj51LrZesjKmsun+EssLEKV1JwwgV5+Vy2qs6lw/6AnCUPJccEV+CB shO70xyy/kS3OBWWdCkmEGxeZBUBKgZgn9ijewsibTKFJwBoJXxO5T+N8BuqhpxQCeQd 6C4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708569453; x=1709174253; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VbWwM7zPic1o2n8E79ikwcyfydTfqLLzWcN1NjJT53s=; b=WZQ3lCpw6oSeXUxin+rsI46UVxoLvUYkyyRSE9nJvNIuGICgEDhyFFayCkzpoLbv+y 0c+Nq3jZYmeqLSfoOSdL8YxE80VeKz+xtOhDKNA8N/Tt2Mopcx7ThMRSJ2setq427fIN lnkasOrFw5h4GxEeHvEadrjX8zpwYVNJMSF61IhIEvs/ZhgY6epOt6jzdQId9G6bStQS +JJaVMxFr5E59z82jA2H0cz7gDoY5eqJsbdfwWp3vC/lbhr8ez4H4OD5Ho7oAmgb1i+f quu+h63VP+5dsihXmZw6ZA274vGjtFgUSc/fpumiS8xe0tJkz3IJqjj0GZJEYP/2pijF AeGQ== X-Gm-Message-State: AOJu0YyjUG8J+BptUUw6Th90ct6RdpIYskvHZw02FcwBJc7TtNalqpk/ ycIXynGDJhplGkdrYl/82LSDSUOuGZtp5iOqxN4lUSchalp3ov5lWq/5iMbCiKY= X-Google-Smtp-Source: AGHT+IFtZGKup9T6YYI7PmRS1JDh3YEQ7nwhJf2ABKpiAKBuUhTyJtqhoSWcShDrWUosyp9JWBH/MQ== X-Received: by 2002:a05:6a00:da:b0:6e4:c5a1:e41d with SMTP id e26-20020a056a0000da00b006e4c5a1e41dmr1396178pfj.29.1708569453628; Wed, 21 Feb 2024 18:37:33 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id kt21-20020a056a004bb500b006e465e1573esm6469705pfb.74.2024.02.21.18.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 18:37:33 -0800 (PST) From: Charlie Jenkins Date: Wed, 21 Feb 2024 18:37:11 -0800 Subject: [PATCH 1/4] asm-generic headers: Allow csum_partial arch override Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240221-parisc_use_generic_checksum-v1-1-ad34d895fd1b@rivosinc.com> References: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> In-Reply-To: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> To: "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Andrew Morton , Guenter Roeck Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708569451; l=1437; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=sNekCmUtLWlwQH/XsGvAEvEx2UjQ+qNezBis71mVY4E=; b=g+fjMFlNSWfcCrlu2uFDLLNXHSUDovxevoYfasXSOOsYTDbSYie7Kx4HZ/ltvBWgwxDLH99EH QhtbgMGsTK1C6kG7qoIseYXNTILqnnfDUH9Um6xbzAAZtYxm8RUNSa+ X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= Arches can have more a efficient implementation of csum_partial. Signed-off-by: Charlie Jenkins Tested-by: Guenter Roeck --- include/asm-generic/checksum.h | 2 ++ lib/checksum.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/asm-generic/checksum.h b/include/asm-generic/checksum.h index ad928cce268b..3309830ba2cb 100644 --- a/include/asm-generic/checksum.h +++ b/include/asm-generic/checksum.h @@ -4,6 +4,7 @@ #include +#ifndef csum_partial /* * computes the checksum of a memory block at buff, length len, * and adds in "sum" (32-bit) @@ -17,6 +18,7 @@ * it's best to have buff aligned on a 32-bit boundary */ extern __wsum csum_partial(const void *buff, int len, __wsum sum); +#endif #ifndef ip_fast_csum /* diff --git a/lib/checksum.c b/lib/checksum.c index 6860d6b05a17..c115a9ac71d9 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -110,6 +110,7 @@ __sum16 ip_fast_csum(const void *iph, unsigned int ihl) EXPORT_SYMBOL(ip_fast_csum); #endif +#ifndef csum_partial /* * computes the checksum of a memory block at buff, length len, * and adds in "sum" (32-bit) @@ -134,6 +135,7 @@ __wsum csum_partial(const void *buff, int len, __wsum wsum) return (__force __wsum)result; } EXPORT_SYMBOL(csum_partial); +#endif /* * this routine is used for miscellaneous IP-like checksums, mainly From patchwork Thu Feb 22 02:37:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13566667 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F72614296 for ; Thu, 22 Feb 2024 02:37:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569457; cv=none; b=A1E5gVBVdo57ctWwx2GUA1Uj5HUL0TtMGn2Rpf6lwky44czog73FvoAOGM1Uj+ZM3/M9o4Ucx2NEywRWef4L7H8VG/OXdiA7emrtYh2d3O8S05JvRuenrvIiC1pm3hEW8I7hnQQQLtyeUqVf1qOb2OVpukYoJauUvkuLX6kWJvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569457; c=relaxed/simple; bh=l+USg6YpypTRM0+WpzcfEdryMXsoNQLARzL5GiGzQLo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=moJcNZKmKe5LIYprXCp9aKkxJyZOpzSluNSXGxH/V2O0EXaWaU9DmOzkhVi4uG4f7pe0MqiXbxoT/nJQ42D/VYzhmmWZnWMNoH/sYILN05sdotrpsBIYILDtMa+uAvpX2RcqSg4T35ThdxWqLFfFoqgEXj1TG2nJ/N3g2iOCnf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=My0RCvBz; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="My0RCvBz" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e471f5f1a5so2331462b3a.1 for ; Wed, 21 Feb 2024 18:37:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1708569455; x=1709174255; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xdYAIYdQG1Ak9nX+umevv7MEU7fdacXyP4+T5jQwePU=; b=My0RCvBzyoUfAKwvIOr/6evWcNGJLzzMtcwkKb1D9MGInpj5eIYlBD5Y+69md2E4KJ Waqg4RYOkpbP2Ot1BJDPWg7cSW4y2YUqGcuMRe661H/ffqPP6Pb9FjG1pTbgS/y+kOrc GQflr0RrvAS5OpusJ1bITlWwEampTy7okf7lJd6c/qg0Gd8yZb9Ll9M9DGE2i8rXDS6m +4Z215xFLj2LD0coTLSHrk2dwaHpJAfYx7M2BK+TXYl74fhNMrwPU4KJe9yhpU77ItnZ rwZxvpmInhbhohbGxbXBrUejxQbrio2OWOpqHFh2GtnE9xhmJQ3M95q2HUQZP0UpCbqu rd+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708569455; x=1709174255; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xdYAIYdQG1Ak9nX+umevv7MEU7fdacXyP4+T5jQwePU=; b=UlZPqm/xBIDEhNcAeb/B3ICQF4yHH086CzGVzN7GDg7nukL29YZrAIZWlCidef7bN9 WUu9M7bL0B+3pU5lVRh+rsThZ0S5Stiqc2w8hZmYdMc4/DyPO1Qi0Dqj1eTvsgtghQo6 +S51r9iDygz6j2NIeyR8OrwtmC8nG3YgfkpO1aISxXN/5v5S7Y43QHfqxd2D+9XuENLG FMolEf/uz4glp5k6cv0nl984hGs/munbWIFLXXexMHxq+8GcdI2eliv6I4PZ+HsZ7zI/ XTApF2pLSeadE7hoz3t/6LtmRVQS7N5YZTJ6MPlf2JkVYCF6pv0s1ndEeV1kpYRKNdQD QniA== X-Gm-Message-State: AOJu0YxZyT1s+sR4ZlP8nCxR7QNXIHxDcW133bsp6K8rILkNeK4Ogk9x aAVOY80ZodbrE8Pb6eckamPAQVRTpt/uigqYq6WO8FsqUyqfn18SdMa5oCOkFt8= X-Google-Smtp-Source: AGHT+IECw2nme63hi+mxaAn1NvEiiav0mQgIl1MQUmLPHTPgHSppDVeUu9MO0MA/vVcETkLZhGo+RQ== X-Received: by 2002:a05:6a00:1d92:b0:6e4:ce30:ae1 with SMTP id z18-20020a056a001d9200b006e4ce300ae1mr229424pfw.20.1708569454826; Wed, 21 Feb 2024 18:37:34 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id kt21-20020a056a004bb500b006e465e1573esm6469705pfb.74.2024.02.21.18.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 18:37:34 -0800 (PST) From: Charlie Jenkins Date: Wed, 21 Feb 2024 18:37:12 -0800 Subject: [PATCH 2/4] parisc: checksum: Use generic implementations Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240221-parisc_use_generic_checksum-v1-2-ad34d895fd1b@rivosinc.com> References: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> In-Reply-To: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> To: "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Andrew Morton , Guenter Roeck Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708569451; l=3620; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=l+USg6YpypTRM0+WpzcfEdryMXsoNQLARzL5GiGzQLo=; b=B+aW/3quyGTiPp/dimTVueCw78vaqCIG5wP05i6PchiAwl3gIbzt2dwaZ6dscnmEwLFzm7aBr xnekuqU4P72D8HfAbwftg4vIXq2sfQCtMjwzQBEvRc/VMEK7L9+evsT X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= The generic implementations of the checksum functions csum_tcpudp_nofold, csum_fold, and ip_compute_csum are either identical or perform better than the parisc ones, so use the generic implementations instead. In order to use the generic implementations of checksum functions, do_csum can no longer be static. Signed-off-by: Charlie Jenkins Tested-by: Guenter Roeck --- arch/parisc/Kconfig | 3 +++ arch/parisc/include/asm/checksum.h | 42 ++++++++------------------------------ arch/parisc/lib/checksum.c | 2 +- 3 files changed, 13 insertions(+), 34 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index d14ccc948a29..1638deb23287 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -122,6 +122,9 @@ config GENERIC_BUG config GENERIC_BUG_RELATIVE_POINTERS bool +config GENERIC_CSUM + def_bool y + config GENERIC_HWEIGHT bool default y diff --git a/arch/parisc/include/asm/checksum.h b/arch/parisc/include/asm/checksum.h index 3c43baca7b39..c7847a08ef7c 100644 --- a/arch/parisc/include/asm/checksum.h +++ b/arch/parisc/include/asm/checksum.h @@ -17,6 +17,7 @@ * it's best to have buff aligned on a 32-bit boundary */ extern __wsum csum_partial(const void *, int, __wsum); +#define csum_partial csum_partial /* * Optimized for IP headers, which always checksum on 4 octet boundaries. @@ -57,20 +58,8 @@ 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 csum) -{ - u32 sum = (__force u32)csum; - /* add the swapped two 16-bit halves of sum, - a possible carry from adding the two 16-bit halves, - will carry from the lower half into the upper half, - giving us the correct sum in the upper half. */ - sum += (sum << 16) + (sum >> 16); - return (__force __sum16)(~sum >> 16); -} - +#define ip_fast_csum ip_fast_csum + static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len, __u8 proto, __wsum sum) @@ -85,28 +74,15 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, return sum; } -/* - * computes the checksum of the TCP/UDP pseudo-header - * returns a 16-bit checksum, already complemented - */ -static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, - __u32 len, __u8 proto, - __wsum sum) -{ - return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); -} - -/* - * this routine is used for miscellaneous IP-like checksums, mainly - * in icmp.c - */ -static inline __sum16 ip_compute_csum(const void *buf, int len) -{ - return csum_fold (csum_partial(buf, len, 0)); -} +#define csum_tcpudp_nofold csum_tcpudp_nofold +extern unsigned int do_csum(const unsigned char *buff, int len); +#define do_csum do_csum #define _HAVE_ARCH_IPV6_CSUM + +#include + static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __u32 len, __u8 proto, diff --git a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c index 4818f3db84a5..05f5ca4b2f96 100644 --- a/arch/parisc/lib/checksum.c +++ b/arch/parisc/lib/checksum.c @@ -34,7 +34,7 @@ static inline unsigned short from32to16(unsigned int x) return (unsigned short)x; } -static inline unsigned int do_csum(const unsigned char * buff, int len) +unsigned int do_csum(const unsigned char *buff, int len) { int odd, count; unsigned int result = 0; From patchwork Thu Feb 22 02:37:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13566668 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D792017553 for ; Thu, 22 Feb 2024 02:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569459; cv=none; b=NyvQrx7oX2pMINyLoWQ6lga4IRv190nyx4sfUjHaaDesqtjOYR7+doyUZJraS4RcqoqNpHpALE/JojcRIbJW8tJ45mSPmD9DKApgE5RP8dBlSyBi9EJy+vnitsP52NY3WH7WyxsPkqF7ZNx04b7zNu4Ifq/rJ2CWIFkqnU1rJaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569459; c=relaxed/simple; bh=loWpjUeaU5B9E/ejxOfrGk83272NpESpvlB1T6y7RcU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EdvF+yj8NIxjxQHMPNe1TUReXt1WX2CbNEbMpM40pPhdINUxLMhMhpm5q2aBw58xkW9RW/TUTpiZzFOontd09lu9ZCeRGe0NzNrVBGL2e9UkiMvp9+i0wzCnp5nW9OZ53h4Ts00jH2y3uvhaQpDPP7wMv+HLl2TgA5v1upbkc9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=bDqLaH4M; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="bDqLaH4M" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3c1404d05bfso5399585b6e.3 for ; Wed, 21 Feb 2024 18:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1708569456; x=1709174256; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZGrNzxe3gyC6VQWPSLHOaYx0WPaI3IQ/8Jr8tyLxsyE=; b=bDqLaH4Mz6HBVCQH8/bzqJM/xjCxIxcGrIh8PIEU0TYPLwt6nH79zDhos0DOTlmk/R sewKpdEG84CTfUkO4fqkKo+KLgPemD7mqj176D+7eicT/3SoHLmguQVgQkvNX5ol1zoE 1W7S3IroWirVSWaPWLLTcdWP2uQMrDsflRj7BxPghmFDaR2YAXMEKZSs0qejzkCxbjGA SPlxggHVkvmjfUHi8n+B1W5tu/YIAmEF7fyYfycUAhwAiGUCgm2UfQa7df201Dg9OBTJ /MxdofkD0gNu3TRQycgc42xIeApQf4q278El0L7milqb7PMFVtXnJXTxROIBSCctm+Os siJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708569456; x=1709174256; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZGrNzxe3gyC6VQWPSLHOaYx0WPaI3IQ/8Jr8tyLxsyE=; b=ZWXHuUWT2O7R46bGCoydA3OUdEGzLqEHSFToxtEZGMvZlbPpHkZCYJJ/gIho39Ypwk um7gNEzv4b5X3IzJZabLgAVPz75SqrrnKrcUQJAAbCBUqOiL+g5zwgHd9ZMs7slrPhCt hjG97mXrWP+P/Q4EZLxkSq4tUH9L5l4BlbiHD28VjQ7Jy97cSYwqtsyn2vqj2ecDec22 oDnfUr6kQ8d5xjkqfRGHcIgU444X9IeQMxi1WeIJJXU09tBRHVJe0WGrOMLsHhdgIkyu qLFGEd0K1lhqvl+4S6yLXQ7FTZEx+FEZvS5+LozFbotfyPwWMmUnUPAcSlOWer3m12NQ nuQQ== X-Gm-Message-State: AOJu0YynPnWDksigg22eHWTEywkse7Hss45b5y5sNV9ZEHmGOx9bJN3O o2Bp3T8BdHy34h4UdYs4Qt03RuMGplTtwrmtdSaOEW48NOrFOmNu4v3dx7Louxo= X-Google-Smtp-Source: AGHT+IHr4SZnfJdYWs07MIcE+jUM6/a0JrEuqqzI8zGh/SYhR/8eR1eYgSYBAmBjDUh92jlYMvK//Q== X-Received: by 2002:a05:6359:45a9:b0:17b:335c:fa07 with SMTP id no41-20020a05635945a900b0017b335cfa07mr13781339rwb.32.1708569455998; Wed, 21 Feb 2024 18:37:35 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id kt21-20020a056a004bb500b006e465e1573esm6469705pfb.74.2024.02.21.18.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 18:37:35 -0800 (PST) From: Charlie Jenkins Date: Wed, 21 Feb 2024 18:37:13 -0800 Subject: [PATCH 3/4] parisc: checksum: Remove folding from csum_partial Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240221-parisc_use_generic_checksum-v1-3-ad34d895fd1b@rivosinc.com> References: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> In-Reply-To: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> To: "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Andrew Morton , Guenter Roeck Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708569451; l=1119; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=loWpjUeaU5B9E/ejxOfrGk83272NpESpvlB1T6y7RcU=; b=xtNabUDylbAE6Wad/8orZRl3dAazwQY8qAbie+Ef8VKsiWBGicqZfawURBgIzMindz5keC/GQ JFElQKZrZefDR+vZaVkejbXrGuxRi9Xb6hk2IyfNMsmFd1KK3OjfEjC X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= The parisc implementation of csum_partial previously folded the result into 16 bits instead of returning all 32 bits and letting consumers like ip_compute_csum do the folding. Since ip_compute_csum no longer depends on this requirement, remove the folding so that the parisc implementation operates the same as other architectures. Signed-off-by: Charlie Jenkins Tested-by: Guenter Roeck --- arch/parisc/lib/checksum.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c index 05f5ca4b2f96..eaa660491e24 100644 --- a/arch/parisc/lib/checksum.c +++ b/arch/parisc/lib/checksum.c @@ -95,14 +95,11 @@ unsigned int do_csum(const unsigned char *buff, int len) /* * computes a partial checksum, e.g. for TCP/UDP fragments */ -/* - * why bother folding? - */ __wsum csum_partial(const void *buff, int len, __wsum sum) { unsigned int result = do_csum(buff, len); addc(result, sum); - return (__force __wsum)from32to16(result); + return (__force __wsum)result; } EXPORT_SYMBOL(csum_partial); From patchwork Thu Feb 22 02:37:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13566669 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C45DB17576 for ; Thu, 22 Feb 2024 02:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569459; cv=none; b=tQBurBkBaHaWnO7FEg5vjpbdAYAmM/N/DrwlEXSWPWmCAYDEaOXvLkwLOeCk8OVe6wPNwpOUW9DvCx15V9lKQbcotms6Tj1OgELunw3hc2fz2vEmupRUKl5FkQEXkKqzG4VK2C0mEs7Q0yG/9PlIaUwGWWwA6XV0Xn6e89IN3Js= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708569459; c=relaxed/simple; bh=mYOv5YQT1yDdOTCAzi4OkkPsYH4iMvZEO+odMa9t9OU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mOreJzAG3plR9os5Y+qjZk1fUpBu161z0SOryv4Q1DXrs7qAjdHQxpkKjMWOXu3+pF7sbH0losgZ0PlsSUyZ2j/ZHijHvznXl67xe4kXuLJUJVdyI4UPD05s/CMs7nM4Nt+BeE41y/dEuwsPARI9rX96erTOfsRne+ZwPtHHIuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=jilndtav; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="jilndtav" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e471f5f1a5so2331479b3a.1 for ; Wed, 21 Feb 2024 18:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1708569457; x=1709174257; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=K6YZh5OBHggNhG2iazj7ayAHylZjnHIget6Lw5n4A74=; b=jilndtav6wK9tlin1vZ80mFJXVjji8doG7sZyl7JpysdxrkyxaOefh6QIAmLsoXFgj wNTbNODr/2hOaE7wIOvZWUmgtrP0HweIbG2zpPvCS3A/rrjc3YTpU7k9x2/WEVCQT/SK pJXf415f+RZt3z466pXUGS5I+zPL6761GDxu5FvNSVOlhEvuQUzT0VR1WkqlupHQSoI7 M7rGYjUmygHH3KA0VoUKceZbVHGW/oFAwZJf6Und66esSukQHLQWqE0FCkhyYSkbwLW6 v1whZDp+GwAJxQtw3Eu3DY+IQ+9l9VPoDjXTzyaccYq+V5w6JBJv6qylE8q7bsWSf0mQ L3RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708569457; x=1709174257; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K6YZh5OBHggNhG2iazj7ayAHylZjnHIget6Lw5n4A74=; b=OJBu8V1a+c8iCX6E6nxQJXLj9K/I4OVuvxdrjbTxhDRcwb5NgfuT1tf/I42/ErZzQ/ tRpTqTmzVekAb06JqgxjMBUiei61cXHq78CfrxoNEAW/53KDIaf50kPuN8Tw56UUdUyN fVyUNdVHWNdxyXsemUlaeG/fUovi8CK24+HpqEszdNS05tDr+E466MDZLpn96LBMgfEn 8N58QD2M2XyWDKaQ65qfVaUKQXInJuqMluUCaAEp5WqcFiDVHtUA6lhtv1SmumnflwXY +Gas79ctG9bEX9sf96sKxmHHsqDqImHPUNeUKheqhZ3dyVRAFd0oZPpgVYMghqDqhgF4 5MSw== X-Gm-Message-State: AOJu0YyyiungEByGyG0Ba4gia+zGF5sTuNfxqALYBW7ZbpkfEmte/pZy j1hhKkDMUcAf0RN7DtWKMJpQt5SPLqitezVzPLXuZuZMnANJOFbmLU3s+3YQohNAGMTpRavnZtn 0 X-Google-Smtp-Source: AGHT+IE3upPGQXOLuSEUYyLoC9ayLGnKcG6FlBuS7HyfXj6mdUciEX9+OmA1mgOUixbXnJmCmqn9Pw== X-Received: by 2002:a62:e306:0:b0:6e4:cf7c:6c28 with SMTP id g6-20020a62e306000000b006e4cf7c6c28mr15413pfh.22.1708569457164; Wed, 21 Feb 2024 18:37:37 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id kt21-20020a056a004bb500b006e465e1573esm6469705pfb.74.2024.02.21.18.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 18:37:36 -0800 (PST) From: Charlie Jenkins Date: Wed, 21 Feb 2024 18:37:14 -0800 Subject: [PATCH 4/4] parisc: checksum: Optimize from32to16 Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240221-parisc_use_generic_checksum-v1-4-ad34d895fd1b@rivosinc.com> References: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> In-Reply-To: <20240221-parisc_use_generic_checksum-v1-0-ad34d895fd1b@rivosinc.com> To: "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Andrew Morton , Guenter Roeck Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708569451; l=833; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=mYOv5YQT1yDdOTCAzi4OkkPsYH4iMvZEO+odMa9t9OU=; b=kcPBmJJuQfkQSLxjGXYurjNDqCrgbi6FLLWky02d0x0JjqeH/QjvkkY9LAedCaybC9FPI+/Uo 2tOaKUsjuarDrM9ZBbUaloDo2KRy4cHqTwp5CTnTJDmua6pJs9ksfxQ X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= Replace the shifting and masking of x with a rotation. This generates better assembly. Signed-off-by: Charlie Jenkins Tested-by: Guenter Roeck --- arch/parisc/lib/checksum.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c index eaa660491e24..1ae8cc730d13 100644 --- a/arch/parisc/lib/checksum.c +++ b/arch/parisc/lib/checksum.c @@ -27,11 +27,8 @@ static inline unsigned short from32to16(unsigned int x) { - /* 32 bits --> 16 bits + carry */ - x = (x & 0xffff) + (x >> 16); - /* 16 bits + carry --> 16 bits including carry */ - x = (x & 0xffff) + (x >> 16); - return (unsigned short)x; + x += ror32(x, 16); + return (unsigned short)(x >> 16); } unsigned int do_csum(const unsigned char *buff, int len)