Subject: Re: [PATCH net-next] selftests: drv-net: add checksum tests

From: Jakub Kicinski <[email-masked]>
Date: Wed, 1 May 2024 18:06:57 -0700

Great! I run it on a couple of older machines. 

mlx5:

TAP version 13
1..1
# timeout set to 0
# selftests: drivers/net/hw: csum.py
# KTAP version 1
# 1..12
# ok 1 csum.ipv4_rx_tcp # SKIP Test requires IPv4 connectivity
# ok 2 csum.ipv4_rx_tcp_invalid # SKIP Test requires IPv4 connectivity
# ok 3 csum.ipv4_rx_udp # SKIP Test requires IPv4 connectivity
# ok 4 csum.ipv4_rx_udp_invalid # SKIP Test requires IPv4 connectivity
# ok 5 csum.ipv4_tx_udp_csum_offload # SKIP Test requires IPv4 connectivity
# ok 6 csum.ipv4_tx_udp_zero_checksum # SKIP Test requires IPv4 connectivity
# ok 7 csum.ipv6_rx_tcp
# ok 8 csum.ipv6_rx_tcp_invalid
# ok 9 csum.ipv6_rx_udp
# ok 10 csum.ipv6_rx_udp_invalid
# ok 11 csum.ipv6_tx_udp_csum_offload
# ok 12 csum.ipv6_tx_udp_zero_checksum
# # Totals: pass:6 fail:0 xfail:0 xpass:0 skip:6 error:0
ok 1 selftests: drivers/net/hw: csum.py

bnxt:

TAP version 13
1..1
# timeout set to 0
# selftests: drivers/net/hw: csum.py
# KTAP version 1
# 1..12
# ok 1 csum.ipv4_rx_tcp # SKIP Test requires IPv4 connectivity
# ok 2 csum.ipv4_rx_tcp_invalid # SKIP Test requires IPv4 connectivity
# ok 3 csum.ipv4_rx_udp # SKIP Test requires IPv4 connectivity
# ok 4 csum.ipv4_rx_udp_invalid # SKIP Test requires IPv4 connectivity
# ok 5 csum.ipv4_tx_udp_csum_offload # SKIP Test requires IPv4 connectivity
# ok 6 csum.ipv4_tx_udp_zero_checksum # SKIP Test requires IPv4 connectivity
# ok 7 csum.ipv6_rx_tcp
# ok 8 csum.ipv6_rx_tcp_invalid
# ok 9 csum.ipv6_rx_udp
# ok 10 csum.ipv6_rx_udp_invalid
# ok 11 csum.ipv6_tx_udp_csum_offload # SKIP Test requires tx checksum offload on eth0
# ok 12 csum.ipv6_tx_udp_zero_checksum # SKIP Test requires tx checksum offload on eth0
# # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:8 error:0
ok 1 selftests: drivers/net/hw: csum.py

On Wed,  1 May 2024 14:51:34 -0400 Willem de Bruijn wrote:
> Run tools/testing/selftest/net/csum.c as part of drv-net.
> This binary covers multiple scenarios, based on arguments given,
> for both IPv4 and IPv6:

The use of csum.c is the only real concern I have. Could you move it to
net/lib? I made net/lib into an automatically included target in commit
b86761ff6374 ("selftests: net: add scaffolding for Netlink tests in Python").

It has a makefile like any selftest directory, so you should be able to
do a simple move and minor path adjustments.

Without this if someone builds and deploys just the drivers/net{,/hw}
targets the csum binary won't be there :( We could auto-include all of
net but using the lib target felt a little cleaner.

> - Accept UDP correct checksum
> - Detect UDP invalid checksum
> - Accept TCP correct checksum
> - Detect TCP invalid checksum
> 
> - Transmit UDP: basic checksum offload
> - Transmit UDP: zero checksum conversion
> 
> The test direction is reversed between receive and transmit tests, so
> that the NIC under test is always the local machine.
> 
> In total this adds up to 12 testcases, with more to follow. For
> conciseness, I replaced individual functions with a function factory.
> It saves a lot of boilerplate, but is a little harder to follow, so
> partially here as a point for discussion.

LGTM, FWIW, but let's hear if anyone feels it's too magical.

> Warning that for now transmit errors are not detected, as for those
> the receiver runs remotely and failures with bkg are ignored.

Should I send a fix for that?