From 17765f8de0782de09ebdf79940f934b8ccb83c41 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Mon, 26 Jul 2021 07:18:50 +0200 Subject: checksum: Introduce AVX2 implementation, unify helpers Provide an AVX2-based function using compiler intrinsics for TCP/IP-style checksums. The load/unpack/add idea and implementation is largely based on code from BESS (the Berkeley Extensible Software Switch) licensed as 3-Clause BSD, with a number of modifications to further decrease pipeline stalls and to minimise cache pollution. This speeds up considerably data paths from sockets to tap interfaces, decreasing overhead for checksum computation, with 16-64KiB packet buffers, from approximately 11% to 7%. The rest is just syscalls at this point. While at it, provide convenience targets in the Makefile for avx2, avx2_debug, and debug targets -- these simply add target-specific CFLAGS to the build. Signed-off-by: Stefano Brivio --- ndp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ndp.c') diff --git a/ndp.c b/ndp.c index acc0473..b676825 100644 --- a/ndp.c +++ b/ndp.c @@ -27,6 +27,7 @@ #include #include +#include "checksum.h" #include "util.h" #include "passt.h" #include "tap.h" @@ -172,8 +173,8 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len) ip6hr->payload_len = htons(sizeof(*ihr) + len); ip6hr->hop_limit = IPPROTO_ICMPV6; ihr->icmp6_cksum = 0; - ihr->icmp6_cksum = csum_ip4(ip6hr, sizeof(*ip6hr) + - sizeof(*ihr) + len); + ihr->icmp6_cksum = csum_unaligned(ip6hr, sizeof(*ip6hr) + + sizeof(*ihr) + len, 0); ip6hr->version = 6; ip6hr->nexthdr = IPPROTO_ICMPV6; -- cgit v1.2.3