git: f7ea2d561288 - stable/15 - iflib: Add sysctl stat for TX watchdog reset events

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 06:03:23 UTC
The branch stable/15 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=f7ea2d561288be5bd0eade18fe2565f30b091f96

commit f7ea2d561288be5bd0eade18fe2565f30b091f96
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-08 07:50:08 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-29 05:41:55 +0000

    iflib: Add sysctl stat for TX watchdog reset events
    
    iflib counts resets initiated by its transmit watchdog in 69c3e0de01c1.
    
    Export the counter in the per-device iflib sysctl tree so every
    driver provides the diagnostic without a driver callback or duplicate
    storage.
    
    A watchdog reset does not establish how many packets failed.  It can
    recover a hardware stall involving several queued packets or a missed
    completion involving no packet loss.  Stop adding one output error per
    watchdog event in em(4), igb(4), and igc(4).
    
    Remove the redundant driver counters and move the diagnostic to
    dev.<driver>.<unit>.iflib.tx_watchdog_events.
    
    Relnotes:       yes
    
    (cherry picked from commit d6f97c6bbca689f00d5edcfd9c8f31b0910edbaf)
---
 share/man/man4/iflib.4   |  5 +++++
 share/man/man9/iflibdi.9 |  4 ++--
 sys/dev/e1000/if_em.c    | 22 +---------------------
 sys/dev/e1000/if_em.h    |  1 -
 sys/dev/igc/if_igc.c     | 19 +------------------
 sys/dev/igc/if_igc.h     |  1 -
 sys/dev/ixgbe/if_ix.c    |  2 --
 sys/dev/ixgbe/if_ixv.c   |  2 --
 sys/dev/ixgbe/ixgbe.h    |  1 -
 sys/net/iflib.c          |  7 +++++--
 10 files changed, 14 insertions(+), 50 deletions(-)

diff --git a/share/man/man4/iflib.4 b/share/man/man4/iflib.4
index e648a679313d..ca1b7918412e 100644
--- a/share/man/man4/iflib.4
+++ b/share/man/man4/iflib.4
@@ -194,6 +194,11 @@ variables are read-only:
 .Bl -tag -width indent
 .It Va driver_version
 A string indicating the internal version of the driver.
+.It Va tx_watchdog_events
+Number of transmit watchdog resets initiated by
+.Nm .
+This counts recovery events, not failed packets, and is not included in the
+interface output error counter.
 .El
 .Pp
 There are a number of queue state
diff --git a/share/man/man9/iflibdi.9 b/share/man/man9/iflibdi.9
index fcfc0f8170be..f5039dd41c3f 100644
--- a/share/man/man9/iflibdi.9
+++ b/share/man/man9/iflibdi.9
@@ -165,8 +165,8 @@ Its possible values are either active or inactive.
 .Pq Vt "eventhandler_tag"
 .It Va ifc_pause_frames
 .Pq Vt "int"
-.It Va ifc_watchdog_events
-.Pq Vt "int"
+.It Va ifc_tx_watchdog_events
+.Pq Vt "uint32_t"
 .It Va ifc_mac
 .Pq Vt "uint8_t"
 .It Va ifc_msix_mem
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 74da82296b59..858cb6a176fd 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -421,7 +421,6 @@ static int	em_if_mtu_set(if_ctx_t, uint32_t);
 static void	em_if_timer(if_ctx_t, uint16_t);
 static void	em_if_vlan_register(if_ctx_t, u16);
 static void	em_if_vlan_unregister(if_ctx_t, u16);
-static void	em_if_watchdog_reset(if_ctx_t);
 static bool	em_if_needs_restart(if_ctx_t, enum iflib_restart_event);
 
 static void	em_identify_hardware(if_ctx_t);
