Re: [PATCH 2/4] parisc: checksum: Use generic implementations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>

Tested-by: Guenter Roeck <linux@xxxxxxxxxxxx>

> ---
>  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
> 




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux