public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Larysa Zaremba <larysa.zaremba@intel.com>
Cc: bpf@vger.kernel.org, "Claudiu Manoil" <claudiu.manoil@nxp.com>,
	"Vladimir Oltean" <vladimir.oltean@nxp.com>,
	"Wei Fang" <wei.fang@nxp.com>,
	"Clark Wang" <xiaoning.wang@nxp.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Tony Nguyen" <anthony.l.nguyen@intel.com>,
	"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
	"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>,
	"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>, "Simon Horman" <horms@kernel.org>,
	"Shuah Khan" <shuah@kernel.org>,
	"Alexander Lobakin" <aleksander.lobakin@intel.com>,
	"Bastien Curutchet (eBPF Foundation)"
	<bastien.curutchet@bootlin.com>,
	"Tushar Vyavahare" <tushar.vyavahare@intel.com>,
	"Jason Xing" <kernelxing@tencent.com>,
	"Ricardo B. Marlière" <rbm@suse.com>,
	"Eelco Chaudron" <echaudro@redhat.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Toke Hoiland-Jorgensen" <toke@redhat.com>,
	imx@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
	linux-kselftest@vger.kernel.org,
	"Aleksandr Loktionov" <aleksandr.loktionov@intel.com>,
	"Dragos Tatulea" <dtatulea@nvidia.com>
Subject: Re: [PATCH bpf v3 5/9] i40e: fix registering XDP RxQ info
Date: Thu, 19 Feb 2026 13:00:05 +0100	[thread overview]
Message-ID: <aZb7RZMA+7bxcmrL@boxer> (raw)
In-Reply-To: <20260217132450.1936200-6-larysa.zaremba@intel.com>

On Tue, Feb 17, 2026 at 02:24:43PM +0100, Larysa Zaremba wrote:
> Current way of handling XDP RxQ info in i40e has following problems:
> * when xsk_buff_pool is detached, memory model is not unregistered before
>   registering a new one, this leads to a dangling xsk_buff_pool in the
>   memory model table

What is 'memory model table' in this context?

I believe you are referring to a case where XDP prog is kept alive on
interface put you close one socket and then bind the other one?

> * frag_size is not updated when xsk_buff_pool is detached or when MTU is
>   changed, this leads to growing tail always failing for multi-buffer
>   packets.

Good catch, i now see that i40e_change_mtu() only does the link flap and
i40e_free_rx_resources() is not called in this path.

