From 634d9abefbb896e0c563ede4b6a7df40d0948501 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 10 Jul 2025 12:50:00 +0100 Subject: [riscv] Add optimised TCP/IP checksumming Add a RISC-V assembly language implementation of TCP/IP checksumming, which is around 50x faster than the generic algorithm. The main loop checksums aligned xlen-bit words, using almost entirely compressible instructions and accumulating carries in a separate register to allow folding to be deferred until after all loops have completed. Experimentation on a C910 CPU suggests that this achieves around four bytes per clock cycle, which is comparable to the x86 implementation. Signed-off-by: Michael Brown --- src/arch/riscv/include/bits/tcpip.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/arch/riscv/include/bits/tcpip.h (limited to 'src/arch/riscv/include') diff --git a/src/arch/riscv/include/bits/tcpip.h b/src/arch/riscv/include/bits/tcpip.h new file mode 100644 index 000000000..0ac55b1a0 --- /dev/null +++ b/src/arch/riscv/include/bits/tcpip.h @@ -0,0 +1,15 @@ +#ifndef _BITS_TCPIP_H +#define _BITS_TCPIP_H + +/** @file + * + * Transport-network layer interface + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +extern uint16_t tcpip_continue_chksum ( uint16_t partial, const void *data, + size_t len ); + +#endif /* _BITS_TCPIP_H */ -- cgit v1.2.3-55-g7522