From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: <matt@boondocker.io>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.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>,
<intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
<bpf@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order
Date: Fri, 4 Dec 2026 10:49:10 +0100 [thread overview]
Message-ID: <axKMlqCtkEBpE2dv@boxer> (raw)
In-Reply-To: <20261203-b4-i40e-xsk-queue-order-v2-1-e14b712d5fc2@boondocker.io>
On Thu, Dec 03, 2026 at 03:53:13PM -0700, Matt Thompson via B4 Relay wrote:
> From: Matt Thompson <matt@boondocker.io>
>
> An AF_XDP zero-copy pool transition on an active X710 can time out
> disabling the regular Tx ring. With 12 combined queues and simultaneous
> 2048-frame bursts on queues 0 and 11, the original driver reported
> "VSI seid 390 Tx ring 11 disable timeout" and networking stopped
> responding.
>
> The queue-pair path disables Tx before Rx. The whole-VSI shutdown path
> first announces the Tx disable to firmware, disables Rx, waits for the
> Rx disable erratum, and then disables both regular and XDP Tx queues.
> Use that sequence for a single queue pair as well. Bring Rx up before
> Tx on enable, matching the whole-VSI start path.
>
> The Tx queue disable request is asynchronous. The X710 leaves QENA_STAT
> set until a disable marker has traversed the Tx pipe, including when
> the descriptor ring is empty. The original ten 10-20 us sleeps can
> report failure while QENA_REQ is clear and QENA_STAT is still set; in
> the test the status then cleared within milliseconds. Poll the status
> with an elapsed-time deadline before cleaning the rings and releasing
> the AF_XDP pool. The deadline covers the observed multi-millisecond
> transitions without using a fixed retry count.
>
> With this change, 1,000 AF_XDP setup/teardown cycles at 12 queues
> completed 2,048 Tx descriptors per cycle on each of queues 0 and 11.
> Another 310 cycles closed the sockets with 2,048 Tx descriptors per
> queue still uncompleted. Neither test produced a disable timeout or
> AF_XDP teardown warning.
>
> Fixes: 123cecd427b6 ("i40e: added queue pair disable/enable functions")
> Cc: stable@vger.kernel.org
> Signed-off-by: Matt Thompson <matt@boondocker.io>
Awesome, thanks:
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> Changes in v2:
> - Share the per-queue disable wait with the full-VSI path, as requested by Maciej Fijalkowski.
> - Order the new local declarations in reverse Christmas tree style.
> - Wait for Tx QENA_STAT with a time-based deadline so the hardware disable marker can drain before AF_XDP buffers are released.
> - Retain the v1 queue shutdown and startup ordering changes.
> - Link to v1: https://patch.msgid.link/20261202-b4-i40e-xsk-queue-order-v1-1-737cfb5a0146@boondocker.io
>
> To: Tony Nguyen <anthony.l.nguyen@intel.com>
> To: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> To: Andrew Lunn <andrew+netdev@lunn.ch>
> To: "David S. Miller" <davem@davemloft.net>
> To: Eric Dumazet <edumazet@kernel.org>
> To: Jakub Kicinski <kuba@kernel.org>
> To: Paolo Abeni <pabeni@redhat.com>
> To: Alexei Starovoitov <ast@kernel.org>
> To: Daniel Borkmann <daniel@iogearbox.net>
> To: Jesper Dangaard Brouer <hawk@kernel.org>
> To: John Fastabend <john.fastabend@gmail.com>
> To: Stanislav Fomichev <sdf@fomichev.me>
> Cc: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org
> Cc: bpf@vger.kernel.org
> ---
> drivers/net/ethernet/intel/i40e/i40e_main.c | 148 ++++++++++++++--------------
> 1 file changed, 72 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index abbc71e81..555eac07e 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -7,6 +7,7 @@
> #include <linux/net/intel/libie/rx.h>
> #include <linux/if_bridge.h>
> #include <linux/if_macvlan.h>
> +#include <linux/iopoll.h>
> #include <linux/module.h>
> #include <net/pkt_cls.h>
> #include <net/xdp_sock_drv.h>
> @@ -4660,6 +4661,8 @@ static void i40e_netpoll(struct net_device *netdev)
> #endif
>
> #define I40E_QTX_ENA_WAIT_COUNT 50
> +#define I40E_TXQ_ENABLE_TIMEOUT_US 1000
> +#define I40E_TXQ_DISABLE_TIMEOUT_US 20000
>
> /**
> * i40e_pf_txq_wait - Wait for a PF's Tx queue to be enabled or disabled
> @@ -4674,20 +4677,16 @@ static void i40e_netpoll(struct net_device *netdev)
> **/
> static int i40e_pf_txq_wait(struct i40e_pf *pf, int pf_q, bool enable)
> {
> - int i;
> u32 tx_reg;
>
> - for (i = 0; i < I40E_QUEUE_WAIT_RETRY_LIMIT; i++) {
> - tx_reg = rd32(&pf->hw, I40E_QTX_ENA(pf_q));
> - if (enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
> - break;
> -
> - usleep_range(10, 20);
> - }
> - if (i >= I40E_QUEUE_WAIT_RETRY_LIMIT)
> - return -ETIMEDOUT;
> -
> - return 0;
> + /* QENA_STAT stays set until the disable marker leaves the Tx pipe.
> + * The pipe can take milliseconds to drain even when the ring is empty.
> + */
> + return read_poll_timeout(rd32, tx_reg,
> + enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK),
> + 200, enable ? I40E_TXQ_ENABLE_TIMEOUT_US :
> + I40E_TXQ_DISABLE_TIMEOUT_US, false, &pf->hw,
> + I40E_QTX_ENA(pf_q));
> }
>
> /**
> @@ -5293,6 +5292,39 @@ static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf)
> i40e_unquiesce_vsi(vsi);
> }
>
> +static int i40e_queue_pair_wait_queues_disabled(struct i40e_vsi *vsi, int pf_q)
> +{
> + struct i40e_pf *pf = vsi->back;
> + int ret;
> +
> + ret = i40e_pf_txq_wait(pf, pf_q, false);
> + if (ret) {
> + dev_info(&pf->pdev->dev,
> + "VSI seid %d Tx ring %d disable timeout\n",
> + vsi->seid, pf_q);
> + return ret;
> + }
> +
> + if (i40e_enabled_xdp_vsi(vsi)) {
> + int xdp_q = pf_q + vsi->alloc_queue_pairs;
> +
> + ret = i40e_pf_txq_wait(pf, xdp_q, false);
> + if (ret) {
> + dev_info(&pf->pdev->dev,
> + "VSI seid %d XDP Tx ring %d disable timeout\n",
> + vsi->seid, xdp_q);
> + return ret;
> + }
> + }
> +
> + ret = i40e_pf_rxq_wait(pf, pf_q, false);
> + if (ret)
> + dev_info(&pf->pdev->dev,
> + "VSI seid %d Rx ring %d disable timeout\n",
> + vsi->seid, pf_q);
> + return ret;
> +}
> +
> /**
> * i40e_vsi_wait_queues_disabled - Wait for VSI's queues to be disabled
> * @vsi: the VSI being configured
> @@ -5301,41 +5333,13 @@ static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf)
> **/
> int i40e_vsi_wait_queues_disabled(struct i40e_vsi *vsi)
> {
> - struct i40e_pf *pf = vsi->back;
> int i, pf_q, ret;
>
> pf_q = vsi->base_queue;
> for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) {
> - /* Check and wait for the Tx queue */
> - ret = i40e_pf_txq_wait(pf, pf_q, false);
> - if (ret) {
> - dev_info(&pf->pdev->dev,
> - "VSI seid %d Tx ring %d disable timeout\n",
> - vsi->seid, pf_q);
> - return ret;
> - }
> -
> - if (!i40e_enabled_xdp_vsi(vsi))
> - goto wait_rx;
> -
> - /* Check and wait for the XDP Tx queue */
> - ret = i40e_pf_txq_wait(pf, pf_q + vsi->alloc_queue_pairs,
> - false);
> - if (ret) {
> - dev_info(&pf->pdev->dev,
> - "VSI seid %d XDP Tx ring %d disable timeout\n",
> - vsi->seid, pf_q);
> - return ret;
> - }
> -wait_rx:
> - /* Check and wait for the Rx queue */
> - ret = i40e_pf_rxq_wait(pf, pf_q, false);
> - if (ret) {
> - dev_info(&pf->pdev->dev,
> - "VSI seid %d Rx ring %d disable timeout\n",
> - vsi->seid, pf_q);
> + ret = i40e_queue_pair_wait_queues_disabled(vsi, pf_q);
> + if (ret)
> return ret;
> - }
> }
>
> return 0;
> @@ -13408,46 +13412,38 @@ static int i40e_queue_pair_toggle_rings(struct i40e_vsi *vsi, int queue_pair,
> bool enable)
> {
> struct i40e_pf *pf = vsi->back;
> - int pf_q, ret = 0;
> + int xdp_q, pf_q, ret;
> + bool has_xdp;
>
> + has_xdp = i40e_enabled_xdp_vsi(vsi);
> pf_q = vsi->base_queue + queue_pair;
> - ret = i40e_control_wait_tx_q(vsi->seid, pf, pf_q,
> - false /*is xdp*/, enable);
> - if (ret) {
> - dev_info(&pf->pdev->dev,
> - "VSI seid %d Tx ring %d %sable timeout\n",
> - vsi->seid, pf_q, (enable ? "en" : "dis"));
> - return ret;
> - }
> + xdp_q = pf_q + vsi->alloc_queue_pairs;
>
> - i40e_control_rx_q(pf, pf_q, enable);
> - ret = i40e_pf_rxq_wait(pf, pf_q, enable);
> - if (ret) {
> - dev_info(&pf->pdev->dev,
> - "VSI seid %d Rx ring %d %sable timeout\n",
> - vsi->seid, pf_q, (enable ? "en" : "dis"));
> - return ret;
> - }
> -
> - /* Due to HW errata, on Rx disable only, the register can
> - * indicate done before it really is. Needs 50ms to be sure
> - */
> - if (!enable)
> - mdelay(50);
> -
> - if (!i40e_enabled_xdp_vsi(vsi))
> - return ret;
> + if (!enable) {
> + /* Use the same firmware transition as i40e_vsi_stop_rings().
> + * Both TX queues must be announced before RX is stopped.
> + */
> + i40e_pre_tx_queue_cfg(&pf->hw, pf_q, false);
> + if (has_xdp)
> + i40e_pre_tx_queue_cfg(&pf->hw, xdp_q, false);
> + i40e_control_rx_q(pf, pf_q, false);
> + msleep(I40E_DISABLE_TX_GAP_MSEC);
> + wr32(&pf->hw, I40E_QTX_ENA(pf_q), 0);
> + if (has_xdp)
> + wr32(&pf->hw, I40E_QTX_ENA(xdp_q), 0);
>
> - ret = i40e_control_wait_tx_q(vsi->seid, pf,
> - pf_q + vsi->alloc_queue_pairs,
> - true /*is xdp*/, enable);
> - if (ret) {
> - dev_info(&pf->pdev->dev,
> - "VSI seid %d XDP Tx ring %d %sable timeout\n",
> - vsi->seid, pf_q, (enable ? "en" : "dis"));
> + return i40e_queue_pair_wait_queues_disabled(vsi, pf_q);
> }
>
> - return ret;
> + /* The whole-VSI enable path brings RX up before TX. */
> + i40e_control_rx_q(pf, pf_q, true);
> + ret = i40e_pf_rxq_wait(pf, pf_q, true);
> + if (ret)
> + return ret;
> + ret = i40e_control_wait_tx_q(vsi->seid, pf, pf_q, false, true);
> + if (ret || !has_xdp)
> + return ret;
> + return i40e_control_wait_tx_q(vsi->seid, pf, xdp_q, true, true);
> }
>
> /**
>
> ---
> base-commit: c1c39137dcc3134010566ff29a81c93124efa539
> change-id: 20261202-b4-i40e-xsk-queue-order-0103023207a2
>
> Best regards,
> --
> Matt Thompson <matt@boondocker.io>
>
>
>
next prev parent reply other threads:[~2026-12-04 9:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 22:53 [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order Matt Thompson via B4 Relay
2026-12-04 9:49 ` Maciej Fijalkowski [this message]
2026-12-04 14:52 ` 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=axKMlqCtkEBpE2dv@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=matt@boondocker.io \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=stable@vger.kernel.org \
/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