Fix an issue initially reported by drahn@ with gem(4) where these
authorbrad <brad@openbsd.org>
Sat, 30 Aug 2008 07:39:12 +0000 (07:39 +0000)
committerbrad <brad@openbsd.org>
Sat, 30 Aug 2008 07:39:12 +0000 (07:39 +0000)
drivers can report 2-3x times the number of actual packets being
transmitted by only incrementing the counter for descriptors with
buffers being freed.

ok kettenis@

sys/dev/ic/gem.c
sys/dev/pci/if_cas.c

index d5d17fb..31a16ba 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: gem.c,v 1.76 2008/08/26 21:06:29 kettenis Exp $       */
+/*     $OpenBSD: gem.c,v 1.77 2008/08/30 07:39:12 brad Exp $   */
 /*     $NetBSD: gem.c,v 1.1 2001/09/16 00:11:43 eeh Exp $ */
 
 /*
@@ -1619,9 +1619,9 @@ gem_tint(struct gem_softc *sc, u_int32_t status)
                        bus_dmamap_unload(sc->sc_dmatag, sd->sd_map);
                        m_freem(sd->sd_mbuf);
                        sd->sd_mbuf = NULL;
+                       ifp->if_opackets++;
                }
                sc->sc_tx_cnt--;
-               ifp->if_opackets++;
                if (++cons == GEM_NTXDESC)
                        cons = 0;
        }
index 35b09af..cc37c7c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_cas.c,v 1.19 2008/05/31 22:49:03 kettenis Exp $    */
+/*     $OpenBSD: if_cas.c,v 1.20 2008/08/30 07:39:12 brad Exp $        */
 
 /*
  *
@@ -1937,9 +1937,9 @@ cas_tint(struct cas_softc *sc, u_int32_t status)
                        bus_dmamap_unload(sc->sc_dmatag, sd->sd_map);
                        m_freem(sd->sd_mbuf);
                        sd->sd_mbuf = NULL;
+                       ifp->if_opackets++;
                }
                sc->sc_tx_cnt--;
-               ifp->if_opackets++;
                if (++cons == CAS_NTXDESC)
                        cons = 0;
        }