RE: [PATCH] LoongArch: add checksum optimization for 64-bit system

From: David Laight
Date: Wed Feb 08 2023 - 08:12:57 EST


From: Bibo Mao
> Sent: 07 February 2023 04:02
>
> loongArch platform is 64-bit system, which supports 8 bytes memory
> accessing, generic checksum function uses 4 byte memory access.
> This patch adds 8-bytes memory access optimization for checksum
> function on loongArch. And the code comes from arm64 system.
>
> When network hw checksum is disabled, iperf performance improves
> about 10% with this patch.
>
...
> +static inline __sum16 csum_fold(__wsum csum)
> +{
> + u32 sum = (__force u32)csum;
> +
> + sum += (sum >> 16) | (sum << 16);
> + return ~(__force __sum16)(sum >> 16);
> +}

Does LoongArch have a rotate instruction?
But for everything except arm (which has a rotate+add instruction)
the best is (probably):
(~sum - rol32(sum, 16)) >> 16

To the point where it is worth killing all the asm
versions and just using that one.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)