* [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs
@ 2025-09-20 12:20 Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Lorenzo Bianconi
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-20 12:20 UTC (permalink / raw)
To: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan
Cc: netdev, bpf, intel-wired-lan, linux-kselftest, Lorenzo Bianconi
Introduce bpf_xdp_metadata_rx_checksum() kfunc in order to load the HW
RX cheksum results in the eBPF program binded to the NIC.
Implement xmo_rx_checksum callback for veth and ice drivers.
---
Lorenzo Bianconi (6):
netlink: specs: Add XDP RX checksum capability to XDP metadata specs
net: xdp: Add xmo_rx_checksum callback
veth: Add xmo_rx_checksum callback to veth driver
net: ice: Add xmo_rx_checksum callback
selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum
selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog
Documentation/netlink/specs/netdev.yaml | 5 ++
drivers/net/ethernet/intel/ice/ice_base.c | 1 +
drivers/net/ethernet/intel/ice/ice_txrx.h | 1 +
drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 82 ++++++++++++++++++++++
drivers/net/veth.c | 19 +++++
include/net/xdp.h | 6 ++
net/core/xdp.c | 29 ++++++++
.../selftests/bpf/prog_tests/xdp_metadata.c | 7 ++
.../testing/selftests/bpf/progs/xdp_hw_metadata.c | 7 ++
tools/testing/selftests/bpf/progs/xdp_metadata.c | 1 +
tools/testing/selftests/bpf/xdp_hw_metadata.c | 27 +++++++
tools/testing/selftests/bpf/xdp_metadata.h | 13 ++++
12 files changed, 198 insertions(+)
---
base-commit: 315f423be0d1ebe720d8fd4fa6bed68586b13d34
change-id: 20250915-xdp-meta-rxcksum-963cb3a793e7
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs
2025-09-20 12:20 [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs Lorenzo Bianconi
@ 2025-09-20 12:20 ` Lorenzo Bianconi
2025-09-22 15:39 ` Stanislav Fomichev
2025-09-20 12:20 ` [PATCH RFC bpf-next 2/6] net: xdp: Add xmo_rx_checksum callback Lorenzo Bianconi
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-20 12:20 UTC (permalink / raw)
To: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan
Cc: netdev, bpf, intel-wired-lan, linux-kselftest, Lorenzo Bianconi
Introduce XDP RX checksum capability to XDP metadata specs. XDP RX
checksum will be use by devices capable of exposing receive checksum
result via bpf_xdp_metadata_rx_checksum().
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Documentation/netlink/specs/netdev.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index e00d3fa1c152d7165e9485d6d383a2cc9cef7cfd..00699bf4a7fdb67c6b9ee3548098b0c933fd39a4 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -61,6 +61,11 @@ definitions:
doc: |
Device is capable of exposing receive packet VLAN tag via
bpf_xdp_metadata_rx_vlan_tag().
+ -
+ name: checksum
+ doc: |
+ Device is capable of exposing receive checksum result via
+ bpf_xdp_metadata_rx_checksum().
-
type: flags
name: xsk-flags
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH RFC bpf-next 2/6] net: xdp: Add xmo_rx_checksum callback
2025-09-20 12:20 [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Lorenzo Bianconi
@ 2025-09-20 12:20 ` Lorenzo Bianconi
2025-09-22 15:43 ` Stanislav Fomichev
2025-09-20 12:20 ` [PATCH RFC bpf-next 3/6] veth: Add xmo_rx_checksum callback to veth driver Lorenzo Bianconi
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-20 12:20 UTC (permalink / raw)
To: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan
Cc: netdev, bpf, intel-wired-lan, linux-kselftest, Lorenzo Bianconi
Introduce xmo_rx_checksum netdev callback in order allow the eBPF
program bounded to the device to retrieve the RX checksum result computed
by the hw NIC.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
include/net/xdp.h | 6 ++++++
net/core/xdp.c | 29 +++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 6fd294fa6841d59c3d7dc4475e09e731996566b0..481b39976ac8c8d4db2de39055c72ba8d0d511c3 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -581,6 +581,10 @@ void xdp_attachment_setup(struct xdp_attachment_info *info,
NETDEV_XDP_RX_METADATA_VLAN_TAG, \
bpf_xdp_metadata_rx_vlan_tag, \
xmo_rx_vlan_tag) \
+ XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_CHECKSUM, \
+ NETDEV_XDP_RX_METADATA_CHECKSUM, \
+ bpf_xdp_metadata_rx_checksum, \
+ xmo_rx_checksum)
enum xdp_rx_metadata {
#define XDP_METADATA_KFUNC(name, _, __, ___) name,
@@ -644,6 +648,8 @@ struct xdp_metadata_ops {
enum xdp_rss_hash_type *rss_type);
int (*xmo_rx_vlan_tag)(const struct xdp_md *ctx, __be16 *vlan_proto,
u16 *vlan_tci);
+ int (*xmo_rx_checksum)(const struct xdp_md *ctx, u8 *ip_summed,
+ u32 *cksum_meta);
};
#ifdef CONFIG_NET
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 9100e160113a9a1e2cb88e7602e85c5f36a9f3b9..3edab2d5e5c7c2013b1ef98c949a83655eb94349 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -961,6 +961,35 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
return -EOPNOTSUPP;
}
+/**
+ * bpf_xdp_metadata_rx_checksum - Read XDP frame RX checksum.
+ * @ctx: XDP context pointer.
+ * @ip_summed: Return value pointer indicating checksum result.
+ * @cksum_meta: Return value pointer indicating checksum result metadata.
+ *
+ * In case of success, ``ip_summed`` is set to the RX checksum result. Possible
+ * values are:
+ * ``CHECKSUM_NONE``
+ * ``CHECKSUM_UNNECESSARY``
+ * ``CHECKSUM_COMPLETE``
+ * ``CHECKSUM_PARTIAL``
+ *
+ * In case of success, ``cksum_meta`` contains the hw computed checksum value
+ * for ``CHECKSUM_COMPLETE`` or the ``csum_level`` for
+ * ``CHECKSUM_UNNECESSARY``. It is set to 0 for ``CHECKSUM_NONE`` and
+ * ``CHECKSUM_PARTIAL``.
+ *
+ * Return:
+ * * Returns 0 on success or ``-errno`` on error.
+ * * ``-EOPNOTSUPP`` : means device driver does not implement kfunc
+ * * ``-ENODATA`` : means no RX-timestamp available for this frame
+ */
+__bpf_kfunc int bpf_xdp_metadata_rx_checksum(const struct xdp_md *ctx,
+ u8 *ip_summed, u32 *cksum_meta)
+{
+ return -EOPNOTSUPP;
+}
+
__bpf_kfunc_end_defs();
BTF_KFUNCS_START(xdp_metadata_kfunc_ids)
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH RFC bpf-next 3/6] veth: Add xmo_rx_checksum callback to veth driver
2025-09-20 12:20 [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 2/6] net: xdp: Add xmo_rx_checksum callback Lorenzo Bianconi
@ 2025-09-20 12:20 ` Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback Lorenzo Bianconi
` (2 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-20 12:20 UTC (permalink / raw)
To: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan
Cc: netdev, bpf, intel-wired-lan, linux-kselftest, Lorenzo Bianconi
Implement xmo_rx_checksum callback in veth driver to report RX checksum
result to the eBPF program bounded to the NIC.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/veth.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index a3046142cb8e2658a30041129f8d298e5e0a5822..2a762cb132fd9fd90376965c65c4fedcc28a26c8 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1692,6 +1692,24 @@ static int veth_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
return err;
}
+static int veth_xdp_rx_checksum(const struct xdp_md *ctx, u8 *ip_summed,
+ u32 *cksum_meta)
+{
+ const struct veth_xdp_buff *_ctx = (void *)ctx;
+ const struct sk_buff *skb = _ctx->skb;
+
+ if (!skb)
+ return -ENODATA;
+
+ /* For locally generated packets ip_summed is set to
+ * CHECKSUM_PARTIAL.
+ */
+ *ip_summed = skb->ip_summed;
+ *cksum_meta = 0;
+
+ return 0;
+}
+
static const struct net_device_ops veth_netdev_ops = {
.ndo_init = veth_dev_init,
.ndo_open = veth_open,
@@ -1717,6 +1735,7 @@ static const struct xdp_metadata_ops veth_xdp_metadata_ops = {
.xmo_rx_timestamp = veth_xdp_rx_timestamp,
.xmo_rx_hash = veth_xdp_rx_hash,
.xmo_rx_vlan_tag = veth_xdp_rx_vlan_tag,
+ .xmo_rx_checksum = veth_xdp_rx_checksum,
};
#define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback
2025-09-20 12:20 [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs Lorenzo Bianconi
` (2 preceding siblings ...)
2025-09-20 12:20 ` [PATCH RFC bpf-next 3/6] veth: Add xmo_rx_checksum callback to veth driver Lorenzo Bianconi
@ 2025-09-20 12:20 ` Lorenzo Bianconi
2025-09-22 10:16 ` Maciej Fijalkowski
2025-09-20 12:20 ` [PATCH RFC bpf-next 5/6] selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 6/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog Lorenzo Bianconi
5 siblings, 1 reply; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-20 12:20 UTC (permalink / raw)
To: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan
Cc: netdev, bpf, intel-wired-lan, linux-kselftest, Lorenzo Bianconi
Implement xmo_rx_checksum callback in ice driver to report RX checksum
result to the eBPF program bounded to the NIC.
Tested-by: Jesper Dangaard Brouer <hawk@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/ethernet/intel/ice/ice_base.c | 1 +
drivers/net/ethernet/intel/ice/ice_txrx.h | 1 +
drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 82 +++++++++++++++++++++++++++
3 files changed, 84 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
index c5da8e9cc0a0e5551b340e70628813999059bcfe..e8ec419bdc98cb1f01e3c088698b0c4c0f97748f 100644
--- a/drivers/net/ethernet/intel/ice/ice_base.c
+++ b/drivers/net/ethernet/intel/ice/ice_base.c
@@ -591,6 +591,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
}
}
+ ring->pkt_ctx.rxq_flags = ring->flags;
xdp_init_buff(&ring->xdp, ice_get_frame_sz(ring), &ring->xdp_rxq);
ring->xdp.data = NULL;
ring->xdp_ext.pkt_ctx = &ring->pkt_ctx;
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h b/drivers/net/ethernet/intel/ice/ice_txrx.h
index 2fd8e78178a271c15fc054ef553bd509b1c8f8f3..96a2bb79e5e95fa0b9c6287eb9769bdecf47dec1 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.h
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.h
@@ -260,6 +260,7 @@ enum ice_rx_dtype {
struct ice_pkt_ctx {
u64 cached_phctime;
__be16 vlan_proto;
+ u8 rxq_flags;
};
struct ice_xdp_buff {
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
index 45cfaabc41cbeb9b119a0e95547e012e0df1e188..5327b0389ec1a3708a469fa9986a1e565b20ecf7 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
@@ -555,6 +555,87 @@ 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_meta: XDP RX checksum metadata destination address
+ *
+ * Copy RX checksum result (if available) and its metadata to the
+ * destination address.
+ */
+static int ice_xdp_rx_checksum(const struct xdp_md *ctx, u8 *ip_summed,
+ u32 *cksum_meta)
+{
+ const struct ice_xdp_buff *xdp_ext = (void *)ctx;
+ const union ice_32b_rx_flex_desc *rx_desc = xdp_ext->eop_desc;
+ u16 rx_status0, rx_status1, ptype = ice_get_ptype(rx_desc);
+ struct libeth_rx_pt decoded = libie_rx_pt_parse(ptype);
+ bool ipv4, ipv6;
+
+ if (!libeth_rx_pt_has_checksum(xdp_ext->xdp_buff.rxq->dev, decoded))
+ goto checksum_none;
+
+ rx_status0 = le16_to_cpu(rx_desc->wb.status_error0);
+ rx_status1 = le16_to_cpu(rx_desc->wb.status_error1);
+ if ((xdp_ext->pkt_ctx->rxq_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)) {
+ const struct ice_32b_rx_flex_desc_nic *desc;
+ u16 csum;
+
+ desc = (struct ice_32b_rx_flex_desc_nic *)rx_desc;
+ *ip_summed = CHECKSUM_COMPLETE;
+ csum = (__force u16)desc->raw_csum;
+ *cksum_meta = csum_unfold((__force __sum16)swab16(csum));
+ return 0;
+ }
+
+ /* check if HW has decoded the packet and checksum */
+ if (!(rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L3L4P_S)))
+ goto checksum_none;
+
+ ipv4 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV4;
+ if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S))))
+ goto checksum_none;
+
+ if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S))))
+ goto checksum_none;
+
+ ipv6 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV6;
+ if (ipv6 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_IPV6EXADD_S))))
+ goto checksum_none;
+
+ /* check for L4 errors and handle packets that were not able to be
+ * checksummed due to arrival speed
+ */
+ if (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S))
+ goto checksum_none;
+
+ /* check for outer UDP checksum error in tunneled packets */
+ if ((rx_status1 & BIT(ICE_RX_FLEX_DESC_STATUS1_NAT_S)) &&
+ (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
+ goto checksum_none;
+
+ /* If there is an outer header present that might contain a checksum
+ * 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)
+ *cksum_meta = 1;
+
+ *ip_summed = CHECKSUM_UNNECESSARY;
+ return 0;
+
+checksum_none:
+ *ip_summed = CHECKSUM_NONE;
+ *cksum_meta = 0;
+
+ return 0;
+}
+
/**
* ice_xdp_rx_vlan_tag - VLAN tag XDP hint handler
* @ctx: XDP buff pointer
@@ -584,4 +665,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.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH RFC bpf-next 5/6] selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum
2025-09-20 12:20 [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs Lorenzo Bianconi
` (3 preceding siblings ...)
2025-09-20 12:20 ` [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback Lorenzo Bianconi
@ 2025-09-20 12:20 ` Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 6/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog Lorenzo Bianconi
5 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-20 12:20 UTC (permalink / raw)
To: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan
Cc: netdev, bpf, intel-wired-lan, linux-kselftest, Lorenzo Bianconi
Introduce support to xdp_metadata selftest for bpf_xdp_metadata_rx_checksum
kfunc.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
tools/testing/selftests/bpf/prog_tests/xdp_metadata.c | 7 +++++++
tools/testing/selftests/bpf/progs/xdp_metadata.c | 1 +
tools/testing/selftests/bpf/xdp_metadata.h | 9 +++++++++
3 files changed, 17 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
index 19f92affc2daa23fdd869554e7a0475b86350a4f..650f87c2bac03841606ceef25eec718b5dcf766f 100644
--- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
+++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
@@ -258,6 +258,7 @@ static void refill_rx(struct xsk *xsk, __u64 addr)
static int verify_xsk_metadata(struct xsk *xsk, bool sent_from_af_xdp)
{
+ __u8 ip_summed = sent_from_af_xdp ? CHECKSUM_NONE : CHECKSUM_PARTIAL;
const struct xdp_desc *rx_desc;
struct pollfd fds = {};
struct xdp_meta *meta;
@@ -310,6 +311,12 @@ static int verify_xsk_metadata(struct xsk *xsk, bool sent_from_af_xdp)
if (!ASSERT_NEQ(meta->rx_hash, 0, "rx_hash"))
return -1;
+ if (!ASSERT_EQ(meta->ip_summed, ip_summed, "rx_ip_summed"))
+ return -1;
+
+ if (!ASSERT_EQ(meta->cksum_meta, 0, "rx_cksum_meta"))
+ return -1;
+
if (!sent_from_af_xdp) {
if (!ASSERT_NEQ(meta->rx_hash_type & XDP_RSS_TYPE_L4, 0, "rx_hash_type"))
return -1;
diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata.c b/tools/testing/selftests/bpf/progs/xdp_metadata.c
index 09bb8a038d528cf26c5b314cc927915ac2796bf0..ef6a5584a1876a3c47440f21dca927ec783469dc 100644
--- a/tools/testing/selftests/bpf/progs/xdp_metadata.c
+++ b/tools/testing/selftests/bpf/progs/xdp_metadata.c
@@ -98,6 +98,7 @@ int rx(struct xdp_md *ctx)
bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash, &meta->rx_hash_type);
bpf_xdp_metadata_rx_vlan_tag(ctx, &meta->rx_vlan_proto,
&meta->rx_vlan_tci);
+ bpf_xdp_metadata_rx_checksum(ctx, &meta->ip_summed, &meta->cksum_meta);
return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS);
}
diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h
index 87318ad1117a1d677af121f11778178532e2a562..f0ef17b328866206b1e63f7d751abeaa78e90932 100644
--- a/tools/testing/selftests/bpf/xdp_metadata.h
+++ b/tools/testing/selftests/bpf/xdp_metadata.h
@@ -30,6 +30,11 @@ enum xdp_meta_field {
XDP_META_FIELD_VLAN_TAG = BIT(2),
};
+#define CHECKSUM_NONE 0
+#define CHECKSUM_UNNECESSARY 1
+#define CHECKSUM_COMPLETE 2
+#define CHECKSUM_PARTIAL 3
+
struct xdp_meta {
union {
__u64 rx_timestamp;
@@ -48,5 +53,9 @@ struct xdp_meta {
};
__s32 rx_vlan_tag_err;
};
+ struct {
+ __u8 ip_summed;
+ __u32 cksum_meta;
+ };
enum xdp_meta_field hint_valid;
};
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH RFC bpf-next 6/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog
2025-09-20 12:20 [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs Lorenzo Bianconi
` (4 preceding siblings ...)
2025-09-20 12:20 ` [PATCH RFC bpf-next 5/6] selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum Lorenzo Bianconi
@ 2025-09-20 12:20 ` Lorenzo Bianconi
5 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-20 12:20 UTC (permalink / raw)
To: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan
Cc: netdev, bpf, intel-wired-lan, linux-kselftest, Lorenzo Bianconi
Introduce the capability to dump HW rx checksum in xdp_hw_metadat
program via bpf_xdp_metadata_rx_checksum() kfunc.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
.../testing/selftests/bpf/progs/xdp_hw_metadata.c | 7 ++++++
tools/testing/selftests/bpf/xdp_hw_metadata.c | 27 ++++++++++++++++++++++
tools/testing/selftests/bpf/xdp_metadata.h | 10 +++++---
3 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
index 330ece2eabdb454da2bb2cbd297d2b2dd6efddc0..dc62d572e3ac6e2ef173b330da515757ea543415 100644
--- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
+++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
@@ -110,6 +110,13 @@ int rx(struct xdp_md *ctx)
else
meta->hint_valid |= XDP_META_FIELD_VLAN_TAG;
+ err = bpf_xdp_metadata_rx_checksum(ctx, &meta->ip_summed,
+ &meta->cksum_meta);
+ if (err)
+ meta->rx_cksum_err = err;
+ else
+ meta->hint_valid |= XDP_META_FIELD_CHECKSUM;
+
__sync_add_and_fetch(&pkts_redir, 1);
return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS);
}
diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c
index 3d8de0d4c96a7afdf5f60b2fdff73c22b876ce54..5e38aa1b565735c2e55fcf2f7b9e672db1348233 100644
--- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
+++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c
@@ -219,6 +219,28 @@ static void print_vlan_tci(__u16 tag)
printf("PCP=%u, DEI=%d, VID=0x%X\n", pcp, dei, vlan_id);
}
+static void print_rx_cksum(__u8 ip_summed, __u32 cksum_meta)
+{
+ const char *cksum = "CHECKSUM_NONE";
+
+ switch (ip_summed) {
+ case CHECKSUM_UNNECESSARY:
+ cksum = "CHECKSUM_UNNECESSARY";
+ break;
+ case CHECKSUM_COMPLETE:
+ cksum = "CHECKSUM_COMPLETE";
+ break;
+ case CHECKSUM_PARTIAL:
+ cksum = "CHECKSUM_PARTIAL";
+ break;
+ case CHECKSUM_NONE:
+ default:
+ break;
+ }
+
+ printf("rx-cksum: %s, csum_meta=0x%x\n", cksum, cksum_meta);
+}
+
static void verify_xdp_metadata(void *data, clockid_t clock_id)
{
struct xdp_meta *meta;
@@ -254,6 +276,11 @@ static void verify_xdp_metadata(void *data, clockid_t clock_id)
printf("No rx_vlan_tci or rx_vlan_proto, err=%d\n",
meta->rx_vlan_tag_err);
}
+
+ if (meta->hint_valid & XDP_META_FIELD_CHECKSUM)
+ print_rx_cksum(meta->ip_summed, meta->cksum_meta);
+ else
+ printf("No rx_chsum, err=%d\n", meta->rx_cksum_err);
}
static void verify_skb_metadata(int fd)
diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h
index f0ef17b328866206b1e63f7d751abeaa78e90932..0fd5e7172fe891275b3b1eb69c51a93a60ae353e 100644
--- a/tools/testing/selftests/bpf/xdp_metadata.h
+++ b/tools/testing/selftests/bpf/xdp_metadata.h
@@ -28,6 +28,7 @@ enum xdp_meta_field {
XDP_META_FIELD_TS = BIT(0),
XDP_META_FIELD_RSS = BIT(1),
XDP_META_FIELD_VLAN_TAG = BIT(2),
+ XDP_META_FIELD_CHECKSUM = BIT(3),
};
#define CHECKSUM_NONE 0
@@ -53,9 +54,12 @@ struct xdp_meta {
};
__s32 rx_vlan_tag_err;
};
- struct {
- __u8 ip_summed;
- __u32 cksum_meta;
+ union {
+ struct {
+ __u8 ip_summed;
+ __u32 cksum_meta;
+ };
+ __s32 rx_cksum_err;
};
enum xdp_meta_field hint_valid;
};
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback
2025-09-20 12:20 ` [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback Lorenzo Bianconi
@ 2025-09-22 10:16 ` Maciej Fijalkowski
2025-09-22 10:32 ` Lorenzo Bianconi
0 siblings, 1 reply; 13+ messages in thread
From: Maciej Fijalkowski @ 2025-09-22 10:16 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan, netdev,
bpf, intel-wired-lan, linux-kselftest
On Sat, Sep 20, 2025 at 02:20:30PM +0200, Lorenzo Bianconi wrote:
> Implement xmo_rx_checksum callback in ice driver to report RX checksum
> result to the eBPF program bounded to the NIC.
>
> Tested-by: Jesper Dangaard Brouer <hawk@kernel.org>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/ethernet/intel/ice/ice_base.c | 1 +
> drivers/net/ethernet/intel/ice/ice_txrx.h | 1 +
> drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 82 +++++++++++++++++++++++++++
> 3 files changed, 84 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
> index c5da8e9cc0a0e5551b340e70628813999059bcfe..e8ec419bdc98cb1f01e3c088698b0c4c0f97748f 100644
> --- a/drivers/net/ethernet/intel/ice/ice_base.c
> +++ b/drivers/net/ethernet/intel/ice/ice_base.c
> @@ -591,6 +591,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
> }
> }
>
> + ring->pkt_ctx.rxq_flags = ring->flags;
> xdp_init_buff(&ring->xdp, ice_get_frame_sz(ring), &ring->xdp_rxq);
> ring->xdp.data = NULL;
> ring->xdp_ext.pkt_ctx = &ring->pkt_ctx;
> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h b/drivers/net/ethernet/intel/ice/ice_txrx.h
> index 2fd8e78178a271c15fc054ef553bd509b1c8f8f3..96a2bb79e5e95fa0b9c6287eb9769bdecf47dec1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx.h
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx.h
> @@ -260,6 +260,7 @@ enum ice_rx_dtype {
> struct ice_pkt_ctx {
> u64 cached_phctime;
> __be16 vlan_proto;
> + u8 rxq_flags;
> };
>
> struct ice_xdp_buff {
> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> index 45cfaabc41cbeb9b119a0e95547e012e0df1e188..5327b0389ec1a3708a469fa9986a1e565b20ecf7 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> @@ -555,6 +555,87 @@ 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_meta: XDP RX checksum metadata destination address
> + *
> + * Copy RX checksum result (if available) and its metadata to the
> + * destination address.
> + */
> +static int ice_xdp_rx_checksum(const struct xdp_md *ctx, u8 *ip_summed,
> + u32 *cksum_meta)
Hi Lorenzo,
any chance we could have some common code used both here and in
ice_rx_csum() ?
> +{
> + const struct ice_xdp_buff *xdp_ext = (void *)ctx;
> + const union ice_32b_rx_flex_desc *rx_desc = xdp_ext->eop_desc;
> + u16 rx_status0, rx_status1, ptype = ice_get_ptype(rx_desc);
> + struct libeth_rx_pt decoded = libie_rx_pt_parse(ptype);
> + bool ipv4, ipv6;
> +
> + if (!libeth_rx_pt_has_checksum(xdp_ext->xdp_buff.rxq->dev, decoded))
> + goto checksum_none;
> +
> + rx_status0 = le16_to_cpu(rx_desc->wb.status_error0);
> + rx_status1 = le16_to_cpu(rx_desc->wb.status_error1);
> + if ((xdp_ext->pkt_ctx->rxq_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)) {
> + const struct ice_32b_rx_flex_desc_nic *desc;
> + u16 csum;
> +
> + desc = (struct ice_32b_rx_flex_desc_nic *)rx_desc;
> + *ip_summed = CHECKSUM_COMPLETE;
> + csum = (__force u16)desc->raw_csum;
> + *cksum_meta = csum_unfold((__force __sum16)swab16(csum));
> + return 0;
> + }
> +
> + /* check if HW has decoded the packet and checksum */
> + if (!(rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L3L4P_S)))
> + goto checksum_none;
> +
> + ipv4 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV4;
> + if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S))))
> + goto checksum_none;
> +
> + if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S))))
> + goto checksum_none;
> +
> + ipv6 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV6;
> + if (ipv6 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_IPV6EXADD_S))))
> + goto checksum_none;
> +
> + /* check for L4 errors and handle packets that were not able to be
> + * checksummed due to arrival speed
> + */
> + if (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S))
> + goto checksum_none;
> +
> + /* check for outer UDP checksum error in tunneled packets */
> + if ((rx_status1 & BIT(ICE_RX_FLEX_DESC_STATUS1_NAT_S)) &&
> + (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
> + goto checksum_none;
> +
> + /* If there is an outer header present that might contain a checksum
> + * 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)
> + *cksum_meta = 1;
> +
> + *ip_summed = CHECKSUM_UNNECESSARY;
> + return 0;
> +
> +checksum_none:
> + *ip_summed = CHECKSUM_NONE;
> + *cksum_meta = 0;
> +
> + return 0;
> +}
> +
> /**
> * ice_xdp_rx_vlan_tag - VLAN tag XDP hint handler
> * @ctx: XDP buff pointer
> @@ -584,4 +665,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.51.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback
2025-09-22 10:16 ` Maciej Fijalkowski
@ 2025-09-22 10:32 ` Lorenzo Bianconi
0 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-22 10:32 UTC (permalink / raw)
To: Maciej Fijalkowski
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan, netdev,
bpf, intel-wired-lan, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 3367 bytes --]
[...]
>
> Hi Lorenzo,
>
> any chance we could have some common code used both here and in
> ice_rx_csum() ?
Hi Maciej,
ack, I will look into it.
Regards,
Lorenzo
>
> > +{
> > + const struct ice_xdp_buff *xdp_ext = (void *)ctx;
> > + const union ice_32b_rx_flex_desc *rx_desc = xdp_ext->eop_desc;
> > + u16 rx_status0, rx_status1, ptype = ice_get_ptype(rx_desc);
> > + struct libeth_rx_pt decoded = libie_rx_pt_parse(ptype);
> > + bool ipv4, ipv6;
> > +
> > + if (!libeth_rx_pt_has_checksum(xdp_ext->xdp_buff.rxq->dev, decoded))
> > + goto checksum_none;
> > +
> > + rx_status0 = le16_to_cpu(rx_desc->wb.status_error0);
> > + rx_status1 = le16_to_cpu(rx_desc->wb.status_error1);
> > + if ((xdp_ext->pkt_ctx->rxq_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)) {
> > + const struct ice_32b_rx_flex_desc_nic *desc;
> > + u16 csum;
> > +
> > + desc = (struct ice_32b_rx_flex_desc_nic *)rx_desc;
> > + *ip_summed = CHECKSUM_COMPLETE;
> > + csum = (__force u16)desc->raw_csum;
> > + *cksum_meta = csum_unfold((__force __sum16)swab16(csum));
> > + return 0;
> > + }
> > +
> > + /* check if HW has decoded the packet and checksum */
> > + if (!(rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L3L4P_S)))
> > + goto checksum_none;
> > +
> > + ipv4 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV4;
> > + if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S))))
> > + goto checksum_none;
> > +
> > + if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S))))
> > + goto checksum_none;
> > +
> > + ipv6 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV6;
> > + if (ipv6 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_IPV6EXADD_S))))
> > + goto checksum_none;
> > +
> > + /* check for L4 errors and handle packets that were not able to be
> > + * checksummed due to arrival speed
> > + */
> > + if (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S))
> > + goto checksum_none;
> > +
> > + /* check for outer UDP checksum error in tunneled packets */
> > + if ((rx_status1 & BIT(ICE_RX_FLEX_DESC_STATUS1_NAT_S)) &&
> > + (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
> > + goto checksum_none;
> > +
> > + /* If there is an outer header present that might contain a checksum
> > + * 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)
> > + *cksum_meta = 1;
> > +
> > + *ip_summed = CHECKSUM_UNNECESSARY;
> > + return 0;
> > +
> > +checksum_none:
> > + *ip_summed = CHECKSUM_NONE;
> > + *cksum_meta = 0;
> > +
> > + return 0;
> > +}
> > +
> > /**
> > * ice_xdp_rx_vlan_tag - VLAN tag XDP hint handler
> > * @ctx: XDP buff pointer
> > @@ -584,4 +665,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.51.0
> >
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs
2025-09-20 12:20 ` [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Lorenzo Bianconi
@ 2025-09-22 15:39 ` Stanislav Fomichev
2025-09-22 15:55 ` Lorenzo Bianconi
0 siblings, 1 reply; 13+ messages in thread
From: Stanislav Fomichev @ 2025-09-22 15:39 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan, netdev,
bpf, intel-wired-lan, linux-kselftest
On 09/20, Lorenzo Bianconi wrote:
> Introduce XDP RX checksum capability to XDP metadata specs. XDP RX
> checksum will be use by devices capable of exposing receive checksum
> result via bpf_xdp_metadata_rx_checksum().
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Documentation/netlink/specs/netdev.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
> index e00d3fa1c152d7165e9485d6d383a2cc9cef7cfd..00699bf4a7fdb67c6b9ee3548098b0c933fd39a4 100644
> --- a/Documentation/netlink/specs/netdev.yaml
> +++ b/Documentation/netlink/specs/netdev.yaml
> @@ -61,6 +61,11 @@ definitions:
> doc: |
> Device is capable of exposing receive packet VLAN tag via
> bpf_xdp_metadata_rx_vlan_tag().
> + -
> + name: checksum
> + doc: |
> + Device is capable of exposing receive checksum result via
> + bpf_xdp_metadata_rx_checksum().
> -
> type: flags
> name: xsk-flags
nit: let's fold it into patch 2? Will be easier to git blame the
feature..
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH RFC bpf-next 2/6] net: xdp: Add xmo_rx_checksum callback
2025-09-20 12:20 ` [PATCH RFC bpf-next 2/6] net: xdp: Add xmo_rx_checksum callback Lorenzo Bianconi
@ 2025-09-22 15:43 ` Stanislav Fomichev
2025-09-22 15:56 ` Lorenzo Bianconi
0 siblings, 1 reply; 13+ messages in thread
From: Stanislav Fomichev @ 2025-09-22 15:43 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan, netdev,
bpf, intel-wired-lan, linux-kselftest
On 09/20, Lorenzo Bianconi wrote:
> Introduce xmo_rx_checksum netdev callback in order allow the eBPF
> program bounded to the device to retrieve the RX checksum result computed
> by the hw NIC.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> include/net/xdp.h | 6 ++++++
> net/core/xdp.c | 29 +++++++++++++++++++++++++++++
> 2 files changed, 35 insertions(+)
>
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index 6fd294fa6841d59c3d7dc4475e09e731996566b0..481b39976ac8c8d4db2de39055c72ba8d0d511c3 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
> @@ -581,6 +581,10 @@ void xdp_attachment_setup(struct xdp_attachment_info *info,
> NETDEV_XDP_RX_METADATA_VLAN_TAG, \
> bpf_xdp_metadata_rx_vlan_tag, \
> xmo_rx_vlan_tag) \
> + XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_CHECKSUM, \
> + NETDEV_XDP_RX_METADATA_CHECKSUM, \
> + bpf_xdp_metadata_rx_checksum, \
> + xmo_rx_checksum)
>
> enum xdp_rx_metadata {
> #define XDP_METADATA_KFUNC(name, _, __, ___) name,
> @@ -644,6 +648,8 @@ struct xdp_metadata_ops {
> enum xdp_rss_hash_type *rss_type);
> int (*xmo_rx_vlan_tag)(const struct xdp_md *ctx, __be16 *vlan_proto,
> u16 *vlan_tci);
> + int (*xmo_rx_checksum)(const struct xdp_md *ctx, u8 *ip_summed,
> + u32 *cksum_meta);
> };
>
> #ifdef CONFIG_NET
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 9100e160113a9a1e2cb88e7602e85c5f36a9f3b9..3edab2d5e5c7c2013b1ef98c949a83655eb94349 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
> @@ -961,6 +961,35 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
> return -EOPNOTSUPP;
> }
>
> +/**
> + * bpf_xdp_metadata_rx_checksum - Read XDP frame RX checksum.
> + * @ctx: XDP context pointer.
> + * @ip_summed: Return value pointer indicating checksum result.
> + * @cksum_meta: Return value pointer indicating checksum result metadata.
> + *
> + * In case of success, ``ip_summed`` is set to the RX checksum result. Possible
> + * values are:
> + * ``CHECKSUM_NONE``
> + * ``CHECKSUM_UNNECESSARY``
> + * ``CHECKSUM_COMPLETE``
> + * ``CHECKSUM_PARTIAL``
What do you think about adding new UAPI enum here? Similar to
xdp_rss_hash_type for the hash. The values can match the internal
CHECKSUM_XXX ones with (BUILD_BUG_ONs to enforce the relationship).
Will be a bit nicer api-wise to have an enum than an opaque u8.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs
2025-09-22 15:39 ` Stanislav Fomichev
@ 2025-09-22 15:55 ` Lorenzo Bianconi
0 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-22 15:55 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan, netdev,
bpf, intel-wired-lan, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]
On Sep 22, Stanislav Fomichev wrote:
> On 09/20, Lorenzo Bianconi wrote:
> > Introduce XDP RX checksum capability to XDP metadata specs. XDP RX
> > checksum will be use by devices capable of exposing receive checksum
> > result via bpf_xdp_metadata_rx_checksum().
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > Documentation/netlink/specs/netdev.yaml | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
> > index e00d3fa1c152d7165e9485d6d383a2cc9cef7cfd..00699bf4a7fdb67c6b9ee3548098b0c933fd39a4 100644
> > --- a/Documentation/netlink/specs/netdev.yaml
> > +++ b/Documentation/netlink/specs/netdev.yaml
> > @@ -61,6 +61,11 @@ definitions:
> > doc: |
> > Device is capable of exposing receive packet VLAN tag via
> > bpf_xdp_metadata_rx_vlan_tag().
> > + -
> > + name: checksum
> > + doc: |
> > + Device is capable of exposing receive checksum result via
> > + bpf_xdp_metadata_rx_checksum().
> > -
> > type: flags
> > name: xsk-flags
>
> nit: let's fold it into patch 2? Will be easier to git blame the
> feature..
ack, I will do it posting a proper series.
Regards,
Lorenzo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH RFC bpf-next 2/6] net: xdp: Add xmo_rx_checksum callback
2025-09-22 15:43 ` Stanislav Fomichev
@ 2025-09-22 15:56 ` Lorenzo Bianconi
0 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Bianconi @ 2025-09-22 15:56 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Andrew Lunn, Tony Nguyen, Przemek Kitszel, Alexander Lobakin,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Hao Luo, Jiri Olsa, Shuah Khan, netdev,
bpf, intel-wired-lan, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 2641 bytes --]
> On 09/20, Lorenzo Bianconi wrote:
> > Introduce xmo_rx_checksum netdev callback in order allow the eBPF
> > program bounded to the device to retrieve the RX checksum result computed
> > by the hw NIC.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > include/net/xdp.h | 6 ++++++
> > net/core/xdp.c | 29 +++++++++++++++++++++++++++++
> > 2 files changed, 35 insertions(+)
> >
> > diff --git a/include/net/xdp.h b/include/net/xdp.h
> > index 6fd294fa6841d59c3d7dc4475e09e731996566b0..481b39976ac8c8d4db2de39055c72ba8d0d511c3 100644
> > --- a/include/net/xdp.h
> > +++ b/include/net/xdp.h
> > @@ -581,6 +581,10 @@ void xdp_attachment_setup(struct xdp_attachment_info *info,
> > NETDEV_XDP_RX_METADATA_VLAN_TAG, \
> > bpf_xdp_metadata_rx_vlan_tag, \
> > xmo_rx_vlan_tag) \
> > + XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_CHECKSUM, \
> > + NETDEV_XDP_RX_METADATA_CHECKSUM, \
> > + bpf_xdp_metadata_rx_checksum, \
> > + xmo_rx_checksum)
> >
> > enum xdp_rx_metadata {
> > #define XDP_METADATA_KFUNC(name, _, __, ___) name,
> > @@ -644,6 +648,8 @@ struct xdp_metadata_ops {
> > enum xdp_rss_hash_type *rss_type);
> > int (*xmo_rx_vlan_tag)(const struct xdp_md *ctx, __be16 *vlan_proto,
> > u16 *vlan_tci);
> > + int (*xmo_rx_checksum)(const struct xdp_md *ctx, u8 *ip_summed,
> > + u32 *cksum_meta);
> > };
> >
> > #ifdef CONFIG_NET
> > diff --git a/net/core/xdp.c b/net/core/xdp.c
> > index 9100e160113a9a1e2cb88e7602e85c5f36a9f3b9..3edab2d5e5c7c2013b1ef98c949a83655eb94349 100644
> > --- a/net/core/xdp.c
> > +++ b/net/core/xdp.c
> > @@ -961,6 +961,35 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
> > return -EOPNOTSUPP;
> > }
> >
> > +/**
> > + * bpf_xdp_metadata_rx_checksum - Read XDP frame RX checksum.
> > + * @ctx: XDP context pointer.
> > + * @ip_summed: Return value pointer indicating checksum result.
> > + * @cksum_meta: Return value pointer indicating checksum result metadata.
> > + *
> > + * In case of success, ``ip_summed`` is set to the RX checksum result. Possible
> > + * values are:
> > + * ``CHECKSUM_NONE``
> > + * ``CHECKSUM_UNNECESSARY``
> > + * ``CHECKSUM_COMPLETE``
> > + * ``CHECKSUM_PARTIAL``
>
> What do you think about adding new UAPI enum here? Similar to
> xdp_rss_hash_type for the hash. The values can match the internal
> CHECKSUM_XXX ones with (BUILD_BUG_ONs to enforce the relationship).
> Will be a bit nicer api-wise to have an enum than an opaque u8.
ack, fine. I will fix it v1.
Regards,
Lorenzo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-09-22 15:56 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-20 12:20 [PATCH RFC bpf-next 0/6] Add the the capability to load HW RX checsum in eBPF programs Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Lorenzo Bianconi
2025-09-22 15:39 ` Stanislav Fomichev
2025-09-22 15:55 ` Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 2/6] net: xdp: Add xmo_rx_checksum callback Lorenzo Bianconi
2025-09-22 15:43 ` Stanislav Fomichev
2025-09-22 15:56 ` Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 3/6] veth: Add xmo_rx_checksum callback to veth driver Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback Lorenzo Bianconi
2025-09-22 10:16 ` Maciej Fijalkowski
2025-09-22 10:32 ` Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 5/6] selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum Lorenzo Bianconi
2025-09-20 12:20 ` [PATCH RFC bpf-next 6/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).