> 
> Couple XDP RxQ info registering with buffer allocations and unregistering
> with cleaning the ring.
> 
> Fixes: a045d2f2d03d ("i40e: set xdp_rxq_info::frag_size")
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 34 ++++++++++++---------
>  drivers/net/ethernet/intel/i40e/i40e_txrx.c |  5 +--
>  2 files changed, 22 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index d3bc3207054f..eaa5b65e6daf 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -3577,18 +3577,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
>  	if (ring->vsi->type != I40E_VSI_MAIN)
>  		goto skip;
>  
> -	if (!xdp_rxq_info_is_reg(&ring->xdp_rxq)) {
> -		err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev,
> -					 ring->queue_index,
> -					 ring->q_vector->napi.napi_id,
> -					 ring->rx_buf_len);
> -		if (err)
> -			return err;
> -	}
> -
>  	ring->xsk_pool = i40e_xsk_pool(ring);
>  	if (ring->xsk_pool) {
> -		xdp_rxq_info_unreg(&ring->xdp_rxq);
>  		ring->rx_buf_len = xsk_pool_get_rx_frame_size(ring->xsk_pool);
>  		err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev,
>  					 ring->queue_index,
> @@ -3600,17 +3590,23 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
>  						 MEM_TYPE_XSK_BUFF_POOL,
>  						 NULL);
>  		if (err)
> -			return err;
> +			goto unreg_xdp;
>  		dev_info(&vsi->back->pdev->dev,
>  			 "Registered XDP mem model MEM_TYPE_XSK_BUFF_POOL on Rx ring %d\n",
>  			 ring->queue_index);
>  
>  	} else {
> +		err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev,
> +					 ring->queue_index,
> +					 ring->q_vector->napi.napi_id,
> +					 ring->rx_buf_len);
> +		if (err)
> +			return err;
>  		err = xdp_rxq_info_reg_mem_model(&ring->xdp_rxq,
>  						 MEM_TYPE_PAGE_SHARED,
>  						 NULL);
>  		if (err)
> -			return err;
> +			goto unreg_xdp;
>  	}
>  
>  skip:
> @@ -3648,7 +3644,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
>  		dev_info(&vsi->back->pdev->dev,
>  			 "Failed to clear LAN Rx queue context on Rx ring %d (pf_q %d), error: %d\n",
>  			 ring->queue_index, pf_q, err);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto unreg_xdp;
>  	}
>  
>  	/* set the context in the HMC */
> @@ -3657,7 +3654,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
>  		dev_info(&vsi->back->pdev->dev,
>  			 "Failed to set LAN Rx queue context on Rx ring %d (pf_q %d), error: %d\n",
>  			 ring->queue_index, pf_q, err);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto unreg_xdp;
>  	}
>  
>  	/* configure Rx buffer alignment */
> @@ -3665,7 +3663,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
>  		if (I40E_2K_TOO_SMALL_WITH_PADDING) {
>  			dev_info(&vsi->back->pdev->dev,
>  				 "2k Rx buffer is too small to fit standard MTU and skb_shared_info\n");
> -			return -EOPNOTSUPP;
> +			err = -EOPNOTSUPP;
> +			goto unreg_xdp;
>  		}
>  		clear_ring_build_skb_enabled(ring);
>  	} else {
> @@ -3695,6 +3694,11 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
>  	}
>  
>  	return 0;
> +unreg_xdp:
> +	if (ring->vsi->type == I40E_VSI_MAIN)
> +		xdp_rxq_info_unreg(&ring->xdp_rxq);
> +
> +	return err;
>  }
>  
>  /**
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> index cc0b9efc2637..816179c7e271 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> @@ -1470,6 +1470,9 @@ void i40e_clean_rx_ring(struct i40e_ring *rx_ring)
>  	if (!rx_ring->rx_bi)
>  		return;
>  
> +	if (xdp_rxq_info_is_reg(&rx_ring->xdp_rxq))
> +		xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
> +
>  	if (rx_ring->xsk_pool) {
>  		i40e_xsk_clean_rx_ring(rx_ring);
>  		goto skip_free;
> @@ -1527,8 +1530,6 @@ void i40e_clean_rx_ring(struct i40e_ring *rx_ring)
>  void i40e_free_rx_resources(struct i40e_ring *rx_ring)
>  {
>  	i40e_clean_rx_ring(rx_ring);
> -	if (rx_ring->vsi->type == I40E_VSI_MAIN)
> -		xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
>  	rx_ring->xdp_prog = NULL;
>  	kfree(rx_ring->rx_bi);
>  	rx_ring->rx_bi = NULL;
> -- 
> 2.52.0
> 

  parent reply	other threads:[~2026-02-19 12:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-17 13:24 [PATCH bpf v3 0/9] Address XDP frags having negative tailroom Larysa Zaremba
2026-02-17 13:24 ` [PATCH bpf v3 1/9] xdp: use modulo operation to calculate XDP frag tailroom Larysa Zaremba
2026-02-17 15:10   ` Loktionov, Aleksandr
2026-02-17 13:24 ` [PATCH bpf v3 2/9] xsk: introduce helper to determine rxq->frag_size Larysa Zaremba
2026-02-17 15:11   ` Loktionov, Aleksandr
2026-02-17 13:24 ` [PATCH bpf v3 3/9] ice: fix rxq info registering in mbuf packets Larysa Zaremba
2026-02-17 13:24 ` [PATCH bpf v3 4/9] ice: change XDP RxQ frag_size from DMA write length to xdp.frame_sz Larysa Zaremba
2026-02-27 11:22   ` Maciej Fijalkowski
2026-03-02 14:32     ` Larysa Zaremba
2026-02-17 13:24 ` [PATCH bpf v3 5/9] i40e: fix registering XDP RxQ info Larysa Zaremba
2026-02-17 15:12   ` Loktionov, Aleksandr
2026-02-19 12:00   ` Maciej Fijalkowski [this message]
2026-03-02 14:23     ` Larysa Zaremba
2026-02-17 13:24 ` [PATCH bpf v3 6/9] i40e: use xdp.frame_sz as XDP RxQ info frag_size Larysa Zaremba
2026-02-17 15:13   ` Loktionov, Aleksandr
2026-02-17 13:24 ` [PATCH bpf v3 7/9] libeth, idpf: use truesize " Larysa Zaremba
2026-02-17 15:06   ` Loktionov, Aleksandr
2026-02-17 16:19   ` Alexander Lobakin
2026-02-17 13:24 ` [PATCH bpf v3 8/9] net: enetc: " Larysa Zaremba
2026-02-17 13:24 ` [PATCH bpf v3 9/9] xdp: produce a warning when calculated tailroom is negative Larysa Zaremba
2026-02-27 15:31 ` [PATCH bpf v3 0/9] Address XDP frags having negative tailroom Maciej Fijalkowski
2026-03-02  9:18   ` Larysa Zaremba

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=aZb7RZMA+7bxcmrL@boxer \
    --to=maciej.fijalkowski@intel.com \
    --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=bastien.curutchet@bootlin.com \
    --cc=bpf@vger.kernel.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=echaudro@redhat.com \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernelxing@tencent.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rbm@suse.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=toke@redhat.com \
    --cc=tushar.vyavahare@intel.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    --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