All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Cc: 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>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback
Date: Mon, 22 Sep 2025 12:32:12 +0200	[thread overview]
Message-ID: <aNElrLdHoh__L1xj@lore-desk> (raw)
In-Reply-To: <aNEh5Q1c93J0p9TN@boxer>

[-- 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 --]

WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Cc: 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>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [Intel-wired-lan] [PATCH RFC bpf-next 4/6] net: ice: Add xmo_rx_checksum callback
Date: Mon, 22 Sep 2025 12:32:12 +0200	[thread overview]
Message-ID: <aNElrLdHoh__L1xj@lore-desk> (raw)
In-Reply-To: <aNEh5Q1c93J0p9TN@boxer>

[-- 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 --]

  reply	other threads:[~2025-09-22 10:32 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` [Intel-wired-lan] " 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   ` [Intel-wired-lan] " Lorenzo Bianconi
2025-09-22 15:39   ` Stanislav Fomichev
2025-09-22 15:39     ` [Intel-wired-lan] " Stanislav Fomichev
2025-09-22 15:55     ` Lorenzo Bianconi
2025-09-22 15:55       ` [Intel-wired-lan] " 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   ` [Intel-wired-lan] " Lorenzo Bianconi
2025-09-21  4:11   ` kernel test robot
2025-09-22 15:43   ` Stanislav Fomichev
2025-09-22 15:43     ` [Intel-wired-lan] " Stanislav Fomichev
2025-09-22 15:56     ` Lorenzo Bianconi
2025-09-22 15:56       ` [Intel-wired-lan] " 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   ` [Intel-wired-lan] " Lorenzo Bianconi
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   ` [Intel-wired-lan] " Lorenzo Bianconi
2025-09-22 10:16   ` Maciej Fijalkowski
2025-09-22 10:16     ` [Intel-wired-lan] " Maciej Fijalkowski
2025-09-22 10:32     ` Lorenzo Bianconi [this message]
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   ` [Intel-wired-lan] " 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
2025-09-20 12:20   ` [Intel-wired-lan] " Lorenzo Bianconi

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=aNElrLdHoh__L1xj@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=aleksander.lobakin@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=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.