Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Aug 2026 10:38:07 +0000
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a108ee9138a6 - main - igc: Correct hardware error statistics
Message-ID:  <6a706f8f.43833.7e96c267@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kbowling:

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

commit a108ee9138a698f212d6d6832d54e88ce6786617
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-03 10:31:36 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-03 10:37:52 +0000

    igc: Correct hardware error statistics
    
    Track RERC separately instead of adding receive errors to the collision
    count, and read the previously omitted RXERRC register.  Include RFC in
    input errors because CRCERRS does not count bad-CRC runts, implementing
    the I225 length-error accounting workaround alongside RUC and ROC.
    
    Stop treating host transmit MAC discards as receive errors.  Expose both
    RERC and HTDPMC as dedicated MAC statistics so their overlapping counts
    remain available without corrupting aggregate interface counters.
    
    MFC after:      2 weeks
---
 sys/dev/igc/if_igc.c   | 17 ++++++++++++++---
 sys/dev/igc/igc_hw.h   |  1 +
 sys/dev/igc/igc_mac.c  |  1 +
 sys/dev/igc/igc_regs.h |  1 +
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c
index fa4f427a5710..21eb0d6357ef 100644
--- a/sys/dev/igc/if_igc.c
+++ b/sys/dev/igc/if_igc.c
@@ -2599,6 +2599,7 @@ igc_update_stats_counters(struct igc_softc *sc)
 	u64 prev_xoffrxc = sc->stats.xoffrxc;
 
 	sc->stats.crcerrs += IGC_READ_REG(&sc->hw, IGC_CRCERRS);
+	sc->stats.rxerrc += IGC_READ_REG(&sc->hw, IGC_RXERRC);
 	sc->stats.mpc += IGC_READ_REG(&sc->hw, IGC_MPC);
 	sc->stats.scc += IGC_READ_REG(&sc->hw, IGC_SCC);
 	sc->stats.ecol += IGC_READ_REG(&sc->hw, IGC_ECOL);
@@ -2606,7 +2607,7 @@ igc_update_stats_counters(struct igc_softc *sc)
 	sc->stats.mcc += IGC_READ_REG(&sc->hw, IGC_MCC);
 	sc->stats.latecol += IGC_READ_REG(&sc->hw, IGC_LATECOL);
 	sc->stats.colc += IGC_READ_REG(&sc->hw, IGC_COLC);
-	sc->stats.colc += IGC_READ_REG(&sc->hw, IGC_RERC);
+	sc->stats.rerc += IGC_READ_REG(&sc->hw, IGC_RERC);
 	sc->stats.dc += IGC_READ_REG(&sc->hw, IGC_DC);
 	sc->stats.rlec += IGC_READ_REG(&sc->hw, IGC_RLEC);
 	sc->stats.xonrxc += IGC_READ_REG(&sc->hw, IGC_XONRXC);
@@ -2685,10 +2686,14 @@ igc_if_get_counter(if_ctx_t ctx, ift_counter cnt)
 	case IFCOUNTER_COLLISIONS:
 		return (sc->stats.colc);
 	case IFCOUNTER_IERRORS:
+		/*
+		 * RERC overlaps the counters below and, on I225, omits length
+		 * errors.  RFC covers bad-CRC runts that CRCERRS does not count.
+		 */
 		return (sc->dropped_pkts + sc->stats.rxerrc +
 		    sc->stats.crcerrs + sc->stats.algnerrc +
-		    sc->stats.ruc + sc->stats.roc +
-		    sc->stats.mpc + sc->stats.htdpmc);
+		    sc->stats.ruc + sc->stats.rfc + sc->stats.roc +
+		    sc->stats.mpc);
 	case IFCOUNTER_OERRORS:
 		return (if_get_counter_default(ifp, cnt) +
 		    sc->stats.ecol + sc->stats.latecol + sc->watchdog_events);
@@ -2911,6 +2916,9 @@ igc_add_hw_stats(struct igc_softc *sc)
 	SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_errs",
 	    CTLFLAG_RD, &sc->stats.rxerrc,
 	    "Receive Errors");
+	SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_error_count",
+	    CTLFLAG_RD, &sc->stats.rerc,
+	    "Receive Error Count (RERC)");
 	SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "crc_errs",
 	    CTLFLAG_RD, &sc->stats.crcerrs,
 	    "CRC errors");
@@ -2987,6 +2995,9 @@ igc_add_hw_stats(struct igc_softc *sc)
 	SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "good_pkts_txd",
 	    CTLFLAG_RD, &sc->stats.gptc,
 	    "Good Packets Transmitted");
+	SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "host_tx_discarded",
+	    CTLFLAG_RD, &sc->stats.htdpmc,
+	    "Host Packets Discarded by Transmit MAC");
 	SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "bcast_pkts_txd",
 	    CTLFLAG_RD, &sc->stats.bptc,
 	    "Broadcast Packets Transmitted");
diff --git a/sys/dev/igc/igc_hw.h b/sys/dev/igc/igc_hw.h
index 864564c42a22..001c2f0b104a 100644
--- a/sys/dev/igc/igc_hw.h
+++ b/sys/dev/igc/igc_hw.h
@@ -275,6 +275,7 @@ struct igc_hw_stats {
 	u64 mcc;
 	u64 latecol;
 	u64 colc;
+	u64 rerc;
 	u64 dc;
 	u64 tncrs;
 	u64 sec;
diff --git a/sys/dev/igc/igc_mac.c b/sys/dev/igc/igc_mac.c
index ab49708837cc..2afba299e147 100644
--- a/sys/dev/igc/igc_mac.c
+++ b/sys/dev/igc/igc_mac.c
@@ -408,6 +408,7 @@ void igc_clear_hw_cntrs_base_generic(struct igc_hw *hw)
 	DEBUGFUNC("igc_clear_hw_cntrs_base_generic");
 
 	IGC_READ_REG(hw, IGC_CRCERRS);
+	IGC_READ_REG(hw, IGC_RXERRC);
 	IGC_READ_REG(hw, IGC_MPC);
 	IGC_READ_REG(hw, IGC_SCC);
 	IGC_READ_REG(hw, IGC_ECOL);
diff --git a/sys/dev/igc/igc_regs.h b/sys/dev/igc/igc_regs.h
index 17fa89e492e8..f4690e24c2af 100644
--- a/sys/dev/igc/igc_regs.h
+++ b/sys/dev/igc/igc_regs.h
@@ -150,6 +150,7 @@
 /* Statistics Register Descriptions */
 #define IGC_CRCERRS		0x04000  /* CRC Error Count - R/clr */
 #define IGC_ALGNERRC		0x04004  /* Alignment Error Count - R/clr */
+#define IGC_RXERRC		0x0400C  /* Receive Error Count - R/clr */
 #define IGC_MPC			0x04010  /* Missed Packet Count - R/clr */
 #define IGC_SCC			0x04014  /* Single Collision Count - R/clr */
 #define IGC_ECOL		0x04018  /* Excessive Collision Count - R/clr */


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a706f8f.43833.7e96c267>