From: Hao Chen chenhao418@huawei.com
driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I94FVZ CVE: NA
----------------------------------------------------------------------
The patch provides a customized interface to modify the tx timeout.
Signed-off-by: Hao Chen chenhao418@huawei.com Signed-off-by: Jiantao Xiao xiaojiantao1@h-partners.com --- drivers/net/ethernet/hisilicon/hns3/hns3_ext.c | 14 ++++++++++++++ drivers/net/ethernet/hisilicon/hns3/hns3_ext.h | 2 ++ 2 files changed, 16 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c index 60631b4a5dab..2f3cb8e90afc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c @@ -389,3 +389,17 @@ int nic_get_port_num_per_chip(struct net_device *ndev, u32 *port_num) return nic_get_port_num_of_die(ndev, port_num); } EXPORT_SYMBOL(nic_get_port_num_per_chip); + +int nic_set_tx_timeout(struct net_device *ndev, int tx_timeout) +{ + if (nic_netdev_match_check(ndev)) + return -ENODEV; + + if (tx_timeout <= 0 || tx_timeout > HNS3_MAX_TX_TIMEOUT) + return -EINVAL; + + ndev->watchdog_timeo = tx_timeout * HZ; + + return 0; +} +EXPORT_SYMBOL(nic_set_tx_timeout); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h index 46ee0d2a735d..78080a7040b1 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 600
int nic_netdev_match_check(struct net_device *netdev); void nic_chip_recover_handler(struct net_device *ndev, @@ -35,4 +36,5 @@ int nic_get_chip_num(struct net_device *ndev, u32 *chip_num); int nic_get_io_die_num(struct net_device *ndev, u32 *io_die_num); int nic_get_port_num_of_die(struct net_device *ndev, u32 *port_num); int nic_get_port_num_per_chip(struct net_device *ndev, u32 *port_num); +int nic_set_tx_timeout(struct net_device *ndev, int tx_timeout); #endif