Commit 9acae9e2 authored by Martyna Szapar-Mudlaw's avatar Martyna Szapar-Mudlaw Committed by Tony Nguyen
Browse files

ixgbe: add link_down_events statistic



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: default avatarKory Maincent <kory.maincent@bootlin.com>
Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: default avatarMartyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent f0768aec
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+10 −0
Original line number Diff line number Diff line
@@ -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,
+2 −0
Original line number Diff line number Diff line
@@ -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;