Commit 8704f21c authored by Philippe Reynes's avatar Philippe Reynes Committed by David S. Miller

net: intel: ixgbe: 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: default avatarPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 99bdb400
...@@ -186,60 +186,62 @@ static u32 ixgbe_get_supported_10gtypes(struct ixgbe_hw *hw) ...@@ -186,60 +186,62 @@ static u32 ixgbe_get_supported_10gtypes(struct ixgbe_hw *hw)
} }
} }
static int ixgbe_get_settings(struct net_device *netdev, static int ixgbe_get_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *ecmd) struct ethtool_link_ksettings *cmd)
{ {
struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw; struct ixgbe_hw *hw = &adapter->hw;
ixgbe_link_speed supported_link; ixgbe_link_speed supported_link;
bool autoneg = false; bool autoneg = false;
u32 supported, advertising;
ethtool_convert_link_mode_to_legacy_u32(&supported,
cmd->link_modes.supported);
hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg); hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg);
/* set the supported link speeds */ /* set the supported link speeds */
if (supported_link & IXGBE_LINK_SPEED_10GB_FULL) if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
ecmd->supported |= ixgbe_get_supported_10gtypes(hw); supported |= ixgbe_get_supported_10gtypes(hw);
if (supported_link & IXGBE_LINK_SPEED_1GB_FULL) if (supported_link & IXGBE_LINK_SPEED_1GB_FULL)
ecmd->supported |= (ixgbe_isbackplane(hw->phy.media_type)) ? supported |= (ixgbe_isbackplane(hw->phy.media_type)) ?
SUPPORTED_1000baseKX_Full : SUPPORTED_1000baseKX_Full :
SUPPORTED_1000baseT_Full; SUPPORTED_1000baseT_Full;
if (supported_link & IXGBE_LINK_SPEED_100_FULL) if (supported_link & IXGBE_LINK_SPEED_100_FULL)
ecmd->supported |= SUPPORTED_100baseT_Full; supported |= SUPPORTED_100baseT_Full;
if (supported_link & IXGBE_LINK_SPEED_10_FULL) if (supported_link & IXGBE_LINK_SPEED_10_FULL)
ecmd->supported |= SUPPORTED_10baseT_Full; supported |= SUPPORTED_10baseT_Full;
/* default advertised speed if phy.autoneg_advertised isn't set */ /* default advertised speed if phy.autoneg_advertised isn't set */
ecmd->advertising = ecmd->supported; advertising = supported;
/* set the advertised speeds */ /* set the advertised speeds */
if (hw->phy.autoneg_advertised) { if (hw->phy.autoneg_advertised) {
ecmd->advertising = 0; advertising = 0;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10_FULL) if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10_FULL)
ecmd->advertising |= ADVERTISED_10baseT_Full; advertising |= ADVERTISED_10baseT_Full;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
ecmd->advertising |= ADVERTISED_100baseT_Full; advertising |= ADVERTISED_100baseT_Full;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
ecmd->advertising |= ecmd->supported & ADVRTSD_MSK_10G; advertising |= supported & ADVRTSD_MSK_10G;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) { if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) {
if (ecmd->supported & SUPPORTED_1000baseKX_Full) if (supported & SUPPORTED_1000baseKX_Full)
ecmd->advertising |= ADVERTISED_1000baseKX_Full; advertising |= ADVERTISED_1000baseKX_Full;
else else
ecmd->advertising |= ADVERTISED_1000baseT_Full; advertising |= ADVERTISED_1000baseT_Full;
} }
} else { } else {
if (hw->phy.multispeed_fiber && !autoneg) { if (hw->phy.multispeed_fiber && !autoneg) {
if (supported_link & IXGBE_LINK_SPEED_10GB_FULL) if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
ecmd->advertising = ADVERTISED_10000baseT_Full; advertising = ADVERTISED_10000baseT_Full;
} }
} }
if (autoneg) { if (autoneg) {
ecmd->supported |= SUPPORTED_Autoneg; supported |= SUPPORTED_Autoneg;
ecmd->advertising |= ADVERTISED_Autoneg; advertising |= ADVERTISED_Autoneg;
ecmd->autoneg = AUTONEG_ENABLE; cmd->base.autoneg = AUTONEG_ENABLE;
} else } else
ecmd->autoneg = AUTONEG_DISABLE; cmd->base.autoneg = AUTONEG_DISABLE;
ecmd->transceiver = XCVR_EXTERNAL;
/* Determine the remaining settings based on the PHY type. */ /* Determine the remaining settings based on the PHY type. */
switch (adapter->hw.phy.type) { switch (adapter->hw.phy.type) {
...@@ -248,14 +250,14 @@ static int ixgbe_get_settings(struct net_device *netdev, ...@@ -248,14 +250,14 @@ static int ixgbe_get_settings(struct net_device *netdev,
case ixgbe_phy_x550em_ext_t: case ixgbe_phy_x550em_ext_t:
case ixgbe_phy_fw: case ixgbe_phy_fw:
case ixgbe_phy_cu_unknown: case ixgbe_phy_cu_unknown:
ecmd->supported |= SUPPORTED_TP; supported |= SUPPORTED_TP;
ecmd->advertising |= ADVERTISED_TP; advertising |= ADVERTISED_TP;
ecmd->port = PORT_TP; cmd->base.port = PORT_TP;
break; break;
case ixgbe_phy_qt: case ixgbe_phy_qt:
ecmd->supported |= SUPPORTED_FIBRE; supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE; advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_FIBRE; cmd->base.port = PORT_FIBRE;
break; break;
case ixgbe_phy_nl: case ixgbe_phy_nl:
case ixgbe_phy_sfp_passive_tyco: case ixgbe_phy_sfp_passive_tyco:
...@@ -273,9 +275,9 @@ static int ixgbe_get_settings(struct net_device *netdev, ...@@ -273,9 +275,9 @@ static int ixgbe_get_settings(struct net_device *netdev,
case ixgbe_sfp_type_da_cu: case ixgbe_sfp_type_da_cu:
case ixgbe_sfp_type_da_cu_core0: case ixgbe_sfp_type_da_cu_core0:
case ixgbe_sfp_type_da_cu_core1: case ixgbe_sfp_type_da_cu_core1:
ecmd->supported |= SUPPORTED_FIBRE; supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE; advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_DA; cmd->base.port = PORT_DA;
break; break;
case ixgbe_sfp_type_sr: case ixgbe_sfp_type_sr:
case ixgbe_sfp_type_lr: case ixgbe_sfp_type_lr:
...@@ -285,102 +287,113 @@ static int ixgbe_get_settings(struct net_device *netdev, ...@@ -285,102 +287,113 @@ static int ixgbe_get_settings(struct net_device *netdev,
case ixgbe_sfp_type_1g_sx_core1: case ixgbe_sfp_type_1g_sx_core1:
case ixgbe_sfp_type_1g_lx_core0: case ixgbe_sfp_type_1g_lx_core0:
case ixgbe_sfp_type_1g_lx_core1: case ixgbe_sfp_type_1g_lx_core1:
ecmd->supported |= SUPPORTED_FIBRE; supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE; advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_FIBRE; cmd->base.port = PORT_FIBRE;
break; break;
case ixgbe_sfp_type_not_present: case ixgbe_sfp_type_not_present:
ecmd->supported |= SUPPORTED_FIBRE; supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE; advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_NONE; cmd->base.port = PORT_NONE;
break; break;
case ixgbe_sfp_type_1g_cu_core0: case ixgbe_sfp_type_1g_cu_core0:
case ixgbe_sfp_type_1g_cu_core1: case ixgbe_sfp_type_1g_cu_core1:
ecmd->supported |= SUPPORTED_TP; supported |= SUPPORTED_TP;
ecmd->advertising |= ADVERTISED_TP; advertising |= ADVERTISED_TP;
ecmd->port = PORT_TP; cmd->base.port = PORT_TP;
break; break;
case ixgbe_sfp_type_unknown: case ixgbe_sfp_type_unknown:
default: default:
ecmd->supported |= SUPPORTED_FIBRE; supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE; advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_OTHER; cmd->base.port = PORT_OTHER;
break; break;
} }
break; break;
case ixgbe_phy_xaui: case ixgbe_phy_xaui:
ecmd->supported |= SUPPORTED_FIBRE; supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE; advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_NONE; cmd->base.port = PORT_NONE;
break; break;
case ixgbe_phy_unknown: case ixgbe_phy_unknown:
case ixgbe_phy_generic: case ixgbe_phy_generic:
case ixgbe_phy_sfp_unsupported: case ixgbe_phy_sfp_unsupported:
default: default:
ecmd->supported |= SUPPORTED_FIBRE; supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE; advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_OTHER; cmd->base.port = PORT_OTHER;
break; break;
} }
/* Indicate pause support */ /* Indicate pause support */
ecmd->supported |= SUPPORTED_Pause; supported |= SUPPORTED_Pause;
switch (hw->fc.requested_mode) { switch (hw->fc.requested_mode) {
case ixgbe_fc_full: case ixgbe_fc_full:
ecmd->advertising |= ADVERTISED_Pause; advertising |= ADVERTISED_Pause;
break; break;
case ixgbe_fc_rx_pause: case ixgbe_fc_rx_pause:
ecmd->advertising |= ADVERTISED_Pause | advertising |= ADVERTISED_Pause |
ADVERTISED_Asym_Pause; ADVERTISED_Asym_Pause;
break; break;
case ixgbe_fc_tx_pause: case ixgbe_fc_tx_pause:
ecmd->advertising |= ADVERTISED_Asym_Pause; advertising |= ADVERTISED_Asym_Pause;
break; break;
default: default:
ecmd->advertising &= ~(ADVERTISED_Pause | advertising &= ~(ADVERTISED_Pause |
ADVERTISED_Asym_Pause); ADVERTISED_Asym_Pause);
} }
if (netif_carrier_ok(netdev)) { if (netif_carrier_ok(netdev)) {
switch (adapter->link_speed) { switch (adapter->link_speed) {
case IXGBE_LINK_SPEED_10GB_FULL: case IXGBE_LINK_SPEED_10GB_FULL:
ethtool_cmd_speed_set(ecmd, SPEED_10000); cmd->base.speed = SPEED_10000;
break; break;
case IXGBE_LINK_SPEED_5GB_FULL: case IXGBE_LINK_SPEED_5GB_FULL:
ethtool_cmd_speed_set(ecmd, SPEED_5000); cmd->base.speed = SPEED_5000;
break; break;
case IXGBE_LINK_SPEED_2_5GB_FULL: case IXGBE_LINK_SPEED_2_5GB_FULL:
ethtool_cmd_speed_set(ecmd, SPEED_2500); cmd->base.speed = SPEED_2500;
break; break;
case IXGBE_LINK_SPEED_1GB_FULL: case IXGBE_LINK_SPEED_1GB_FULL:
ethtool_cmd_speed_set(ecmd, SPEED_1000); cmd->base.speed = SPEED_1000;
break; break;
case IXGBE_LINK_SPEED_100_FULL: case IXGBE_LINK_SPEED_100_FULL:
ethtool_cmd_speed_set(ecmd, SPEED_100); cmd->base.speed = SPEED_100;
break; break;
case IXGBE_LINK_SPEED_10_FULL: case IXGBE_LINK_SPEED_10_FULL:
ethtool_cmd_speed_set(ecmd, SPEED_10); cmd->base.speed = SPEED_10;
break; break;
default: default:
break; break;
} }
ecmd->duplex = DUPLEX_FULL; cmd->base.duplex = DUPLEX_FULL;
} else { } else {
ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); cmd->base.speed = SPEED_UNKNOWN;
ecmd->duplex = DUPLEX_UNKNOWN; cmd->base.duplex = DUPLEX_UNKNOWN;
} }
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;
} }
static int ixgbe_set_settings(struct net_device *netdev, static int ixgbe_set_link_ksettings(struct net_device *netdev,
struct ethtool_cmd *ecmd) const struct ethtool_link_ksettings *cmd)
{ {
struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw; struct ixgbe_hw *hw = &adapter->hw;
u32 advertised, old; u32 advertised, old;
s32 err = 0; s32 err = 0;
u32 supported, advertising;
ethtool_convert_link_mode_to_legacy_u32(&supported,
cmd->link_modes.supported);
ethtool_convert_link_mode_to_legacy_u32(&advertising,
cmd->link_modes.advertising);
if ((hw->phy.media_type == ixgbe_media_type_copper) || if ((hw->phy.media_type == ixgbe_media_type_copper) ||
(hw->phy.multispeed_fiber)) { (hw->phy.multispeed_fiber)) {
...@@ -388,12 +401,12 @@ static int ixgbe_set_settings(struct net_device *netdev, ...@@ -388,12 +401,12 @@ static int ixgbe_set_settings(struct net_device *netdev,
* this function does not support duplex forcing, but can * this function does not support duplex forcing, but can
* limit the advertising of the adapter to the specified speed * limit the advertising of the adapter to the specified speed
*/ */
if (ecmd->advertising & ~ecmd->supported) if (advertising & ~supported)
return -EINVAL; return -EINVAL;
/* only allow one speed at a time if no autoneg */ /* only allow one speed at a time if no autoneg */
if (!ecmd->autoneg && hw->phy.multispeed_fiber) { if (!cmd->base.autoneg && hw->phy.multispeed_fiber) {
if (ecmd->advertising == if (advertising ==
(ADVERTISED_10000baseT_Full | (ADVERTISED_10000baseT_Full |
ADVERTISED_1000baseT_Full)) ADVERTISED_1000baseT_Full))
return -EINVAL; return -EINVAL;
...@@ -401,16 +414,16 @@ static int ixgbe_set_settings(struct net_device *netdev, ...@@ -401,16 +414,16 @@ static int ixgbe_set_settings(struct net_device *netdev,
old = hw->phy.autoneg_advertised; old = hw->phy.autoneg_advertised;
advertised = 0; advertised = 0;
if (ecmd->advertising & ADVERTISED_10000baseT_Full) if (advertising & ADVERTISED_10000baseT_Full)
advertised |= IXGBE_LINK_SPEED_10GB_FULL; advertised |= IXGBE_LINK_SPEED_10GB_FULL;
if (ecmd->advertising & ADVERTISED_1000baseT_Full) if (advertising & ADVERTISED_1000baseT_Full)
advertised |= IXGBE_LINK_SPEED_1GB_FULL; advertised |= IXGBE_LINK_SPEED_1GB_FULL;
if (ecmd->advertising & ADVERTISED_100baseT_Full) if (advertising & ADVERTISED_100baseT_Full)
advertised |= IXGBE_LINK_SPEED_100_FULL; advertised |= IXGBE_LINK_SPEED_100_FULL;
if (ecmd->advertising & ADVERTISED_10baseT_Full) if (advertising & ADVERTISED_10baseT_Full)
advertised |= IXGBE_LINK_SPEED_10_FULL; advertised |= IXGBE_LINK_SPEED_10_FULL;
if (old == advertised) if (old == advertised)
...@@ -428,10 +441,11 @@ static int ixgbe_set_settings(struct net_device *netdev, ...@@ -428,10 +441,11 @@ static int ixgbe_set_settings(struct net_device *netdev,
clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state);
} else { } else {
/* in this case we currently only support 10Gb/FULL */ /* in this case we currently only support 10Gb/FULL */
u32 speed = ethtool_cmd_speed(ecmd); u32 speed = cmd->base.speed;
if ((ecmd->autoneg == AUTONEG_ENABLE) ||
(ecmd->advertising != ADVERTISED_10000baseT_Full) || if ((cmd->base.autoneg == AUTONEG_ENABLE) ||
(speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)) (advertising != ADVERTISED_10000baseT_Full) ||
(speed + cmd->base.duplex != SPEED_10000 + DUPLEX_FULL))
return -EINVAL; return -EINVAL;
} }
...@@ -3402,8 +3416,6 @@ static int ixgbe_set_priv_flags(struct net_device *netdev, u32 priv_flags) ...@@ -3402,8 +3416,6 @@ static int ixgbe_set_priv_flags(struct net_device *netdev, u32 priv_flags)
} }
static const struct ethtool_ops ixgbe_ethtool_ops = { static const struct ethtool_ops ixgbe_ethtool_ops = {
.get_settings = ixgbe_get_settings,
.set_settings = ixgbe_set_settings,
.get_drvinfo = ixgbe_get_drvinfo, .get_drvinfo = ixgbe_get_drvinfo,
.get_regs_len = ixgbe_get_regs_len, .get_regs_len = ixgbe_get_regs_len,
.get_regs = ixgbe_get_regs, .get_regs = ixgbe_get_regs,
...@@ -3442,6 +3454,8 @@ static const struct ethtool_ops ixgbe_ethtool_ops = { ...@@ -3442,6 +3454,8 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {
.get_ts_info = ixgbe_get_ts_info, .get_ts_info = ixgbe_get_ts_info,
.get_module_info = ixgbe_get_module_info, .get_module_info = ixgbe_get_module_info,
.get_module_eeprom = ixgbe_get_module_eeprom, .get_module_eeprom = ixgbe_get_module_eeprom,
.get_link_ksettings = ixgbe_get_link_ksettings,
.set_link_ksettings = ixgbe_set_link_ksettings,
}; };
void ixgbe_set_ethtool_ops(struct net_device *netdev) void ixgbe_set_ethtool_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