From: Tianyi Gao <tianyi@cloudflare.com>
To: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Paul Greenwalt <paul.greenwalt@intel.com>,
Alice Michael <alice.michael@intel.com>,
Eric Joyner <eric.joyner@intel.com>,
Jesse Brandeburg <jbrandeb@kernel.org>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Alexander Duyck <alexander.duyck@gmail.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
bpf@vger.kernel.org, kernel-team@cloudflare.com,
tianyi.gao@linux.dev, Tianyi Gao <tianyi@cloudflare.com>
Subject: [PATCH net v2] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
Date: Wed, 25 Nov 2026 09:52:01 +0000 [thread overview]
Message-ID: <20261125095201.98279-1-tianyi@cloudflare.com> (raw)
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
reply other threads:[~2026-11-25 9:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261125095201.98279-1-tianyi@cloudflare.com \
--to=tianyi@cloudflare.com \
--cc=alexander.duyck@gmail.com \
--cc=alice.michael@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eric.joyner@intel.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jbrandeb@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=lorenzo@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paul.greenwalt@intel.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=tianyi.gao@linux.dev \
/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