提交 fb052fdd 编写于 作者: P Philippe Reynes 提交者: Jeff Kirsher

e1000e: use new API ethtool_{get|set}_link_ksettings

The ethtool API {get|set}_settings is deprecated.
We move this driver to new API {get|set}_link_ksettings.

As I don't have the hardware, I'd be very pleased if
someone may test this patch.
Signed-off-by: NPhilippe Reynes <tremyfr@gmail.com>
Tested-by: NAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 5add2f9a
...@@ -117,55 +117,52 @@ static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = { ...@@ -117,55 +117,52 @@ static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
#define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test) #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test)
static int e1000_get_settings(struct net_device *netdev, static int e1000_get_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *ecmd) struct ethtool_link_ksettings *cmd)
{ {
struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
u32 speed; u32 speed, supported, advertising;
if (hw->phy.media_type == e1000_media_type_copper) { if (hw->phy.media_type == e1000_media_type_copper) {
ecmd->supported = (SUPPORTED_10baseT_Half | supported = (SUPPORTED_10baseT_Half |
SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Full |
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Half |
SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Full |
SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Full |
SUPPORTED_Autoneg | SUPPORTED_Autoneg |
SUPPORTED_TP); SUPPORTED_TP);
if (hw->phy.type == e1000_phy_ife) if (hw->phy.type == e1000_phy_ife)
ecmd->supported &= ~SUPPORTED_1000baseT_Full; supported &= ~SUPPORTED_1000baseT_Full;
ecmd->advertising = ADVERTISED_TP; advertising = ADVERTISED_TP;
if (hw->mac.autoneg == 1) { if (hw->mac.autoneg == 1) {
ecmd->advertising |= ADVERTISED_Autoneg; advertising |= ADVERTISED_Autoneg;
/* the e1000 autoneg seems to match ethtool nicely */ /* the e1000 autoneg seems to match ethtool nicely */
ecmd->advertising |= hw->phy.autoneg_advertised; advertising |= hw->phy.autoneg_advertised;
} }
ecmd->port = PORT_TP; cmd->base.port = PORT_TP;
ecmd->phy_address = hw->phy.addr; cmd->base.phy_address = hw->phy.addr;
ecmd->transceiver = XCVR_INTERNAL;
} else { } else {
ecmd->supported = (SUPPORTED_1000baseT_Full | supported = (SUPPORTED_1000baseT_Full |
SUPPORTED_FIBRE | SUPPORTED_FIBRE |
SUPPORTED_Autoneg); SUPPORTED_Autoneg);
ecmd->advertising = (ADVERTISED_1000baseT_Full | advertising = (ADVERTISED_1000baseT_Full |
ADVERTISED_FIBRE | ADVERTISED_FIBRE |
ADVERTISED_Autoneg); ADVERTISED_Autoneg);
ecmd->port = PORT_FIBRE; cmd->base.port = PORT_FIBRE;
ecmd->transceiver = XCVR_EXTERNAL;
} }
speed = SPEED_UNKNOWN; speed = SPEED_UNKNOWN;
ecmd->duplex = DUPLEX_UNKNOWN; cmd->base.duplex = DUPLEX_UNKNOWN;
if (netif_running(netdev)) { if (netif_running(netdev)) {
if (netif_carrier_ok(netdev)) { if (netif_carrier_ok(netdev)) {
speed = adapter->link_speed; speed = adapter->link_speed;
ecmd->duplex = adapter->link_duplex - 1; cmd->base.duplex = adapter->link_duplex - 1;
} }
} else if (!pm_runtime_suspended(netdev->dev.parent)) { } else if (!pm_runtime_suspended(netdev->dev.parent)) {
u32 status = er32(STATUS); u32 status = er32(STATUS);
...@@ -179,30 +176,36 @@ static int e1000_get_settings(struct net_device *netdev, ...@@ -179,30 +176,36 @@ static int e1000_get_settings(struct net_device *netdev,
speed = SPEED_10; speed = SPEED_10;
if (status & E1000_STATUS_FD) if (status & E1000_STATUS_FD)
ecmd->duplex = DUPLEX_FULL; cmd->base.duplex = DUPLEX_FULL;
else else
ecmd->duplex = DUPLEX_HALF; cmd->base.duplex = DUPLEX_HALF;
} }
} }
ethtool_cmd_speed_set(ecmd, speed); cmd->base.speed = speed;
ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) || cmd->base.autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE; hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
/* MDI-X => 2; MDI =>1; Invalid =>0 */ /* MDI-X => 2; MDI =>1; Invalid =>0 */
if ((hw->phy.media_type == e1000_media_type_copper) && if ((hw->phy.media_type == e1000_media_type_copper) &&
netif_carrier_ok(netdev)) netif_carrier_ok(netdev))
ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X : ETH_TP_MDI; cmd->base.eth_tp_mdix = hw->phy.is_mdix ?
ETH_TP_MDI_X : ETH_TP_MDI;
else else
ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID; cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID;
if (hw->phy.mdix == AUTO_ALL_MODES) if (hw->phy.mdix == AUTO_ALL_MODES)
ecmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO; cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO;
else else
ecmd->eth_tp_mdix_ctrl = hw->phy.mdix; cmd->base.eth_tp_mdix_ctrl = hw->phy.mdix;
if (hw->phy.media_type != e1000_media_type_copper) if (hw->phy.media_type != e1000_media_type_copper)
ecmd->eth_tp_mdix_ctrl = ETH_TP_MDI_INVALID; cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_INVALID;
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
advertising);
return 0; return 0;
} }
...@@ -262,12 +265,16 @@ static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx) ...@@ -262,12 +265,16 @@ static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
return -EINVAL; return -EINVAL;
} }
static int e1000_set_settings(struct net_device *netdev, static int e1000_set_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *ecmd) const struct ethtool_link_ksettings *cmd)
{ {
struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
int ret_val = 0; int ret_val = 0;
u32 advertising;
ethtool_convert_link_mode_to_legacy_u32(&advertising,
cmd->link_modes.advertising);
pm_runtime_get_sync(netdev->dev.parent); pm_runtime_get_sync(netdev->dev.parent);
...@@ -285,14 +292,14 @@ static int e1000_set_settings(struct net_device *netdev, ...@@ -285,14 +292,14 @@ static int e1000_set_settings(struct net_device *netdev,
* some hardware doesn't allow MDI setting when speed or * some hardware doesn't allow MDI setting when speed or
* duplex is forced. * duplex is forced.
*/ */
if (ecmd->eth_tp_mdix_ctrl) { if (cmd->base.eth_tp_mdix_ctrl) {
if (hw->phy.media_type != e1000_media_type_copper) { if (hw->phy.media_type != e1000_media_type_copper) {
ret_val = -EOPNOTSUPP; ret_val = -EOPNOTSUPP;
goto out; goto out;
} }
if ((ecmd->eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) && if ((cmd->base.eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) &&
(ecmd->autoneg != AUTONEG_ENABLE)) { (cmd->base.autoneg != AUTONEG_ENABLE)) {
e_err("forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n"); e_err("forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n");
ret_val = -EINVAL; ret_val = -EINVAL;
goto out; goto out;
...@@ -302,35 +309,35 @@ static int e1000_set_settings(struct net_device *netdev, ...@@ -302,35 +309,35 @@ static int e1000_set_settings(struct net_device *netdev,
while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
usleep_range(1000, 2000); usleep_range(1000, 2000);
if (ecmd->autoneg == AUTONEG_ENABLE) { if (cmd->base.autoneg == AUTONEG_ENABLE) {
hw->mac.autoneg = 1; hw->mac.autoneg = 1;
if (hw->phy.media_type == e1000_media_type_fiber) if (hw->phy.media_type == e1000_media_type_fiber)
hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full | hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full |
ADVERTISED_FIBRE | ADVERTISED_Autoneg; ADVERTISED_FIBRE | ADVERTISED_Autoneg;
else else
hw->phy.autoneg_advertised = ecmd->advertising | hw->phy.autoneg_advertised = advertising |
ADVERTISED_TP | ADVERTISED_Autoneg; ADVERTISED_TP | ADVERTISED_Autoneg;
ecmd->advertising = hw->phy.autoneg_advertised; advertising = hw->phy.autoneg_advertised;
if (adapter->fc_autoneg) if (adapter->fc_autoneg)
hw->fc.requested_mode = e1000_fc_default; hw->fc.requested_mode = e1000_fc_default;
} else { } else {
u32 speed = ethtool_cmd_speed(ecmd); u32 speed = cmd->base.speed;
/* calling this overrides forced MDI setting */ /* calling this overrides forced MDI setting */
if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) { if (e1000_set_spd_dplx(adapter, speed, cmd->base.duplex)) {
ret_val = -EINVAL; ret_val = -EINVAL;
goto out; goto out;
} }
} }
/* MDI-X => 2; MDI => 1; Auto => 3 */ /* MDI-X => 2; MDI => 1; Auto => 3 */
if (ecmd->eth_tp_mdix_ctrl) { if (cmd->base.eth_tp_mdix_ctrl) {
/* fix up the value for auto (3 => 0) as zero is mapped /* fix up the value for auto (3 => 0) as zero is mapped
* internally to auto * internally to auto
*/ */
if (ecmd->eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO) if (cmd->base.eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO)
hw->phy.mdix = AUTO_ALL_MODES; hw->phy.mdix = AUTO_ALL_MODES;
else else
hw->phy.mdix = ecmd->eth_tp_mdix_ctrl; hw->phy.mdix = cmd->base.eth_tp_mdix_ctrl;
} }
/* reset the link */ /* reset the link */
...@@ -2313,8 +2320,6 @@ static int e1000e_get_ts_info(struct net_device *netdev, ...@@ -2313,8 +2320,6 @@ static int e1000e_get_ts_info(struct net_device *netdev,
} }
static const struct ethtool_ops e1000_ethtool_ops = { static const struct ethtool_ops e1000_ethtool_ops = {
.get_settings = e1000_get_settings,
.set_settings = e1000_set_settings,
.get_drvinfo = e1000_get_drvinfo, .get_drvinfo = e1000_get_drvinfo,
.get_regs_len = e1000_get_regs_len, .get_regs_len = e1000_get_regs_len,
.get_regs = e1000_get_regs, .get_regs = e1000_get_regs,
...@@ -2342,6 +2347,8 @@ static const struct ethtool_ops e1000_ethtool_ops = { ...@@ -2342,6 +2347,8 @@ static const struct ethtool_ops e1000_ethtool_ops = {
.get_ts_info = e1000e_get_ts_info, .get_ts_info = e1000e_get_ts_info,
.get_eee = e1000e_get_eee, .get_eee = e1000e_get_eee,
.set_eee = e1000e_set_eee, .set_eee = e1000e_set_eee,
.get_link_ksettings = e1000_get_link_ksettings,
.set_link_ksettings = e1000_set_link_ksettings,
}; };
void e1000e_set_ethtool_ops(struct net_device *netdev) void e1000e_set_ethtool_ops(struct net_device *netdev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册