diff options
author | Michael Chan <michael.chan@broadcom.com> | 2016-06-13 02:25:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-14 19:16:14 -0400 |
commit | 93ed8117336485af2cedb069d28f3d4270fb90a1 (patch) | |
tree | 263059504a4c96ab1140ba6e751a3b6b6c143331 /drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | |
parent | b24eb6ae7058ca1a42b0532489e5f5796c107d65 (diff) | |
download | op-kernel-dev-93ed8117336485af2cedb069d28f3d4270fb90a1.zip op-kernel-dev-93ed8117336485af2cedb069d28f3d4270fb90a1.tar.gz |
bnxt_en: Don't allow autoneg on cards that don't support it.
Some cards do not support autoneg. The current code does not prevent the
user from enabling autoneg with ethtool on such cards, causing confusion.
Firmware provides the autoneg capability information and we just need to
store it in the support_auto_speeds field in bnxt_link_info struct.
The ethtool set_settings() call will check this field before proceeding
with autoneg.
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c')
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 89050ed..3362e90 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -659,6 +659,17 @@ static u32 bnxt_fw_to_ethtool_support_spds(struct bnxt_link_info *link_info) return supported | SUPPORTED_Pause | SUPPORTED_Asym_Pause; } +static u32 bnxt_fw_to_ethtool_support_adv_spds(struct bnxt_link_info *link_info) +{ + u16 fw_speeds = link_info->support_auto_speeds; + u32 supported; + + supported = _bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0); + if (supported) + supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; + return supported; +} + u32 bnxt_fw_to_ethtool_speed(u16 fw_link_speed) { switch (fw_link_speed) { @@ -691,7 +702,7 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) cmd->supported = bnxt_fw_to_ethtool_support_spds(link_info); - if (link_info->auto_link_speeds) + if (link_info->support_auto_speeds) cmd->supported |= SUPPORTED_Autoneg; if (link_info->autoneg) { @@ -827,8 +838,14 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) return rc; if (cmd->autoneg == AUTONEG_ENABLE) { - u32 supported_spds = bnxt_fw_to_ethtool_support_spds(link_info); + u32 supported_spds = + bnxt_fw_to_ethtool_support_adv_spds(link_info); + if (!supported_spds) { + netdev_err(dev, "Autoneg not supported\n"); + rc = -EINVAL; + goto set_setting_exit; + } if (cmd->advertising & ~(supported_spds | ADVERTISED_Autoneg | ADVERTISED_TP | ADVERTISED_FIBRE)) { netdev_err(dev, "Unsupported advertising mask (adv: 0x%x)\n", @@ -837,15 +854,9 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) goto set_setting_exit; } fw_advertising = bnxt_get_fw_auto_link_speeds(cmd->advertising); - if (fw_advertising & ~link_info->support_speeds) { - netdev_err(dev, "Advertising parameters are not supported! (adv: 0x%x)\n", - cmd->advertising); - rc = -EINVAL; - goto set_setting_exit; - } link_info->autoneg |= BNXT_AUTONEG_SPEED; if (!fw_advertising) - link_info->advertising = link_info->support_speeds; + link_info->advertising = link_info->support_auto_speeds; else link_info->advertising = fw_advertising; /* any change to autoneg will cause link change, therefore the |