@@ -616,7 +615,6 @@ static device_method_t em_if_methods[] = {
 	DEVMETHOD(ifdi_mtu_set, em_if_mtu_set),
 	DEVMETHOD(ifdi_promisc_set, em_if_set_promisc),
 	DEVMETHOD(ifdi_timer, em_if_timer),
-	DEVMETHOD(ifdi_watchdog_reset, em_if_watchdog_reset),
 	DEVMETHOD(ifdi_vlan_register, em_if_vlan_register),
 	DEVMETHOD(ifdi_vlan_unregister, em_if_vlan_unregister),
 	DEVMETHOD(ifdi_get_counter, em_if_get_counter),
@@ -654,7 +652,6 @@ static device_method_t igb_if_methods[] = {
 	DEVMETHOD(ifdi_mtu_set, em_if_mtu_set),
 	DEVMETHOD(ifdi_promisc_set, em_if_set_promisc),
 	DEVMETHOD(ifdi_timer, em_if_timer),
-	DEVMETHOD(ifdi_watchdog_reset, em_if_watchdog_reset),
 	DEVMETHOD(ifdi_vlan_register, em_if_vlan_register),
 	DEVMETHOD(ifdi_vlan_unregister, em_if_vlan_unregister),
 	DEVMETHOD(ifdi_get_counter, em_if_get_counter),
@@ -3654,18 +3651,6 @@ em_if_update_admin_status(if_ctx_t ctx)
 		lem_smartspeed(sc);
 }
 
-static void
-em_if_watchdog_reset(if_ctx_t ctx)
-{
-	struct e1000_softc *sc = iflib_get_softc(ctx);
-
-	/*
-	 * Just count the event; iflib(4) will already trigger a
-	 * sufficient reset of the controller.
-	 */
-	sc->watchdog_events++;
-}
-
 /*********************************************************************
  *
  *  This routine disables all traffic on the adapter by issuing a
@@ -6836,8 +6821,6 @@ em_if_get_vf_counter(if_ctx_t ctx, ift_counter cnt)
 	switch (cnt) {
 	case IFCOUNTER_IERRORS:
 		return sc->dropped_pkts;
-	case IFCOUNTER_OERRORS:
-		return sc->watchdog_events;
 	default:
 		return (if_get_counter_default(ifp, cnt));
 	}
@@ -6865,7 +6848,7 @@ em_if_get_counter(if_ctx_t ctx, ift_counter cnt)
 		    stats->mpc + stats->cexterr);
 	case IFCOUNTER_OERRORS:
 		return (if_get_counter_default(ifp, cnt) +
-		    stats->ecol + stats->latecol + sc->watchdog_events);
+		    stats->ecol + stats->latecol);
 	default:
 		return (if_get_counter_default(ifp, cnt));
 	}
@@ -6986,9 +6969,6 @@ em_add_hw_stats(struct e1000_softc *sc)
 	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "rx_overruns",
 	    CTLFLAG_RD, &sc->rx_overruns,
 	    "RX overruns");
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "watchdog_timeouts",
-	    CTLFLAG_RD, &sc->watchdog_events,
-	    "Watchdog timeouts");
 	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "device_control",
 	    CTLTYPE_UINT | CTLFLAG_RD,
 	    sc, E1000_CTRL, em_sysctl_reg_handler, "IU",
diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h
index 3e8d7edc69d4..42332b43dccc 100644
--- a/sys/dev/e1000/if_em.h
+++ b/sys/dev/e1000/if_em.h
@@ -669,7 +669,6 @@ struct e1000_softc {
 	unsigned long		dropped_pkts;
 	unsigned long		link_irq;
 	unsigned long		rx_overruns;
-	unsigned long		watchdog_events;
 
 	union {
 		struct e1000_hw_stats	stats;		/* !sc->vf_ifp */
diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c
index 3734bb09508e..7aa8a1df9203 100644
--- a/sys/dev/igc/if_igc.c
+++ b/sys/dev/igc/if_igc.c
@@ -111,7 +111,6 @@ static int	igc_if_mtu_set(if_ctx_t, uint32_t);
 static void	igc_if_timer(if_ctx_t, uint16_t);
 static void	igc_if_vlan_register(if_ctx_t, u16);
 static void	igc_if_vlan_unregister(if_ctx_t, u16);
-static void	igc_if_watchdog_reset(if_ctx_t);
 static bool	igc_if_needs_restart(if_ctx_t, enum iflib_restart_event);
 
 static void	igc_identify_hardware(if_ctx_t);
@@ -243,7 +242,6 @@ static device_method_t igc_if_methods[] = {
 	DEVMETHOD(ifdi_mtu_set, igc_if_mtu_set),
 	DEVMETHOD(ifdi_promisc_set, igc_if_set_promisc),
 	DEVMETHOD(ifdi_timer, igc_if_timer),
-	DEVMETHOD(ifdi_watchdog_reset, igc_if_watchdog_reset),
 	DEVMETHOD(ifdi_vlan_register, igc_if_vlan_register),
 	DEVMETHOD(ifdi_vlan_unregister, igc_if_vlan_unregister),
 	DEVMETHOD(ifdi_get_counter, igc_if_get_counter),
@@ -1625,18 +1623,6 @@ igc_if_update_admin_status(if_ctx_t ctx)
 	igc_update_stats_counters(sc);
 }
 
-static void
-igc_if_watchdog_reset(if_ctx_t ctx)
-{
-	struct igc_softc *sc = iflib_get_softc(ctx);
-
-	/*
-	 * Just count the event; iflib(4) will already trigger a
-	 * sufficient reset of the controller.
-	 */
-	sc->watchdog_events++;
-}
-
 /*********************************************************************
  *
  *  This routine disables all traffic on the adapter by issuing a
@@ -3172,7 +3158,7 @@ igc_if_get_counter(if_ctx_t ctx, ift_counter cnt)
 		    sc->stats.mpc);
 	case IFCOUNTER_OERRORS:
 		return (if_get_counter_default(ifp, cnt) +
-		    sc->stats.ecol + sc->stats.latecol + sc->watchdog_events);
+		    sc->stats.ecol + sc->stats.latecol);
 	default:
 		return (if_get_counter_default(ifp, cnt));
 	}
@@ -3275,9 +3261,6 @@ igc_add_hw_stats(struct igc_softc *sc)
 	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "rx_overruns",
 	    CTLFLAG_RD, &sc->rx_overruns,
 	    "RX overruns");
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "watchdog_timeouts",
-	    CTLFLAG_RD, &sc->watchdog_events,
-	    "Watchdog timeouts");
 	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "device_control",
 	    CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
 	    sc, IGC_CTRL, igc_sysctl_reg_handler, "IU",
diff --git a/sys/dev/igc/if_igc.h b/sys/dev/igc/if_igc.h
index 495f684eab39..bef6b9d1211c 100644
--- a/sys/dev/igc/if_igc.h
+++ b/sys/dev/igc/if_igc.h
@@ -412,7 +412,6 @@ struct igc_softc {
 	unsigned long	dropped_pkts;
 	unsigned long	link_irq;
 	unsigned long	rx_overruns;
-	unsigned long	watchdog_events;
 
 	u32		fatal_error_state;
 	u32		fatal_error_peind;
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index ada3cead1dd1..42054fc498ae 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -2238,8 +2238,6 @@ ixgbe_add_hw_stats(struct ixgbe_softc *sc)
 	/* Driver Statistics */
 	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "dropped",
 	    CTLFLAG_RD, &sc->dropped_pkts, "Driver dropped packets");
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "watchdog_events",
-	    CTLFLAG_RD, &sc->watchdog_events, "Watchdog timeouts");
 	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "link_irq",
 	    CTLFLAG_RD, &sc->link_irq, "Link MSI-X IRQ Handled");
 
diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c
index 166a480dd560..62e92be75197 100644
--- a/sys/dev/ixgbe/if_ixv.c
+++ b/sys/dev/ixgbe/if_ixv.c
@@ -2450,8 +2450,6 @@ ixv_add_stats_sysctls(struct ixgbe_softc *sc)
 	char namebuf[QUEUE_NAME_LEN];
 
 	/* Driver Statistics */
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "watchdog_events",
-	    CTLFLAG_RD, &sc->watchdog_events, "Watchdog timeouts");
 	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "link_irq",
 	    CTLFLAG_RD, &sc->link_irq, "Link MSI-X IRQ Handled");
 
diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h
index 28010526d235..2656d44772e3 100644
--- a/sys/dev/ixgbe/ixgbe.h
+++ b/sys/dev/ixgbe/ixgbe.h
@@ -513,7 +513,6 @@ struct ixgbe_softc {
 	unsigned long		dropped_pkts;
 	unsigned long		mbuf_header_failed;
 	unsigned long		mbuf_packet_failed;
-	unsigned long		watchdog_events;
 	unsigned long		link_irq;
 	union {
 		struct ixgbe_hw_stats pf;
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index d9b4e770741b..7cbf3216b12d 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -232,7 +232,7 @@ struct iflib_ctx {
 	uint32_t ifc_rx_mbuf_sz;
 
 	int ifc_link_state;
-	int ifc_watchdog_events;
+	uint32_t ifc_tx_watchdog_events;
 	struct cdev *ifc_led_dev;
 	int ifc_led_state;
 	struct resource *ifc_msix_mem;
@@ -4543,7 +4543,7 @@ _task_fn_admin(void *context, int pending)
 	if (ctx->ifc_sctx->isc_flags & IFLIB_HAS_ADMINCQ)
 		IFDI_ADMIN_COMPLETION_HANDLE(ctx);
 	if (do_watchdog) {
-		ctx->ifc_watchdog_events++;
+		ctx->ifc_tx_watchdog_events++;
 		IFDI_WATCHDOG_RESET(ctx);
 	}
 	IFDI_UPDATE_ADMIN_STATUS(ctx);
@@ -7629,6 +7629,9 @@ iflib_add_device_sysctl_pre(if_ctx_t ctx)
 
 	SYSCTL_ADD_CONST_STRING(&ctx->ifc_sysctl_ctx, oid_list, OID_AUTO, "driver_version",
 	    CTLFLAG_RD, ctx->ifc_sctx->isc_driver_version, "driver version");
+	SYSCTL_ADD_U32(&ctx->ifc_sysctl_ctx, oid_list, OID_AUTO,
+	    "tx_watchdog_events", CTLFLAG_RD, &ctx->ifc_tx_watchdog_events, 0,
+	    "TX watchdog resets initiated by iflib");
 
 	SYSCTL_ADD_BOOL(&ctx->ifc_sysctl_ctx, oid_list, OID_AUTO, "simple_tx",
 	    CTLFLAG_RDTUN, &ctx->ifc_sysctl_simple_tx, 0,