em/emx/igb/ix: Increase opackets stats in if_start method
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 24 Apr 2015 12:30:36 +0000 (20:30 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 27 Apr 2015 03:24:19 +0000 (11:24 +0800)
Since these drivers TX interrupt are aggressively aggregated, increasing
opackets at TX interrupt time will make the opackets statistics vastly
inaccurate.

Noticed-by: dillon@
sys/dev/netif/em/if_em.c
sys/dev/netif/emx/if_emx.c
sys/dev/netif/igb/if_igb.c
sys/dev/netif/ix/if_ix.c

index 75a556f..938ca9e 100644 (file)
@@ -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);
index 821c2b8..824590e 100644 (file)
@@ -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);
index 3006c10..8bed400 100644 (file)
@@ -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;
index 7c52cd8..519b38c 100644 (file)
@@ -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;