hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
....@@ -71,6 +71,8 @@
7171 static void hclge_sync_mac_table(struct hclge_dev *hdev);
7272 static void hclge_restore_hw_table(struct hclge_dev *hdev);
7373 static void hclge_sync_promisc_mode(struct hclge_dev *hdev);
74
+static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret,
75
+ int wait_cnt);
7476
7577 static struct hnae3_ae_algo ae_algo;
7678
....@@ -3123,8 +3125,13 @@
31233125 static void hclge_clear_event_cause(struct hclge_dev *hdev, u32 event_type,
31243126 u32 regclr)
31253127 {
3128
+#define HCLGE_IMP_RESET_DELAY 5
3129
+
31263130 switch (event_type) {
31273131 case HCLGE_VECTOR0_EVENT_RST:
3132
+ if (regclr == BIT(HCLGE_VECTOR0_IMPRESET_INT_B))
3133
+ mdelay(HCLGE_IMP_RESET_DELAY);
3134
+
31283135 hclge_write_dev(&hdev->hw, HCLGE_MISC_RESET_STS_REG, regclr);
31293136 break;
31303137 case HCLGE_VECTOR0_EVENT_MBX:
....@@ -6558,6 +6565,8 @@
65586565
65596566 static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable)
65606567 {
6568
+#define HCLGE_LINK_STATUS_WAIT_CNT 3
6569
+
65616570 struct hclge_desc desc;
65626571 struct hclge_config_mac_mode_cmd *req =
65636572 (struct hclge_config_mac_mode_cmd *)desc.data;
....@@ -6582,9 +6591,15 @@
65826591 req->txrx_pad_fcs_loop_en = cpu_to_le32(loop_en);
65836592
65846593 ret = hclge_cmd_send(&hdev->hw, &desc, 1);
6585
- if (ret)
6594
+ if (ret) {
65866595 dev_err(&hdev->pdev->dev,
65876596 "mac enable fail, ret =%d.\n", ret);
6597
+ return;
6598
+ }
6599
+
6600
+ if (!enable)
6601
+ hclge_mac_link_status_wait(hdev, HCLGE_LINK_STATUS_DOWN,
6602
+ HCLGE_LINK_STATUS_WAIT_CNT);
65886603 }
65896604
65906605 static int hclge_config_switch_param(struct hclge_dev *hdev, int vfid,
....@@ -6647,10 +6662,9 @@
66476662 } while (++i < HCLGE_PHY_LINK_STATUS_NUM);
66486663 }
66496664
6650
-static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
6665
+static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret,
6666
+ int wait_cnt)
66516667 {
6652
-#define HCLGE_MAC_LINK_STATUS_NUM 100
6653
-
66546668 int link_status;
66556669 int i = 0;
66566670 int ret;
....@@ -6663,13 +6677,15 @@
66636677 return 0;
66646678
66656679 msleep(HCLGE_LINK_STATUS_MS);
6666
- } while (++i < HCLGE_MAC_LINK_STATUS_NUM);
6680
+ } while (++i < wait_cnt);
66676681 return -EBUSY;
66686682 }
66696683
66706684 static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en,
66716685 bool is_phy)
66726686 {
6687
+#define HCLGE_MAC_LINK_STATUS_NUM 100
6688
+
66736689 int link_ret;
66746690
66756691 link_ret = en ? HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN;
....@@ -6677,7 +6693,8 @@
66776693 if (is_phy)
66786694 hclge_phy_link_status_wait(hdev, link_ret);
66796695
6680
- return hclge_mac_link_status_wait(hdev, link_ret);
6696
+ return hclge_mac_link_status_wait(hdev, link_ret,
6697
+ HCLGE_MAC_LINK_STATUS_NUM);
66816698 }
66826699
66836700 static int hclge_set_app_loopback(struct hclge_dev *hdev, bool en)
....@@ -7023,12 +7040,15 @@
70237040 /* If it is not PF reset or FLR, the firmware will disable the MAC,
70247041 * so it only need to stop phy here.
70257042 */
7026
- if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) &&
7027
- hdev->reset_type != HNAE3_FUNC_RESET &&
7028
- hdev->reset_type != HNAE3_FLR_RESET) {
7029
- hclge_mac_stop_phy(hdev);
7030
- hclge_update_link_status(hdev);
7031
- return;
7043
+ if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) {
7044
+ hclge_pfc_pause_en_cfg(hdev, HCLGE_PFC_TX_RX_DISABLE,
7045
+ HCLGE_PFC_DISABLE);
7046
+ if (hdev->reset_type != HNAE3_FUNC_RESET &&
7047
+ hdev->reset_type != HNAE3_FLR_RESET) {
7048
+ hclge_mac_stop_phy(hdev);
7049
+ hclge_update_link_status(hdev);
7050
+ return;
7051
+ }
70327052 }
70337053
70347054 for (i = 0; i < handle->kinfo.num_tqps; i++)
....@@ -7835,7 +7855,7 @@
78357855 if (mac_type == HCLGE_MAC_ADDR_UC) {
78367856 if (is_all_added)
78377857 vport->overflow_promisc_flags &= ~HNAE3_OVERFLOW_UPE;
7838
- else
7858
+ else if (hclge_is_umv_space_full(vport, true))
78397859 vport->overflow_promisc_flags |= HNAE3_OVERFLOW_UPE;
78407860 } else {
78417861 if (is_all_added)