* [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order
@ 2026-12-03 22:53 Matt Thompson via B4 Relay
2026-12-04 9:49 ` Maciej Fijalkowski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Matt Thompson via B4 Relay @ 2026-12-03 22:53 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev
Cc: intel-wired-lan, netdev, bpf, stable, Matt Thompson
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>
---
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>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order
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
2026-12-04 14:52 ` Loktionov, Aleksandr
2026-12-04 22:53 ` sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: Maciej Fijalkowski @ 2026-12-04 9:49 UTC (permalink / raw)
To: matt
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, intel-wired-lan, netdev, bpf, stable
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>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order
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
@ 2026-12-04 14:52 ` Loktionov, Aleksandr
2026-12-04 22:53 ` sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: Loktionov, Aleksandr @ 2026-12-04 14:52 UTC (permalink / raw)
To: matt@boondocker.io, Nguyen, Anthony L, Kitszel, Przemyslaw,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, stable@vger.kernel.org
> -----Original Message-----
> From: Matt Thompson via B4 Relay <devnull+matt.boondocker.io@kernel.org>
> Sent: Thursday, December 3, 2026 11:53 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <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>
> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org;
> bpf@vger.kernel.org; stable@vger.kernel.org; Matt Thompson
> <matt@boondocker.io>
> Subject: [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order
>
> 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>
> ---
> 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);
> }
>
...
> }
>
> /**
>
> ---
> base-commit: c1c39137dcc3134010566ff29a81c93124efa539
> change-id: 20261202-b4-i40e-xsk-queue-order-0103023207a2
>
> Best regards,
> --
> Matt Thompson <matt@boondocker.io>
>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order
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
2026-12-04 14:52 ` Loktionov, Aleksandr
@ 2026-12-04 22:53 ` sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-04 22:53 UTC (permalink / raw)
To: Matt Thompson; +Cc: intel-wired-lan, bpf
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] i40e: i40e_pf_txq_wait() 20 ms timeout multiplies
sequentially across VFs
- [Low] i40e: Rx enable timeout log dropped in
i40e_queue_pair_toggle_rings()
--
commit 93f51afdbe4fd98b091222e08a53b9e822832e16
Author: Matt Thompson <matt@boondocker.io>
i40e: stop XSK queue pairs in VSI shutdown order
This commit updates i40e_queue_pair_toggle_rings() to match the whole-VSI
shutdown and startup sequence, shares the per-queue disable wait with
i40e_vsi_wait_queues_disabled(), and converts i40e_pf_txq_wait() to
read_poll_timeout() with a 20 ms disable timeout.
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index abbc71e815ae3..555eac07e28b8 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
[ ... ]
> @@ -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));
> }
[Severity: Medium]
Can the 20 ms disable timeout in i40e_pf_txq_wait() multiply into a
multi-second stall across VFs?
i40e_reset_all_vfs() and i40e_free_vfs() call
i40e_vsi_wait_queues_disabled() per VF and ignore -ETIMEDOUT. If a
wedged Tx pipe or PCIe link loss (rd32() returning 0xffffffff) leaves
QENA_STAT set, up to 128 VFs wait 20 ms each sequentially (up to 2.56 s).
When i40e_rebuild() runs with lock_acquired true (such as from
i40e_do_reset_safe()), i40e_reset_all_vfs() holds global rtnl_lock()
across the whole loop. Exiting early on tx_reg == ~0U and aborting or
sharing a deadline across VFs would avoid this.
[ ... ]
> @@ -13408,46 +13412,38 @@ static int i40e_queue_pair_toggle_rings(struct i40e_vsi *vsi, int queue_pair,
> bool enable)
[ ... ]
> - 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;
> - }
[ ... ]
> + /* 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);
> }
[Severity: Low]
Should this keep the dev_info() Rx ring enable timeout log and reuse
i40e_control_wait_rx_q()?
Unlike i40e_control_wait_tx_q() below, i40e_pf_rxq_wait() does not log on
timeout, so an Rx ring enable failure now returns -ETIMEDOUT silently.
i40e_vsi_enable_rx() calls i40e_control_wait_rx_q() and logs the timeout
explicitly.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-b4-i40e-xsk-queue-order-v2-1-e14b712d5fc2@boondocker.io?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-04 22:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-12-04 14:52 ` Loktionov, Aleksandr
2026-12-04 22:53 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox