]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ice: add link_down_events statistic
authorMartyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
Thu, 15 May 2025 10:50:09 +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 ice 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>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice.h
drivers/net/ethernet/intel/ice/ice_ethtool.c
drivers/net/ethernet/intel/ice/ice_main.c

index ddd0ad68185b44e92dced15b9d8c29e4eb8663d7..dcf87efb9f20f9d2ab00a29b657f0de5d970ddce 100644 (file)
@@ -614,6 +614,7 @@ struct ice_pf {
        u16 globr_count;        /* Global reset count */
        u16 empr_count;         /* EMP reset count */
        u16 pfr_count;          /* PF reset count */
+       u32 link_down_events;
 
        u8 wol_ena : 1;         /* software state of WoL */
        u32 wakeup_reason;      /* last wakeup reason */
index bbf9e6fd315b26c0120b091062bc7d41544b0c1b..5863a86482f5828620032c68416023e54a18fb21 100644 (file)
@@ -836,6 +836,15 @@ static void ice_set_msglevel(struct net_device *netdev, u32 data)
 #endif /* !CONFIG_DYNAMIC_DEBUG */
 }
 
+static void ice_get_link_ext_stats(struct net_device *netdev,
+                                  struct ethtool_link_ext_stats *stats)
+{
+       struct ice_netdev_priv *np = netdev_priv(netdev);
+       struct ice_pf *pf = np->vsi->back;
+
+       stats->link_down_events = pf->link_down_events;
+}
+
 static int ice_get_eeprom_len(struct net_device *netdev)
 {
        struct ice_netdev_priv *np = netdev_priv(netdev);
@@ -4784,6 +4793,7 @@ static const struct ethtool_ops ice_ethtool_ops = {
        .set_msglevel           = ice_set_msglevel,
        .self_test              = ice_self_test,
        .get_link               = ethtool_op_get_link,
+       .get_link_ext_stats     = ice_get_link_ext_stats,
        .get_eeprom_len         = ice_get_eeprom_len,
        .get_eeprom             = ice_get_eeprom,
        .get_coalesce           = ice_get_coalesce,
index d97d4b25b30d2834a233cc15a6cb63c66940d26e..4e04721467bf72339f662df000852542d0a718ee 100644 (file)
@@ -1144,6 +1144,9 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,
        if (link_up == old_link && link_speed == old_link_speed)
                return 0;
 
+       if (!link_up && old_link)
+               pf->link_down_events++;
+
        ice_ptp_link_change(pf, link_up);
 
        if (ice_is_dcb_active(pf)) {