* [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper
@ 2026-01-12 9:16 Tariq Toukan
2026-01-12 9:16 ` [PATCH net-next V2 1/3] net: Introduce " Tariq Toukan
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Tariq Toukan @ 2026-01-12 9:16 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Jian Shen, Salil Mehta, Jijie Shao, Saeed Mahameed, Tariq Toukan,
Mark Bloch, Leon Romanovsky, netdev, linux-kernel, linux-rdma,
Gal Pressman, Moshe Shemesh, Shahar Shitrit, Yael Chemla,
Jamal Hadi Salim
Hi,
This is V2, find V1 here:
https://lore.kernel.org/all/1764054776-1308696-1-git-send-email-tariqt@nvidia.com/
This series by Shahar introduces a new helper function
netif_xmit_timeout_ms() to check if a TX queue has timed out and report
the timeout duration.
It also encapsulates the check for whether the TX queue is stopped.
Replace duplicated open-coded timeout check in hns3 driver with the new
helper.
For mlx5e, refine the TX timeout recovery flow to act only on SQs whose
transmit timestamp indicates an actual timeout, as determined by the
helper. This prevents unnecessary channel reopen events caused by
attempting recovery on queues that are merely stopped but not truly
timed out.
Regards,
Tariq
V2:
- Rebase.
- Move helper to include/net/netdev_queues.h.
- Remove output paramter trans_start from the new helper.
- Revert the code in dev_watchdog to not use the helper.
- Fix the helper name in commit message.
Shahar Shitrit (3):
net: Introduce netif_xmit_timeout_ms() helper
net: hns3: Use netif_xmit_timeout_ms() helper
net/mlx5e: Refine TX timeout handling to skip non-timed-out SQ
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 12 +++++-------
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +-
include/net/netdev_queues.h | 11 +++++++++++
3 files changed, 17 insertions(+), 8 deletions(-)
base-commit: 60d8484c4cec811f5ceb6550655df74490d1a165
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next V2 1/3] net: Introduce netif_xmit_timeout_ms() helper
2026-01-12 9:16 [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Tariq Toukan
@ 2026-01-12 9:16 ` Tariq Toukan
2026-01-12 9:16 ` [PATCH net-next V2 2/3] net: hns3: Use " Tariq Toukan
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Tariq Toukan @ 2026-01-12 9:16 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Jian Shen, Salil Mehta, Jijie Shao, Saeed Mahameed, Tariq Toukan,
Mark Bloch, Leon Romanovsky, netdev, linux-kernel, linux-rdma,
Gal Pressman, Moshe Shemesh, Shahar Shitrit, Yael Chemla,
Jamal Hadi Salim
From: Shahar Shitrit <shshitrit@nvidia.com>
Introduce a new helper function netif_xmit_timeout_ms() to check
if a TX queue is stopped and has timed out and report the timeout
duration. This makes the timeout logic reusable, and will be used
in several places in subsequent patches.
Signed-off-by: Shahar Shitrit <shshitrit@nvidia.com>
Reviewed-by: Yael Chemla <ychemla@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
include/net/netdev_queues.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index cd00e0406cf4..b55d3b9cb9c2 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -310,6 +310,17 @@ static inline void netif_subqueue_sent(const struct net_device *dev,
netdev_tx_sent_queue(txq, bytes);
}
+static inline unsigned int netif_xmit_timeout_ms(struct netdev_queue *txq)
+{
+ unsigned long trans_start = READ_ONCE(txq->trans_start);
+
+ if (netif_xmit_stopped(txq) &&
+ time_after(jiffies, trans_start + txq->dev->watchdog_timeo))
+ return jiffies_to_msecs(jiffies - trans_start);
+
+ return 0;
+}
+
#define netif_subqueue_maybe_stop(dev, idx, get_desc, stop_thrs, start_thrs) \
({ \
struct netdev_queue *_txq; \
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next V2 2/3] net: hns3: Use netif_xmit_timeout_ms() helper
2026-01-12 9:16 [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Tariq Toukan
2026-01-12 9:16 ` [PATCH net-next V2 1/3] net: Introduce " Tariq Toukan
@ 2026-01-12 9:16 ` Tariq Toukan
2026-01-12 11:22 ` Jijie Shao
2026-01-12 9:16 ` [PATCH net-next V2 3/3] net/mlx5e: Refine TX timeout handling to skip non-timed-out SQ Tariq Toukan
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Tariq Toukan @ 2026-01-12 9:16 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Jian Shen, Salil Mehta, Jijie Shao, Saeed Mahameed, Tariq Toukan,
Mark Bloch, Leon Romanovsky, netdev, linux-kernel, linux-rdma,
Gal Pressman, Moshe Shemesh, Shahar Shitrit, Yael Chemla,
Jamal Hadi Salim
From: Shahar Shitrit <shshitrit@nvidia.com>
Replace the open-coded TX queue timeout check
in hns3_get_timeout_queue() with a call to
netif_xmit_timeout_ms() helper.
Signed-off-by: Shahar Shitrit <shshitrit@nvidia.com>
Reviewed-by: Yael Chemla <ychemla@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 7a0654e2d3dd..7b9269f6fdfc 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -25,6 +25,7 @@
#include <net/tcp.h>
#include <net/vxlan.h>
#include <net/geneve.h>
+#include <net/netdev_queues.h>
#include "hnae3.h"
#include "hns3_enet.h"
@@ -2807,14 +2808,12 @@ static int hns3_get_timeout_queue(struct net_device *ndev)
/* Find the stopped queue the same way the stack does */
for (i = 0; i < ndev->num_tx_queues; i++) {
+ unsigned int timedout_ms;
struct netdev_queue *q;
- unsigned long trans_start;
q = netdev_get_tx_queue(ndev, i);
- trans_start = READ_ONCE(q->trans_start);
- if (netif_xmit_stopped(q) &&
- time_after(jiffies,
- (trans_start + ndev->watchdog_timeo))) {
+ timedout_ms = netif_xmit_timeout_ms(q);
+ if (timedout_ms) {
#ifdef CONFIG_BQL
struct dql *dql = &q->dql;
@@ -2823,8 +2822,7 @@ static int hns3_get_timeout_queue(struct net_device *ndev)
dql->adj_limit, dql->num_completed);
#endif
netdev_info(ndev, "queue state: 0x%lx, delta msecs: %u\n",
- q->state,
- jiffies_to_msecs(jiffies - trans_start));
+ q->state, timedout_ms);
break;
}
}
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next V2 3/3] net/mlx5e: Refine TX timeout handling to skip non-timed-out SQ
2026-01-12 9:16 [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Tariq Toukan
2026-01-12 9:16 ` [PATCH net-next V2 1/3] net: Introduce " Tariq Toukan
2026-01-12 9:16 ` [PATCH net-next V2 2/3] net: hns3: Use " Tariq Toukan
@ 2026-01-12 9:16 ` Tariq Toukan
2026-01-14 9:18 ` [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Simon Horman
2026-01-15 11:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: Tariq Toukan @ 2026-01-12 9:16 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Jian Shen, Salil Mehta, Jijie Shao, Saeed Mahameed, Tariq Toukan,
Mark Bloch, Leon Romanovsky, netdev, linux-kernel, linux-rdma,
Gal Pressman, Moshe Shemesh, Shahar Shitrit, Yael Chemla,
Jamal Hadi Salim
From: Shahar Shitrit <shshitrit@nvidia.com>
mlx5e_tx_timeout_work() is invoked when the dev_watchdog reports a
timed-out TX queue. Currently, the recovery flow is triggered for all
stopped SQs, which is not always correct — some SQs may be temporarily
stopped without actually timing out. Attempting to recover such SQs
results in no EQE being polled (since no real timeout occurred), which
the driver misinterprets as a recovery failure, unnecessarily causing
channel reopening.
Improve the logic to initiate recovery only for SQs that are both
stopped and timed out. Utilize the helper introduced in the previous
patch to determine whether the netdevice watchdog timeout period has
elapsed since the SQ’s last transmit timestamp.
Signed-off-by: Shahar Shitrit <shshitrit@nvidia.com>
Reviewed-by: Yael Chemla <ychemla@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 3ac47df83ac8..7dbcf71404d8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5137,7 +5137,7 @@ static void mlx5e_tx_timeout_work(struct work_struct *work)
netdev_get_tx_queue(netdev, i);
struct mlx5e_txqsq *sq = priv->txq2sq[i];
- if (!netif_xmit_stopped(dev_queue))
+ if (!netif_xmit_timeout_ms(dev_queue))
continue;
if (mlx5e_reporter_tx_timeout(sq))
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next V2 2/3] net: hns3: Use netif_xmit_timeout_ms() helper
2026-01-12 9:16 ` [PATCH net-next V2 2/3] net: hns3: Use " Tariq Toukan
@ 2026-01-12 11:22 ` Jijie Shao
0 siblings, 0 replies; 7+ messages in thread
From: Jijie Shao @ 2026-01-12 11:22 UTC (permalink / raw)
To: Tariq Toukan, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn, David S. Miller
Cc: shaojijie, Jian Shen, Salil Mehta, Saeed Mahameed, Mark Bloch,
Leon Romanovsky, netdev, linux-kernel, linux-rdma, Gal Pressman,
Moshe Shemesh, Shahar Shitrit, Yael Chemla, Jamal Hadi Salim
on 2026/1/12 17:16, Tariq Toukan wrote:
> From: Shahar Shitrit <shshitrit@nvidia.com>
>
> Replace the open-coded TX queue timeout check
> in hns3_get_timeout_queue() with a call to
> netif_xmit_timeout_ms() helper.
>
> Signed-off-by: Shahar Shitrit <shshitrit@nvidia.com>
> Reviewed-by: Yael Chemla <ychemla@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Thanks,
Reviewed-by: Jijie Shao <shaojijie@huawei.com>
> ---
> drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index 7a0654e2d3dd..7b9269f6fdfc 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -25,6 +25,7 @@
> #include <net/tcp.h>
> #include <net/vxlan.h>
> #include <net/geneve.h>
> +#include <net/netdev_queues.h>
>
> #include "hnae3.h"
> #include "hns3_enet.h"
> @@ -2807,14 +2808,12 @@ static int hns3_get_timeout_queue(struct net_device *ndev)
>
> /* Find the stopped queue the same way the stack does */
> for (i = 0; i < ndev->num_tx_queues; i++) {
> + unsigned int timedout_ms;
> struct netdev_queue *q;
> - unsigned long trans_start;
>
> q = netdev_get_tx_queue(ndev, i);
> - trans_start = READ_ONCE(q->trans_start);
> - if (netif_xmit_stopped(q) &&
> - time_after(jiffies,
> - (trans_start + ndev->watchdog_timeo))) {
> + timedout_ms = netif_xmit_timeout_ms(q);
> + if (timedout_ms) {
> #ifdef CONFIG_BQL
> struct dql *dql = &q->dql;
>
> @@ -2823,8 +2822,7 @@ static int hns3_get_timeout_queue(struct net_device *ndev)
> dql->adj_limit, dql->num_completed);
> #endif
> netdev_info(ndev, "queue state: 0x%lx, delta msecs: %u\n",
> - q->state,
> - jiffies_to_msecs(jiffies - trans_start));
> + q->state, timedout_ms);
> break;
> }
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper
2026-01-12 9:16 [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Tariq Toukan
` (2 preceding siblings ...)
2026-01-12 9:16 ` [PATCH net-next V2 3/3] net/mlx5e: Refine TX timeout handling to skip non-timed-out SQ Tariq Toukan
@ 2026-01-14 9:18 ` Simon Horman
2026-01-15 11:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2026-01-14 9:18 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Jian Shen, Salil Mehta, Jijie Shao,
Saeed Mahameed, Mark Bloch, Leon Romanovsky, netdev, linux-kernel,
linux-rdma, Gal Pressman, Moshe Shemesh, Shahar Shitrit,
Yael Chemla, Jamal Hadi Salim
On Mon, Jan 12, 2026 at 11:16:20AM +0200, Tariq Toukan wrote:
> Hi,
>
> This is V2, find V1 here:
> https://lore.kernel.org/all/1764054776-1308696-1-git-send-email-tariqt@nvidia.com/
>
> This series by Shahar introduces a new helper function
> netif_xmit_timeout_ms() to check if a TX queue has timed out and report
> the timeout duration.
> It also encapsulates the check for whether the TX queue is stopped.
>
> Replace duplicated open-coded timeout check in hns3 driver with the new
> helper.
>
> For mlx5e, refine the TX timeout recovery flow to act only on SQs whose
> transmit timestamp indicates an actual timeout, as determined by the
> helper. This prevents unnecessary channel reopen events caused by
> attempting recovery on queues that are merely stopped but not truly
> timed out.
>
> Regards,
> Tariq
>
> V2:
> - Rebase.
> - Move helper to include/net/netdev_queues.h.
> - Remove output paramter trans_start from the new helper.
> - Revert the code in dev_watchdog to not use the helper.
> - Fix the helper name in commit message.
Thanks for the updates.
I agree the address the review of v1.
And, overall, this looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper
2026-01-12 9:16 [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Tariq Toukan
` (3 preceding siblings ...)
2026-01-14 9:18 ` [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Simon Horman
@ 2026-01-15 11:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-15 11:10 UTC (permalink / raw)
To: Tariq Toukan
Cc: edumazet, kuba, pabeni, andrew+netdev, davem, shenjian15,
salil.mehta, shaojijie, saeedm, mbloch, leon, netdev,
linux-kernel, linux-rdma, gal, moshe, shshitrit, ychemla, jhs
Hello:
This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Mon, 12 Jan 2026 11:16:20 +0200 you wrote:
> Hi,
>
> This is V2, find V1 here:
> https://lore.kernel.org/all/1764054776-1308696-1-git-send-email-tariqt@nvidia.com/
>
> This series by Shahar introduces a new helper function
> netif_xmit_timeout_ms() to check if a TX queue has timed out and report
> the timeout duration.
> It also encapsulates the check for whether the TX queue is stopped.
>
> [...]
Here is the summary with links:
- [net-next,V2,1/3] net: Introduce netif_xmit_timeout_ms() helper
https://git.kernel.org/netdev/net-next/c/cfbc8b6babf2
- [net-next,V2,2/3] net: hns3: Use netif_xmit_timeout_ms() helper
https://git.kernel.org/netdev/net-next/c/3ae02d659773
- [net-next,V2,3/3] net/mlx5e: Refine TX timeout handling to skip non-timed-out SQ
https://git.kernel.org/netdev/net-next/c/b0ba734516d2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-01-15 11:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 9:16 [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Tariq Toukan
2026-01-12 9:16 ` [PATCH net-next V2 1/3] net: Introduce " Tariq Toukan
2026-01-12 9:16 ` [PATCH net-next V2 2/3] net: hns3: Use " Tariq Toukan
2026-01-12 11:22 ` Jijie Shao
2026-01-12 9:16 ` [PATCH net-next V2 3/3] net/mlx5e: Refine TX timeout handling to skip non-timed-out SQ Tariq Toukan
2026-01-14 9:18 ` [PATCH net-next V2 0/3] Introduce and use netif_xmit_timeout_ms() helper Simon Horman
2026-01-15 11:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox