Commit aa5fbf07 authored by David S. Miller's avatar David S. Miller

Merge branch 'hns3-ethtool-ksettings'

Lipeng says:

====================
net: hns3: support set_link_ksettings and for nway_reset ethtool command

This patch-set adds support for set_link_ksettings && for nway_resets
ethtool command and fixes some related ethtool bugs.
1, patch[4/6] adds support for ethtool_ops.set_link_ksettings.
2, patch[5/6] adds support ethtool_ops.for nway_reset.
3, patch[1/6,2/6,3/6,6/6] fix some bugs for getting port information by
   ethtool command(ethtool ethx).
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 739c5960 439adf88
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
#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 | \
SUPPORTED_Pause | \
PHY_10BT_FEATURES | \
PHY_100BT_FEATURES | \
PHY_1000BT_FEATURES)
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
...@@ -195,6 +202,9 @@ int hclge_mac_start_phy(struct hclge_dev *hdev) ...@@ -195,6 +202,9 @@ int hclge_mac_start_phy(struct hclge_dev *hdev)
return ret; return ret;
} }
phydev->supported &= HCLGE_PHY_SUPPORTED_FEATURES;
phydev->advertising = phydev->supported;
phy_start(phydev); phy_start(phydev);
return 0; return 0;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/phy.h>
#include "hns3_enet.h" #include "hns3_enet.h"
...@@ -358,17 +359,12 @@ static void hns3_driv_to_eth_caps(u32 caps, struct ethtool_link_ksettings *cmd, ...@@ -358,17 +359,12 @@ static void hns3_driv_to_eth_caps(u32 caps, struct ethtool_link_ksettings *cmd,
if (!(caps & hns3_lm_map[i].hns3_link_mode)) if (!(caps & hns3_lm_map[i].hns3_link_mode))
continue; continue;
if (is_advertised) { if (is_advertised)
ethtool_link_ksettings_zero_link_mode(cmd,
advertising);
__set_bit(hns3_lm_map[i].ethtool_link_mode, __set_bit(hns3_lm_map[i].ethtool_link_mode,
cmd->link_modes.advertising); cmd->link_modes.advertising);
} else { else
ethtool_link_ksettings_zero_link_mode(cmd,
supported);
__set_bit(hns3_lm_map[i].ethtool_link_mode, __set_bit(hns3_lm_map[i].ethtool_link_mode,
cmd->link_modes.supported); cmd->link_modes.supported);
}
} }
} }
...@@ -571,26 +567,25 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ...@@ -571,26 +567,25 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
u32 advertised_caps; u32 advertised_caps;
u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN; u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
u8 link_stat; u8 link_stat;
u8 auto_neg;
u8 duplex;
u32 speed;
if (!h->ae_algo || !h->ae_algo->ops) if (!h->ae_algo || !h->ae_algo->ops)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* 1.auto_neg & speed & duplex from cmd */ /* 1.auto_neg & speed & duplex from cmd */
if (h->ae_algo->ops->get_ksettings_an_result) { if (netdev->phydev)
h->ae_algo->ops->get_ksettings_an_result(h, &auto_neg, phy_ethtool_ksettings_get(netdev->phydev, cmd);
&speed, &duplex); else if (h->ae_algo->ops->get_ksettings_an_result)
cmd->base.autoneg = auto_neg; h->ae_algo->ops->get_ksettings_an_result(h,
cmd->base.speed = speed; &cmd->base.autoneg,
cmd->base.duplex = duplex; &cmd->base.speed,
&cmd->base.duplex);
link_stat = hns3_get_link(netdev); else
if (!link_stat) { return -EOPNOTSUPP;
cmd->base.speed = (u32)SPEED_UNKNOWN;
cmd->base.duplex = DUPLEX_UNKNOWN; link_stat = hns3_get_link(netdev);
} if (!link_stat) {
cmd->base.speed = SPEED_UNKNOWN;
cmd->base.duplex = DUPLEX_UNKNOWN;
} }
/* 2.media_type get from bios parameter block */ /* 2.media_type get from bios parameter block */
...@@ -640,6 +635,9 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ...@@ -640,6 +635,9 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
break; break;
} }
if (!cmd->base.autoneg)
advertised_caps &= ~HNS3_LM_AUTONEG_BIT;
/* now, map driver link modes to ethtool link modes */ /* now, map driver link modes to ethtool link modes */
hns3_driv_to_eth_caps(supported_caps, cmd, false); hns3_driv_to_eth_caps(supported_caps, cmd, false);
hns3_driv_to_eth_caps(advertised_caps, cmd, true); hns3_driv_to_eth_caps(advertised_caps, cmd, true);
...@@ -655,6 +653,16 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ...@@ -655,6 +653,16 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
return 0; return 0;
} }
static int hns3_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *cmd)
{
/* Only support ksettings_set for netdev with phy attached for now */
if (netdev->phydev)
return phy_ethtool_ksettings_set(netdev->phydev, cmd);
return -EOPNOTSUPP;
}
static u32 hns3_get_rss_key_size(struct net_device *netdev) static u32 hns3_get_rss_key_size(struct net_device *netdev)
{ {
struct hnae3_handle *h = hns3_get_handle(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
...@@ -824,6 +832,23 @@ static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd) ...@@ -824,6 +832,23 @@ static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
} }
} }
static int hns3_nway_reset(struct net_device *netdev)
{
struct phy_device *phy = netdev->phydev;
if (!netif_running(netdev))
return 0;
/* Only support nway_reset for netdev with phy attached for now */
if (!phy)
return -EOPNOTSUPP;
if (phy->autoneg != AUTONEG_ENABLE)
return -EINVAL;
return genphy_restart_aneg(phy);
}
static const struct ethtool_ops hns3_ethtool_ops = { static const struct ethtool_ops hns3_ethtool_ops = {
.self_test = hns3_self_test, .self_test = hns3_self_test,
.get_drvinfo = hns3_get_drvinfo, .get_drvinfo = hns3_get_drvinfo,
...@@ -841,6 +866,8 @@ static const struct ethtool_ops hns3_ethtool_ops = { ...@@ -841,6 +866,8 @@ static const struct ethtool_ops hns3_ethtool_ops = {
.get_rxfh = hns3_get_rss, .get_rxfh = hns3_get_rss,
.set_rxfh = hns3_set_rss, .set_rxfh = hns3_set_rss,
.get_link_ksettings = hns3_get_link_ksettings, .get_link_ksettings = hns3_get_link_ksettings,
.set_link_ksettings = hns3_set_link_ksettings,
.nway_reset = hns3_nway_reset,
}; };
void hns3_ethtool_set_ops(struct net_device *netdev) void hns3_ethtool_set_ops(struct net_device *netdev)
......
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