Commit db018963 authored by Jacob Keller's avatar Jacob Keller Committed by Jeff Kirsher

ixgbe: clean up ixgbe_get_settings ethtool function

This patch cleans up the method used for determining the link speed of
devices. The old method re-wrote some logic already existing in a mac.ops
function which should be used instead. The result is much simpler to
understand and removes a strange double-check of logic, as well as reducing
code redundancy.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent a49fda3e
...@@ -154,100 +154,60 @@ static int ixgbe_get_settings(struct net_device *netdev, ...@@ -154,100 +154,60 @@ static int ixgbe_get_settings(struct net_device *netdev,
{ {
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;
u32 link_speed = 0; u32 link_speed = 0;
bool autoneg;
bool link_up; bool link_up;
ecmd->supported = SUPPORTED_10000baseT_Full; hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg);
ecmd->autoneg = AUTONEG_ENABLE;
ecmd->transceiver = XCVR_EXTERNAL;
if ((hw->phy.media_type == ixgbe_media_type_copper) ||
(hw->phy.multispeed_fiber)) {
ecmd->supported |= (SUPPORTED_1000baseT_Full |
SUPPORTED_Autoneg);
switch (hw->mac.type) { /* set the supported link speeds */
case ixgbe_mac_X540: if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
ecmd->supported |= SUPPORTED_10000baseT_Full;
if (supported_link & IXGBE_LINK_SPEED_1GB_FULL)
ecmd->supported |= SUPPORTED_1000baseT_Full;
if (supported_link & IXGBE_LINK_SPEED_100_FULL)
ecmd->supported |= SUPPORTED_100baseT_Full; ecmd->supported |= SUPPORTED_100baseT_Full;
break;
default:
break;
}
ecmd->advertising = ADVERTISED_Autoneg; /* set the advertised speeds */
if (hw->phy.autoneg_advertised) { if (hw->phy.autoneg_advertised) {
if (hw->phy.autoneg_advertised & if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
IXGBE_LINK_SPEED_100_FULL)
ecmd->advertising |= ADVERTISED_100baseT_Full; ecmd->advertising |= ADVERTISED_100baseT_Full;
if (hw->phy.autoneg_advertised & if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
IXGBE_LINK_SPEED_10GB_FULL)
ecmd->advertising |= ADVERTISED_10000baseT_Full; ecmd->advertising |= ADVERTISED_10000baseT_Full;
if (hw->phy.autoneg_advertised & if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
IXGBE_LINK_SPEED_1GB_FULL)
ecmd->advertising |= ADVERTISED_1000baseT_Full; ecmd->advertising |= ADVERTISED_1000baseT_Full;
} else { } else {
/* /* default modes in case phy.autoneg_advertised isn't set */
* Default advertised modes in case if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
* phy.autoneg_advertised isn't set. ecmd->advertising |= ADVERTISED_10000baseT_Full;
*/ if (supported_link & IXGBE_LINK_SPEED_1GB_FULL)
ecmd->advertising |= (ADVERTISED_10000baseT_Full | ecmd->advertising |= ADVERTISED_1000baseT_Full;
ADVERTISED_1000baseT_Full); if (supported_link & IXGBE_LINK_SPEED_100_FULL)
if (hw->mac.type == ixgbe_mac_X540)
ecmd->advertising |= ADVERTISED_100baseT_Full; ecmd->advertising |= ADVERTISED_100baseT_Full;
} }
if (hw->phy.media_type == ixgbe_media_type_copper) { if (autoneg) {
ecmd->supported |= SUPPORTED_TP; ecmd->supported |= SUPPORTED_Autoneg;
ecmd->advertising |= ADVERTISED_TP; ecmd->advertising |= ADVERTISED_Autoneg;
ecmd->port = PORT_TP; ecmd->autoneg = AUTONEG_ENABLE;
} else { } else
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_FIBRE;
}
} else if (hw->phy.media_type == ixgbe_media_type_backplane) {
/* Set as FIBRE until SERDES defined in kernel */
if (hw->device_id == IXGBE_DEV_ID_82598_BX) {
ecmd->supported = (SUPPORTED_1000baseT_Full |
SUPPORTED_FIBRE);
ecmd->advertising = (ADVERTISED_1000baseT_Full |
ADVERTISED_FIBRE);
ecmd->port = PORT_FIBRE;
ecmd->autoneg = AUTONEG_DISABLE;
} else if ((hw->device_id == IXGBE_DEV_ID_82599_COMBO_BACKPLANE) ||
(hw->device_id == IXGBE_DEV_ID_82599_KX4_MEZZ)) {
ecmd->supported |= (SUPPORTED_1000baseT_Full |
SUPPORTED_Autoneg |
SUPPORTED_FIBRE);
ecmd->advertising = (ADVERTISED_10000baseT_Full |
ADVERTISED_1000baseT_Full |
ADVERTISED_Autoneg |
ADVERTISED_FIBRE);
ecmd->port = PORT_FIBRE;
} else {
ecmd->supported |= (SUPPORTED_1000baseT_Full |
SUPPORTED_FIBRE);
ecmd->advertising = (ADVERTISED_10000baseT_Full |
ADVERTISED_1000baseT_Full |
ADVERTISED_FIBRE);
ecmd->port = PORT_FIBRE;
}
} else {
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising = (ADVERTISED_10000baseT_Full |
ADVERTISED_FIBRE);
ecmd->port = PORT_FIBRE;
ecmd->autoneg = AUTONEG_DISABLE; ecmd->autoneg = AUTONEG_DISABLE;
}
/* Get PHY type */ ecmd->transceiver = XCVR_EXTERNAL;
/* Determine the remaining settings based on the PHY type. */
switch (adapter->hw.phy.type) { switch (adapter->hw.phy.type) {
case ixgbe_phy_tn: case ixgbe_phy_tn:
case ixgbe_phy_aq: case ixgbe_phy_aq:
case ixgbe_phy_cu_unknown: case ixgbe_phy_cu_unknown:
/* Copper 10G-BASET */ ecmd->supported |= SUPPORTED_TP;
ecmd->advertising |= ADVERTISED_TP;
ecmd->port = PORT_TP; ecmd->port = PORT_TP;
break; break;
case ixgbe_phy_qt: case ixgbe_phy_qt:
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_FIBRE; ecmd->port = PORT_FIBRE;
break; break;
case ixgbe_phy_nl: case ixgbe_phy_nl:
...@@ -257,42 +217,59 @@ static int ixgbe_get_settings(struct net_device *netdev, ...@@ -257,42 +217,59 @@ static int ixgbe_get_settings(struct net_device *netdev,
case ixgbe_phy_sfp_avago: case ixgbe_phy_sfp_avago:
case ixgbe_phy_sfp_intel: case ixgbe_phy_sfp_intel:
case ixgbe_phy_sfp_unknown: case ixgbe_phy_sfp_unknown:
switch (adapter->hw.phy.sfp_type) {
/* SFP+ devices, further checking needed */ /* SFP+ devices, further checking needed */
switch (adapter->hw.phy.sfp_type) {
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;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_DA; ecmd->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:
case ixgbe_sfp_type_srlr_core0: case ixgbe_sfp_type_srlr_core0:
case ixgbe_sfp_type_srlr_core1: case ixgbe_sfp_type_srlr_core1:
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_FIBRE; ecmd->port = PORT_FIBRE;
break; break;
case ixgbe_sfp_type_not_present: case ixgbe_sfp_type_not_present:
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_NONE; ecmd->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;
ecmd->advertising |= ADVERTISED_TP;
ecmd->port = PORT_TP; ecmd->port = PORT_TP;
ecmd->supported = SUPPORTED_TP; break;
ecmd->advertising = (ADVERTISED_1000baseT_Full | case ixgbe_sfp_type_1g_sx_core0:
ADVERTISED_TP); case ixgbe_sfp_type_1g_sx_core1:
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_FIBRE;
break; break;
case ixgbe_sfp_type_unknown: case ixgbe_sfp_type_unknown:
default: default:
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_OTHER; ecmd->port = PORT_OTHER;
break; break;
} }
break; break;
case ixgbe_phy_xaui: case ixgbe_phy_xaui:
ecmd->supported |= SUPPORTED_FIBRE;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_NONE; ecmd->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;
ecmd->advertising |= ADVERTISED_FIBRE;
ecmd->port = PORT_OTHER; ecmd->port = PORT_OTHER;
break; break;
} }
......
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