* [RFC] net: selftests: Adding TX checksum offload validation
@ 2025-09-16 9:12 Oleksij Rempel
2025-09-17 22:07 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Oleksij Rempel @ 2025-09-16 9:12 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
Paolo Abeni, kernel, linux-kernel, netdev
Hello everyone,
While working with the smsc95xx driver, I identified a need for better
validation of the driver and hardware TX checksum offloading capabilities. I
believe a generic test suite for this would benefit other drivers as well.
The generic selftest framework in net/core/selftests.c seems like the ideal
location. It already contains a test for the RX checksum path, so adding
validation for the TX path feels like a natural extension.
Here is the list of test cases I propose to add:
- TX csum offload, IPv4, TCP, Standard MTU Packet
- TX csum offload, IPv4, UDP, Standard MTU Packet
- TX csum offload, IPv4, ICMP, Standard Payload
- TX csum offload, IPv4, TCP, Minimal Size Packet (1-byte payload)
- TX csum offload, IPv4, UDP, Minimal Size Packet (1-byte payload)
- TX csum offload, IPv4, UDP, Zero-Checksum Payload (Verify checksum becomes
0xFFFF)
- TX csum offload, IPv4, TCP, With Single VLAN Tag
- TX csum offload, IPv4, TCP, With Double VLAN Tag (Q-in-Q)
- TX csum offload, IPv6, TCP, Standard MTU Packet
- TX csum offload, IPv6, UDP, Standard MTU Packet
The implementation for these tests would involve preparing an skb with the
corresponding L3/L4 headers, flagging it with CHECKSUM_PARTIAL, and sending it
through the PHY loopback. The test would pass if the received frame has a
valid checksum.
As a related question on driver implementation:
The documentation suggests that the older flags NETIF_F_IP_CSUM and
NETIF_F_IPV6_CSUM are being superseded by the more generic NETIF_F_HW_CSUM.
When the network stack sends a packet with skb->ip_summed = CHECKSUM_PARTIAL,
the driver is responsible for ensuring the final checksum is correct, either by
offloading the calculation to the device or by falling back to a software
function like skb_checksum_help().
Is this understanding correct, and is relying on CHECKSUM_PARTIAL as the
primary mechanism for requesting TX offload the recommended practice for modern
network drivers?
Thanks,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [RFC] net: selftests: Adding TX checksum offload validation
2025-09-16 9:12 [RFC] net: selftests: Adding TX checksum offload validation Oleksij Rempel
@ 2025-09-17 22:07 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2025-09-17 22:07 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
Paolo Abeni, kernel, linux-kernel, netdev
On Tue, 16 Sep 2025 11:12:02 +0200 Oleksij Rempel wrote:
> While working with the smsc95xx driver, I identified a need for better
> validation of the driver and hardware TX checksum offloading capabilities. I
> believe a generic test suite for this would benefit other drivers as well.
>
> The generic selftest framework in net/core/selftests.c seems like the ideal
> location. It already contains a test for the RX checksum path, so adding
> validation for the TX path feels like a natural extension.
>
> Here is the list of test cases I propose to add:
> - TX csum offload, IPv4, TCP, Standard MTU Packet
> - TX csum offload, IPv4, UDP, Standard MTU Packet
> - TX csum offload, IPv4, ICMP, Standard Payload
> - TX csum offload, IPv4, TCP, Minimal Size Packet (1-byte payload)
> - TX csum offload, IPv4, UDP, Minimal Size Packet (1-byte payload)
> - TX csum offload, IPv4, UDP, Zero-Checksum Payload (Verify checksum becomes
> 0xFFFF)
> - TX csum offload, IPv4, TCP, With Single VLAN Tag
> - TX csum offload, IPv4, TCP, With Double VLAN Tag (Q-in-Q)
> - TX csum offload, IPv6, TCP, Standard MTU Packet
> - TX csum offload, IPv6, UDP, Standard MTU Packet
The in-kernel tests are best for things which are hard to trigger from
user space. Have you seen tools/testing/selftests/drivers/net/hw/csum.py
and tools/testing/selftests/net/lib/csum.c ?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-17 22:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-16 9:12 [RFC] net: selftests: Adding TX checksum offload validation Oleksij Rempel
2025-09-17 22:07 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).