The GEM checksum engine writes its raw result into the UDP checksum field, so a UDPv4 checksum that computes to zero goes out as 0x0000. RFC 768 requires: If the computed checksum is zero, it is transmitted as all ones (the equivalent in one's complement arithmetic). An all zero transmitted checksum value means that the transmitter generated no checksum (for debugging or for higher level protocols that don't care). Raspberry Pi confirmed in a simulation of the Cadence IP [1] that the engine skips the final substitution exactly for UDP over IPv4. UDPv6 and TCP come out correct. The IP changelog shows no related change, so probably all GEM revisions have the same bug. Clear the checksum offload features for UDPv4 frames in macb_features_check(), the core then completes the checksum in software. With ip_summed cleared, macb_pad_and_fcs() appends the FCS and TX_NOCRC keeps the hardware off the frame. TCP and UDPv6 keep the offload. One-step PTP sync packets stay on the hardware path, the MAC rewrites their timestamp during transmit and would invalidate a software checksum. Link: https://github.com/raspberrypi/linux/issues/7550#issuecomment-5343018065 [1] Fixes: 85ff3d87bf2e ("net/macb: add TX checksum offload feature") Cc: Jonathan Bell Signed-off-by: Nicolai Buchwitz --- drivers/net/ethernet/cadence/macb_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 623d072a271d..f3548475f945 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -2373,6 +2374,16 @@ static netdev_features_t macb_features_check(struct sk_buff *skb, unsigned int nr_frags, f; unsigned int hdrlen; + /* The GEM skips the RFC 768 substitution of 0xffff for a zero + * UDPv4 checksum, do those in software. One-step PTP sync frames + * stay on hardware, the MAC rewrites their timestamp in flight. + */ + if (skb->ip_summed == CHECKSUM_PARTIAL && + vlan_get_protocol(skb) == htons(ETH_P_IP) && + skb->csum_offset == offsetof(struct udphdr, check) && + !ptp_one_step_sync(skb)) + features &= ~NETIF_F_CSUM_MASK; + /* Validate LSO compatibility */ /* there is only one buffer or protocol is not UDP */ -- 2.53.0