From 2bcb9bfde0fb33e46d25ea49709821b66e62650d Mon Sep 17 00:00:00 2001 From: shenjian Date: Fri, 5 Jul 2019 10:57:33 +0800 Subject: [PATCH] net: hns3: fix max ring bd number driver inclusion category: bugfix bugzilla: NA CVE: NA There is a limitation in hardware, if driver stop fetching packets from rx ring, and the max ring bd number is set to 32768. Then the FBD register value will remain 32768, which may block the hardware receive unit. This patch fixes it by reduce the max ring bd number to 32760. Signed-off-by: shenjian (K) Reviewed-by: lipeng Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 5 ++++- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 8143878b5ffa..d863b74ad2ae 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -75,7 +75,7 @@ enum hns3_nic_state { #define HNS3_TX_TIMEOUT (5 * HZ) #define HNS3_RING_NAME_LEN 16 #define HNS3_BUFFER_SIZE_2048 2048 -#define HNS3_RING_MAX_PENDING 32768 +#define HNS3_RING_MAX_PENDING 32760 #define HNS3_RING_MIN_PENDING 24 #define HNS3_RING_BD_MULTIPLE 8 /* max frame size of mac */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 3dc6b65062fe..c9c0107200c8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -908,6 +908,9 @@ static struct hns3_enet_ring *hns3_backup_ringparam(struct hns3_nic_priv *priv) static int hns3_check_ringparam(struct net_device *ndev, struct ethtool_ringparam *param) { + if (hns3_nic_resetting(ndev)) + return -EBUSY; + if (param->rx_mini_pending || param->rx_jumbo_pending) return -EINVAL; @@ -975,7 +978,7 @@ static int hns3_set_ringparam(struct net_device *ndev, memcpy(priv->ring_data[i].ring, &tmp_rings[i], sizeof(struct hns3_enet_ring)); } else { - for (i = 0; i < h->kinfo.num_tqps; i++) + for (i = 0; i < h->kinfo.num_tqps * 2; i++) hns3_fini_ring(&tmp_rings[i]); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 1bbac2d5d050..70d2d07af18e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2759,6 +2759,7 @@ static int hclge_get_sfp_info(struct hclge_dev *hdev, struct hclge_mac *mac) mac->speed_ability = le32_to_cpu(resp->speed_ability); mac->autoneg = resp->autoneg; mac->support_autoneg = resp->autoneg_ability; + mac->speed_type = QUERY_ACTIVE_SPEED; if (!resp->active_fec) mac->fec_mode = 0; else -- GitLab