bnxt_en: refactor bnxt_get_fw_speed()
It will be necessary to update more than one field in the link_info structure when PAM4 speeds are added in a later patch. Instead of merely translating ethtool speed values to firmware speed values, change the responsiblity of this function to update all the necessary link_info fields required to force the speed change to the desired ethtool value. This also reduces code duplication somewhat at the two call sites, which otherwise both have to independently update link_info fields to turn off auto negotiation advertisements. Also use the appropriate REQ_FORCE_LINK_SPEED definitions. These happen to have the same values, but req_link_speed is utilimately passed as force_link_speed in HWRM_PORT_PHY_CFG which is not defined in terms of REQ_AUTO_LINK_SPEED. Reviewed-by: Scott Branden <scott.branden@broadcom.com> Signed-off-by: Edwin Peer <edwin.peer@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c916062a89
commit
f00530bf3c
|
@ -1636,55 +1636,63 @@ static int bnxt_get_link_ksettings(struct net_device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static u32 bnxt_get_fw_speed(struct net_device *dev, u32 ethtool_speed)
|
||||
static int bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed)
|
||||
{
|
||||
struct bnxt *bp = netdev_priv(dev);
|
||||
struct bnxt_link_info *link_info = &bp->link_info;
|
||||
u16 support_spds = link_info->support_speeds;
|
||||
u32 fw_speed = 0;
|
||||
u16 fw_speed = 0;
|
||||
|
||||
switch (ethtool_speed) {
|
||||
case SPEED_100:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_100MB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_100MB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100MB;
|
||||
break;
|
||||
case SPEED_1000:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_1GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_1GB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB;
|
||||
break;
|
||||
case SPEED_2500:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_2_5GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_2_5GB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_2_5GB;
|
||||
break;
|
||||
case SPEED_10000:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_10GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_10GB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB;
|
||||
break;
|
||||
case SPEED_20000:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_20GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_20GB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_20GB;
|
||||
break;
|
||||
case SPEED_25000:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_25GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_25GB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_25GB;
|
||||
break;
|
||||
case SPEED_40000:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_40GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_40GB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_40GB;
|
||||
break;
|
||||
case SPEED_50000:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_50GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_50GB;
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_50GB;
|
||||
break;
|
||||
case SPEED_100000:
|
||||
if (support_spds & BNXT_LINK_SPEED_MSK_100GB)
|
||||
fw_speed = PORT_PHY_CFG_REQ_AUTO_LINK_SPEED_100GB;
|
||||
break;
|
||||
default:
|
||||
netdev_err(dev, "unsupported speed!\n");
|
||||
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100GB;
|
||||
break;
|
||||
}
|
||||
return fw_speed;
|
||||
|
||||
if (!fw_speed) {
|
||||
netdev_err(dev, "unsupported speed!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
link_info->req_link_speed = fw_speed;
|
||||
link_info->req_duplex = BNXT_LINK_DUPLEX_FULL;
|
||||
link_info->autoneg = 0;
|
||||
link_info->advertising = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16 bnxt_get_fw_auto_link_speeds(u32 advertising)
|
||||
|
@ -1737,7 +1745,6 @@ static int bnxt_set_link_ksettings(struct net_device *dev,
|
|||
*/
|
||||
set_pause = true;
|
||||
} else {
|
||||
u16 fw_speed;
|
||||
u8 phy_type = link_info->phy_type;
|
||||
|
||||
if (phy_type == PORT_PHY_QCFG_RESP_PHY_TYPE_BASET ||
|
||||
|
@ -1753,15 +1760,9 @@ static int bnxt_set_link_ksettings(struct net_device *dev,
|
|||
goto set_setting_exit;
|
||||
}
|
||||
speed = base->speed;
|
||||
fw_speed = bnxt_get_fw_speed(dev, speed);
|
||||
if (!fw_speed) {
|
||||
rc = -EINVAL;
|
||||
rc = bnxt_force_link_speed(dev, speed);
|
||||
if (rc)
|
||||
goto set_setting_exit;
|
||||
}
|
||||
link_info->req_link_speed = fw_speed;
|
||||
link_info->req_duplex = BNXT_LINK_DUPLEX_FULL;
|
||||
link_info->autoneg = 0;
|
||||
link_info->advertising = 0;
|
||||
}
|
||||
|
||||
if (netif_running(dev))
|
||||
|
|
Loading…
Reference in New Issue