There already exists a link_down_events statistic that is calculated by the firmware and is reported via the .get_link_ext_stats() ethtool handler, but there is a value that is calculated by the firmware, too, that could be useful. Instead of replacing the driver calculated value, add the firmware value to the ethtool general stats output. Unlike the driver value, the firmware value doesn't get reset unless the actual card itself gets reset and is limited 16 bits, making it harder to use to track link down events e.g. during the current boot and any excessive number of link flaps. That said, it could still be useful to track link down events while the driver is not loaded, such as checking if the link partner is flapping while the local system is booting or otherwise does not have the ionic driver loaded. Signed-off-by: Eric Joyner --- drivers/net/ethernet/pensando/ionic/ionic_stats.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c index e81190cc9d2f..d0ebba7aec22 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c @@ -237,7 +237,7 @@ static u32 ionic_extra_port_stats_get_count(struct ionic_lif *lif) { struct ionic_dev *idev = &lif->ionic->idev; struct ionic_port_extra_stats *pes_cache; - u32 count = 0; + u32 count = 1; if (!(lif->ionic->ident.dev.capabilities & cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS))) @@ -296,6 +296,8 @@ static void ionic_extra_port_stats_get_strings(struct ionic_lif *lif, u8 **buf) { struct ionic_port_extra_stats *pes_cache; + ethtool_puts(buf, "link_down_events_phy"); + if (!(lif->ionic->ident.dev.capabilities & cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS))) return; @@ -360,8 +362,12 @@ static void ionic_sw_stats_get_rxq_values(struct ionic_lif *lif, u64 **buf, static void ionic_extra_port_stats_get_values(struct ionic_lif *lif, u64 **buf) { + struct ionic_port_info *port_info = lif->ionic->idev.port_info; struct ionic_port_extra_stats *pes_cache; + **buf = le16_to_cpu(port_info->status.link_down_count); + (*buf)++; + if (!(lif->ionic->ident.dev.capabilities & cpu_to_le64(IONIC_DEV_CAP_EXTRA_STATS))) return; -- 2.17.1