Skip to content

Commit 93ed811

Browse files
Michael Chandavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b24eb6a commit 93ed811

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4823,6 +4823,7 @@ static int bnxt_hwrm_phy_qcaps(struct bnxt *bp)
48234823
int rc = 0;
48244824
struct hwrm_port_phy_qcaps_input req = {0};
48254825
struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
4826+
struct bnxt_link_info *link_info = &bp->link_info;
48264827

48274828
if (bp->hwrm_spec_code < 0x10201)
48284829
return 0;
@@ -4845,6 +4846,8 @@ static int bnxt_hwrm_phy_qcaps(struct bnxt *bp)
48454846
bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) &
48464847
PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_MASK;
48474848
}
4849+
link_info->support_auto_speeds =
4850+
le16_to_cpu(resp->supported_speeds_auto_mode);
48484851

48494852
hwrm_phy_qcaps_exit:
48504853
mutex_unlock(&bp->hwrm_cmd_lock);
@@ -6368,6 +6371,12 @@ static int bnxt_probe_phy(struct bnxt *bp)
63686371
return rc;
63696372
}
63706373

6374+
/* Older firmware does not have supported_auto_speeds, so assume
6375+
* that all supported speeds can be autonegotiated.
6376+
*/
6377+
if (link_info->auto_link_speeds && !link_info->support_auto_speeds)
6378+
link_info->support_auto_speeds = link_info->support_speeds;
6379+
63716380
/*initialize the ethool setting copy with NVM settings */
63726381
if (BNXT_AUTO_MODE(link_info->auto_mode)) {
63736382
link_info->autoneg = BNXT_AUTONEG_SPEED;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ struct bnxt_link_info {
849849
#define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB
850850
#define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB
851851
#define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB
852+
u16 support_auto_speeds;
852853
u16 lp_auto_link_speeds;
853854
u16 force_link_speed;
854855
u32 preemphasis;

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,17 @@ static u32 bnxt_fw_to_ethtool_support_spds(struct bnxt_link_info *link_info)
659659
return supported | SUPPORTED_Pause | SUPPORTED_Asym_Pause;
660660
}
661661

662+
static u32 bnxt_fw_to_ethtool_support_adv_spds(struct bnxt_link_info *link_info)
663+
{
664+
u16 fw_speeds = link_info->support_auto_speeds;
665+
u32 supported;
666+
667+
supported = _bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0);
668+
if (supported)
669+
supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
670+
return supported;
671+
}
672+
662673
u32 bnxt_fw_to_ethtool_speed(u16 fw_link_speed)
663674
{
664675
switch (fw_link_speed) {
@@ -691,7 +702,7 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
691702

692703
cmd->supported = bnxt_fw_to_ethtool_support_spds(link_info);
693704

694-
if (link_info->auto_link_speeds)
705+
if (link_info->support_auto_speeds)
695706
cmd->supported |= SUPPORTED_Autoneg;
696707

697708
if (link_info->autoneg) {
@@ -827,8 +838,14 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
827838
return rc;
828839

829840
if (cmd->autoneg == AUTONEG_ENABLE) {
830-
u32 supported_spds = bnxt_fw_to_ethtool_support_spds(link_info);
841+
u32 supported_spds =
842+
bnxt_fw_to_ethtool_support_adv_spds(link_info);
831843

844+
if (!supported_spds) {
845+
netdev_err(dev, "Autoneg not supported\n");
846+
rc = -EINVAL;
847+
goto set_setting_exit;
848+
}
832849
if (cmd->advertising & ~(supported_spds | ADVERTISED_Autoneg |
833850
ADVERTISED_TP | ADVERTISED_FIBRE)) {
834851
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)
837854
goto set_setting_exit;
838855
}
839856
fw_advertising = bnxt_get_fw_auto_link_speeds(cmd->advertising);
840-
if (fw_advertising & ~link_info->support_speeds) {
841-
netdev_err(dev, "Advertising parameters are not supported! (adv: 0x%x)\n",
842-
cmd->advertising);
843-
rc = -EINVAL;
844-
goto set_setting_exit;
845-
}
846857
link_info->autoneg |= BNXT_AUTONEG_SPEED;
847858
if (!fw_advertising)
848-
link_info->advertising = link_info->support_speeds;
859+
link_info->advertising = link_info->support_auto_speeds;
849860
else
850861
link_info->advertising = fw_advertising;
851862
/* any change to autoneg will cause link change, therefore the

0 commit comments

Comments
 (0)