git: c7c8b80659f5 - stable/12 - if_dwc: avoid duplicate packet counts

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 11 Aug 2022 14:53:20 UTC
The branch stable/12 has been updated by mhorne:

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

commit c7c8b80659f5e03a6a1c87a643e18e0ab929e286
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-06-21 13:24:25 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-08-11 14:52:03 +0000

    if_dwc: avoid duplicate packet counts
    
    We already increment the unicast IPACKETS and OPACKETS counters in the
    rx/tx paths, respectively. Multicast packets are counted in the generic
    ethernet code. Therefore, we shouldn't increment these counters in
    dwc_harvest_stats().
    
    Drop the early return from dwc_rxfinish_one() so that we still count
    received packets with e.g. a checksum error.
    
    PR:             263817
    Reported by:    Jiahao LI <jiahali@blackberry.com>
    Reviewed by:    manu
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D35499
    
    (cherry picked from commit 9718759043ec2ef36f12b15963194b866d731b5b)
---
 sys/dev/dwc/if_dwc.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c
index 919f8fee1527..934c19f8c419 100644
--- a/sys/dev/dwc/if_dwc.c
+++ b/sys/dev/dwc/if_dwc.c
@@ -747,14 +747,6 @@ dwc_rxfinish_one(struct dwc_softc *sc, struct dwc_hwdesc *desc,
 	m = map->mbuf;
 	ifp = sc->ifp;
 	rdesc0 = desc ->desc0;
-	/* Validate descriptor. */
-	if (rdesc0 & RDESC0_ES) {
-		/*
-		 * Errored packet. Statistic counters are updated
-		 * globally, so do nothing
-		 */
-		return (NULL);
-	}
 
 	if ((rdesc0 & (RDESC0_FS | RDESC0_LS)) !=
 		    (RDESC0_FS | RDESC0_LS)) {
@@ -1268,16 +1260,12 @@ dwc_harvest_stats(struct dwc_softc *sc)
 	sc->stats_harvest_count = 0;
 	ifp = sc->ifp;
 
-	if_inc_counter(ifp, IFCOUNTER_IPACKETS, READ4(sc, RXFRAMECOUNT_GB));
-	if_inc_counter(ifp, IFCOUNTER_IMCASTS, READ4(sc, RXMULTICASTFRAMES_G));
 	if_inc_counter(ifp, IFCOUNTER_IERRORS,
 	    READ4(sc, RXOVERSIZE_G) + READ4(sc, RXUNDERSIZE_G) +
 	    READ4(sc, RXCRCERROR) + READ4(sc, RXALIGNMENTERROR) +
 	    READ4(sc, RXRUNTERROR) + READ4(sc, RXJABBERERROR) +
 	    READ4(sc, RXLENGTHERROR));
 
-	if_inc_counter(ifp, IFCOUNTER_OPACKETS, READ4(sc, TXFRAMECOUNT_G));
-	if_inc_counter(ifp, IFCOUNTER_OMCASTS, READ4(sc, TXMULTICASTFRAMES_G));
 	if_inc_counter(ifp, IFCOUNTER_OERRORS,
 	    READ4(sc, TXOVERSIZE_G) + READ4(sc, TXEXCESSDEF) +
 	    READ4(sc, TXCARRIERERR) + READ4(sc, TXUNDERFLOWERROR));