[PATCH net-next V2 2/3] net: hns3: Use netif_xmit_timeout_ms() helper

Tariq Toukan posted 3 patches 3 weeks, 6 days ago
[PATCH net-next V2 2/3] net: hns3: Use netif_xmit_timeout_ms() helper
Posted by Tariq Toukan 3 weeks, 6 days ago
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
Re: [PATCH net-next V2 2/3] net: hns3: Use netif_xmit_timeout_ms() helper
Posted by Jijie Shao 3 weeks, 6 days ago
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;
>   		}
>   	}