Skip to contentSkip to conversation

selftests/net: add csum offload test

PATCH Applied Willem de Bruijn 3 participants 5 messages Nov 28, 2022 – Nov 30, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/net: add csum offload test

From: Willem de Bruijn <[email protected]>

Test NIC hardware checksum offload:

- Rx + Tx
- IPv4 + IPv6
- TCP + UDP

Optional features:

- zero checksum 0xFFFF
- checksum disable 0x0000
- transport encap headers
- randomization

See file header for detailed comments.

Expected results differ depending on NIC features:

- CHECKSUM_UNNECESSARY vs CHECKSUM_COMPLETE
- NETIF_F_HW_CSUM (csum_start/csum_off) vs NETIF_F_IP(V6)_CSUM

---
 tools/testing/selftests/net/.gitignore |   1 +
 tools/testing/selftests/net/Makefile   |   1 +
 tools/testing/selftests/net/csum.c     | 986 +++++++++++++++++++++++++
 3 files changed, 988 insertions(+)
 create mode 100644 tools/testing/selftests/net/csum.c
tools/testing/selftests/net/.gitignore +1 -0
index ff8807cc9c2e..ee38ca888244 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 bind_bhash
+csum
 cmsg_sender
 fin_ack_lat
 gro
tools/testing/selftests/net/Makefile +1 -0
index 880e6ded6ed5..3007e98a6d64 100644
@@ -74,6 +74,7 @@ TEST_PROGS += test_ingress_egress_chaining.sh
 TEST_GEN_PROGS += so_incoming_cpu
 TEST_PROGS += sctp_vrf.sh
 TEST_GEN_FILES += sctp_hello
+TEST_GEN_FILES += csum
 
 TEST_FILES := settings
 
tools/testing/selftests/net/csum.c new file +986 -0

986 lines not on this page · raw message

Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
maintainer
#1 lore raw

Hi,

Quoted 15 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Test NIC hardware checksum offload:

- Rx + Tx
- IPv4 + IPv6
- TCP + UDP

Optional features:

- zero checksum 0xFFFF
- checksum disable 0x0000
- transport encap headers
- randomization

Quoted 8 lines

See file header for detailed comments.

Expected results differ depending on NIC features:

- CHECKSUM_UNNECESSARY vs CHECKSUM_COMPLETE
- NETIF_F_HW_CSUM (csum_start/csum_off) vs NETIF_F_IP(V6)_CSUM

I'm wondering if we could hook this into the self-tests list with a suitable wrapper script, e.g. searching for a NIC exposing the loopback feature, quering the NETIF_F_HW_CSUM/NETIF_F_IP(V6)_CSUM bit via ethtool and guessing CHECKSUM_UNNECESSARY vs CHECKSUM_COMPLETE via the received packet.

If the host lacks a suitable device, the test is skipped. WDYT?

Thanks!

Paolo

#2 lore raw
Quoted 28 lines · Paolo Abeni

Hi,

Quoted 15 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Test NIC hardware checksum offload:

- Rx + Tx
- IPv4 + IPv6
- TCP + UDP

Optional features:

- zero checksum 0xFFFF
- checksum disable 0x0000
- transport encap headers
- randomization

Quoted 8 lines

See file header for detailed comments.

Expected results differ depending on NIC features:

- CHECKSUM_UNNECESSARY vs CHECKSUM_COMPLETE
- NETIF_F_HW_CSUM (csum_start/csum_off) vs NETIF_F_IP(V6)_CSUM

Quoted 7 lines

I'm wondering if we could hook this into the self-tests list with a suitable wrapper script, e.g. searching for a NIC exposing the loopback feature, quering the NETIF_F_HW_CSUM/NETIF_F_IP(V6)_CSUM bit via ethtool and guessing CHECKSUM_UNNECESSARY vs CHECKSUM_COMPLETE via the received packet.

If the host lacks a suitable device, the test is skipped. WDYT?

We could. Optionally with ipvlan and two netns to really emulate a two host setup.

I'm hesitant to include this into kselftests without warning though. Have too often had to debug tests that crashed and left a machine unreachable, because in loopback mode.

Either way, something to do as a separate follow-up patch?

maintainer
#3 lore raw
Quoted 32 lines · Willem de Bruijn
Quoted 31 lines · Paolo Abeni
Quoted 15 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Test NIC hardware checksum offload:

- Rx + Tx
- IPv4 + IPv6
- TCP + UDP

Optional features:

- zero checksum 0xFFFF
- checksum disable 0x0000
- transport encap headers
- randomization

Quoted 8 lines

See file header for detailed comments.

Expected results differ depending on NIC features:

- CHECKSUM_UNNECESSARY vs CHECKSUM_COMPLETE
- NETIF_F_HW_CSUM (csum_start/csum_off) vs NETIF_F_IP(V6)_CSUM

I'm wondering if we could hook this into the self-tests list with a suitable wrapper script, e.g. searching for a NIC exposing the loopback feature, quering the NETIF_F_HW_CSUM/NETIF_F_IP(V6)_CSUM bit via ethtool and guessing CHECKSUM_UNNECESSARY vs CHECKSUM_COMPLETE via the received packet.

Quoted 8 lines
Quoted 1 line

If the host lacks a suitable device, the test is skipped. WDYT?

We could. Optionally with ipvlan and two netns to really emulate a two host setup.

I'm hesitant to include this into kselftests without warning though. Have too often had to debug tests that crashed and left a machine unreachable, because in loopback mode.

I see your point. The forwarding/loopback.sh test does nothing by default without additional command line arguments, something similar could work here, too.

I think it would still be valuable, because it will simplify automating this kind of testing - compared to guessing the needed setup from the binary alone.

Quoted 1 line

Either way, something to do as a separate follow-up patch?

Fine by me.

Thanks,

Paolo

#4 lore raw
In reply to Willem de Bruijn
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Mon, 28 Nov 2022 09:02:10 -0500 you wrote:

From: Willem de Bruijn <[email protected]>

Test NIC hardware checksum offload:

- Rx + Tx
- IPv4 + IPv6
- TCP + UDP

[...]

Here is the summary with links:
- [net-next] selftests/net: add csum offload test

    https://git.kernel.org/netdev/net-next/c/91a7de85600d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html