mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Charlie Jenkins <charlie@rivosinc.com>
Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Helge Deller <deller@gmx.de>, Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH 2/4] parisc: checksum: Use generic implementations
Date: Thu, 22 Feb 2024 08:04:27 -0800	[thread overview]
Message-ID: <e7bb76ae-285d-4840-ba58-c3fc5c5af6ec@roeck-us.net> (raw)
In-Reply-To: <20240221-parisc_use_generic_checksum-v1-2-ad34d895fd1b@rivosinc.com>

On Wed, Feb 21, 2024 at 06:37:12PM -0800, Charlie Jenkins wrote:
> 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 <charlie@rivosinc.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  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 <asm-generic/checksum.h>
> +
>  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;
> 
> -- 
> 2.34.1
> 

  reply	other threads:[~2024-02-22 16:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22  2:37 [PATCH 0/4] parisc: checksum: Use generic implementations and optimize checksum Charlie Jenkins
2024-02-22  2:37 ` [PATCH 1/4] asm-generic headers: Allow csum_partial arch override Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck
2024-02-22  2:37 ` [PATCH 2/4] parisc: checksum: Use generic implementations Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck [this message]
2024-02-22  2:37 ` [PATCH 3/4] parisc: checksum: Remove folding from csum_partial Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck
2024-02-22  2:37 ` [PATCH 4/4] parisc: checksum: Optimize from32to16 Charlie Jenkins
2024-02-22 16:04   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7bb76ae-285d-4840-ba58-c3fc5c5af6ec@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=charlie@rivosinc.com \
    --cc=deller@gmx.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®