kernel/patches/0604-net-hns3-fix-setting-wrong-tx_timeout-value-issue.patch
2023-11-17 14:19:46 +08:00

64 lines
2.1 KiB
Diff

From 7e1a34028c5ab29f6c2a8fda7008a84956d1abc0 Mon Sep 17 00:00:00 2001
From: Hao Chen <chenhao418@huawei.com>
Date: Tue, 25 Jul 2023 15:48:37 +0800
Subject: [PATCH 243/283] net: hns3: fix setting wrong tx_timeout value issue
driver inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8EN49
CVE: NA
----------------------------------------------------------------------
When user set tx_timeout, hns3 driver should set tx_timeout * HZ to
ndev->watchdog_timeo but tx_timeout.
So, change it to be correct.
Fixes: dd347d0de71ab (net: hns3: add support modified tx timeout)
Signed-off-by: Hao Chen <chenhao418@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Signed-off-by: Xiaodong Li <lixiaodong67@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_ext.c | 6 ++++--
drivers/net/ethernet/hisilicon/hns3/hns3_ext.h | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c
index 168c9c903158..45189aaea9a3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c
@@ -326,13 +326,15 @@ EXPORT_SYMBOL(nic_get_port_num_per_chip);
int nic_set_tx_timeout(struct net_device *ndev, int tx_timeout)
{
+ int watchdog_timeo = tx_timeout * HZ;
+
if (nic_netdev_match_check(ndev))
return -ENODEV;
- if (tx_timeout <= 0)
+ if (watchdog_timeo <= 0 || watchdog_timeo > HNS3_MAX_TX_TIMEOUT)
return -EINVAL;
- ndev->watchdog_timeo = tx_timeout;
+ ndev->watchdog_timeo = watchdog_timeo;
return 0;
}
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h
index d9c107f5e231..f883beae8bf4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h
@@ -13,6 +13,7 @@
#define HNS3_PFC_STORM_PARA_ENABLE 1
#define HNS3_PFC_STORM_PARA_PERIOD_MIN 5
#define HNS3_PFC_STORM_PARA_PERIOD_MAX 2000
+#define HNS3_MAX_TX_TIMEOUT (10 * 60 * HZ)
#define nic_set_8211_phy_reg nic_set_phy_reg
#define nic_get_8211_phy_reg nic_get_phy_reg
--
2.34.1