Commit f18635d5 authored by Jian Shen's avatar Jian Shen Committed by David S. Miller

net: hns3: fix port info query issue for copper port

In original codes, for copper port which doesn't connect to phy,
it always returns -EOPNOTSUPP when query port information. This
patch fixes it by return the port information of MAC.

Fixes: 5f373b15 ("net: hns3: Fix speed/duplex information loss problem when executing ethtool ethx cmd of VF")
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent db68ca0e
...@@ -621,12 +621,11 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ...@@ -621,12 +621,11 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
hns3_get_ksettings(h, cmd); hns3_get_ksettings(h, cmd);
break; break;
case HNAE3_MEDIA_TYPE_COPPER: case HNAE3_MEDIA_TYPE_COPPER:
if (!netdev->phydev)
return -EOPNOTSUPP;
cmd->base.port = PORT_TP; cmd->base.port = PORT_TP;
phy_ethtool_ksettings_get(netdev->phydev, cmd); if (!netdev->phydev)
hns3_get_ksettings(h, cmd);
else
phy_ethtool_ksettings_get(netdev->phydev, cmd);
break; break;
default: default:
......
...@@ -862,14 +862,44 @@ static void hclge_parse_fiber_link_mode(struct hclge_dev *hdev, ...@@ -862,14 +862,44 @@ static void hclge_parse_fiber_link_mode(struct hclge_dev *hdev,
linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, supported); linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, supported);
} }
static void hclge_parse_copper_link_mode(struct hclge_dev *hdev,
u8 speed_ability)
{
unsigned long *supported = hdev->hw.mac.supported;
/* default to support all speed for GE port */
if (!speed_ability)
speed_ability = HCLGE_SUPPORT_GE;
if (speed_ability & HCLGE_SUPPORT_1G_BIT)
linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
supported);
if (speed_ability & HCLGE_SUPPORT_100M_BIT) {
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
supported);
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT,
supported);
}
if (speed_ability & HCLGE_SUPPORT_10M_BIT) {
linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, supported);
linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, supported);
}
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, supported);
linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, supported);
linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, supported);
}
static void hclge_parse_link_mode(struct hclge_dev *hdev, u8 speed_ability) static void hclge_parse_link_mode(struct hclge_dev *hdev, u8 speed_ability)
{ {
u8 media_type = hdev->hw.mac.media_type; u8 media_type = hdev->hw.mac.media_type;
if (media_type != HNAE3_MEDIA_TYPE_FIBER) if (media_type == HNAE3_MEDIA_TYPE_FIBER)
return; hclge_parse_fiber_link_mode(hdev, speed_ability);
else if (media_type == HNAE3_MEDIA_TYPE_COPPER)
hclge_parse_fiber_link_mode(hdev, speed_ability); hclge_parse_copper_link_mode(hdev, speed_ability);
} }
static void hclge_parse_cfg(struct hclge_cfg *cfg, struct hclge_desc *desc) static void hclge_parse_cfg(struct hclge_cfg *cfg, struct hclge_desc *desc)
......
...@@ -188,6 +188,10 @@ enum HLCGE_PORT_TYPE { ...@@ -188,6 +188,10 @@ enum HLCGE_PORT_TYPE {
#define HCLGE_SUPPORT_25G_BIT BIT(2) #define HCLGE_SUPPORT_25G_BIT BIT(2)
#define HCLGE_SUPPORT_50G_BIT BIT(3) #define HCLGE_SUPPORT_50G_BIT BIT(3)
#define HCLGE_SUPPORT_100G_BIT BIT(4) #define HCLGE_SUPPORT_100G_BIT BIT(4)
#define HCLGE_SUPPORT_100M_BIT BIT(6)
#define HCLGE_SUPPORT_10M_BIT BIT(7)
#define HCLGE_SUPPORT_GE \
(HCLGE_SUPPORT_1G_BIT | HCLGE_SUPPORT_100M_BIT | HCLGE_SUPPORT_10M_BIT)
enum HCLGE_DEV_STATE { enum HCLGE_DEV_STATE {
HCLGE_STATE_REINITING, HCLGE_STATE_REINITING,
......
...@@ -8,12 +8,6 @@ ...@@ -8,12 +8,6 @@
#include "hclge_main.h" #include "hclge_main.h"
#include "hclge_mdio.h" #include "hclge_mdio.h"
#define HCLGE_PHY_SUPPORTED_FEATURES (SUPPORTED_Autoneg | \
SUPPORTED_TP | \
PHY_10BT_FEATURES | \
PHY_100BT_FEATURES | \
SUPPORTED_1000baseT_Full)
enum hclge_mdio_c22_op_seq { enum hclge_mdio_c22_op_seq {
HCLGE_MDIO_C22_WRITE = 1, HCLGE_MDIO_C22_WRITE = 1,
HCLGE_MDIO_C22_READ = 2 HCLGE_MDIO_C22_READ = 2
...@@ -217,16 +211,9 @@ int hclge_mac_connect_phy(struct hnae3_handle *handle) ...@@ -217,16 +211,9 @@ int hclge_mac_connect_phy(struct hnae3_handle *handle)
return ret; return ret;
} }
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, mask); linkmode_copy(mask, hdev->hw.mac.supported);
linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, mask);
linkmode_set_bit_array(phy_10_100_features_array,
ARRAY_SIZE(phy_10_100_features_array),
mask);
linkmode_set_bit_array(phy_gbit_features_array,
ARRAY_SIZE(phy_gbit_features_array),
mask);
linkmode_and(phydev->supported, phydev->supported, mask); linkmode_and(phydev->supported, phydev->supported, mask);
phy_support_asym_pause(phydev); linkmode_copy(phydev->advertising, phydev->supported);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment