@@ -2673,11 +2673,10 @@ void hclge_task_schedule(struct hclge_dev *hdev, unsigned long delay_time)
2673
2673
delay_time );
2674
2674
}
2675
2675
2676
- static int hclge_get_mac_link_status (struct hclge_dev * hdev )
2676
+ static int hclge_get_mac_link_status (struct hclge_dev * hdev , int * link_status )
2677
2677
{
2678
2678
struct hclge_link_status_cmd * req ;
2679
2679
struct hclge_desc desc ;
2680
- int link_status ;
2681
2680
int ret ;
2682
2681
2683
2682
hclge_cmd_setup_basic_desc (& desc , HCLGE_OPC_QUERY_LINK_STATUS , true);
@@ -2689,33 +2688,25 @@ static int hclge_get_mac_link_status(struct hclge_dev *hdev)
2689
2688
}
2690
2689
2691
2690
req = (struct hclge_link_status_cmd * )desc .data ;
2692
- link_status = req -> status & HCLGE_LINK_STATUS_UP_M ;
2691
+ * link_status = (req -> status & HCLGE_LINK_STATUS_UP_M ) > 0 ?
2692
+ HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN ;
2693
2693
2694
- return !! link_status ;
2694
+ return 0 ;
2695
2695
}
2696
2696
2697
- static int hclge_get_mac_phy_link (struct hclge_dev * hdev )
2697
+ static int hclge_get_mac_phy_link (struct hclge_dev * hdev , int * link_status )
2698
2698
{
2699
- unsigned int mac_state ;
2700
- int link_stat ;
2699
+ struct phy_device * phydev = hdev -> hw .mac .phydev ;
2700
+
2701
+ * link_status = HCLGE_LINK_STATUS_DOWN ;
2701
2702
2702
2703
if (test_bit (HCLGE_STATE_DOWN , & hdev -> state ))
2703
2704
return 0 ;
2704
2705
2705
- mac_state = hclge_get_mac_link_status (hdev );
2706
-
2707
- if (hdev -> hw .mac .phydev ) {
2708
- if (hdev -> hw .mac .phydev -> state == PHY_RUNNING )
2709
- link_stat = mac_state &
2710
- hdev -> hw .mac .phydev -> link ;
2711
- else
2712
- link_stat = 0 ;
2713
-
2714
- } else {
2715
- link_stat = mac_state ;
2716
- }
2706
+ if (phydev && (phydev -> state != PHY_RUNNING || !phydev -> link ))
2707
+ return 0 ;
2717
2708
2718
- return !! link_stat ;
2709
+ return hclge_get_mac_link_status ( hdev , link_status ) ;
2719
2710
}
2720
2711
2721
2712
static void hclge_update_link_status (struct hclge_dev * hdev )
@@ -2725,6 +2716,7 @@ static void hclge_update_link_status(struct hclge_dev *hdev)
2725
2716
struct hnae3_handle * rhandle ;
2726
2717
struct hnae3_handle * handle ;
2727
2718
int state ;
2719
+ int ret ;
2728
2720
int i ;
2729
2721
2730
2722
if (!client )
@@ -2733,7 +2725,12 @@ static void hclge_update_link_status(struct hclge_dev *hdev)
2733
2725
if (test_and_set_bit (HCLGE_STATE_LINK_UPDATING , & hdev -> state ))
2734
2726
return ;
2735
2727
2736
- state = hclge_get_mac_phy_link (hdev );
2728
+ ret = hclge_get_mac_phy_link (hdev , & state );
2729
+ if (ret ) {
2730
+ clear_bit (HCLGE_STATE_LINK_UPDATING , & hdev -> state );
2731
+ return ;
2732
+ }
2733
+
2737
2734
if (state != hdev -> hw .mac .link ) {
2738
2735
for (i = 0 ; i < hdev -> num_vmdq_vport + 1 ; i ++ ) {
2739
2736
handle = & hdev -> vport [i ].nic ;
@@ -6524,14 +6521,15 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
6524
6521
{
6525
6522
#define HCLGE_MAC_LINK_STATUS_NUM 100
6526
6523
6524
+ int link_status ;
6527
6525
int i = 0 ;
6528
6526
int ret ;
6529
6527
6530
6528
do {
6531
- ret = hclge_get_mac_link_status (hdev );
6532
- if (ret < 0 )
6529
+ ret = hclge_get_mac_link_status (hdev , & link_status );
6530
+ if (ret )
6533
6531
return ret ;
6534
- else if (ret == link_ret )
6532
+ if (link_status == link_ret )
6535
6533
return 0 ;
6536
6534
6537
6535
msleep (HCLGE_LINK_STATUS_MS );
@@ -6542,9 +6540,6 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
6542
6540
static int hclge_mac_phy_link_status_wait (struct hclge_dev * hdev , bool en ,
6543
6541
bool is_phy )
6544
6542
{
6545
- #define HCLGE_LINK_STATUS_DOWN 0
6546
- #define HCLGE_LINK_STATUS_UP 1
6547
-
6548
6543
int link_ret ;
6549
6544
6550
6545
link_ret = en ? HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN ;
0 commit comments