Netdev List
 help / color / mirror / Atom feed
From: Alexander Dahl <ada@thorsis.com>
To: Nicolai Buchwitz <nb@tipi-net.de>
Cc: "Théo Lebrun" <theo.lebrun@bootlin.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
	"Jonathan Bell" <jonathan@raspberrypi.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Richard Cochran" <richardcochran@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 0/2] net: macb: fix zero UDPv4 checksum on transmit
Date: Fri, 28 Aug 2026 08:04:08 +0200	[thread overview]
Message-ID: <20260826-untrimmed-take-024590e9f9d8@thorsis.com> (raw)
In-Reply-To: <20260824134703.766708-1-nb@tipi-net.de>

Hello Nicolai,

Am Mon, Aug 24, 2026 at 03:47:01PM +0200 schrieb Nicolai Buchwitz:
> When a UDPv4 checksum computes to zero, RFC 768 wants 0xffff on the
> wire, but the GEM sends the raw 0x0000, which receivers read as "no
> checksum". Raspberry Pi confirmed in a simulation of the Cadence IP
> that the engine skips the substitution for UDPv4. UDPv6 and TCP are
> fine, and the IP changelog suggests all GEM revisions could be affected.
> Reported and analyzed on the Raspberry Pi 5:
> https://github.com/raspberrypi/linux/issues/7550
> 
> Patch 2 does UDPv4 checksums in software and lets the existing pad
> and FCS path keep the hardware off the frame, UDPv6 and TCP keep
> the offload. That path miscounts tx_bytes by the software FCS, so
> patch 1 fixes the accounting first.
> 
> Tested on CM5. To reproduce, send bulk UDP to another host and capture
> zero checksums on the receiving side:
> 
>   iperf3 -c <host> -u -b 200M -t 30
>   tcpdump -ni <iface> 'src host <dut> and udp[6:2] == 0'
> 
> Without the fix a packet shows up every few seconds:
> 
>   12:46:20.002739 IP <dut>.36309 > <host>.5201: UDP, length 1448
>   12:46:23.773968 IP <dut>.36309 > <host>.5201: UDP, length 1448
>   12:46:40.227460 IP <dut>.36309 > <host>.5201: UDP, length 1448
> 
> With the fix the capture showed none.
> 
> Some numbers (udpgso_bench):
> - 18-byte UDP throughput dropped by ~ 8%
> - 256-byte UDP throughput dropped by ~ 10%
> - MTU-sized UDP and UDP GSO were unchanged at the 116 MiB/s link limit
> 
> Unfortunately I don't see a cheaper fix, the zero only shows up after
> computing the checksum, the MAC inserts it in flight, and AFAIU there is
> no register or descriptor bit for the substitution.
> 
> I'd appreciate testing on other silicon.

I tested without your patch on at91 sama5d2 (Cadence GEM rev
0x00020203), sam9x60 (Cadence MACB rev 0x0001010c), and sam9g20
(Cadence MACB rev 0x0001010c), and tried to reproduce the flaw (not
the fix).  Rewrote the Python reproducer suggested in that RPi github
issue in C, but iperf3 gave similar results:  tcpdump started as
suggested showed not a single wrong package!

However according to ethtool it seems at least the older MACB bases
hardware has no hardware checksumming here.  On sama5d2 (GEM, but no
Gigabit) I'm not sure if it is supposed to be done for UDP?  See:

    $ ethtool -k eth0 | grep sum
    rx-checksumming: on
    tx-checksumming: on
            tx-checksum-ipv4: off [fixed]
            tx-checksum-ip-generic: on
            tx-checksum-ipv6: off [fixed]
            tx-checksum-fcoe-crc: off [fixed]
            tx-checksum-sctp: off [fixed]
    tx-gre-csum-segmentation: off [fixed]
    tx-udp_tnl-csum-segmentation: off [fixed]
    tx-tunnel-remcsum-segmentation: off [fixed]
    esp-tx-csum-hw-offload: off [fixed]

On sam9x60 (MACB) there seems to be no hardware offloading at all:

    $ ethtool -k eth0 | grep sum
    rx-checksumming: off [fixed]
    tx-checksumming: off
            tx-checksum-ipv4: off [fixed]
            tx-checksum-ip-generic: off [fixed]
            tx-checksum-ipv6: off [fixed]
            tx-checksum-fcoe-crc: off [fixed]
            tx-checksum-sctp: off [fixed]
    tx-gre-csum-segmentation: off [fixed]
    tx-udp_tnl-csum-segmentation: off [fixed]
    tx-tunnel-remcsum-segmentation: off [fixed]
    esp-tx-csum-hw-offload: off [fixed]

How are those chips affected by your patch then?

> Nicolai Buchwitz (2):
>   net: macb: exclude software FCS from TX byte statistics
>   net: macb: fix zero UDPv4 checksum on transmit

That fix seems to be very generic and not specific to macb or gem nor
to any variant.  I'd suggest narrowing it down and testing on more
hardware.

Greets
Alex

> 
>  drivers/net/ethernet/cadence/macb.h      |  3 +++
>  drivers/net/ethernet/cadence/macb_main.c | 28 +++++++++++++++++++++-------
>  2 files changed, 24 insertions(+), 7 deletions(-)
> 
> -- 
> 2.53.0
> 

      parent reply	other threads:[~2026-08-28  6:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 13:47 [PATCH net 0/2] net: macb: fix zero UDPv4 checksum on transmit Nicolai Buchwitz
2026-08-24 13:47 ` [PATCH net 1/2] net: macb: exclude software FCS from TX byte statistics Nicolai Buchwitz
2026-08-25 15:04   ` Nicolai Buchwitz
2026-08-27  8:52     ` Paolo Abeni
2026-08-28  8:10       ` Nicolai Buchwitz
2026-08-27 18:56   ` Jakub Kicinski
2026-08-28  8:20     ` Nicolai Buchwitz
2026-08-28 13:02       ` David Laight
2026-08-28  8:37     ` David Laight
2026-08-24 13:47 ` [PATCH net 2/2] net: macb: fix zero UDPv4 checksum on transmit Nicolai Buchwitz
2026-08-28  6:04 ` Alexander Dahl [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260826-untrimmed-take-024590e9f9d8@thorsis.com \
    --to=ada@thorsis.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=conor.dooley@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jonathan@raspberrypi.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=theo.lebrun@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox