[PATCH 0/5] riscv: Add fine-tuned checksum functions

Charlie Jenkins
2023-08-27T01:27:05Z

Each architecture generally implements fine-tuned checksum functions to
leverage the instruction set. This patch adds the main checksum
functions that are used in networking.

Vector support is included in this patch to start a discussion on those
since I am not super familiar with the vector instructions. I wasn't
able to get the vector patches to compile in the kernel, but as vector
support matures I will be able to go back and fix them up. I have tested
the vector patches as standalone algorithms in QEMU.

These functions work best with the Zba and Zbb extensions, so support
for those instructions were added to the kernel.

To test this patch, enable the configs for KUNIT, then CHECKSUM_KUNIT
and RISCV_CHECKSUM_KUNIT.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
---
Charlie Jenkins (5):
riscv: Checksum header
riscv: Add checksum library
riscv: Vector checksum header
riscv: Vector checksum library
riscv: Test checksum functions

arch/riscv/Kconfig | 23 +++
arch/riscv/Kconfig.debug | 1 +
arch/riscv/Makefile | 2 +
arch/riscv/include/asm/checksum.h | 165 ++++++++++++++++++++
arch/riscv/lib/Kconfig.debug | 31 ++++
arch/riscv/lib/Makefile | 3 +
arch/riscv/lib/csum.c | 283 ++++++++++++++++++++++++++++++++++
arch/riscv/lib/riscv_checksum_kunit.c | 111 +++++++++++++
8 files changed, 619 insertions(+)
---
base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
change-id: 20230804-optimize_checksum-db145288ac21
--
- Charlie