On Thu, Dec 03, 2026 at 03:53:13PM -0700, Matt Thompson via B4 Relay wrote:
> From: Matt Thompson <ma…@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: stab…@vger.kernel.org > Signed-off-by: Matt Thompson <ma…@boondocker.io>
Awesome, thanks: Reviewed-by: Maciej Fijalkowski <maci…@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/2026…@boondocker.io > > To: Tony Nguyen <anth…@intel.com> > To: Przemek Kitszel <prze…@intel.com> > To: Andrew Lunn <andr…@lunn.ch> > To: "David S. Miller" <dav…@davemloft.net> > To: Eric Dumazet <edum…@kernel.org> > To: Jakub Kicinski <ku…@kernel.org> > To: Paolo Abeni <pabe…@redhat.com> > To: Alexei Starovoitov <a…@kernel.org> > To: Daniel Borkmann <dani…@iogearbox.net> > To: Jesper Dangaard Brouer <ha…@kernel.org> > To: John Fastabend <john…@gmail.com> > To: Stanislav Fomichev <s…@fomichev.me> > Cc: inte…@lists.osuosl.org > Cc: netd…@vger.kernel.org > Cc: b…@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 <ma…@boondocker.io> > > >