net: hns3: add get/set pause parameters support for imp-controlled PHYs
authorGuangbin Huang <huangguangbin2@huawei.com>
Fri, 12 Mar 2021 08:50:14 +0000 (16:50 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Mar 2021 22:11:28 +0000 (14:11 -0800)
When the imp-controlled PHYs feature is enabled, phydev is NULL.
In this case, the autoneg is always off when user uses ethtool -a
command to get pause parameters because  hclge_get_pauseparam()
uses phydev to check whether device is TP port. To fit this new
feature, use media type to check whether device is TP port.

And when user set pause parameters, these parameters need to
always set to mac, no matter whether autoneg is off.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index a39afcde87b367c18c9ff45949c55c8ab0ddae64..dbca489445dfe08886e40cc2755c36183d0ef624 100644 (file)
@@ -10158,9 +10158,10 @@ static void hclge_get_pauseparam(struct hnae3_handle *handle, u32 *auto_neg,
 {
        struct hclge_vport *vport = hclge_get_vport(handle);
        struct hclge_dev *hdev = vport->back;
-       struct phy_device *phydev = hdev->hw.mac.phydev;
+       u8 media_type = hdev->hw.mac.media_type;
 
-       *auto_neg = phydev ? hclge_get_autoneg(handle) : 0;
+       *auto_neg = (media_type == HNAE3_MEDIA_TYPE_COPPER) ?
+                   hclge_get_autoneg(handle) : 0;
 
        if (hdev->tm_info.fc_mode == HCLGE_FC_PFC) {
                *rx_en = 0;
@@ -10206,7 +10207,7 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg,
        struct phy_device *phydev = hdev->hw.mac.phydev;
        u32 fc_autoneg;
 
-       if (phydev) {
+       if (phydev || hnae3_dev_phy_imp_supported(hdev)) {
                fc_autoneg = hclge_get_autoneg(handle);
                if (auto_neg != fc_autoneg) {
                        dev_info(&hdev->pdev->dev,
@@ -10225,7 +10226,7 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg,
 
        hclge_record_user_pauseparam(hdev, rx_en, tx_en);
 
-       if (!auto_neg)
+       if (!auto_neg || hnae3_dev_phy_imp_supported(hdev))
                return hclge_cfg_pauseparam(hdev, rx_en, tx_en);
 
        if (phydev)