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. Fixes: e95f922f4c2f ("ionic: implement ethtool set-fec") Signed-off-by: Nikhil P. Rao Signed-off-by: Eric Joyner --- drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c index 8f0f1585116b..ac728b8aa780 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c @@ -440,6 +440,18 @@ static u32 ionic_fec_type_to_ethtool(u8 fec_type) } } +/* Firmware that predates status.fec_type leaves it zero, which reads as + * FEC off. With autoneg disabled the port runs the configured mode, so + * only trust status.fec_type on an autoneg link. + */ +static u8 ionic_active_fec_type(const struct ionic_port_info *port_info) +{ + if (READ_ONCE(port_info->config.an_enable)) + return READ_ONCE(port_info->status.fec_type); + + return READ_ONCE(port_info->config.fec_type); +} + static int ionic_get_fecparam(struct net_device *netdev, struct ethtool_fecparam *fec) { @@ -449,8 +461,10 @@ static int ionic_get_fecparam(struct net_device *netdev, lif = netdev_priv(netdev); port_info = lif->ionic->idev.port_info; - fec->active_fec = ionic_fec_type_to_ethtool(port_info->config.fec_type); - fec->fec = ionic_fec_type_to_ethtool(port_info->config.fec_type); + fec->active_fec = + ionic_fec_type_to_ethtool(ionic_active_fec_type(port_info)); + fec->fec = + ionic_fec_type_to_ethtool(READ_ONCE(port_info->config.fec_type)); return 0; } -- 2.53.0