Skip to content

Add the the capability to load HW RX checsum in eBPF programs#11012

Closed
kernel-patches-daemon-bpf[bot] wants to merge 5 commits intobpf-next_basefrom
series/1052828=>bpf-next
Closed

Add the the capability to load HW RX checsum in eBPF programs#11012
kernel-patches-daemon-bpf[bot] wants to merge 5 commits intobpf-next_basefrom
series/1052828=>bpf-next

Conversation

@kernel-patches-daemon-bpf
Copy link

Pull request for series with
subject: Add the the capability to load HW RX checsum in eBPF programs
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: db975de
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828
version: 1

@kernel-patches-review-bot
Copy link

commit 6de365db30bae44b9c975e5b2c3e141f2ddb7618
Author: Lorenzo Bianconi <lorenzo@kernel.org>

selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog

This commit adds support for dumping HW rx checksum metadata in the
xdp_hw_metadata test program using the bpf_xdp_metadata_rx_checksum() kfunc.

> diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
> index 330ece2eabdb..dc62d572e3ac 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);

This call to bpf_xdp_metadata_rx_checksum() appears to be missing its extern
declaration. The other kfuncs in this file have declarations like:

extern int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx,
                                         __u64 *timestamp) __ksym;
extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash,
                                    enum xdp_rss_hash_type *rss_type) __ksym;
extern int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
                                        __be16 *vlan_proto,
                                        __u16 *vlan_tci) __ksym;

Should there be a corresponding declaration for bpf_xdp_metadata_rx_checksum?

> +	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

[ ... ]

> @@ -254,6 +277,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);
                       ^^^^^^

Minor typo: "rx_chsum" should be "rx_cksum" to match the variable naming
(rx_cksum_err) and be consistent with other similar messages.



AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

In-Reply-To-Subject: netlink: specs: Add XDP RX checksum capability to XDP metadata specs
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21875603263

AI-authorship-score: low
AI-authorship-explanation: The commit is from an established kernel maintainer and follows existing code patterns, with the errors being typical human oversights (missing declaration, typo) rather than AI-generated issues.
issues-found: 2
issue-severity-score: medium
issue-severity-explanation: Missing extern declaration for kfunc will cause compilation failure of the BPF selftest program, plus a minor typo in error output.

@kernel-patches-review-bot
Copy link

commit 167ee93837624374feb19cacb0e99abf047a2913
Author: Lorenzo Bianconi <lorenzo@kernel.org>

net: ice: Add xmo_rx_checksum callback

This commit refactors the ice driver's RX checksum handling to extract
the core logic into a new ice_get_rx_csum() utility function, enabling
code sharing between the existing ice_rx_csum() and a new XDP metadata
callback ice_xdp_rx_checksum().

> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c

[ ... ]

> @@ -168,16 +144,49 @@
>  	 * we are indicating we validated the inner checksum.
>  	 */
>  	if (decoded.tunnel_type >= LIBETH_RX_PT_TUNNEL_IP_GRENAT)
> -		skb->csum_level = 1;
> +		*cksum_meta = 1;
>
> -	skb->ip_summed = CHECKSUM_UNNECESSARY;
> +	*ip_summed = XDP_CHECKSUM_UNNECESSARY;
>  	return;

For non-tunneled packets that reach this return, is cksum_meta left
uninitialized? The tunnel_type check only sets *cksum_meta = 1 for
tunneled packets, but there's no else clause setting it to 0.

The caller ice_rx_csum() declares cksum_meta without initialization:

> +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;
> +	u32 cksum_meta;
> +
> +	ice_get_rx_csum(rx_desc, ptype, ring, &ip_summed, &cksum_meta);
> +	switch (ip_summed) {
> +	case XDP_CHECKSUM_UNNECESSARY:
> +		skb->csum_level = cksum_meta;

When ip_summed is XDP_CHECKSUM_UNNECESSARY and the packet is not tunneled,
this assigns an uninitialized value to skb->csum_level.

The original code relied on skb fields being pre-initialized to 0, but now
the refactored ice_get_rx_csum() needs to explicitly set *cksum_meta = 0
for the non-tunneled CHECKSUM_UNNECESSARY case, similar to how
checksum_none does.

> +		break;
> +	case XDP_CHECKSUM_COMPLETE:
> +		skb->csum = cksum_meta;
> +		break;
> +	default:
> +		break;
> +	}
> +	skb->ip_summed = ip_summed;
> +}

[ ... ]



AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

In-Reply-To-Subject: net: ice: Add xmo_rx_checksum callback
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21875603263

AI-authorship-score: low
AI-authorship-explanation: The commit shows typical human characteristics including a subtle uninitialized variable bug and minor grammatical imperfections in the commit message, both of which are patterns AI tools tend to avoid.
issues-found: 1
issue-severity-score: medium
issue-severity-explanation: Uninitialized variable causes skb->csum_level to receive garbage values for non-tunneled packets with valid checksums, potentially affecting network stack checksum handling.

@kernel-patches-review-bot
Copy link

commit aa7b7822e48c6a77812b4998e3893f7f06d43dda
Author: Lorenzo Bianconi <lorenzo@kernel.org>

net: veth: Add xmo_rx_checksum callback to veth driver

This commit adds the xmo_rx_checksum callback to the veth driver,
allowing XDP programs to query checksum information via the
bpf_xdp_metadata_rx_checksum() kfunc.

> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -1693,6 +1693,25 @@ 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,
> +				enum xdp_checksum *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;

Should cksum_meta return different values based on ip_summed?

