Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
@ 2026-11-25  9:52 Tianyi Gao
  2026-11-25 11:17 ` Alexander Lobakin
  2026-11-25 11:27 ` Maciej Fijalkowski
  0 siblings, 2 replies; 3+ messages in thread
From: Tianyi Gao @ 2026-11-25  9:52 UTC (permalink / raw)
  To: netdev, intel-wired-lan, Tony Nguyen, Przemek Kitszel
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Paul Greenwalt, Alice Michael, Eric Joyner, Jesse Brandeburg,
	Lorenzo Bianconi, Alexander Duyck, Maciej Fijalkowski, bpf,
	kernel-team, tianyi.gao, Tianyi Gao

On E830, ice reports CHECKSUM_COMPLETE with the generic checksum (GCS)
that the hardware computes over the received frame. If an XDP program
changes the packet and returns XDP_PASS, that checksum no longer
matches. The stack then checks the packet again in software and calls
netdev_rx_csum_fault().

On Cloudflare servers, an XDP load balancer removes the encapsulation
of the packets that it accepts locally. Our production traffic hits
netdev_rx_csum_fault() all the time.

Do not use GCS while the VSI has an XDP program, as mlx5 has done since
commit 5d0bb3bac4b9 ("net/mlx5e: XDP, Avoid checksum complete when XDP
prog is loaded"). Set ICE_RX_FLAGS_RING_GCS in ice_vsi_cfg_rxq()
instead of ice_vsi_alloc_rings(). The flag then follows the program
when it is attached or removed, and after a VSI rebuild. Log an info
message when a program is attached on a port with GCS.

E830 also sets the L3L4P and checksum error bits, so the packet gets
CHECKSUM_UNNECESSARY or CHECKSUM_NONE, as on E810. For example, a zero
UDP checksum over IPv6 is marked as bad and gets CHECKSUM_NONE. A zero
UDP checksum over IPv4 gets CHECKSUM_UNNECESSARY, so the inner checksum
is never checked, as on E810 and as on E830 before v6.15. The
discussion in [3] concluded that CHECKSUM_UNNECESSARY only is the safe
option with XDP for now, and that the decap case is a known problem.

Two pending series [1][2] give XDP access to the checksum status.
Neither of them supports CHECKSUM_COMPLETE.

Tested on an E830 with an XDP program that removes 16 bytes of UDP
payload with bpf_xdp_adjust_head() and returns XDP_PASS:

- Without this patch, the changed packets got CHECKSUM_COMPLETE, and
  the stack called netdev_rx_csum_fault() 368512 times.
- With it, they got CHECKSUM_UNNECESSARY, and there were no calls.
- Plain UDP got CHECKSUM_UNNECESSARY while the program was attached,
  also after ethtool -L rebuilt the VSI, and CHECKSUM_COMPLETE again
  after it was removed.

On an E810, which has no GCS, drivers/net/xdp.py, ping.py and
hw/csum.py give the same results with and without this patch.

Link: https://lore.kernel.org/all/20260715-bpf-xdp-meta-rxcksum-v5-0-623d5c0d0ab7@kernel.org/ [1]
Link: https://lore.kernel.org/all/cover.1794281983.git.tianyi@cloudflare.com/ [2]
Link: https://lore.kernel.org/all/20260721183256.6f49d6e1@kernel.org/ [3]
Fixes: 905d1a220e8d ("ice: Add E830 checksum offload support")
Suggested-by: Jesse Brandeburg <jbrandeb@kernel.org>
Signed-off-by: Tianyi Gao <tianyi@cloudflare.com>
---
Changes in v2:
- Set ICE_RX_FLAGS_RING_GCS in ice_vsi_cfg_rxq() instead of reading
  rx_ring->xdp_prog for each packet in ice_rx_csum() (Alexander Duyck).
- Log an info message when a program is attached on a port with GCS
  (Alexander Duyck).
- Drop the paragraph about the two reads of rx_ring->xdp_prog. It does
  not apply any more.
- Move the test results into the commit message.
- Drop the Acked-by of Maciej Fijalkowski, because the code changed.
- v1: https://lore.kernel.org/all/20261121012402.84848-1-tianyi@cloudflare.com/

The E810 tests ran on net. The E830 tests ran on v6.18.65 with this
patch applied, on 8086:12d2 with fw.mgmt 7.9.5 and DDP ICE COMMS
1.3.63.0. Without the patch, 164150 changed IPv4 packets and 154671
changed IPv6 packets got CHECKSUM_COMPLETE in 2 s each.

 drivers/net/ethernet/intel/ice/ice_base.c | 7 +++++++
 drivers/net/ethernet/intel/ice/ice_lib.c  | 3 ---
 drivers/net/ethernet/intel/ice/ice_main.c | 2 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
index 1667f686ff75..3c44e112acf9 100644
--- a/drivers/net/ethernet/intel/ice/ice_base.c
+++ b/drivers/net/ethernet/intel/ice/ice_base.c
@@ -705,6 +705,13 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
 		}
 	}
 
+	/* XDP can change the frame and make the GCS value wrong */
+	if (ice_is_feature_supported(ring->vsi->back, ICE_F_GCS) &&
+	    !ice_is_xdp_ena_vsi(ring->vsi))
+		ring->flags |= ICE_RX_FLAGS_RING_GCS;
+	else
+		ring->flags &= ~ICE_RX_FLAGS_RING_GCS;
+
 	ring->xdp.data = NULL;
 	err = ice_setup_rx_ctx(ring);
 	if (err) {
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 977cd8dd6e31..910951a17950 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1532,9 +1532,6 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi)
 		ring->count = vsi->num_rx_desc;
 		ring->cached_phctime = pf->ptp.cached_phc_time;
 
-		if (ice_is_feature_supported(pf, ICE_F_GCS))
-			ring->flags |= ICE_RX_FLAGS_RING_GCS;
-
 		WRITE_ONCE(vsi->rx_rings[i], ring);
 	}
 
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 47c6798c97e8..9644b25e7935 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2944,6 +2944,8 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
 			}
 		}
 		xdp_features_set_redirect_target(vsi->netdev, true);
+		if (ice_is_feature_supported(vsi->back, ICE_F_GCS))
+			netdev_info(vsi->netdev, "XDP program attached, Rx CHECKSUM_COMPLETE disabled\n");
 	} else if (ice_is_xdp_ena_vsi(vsi) && !prog) {
 		xdp_features_clear_redirect_target(vsi->netdev);
 		xdp_ring_err = ice_destroy_xdp_rings(vsi, ICE_XDP_CFG_FULL);

base-commit: cc7fe6e741730fef549e484379281736d32746f0
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-25 11:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  9:52 [PATCH net v2] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached Tianyi Gao
2026-11-25 11:17 ` Alexander Lobakin
2026-11-25 11:27 ` Maciej Fijalkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox