From: Sepherosa Ziehau Date: Fri, 24 Apr 2015 12:30:36 +0000 (+0800) Subject: em/emx/igb/ix: Increase opackets stats in if_start method X-Git-Tag: v4.2.0rc~299 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/608dda762b4fff99bd8e99e1393ec28dcad1cff8 em/emx/igb/ix: Increase opackets stats in if_start method Since these drivers TX interrupt are aggressively aggregated, increasing opackets at TX interrupt time will make the opackets statistics vastly inaccurate. Noticed-by: dillon@ --- diff --git a/sys/dev/netif/em/if_em.c b/sys/dev/netif/em/if_em.c index 75a556f7d0..938ca9ecb5 100644 --- a/sys/dev/netif/em/if_em.c +++ b/sys/dev/netif/em/if_em.c @@ -1043,6 +1043,14 @@ em_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) continue; } + /* + * TX interrupt are aggressively aggregated, so increasing + * opackets at TX interrupt time will make the opackets + * statistics vastly inaccurate; we do the opackets increment + * now. + */ + IFNET_STAT_INC(ifp, opackets, 1); + if (nsegs >= adapter->tx_wreg_nsegs && idx >= 0) { E1000_WRITE_REG(&adapter->hw, E1000_TDT(0), idx); nsegs = 0; @@ -2970,7 +2978,6 @@ em_txeof(struct adapter *adapter) tx_buffer = &adapter->tx_buffer_area[first]; if (tx_buffer->m_head) { - IFNET_STAT_INC(ifp, opackets, 1); bus_dmamap_unload(adapter->txtag, tx_buffer->map); m_freem(tx_buffer->m_head); @@ -3028,7 +3035,6 @@ em_tx_collect(struct adapter *adapter) tx_buffer = &adapter->tx_buffer_area[first]; if (tx_buffer->m_head) { - IFNET_STAT_INC(ifp, opackets, 1); bus_dmamap_unload(adapter->txtag, tx_buffer->map); m_freem(tx_buffer->m_head); diff --git a/sys/dev/netif/emx/if_emx.c b/sys/dev/netif/emx/if_emx.c index 821c2b8280..824590e8e6 100644 --- a/sys/dev/netif/emx/if_emx.c +++ b/sys/dev/netif/emx/if_emx.c @@ -1035,6 +1035,14 @@ emx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) continue; } + /* + * TX interrupt are aggressively aggregated, so increasing + * opackets at TX interrupt time will make the opackets + * statistics vastly inaccurate; we do the opackets increment + * now. + */ + IFNET_STAT_INC(ifp, opackets, 1); + if (nsegs >= tdata->tx_wreg_nsegs) { E1000_WRITE_REG(&sc->hw, E1000_TDT(tdata->idx), idx); nsegs = 0; @@ -2529,7 +2537,6 @@ emx_txcsum(struct emx_txdata *tdata, struct mbuf *mp, static void emx_txeof(struct emx_txdata *tdata) { - struct ifnet *ifp = &tdata->sc->arpcom.ac_if; struct emx_txbuf *tx_buffer; int first, num_avail; @@ -2560,7 +2567,6 @@ emx_txeof(struct emx_txdata *tdata) tx_buffer = &tdata->tx_buf[first]; if (tx_buffer->m_head) { - IFNET_STAT_INC(ifp, opackets, 1); bus_dmamap_unload(tdata->txtag, tx_buffer->map); m_freem(tx_buffer->m_head); @@ -2594,7 +2600,6 @@ emx_txeof(struct emx_txdata *tdata) static void emx_tx_collect(struct emx_txdata *tdata) { - struct ifnet *ifp = &tdata->sc->arpcom.ac_if; struct emx_txbuf *tx_buffer; int tdh, first, num_avail, dd_idx = -1; @@ -2618,7 +2623,6 @@ emx_tx_collect(struct emx_txdata *tdata) tx_buffer = &tdata->tx_buf[first]; if (tx_buffer->m_head) { - IFNET_STAT_INC(ifp, opackets, 1); bus_dmamap_unload(tdata->txtag, tx_buffer->map); m_freem(tx_buffer->m_head); diff --git a/sys/dev/netif/igb/if_igb.c b/sys/dev/netif/igb/if_igb.c index 3006c10b44..8bed40033e 100644 --- a/sys/dev/netif/igb/if_igb.c +++ b/sys/dev/netif/igb/if_igb.c @@ -2112,7 +2112,6 @@ igb_txcsum_ctx(struct igb_tx_ring *txr, struct mbuf *mp) static void igb_txeof(struct igb_tx_ring *txr) { - struct ifnet *ifp = &txr->sc->arpcom.ac_if; int first, hdr, avail; if (txr->tx_avail == txr->num_tx_desc) @@ -2133,7 +2132,6 @@ igb_txeof(struct igb_tx_ring *txr) bus_dmamap_unload(txr->tx_tag, txbuf->map); m_freem(txbuf->m_head); txbuf->m_head = NULL; - IFNET_STAT_INC(ifp, opackets, 1); } if (++first == txr->num_tx_desc) first = 0; @@ -3522,6 +3520,14 @@ igb_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) continue; } + /* + * TX interrupt are aggressively aggregated, so increasing + * opackets at TX interrupt time will make the opackets + * statistics vastly inaccurate; we do the opackets increment + * now. + */ + IFNET_STAT_INC(ifp, opackets, 1); + if (nsegs >= txr->wreg_nsegs) { E1000_WRITE_REG(&txr->sc->hw, E1000_TDT(txr->me), idx); idx = -1; diff --git a/sys/dev/netif/ix/if_ix.c b/sys/dev/netif/ix/if_ix.c index 7c52cd8d6d..519b38c925 100644 --- a/sys/dev/netif/ix/if_ix.c +++ b/sys/dev/netif/ix/if_ix.c @@ -629,6 +629,14 @@ ix_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) continue; } + /* + * TX interrupt are aggressively aggregated, so increasing + * opackets at TX interrupt time will make the opackets + * statistics vastly inaccurate; we do the opackets increment + * now. + */ + IFNET_STAT_INC(ifp, opackets, 1); + if (nsegs >= txr->tx_wreg_nsegs) { IXGBE_WRITE_REG(&sc->hw, IXGBE_TDT(txr->tx_idx), idx); nsegs = 0; @@ -2065,7 +2073,6 @@ ix_tso_ctx_setup(struct ix_tx_ring *txr, const struct mbuf *mp, static void ix_txeof(struct ix_tx_ring *txr, int hdr) { - struct ifnet *ifp = &txr->tx_sc->arpcom.ac_if; int first, avail; if (txr->tx_avail == txr->tx_ndesc) @@ -2084,7 +2091,6 @@ ix_txeof(struct ix_tx_ring *txr, int hdr) bus_dmamap_unload(txr->tx_tag, txbuf->map); m_freem(txbuf->m_head); txbuf->m_head = NULL; - IFNET_STAT_INC(ifp, opackets, 1); } if (++first == txr->tx_ndesc) first = 0;