The API documentation in net/core/xdp.c states that cksum_meta should contain:
- the hw computed checksum value for XDP_CHECKSUM_COMPLETE
- the csum_level for XDP_CHECKSUM_UNNECESSARY
- 0 for XDP_CHECKSUM_NONE and XDP_CHECKSUM_PARTIAL

The ice driver implementation in this same series handles these cases:

    switch (ip_summed) {
    case XDP_CHECKSUM_COMPLETE:
        *cksum_meta = csum_unfold(...);  /* hw computed checksum */
        break;
    case XDP_CHECKSUM_UNNECESSARY:
        if (tunnel)
            *cksum_meta = 1;  /* csum_level */
        break;
    default:
        *cksum_meta = 0;
        break;
    }

While veth typically handles locally generated packets (CHECKSUM_PARTIAL) or
packets with CHECKSUM_NONE, packets forwarded from other interfaces could have
CHECKSUM_COMPLETE or CHECKSUM_UNNECESSARY with csum_level > 0.

Would something like the following be more consistent with the API:

    switch (skb->ip_summed) {
    case CHECKSUM_COMPLETE:
        *cksum_meta = skb->csum;
        break;
    case CHECKSUM_UNNECESSARY:
        *cksum_meta = skb->csum_level;
        break;
    default:
        *cksum_meta = 0;
        break;
    }

> +
> +	return 0;
> +}

[ ... ]



AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

In-Reply-To-Subject: net: veth: Add xmo_rx_checksum callback to veth driver
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21875603263

AI-authorship-score: low
AI-authorship-explanation: The commit follows established kernel patterns, has a concise commit message, and is authored by a known kernel contributor with extensive networking experience.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: API inconsistency where cksum_meta always returns 0 instead of returning skb->csum for CHECKSUM_COMPLETE or skb->csum_level for CHECKSUM_UNNECESSARY as documented.

@kernel-patches-review-bot
Copy link

commit 6de365db30bae44b9c975e5b2c3e141f2ddb7618
Author: Lorenzo Bianconi <lorenzo@kernel.org>

selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog

This commit adds support for the bpf_xdp_metadata_rx_checksum() kfunc to
the xdp_hw_metadata selftest program, enabling verification of hardware
RX checksum metadata.

> selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog

This isn't a bug, but there's a typo in the subject line - "xdp_hw_metadat"
should be "xdp_hw_metadata".

> diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c
> --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
> +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c

[ ... ]

> +	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);
                    ^^^^^^^^

Should "rx_chsum" be "rx_checksum"?  The other error messages in this
function use the full field names: "rx_hash", "rx_timestamp",
"rx_vlan_tci".

> diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
> --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
> +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c

[ ... ]

> +	err = bpf_xdp_metadata_rx_checksum(ctx, &meta->ip_summed,
> +					   &meta->cksum_meta);

The file declares extern __ksym for the other XDP metadata kfuncs:

    extern int bpf_xdp_metadata_rx_timestamp(...) __ksym;
    extern int bpf_xdp_metadata_rx_hash(...) __ksym;
    extern int bpf_xdp_metadata_rx_vlan_tag(...) __ksym;

Should bpf_xdp_metadata_rx_checksum have a matching extern declaration
for consistency?



AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

In-Reply-To-Subject: selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21875603263

AI-authorship-score: low
AI-authorship-explanation: The presence of typos and natural integration with existing kernel patterns suggest human authorship; no AI-like patterns detected.
issues-found: 3
issue-severity-score: low
issue-severity-explanation: Three minor issues found in test code: two typos (commit subject, error message) and a missing extern declaration for consistency.

@kernel-patches-review-bot
Copy link

commit b68d6ab905b9911620f14b6c4e1e872ab74ae5dc
Author: Lorenzo Bianconi <lorenzo@kernel.org>

selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum

This commit adds selftest support for the bpf_xdp_metadata_rx_checksum kfunc
to the xdp_metadata selftest. It extends the xdp_meta struct with checksum
fields and adds verification assertions.

> diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata.c b/tools/testing/selftests/bpf/progs/xdp_metadata.c
> index 09bb8a038d52..ef6a5584a187 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);

Is there a missing extern declaration for bpf_xdp_metadata_rx_checksum()?
The other kfuncs used in this file have extern declarations with __ksym:

extern int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx,
                                         __u64 *timestamp) __ksym;
extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash,
                                    enum xdp_rss_hash_type *rss_type) __ksym;
extern int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
                                        __be16 *vlan_proto,
                                        __u16 *vlan_tci) __ksym;

Without a similar declaration for bpf_xdp_metadata_rx_checksum(), the BPF
program may fail to compile or link.



AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

In-Reply-To-Subject: selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21875603263

AI-authorship-score: low
AI-authorship-explanation: The code follows standard BPF selftest patterns and appears to be written by a domain expert familiar with XDP metadata kfuncs.
issues-found: 1
issue-severity-score: medium
issue-severity-explanation: Missing extern declaration for bpf_xdp_metadata_rx_checksum kfunc will cause BPF program build failure.

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: a9aabb3
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: dc855b7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: dc855b7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: dc855b7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828
version: 1

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().
Moreover, 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>
Implement xmo_rx_checksum callback in veth driver to report RX checksum
result to the eBPF program bounded to the veth device.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
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 rx cksum codebase
available in ice_rx_csum().

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Introduce support to xdp_metadata selftest for bpf_xdp_metadata_rx_checksum
kfunc.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
…adat prog

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>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4475cda
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1052828 expired. Closing PR.

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot deleted the series/1052828=>bpf-next branch February 13, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant