netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iwl-next v4 0/2] Add link_down_events counters to ixgbe and ice drivers
@ 2025-05-15 10:50 Martyna Szapar-Mudlaw
  2025-05-15 10:50 ` [PATCH iwl-next v4 1/2] ice: add link_down_events statistic Martyna Szapar-Mudlaw
  2025-05-15 10:50 ` [PATCH iwl-next v4 2/2] ixgbe: " Martyna Szapar-Mudlaw
  0 siblings, 2 replies; 6+ messages in thread
From: Martyna Szapar-Mudlaw @ 2025-05-15 10:50 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: netdev, kuba, dawid.osuchowski, pmenzel, Martyna Szapar-Mudlaw

This series introduces link_down_events counters to the ixgbe and ice drivers.
The counters are incremented each time the link transitions from up to down,
allowing better diagnosis of link stability issues such as port flapping or
unexpected link drops.

The counter increments only on actual physical link-down events visible
to the PHY. It does not increment when the user performs a software-only
interface down/up (e.g. ip link set dev down).
The counter does increment in cases where the interface is reinitialized
in a way that causes a real link drop — such as eg. when attaching
an XDP program, reconfiguring channels, or toggling certain priv-flags.

The values are exposed via ethtool using the get_link_ext_stats() interface.

Example output:
#ethtool --include-statistics <ethX>
Settings for <ethX>:
        [...]
        Link Down Events: 2

Martyna Szapar-Mudlaw (2):
  ice: add link_down_events statistic
  ixgbe: add link_down_events statistic

v4->v3:
only cover letter edits
v3 -> v2:
ixgbe patch: rebased on latest ixgbe changes; added statistic for E610
no changes to ice driver patch 
v2 -> v1:
used ethtool get_link_ext_stats() interface to expose counters

 drivers/net/ethernet/intel/ice/ice.h             |  1 +
 drivers/net/ethernet/intel/ice/ice_ethtool.c     | 10 ++++++++++
 drivers/net/ethernet/intel/ice/ice_main.c        |  3 +++
 drivers/net/ethernet/intel/ixgbe/ixgbe.h         |  1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |  9 +++++++++
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    |  2 ++
 6 files changed, 26 insertions(+)

-- 
2.47.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH iwl-next v4 1/2] ice: add link_down_events statistic
  2025-05-15 10:50 [PATCH iwl-next v4 0/2] Add link_down_events counters to ixgbe and ice drivers Martyna Szapar-Mudlaw
@ 2025-05-15 10:50 ` Martyna Szapar-Mudlaw
  2025-05-22 13:47   ` Simon Horman
  2025-05-15 10:50 ` [PATCH iwl-next v4 2/2] ixgbe: " Martyna Szapar-Mudlaw
  1 sibling, 1 reply; 6+ messages in thread
From: Martyna Szapar-Mudlaw @ 2025-05-15 10:50 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: netdev, kuba, dawid.osuchowski, pmenzel, Martyna Szapar-Mudlaw,
	Kory Maincent, Rinitha S

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>
---
 drivers/net/ethernet/intel/ice/ice.h         |  1 +
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 10 ++++++++++
 drivers/net/ethernet/intel/ice/ice_main.c    |  3 +++
 3 files changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index e42572ae7631..eac0f95d20f1 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -617,6 +617,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 */
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index 648815170477..db7ae817b127 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -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,
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 1fbe13ee93a8..2d1361b68b14 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -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)) {
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH iwl-next v4 2/2] ixgbe: add link_down_events statistic
  2025-05-15 10:50 [PATCH iwl-next v4 0/2] Add link_down_events counters to ixgbe and ice drivers Martyna Szapar-Mudlaw
  2025-05-15 10:50 ` [PATCH iwl-next v4 1/2] ice: add link_down_events statistic Martyna Szapar-Mudlaw
@ 2025-05-15 10:50 ` Martyna Szapar-Mudlaw
  2025-05-19 12:31   ` [Intel-wired-lan] " Rinitha, SX
  2025-05-22 13:48   ` Simon Horman
  1 sibling, 2 replies; 6+ messages in thread
From: Martyna Szapar-Mudlaw @ 2025-05-15 10:50 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: netdev, kuba, dawid.osuchowski, pmenzel, Martyna Szapar-Mudlaw,
	Kory Maincent, Aleksandr Loktionov

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>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h         |  1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 10 ++++++++++
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    |  2 ++
 3 files changed, 13 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 47311b134a7a..c6772cd2d802 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -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;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index d8a919ab7027..1dc1c6e611a4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -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,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 03d31e5b131d..1982314aaf3c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -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;
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [Intel-wired-lan] [PATCH iwl-next v4 2/2] ixgbe: add link_down_events statistic
  2025-05-15 10:50 ` [PATCH iwl-next v4 2/2] ixgbe: " Martyna Szapar-Mudlaw
@ 2025-05-19 12:31   ` Rinitha, SX
  2025-05-22 13:48   ` Simon Horman
  1 sibling, 0 replies; 6+ messages in thread
From: Rinitha, SX @ 2025-05-19 12:31 UTC (permalink / raw)
  To: Martyna Szapar-Mudlaw, intel-wired-lan@lists.osuosl.org
  Cc: netdev@vger.kernel.org, kuba@kernel.org,
	dawid.osuchowski@linux.intel.com, pmenzel@molgen.mpg.de,
	Kory Maincent, Loktionov, Aleksandr

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Martyna Szapar-Mudlaw
> Sent: 15 May 2025 16:20
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; kuba@kernel.org; dawid.osuchowski@linux.intel.com; pmenzel@molgen.mpg.de; Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>; Kory Maincent <kory.maincent@bootlin.com>; Loktionov, Aleksandr <aleksandr.loktionov@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v4 2/2] 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: 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>
> ---
> drivers/net/ethernet/intel/ixgbe/ixgbe.h         |  1 +
> drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 10 ++++++++++
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    |  2 ++
> 3 files changed, 13 insertions(+)
>

Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH iwl-next v4 1/2] ice: add link_down_events statistic
  2025-05-15 10:50 ` [PATCH iwl-next v4 1/2] ice: add link_down_events statistic Martyna Szapar-Mudlaw
@ 2025-05-22 13:47   ` Simon Horman
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2025-05-22 13:47 UTC (permalink / raw)
  To: Martyna Szapar-Mudlaw
  Cc: intel-wired-lan, netdev, kuba, dawid.osuchowski, pmenzel,
	Kory Maincent, Rinitha S

On Thu, May 15, 2025 at 12:50:09PM +0200, Martyna Szapar-Mudlaw wrote:
> 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>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH iwl-next v4 2/2] ixgbe: add link_down_events statistic
  2025-05-15 10:50 ` [PATCH iwl-next v4 2/2] ixgbe: " Martyna Szapar-Mudlaw
  2025-05-19 12:31   ` [Intel-wired-lan] " Rinitha, SX
@ 2025-05-22 13:48   ` Simon Horman
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Horman @ 2025-05-22 13:48 UTC (permalink / raw)
  To: Martyna Szapar-Mudlaw
  Cc: intel-wired-lan, netdev, kuba, dawid.osuchowski, pmenzel,
	Kory Maincent, Aleksandr Loktionov

On Thu, May 15, 2025 at 12:50:10PM +0200, Martyna Szapar-Mudlaw wrote:
> 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>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-22 13:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 10:50 [PATCH iwl-next v4 0/2] Add link_down_events counters to ixgbe and ice drivers Martyna Szapar-Mudlaw
2025-05-15 10:50 ` [PATCH iwl-next v4 1/2] ice: add link_down_events statistic Martyna Szapar-Mudlaw
2025-05-22 13:47   ` Simon Horman
2025-05-15 10:50 ` [PATCH iwl-next v4 2/2] ixgbe: " Martyna Szapar-Mudlaw
2025-05-19 12:31   ` [Intel-wired-lan] " Rinitha, SX
2025-05-22 13:48   ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).