From: "Nikhil P. Rao" ionic_get_fecparam() fills fec->active_fec from config.fec_type, the mode the host requested, which on an autoneg link is whatever was last programmed while the link negotiates something else. On an autoneg link, read it from status.fec_type, where firmware reports the operational mode. status.fec_type was carved out of the reserved area by commit c4e7a75a096c ("ionic: updates to ionic FW api description"), and firmware older than that leaves the byte zero, which reads as FEC off. With autoneg disabled the port runs the configured mode, so keep reporting config.fec_type there; only autoneg links on such old firmware report FEC off. Fill both fields in a new ionic_get_fec_modes(), which reads config.an_enable once so that fec and active_fec always describe the same autoneg state. Fixes: e95f922f4c2f ("ionic: implement ethtool set-fec") Signed-off-by: Nikhil P. Rao Signed-off-by: Eric Joyner Signed-off-by: Brett Creeley --- .../net/ethernet/pensando/ionic/ionic_ethtool.c | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c index 9f0af298c8db..c25483134b93 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c @@ -438,22 +438,29 @@ static u32 ionic_fec_type_to_ethtool(u8 fec_type) } } +static void ionic_get_fec_modes(const struct ionic_port_info *port_info, + u32 *fec, u32 *active_fec) +{ + u8 fec_type; + + if (READ_ONCE(port_info->config.an_enable)) { + *fec = ETHTOOL_FEC_AUTO; + fec_type = READ_ONCE(port_info->status.fec_type); + *active_fec = ionic_fec_type_to_ethtool(fec_type); + } else { + fec_type = READ_ONCE(port_info->config.fec_type); + *fec = ionic_fec_type_to_ethtool(fec_type); + *active_fec = *fec; + } +} + static int ionic_get_fecparam(struct net_device *netdev, struct ethtool_fecparam *fec) { - struct ionic_port_info *port_info; - struct ionic_lif *lif; - u8 config_fec_type; - - lif = netdev_priv(netdev); - port_info = lif->ionic->idev.port_info; - config_fec_type = port_info->config.fec_type; + struct ionic_lif *lif = netdev_priv(netdev); - fec->active_fec = ionic_fec_type_to_ethtool(config_fec_type); - if (port_info->config.an_enable) - fec->fec = ETHTOOL_FEC_AUTO; - else - fec->fec = ionic_fec_type_to_ethtool(config_fec_type); + ionic_get_fec_modes(lif->ionic->idev.port_info, &fec->fec, + &fec->active_fec); return 0; } -- 2.53.0