]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ixgbe: add link_down_events statistic
authorMartyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
Thu, 15 May 2025 10:50:10 +0000 (12:50 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 9 Jun 2025 16:56:18 +0000 (09:56 -0700)
Introduce a link_down_events counter to the ixgbe driver, incremented
each time the link transitions from up to down.
This counter can help diagnose issues related to link stability,
such as port flapping or unexpected link drops.

The value is exposed via ethtool's get_link_ext_stats() interface.

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

index 47311b134a7a93515be55fb823bbc7953b55c00e..c6772cd2d80214a444844aeb978bddfac1ef4b04 100644 (file)
@@ -752,6 +752,7 @@ struct ixgbe_adapter {
        bool link_up;
        unsigned long sfp_poll_time;
        unsigned long link_check_timeout;
+       u32 link_down_events;
 
        struct timer_list service_timer;
        struct work_struct service_task;
index d8a919ab7027aa1a6b6a4196a92557c9c95e6f3f..1dc1c6e611a40429850064e5770953d773ee7323 100644 (file)
@@ -1033,6 +1033,14 @@ static void ixgbe_get_regs(struct net_device *netdev,
        regs_buff[1144] = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT);
 }
 
+static void ixgbe_get_link_ext_stats(struct net_device *netdev,
+                                    struct ethtool_link_ext_stats *stats)
+{
+       struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
+
+       stats->link_down_events = adapter->link_down_events;
+}
+
 static int ixgbe_get_eeprom_len(struct net_device *netdev)
 {
        struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
@@ -3719,6 +3727,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {
        .set_wol                = ixgbe_set_wol,
        .nway_reset             = ixgbe_nway_reset,
        .get_link               = ethtool_op_get_link,
+       .get_link_ext_stats     = ixgbe_get_link_ext_stats,
        .get_eeprom_len         = ixgbe_get_eeprom_len,
        .get_eeprom             = ixgbe_get_eeprom,
        .set_eeprom             = ixgbe_set_eeprom,
@@ -3764,6 +3773,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops_e610 = {
        .set_wol                = ixgbe_set_wol_e610,
        .nway_reset             = ixgbe_nway_reset,
        .get_link               = ethtool_op_get_link,
+       .get_link_ext_stats     = ixgbe_get_link_ext_stats,
        .get_eeprom_len         = ixgbe_get_eeprom_len,
        .get_eeprom             = ixgbe_get_eeprom,
        .set_eeprom             = ixgbe_set_eeprom,
index 03d31e5b131dc05e4bff30993f4af4ae7441619e..1982314aaf3c114e7bc3d8d6b392a27a4dab15dc 100644 (file)
@@ -7991,6 +7991,8 @@ static void ixgbe_watchdog_link_is_down(struct ixgbe_adapter *adapter)
        if (!netif_carrier_ok(netdev))
                return;
 
+       adapter->link_down_events++;
+
        /* poll for SFP+ cable when link is down */
        if (ixgbe_is_sfp(hw) && hw->mac.type == ixgbe_mac_82598EB)
                adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP;