From: Vladimir Vdovin <deliran@verdict.gg>
To: Lorenzo Bianconi <lorenzo@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
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>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Cc: Jakub Sitnicki <jakub@cloudflare.com>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
intel-wired-lan@lists.osuosl.org,
linux-kselftest@vger.kernel.org,
Vladimir Vdovin <deliran@verdict.gg>
Subject: [PATCH bpf-next v4 3/6] net: ice: Add xmo_rx_checksum callback
Date: Wed, 8 Jul 2026 23:34:07 +0300 [thread overview]
Message-ID: <20260708203410.45121-4-deliran@verdict.gg> (raw)
In-Reply-To: <20260708203410.45121-1-deliran@verdict.gg>
From: Lorenzo Bianconi <lorenzo@kernel.org>
Implement xmo_rx_checksum callback in ice driver to report RX checksum
result to the eBPF program bounded to the NIC.
Introduce ice_get_rx_csum utility routine in order to make the rx checksum
code reusable from ice_rx_csum()
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Vladimir Vdovin <deliran@verdict.gg>
---
drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 123 ++++++++++++------
1 file changed, 81 insertions(+), 42 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
index e695a664e53d..3aa82ff03d9e 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
@@ -78,69 +78,48 @@ ice_rx_hash_to_skb(const struct ice_rx_ring *rx_ring,
libeth_rx_pt_set_hash(skb, hash, decoded);
}
-/**
- * ice_rx_gcs - Set generic checksum in skb
- * @skb: skb currently being received and modified
- * @rx_desc: receive descriptor
- */
-static void ice_rx_gcs(struct sk_buff *skb,
- const union ice_32b_rx_flex_desc *rx_desc)
-{
- const struct ice_32b_rx_flex_desc_nic *desc;
- u16 csum;
-
- desc = (struct ice_32b_rx_flex_desc_nic *)rx_desc;
- skb->ip_summed = CHECKSUM_COMPLETE;
- csum = (__force u16)desc->raw_csum;
- skb->csum = csum_unfold((__force __sum16)swab16(csum));
-}
-
-/**
- * ice_rx_csum - Indicate in skb if checksum is good
- * @ring: the ring we care about
- * @skb: skb currently being received and modified
- * @rx_desc: the receive descriptor
- * @ptype: the packet type decoded by hardware
- *
- * skb->protocol must be set before this function is called
- */
static void
-ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb,
- union ice_32b_rx_flex_desc *rx_desc, u16 ptype)
+ice_get_rx_csum(const union ice_32b_rx_flex_desc *rx_desc, u16 ptype,
+ struct ice_rx_ring *ring, enum xdp_checksum *ip_summed,
+ u32 *cksum, u8 *cksum_level)
{
- struct libeth_rx_pt decoded;
+ struct libeth_rx_pt decoded = libie_rx_pt_parse(ptype);
u16 rx_status0, rx_status1;
bool ipv4, ipv6;
- /* Start with CHECKSUM_NONE and by default csum_level = 0 */
- skb->ip_summed = CHECKSUM_NONE;
-
- decoded = libie_rx_pt_parse(ptype);
if (!libeth_rx_pt_has_checksum(ring->netdev, decoded))
- return;
+ goto checksum_none;
rx_status0 = le16_to_cpu(rx_desc->wb.status_error0);
rx_status1 = le16_to_cpu(rx_desc->wb.status_error1);
-
if ((ring->flags & ICE_RX_FLAGS_RING_GCS) &&
rx_desc->wb.rxdid == ICE_RXDID_FLEX_NIC &&
(decoded.inner_prot == LIBETH_RX_PT_INNER_TCP ||
decoded.inner_prot == LIBETH_RX_PT_INNER_UDP ||
decoded.inner_prot == LIBETH_RX_PT_INNER_ICMP)) {
- ice_rx_gcs(skb, rx_desc);
+ const struct ice_32b_rx_flex_desc_nic *desc;
+ __wsum wcsum;
+ u16 csum;
+
+ desc = (struct ice_32b_rx_flex_desc_nic *)rx_desc;
+ *ip_summed = XDP_CHECKSUM_COMPLETE;
+ csum = (__force u16)desc->raw_csum;
+ wcsum = csum_unfold((__force __sum16)swab16(csum));
+ *cksum = (__force u32)wcsum;
+ *cksum_level = 0;
return;
}
/* check if HW has decoded the packet and checksum */
if (!(rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L3L4P_S)))
- return;
+ goto checksum_none;
ipv4 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV4;
ipv6 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV6;
if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))) {
ring->vsi->back->hw_rx_eipe_error++;
- return;
+ goto checksum_none;
}
if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S))))
@@ -164,14 +143,51 @@ ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb,
* we need to bump the checksum level by 1 to reflect the fact that
* we are indicating we validated the inner checksum.
*/
- if (decoded.tunnel_type >= LIBETH_RX_PT_TUNNEL_IP_GRENAT)
- skb->csum_level = 1;
-
- skb->ip_summed = CHECKSUM_UNNECESSARY;
+ *cksum_level = decoded.tunnel_type >= LIBETH_RX_PT_TUNNEL_IP_GRENAT;
+ *ip_summed = XDP_CHECKSUM_UNNECESSARY;
+ *cksum = 0;
return;
checksum_fail:
ring->vsi->back->hw_csum_rx_error++;
+checksum_none:
+ *ip_summed = XDP_CHECKSUM_NONE;
+ *cksum_level = 0;
+ *cksum = 0;
+}
+
+/**
+ * ice_rx_csum - Indicate in skb if checksum is good
+ * @ring: the ring we care about
+ * @skb: skb currently being received and modified
+ * @rx_desc: the receive descriptor
+ * @ptype: the packet type decoded by hardware
+ *
+ * skb->protocol must be set before this function is called
+ */
+static void
+ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb,
+ union ice_32b_rx_flex_desc *rx_desc, u16 ptype)
+{
+ enum xdp_checksum ip_summed;
+ u8 cksum_level;
+ u32 cksum;
+
+ ice_get_rx_csum(rx_desc, ptype, ring, &ip_summed, &cksum,
+ &cksum_level);
+ switch (ip_summed) {
+ case XDP_CHECKSUM_UNNECESSARY:
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb->csum_level = cksum_level;
+ break;
+ case XDP_CHECKSUM_COMPLETE:
+ skb->ip_summed = CHECKSUM_COMPLETE;
+ skb->csum = (__force __wsum)cksum;
+ break;
+ default:
+ skb->ip_summed = CHECKSUM_NONE;
+ break;
+ }
}
/**
@@ -566,6 +582,28 @@ static int ice_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
return 0;
}
+/**
+ * ice_xdp_rx_checksum - RX checksum XDP hint handler
+ * @ctx: XDP buff pointer
+ * @ip_summed: RX checksum result destination address
+ * @cksum: RX checksum value destination address
+ * @cksum_level: RX checksum level value destination address
+ */
+static int ice_xdp_rx_checksum(const struct xdp_md *ctx,
+ enum xdp_checksum *ip_summed,
+ u32 *cksum, u8 *cksum_level)
+{
+ const struct libeth_xdp_buff *xdp_ext = (void *)ctx;
+ const union ice_32b_rx_flex_desc *rx_desc = xdp_ext->desc;
+ struct ice_rx_ring *ring;
+
+ ring = libeth_xdp_buff_to_rq(xdp_ext, typeof(*ring), xdp_rxq);
+ ice_get_rx_csum(rx_desc, ice_get_ptype(rx_desc), ring, ip_summed,
+ cksum, cksum_level);
+
+ return 0;
+}
+
/**
* ice_xdp_rx_vlan_tag - VLAN tag XDP hint handler
* @ctx: XDP buff pointer
@@ -598,4 +636,5 @@ const struct xdp_metadata_ops ice_xdp_md_ops = {
.xmo_rx_timestamp = ice_xdp_rx_hw_ts,
.xmo_rx_hash = ice_xdp_rx_hash,
.xmo_rx_vlan_tag = ice_xdp_rx_vlan_tag,
+ .xmo_rx_checksum = ice_xdp_rx_checksum,
};
--
2.47.0
next prev parent reply other threads:[~2026-07-08 20:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 20:34 [PATCH bpf-next v4 0/6] Add the capability to load HW RX checksum in eBPF programs Vladimir Vdovin
2026-07-08 20:34 ` [PATCH bpf-next v4 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Vladimir Vdovin
2026-07-10 10:09 ` Loktionov, Aleksandr
2026-07-10 19:05 ` Stanislav Fomichev
2026-07-08 20:34 ` [PATCH bpf-next v4 2/6] net: veth: Add xmo_rx_checksum callback to veth driver Vladimir Vdovin
2026-07-10 10:09 ` Loktionov, Aleksandr
2026-07-08 20:34 ` Vladimir Vdovin [this message]
2026-07-10 10:10 ` [PATCH bpf-next v4 3/6] net: ice: Add xmo_rx_checksum callback Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 4/6] selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum Vladimir Vdovin
2026-07-08 20:34 ` [PATCH bpf-next v4 5/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog Vladimir Vdovin
2026-07-10 10:11 ` Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 6/6] selftests: drv-net: add XDP RX checksum metadata tests Vladimir Vdovin
2026-07-10 10:12 ` Loktionov, Aleksandr
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=20260708203410.45121-4-deliran@verdict.gg \
--to=deliran@verdict.gg \
--cc=aleksander.lobakin@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@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