if: Per-cpu ifnet/ifaddr statistics, step 1/3
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 13 Feb 2013 06:00:14 +0000 (14:00 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 15 Feb 2013 03:45:05 +0000 (11:45 +0800)
Wrap ifnet/ifaddr stats updating, setting and extraction into macros;
ease upcoming changes.

127 files changed:
sys/bus/u4b/net/if_axe.c
sys/bus/u4b/net/if_udav.c
sys/bus/u4b/net/usb_ethernet.c
sys/dev/atm/en/midway.c
sys/dev/netif/acx/if_acx.c
sys/dev/netif/ae/if_ae.c
sys/dev/netif/age/if_age.c
sys/dev/netif/alc/if_alc.c
sys/dev/netif/ale/if_ale.c
sys/dev/netif/an/if_an.c
sys/dev/netif/ar/if_ar.c
sys/dev/netif/ath/ath/if_ath.c
sys/dev/netif/aue/if_aue.c
sys/dev/netif/axe/if_axe.c
sys/dev/netif/bce/if_bce.c
sys/dev/netif/bfe/if_bfe.c
sys/dev/netif/bge/if_bge.c
sys/dev/netif/bnx/if_bnx.c
sys/dev/netif/bwi/if_bwi.c
sys/dev/netif/cs/if_cs.c
sys/dev/netif/cue/if_cue.c
sys/dev/netif/dc/if_dc.c
sys/dev/netif/de/if_de.c
sys/dev/netif/ed/if_ed.c
sys/dev/netif/em/if_em.c
sys/dev/netif/emx/if_emx.c
sys/dev/netif/ep/if_ep.c
sys/dev/netif/et/if_et.c
sys/dev/netif/ex/if_ex.c
sys/dev/netif/fe/if_fe.c
sys/dev/netif/fwe/if_fwe.c
sys/dev/netif/fxp/if_fxp.c
sys/dev/netif/ic/if_ic.c
sys/dev/netif/igb/if_igb.c
sys/dev/netif/iwi/if_iwi.c
sys/dev/netif/iwl/iwl2100.c
sys/dev/netif/iwn/if_iwn.c
sys/dev/netif/ixgbe/ixgbe.c
sys/dev/netif/jme/if_jme.c
sys/dev/netif/kue/if_kue.c
sys/dev/netif/lge/if_lge.c
sys/dev/netif/lgue/if_lgue.c
sys/dev/netif/lnc/am7990.c
sys/dev/netif/lnc/am79900.c
sys/dev/netif/lnc/lance.c
sys/dev/netif/msk/if_msk.c
sys/dev/netif/mxge/if_mxge.c
sys/dev/netif/my/if_my.c
sys/dev/netif/ndis/if_ndis.c
sys/dev/netif/nfe/if_nfe.c
sys/dev/netif/nge/if_nge.c
sys/dev/netif/pcn/if_pcn.c
sys/dev/netif/plip/if_plip.c
sys/dev/netif/ral/rt2560.c
sys/dev/netif/ral/rt2661.c
sys/dev/netif/re/if_re.c
sys/dev/netif/rl/if_rl.c
sys/dev/netif/rtw/rtw.c
sys/dev/netif/rue/if_rue.c
sys/dev/netif/rum/if_rum.c
sys/dev/netif/sbni/if_sbni.c
sys/dev/netif/sbsh/if_sbsh.c
sys/dev/netif/sf/if_sf.c
sys/dev/netif/sis/if_sis.c
sys/dev/netif/sk/if_sk.c
sys/dev/netif/sln/if_sln.c
sys/dev/netif/sn/if_sn.c
sys/dev/netif/sr/if_sr.c
sys/dev/netif/ste/if_ste.c
sys/dev/netif/stge/if_stge.c
sys/dev/netif/ti/if_ti.c
sys/dev/netif/tl/if_tl.c
sys/dev/netif/tx/if_tx.c
sys/dev/netif/txp/if_txp.c
sys/dev/netif/ural/if_ural.c
sys/dev/netif/vge/if_vge.c
sys/dev/netif/vr/if_vr.c
sys/dev/netif/vx/if_vx.c
sys/dev/netif/wb/if_wb.c
sys/dev/netif/wi/if_wi.c
sys/dev/netif/wpi/if_wpi.c
sys/dev/netif/xe/if_xe.c
sys/dev/netif/xl/if_xl.c
sys/dev/virtual/vkernel/net/if_vke.c
sys/net/bridge/if_bridge.c
sys/net/disc/if_disc.c
sys/net/ef/if_ef.c
sys/net/faith/if_faith.c
sys/net/gif/if_gif.c
sys/net/gre/if_gre.c
sys/net/if.c
sys/net/if_atmsubr.c
sys/net/if_ethersubr.c
sys/net/if_loop.c
sys/net/if_var.h
sys/net/ifq_var.h
sys/net/pf/if_pflog.c
sys/net/pf/if_pfsync.c
sys/net/ppp/if_ppp.c
sys/net/ppp_layer/ppp_tty.c
sys/net/sl/if_sl.c
sys/net/sppp/if_spppsubr.c
sys/net/stf/if_stf.c
sys/net/tap/if_tap.c
sys/net/tun/if_tun.c
sys/net/vlan/if_vlan.c
sys/netgraph/eiface/ng_eiface.c
sys/netgraph/fec/ng_fec.c
sys/netgraph/iface/ng_iface.c
sys/netgraph7/iface/ng_iface.c
sys/netinet/ip_carp.c
sys/netinet/ip_gre.c
sys/netinet/ip_input.c
sys/netinet/ip_output.c
sys/netinet6/ip6_input.c
sys/netinet6/ip6_output.c
sys/netproto/802_11/wlan/ieee80211.c
sys/netproto/802_11/wlan/ieee80211_adhoc.c
sys/netproto/802_11/wlan/ieee80211_hostap.c
sys/netproto/802_11/wlan/ieee80211_input.c
sys/netproto/802_11/wlan/ieee80211_mesh.c
sys/netproto/802_11/wlan/ieee80211_monitor.c
sys/netproto/802_11/wlan/ieee80211_output.c
sys/netproto/802_11/wlan/ieee80211_sta.c
sys/netproto/802_11/wlan/ieee80211_superg.c
sys/netproto/802_11/wlan/ieee80211_wds.c
sys/netproto/ipx/ipx_ip.c

index ab4e16a..47d2b17 100644 (file)
@@ -1116,7 +1116,7 @@ axe_rx_frame(struct usb_ether *ue, struct usb_page_cache *pc, int actlen)
                axe_rxeof(ue, pc, 0, actlen, NULL);
 
        if (error != 0)
-               ue->ue_ifp->if_ierrors++;
+               IFNET_STAT_INC(ue->ue_ifp, ierrors, 1);
        return (error);
 }
 
@@ -1128,13 +1128,13 @@ axe_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned int offset,
        struct mbuf *m;
 
        if (len < ETHER_HDR_LEN || len > MCLBYTES - ETHER_ALIGN) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return (EINVAL);
        }
 
        m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
        if (m == NULL) {
-               ifp->if_iqdrops++;
+               IFNET_STAT_INC(ifp, iqdrops, 1);
                return (ENOMEM);
        }
        m->m_len = m->m_pkthdr.len = MCLBYTES;
@@ -1142,7 +1142,7 @@ axe_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned int offset,
 
        usbd_copy_out(pc, offset, mtod(m, uint8_t *), len);
 
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = len;
 
@@ -1255,7 +1255,7 @@ tr_setup:
                         * multiple writes into single one if there is
                         * room in TX buffer of controller.
                         */
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
 
                        /*
                         * if there's a BPF listener, bounce a copy
@@ -1280,7 +1280,7 @@ tr_setup:
                DPRINTFN(11, "transfer error, %s\n",
                    usbd_errstr(error));
 
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                ifq_clr_oactive(&ifp->if_snd);
                if (error != USB_ERR_CANCELLED) {
                        /* try to clear stall first */
index 188945c..7acb9dc 100644 (file)
@@ -555,7 +555,7 @@ udav_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
        switch (USB_GET_STATE(xfer)) {
        case USB_ST_TRANSFERRED:
                DPRINTFN(11, "transfer complete\n");
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
                /* FALLTHROUGH */
        case USB_ST_SETUP:
@@ -611,7 +611,7 @@ tr_setup:
                DPRINTFN(11, "transfer error, %s\n",
                    usbd_errstr(error));
 
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
 
                if (error != USB_ERR_CANCELLED) {
                        /* try to clear stall first */
@@ -639,7 +639,7 @@ udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
        case USB_ST_TRANSFERRED:
 
                if (actlen < sizeof(stat) + ETHER_CRC_LEN) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto tr_setup;
                }
                pc = usbd_xfer_get_frame(xfer, 0);
@@ -649,11 +649,11 @@ udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
                len -= ETHER_CRC_LEN;
 
                if (stat.rxstat & UDAV_RSR_LCS) {
-                       ifp->if_collisions++;
+                       IFNET_STAT_INC(ifp, collisions, 1);
                        goto tr_setup;
                }
                if (stat.rxstat & UDAV_RSR_ERR) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto tr_setup;
                }
                uether_rxbuf(ue, pc, sizeof(stat), len);
index 942b7d1..6937615 100644 (file)
@@ -597,7 +597,7 @@ uether_rxmbuf(struct usb_ether *ue, struct mbuf *m,
        UE_LOCK_ASSERT(ue);
 
        /* finalize mbuf */
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = len;
 
@@ -620,14 +620,14 @@ uether_rxbuf(struct usb_ether *ue, struct usb_page_cache *pc,
 
        m = uether_newbuf();
        if (m == NULL) {
-               ifp->if_iqdrops++;
+               IFNET_STAT_INC(ifp, iqdrops, 1);
                return (ENOMEM);
        }
 
        usbd_copy_out(pc, offset, mtod(m, uint8_t *), len);
 
        /* finalize mbuf */
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = len;
 
index ff68193..d53c7ee 100644 (file)
@@ -1926,7 +1926,7 @@ again:
 
   EN_COUNT(sc->launch);
   ifp = &sc->enif;
-  ifp->if_opackets++;
+  IFNET_STAT_INC(ifp, opackets, 1);
   
   if ((launch.atm_flags & EN_OBHDR) == 0) {
     EN_COUNT(sc->lheader);
@@ -2516,7 +2516,7 @@ en_intr(void *arg)
 #endif
 
          ifp = &sc->enif;
-         ifp->if_ipackets++;
+         IFNET_STAT_INC(ifp, ipackets, 1);
 
          BPF_MTAP(ifp, m);
 
@@ -2746,7 +2746,7 @@ defer:                                    /* defer processing */
        fill = tlen;
 
        ifp = &sc->enif;
-       ifp->if_ierrors++;
+       IFNET_STAT_INC(ifp, ierrors, 1);
 
       }
       mlen = tlen - fill;
index d0f7af5..f4ec703 100644 (file)
@@ -1166,7 +1166,7 @@ acx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        if (m->m_len < sizeof(struct ether_header)) {
                                m = m_pullup(m, sizeof(struct ether_header));
                                if (m == NULL) {
-                                       ifp->if_oerrors++;
+                                       IFNET_STAT_INC(ifp, oerrors, 1);
                                        continue;
                                }
                        }
@@ -1175,7 +1175,7 @@ acx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        ni = ieee80211_find_txnode(ic, eh->ether_dhost);
                        if (ni == NULL) {
                                m_freem(m);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
 
@@ -1186,7 +1186,7 @@ acx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        m = ieee80211_encap(ic, m, ni);
                        if (m == NULL) {
                                ieee80211_free_node(ni);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
                } else {
@@ -1202,7 +1202,7 @@ acx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        if (ieee80211_crypto_encap(ic, ni, m) == NULL) {
                                ieee80211_free_node(ni);
                                m_freem(m);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
                }
@@ -1223,7 +1223,7 @@ acx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                         */
                        if (ni != NULL)
                                ieee80211_free_node(ni);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        continue;
                }
 
@@ -1262,7 +1262,7 @@ acx_watchdog(struct ifnet *ifp)
        if (sc->sc_tx_timer) {
                if (--sc->sc_tx_timer == 0) {
                        if_printf(ifp, "watchdog timeout\n");
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        acx_txeof(ifp->if_softc);
                } else {
                        ifp->if_timer = 1;
@@ -1348,9 +1348,9 @@ acx_txeof(struct acx_softc *sc)
                error = FW_TXDESC_GETFIELD_1(sc, buf, f_tx_error);
                if (error) {
                        acx_txerr(sc, error);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                } else {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                }
 
                if (buf->tb_node != NULL) {
@@ -1507,7 +1507,7 @@ acx_rxeof(struct acx_softc *sc)
 
                error = acx_newbuf(sc, buf, 0);
                if (error) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto next;
                }
 
@@ -1577,7 +1577,7 @@ acx_rxeof(struct acx_softc *sc)
                                        le32toh(head->rbh_time));
                        ieee80211_free_node(ni);
 
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
                } else {
                        if (len < sizeof(struct ieee80211_frame_min)) {
                                if (ic->ic_rawbpf != NULL &&
index 63209a4..14ed240 100644 (file)
@@ -666,15 +666,15 @@ ae_rx_intr(struct ae_softc *sc)
                 */
                sc->rxd_cur = (sc->rxd_cur + 1) % AE_RXD_COUNT_DEFAULT;
                if ((flags & AE_RXD_SUCCESS) == 0) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        continue;
                }
 
                error = ae_rxeof(sc, rxd);
                if (error)
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                else
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
        }
 
        /* Update Rx index. */
@@ -724,9 +724,9 @@ ae_tx_intr(struct ae_softc *sc)
                sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) + 4 + 3) & ~3) %
                    AE_TXD_BUFSIZE_DEFAULT;
                if ((flags & AE_TXS_SUCCESS) != 0)
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                else
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                sc->tx_inproc--;
        }
 
@@ -988,7 +988,7 @@ ae_watchdog(struct ifnet *ifp)
                if_printf(ifp, "watchdog timeout (missed link).\n");
        else
                if_printf(ifp, "watchdog timeout - resetting.\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        ae_init(sc);
        if (!ifq_is_empty(&ifp->if_snd))
index 164eead..e8f0452 100644 (file)
@@ -1635,7 +1635,7 @@ age_watchdog(struct ifnet *ifp)
 
        if ((sc->age_flags & AGE_FLAG_LINK) == 0) {
                if_printf(ifp, "watchdog timeout (missed link)\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                age_init(sc);
                return;
        }
@@ -1649,7 +1649,7 @@ age_watchdog(struct ifnet *ifp)
        }
 
        if_printf(ifp, "watchdog timeout\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        age_init(sc);
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -1847,22 +1847,22 @@ age_stats_update(struct age_softc *sc)
        stat->tx_mcast_bytes += smb->tx_mcast_bytes;
 
        /* Update counters in ifnet. */
-       ifp->if_opackets += smb->tx_frames;
+       IFNET_STAT_INC(ifp, opackets, smb->tx_frames);
 
-       ifp->if_collisions += smb->tx_single_colls +
+       IFNET_STAT_INC(ifp, collisions, smb->tx_single_colls +
            smb->tx_multi_colls + smb->tx_late_colls +
-           smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT;
+           smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT);
 
-       ifp->if_oerrors += smb->tx_excess_colls +
+       IFNET_STAT_INC(ifp, oerrors, smb->tx_excess_colls +
            smb->tx_late_colls + smb->tx_underrun +
-           smb->tx_pkts_truncated;
+           smb->tx_pkts_truncated);
 
-       ifp->if_ipackets += smb->rx_frames;
+       IFNET_STAT_INC(ifp, ipackets, smb->rx_frames);
 
-       ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+       IFNET_STAT_INC(ifp, ierrors, smb->rx_crcerrs + smb->rx_lenerrs +
            smb->rx_runts + smb->rx_pkts_truncated +
            smb->rx_fifo_oflows + smb->rx_desc_oflows +
-           smb->rx_alignerrs;
+           smb->rx_alignerrs);
 
        /* Update done, clear. */
        smb->updated = 0;
@@ -2043,7 +2043,7 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd)
                desc = rxd->rx_desc;
                /* Add a new receive buffer to the ring. */
                if (age_newbuf(sc, rxd, 0) != 0) {
-                       ifp->if_iqdrops++;
+                       IFNET_STAT_INC(ifp, iqdrops, 1);
                        /* Reuse Rx buffers. */
                        if (sc->age_cdata.age_rxhead != NULL) {
                                m_freem(sc->age_cdata.age_rxhead);
index 572c075..27d7a22 100644 (file)
@@ -2244,12 +2244,12 @@ alc_watchdog(struct alc_softc *sc)
 
        if ((sc->alc_flags & ALC_FLAG_LINK) == 0) {
                if_printf(sc->alc_ifp, "watchdog timeout (lost link)\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                alc_init(sc);
                return;
        }
        if_printf(sc->alc_ifp, "watchdog timeout -- resetting\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        alc_init(sc);
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -2516,11 +2516,11 @@ alc_stats_update(struct alc_softc *sc)
        stat->tx_mcast_bytes += smb->tx_mcast_bytes;
 
        /* Update counters in ifnet. */
-       ifp->if_opackets += smb->tx_frames;
+       IFNET_STAT_INC(ifp, opackets, smb->tx_frames);
 
-       ifp->if_collisions += smb->tx_single_colls +
+       IFNET_STAT_INC(ifp, collisions, smb->tx_single_colls +
            smb->tx_multi_colls * 2 + smb->tx_late_colls +
-           smb->tx_abort * HDPX_CFG_RETRY_DEFAULT;
+           smb->tx_abort * HDPX_CFG_RETRY_DEFAULT);
 
        /*
         * XXX
@@ -2529,15 +2529,15 @@ alc_stats_update(struct alc_softc *sc)
         * the counter name is not correct one so I've removed the
         * counter in output errors.
         */
-       ifp->if_oerrors += smb->tx_abort + smb->tx_late_colls +
-           smb->tx_underrun;
+       IFNET_STAT_INC(ifp, oerrors, smb->tx_abort + smb->tx_late_colls +
+           smb->tx_underrun);
 
-       ifp->if_ipackets += smb->rx_frames;
+       IFNET_STAT_INC(ifp, ipackets, smb->rx_frames);
 
-       ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+       IFNET_STAT_INC(ifp, ierrors, smb->rx_crcerrs + smb->rx_lenerrs +
            smb->rx_runts + smb->rx_pkts_truncated +
            smb->rx_fifo_oflows + smb->rx_rrs_errs +
-           smb->rx_alignerrs;
+           smb->rx_alignerrs);
 
        if ((sc->alc_flags & ALC_FLAG_SMB_BUG) == 0) {
                /* Update done, clear. */
@@ -2804,7 +2804,7 @@ alc_rxeof(struct alc_softc *sc, struct rx_rdesc *rrd)
                mp = rxd->rx_m;
                /* Add a new receive buffer to the ring. */
                if (alc_newbuf(sc, rxd, FALSE) != 0) {
-                       ifp->if_iqdrops++;
+                       IFNET_STAT_INC(ifp, iqdrops, 1);
                        /* Reuse Rx buffers. */
                        if (sc->alc_cdata.alc_rxhead != NULL)
                                m_freem(sc->alc_cdata.alc_rxhead);
index edd92a3..e70c1b4 100644 (file)
@@ -1727,13 +1727,13 @@ ale_watchdog(struct ifnet *ifp)
 
        if ((sc->ale_flags & ALE_FLAG_LINK) == 0) {
                if_printf(ifp, "watchdog timeout (lost link)\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                ale_init(sc);
                return;
        }
 
        if_printf(ifp, "watchdog timeout -- resetting\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        ale_init(sc);
 
        if (!ifq_is_empty(&ifp->if_snd))
@@ -1953,11 +1953,11 @@ ale_stats_update(struct ale_softc *sc)
        stat->tx_mcast_bytes += smb->tx_mcast_bytes;
 
        /* Update counters in ifnet. */
-       ifp->if_opackets += smb->tx_frames;
+       IFNET_STAT_INC(ifp, opackets, smb->tx_frames);
 
-       ifp->if_collisions += smb->tx_single_colls +
+       IFNET_STAT_INC(ifp, collisions, smb->tx_single_colls +
            smb->tx_multi_colls * 2 + smb->tx_late_colls +
-           smb->tx_abort * HDPX_CFG_RETRY_DEFAULT;
+           smb->tx_abort * HDPX_CFG_RETRY_DEFAULT);
 
        /*
         * XXX
@@ -1966,15 +1966,15 @@ ale_stats_update(struct ale_softc *sc)
         * the counter name is not correct one so I've removed the
         * counter in output errors.
         */
-       ifp->if_oerrors += smb->tx_abort + smb->tx_late_colls +
-           smb->tx_underrun;
+       IFNET_STAT_INC(ifp, oerrors, smb->tx_abort + smb->tx_late_colls +
+           smb->tx_underrun);
 
-       ifp->if_ipackets += smb->rx_frames;
+       IFNET_STAT_INC(ifp, ipackets, smb->rx_frames);
 
-       ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+       IFNET_STAT_INC(ifp, ierrors, smb->rx_crcerrs + smb->rx_lenerrs +
            smb->rx_runts + smb->rx_pkts_truncated +
            smb->rx_fifo_oflows + smb->rx_rrs_errs +
-           smb->rx_alignerrs;
+           smb->rx_alignerrs);
 }
 
 static void
@@ -2250,7 +2250,7 @@ ale_rxeof(struct ale_softc *sc)
                m = m_devget((char *)(rs + 1), length - ETHER_CRC_LEN,
                    ETHER_ALIGN, ifp, NULL);
                if (m == NULL) {
-                       ifp->if_iqdrops++;
+                       IFNET_STAT_INC(ifp, iqdrops, 1);
                        ale_rx_update_page(sc, &rx_page, length, &prod);
                        continue;
                }
index 08a9524..dc5735a 100644 (file)
@@ -828,7 +828,7 @@ an_rxeof(struct an_softc *sc)
                        /* read header */
                        if (an_read_data(sc, id, 0x0, (caddr_t)&rx_frame,
                                         sizeof(rx_frame))) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                return;
                        }
 
@@ -851,7 +851,7 @@ an_rxeof(struct an_softc *sc)
                                        if_printf(ifp,
                                                  "oversized packet received "
                                                  "(%d, %d)\n", len, MCLBYTES);
-                                       ifp->if_ierrors++;
+                                       IFNET_STAT_INC(ifp, ierrors, 1);
                                        return;
                                }
 
@@ -877,7 +877,7 @@ an_rxeof(struct an_softc *sc)
                                        if_printf(ifp,
                                                  "oversized packet received "
                                                  "(%d, %d)\n", len, MCLBYTES);
-                                       ifp->if_ierrors++;
+                                       IFNET_STAT_INC(ifp, ierrors, 1);
                                        return;
                                }
 
@@ -895,7 +895,7 @@ an_rxeof(struct an_softc *sc)
                } else {
                        m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
                        if (m == NULL) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                return;
                        }
                        m->m_pkthdr.rcvif = ifp;
@@ -905,7 +905,7 @@ an_rxeof(struct an_softc *sc)
                        /* Read NIC frame header */
                        if (an_read_data(sc, id, 0, (caddr_t)&rx_frame, 
                                         sizeof(rx_frame))) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                return;
                        }
 #endif
@@ -913,11 +913,11 @@ an_rxeof(struct an_softc *sc)
                        if (an_read_data(sc, id, 0x34, 
                                         (caddr_t)&rx_frame_802_3,
                                         sizeof(rx_frame_802_3))) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                return;
                        }
                        if (rx_frame_802_3.an_rx_802_3_status != 0) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                return;
                        }
                        /* Check for insane frame length */
@@ -926,7 +926,7 @@ an_rxeof(struct an_softc *sc)
                                if_printf(ifp,
                                    "oversized packet received (%d, %d)\n",
                                    len, MCLBYTES);
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                return;
                        }
                        m->m_pkthdr.len = m->m_len =
@@ -946,10 +946,10 @@ an_rxeof(struct an_softc *sc)
 
                        if (error) {
                                m_freem(m);
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                return;
                        }
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
 
 #ifdef ANCACHE
                        an_cache_store(sc, m,
@@ -973,7 +973,7 @@ an_rxeof(struct an_softc *sc)
 
                                m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
                                if (m == NULL) {
-                                       ifp->if_ierrors++;
+                                       IFNET_STAT_INC(ifp, ierrors, 1);
                                        return;
                                }
                                m->m_pkthdr.rcvif = ifp;
@@ -996,7 +996,7 @@ an_rxeof(struct an_softc *sc)
                                        if_printf(ifp,
                                                  "oversized packet received "
                                                  "(%d, %d)\n", len, MCLBYTES);
-                                       ifp->if_ierrors++;
+                                       IFNET_STAT_INC(ifp, ierrors, 1);
                                        return;
                                }
 
@@ -1008,7 +1008,7 @@ an_rxeof(struct an_softc *sc)
                                bcopy(buf, (char *)eh,
                                      m->m_pkthdr.len);
                                
-                               ifp->if_ipackets++;
+                               IFNET_STAT_INC(ifp, ipackets, 1);
                                
 #if 0
 #ifdef ANCACHE
@@ -1058,9 +1058,9 @@ an_txeof(struct an_softc *sc, int status)
                id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
 
                if (status & AN_EV_TX_EXC) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                } else
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
 
                for (i = 0; i < AN_TX_RING_CNT; i++) {
                        if (id == sc->an_rdata.an_tx_ring[i]) {
@@ -1074,9 +1074,9 @@ an_txeof(struct an_softc *sc, int status)
                id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
                if (!sc->an_rdata.an_tx_empty){
                        if (status & AN_EV_TX_EXC) {
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                        } else
-                               ifp->if_opackets++;
+                               IFNET_STAT_INC(ifp, opackets, 1);
                        AN_INC(sc->an_rdata.an_tx_cons, AN_MAX_TX_DESC);
                        if (sc->an_rdata.an_tx_prod ==
                            sc->an_rdata.an_tx_cons)
@@ -2686,7 +2686,7 @@ an_watchdog(struct ifnet *ifp)
                an_init_mpi350_desc(sc);        
        an_init(sc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        if_printf(ifp, "device timeout\n");
 }
index a2fded9..6a540bd 100644 (file)
@@ -713,7 +713,7 @@ top_arstart:
 #ifndef NETGRAPH
                BPF_MTAP(ifp, mtx);
                m_freem(mtx);
-               ++sc->ifsppp.pp_if.if_opackets;
+               IFNET_STAT_INC(&sc->ifsppp.pp_if, opackets, 1);
 #else  /* NETGRAPH */
                m_freem(mtx);
                sc->outbytes += len;
@@ -1707,7 +1707,7 @@ ar_get_packets(struct ar_softc *sc)
 #else
                        BPF_MTAP(&sc->ifsppp.pp_if, m);
                        sppp_input(&sc->ifsppp.pp_if, m);
-                       sc->ifsppp.pp_if.if_ipackets++;
+                       IFNET_STAT_INC(&sc->ifsppp.pp_if, ipackets, 1);
 #endif
                        /*
                         * Update the eda to the previous descriptor.
@@ -1741,7 +1741,7 @@ ar_get_packets(struct ar_softc *sc)
                        ar_eat_packet(sc, 1);
 
 #ifndef        NETGRAPH
-                       sc->ifsppp.pp_if.if_ierrors++;
+                       IFNET_STAT_INC(&sc->ifsppp.pp_if, ierrors, 1);
 #else  /* NETGRAPH */
                        sc->ierrors[0]++;
 #endif /* NETGRAPH */
@@ -1800,6 +1800,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
                 * Transmit channel
                 */
                if(isr1 & 0x0C) {
+                       u_long opkt;
+
                        dmac = &sca->dmac[DMAC_TXCH(mch)];
 
                        if(hc->bustype == AR_BUS_ISA)
@@ -1810,37 +1812,37 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
 
                        /* Counter overflow */
                        if(dsr & SCA_DSR_COF) {
-                               kprintf("ar%d: TX DMA Counter overflow, "
-                                       "txpacket no %lu.\n",
-                                       sc->unit,
 #ifndef        NETGRAPH
-                                       sc->ifsppp.pp_if.if_opackets);
-                               sc->ifsppp.pp_if.if_oerrors++;
+                               IFNET_STAT_GET(&sc->ifsppp.pp_if, opackets,
+                                   opkt);
+                               IFNET_STAT_INC(&sc->ifsppp.pp_if, oerrors, 1);
 #else  /* NETGRAPH */
-                                       sc->opackets);
+                               opkt = sc->opackets;
                                sc->oerrors++;
 #endif /* NETGRAPH */
+                               kprintf("ar%d: TX DMA Counter overflow, "
+                                       "txpacket no %lu.\n",
+                                       sc->unit, opkt);
                        }
 
                        /* Buffer overflow */
                        if(dsr & SCA_DSR_BOF) {
+#ifndef        NETGRAPH
+                               IFNET_STAT_GET(&sc->ifsppp.pp_if, opackets,
+                                   opkt);
+                               IFNET_STAT_INC(&sc->ifsppp.pp_if, oerrors, 1);
+#else  /* NETGRAPH */
+                               opkt = sc->opackets,
+                               sc->oerrors++;
+#endif /* NETGRAPH */
                                kprintf("ar%d: TX DMA Buffer overflow, "
                                        "txpacket no %lu, dsr %02x, "
                                        "cda %04x, eda %04x.\n",
                                        sc->unit,
-#ifndef        NETGRAPH
-                                       sc->ifsppp.pp_if.if_opackets,
-#else  /* NETGRAPH */
-                                       sc->opackets,
-#endif /* NETGRAPH */
+                                       opkt,
                                        dsr,
                                        dmac->cda,
                                        dmac->eda);
-#ifndef        NETGRAPH
-                               sc->ifsppp.pp_if.if_oerrors++;
-#else  /* NETGRAPH */
-                               sc->oerrors++;
-#endif /* NETGRAPH */
                        }
 
                        /* End of Transfer */
@@ -1869,6 +1871,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
                 * Receive channel
                 */
                if(isr1 & 0x03) {
+                       u_long ipkt;
+
                        dmac = &sca->dmac[DMAC_RXCH(mch)];
 
                        if(hc->bustype == AR_BUS_ISA)
@@ -1886,11 +1890,12 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
 
                                ar_get_packets(sc);
 #ifndef        NETGRAPH
-#define        IPACKETS sc->ifsppp.pp_if.if_ipackets
+                               IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets,
+                                   ipkt);
 #else  /* NETGRAPH */
-#define        IPACKETS sc->ipackets
+                               ipkt = sc->ipackets
 #endif /* NETGRAPH */
-                               TRC(if(tt == IPACKETS) {
+                               TRC(if(tt == ipkt) {
                                        sca_descriptor *rxdesc;
                                        int i;
 
@@ -1926,36 +1931,39 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
                                                        "len %d.\n",
                                                        rxdesc->stat,
                                                        rxdesc->len);
-                               })
+                               });
                        }
 
                        /* Counter overflow */
                        if(dsr & SCA_DSR_COF) {
-                               kprintf("ar%d: RX DMA Counter overflow, "
-                                       "rxpkts %lu.\n",
-                                       sc->unit,
 #ifndef        NETGRAPH
-                                       sc->ifsppp.pp_if.if_ipackets);
-                               sc->ifsppp.pp_if.if_ierrors++;
+                               IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets,
+                                   ipkt);
+                               IFNET_STAT_INC(&sc->ifsppp.pp_if, ierrors, 1);
 #else  /* NETGRAPH */
-                                       sc->ipackets);
+                               ipkt = sc->ipackets;
                                sc->ierrors[1]++;
 #endif /* NETGRAPH */
+                               kprintf("ar%d: RX DMA Counter overflow, "
+                                       "rxpkts %lu.\n",
+                                       sc->unit, ipkt);
                        }
 
                        /* Buffer overflow */
                        if(dsr & SCA_DSR_BOF) {
+#ifndef        NETGRAPH
+                               IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets,
+                                   ipkt);
+#else  /* NETGRAPH */
+                               ipkt = sc->ipackets;
+#endif /* NETGRAPH */
                                if(hc->bustype == AR_BUS_ISA)
                                        ARC_SET_SCA(hc, scano);
                                kprintf("ar%d: RX DMA Buffer overflow, "
                                        "rxpkts %lu, rxind %d, "
                                        "cda %x, eda %x, dsr %x.\n",
                                        sc->unit,
-#ifndef        NETGRAPH
-                                       sc->ifsppp.pp_if.if_ipackets,
-#else  /* NETGRAPH */
-                                       sc->ipackets,
-#endif /* NETGRAPH */
+                                       ipkt,
                                        sc->rxhind,
                                        dmac->cda,
                                        dmac->eda,
@@ -1966,7 +1974,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
                                 */
                                ar_eat_packet(sc, 0);
 #ifndef        NETGRAPH
-                               sc->ifsppp.pp_if.if_ierrors++;
+                               IFNET_STAT_INC(&sc->ifsppp.pp_if, ierrors, 1);
 #else  /* NETGRAPH */
                                sc->ierrors[2]++;
 #endif /* NETGRAPH */
@@ -1988,6 +1996,14 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
 
                        /* End of Transfer */
                        if(dsr & SCA_DSR_EOT) {
+#ifndef        NETGRAPH
+                               IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets,
+                                   ipkt);
+                               IFNET_STAT_INC(&sc->ifsppp.pp_if, ierrors, 1);
+#else  /* NETGRAPH */
+                               ipkt = sc->ipackets;
+                               sc->ierrors[3]++;
+#endif /* NETGRAPH */
                                /*
                                 * If this happen, it means that we are
                                 * receiving faster than what the processor
@@ -1996,14 +2012,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
                                 * XXX We should enable the dma again.
                                 */
                                kprintf("ar%d: RX End of transfer, rxpkts %lu.\n",
-                                       sc->unit,
-#ifndef        NETGRAPH
-                                       sc->ifsppp.pp_if.if_ipackets);
-                               sc->ifsppp.pp_if.if_ierrors++;
-#else  /* NETGRAPH */
-                                       sc->ipackets);
-                               sc->ierrors[3]++;
-#endif /* NETGRAPH */
+                                       sc->unit, ipkt);
                        }
                }
 
index 0d4f153..c40aada 100644 (file)
@@ -1846,11 +1846,11 @@ ath_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        DPRINTF(sc, ATH_DEBUG_XMIT,
                            "%s: out of txfrag buffers\n", __func__);
                        sc->sc_stats.ast_tx_nofrag++;
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        ath_freetx(m);
                        goto bad;
                }
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
        nextfrag:
                /*
                 * Pass the frame to the h/w for transmission.
@@ -1867,7 +1867,7 @@ ath_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                next = m->m_nextpkt;
                if (ath_tx_start(sc, ni, bf, m)) {
        bad:
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
        reclaim:
                        bf->bf_m = NULL;
                        bf->bf_node = NULL;
@@ -3870,7 +3870,7 @@ ath_rx_task(void *arg, int npending)
                                                rs->rs_keyix-32 : rs->rs_keyix);
                                }
                        }
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
 rx_error:
                        /*
                         * Cleanup any pending partial frame.
@@ -3948,7 +3948,7 @@ rx_accept:
                        m->m_pkthdr.len = len;
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                sc->sc_stats.ast_ant_rx[rs->rs_antenna]++;
 
                /*
@@ -6124,7 +6124,7 @@ ath_watchdog_callout(void *arg)
                } else
                        if_printf(ifp, "device timeout\n");
                ath_reset(ifp);
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                sc->sc_stats.ast_watchdog++;
        }
        callout_reset(&sc->sc_wd_ch, hz, ath_watchdog_callout, sc);
@@ -6233,8 +6233,8 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *ucred)
                break;
        case SIOCGATHSTATS:
                /* NB: embed these numbers to get a consistent view */
-               sc->sc_stats.ast_tx_packets = ifp->if_opackets;
-               sc->sc_stats.ast_rx_packets = ifp->if_ipackets;
+               IFNET_STAT_GET(ifp, opackets, sc->sc_stats.ast_tx_packets);
+               IFNET_STAT_GET(ifp, ipackets, sc->sc_stats.ast_rx_packets);
                sc->sc_stats.ast_tx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgtxrssi);
                sc->sc_stats.ast_rx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgrssi);
 #ifdef IEEE80211_SUPPORT_TDMA
@@ -6989,14 +6989,14 @@ ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
                }
        }
        sc->sc_wd_timer = 5;
-       ifp->if_opackets++;
+       IFNET_STAT_INC(ifp, opackets, 1);
        sc->sc_stats.ast_tx_raw++;
 
        return 0;
 bad2:
        STAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list);
 bad:
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        sc->sc_stats.ast_tx_raw_fail++;
        ieee80211_free_node(ni);
        return error;
index 4b0a97e..57e9b70 100644 (file)
@@ -879,7 +879,7 @@ aue_rxstart(struct ifnet *ifp)
        c = &sc->aue_cdata.aue_rx_chain[sc->aue_cdata.aue_rx_prod];
 
        if (aue_newbuf(sc, c, NULL) == ENOBUFS) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                AUE_UNLOCK(sc);
                return;
        }
@@ -931,7 +931,7 @@ aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
 
        if (total_len <= 4 + ETHER_CRC_LEN) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
@@ -942,14 +942,14 @@ aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        r.aue_rxstat &= AUE_RXSTAT_MASK;
 
        if (r.aue_rxstat) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
        /* No errors; receive the packet. */
        total_len -= (4 + ETHER_CRC_LEN);
 
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = total_len;
 
@@ -991,9 +991,9 @@ aue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
 
        usbd_get_xfer_status(c->aue_xfer, NULL, NULL, NULL, &err);
        if (err)
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        else
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
        /* XXX should hold serializer */
        ifp->if_timer = 0;
@@ -1339,7 +1339,7 @@ aue_watchdog(struct ifnet *ifp)
 
        ASSERT_SERIALIZED(ifp->if_serializer);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        if_printf(ifp, "watchdog timeout\n");
 
        c = &sc->aue_cdata.aue_tx_chain[0];
index 6fd394f..39be2b0 100644 (file)
@@ -582,7 +582,7 @@ axe_rxstart(struct ifnet *ifp)
        c = &sc->axe_cdata.axe_rx_chain[sc->axe_cdata.axe_rx_prod];
 
        if (axe_newbuf(sc, c, NULL) == ENOBUFS) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -632,11 +632,11 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        m = c->axe_mbuf;
 
        if (total_len < sizeof(struct ether_header)) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = total_len;
 
@@ -690,9 +690,9 @@ axe_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        }
 
        if (err)
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        else
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -945,7 +945,7 @@ axe_watchdog(struct ifnet *ifp)
        struct axe_chain *c;
        usbd_status stat;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        if_printf(ifp, "watchdog timeout\n");
 
        c = &sc->axe_cdata.axe_tx_chain[0];
index 602a4a1..9ddb6b8 100644 (file)
@@ -4429,7 +4429,7 @@ bce_rx_intr(struct bce_softc *sc, int count, uint16_t hw_cons)
                                if_printf(ifp, "RX cons(%d) != prod(%d), "
                                          "drop!\n", sw_chain_cons,
                                          sw_chain_prod);
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
 
                                bce_setup_rxdesc_std(sc, sw_chain_cons,
                                                     &sw_prod_bseq);
@@ -4476,7 +4476,7 @@ bce_rx_intr(struct bce_softc *sc, int count, uint16_t hw_cons)
                                      L2_FHDR_ERRORS_ALIGNMENT |
                                      L2_FHDR_ERRORS_TOO_SHORT |
                                      L2_FHDR_ERRORS_GIANT_FRAME)) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
 
                                /* Reuse the mbuf for a new frame. */
                                bce_setup_rxdesc_std(sc, sw_chain_prod,
@@ -4493,7 +4493,7 @@ bce_rx_intr(struct bce_softc *sc, int count, uint16_t hw_cons)
                         */
                        if (bce_newbuf_std(sc, &sw_prod, &sw_chain_prod,
                                           &sw_prod_bseq, 0)) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
 
                                /* Try and reuse the exisitng mbuf. */
                                bce_setup_rxdesc_std(sc, sw_chain_prod,
@@ -4543,7 +4543,7 @@ bce_rx_intr(struct bce_softc *sc, int count, uint16_t hw_cons)
                                }
                        }
 
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
 bce_rx_int_next_rx:
                        sw_prod = NEXT_RX_BD(sw_prod);
                }
@@ -4625,7 +4625,7 @@ bce_tx_intr(struct bce_softc *sc, uint16_t hw_tx_cons)
                        m_freem(sc->tx_mbuf_ptr[sw_tx_chain_cons]);
                        sc->tx_mbuf_ptr[sw_tx_chain_cons] = NULL;
 
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                }
 
                sc->used_tx_bd--;
@@ -5033,7 +5033,7 @@ bce_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                 * to wait for the NIC to drain the chain.
                 */
                if (bce_encap(sc, &m_head, &count)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (sc->used_tx_bd == 0) {
                                continue;
                        } else {
@@ -5203,7 +5203,7 @@ bce_watchdog(struct ifnet *ifp)
        ifp->if_flags &= ~IFF_RUNNING;  /* Force reinitialize */
        bce_init(sc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -5566,8 +5566,8 @@ bce_stats_update(struct bce_softc *sc)
         */
        if (!(BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5706) &&
            !(BCE_CHIP_ID(sc) == BCE_CHIP_ID_5708_A0)) {
-               ifp->if_oerrors +=
-                       (u_long)stats->stat_Dot3StatsCarrierSenseErrors;
+               IFNET_STAT_INC(ifp, oerrors,
+                       (u_long)stats->stat_Dot3StatsCarrierSenseErrors);
        }
 
        /*
@@ -5751,21 +5751,21 @@ bce_stats_update(struct bce_softc *sc)
         * Update the interface statistics from the
         * hardware statistics.
         */
-       ifp->if_collisions = (u_long)sc->stat_EtherStatsCollisions;
+       IFNET_STAT_SET(ifp, collisions, (u_long)sc->stat_EtherStatsCollisions);
 
-       ifp->if_ierrors = (u_long)sc->stat_EtherStatsUndersizePkts +
+       IFNET_STAT_SET(ifp, ierrors, (u_long)sc->stat_EtherStatsUndersizePkts +
            (u_long)sc->stat_EtherStatsOverrsizePkts +
            (u_long)sc->stat_IfInMBUFDiscards +
            (u_long)sc->stat_Dot3StatsAlignmentErrors +
            (u_long)sc->stat_Dot3StatsFCSErrors +
            (u_long)sc->stat_IfInRuleCheckerDiscards +
            (u_long)sc->stat_IfInFTQDiscards +
-           (u_long)sc->com_no_buffers;
+           (u_long)sc->com_no_buffers);
 
-       ifp->if_oerrors =
+       IFNET_STAT_SET(ifp, oerrors,
            (u_long)sc->stat_emac_tx_stat_dot3statsinternalmactransmiterrors +
            (u_long)sc->stat_Dot3StatsExcessiveCollisions +
-           (u_long)sc->stat_Dot3StatsLateCollisions;
+           (u_long)sc->stat_Dot3StatsLateCollisions);
 
        DBPRINT(sc, BCE_EXCESSIVE, "Exiting %s()\n", __func__);
 }
index a27ebff..34317f4 100644 (file)
@@ -1074,7 +1074,7 @@ bfe_txeof(struct bfe_softc *sc)
                struct bfe_data *r = &sc->bfe_tx_ring[i];
 
                if (r->bfe_mbuf != NULL) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        bus_dmamap_unload(sc->bfe_txbuf_tag, r->bfe_map);
                        m_freem(r->bfe_mbuf);
                        r->bfe_mbuf = NULL;
@@ -1122,9 +1122,9 @@ bfe_rxeof(struct bfe_softc *sc)
 
                /* flag an error and try again */
                if (len > ETHER_MAX_LEN + 32 || (flags & BFE_RX_FLAG_ERRORS)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        if (flags & BFE_RX_FLAG_SERR)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
 
                        bfe_setup_rxdesc(sc, cons);
                        BFE_INC(cons, BFE_RX_LIST_CNT);
@@ -1134,7 +1134,7 @@ bfe_rxeof(struct bfe_softc *sc)
                /* Go past the rx header */
                if (bfe_newbuf(sc, cons, 0) != 0) {
                        bfe_setup_rxdesc(sc, cons);
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        BFE_INC(cons, BFE_RX_LIST_CNT);
                        continue;
                }
@@ -1142,7 +1142,7 @@ bfe_rxeof(struct bfe_softc *sc)
                m_adj(m, BFE_RX_OFFSET);
                m->m_len = m->m_pkthdr.len = len;
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                m->m_pkthdr.rcvif = ifp;
 
                ifp->if_input(ifp, m);
@@ -1179,11 +1179,11 @@ bfe_intr(void *xsc)
        if (istat & BFE_ISTAT_ERRORS) {
                flag = CSR_READ_4(sc, BFE_DMATX_STAT);
                if (flag & BFE_STAT_EMASK)
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
 
                flag = CSR_READ_4(sc, BFE_DMARX_STAT);
                if (flag & BFE_RX_FLAG_ERRORS)
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
 
                ifp->if_flags &= ~IFF_RUNNING;
                bfe_init(sc);
@@ -1314,7 +1314,7 @@ bfe_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                 */
                if (bfe_encap(sc, &m_head, &idx)) {
                        /* m_head is freed by re_encap(), if we reach here */
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
 
                        if (sc->bfe_tx_cnt > 0) {
                                ifq_set_oactive(&ifp->if_snd);
@@ -1482,7 +1482,7 @@ bfe_watchdog(struct ifnet *ifp)
        ifp->if_flags &= ~IFF_RUNNING;
        bfe_init(sc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 }
 
 static void
index 9e46978..10bc567 100644 (file)
@@ -2930,7 +2930,7 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int count)
                        jumbocnt++;
 
                        if (rxidx != sc->bge_jumbo) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                if_printf(ifp, "sw jumbo index(%d) "
                                    "and hw jumbo index(%d) mismatch, drop!\n",
                                    sc->bge_jumbo, rxidx);
@@ -2940,12 +2940,12 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int count)
 
                        m = sc->bge_cdata.bge_rx_jumbo_chain[rxidx].bge_mbuf;
                        if (cur_rx->bge_flags & BGE_RXBDFLAG_ERROR) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bge_setup_rxdesc_jumbo(sc, sc->bge_jumbo);
                                continue;
                        }
                        if (bge_newbuf_jumbo(sc, sc->bge_jumbo, 0)) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bge_setup_rxdesc_jumbo(sc, sc->bge_jumbo);
                                continue;
                        }
@@ -2954,7 +2954,7 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int count)
                        stdcnt++;
 
                        if (rxidx != sc->bge_std) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                if_printf(ifp, "sw std index(%d) "
                                    "and hw std index(%d) mismatch, drop!\n",
                                    sc->bge_std, rxidx);
@@ -2964,18 +2964,18 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int count)
 
                        m = sc->bge_cdata.bge_rx_std_chain[rxidx].bge_mbuf;
                        if (cur_rx->bge_flags & BGE_RXBDFLAG_ERROR) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bge_setup_rxdesc_std(sc, sc->bge_std);
                                continue;
                        }
                        if (bge_newbuf_std(sc, sc->bge_std, 0)) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bge_setup_rxdesc_std(sc, sc->bge_std);
                                continue;
                        }
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 #if !defined(__i386__) && !defined(__x86_64__)
                /*
                 * The x86 allows unaligned accesses, but for other
@@ -3039,7 +3039,7 @@ bge_txeof(struct bge_softc *sc, uint16_t tx_cons)
 
                idx = sc->bge_tx_saved_considx;
                if (sc->bge_cdata.bge_tx_chain[idx] != NULL) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        bus_dmamap_unload(sc->bge_cdata.bge_tx_mtag,
                            sc->bge_cdata.bge_tx_dmamap[idx]);
                        m_freem(sc->bge_cdata.bge_tx_chain[idx]);
@@ -3306,12 +3306,11 @@ bge_stats_update_regs(struct bge_softc *sc)
                s++;
        }
 
-       ifp->if_collisions +=
+       IFNET_STAT_SET(ifp, collisions,
           (stats.dot3StatsSingleCollisionFrames +
           stats.dot3StatsMultipleCollisionFrames +
           stats.dot3StatsExcessiveCollisions +
-          stats.dot3StatsLateCollisions) -
-          ifp->if_collisions;
+          stats.dot3StatsLateCollisions));
 }
 
 static void
@@ -3325,7 +3324,7 @@ bge_stats_update(struct bge_softc *sc)
 #define READ_STAT(sc, stats, stat)     \
        CSR_READ_4(sc, stats + offsetof(struct bge_stats, stat))
 
-       ifp->if_collisions +=
+       IFNET_STAT_SET(ifp, collisions,
           (READ_STAT(sc, stats,
                txstats.dot3StatsSingleCollisionFrames.bge_addr_lo) +
            READ_STAT(sc, stats,
@@ -3333,18 +3332,16 @@ bge_stats_update(struct bge_softc *sc)
            READ_STAT(sc, stats,
                txstats.dot3StatsExcessiveCollisions.bge_addr_lo) +
            READ_STAT(sc, stats,
-               txstats.dot3StatsLateCollisions.bge_addr_lo)) -
-          ifp->if_collisions;
+               txstats.dot3StatsLateCollisions.bge_addr_lo)));
 
 #undef READ_STAT
 
 #ifdef notdef
-       ifp->if_collisions +=
+       IFNET_STAT_SET(ifp, collisions,
           (sc->bge_rdata->bge_info.bge_stats.dot3StatsSingleCollisionFrames +
           sc->bge_rdata->bge_info.bge_stats.dot3StatsMultipleCollisionFrames +
           sc->bge_rdata->bge_info.bge_stats.dot3StatsExcessiveCollisions +
-          sc->bge_rdata->bge_info.bge_stats.dot3StatsLateCollisions) -
-          ifp->if_collisions;
+          sc->bge_rdata->bge_info.bge_stats.dot3StatsLateCollisions));
 #endif
 }
 
@@ -3559,7 +3556,7 @@ bge_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                 */
                if (bge_encap(sc, &m_head, &prodidx, &nsegs)) {
                        ifq_set_oactive(&ifp->if_snd);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        break;
                }
 
@@ -3934,7 +3931,7 @@ bge_watchdog(struct ifnet *ifp)
 
        bge_init(sc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
index 6b71bb6..45d4358 100644 (file)
@@ -2513,7 +2513,7 @@ bnx_rxeof(struct bnx_softc *sc, uint16_t rx_prod, int count)
                        jumbocnt++;
 
                        if (rxidx != sc->bnx_jumbo) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                if_printf(ifp, "sw jumbo index(%d) "
                                    "and hw jumbo index(%d) mismatch, drop!\n",
                                    sc->bnx_jumbo, rxidx);
@@ -2523,12 +2523,12 @@ bnx_rxeof(struct bnx_softc *sc, uint16_t rx_prod, int count)
 
                        m = sc->bnx_cdata.bnx_rx_jumbo_chain[rxidx].bnx_mbuf;
                        if (cur_rx->bge_flags & BGE_RXBDFLAG_ERROR) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bnx_setup_rxdesc_jumbo(sc, sc->bnx_jumbo);
                                continue;
                        }
                        if (bnx_newbuf_jumbo(sc, sc->bnx_jumbo, 0)) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bnx_setup_rxdesc_jumbo(sc, sc->bnx_jumbo);
                                continue;
                        }
@@ -2537,7 +2537,7 @@ bnx_rxeof(struct bnx_softc *sc, uint16_t rx_prod, int count)
                        stdcnt++;
 
                        if (rxidx != sc->bnx_std) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                if_printf(ifp, "sw std index(%d) "
                                    "and hw std index(%d) mismatch, drop!\n",
                                    sc->bnx_std, rxidx);
@@ -2547,18 +2547,18 @@ bnx_rxeof(struct bnx_softc *sc, uint16_t rx_prod, int count)
 
                        m = sc->bnx_cdata.bnx_rx_std_chain[rxidx].bnx_mbuf;
                        if (cur_rx->bge_flags & BGE_RXBDFLAG_ERROR) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bnx_setup_rxdesc_std(sc, sc->bnx_std);
                                continue;
                        }
                        if (bnx_newbuf_std(sc, sc->bnx_std, 0)) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                bnx_setup_rxdesc_std(sc, sc->bnx_std);
                                continue;
                        }
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                m->m_pkthdr.len = m->m_len = cur_rx->bge_len - ETHER_CRC_LEN;
                m->m_pkthdr.rcvif = ifp;
 
@@ -2612,7 +2612,7 @@ bnx_txeof(struct bnx_softc *sc, uint16_t tx_cons)
 
                idx = sc->bnx_tx_saved_considx;
                if (sc->bnx_cdata.bnx_tx_chain[idx] != NULL) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        bus_dmamap_unload(sc->bnx_cdata.bnx_tx_mtag,
                            sc->bnx_cdata.bnx_tx_dmamap[idx]);
                        m_freem(sc->bnx_cdata.bnx_tx_chain[idx]);
@@ -2819,12 +2819,11 @@ bnx_stats_update_regs(struct bnx_softc *sc)
                s++;
        }
 
-       ifp->if_collisions +=
+       IFNET_STAT_SET(ifp, collisions,
           (stats.dot3StatsSingleCollisionFrames +
           stats.dot3StatsMultipleCollisionFrames +
           stats.dot3StatsExcessiveCollisions +
-          stats.dot3StatsLateCollisions) -
-          ifp->if_collisions;
+          stats.dot3StatsLateCollisions));
 }
 
 /*
@@ -3011,7 +3010,7 @@ bnx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                 */
                if (bnx_encap(sc, &m_head, &prodidx, &nsegs)) {
                        ifq_set_oactive(&ifp->if_snd);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        break;
                }
 
@@ -3344,7 +3343,7 @@ bnx_watchdog(struct ifnet *ifp)
 
        bnx_init(sc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
index 08b725e..5a6b7b3 100644 (file)
@@ -1613,7 +1613,7 @@ bwi_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        if (m->m_len < sizeof(*eh)) {
                                m = m_pullup(m, sizeof(*eh));
                                if (m == NULL) {
-                                       ifp->if_oerrors++;
+                                       IFNET_STAT_INC(ifp, oerrors, 1);
                                        continue;
                                }
                        }
@@ -1622,7 +1622,7 @@ bwi_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        ni = ieee80211_find_txnode(ic, eh->ether_dhost);
                        if (ni == NULL) {
                                m_freem(m);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
 
@@ -1633,7 +1633,7 @@ bwi_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        m = ieee80211_encap(ic, m, ni);
                        if (m == NULL) {
                                ieee80211_free_node(ni);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
                } else {
@@ -1648,7 +1648,7 @@ bwi_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        if (ieee80211_crypto_encap(ic, ni, m) == NULL) {
                                ieee80211_free_node(ni);
                                m_freem(m);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
                }
@@ -1658,7 +1658,7 @@ bwi_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        /* 'm' is freed in bwi_encap() if we reach here */
                        if (ni != NULL)
                                ieee80211_free_node(ni);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        continue;
                }
 
@@ -1693,7 +1693,7 @@ bwi_watchdog(struct ifnet *ifp)
        if (sc->sc_tx_timer) {
                if (--sc->sc_tx_timer == 0) {
                        if_printf(ifp, "watchdog timeout\n");
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        /* TODO */
                } else {
                        ifp->if_timer = 1;
@@ -2781,7 +2781,7 @@ bwi_rxeof(struct bwi_softc *sc, int end_idx)
                                BUS_DMASYNC_POSTREAD);
 
                if (bwi_newbuf(sc, idx, 0)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto next;
                }
 
@@ -2797,7 +2797,7 @@ bwi_rxeof(struct bwi_softc *sc, int end_idx)
                if (buflen < BWI_FRAME_MIN_LEN(wh_ofs)) {
                        if_printf(ifp, "short frame %d, hdr_extra %d\n",
                                  buflen, hdr_extra);
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        m_freem(m);
                        goto next;
                }
@@ -3311,10 +3311,10 @@ _bwi_txeof(struct bwi_softc *sc, uint16_t tx_id, int acked, int data_txcnt)
                }
 
                if (acked) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        retry = data_txcnt > 0 ? data_txcnt - 1 : 0;
                } else {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        retry = data_txcnt;
                }
 
@@ -3325,7 +3325,7 @@ _bwi_txeof(struct bwi_softc *sc, uint16_t tx_id, int acked, int data_txcnt)
                tb->tb_ni = NULL;
        } else {
                /* XXX mgt packet error */
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
        }
 
        if (tbd->tbd_used == 0)
index 44862bf..670ae39 100644 (file)
@@ -835,7 +835,7 @@ cs_get_packet(struct cs_softc *sc)
 #ifdef CS_DEBUG
                if_printf(ifp, "bad pkt stat %x\n", status);
 #endif
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return -1;
        }
 
@@ -869,7 +869,7 @@ cs_get_packet(struct cs_softc *sc)
            (ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) {
                ifp->if_input(ifp, m);
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 
                if (length==ETHER_MAX_LEN-ETHER_CRC_LEN)
                         DELAY( cs_recv_delay );
@@ -907,9 +907,9 @@ csintr(void *arg)
 
                 case ISQ_TRANSMITTER_EVENT:
                         if (status & TX_OK)
-                                ifp->if_opackets++;
+                                IFNET_STAT_INC(ifp, opackets, 1);
                         else
-                                ifp->if_oerrors++;
+                                IFNET_STAT_INC(ifp, oerrors, 1);
                         ifq_clr_oactive(&ifp->if_snd);
                         ifp->if_timer = 0;
                         break;
@@ -923,16 +923,16 @@ csintr(void *arg)
                         if (status & TX_UNDERRUN) {
                                 ifq_clr_oactive(&ifp->if_snd);
                                 ifp->if_timer = 0;
-                                ifp->if_oerrors++;
+                                IFNET_STAT_INC(ifp, oerrors, 1);
                         }
                         break;
 
                 case ISQ_RX_MISS_EVENT:
-                        ifp->if_ierrors+=(status>>6);
+                        IFNET_STAT_INC(ifp, ierrors, (status>>6));
                         break;
 
                 case ISQ_TX_COL_EVENT:
-                        ifp->if_collisions+=(status>>6);
+                        IFNET_STAT_INC(ifp, collisions, (status>>6));
                         break;
                 }
         }
@@ -1183,7 +1183,7 @@ cs_watchdog(struct ifnet *ifp)
 {
        struct cs_softc *sc = ifp->if_softc;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
 
        /* Reset the interface */
index e00f4ee..8e9475f 100644 (file)
@@ -604,7 +604,7 @@ cue_rxstart(struct ifnet *ifp)
        c = &sc->cue_cdata.cue_rx_chain[sc->cue_cdata.cue_rx_prod];
 
        if (cue_newbuf(sc, c, NULL) == ENOBUFS) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                CUE_UNLOCK(sc);
                return;
        }
@@ -666,11 +666,11 @@ cue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        total_len = len;
 
        if (len < sizeof(struct ether_header)) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m_adj(m, sizeof(u_int16_t));
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = total_len;
@@ -733,9 +733,9 @@ cue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        }
 
        if (err)
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        else
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -760,12 +760,15 @@ cue_tick(void *xsc)
 
        ifp = &sc->arpcom.ac_if;
 
-       ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_SINGLECOLL);
-       ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_MULTICOLL);
-       ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_EXCESSCOLL);
+       IFNET_STAT_INC(ifp, collisions,
+           cue_csr_read_2(sc, CUE_TX_SINGLECOLL));
+       IFNET_STAT_INC(ifp, collisions,
+           cue_csr_read_2(sc, CUE_TX_MULTICOLL));
+       IFNET_STAT_INC(ifp, collisions,
+           cue_csr_read_2(sc, CUE_TX_EXCESSCOLL));
 
        if (cue_csr_read_2(sc, CUE_RX_FRAMEERR))
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
 
        callout_reset(&sc->cue_stat_timer, hz, cue_tick, sc);
 
@@ -1011,7 +1014,7 @@ cue_watchdog(struct ifnet *ifp)
        sc = ifp->if_softc;
        CUE_LOCK(sc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        if_printf(ifp, "watchdog timeout\n");
 
        c = &sc->cue_cdata.cue_tx_chain[0];
index e8566e8..231e8d1 100644 (file)
@@ -2550,9 +2550,9 @@ dc_rxeof(struct dc_softc *sc)
                            (rxstat & (DC_RXSTAT_CRCERR | DC_RXSTAT_DRIBBLE |
                                       DC_RXSTAT_MIIERE | DC_RXSTAT_COLLSEEN |
                                       DC_RXSTAT_RUNT   | DC_RXSTAT_DE))) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                if (rxstat & DC_RXSTAT_COLLSEEN)
-                                       ifp->if_collisions++;
+                                       IFNET_STAT_INC(ifp, collisions, 1);
                                dc_newbuf(sc, i, m);
                                if (rxstat & DC_RXSTAT_CRCERR) {
                                        DC_INC(i, DC_RX_LIST_CNT);
@@ -2591,14 +2591,14 @@ dc_rxeof(struct dc_softc *sc)
                        dc_newbuf(sc, i, m);
                        DC_INC(i, DC_RX_LIST_CNT);
                        if (m0 == NULL) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                continue;
                        }
                        m_adj(m0, ETHER_ALIGN);
                        m = m0;
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                ifp->if_input(ifp, m);
        }
 
@@ -2679,20 +2679,21 @@ dc_txeof(struct dc_softc *sc)
                }
 
                if (txstat & DC_TXSTAT_ERRSUM) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (txstat & DC_TXSTAT_EXCESSCOLL)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (txstat & DC_TXSTAT_LATECOLL)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (!(txstat & DC_TXSTAT_UNDERRUN)) {
                                dc_init(sc);
                                return;
                        }
                }
 
-               ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3;
+               IFNET_STAT_INC(ifp, collisions,
+                   (txstat & DC_TXSTAT_COLLCNT) >> 3);
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                if (sc->dc_cdata.dc_tx_chain[idx] != NULL) {
                        m_freem(sc->dc_cdata.dc_tx_chain[idx]);
                        sc->dc_cdata.dc_tx_chain[idx] = NULL;
@@ -2871,7 +2872,8 @@ dc_npoll_compat(struct ifnet *ifp, void *arg __unused, int count)
 
                if (status & (DC_ISR_RX_WATDOGTIMEO|DC_ISR_RX_NOBUF) ) {
                        u_int32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED);
-                       ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff);
+                       IFNET_STAT_INC(ifp, ierrors,
+                           (r & 0xffff) + ((r >> 17) & 0x7ff));
 
                        if (dc_rx_resync(sc))
                                dc_rxeof(sc);
@@ -2956,10 +2958,13 @@ dc_intr(void *arg)
                CSR_WRITE_4(sc, DC_ISR, status);
 
                if (status & DC_ISR_RX_OK) {
-                       int             curpkts;
-                       curpkts = ifp->if_ipackets;
+                       u_long curpkts, ncurpkts;
+
+                       IFNET_STAT_GET(ifp, ipackets, curpkts);
                        dc_rxeof(sc);
-                       if (curpkts == ifp->if_ipackets) {
+                       IFNET_STAT_GET(ifp, ipackets, ncurpkts);
+
+                       if (curpkts == ncurpkts) {
                                while(dc_rx_resync(sc))
                                        dc_rxeof(sc);
                        }
@@ -2981,10 +2986,13 @@ dc_intr(void *arg)
 
                if ((status & DC_ISR_RX_WATDOGTIMEO)
                    || (status & DC_ISR_RX_NOBUF)) {
-                       int             curpkts;
-                       curpkts = ifp->if_ipackets;
+                       u_long curpkts, ncurpkts;
+
+                       IFNET_STAT_GET(ifp, ipackets, curpkts);
                        dc_rxeof(sc);
-                       if (curpkts == ifp->if_ipackets) {
+                       IFNET_STAT_GET(ifp, ipackets, ncurpkts);
+
+                       if (curpkts == ncurpkts) {
                                while(dc_rx_resync(sc))
                                        dc_rxeof(sc);
                        }
@@ -3453,7 +3461,7 @@ dc_watchdog(struct ifnet *ifp)
 
        sc = ifp->if_softc;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        if_printf(ifp, "watchdog timeout\n");
 
        dc_stop(sc);
index 0c38297..0b571f0 100644 (file)
@@ -3100,7 +3100,7 @@ tulip_rx_intr(tulip_softc_t *sc)
            sc->tulip_flags |= TULIP_RXACT;
            accept = 1;
        } else {
-           ifp->if_ierrors++;
+           IFNET_STAT_INC(ifp, ierrors, 1);
            if (eop->d_status & (TULIP_DSTS_RxBADLENGTH|TULIP_DSTS_RxOVERFLOW|TULIP_DSTS_RxWATCHDOG)) {
                sc->tulip_dot3stats.dot3StatsInternalMacReceiveErrors++;
            } else {
@@ -3116,7 +3116,7 @@ tulip_rx_intr(tulip_softc_t *sc)
                }
            }
        }
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        if (++eop == ri->ri_last)
            eop = ri->ri_first;
        ri->ri_nextin = eop;
@@ -3257,7 +3257,7 @@ tulip_tx_intr(tulip_softc_t *sc)
                } else {
                    xmits++;
                    if (d_status & TULIP_DSTS_ERRSUM) {
-                       sc->tulip_if.if_oerrors++;
+                       IFNET_STAT_INC(&sc->tulip_if, oerrors, 1);
                        if (d_status & TULIP_DSTS_TxEXCCOLL)
                            sc->tulip_dot3stats.dot3StatsExcessiveCollisions++;
                        if (d_status & TULIP_DSTS_TxLATECOLL)
@@ -3274,7 +3274,7 @@ tulip_tx_intr(tulip_softc_t *sc)
                        u_int32_t collisions = 
                            (d_status & TULIP_DSTS_TxCOLLMASK)
                                >> TULIP_DSTS_V_TxCOLLCNT;
-                       sc->tulip_if.if_collisions += collisions;
+                       IFNET_STAT_INC(&sc->tulip_if, collisions, collisions);
                        if (collisions == 1)
                            sc->tulip_dot3stats.dot3StatsSingleCollisionFrames++;
                        else if (collisions > 1)
@@ -3310,7 +3310,7 @@ tulip_tx_intr(tulip_softc_t *sc)
        sc->tulip_txtimer = 0;
     else if (xmits > 0)
        sc->tulip_txtimer = (TULIP_TXTIMER & 3);
-    sc->tulip_if.if_opackets += xmits;
+    IFNET_STAT_INC(&sc->tulip_if, opackets, xmits);
     return descs;
 }
 
index c34e4c4..ec4af3c 100644 (file)
@@ -1814,7 +1814,7 @@ ed_watchdog(struct ifnet *ifp)
        if (sc->gone)
                return;
        log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        ed_reset(ifp);
 }
@@ -2308,7 +2308,7 @@ ed_rint(struct ed_softc *sc)
                         */
                        ed_get_packet(sc, packet_ptr + sizeof(struct ed_ring),
                                      len - sizeof(struct ed_ring));
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
                } else {
                        /*
                         * Really BAD. The ring pointers are corrupted.
@@ -2316,7 +2316,7 @@ ed_rint(struct ed_softc *sc)
                        log(LOG_ERR,
                            "%s: NIC memory corrupt - invalid packet length %d\n",
                            ifp->if_xname, len);
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        ed_reset(ifp);
                        return;
                }
@@ -2447,14 +2447,14 @@ edintr(void *arg)
                                /*
                                 * update output errors counter
                                 */
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                        } else {
 
                                /*
                                 * Update total number of successfully
                                 * transmitted packets.
                                 */
-                               ifp->if_opackets++;
+                               IFNET_STAT_INC(ifp, opackets, 1);
                        }
 
                        /*
@@ -2472,7 +2472,7 @@ edintr(void *arg)
                         * Add in total number of collisions on last
                         * transmission.
                         */
-                       ifp->if_collisions += collisions;
+                       IFNET_STAT_INC(ifp, collisions, collisions);
                        switch(collisions) {
                        case 0:
                        case 16:
@@ -2515,7 +2515,7 @@ edintr(void *arg)
                         * fixed in later revs. -DG
                         */
                        if (isr & ED_ISR_OVW) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
 #ifdef DIAGNOSTIC
                                log(LOG_WARNING,
                                    "%s: warning - receiver ring buffer overrun\n",
@@ -2542,7 +2542,7 @@ edintr(void *arg)
                                                sc->mibdata.dot3StatsAlignmentErrors++;
                                        if (rsr & ED_RSR_FO)
                                                sc->mibdata.dot3StatsInternalMacReceiveErrors++;
-                                       ifp->if_ierrors++;
+                                       IFNET_STAT_INC(ifp, ierrors, 1);
 #ifdef ED_DEBUG
                                        if_printf("receive error %x\n",
                                               ed_nic_inb(sc, ED_P0_RSR));
index ecbb696..4318d7d 100644 (file)
@@ -1024,7 +1024,7 @@ em_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        break;
 
                if (em_encap(adapter, &m_head, &nsegs, &idx)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        em_tx_collect(adapter);
                        continue;
                }
@@ -1233,7 +1233,7 @@ em_watchdog(struct ifnet *ifp)
        if (e1000_check_for_link(&adapter->hw) == 0)
                if_printf(ifp, "watchdog timeout -- resetting\n");
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        adapter->watchdog_events++;
 
        em_init(adapter);
@@ -2956,7 +2956,7 @@ em_txeof(struct adapter *adapter)
 
                                tx_buffer = &adapter->tx_buffer_area[first];
                                if (tx_buffer->m_head) {
-                                       ifp->if_opackets++;
+                                       IFNET_STAT_INC(ifp, opackets, 1);
                                        bus_dmamap_unload(adapter->txtag,
                                                          tx_buffer->map);
                                        m_freem(tx_buffer->m_head);
@@ -3014,7 +3014,7 @@ em_tx_collect(struct adapter *adapter)
 
                tx_buffer = &adapter->tx_buffer_area[first];
                if (tx_buffer->m_head) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        bus_dmamap_unload(adapter->txtag,
                                          tx_buffer->map);
                        m_freem(tx_buffer->m_head);
@@ -3429,7 +3429,7 @@ em_rxeof(struct adapter *adapter, int count)
 
                if (accept_frame) {
                        if (em_newbuf(adapter, i, 0) != 0) {
-                               ifp->if_iqdrops++;
+                               IFNET_STAT_INC(ifp, iqdrops, 1);
                                goto discard;
                        }
 
@@ -3462,7 +3462,7 @@ em_rxeof(struct adapter *adapter, int count)
 
                        if (eop) {
                                adapter->fmp->m_pkthdr.rcvif = ifp;
-                               ifp->if_ipackets++;
+                               IFNET_STAT_INC(ifp, ipackets, 1);
 
                                if (ifp->if_capenable & IFCAP_RXCSUM) {
                                        em_rxcsum(adapter, current_desc,
@@ -3480,7 +3480,7 @@ em_rxeof(struct adapter *adapter, int count)
                                adapter->lmp = NULL;
                        }
                } else {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
 discard:
 #ifdef foo
                        /* Reuse loaded DMA map and just update mbuf chain */
@@ -3863,19 +3863,19 @@ em_update_stats(struct adapter *adapter)
                E1000_READ_REG(&adapter->hw, E1000_TSCTFC);
        }
 
-       ifp->if_collisions = adapter->stats.colc;
+       IFNET_STAT_SET(ifp, collisions, adapter->stats.colc);
 
        /* Rx Errors */
-       ifp->if_ierrors =
+       IFNET_STAT_SET(ifp, ierrors,
            adapter->dropped_pkts + adapter->stats.rxerrc +
            adapter->stats.crcerrs + adapter->stats.algnerrc +
            adapter->stats.ruc + adapter->stats.roc +
-           adapter->stats.mpc + adapter->stats.cexterr;
+           adapter->stats.mpc + adapter->stats.cexterr);
 
        /* Tx Errors */
-       ifp->if_oerrors =
+       IFNET_STAT_SET(ifp, oerrors,
            adapter->stats.ecol + adapter->stats.latecol +
-           adapter->watchdog_events;
+           adapter->watchdog_events);
 }
 
 static void
index e768678..b0830b6 100644 (file)
@@ -977,7 +977,7 @@ emx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        break;
 
                if (emx_encap(tdata, &m_head, &nsegs, &idx)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        emx_tx_collect(tdata);
                        continue;
                }
@@ -1172,7 +1172,7 @@ emx_watchdog(struct ifaltq_subque *ifsq)
 
        if_printf(ifp, "TX %d watchdog timeout -- resetting\n", tdata->idx);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        emx_init(sc);
        for (i = 0; i < sc->tx_ring_inuse; ++i)
@@ -2467,7 +2467,7 @@ emx_txeof(struct emx_txdata *tdata)
 
                                tx_buffer = &tdata->tx_buf[first];
                                if (tx_buffer->m_head) {
-                                       ifp->if_opackets++;
+                                       IFNET_STAT_INC(ifp, opackets, 1);
                                        bus_dmamap_unload(tdata->txtag,
                                                          tx_buffer->map);
                                        m_freem(tx_buffer->m_head);
@@ -2525,7 +2525,7 @@ emx_tx_collect(struct emx_txdata *tdata)
 
                tx_buffer = &tdata->tx_buf[first];
                if (tx_buffer->m_head) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        bus_dmamap_unload(tdata->txtag,
                                          tx_buffer->map);
                        m_freem(tx_buffer->m_head);
@@ -3060,7 +3060,7 @@ emx_rxeof(struct emx_rxdata *rdata, int count)
                            rdata->idx, mrq, rss_hash);
 
                        if (emx_newbuf(rdata, i, 0) != 0) {
-                               ifp->if_iqdrops++;
+                               IFNET_STAT_INC(ifp, iqdrops, 1);
                                goto discard;
                        }
 
@@ -3082,7 +3082,7 @@ emx_rxeof(struct emx_rxdata *rdata, int count)
 
                        if (eop) {
                                rdata->fmp->m_pkthdr.rcvif = ifp;
-                               ifp->if_ipackets++;
+                               IFNET_STAT_INC(ifp, ipackets, 1);
 
                                if (ifp->if_capenable & IFCAP_RXCSUM)
                                        emx_rxcsum(staterr, rdata->fmp);
@@ -3105,7 +3105,7 @@ emx_rxeof(struct emx_rxdata *rdata, int count)
 #endif
                        }
                } else {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
 discard:
                        emx_setup_rxdesc(current_desc, rx_buf);
                        if (rdata->fmp != NULL) {
@@ -3368,16 +3368,15 @@ emx_update_stats(struct emx_softc *sc)
        sc->stats.tsctc += E1000_READ_REG(&sc->hw, E1000_TSCTC);
        sc->stats.tsctfc += E1000_READ_REG(&sc->hw, E1000_TSCTFC);
 
-       ifp->if_collisions = sc->stats.colc;
+       IFNET_STAT_SET(ifp, collisions, sc->stats.colc);
 
        /* Rx Errors */
-       ifp->if_ierrors = sc->stats.rxerrc +
-                         sc->stats.crcerrs + sc->stats.algnerrc +
-                         sc->stats.ruc + sc->stats.roc +
-                         sc->stats.mpc + sc->stats.cexterr;
+       IFNET_STAT_SET(ifp, ierrors,
+           sc->stats.rxerrc + sc->stats.crcerrs + sc->stats.algnerrc +
+           sc->stats.ruc + sc->stats.roc + sc->stats.mpc + sc->stats.cexterr);
 
        /* Tx Errors */
-       ifp->if_oerrors = sc->stats.ecol + sc->stats.latecol;
+       IFNET_STAT_SET(ifp, oerrors, sc->stats.ecol + sc->stats.latecol);
 }
 
 static void
index 186b9c7..bbd98ca 100644 (file)
@@ -456,7 +456,7 @@ startagain:
      */
     if (len + pad > ETHER_MAX_LEN) {
        /* packet is obviously too large: toss it */
-       ++ifp->if_oerrors;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        m_freem(m);
        goto readcheck;
     }
@@ -501,7 +501,7 @@ startagain:
     BPF_MTAP(ifp, top);
 
     ifp->if_timer = 2;
-    ifp->if_opackets++;
+    IFNET_STAT_INC(ifp, opackets, 1);
     m_freem(top);
 
     /*
@@ -574,7 +574,7 @@ rescan:
 #ifdef DIAGNOSTIC
            if_printf(ifp, "Status: %x (input buffer overflow)\n", status);
 #else
-           ++ifp->if_ierrors;
+           IFNET_STAT_INC(ifp, ierrors, 1);
 #endif
 
 #endif
@@ -599,9 +599,9 @@ rescan:
                    } else {
                        if (status & TXS_JABBER);
                        else    /* TXS_MAX_COLLISION - we shouldn't get here */
-                           ++ifp->if_collisions;
+                           IFNET_STAT_INC(ifp, collisions, 1);
                    }
-                   ++ifp->if_oerrors;
+                   IFNET_STAT_INC(ifp, oerrors, 1);
                    outw(BASE + EP_COMMAND, TX_ENABLE);
                    /*
                     * To have a tx_avail_int but giving the chance to the
@@ -645,7 +645,7 @@ epread(struct ep_softc *sc)
 read_again:
 
     if (status & ERR_RX) {
-       ++ifp->if_ierrors;
+       IFNET_STAT_INC(ifp, ierrors, 1);
        if (status & ERR_RX_OVERRUN) {
            /*
             * we can think the rx latency is actually greather than we
@@ -730,7 +730,7 @@ read_again:
        return;
     }
     outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
-    ++ifp->if_ipackets;
+    IFNET_STAT_INC(ifp, ipackets, 1);
     EP_FSET(sc, F_RX_FIRST);
     top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
     top->m_pkthdr.len = sc->cur_len;
index 2f0d1a7..119d62c 100644 (file)
@@ -1235,7 +1235,7 @@ et_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
 
                error = et_encap(sc, &m);
                if (error) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        KKASSERT(m == NULL);
 
                        if (error == EFBIG) {
@@ -1879,12 +1879,12 @@ et_rxeof(struct et_softc *sc)
                CSR_WRITE_4(sc, ET_RXSTAT_POS, rxstat_pos);
 
                if (ring_idx >= ET_RX_NRING) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        if_printf(ifp, "invalid ring index %d\n", ring_idx);
                        continue;
                }
                if (buf_idx >= ET_RX_NDESC) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        if_printf(ifp, "invalid buf index %d\n", buf_idx);
                        continue;
                }
@@ -1895,18 +1895,18 @@ et_rxeof(struct et_softc *sc)
                if (rbd->rbd_newbuf(rbd, buf_idx, 0) == 0) {
                        if (buflen < ETHER_CRC_LEN) {
                                m_freem(m);
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                        } else {
                                m->m_pkthdr.len = m->m_len = buflen;
                                m->m_pkthdr.rcvif = ifp;
 
                                m_adj(m, -ETHER_CRC_LEN);
 
-                               ifp->if_ipackets++;
+                               IFNET_STAT_INC(ifp, ipackets, 1);
                                ifp->if_input(ifp, m);
                        }
                } else {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                }
                m = NULL;       /* Catch invalid reference */
 
@@ -2043,7 +2043,7 @@ et_txeof(struct et_softc *sc, int start)
                        bus_dmamap_unload(sc->sc_txbuf_dtag, tb->tb_dmap);
                        m_freem(tb->tb_mbuf);
                        tb->tb_mbuf = NULL;
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                }
 
                if (++tbd->tbd_start_index == ET_TX_NDESC) {
index 782175a..64b2c52 100644 (file)
@@ -521,7 +521,7 @@ ex_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        BPF_MTAP(ifp, opkt);
 
                        ifp->if_timer = 2;
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        m_freem(opkt);
                } else {
                        ifq_set_oactive(&ifp->if_snd);
@@ -636,12 +636,12 @@ ex_tx_intr(struct ex_softc *sc)
                sc->tx_head = inw(iobase + IO_PORT_REG);
 
                if (tx_status & TX_OK_bit) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                } else {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                }
 
-               ifp->if_collisions += tx_status & No_Collisions_bits;
+               IFNET_STAT_INC(ifp, collisions, tx_status & No_Collisions_bits);
        }
 
        /*
@@ -688,7 +688,7 @@ ex_rx_intr(struct ex_softc *sc)
                        MGETHDR(m, MB_DONTWAIT, MT_DATA);
                        ipkt = m;
                        if (ipkt == NULL) {
-                               ifp->if_iqdrops++;
+                               IFNET_STAT_INC(ifp, iqdrops, 1);
                        } else {
                                ipkt->m_pkthdr.rcvif = ifp;
                                ipkt->m_pkthdr.len = pkt_len;
@@ -701,7 +701,7 @@ ex_rx_intr(struct ex_softc *sc)
                                                        m->m_len = MCLBYTES;
                                                } else {
                                                        m_freem(ipkt);
-                                                       ifp->if_iqdrops++;
+                                                       IFNET_STAT_INC(ifp, iqdrops, 1);
                                                        goto rx_another;
                                                }
                                        }
@@ -724,7 +724,7 @@ ex_rx_intr(struct ex_softc *sc)
                                                MGET(m->m_next, MB_DONTWAIT, MT_DATA);
                                                if (m->m_next == NULL) {
                                                        m_freem(ipkt);
-                                                       ifp->if_iqdrops++;
+                                                       IFNET_STAT_INC(ifp, iqdrops, 1);
                                                        goto rx_another;
                                                }
                                                m = m->m_next;
@@ -732,10 +732,10 @@ ex_rx_intr(struct ex_softc *sc)
                                        }
                                }
                                ifp->if_input(ifp, ipkt);
-                               ifp->if_ipackets++;
+                               IFNET_STAT_INC(ifp, ipackets, 1);
                        }
                } else {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                }
                outw(iobase + HOST_ADDR_REG, sc->rx_head);
 rx_another: ;
@@ -825,7 +825,7 @@ ex_watchdog(struct ifnet *ifp)
 
        DODEBUG(Status, kprintf("OIDLE watchdog\n"););
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        ex_reset(sc);
        if_devstart(ifp);
 
index c45252b..9ee9173 100644 (file)
@@ -934,7 +934,7 @@ static void
 fe_reset (struct fe_softc *sc)
 {
        /* Record how many packets are lost by this accident.  */
-       sc->sc_if.if_oerrors += sc->txb_sched + sc->txb_count;
+       IFNET_STAT_INC(&sc->sc_if, oerrors, sc->txb_sched + sc->txb_count);
        sc->mibdata.dot3StatsInternalMacTransmitErrors++;
 
        /* Put the interface into known initial state.  */
@@ -994,12 +994,15 @@ static void
 fe_watchdog ( struct ifnet *ifp )
 {
        struct fe_softc *sc = (struct fe_softc *)ifp;
+       u_long opkts, ipkts;
 
        /* A "debug" message.  */
        kprintf("%s: transmission timeout (%d+%d)%s\n",
               ifp->if_xname, sc->txb_sched, sc->txb_count,
               (ifp->if_flags & IFF_UP) ? "" : " when down");
-       if (sc->sc_if.if_opackets == 0 && sc->sc_if.if_ipackets == 0)
+       IFNET_STAT_GET(&sc->sc_if, opackets, opkts);
+       IFNET_STAT_GET(&sc->sc_if, ipackets, ipkts);
+       if (opkts == 0 && ipkts == 0)
                kprintf("%s: wrong IRQ setting in config?\n", ifp->if_xname);
        fe_reset(sc);
 }
@@ -1517,9 +1520,9 @@ fe_tint (struct fe_softc * sc, u_char tstat)
                 * Be sure to reflect number of excessive collisions.
                 */
                col = sc->tx_excolls;
-               sc->sc_if.if_opackets += sc->txb_sched - col;
-               sc->sc_if.if_oerrors += col;
-               sc->sc_if.if_collisions += col * 16;
+               IFNET_STAT_INC(&sc->sc_if, opackets, sc->txb_sched - col);
+               IFNET_STAT_INC(&sc->sc_if, oerrors, col);
+               IFNET_STAT_INC(&sc->sc_if, collisions, col * 16);
                sc->mibdata.dot3StatsExcessiveCollisions += col;
                sc->mibdata.dot3StatsCollFrequencies[15] += col;
                sc->txb_sched = 0;
@@ -1576,7 +1579,7 @@ fe_rint (struct fe_softc * sc, u_char rstat)
                if (rstat & FE_D1_SRTPKT)
                        sc->mibdata.dot3StatsFrameTooShorts++; /* :-) */
 #endif
-               sc->sc_if.if_ierrors++;
+               IFNET_STAT_INC(&sc->sc_if, ierrors, 1);
        }
 
        /*
@@ -1639,7 +1642,7 @@ fe_rint (struct fe_softc * sc, u_char rstat)
                    len > ETHER_MAX_LEN - ETHER_CRC_LEN ||
                    len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
                        kprintf("fe%d: RX buffer out-of-sync\n", sc->sc_unit);
-                       sc->sc_if.if_ierrors++;
+                       IFNET_STAT_INC(&sc->sc_if, ierrors, 1);
                        sc->mibdata.dot3StatsInternalMacReceiveErrors++;
                        fe_reset(sc);
                        return;
@@ -1656,14 +1659,14 @@ fe_rint (struct fe_softc * sc, u_char rstat)
                         * in the buffer.  We hope we can get more
                         * mbuf next time.
                         */
-                       sc->sc_if.if_ierrors++;
+                       IFNET_STAT_INC(&sc->sc_if, ierrors, 1);
                        sc->mibdata.dot3StatsMissedFrames++;
                        fe_droppacket(sc, len);
                        return;
                }
 
                /* Successfully received a packet.  Update stat.  */
-               sc->sc_if.if_ipackets++;
+               IFNET_STAT_INC(&sc->sc_if, ipackets, 1);
        }
 
        /* Maximum number of frames has been received.  Something
@@ -1934,7 +1937,7 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
            length > ETHER_MAX_LEN - ETHER_CRC_LEN) {
                kprintf("fe%d: got an out-of-spec packet (%u bytes) to send\n",
                        sc->sc_unit, length);
-               sc->sc_if.if_oerrors++;
+               IFNET_STAT_INC(&sc->sc_if, oerrors, 1);
                sc->mibdata.dot3StatsInternalMacTransmitErrors++;
                return;
        }
index 3dada38..d2c15c0 100644 (file)
@@ -440,7 +440,7 @@ fwe_output_callback(struct fw_xfer *xfer)
        /* XXX error check */
        FWEDEBUG(ifp, "resp = %d\n", xfer->resp);
        if (xfer->resp != 0)
-               ifp->if_oerrors ++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                
        m_freem(xfer->mbuf);
        fw_xfer_unload(xfer);
@@ -513,11 +513,11 @@ fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp)
 
                if (fw_asyreq(fwe->fd.fc, -1, xfer) != 0) {
                        /* error */
-                       ifp->if_oerrors ++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        /* XXX set error code */
                        fwe_output_callback(xfer);
                } else {
-                       ifp->if_opackets ++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        i++;
                }
        }
@@ -561,7 +561,7 @@ fwe_as_input(struct fw_xferq *xferq)
                if (sxfer->resp != 0 || fp->mode.stream.len <
                    ETHER_ALIGN + sizeof(struct ether_header)) {
                        m_freem(m);
-                       ifp->if_ierrors ++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        continue;
                }
 
@@ -585,7 +585,7 @@ fwe_as_input(struct fw_xferq *xferq)
                 );
 #endif
                ifp->if_input(ifp, m);
-               ifp->if_ipackets ++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
        }
        if (STAILQ_FIRST(&xferq->stfree) != NULL)
                fwe->fd.fc->irx_enable(fwe->fd.fc, fwe->dma_ch);
index dc4101c..b6a7450 100644 (file)
@@ -1107,14 +1107,14 @@ tbdinit:
                                 * desc.  Give it up.
                                 */
                                m_freem(mb_head);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
 
                        mn = m_dup(mb_head, MB_DONTWAIT);
                        if (mn == NULL) {
                                m_freem(mb_head);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
 
@@ -1457,10 +1457,10 @@ fxp_tick(void *xsc)
 
        lwkt_serialize_enter(sc->arpcom.ac_if.if_serializer);
 
-       ifp->if_opackets += sp->tx_good;
-       ifp->if_collisions += sp->tx_total_collisions;
+       IFNET_STAT_INC(ifp, opackets, sp->tx_good);
+       IFNET_STAT_INC(ifp, collisions, sp->tx_total_collisions);
        if (sp->rx_good) {
-               ifp->if_ipackets += sp->rx_good;
+               IFNET_STAT_INC(ifp, ipackets, sp->rx_good);
                sc->rx_idle_secs = 0;
        } else {
                /*
@@ -1468,17 +1468,17 @@ fxp_tick(void *xsc)
                 */
                sc->rx_idle_secs++;
        }
-       ifp->if_ierrors +=
+       IFNET_STAT_INC(ifp, ierrors,
            sp->rx_crc_errors +
            sp->rx_alignment_errors +
            sp->rx_rnr_errors +
-           sp->rx_overrun_errors;
+           sp->rx_overrun_errors);
        /*
         * If any transmit underruns occured, bump up the transmit
         * threshold by another 512 bytes (64 * 8).
         */
        if (sp->tx_underruns) {
-               ifp->if_oerrors += sp->tx_underruns;
+               IFNET_STAT_INC(ifp, oerrors, sp->tx_underruns);
                if (tx_threshold < 192)
                        tx_threshold += 64;
        }
@@ -1637,7 +1637,7 @@ fxp_watchdog(struct ifnet *ifp)
        ASSERT_SERIALIZED(ifp->if_serializer);
 
        if_printf(ifp, "device timeout\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        fxp_init(ifp->if_softc);
 }
 
index bd1011d..84dfd71 100644 (file)
@@ -287,8 +287,8 @@ icintr (device_t dev, int event, char *ptr)
            goto err;
 
          len -= ICHDRLEN;
-         sc->ic_if.if_ipackets ++;
-         sc->ic_if.if_ibytes += len;
+         IFNET_STAT_INC(&sc->ic_if, ipackets, 1);
+         IFNET_STAT_INC(&sc->ic_if, ibytes, len);
 
          BPF_TAP(&sc->ic_if, sc->ic_ifbuf, len + ICHDRLEN);
 
@@ -302,7 +302,7 @@ icintr (device_t dev, int event, char *ptr)
          kprintf("ic%d: errors (%d)!\n", unit, sc->ic_iferrs);
 
          sc->ic_iferrs = 0;                    /* reset error count */
-         sc->ic_if.if_ierrors ++;
+         IFNET_STAT_INC(&sc->ic_if, ierrors, 1);
 
          break;
 
@@ -355,7 +355,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m,
 
        /* already sending? */
        if (sc->ic_sending) {
-               ifp->if_oerrors ++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                goto error;
        }
                
@@ -368,7 +368,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m,
        do {
                if (len + mm->m_len > sc->ic_if.if_mtu) {
                        /* packet to large */
-                       ifp->if_oerrors ++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        goto error;
                }
                        
@@ -395,10 +395,10 @@ icoutput(struct ifnet *ifp, struct mbuf *m,
        if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf,
                                len + ICHDRLEN, &sent))
 
-               ifp->if_oerrors ++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        else {
-               ifp->if_opackets ++;
-               ifp->if_obytes += len;
+               IFNET_STAT_INC(ifp, opackets, 1);
+               IFNET_STAT_INC(ifp, obytes, len);
        }
 
        sc->ic_sending = 0;
index e3fe181..af19a95 100644 (file)
@@ -2096,7 +2096,7 @@ igb_txeof(struct igb_tx_ring *txr)
                        bus_dmamap_unload(txr->tx_tag, txbuf->map);
                        m_freem(txbuf->m_head);
                        txbuf->m_head = NULL;
-                       ++ifp->if_opackets;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                }
                if (++first == txr->num_tx_desc)
                        first = 0;
@@ -2607,7 +2607,7 @@ igb_rxeof(struct igb_rx_ring *rxr, int count)
                            BUS_DMASYNC_POSTREAD);
 
                        if (igb_newbuf(rxr, i, FALSE) != 0) {
-                               ifp->if_iqdrops++;
+                               IFNET_STAT_INC(ifp, iqdrops, 1);
                                goto discard;
                        }
 
@@ -2628,7 +2628,7 @@ igb_rxeof(struct igb_rx_ring *rxr, int count)
                                rxr->lmp = NULL;
 
                                m->m_pkthdr.rcvif = ifp;
-                               ifp->if_ipackets++;
+                               IFNET_STAT_INC(ifp, ipackets, 1);
 
                                if (ifp->if_capenable & IFCAP_RXCSUM)
                                        igb_rxcsum(staterr, m);
@@ -2647,7 +2647,7 @@ igb_rxeof(struct igb_rx_ring *rxr, int count)
 #endif
                        }
                } else {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
 discard:
                        igb_setup_rxdesc(cur, rxbuf);
                        if (!eop)
@@ -3027,14 +3027,16 @@ igb_update_stats_counters(struct igb_softc *sc)
        stats->tsctc += E1000_READ_REG(hw, E1000_TSCTC);
        stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC);
 
-       ifp->if_collisions = stats->colc;
+       IFNET_STAT_SET(ifp, collisions, stats->colc);
 
        /* Rx Errors */
-       ifp->if_ierrors = stats->rxerrc + stats->crcerrs + stats->algnerrc +
-           stats->ruc + stats->roc + stats->mpc + stats->cexterr;
+       IFNET_STAT_SET(ifp, ierrors,
+           stats->rxerrc + stats->crcerrs + stats->algnerrc +
+           stats->ruc + stats->roc + stats->mpc + stats->cexterr);
 
        /* Tx Errors */
-       ifp->if_oerrors = stats->ecol + stats->latecol + sc->watchdog_events;
+       IFNET_STAT_SET(ifp, oerrors,
+           stats->ecol + stats->latecol + sc->watchdog_events);
 
        /* Driver specific counters */
        sc->device_control = E1000_READ_REG(hw, E1000_CTRL);
@@ -3471,7 +3473,7 @@ igb_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        break;
 
                if (igb_encap(txr, &m_head, &nsegs, &idx)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        continue;
                }
 
@@ -3517,7 +3519,7 @@ igb_watchdog(struct ifaltq_subque *ifsq)
            "Next TX to Clean = %d\n",
            txr->me, txr->tx_avail, txr->next_to_clean);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        sc->watchdog_events++;
 
        igb_init(sc);
index 2d34c02..53157c5 100644 (file)
@@ -1233,7 +1233,7 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data, int i,
         */
        mnew = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
        if (mnew == NULL) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -1254,7 +1254,7 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data, int i,
                        panic("%s: could not load old rx mbuf",
                            device_get_name(sc->sc_dev));
                }
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -1603,7 +1603,7 @@ iwi_tx_intr(struct iwi_softc *sc, struct iwi_tx_ring *txq)
 
                DPRINTFN(15, ("tx done idx=%u\n", txq->next));
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
                txq->queued--;
                txq->next = (txq->next + 1) % IWI_TX_RING_COUNT;
@@ -1798,7 +1798,7 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni,
                                        /* h/w table is full */
                                        m_freem(m0);
                                        ieee80211_free_node(ni);
-                                       ifp->if_oerrors++;
+                                       IFNET_STAT_INC(ifp, oerrors, 1);
                                        return 0;
                                }
                                iwi_write_ibssnode(sc,
@@ -1951,7 +1951,7 @@ iwi_start_locked(struct ifnet *ifp)
                ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
                if (iwi_tx_start(ifp, m, ni, ac) != 0) {
                        ieee80211_free_node(ni);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        break;
                }
 
@@ -1977,7 +1977,7 @@ iwi_watchdog(void *arg)
        if (sc->sc_tx_timer > 0) {
                if (--sc->sc_tx_timer == 0) {
                        if_printf(ifp, "device timeout\n");
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        wlan_serialize_exit();
                        ieee80211_runtask(ic, &sc->sc_restarttask);
                        wlan_serialize_enter();
index 86be329..6589b49 100644 (file)
@@ -876,7 +876,7 @@ iwl2100_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                if (m->m_len < sizeof(*eh)) {
                        m = m_pullup(m, sizeof(*eh));
                        if (m == NULL) {
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
                }
@@ -885,7 +885,7 @@ iwl2100_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                ni = ieee80211_find_txnode(ic, eh->ether_dhost);
                if (ni == NULL) {
                        m_freem(m);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        continue;
                }
 
@@ -896,7 +896,7 @@ iwl2100_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                m = ieee80211_encap(ic, m, ni);
                if (m == NULL) {
                        ieee80211_free_node(ni);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        continue;
                }
 
@@ -908,7 +908,7 @@ iwl2100_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        if (ieee80211_crypto_encap(ic, ni, m) == NULL) {
                                ieee80211_free_node(ni);
                                m_freem(m);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                continue;
                        }
                }
@@ -929,11 +929,11 @@ iwl2100_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                ieee80211_free_node(ni);
 
                if (iwl2100_encap(sc, m)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        continue;
                }
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                trans = 1;
        }
 
@@ -963,7 +963,7 @@ iwl2100_watchdog(struct ifnet *ifp)
        if (sc->sc_tx_timer) {
                if (--sc->sc_tx_timer == 0) {
                        if_printf(ifp, "watchdog timeout!\n");
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        iwl2100_restart(sc);
                        return;
                } else {
@@ -3045,7 +3045,7 @@ iwl2100_rxeof_data(struct iwl2100_softc *sc, int i)
        frame_len = st->r_len;
 
        if (iwl2100_newbuf(sc, i, 0)) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
index 10e9e45..561c543 100644 (file)
@@ -2068,7 +2068,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
                if (!sc->last_rx_valid) {
                        DPRINTF(sc, IWN_DEBUG_ANY,
                            "%s: missing RX_PHY\n", __func__);
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        return;
                }
                sc->last_rx_valid = 0;
@@ -2082,7 +2082,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
                device_printf(sc->sc_dev,
                    "%s: invalid rx statistic header, len %d\n",
                    __func__, stat->cfg_phy_len);
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
        if (desc->type == IWN_MPDU_RX_DONE) {
@@ -2100,14 +2100,14 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
        if ((flags & IWN_RX_NOERROR) != IWN_RX_NOERROR) {
                DPRINTF(sc, IWN_DEBUG_RECV, "%s: rx flags error %x\n",
                    __func__, flags);
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
        /* Discard frames that are too short. */
        if (len < sizeof (*wh)) {
                DPRINTF(sc, IWN_DEBUG_RECV, "%s: frame too short: %d\n",
                    __func__, len);
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -2116,7 +2116,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
        if (m1 == NULL) {
                DPRINTF(sc, IWN_DEBUG_ANY, "%s: no mbuf to restock ring\n",
                    __func__);
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
        bus_dmamap_unload(ring->data_dmat, data->map);
@@ -2128,7 +2128,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
                device_printf(sc->sc_dev,
                    "%s: bus_dmamap_load failed, error %d\n", __func__, error);
                m_freem(m1);
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -2413,7 +2413,7 @@ iwn_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, int ackfailcnt,
         * Update rate control statistics for the node.
         */
        if (status & 0x80) {
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                ieee80211_ratectl_tx_complete(vap, ni,
                    IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL);
        } else {
@@ -3351,7 +3351,7 @@ iwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
        if (error != 0) {
                /* NB: m is reclaimed on tx failure */
                ieee80211_free_node(ni);
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        }
        return error;
 }
@@ -3387,7 +3387,7 @@ iwn_start_locked(struct ifnet *ifp)
                pri = M_WME_GETAC(m);
                txq = &sc->txq[pri];
                if (iwn_tx_data(sc, m, ni, txq) != 0) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        ieee80211_free_node(ni);
                        break;
                }
index 8b34577..1c2aaeb 100644 (file)
@@ -3473,7 +3473,7 @@ ixgbe_txeof(struct tx_ring *txr)
                            (struct ixgbe_legacy_tx_desc *)&txr->tx_base[first];
                }
                ++txr->packets;
-               ++ifp->if_opackets;
+               IFNET_STAT_INC(ifp, opackets, 1);
                /* See if there is more work now */
                last = tx_buffer->eop_index;
                if (last != -1) {
@@ -4398,7 +4398,7 @@ ixgbe_rxeof(struct ix_queue *que, int count)
                /* Make sure bad packets are discarded */
                if (((staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) != 0) ||
                    (rxr->discard)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        rxr->rx_discarded++;
                        if (eop)
                                rxr->discard = FALSE;
@@ -4539,7 +4539,7 @@ ixgbe_rxeof(struct ix_queue *que, int count)
                /* Sending this frame? */
                if (eop) {
                        sendmp->m_pkthdr.rcvif = ifp;
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
                        rxr->rx_packets++;
                        /* capture data for AIM */
                        rxr->bytes += sendmp->m_pkthdr.len;
@@ -5136,16 +5136,15 @@ ixgbe_update_stats_counters(struct adapter *adapter)
        }
 
        /* Fill out the OS statistics structure */
-       ifp->if_ipackets = adapter->stats.gprc;
-       ifp->if_opackets = adapter->stats.gptc;
-       ifp->if_ibytes = adapter->stats.gorc;
-       ifp->if_obytes = adapter->stats.gotc;
-       ifp->if_imcasts = adapter->stats.mprc;
-       ifp->if_collisions = 0;
+       IFNET_STAT_SET(ifp, ipackets, adapter->stats.gprc);
+       IFNET_STAT_SET(ifp, opackets, adapter->stats.gptc);
+       IFNET_STAT_SET(ifp, ibytes, adapter->stats.gorc);
+       IFNET_STAT_SET(ifp, obytes, adapter->stats.gotc);
+       IFNET_STAT_SET(ifp, imcasts, adapter->stats.mprc);
 
        /* Rx Errors */
-       ifp->if_ierrors = total_missed_rx + adapter->stats.crcerrs +
-               adapter->stats.rlec;
+       IFNET_STAT_SET(ifp, ierrors, total_missed_rx + adapter->stats.crcerrs +
+               adapter->stats.rlec);
 }
 
 /** ixgbe_sysctl_tdh_handler - Handler function
index 629bb68..7bf30dc 100644 (file)
@@ -443,7 +443,7 @@ jme_miibus_statchg(device_t dev)
                                m_freem(txd->tx_m);
                                txd->tx_m = NULL;
                                txd->tx_ndesc = 0;
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                        }
                }
        }
@@ -1840,7 +1840,7 @@ jme_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                 */
                if (jme_encap(tdata, &m_head, &enq)) {
                        KKASSERT(m_head == NULL);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        ifq_set_oactive(&ifp->if_snd);
                        break;
                }
@@ -1883,7 +1883,7 @@ jme_watchdog(struct ifnet *ifp)
 
        if (!sc->jme_has_link) {
                if_printf(ifp, "watchdog timeout (missed link)\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                jme_init(sc);
                return;
        }
@@ -1898,7 +1898,7 @@ jme_watchdog(struct ifnet *ifp)
        }
 
        if_printf(ifp, "watchdog timeout\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        jme_init(sc);
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -2224,13 +2224,13 @@ jme_txeof(struct jme_txdata *tdata)
                        break;
 
                if (status & (JME_TD_TMOUT | JME_TD_RETRY_EXP)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                } else {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        if (status & JME_TD_COLLISION) {
-                               ifp->if_collisions +=
+                               IFNET_STAT_INC(ifp, collisions,
                                    le32toh(txd->tx_desc->buflen) &
-                                   JME_TD_BUF_LEN_MASK;
+                                   JME_TD_BUF_LEN_MASK);
                        }
                }
 
@@ -2348,7 +2348,7 @@ jme_rxpkt(struct jme_rxdata *rdata)
                        rdata->jme_rx_idx, flags, hash, hashinfo);
 
        if (status & JME_RX_ERR_STAT) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                jme_discard_rxbufs(rdata, cons, nsegs);
 #ifdef JME_SHOW_ERRORS
                if_printf(ifp, "%s : receive error = 0x%b\n",
@@ -2367,7 +2367,7 @@ jme_rxpkt(struct jme_rxdata *rdata)
 
                /* Add a new receive buffer to the ring. */
                if (jme_newbuf(rdata, rxd, 0) != 0) {
-                       ifp->if_iqdrops++;
+                       IFNET_STAT_INC(ifp, iqdrops, 1);
                        /* Reuse buffer. */
                        jme_discard_rxbufs(rdata, cons, nsegs - count);
                        if (rdata->jme_rxhead != NULL) {
@@ -2448,7 +2448,7 @@ jme_rxpkt(struct jme_rxdata *rdata)
                                m->m_flags |= M_VLANTAG;
                        }
 
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
 
                        if (ifp->if_capenable & IFCAP_RSS)
                                pi = jme_pktinfo(&pi0, flags);
index 6d46427..1fc0346 100644 (file)
@@ -601,7 +601,7 @@ kue_rxstart(struct ifnet *ifp)
        c = &sc->kue_cdata.kue_rx_chain[sc->kue_cdata.kue_rx_prod];
 
        if (kue_newbuf(sc, c, NULL) == ENOBUFS) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -665,11 +665,11 @@ kue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        total_len = len;
 
        if (len < sizeof(struct ether_header)) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = total_len;
 
@@ -734,9 +734,9 @@ kue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        }
 
        if (err)
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        else
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -977,7 +977,7 @@ kue_watchdog(struct ifnet *ifp)
 
        sc = ifp->if_softc;
        KUE_LOCK(sc);
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        kprintf("kue%d: watchdog timeout\n", sc->kue_unit);
 
        c = &sc->kue_cdata.kue_tx_chain[0];
index 38c26d7..35e783f 100644 (file)
@@ -878,7 +878,7 @@ lge_rxeof(struct lge_softc *sc, int cnt)
                 * comes up in the ring.
                 */
                if (rxctl & LGE_RXCTL_ERRMASK) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        lge_newbuf(sc, &LGE_RXTAIL(sc), m);
                        continue;
                }
@@ -891,7 +891,7 @@ lge_rxeof(struct lge_softc *sc, int cnt)
                                kprintf("lge%d: no receive buffers "
                                    "available -- packet dropped!\n",
                                    sc->lge_unit);
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                continue;
                        }
                        m_adj(m0, ETHER_ALIGN);
@@ -901,7 +901,7 @@ lge_rxeof(struct lge_softc *sc, int cnt)
                        m->m_pkthdr.len = m->m_len = total_len;
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 
                /* Do IP checksum checking. */
                if (rxsts & LGE_RXSTS_ISIP)
@@ -957,7 +957,7 @@ lge_txeof(struct lge_softc *sc)
        while (idx != sc->lge_cdata.lge_tx_prod && txdone) {
                cur_tx = &sc->lge_ldata->lge_tx_list[idx];
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                if (cur_tx->lge_mbuf != NULL) {
                        m_freem(cur_tx->lge_mbuf);
                        cur_tx->lge_mbuf = NULL;
@@ -994,9 +994,9 @@ lge_tick_serialized(void *xsc)
        struct ifnet *ifp = &sc->arpcom.ac_if;
 
        CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_SINGLE_COLL_PKTS);
-       ifp->if_collisions += CSR_READ_4(sc, LGE_STATSVAL);
+       IFNET_STAT_INC(ifp, collisions, CSR_READ_4(sc, LGE_STATSVAL));
        CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_MULTI_COLL_PKTS);
-       ifp->if_collisions += CSR_READ_4(sc, LGE_STATSVAL);
+       IFNET_STAT_INC(ifp, collisions, CSR_READ_4(sc, LGE_STATSVAL));
 
        if (!sc->lge_link) {
                mii = device_get_softc(sc->lge_miibus);
@@ -1416,7 +1416,7 @@ lge_watchdog(struct ifnet *ifp)
 {
        struct lge_softc *sc = ifp->if_softc;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        kprintf("lge%d: watchdog timeout\n", sc->lge_unit);
 
        lge_stop(sc);
index d62be41..ce4c989 100644 (file)
@@ -478,9 +478,9 @@ lgue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        }
        usbd_get_xfer_status(sc->lgue_tx_xfer, NULL, NULL, NULL,&err);
        if (err)
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        else
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
        if (!STAILQ_EMPTY(&sc->lgue_tx_queue)) {
                if_devstart_sched(ifp);
@@ -774,16 +774,16 @@ lgue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
 
        if (total_len < sizeof(struct ether_header)) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
        if (lgue_newbuf(sc, total_len, &m) == ENOBUFS) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m_copyback(m, 0, total_len, sc->lgue_rx_buf);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = total_len;
@@ -845,7 +845,7 @@ lgue_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr)
 static void
 lgue_watchdog(struct ifnet *ifp)
 {
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart_sched(ifp);
index bfba8d4..714a4b9 100644 (file)
@@ -275,7 +275,7 @@ am7990_rint(struct lance_softc *sc)
                        bix = 0;
 
                if (m != NULL) {
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
 
 #ifdef LANCE_REVC_BUG
                        /*
@@ -299,7 +299,7 @@ am7990_rint(struct lance_softc *sc)
                        /* Pass the packet up. */
                        (*ifp->if_input)(ifp, m);
                } else
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
        }
 
        sc->sc_last_rd = bix;
@@ -356,22 +356,22 @@ am7990_tint(struct lance_softc *sc)
                                        if_printf(ifp, "lost carrier\n");
                        }
                        if (tmd.tmd3 & LE_T3_LCOL)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (tmd.tmd3 & LE_T3_RTRY) {
 #ifdef LEDEBUG
                                if_printf(ifp, "excessive collisions, tdr %d\n",
                                    tmd.tmd3 & LE_T3_TDR_MASK);
 #endif
-                               ifp->if_collisions += 16;
+                               IFNET_STAT_INC(ifp, collisions, 16);
                        }
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                } else {
                        if (tmd.tmd1_bits & LE_T1_ONE)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        else if (tmd.tmd1_bits & LE_T1_MORE)
                                /* Real number is unknown. */
-                               ifp->if_collisions += 2;
-                       ifp->if_opackets++;
+                               IFNET_STAT_INC(ifp, collisions, 2);
+                       IFNET_STAT_INC(ifp, opackets, 1);
                }
 
                if (++bix == sc->sc_ntbuf)
@@ -396,7 +396,7 @@ am7990_intr(void *arg)
        uint16_t isr;
 
        if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                lance_init_locked(sc);
                return;
        }
@@ -427,19 +427,19 @@ am7990_intr(void *arg)
 #ifdef LEDEBUG
                        if_printf(ifp, "babble\n");
 #endif
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                }
 #if 0
                if (isr & LE_C0_CERR) {
                        if_printf(ifp, "collision error\n");
-                       ifp->if_collisions++;
+                       IFNET_STAT_INC(ifp, collisions, 1);
                }
 #endif
                if (isr & LE_C0_MISS) {
 #ifdef LEDEBUG
                        if_printf(ifp, "missed packet\n");
 #endif
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                }
                if (isr & LE_C0_MERR) {
                        if_printf(ifp, "memory error\n");
@@ -450,13 +450,13 @@ am7990_intr(void *arg)
 
        if ((isr & LE_C0_RXON) == 0) {
                if_printf(ifp, "receiver disabled\n");
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                lance_init_locked(sc);
                return;
        }
        if ((isr & LE_C0_TXON) == 0) {
                if_printf(ifp, "transmitter disabled\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                lance_init_locked(sc);
                return;
        }
index a575ae4..5fbc4bd 100644 (file)
@@ -315,7 +315,7 @@ am79900_rint(struct lance_softc *sc)
                        bix = 0;
 
                if (m != NULL) {
-                       ifp->if_ipackets++;
+                       IFNET_STAT_INC(ifp, ipackets, 1);
 
 #ifdef __i386__
                        /*
@@ -334,7 +334,7 @@ am79900_rint(struct lance_softc *sc)
                        /* Pass the packet up. */
                        (*ifp->if_input)(ifp, m);
                } else
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
        }
 
        sc->sc_last_rd = bix;
@@ -393,21 +393,21 @@ am79900_tint(struct lance_softc *sc)
                                        if_printf(ifp, "lost carrier\n");
                        }
                        if (tmd2 & LE_T2_LCOL)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (tmd2 & LE_T2_RTRY) {
 #ifdef LEDEBUG
                                if_printf(ifp, "excessive collisions\n");
 #endif
-                               ifp->if_collisions += 16;
+                               IFNET_STAT_INC(ifp, collisions, 16);
                        }
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                } else {
                        if (tmd1 & LE_T1_ONE)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        else if (tmd1 & LE_T1_MORE)
                                /* Real number is unknown. */
-                               ifp->if_collisions += 2;
-                       ifp->if_opackets++;
+                               IFNET_STAT_INC(ifp, collisions, 2);
+                       IFNET_STAT_INC(ifp, opackets, 1);
                }
 
                if (++bix == sc->sc_ntbuf)
@@ -432,7 +432,7 @@ am79900_intr(void *arg)
        uint16_t isr;
 
        if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                lance_init_locked(sc);
                return;
        }
@@ -463,7 +463,7 @@ am79900_intr(void *arg)
 #ifdef LEDEBUG
                        if_printf(ifp, "babble\n");
 #endif
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                }
 #if 0
                if (isr & LE_C0_CERR) {
@@ -475,7 +475,7 @@ am79900_intr(void *arg)
 #ifdef LEDEBUG
                        if_printf(ifp, "missed packet\n");
 #endif
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                }
                if (isr & LE_C0_MERR) {
                        if_printf(ifp, "memory error\n");
@@ -486,13 +486,13 @@ am79900_intr(void *arg)
 
        if ((isr & LE_C0_RXON) == 0) {
                if_printf(ifp, "receiver disabled\n");
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                lance_init_locked(sc);
                return;
        }
        if ((isr & LE_C0_TXON) == 0) {
                if_printf(ifp, "transmitter disabled\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                lance_init_locked(sc);
                return;
        }
index 0d24774..597ce24 100644 (file)
@@ -393,7 +393,7 @@ lance_watchdog(struct ifnet *ifp)
        struct lance_softc *sc = ifp->if_softc;
 
        if_printf(ifp, "device timeout\n");
-       ++ifp->if_oerrors;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        lance_init_locked(sc);
 }
 
index 24aa343..ad61266 100644 (file)
@@ -2632,7 +2632,7 @@ msk_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                 * for the NIC to drain the ring.
                 */
                if (msk_encap(sc_if, &m_head) != 0) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (sc_if->msk_cdata.msk_tx_cnt == 0) {
                                continue;
                        } else {
@@ -2673,7 +2673,7 @@ msk_watchdog(struct ifnet *ifp)
                if (bootverbose)
                        if_printf(sc_if->msk_ifp, "watchdog timeout "
                           "(missed link)\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                msk_init(sc_if);
                return;
        }
@@ -2696,7 +2696,7 @@ msk_watchdog(struct ifnet *ifp)
        }
 
        if_printf(ifp, "watchdog timeout\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        msk_init(sc_if);
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -2799,7 +2799,7 @@ msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, int len)
                         * handle this frame.
                         */
                        if (len > MSK_MAX_FRAMELEN || len < ETHER_HDR_LEN) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                msk_discard_rxbuf(sc_if, cons);
                                break;
                        }
@@ -2808,21 +2808,21 @@ msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, int len)
                    ((status & GMR_FS_RX_OK) == 0) || (rxlen != len)) {
                        /* Don't count flow-control packet as errors. */
                        if ((status & GMR_FS_GOOD_FC) == 0)
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                        msk_discard_rxbuf(sc_if, cons);
                        break;
                }
                rxd = &sc_if->msk_cdata.msk_rxdesc[cons];
                m = rxd->rx_m;
                if (msk_newbuf(sc_if, cons, 0) != 0) {
-                       ifp->if_iqdrops++;
+                       IFNET_STAT_INC(ifp, iqdrops, 1);
                        /* Reuse old buffer. */
                        msk_discard_rxbuf(sc_if, cons);
                        break;
                }
                m->m_pkthdr.rcvif = ifp;
                m->m_pkthdr.len = m->m_len = len;
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 #ifdef notyet
                /* Check for VLAN tagged packets. */
                if ((status & GMR_FS_VLAN) != 0 &&
@@ -2923,7 +2923,7 @@ msk_txeof(struct msk_if_softc *sc_if, int idx)
                txd = &sc_if->msk_cdata.msk_txdesc[cons];
                bus_dmamap_unload(sc_if->msk_cdata.msk_tx_tag, txd->tx_dmamap);
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                KASSERT(txd->tx_m != NULL, ("%s: freeing NULL mbuf!",
                    __func__));
                m_freem(txd->tx_m);
index 37badda..50b2db9 100644 (file)
@@ -2440,7 +2440,7 @@ mxge_rx_done_big(struct mxge_slice_state *ss, uint32_t len, uint32_t csum)
        /* try to replace the received mbuf */
        if (mxge_get_buf_big(ss, rx->extra_map, idx)) {
                /* drop the frame -- the old mbuf is re-cycled */
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -2506,7 +2506,7 @@ mxge_rx_done_small(struct mxge_slice_state *ss, uint32_t len, uint32_t csum)
        /* try to replace the received mbuf */
        if (mxge_get_buf_small(ss, rx->extra_map, idx)) {
                /* drop the frame -- the old mbuf is re-cycled */
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                return;
        }
 
@@ -3729,14 +3729,14 @@ mxge_update_stats(mxge_softc_t *sc)
 #endif
                oerrors += ss->oerrors;
        }
-       sc->ifp->if_ipackets = ipackets;
-       sc->ifp->if_opackets = opackets;
+       IFNET_STAT_SET(sc->ifp, ipackets, ipackets);
+       IFNET_STAT_SET(sc->ifp, opackets, opackets);
 #ifdef IFNET_BUF_RING
        sc->ifp->if_obytes = obytes;
        sc->ifp->if_omcasts = omcasts;
        sc->ifp->if_snd.ifq_drops = odrops;
 #endif
-       sc->ifp->if_oerrors = oerrors;
+       IFNET_STAT_SET(sc->ifp, oerrors, oerrors);
 }
 
 static void
index 53e1b13..6047cb4 100644 (file)
@@ -1098,7 +1098,7 @@ my_rxeof(struct my_softc * sc)
                sc->my_cdata.my_rx_head = cur_rx->my_nextdesc;
 
                if (rxstat & MY_ES) {   /* error summary: give up this rx pkt */
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        cur_rx->my_ptr->my_status = MY_OWNByNIC;
                        continue;
                }
@@ -1111,7 +1111,7 @@ my_rxeof(struct my_softc * sc)
                            total_len, 0, ifp, NULL);
                        cur_rx->my_ptr->my_status = MY_OWNByNIC;
                        if (m == NULL) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                continue;
                        }
                } else {
@@ -1124,14 +1124,14 @@ my_rxeof(struct my_softc * sc)
                         * little else we can do in this situation.
                         */
                        if (my_newbuf(sc, cur_rx) == ENOBUFS) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                cur_rx->my_ptr->my_status = MY_OWNByNIC;
                                continue;
                        }
                        m->m_pkthdr.rcvif = ifp;
                        m->m_pkthdr.len = m->m_len = total_len;
                }
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                ifp->if_input(ifp, m);
        }
 }
@@ -1164,16 +1164,16 @@ my_txeof(struct my_softc * sc)
                        break;
                if (!(CSR_READ_4(sc, MY_TCRRCR) & MY_Enhanced)) {
                        if (txstat & MY_TXERR) {
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                if (txstat & MY_EC) /* excessive collision */
-                                       ifp->if_collisions++;
+                                       IFNET_STAT_INC(ifp, collisions, 1);
                                if (txstat & MY_LC)     /* late collision */
-                                       ifp->if_collisions++;
+                                       IFNET_STAT_INC(ifp, collisions, 1);
                        }
-                       ifp->if_collisions += (txstat & MY_NCRMASK) >>
-                           MY_NCRShift;
+                       IFNET_STAT_INC(ifp, collisions,
+                           (txstat & MY_NCRMASK) >> MY_NCRShift);
                }
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                m_freem(cur_tx->my_mbuf);
                cur_tx->my_mbuf = NULL;
                if (sc->my_cdata.my_tx_head == sc->my_cdata.my_tx_tail) {
@@ -1184,7 +1184,8 @@ my_txeof(struct my_softc * sc)
                sc->my_cdata.my_tx_head = cur_tx->my_nextdesc;
        }
        if (CSR_READ_4(sc, MY_TCRRCR) & MY_Enhanced) {
-               ifp->if_collisions += (CSR_READ_4(sc, MY_TSR) & MY_NCRMask);
+               IFNET_STAT_INC(ifp, collisions,
+                   (CSR_READ_4(sc, MY_TSR) & MY_NCRMask));
        }
 }
 
@@ -1237,7 +1238,7 @@ my_intr(void *arg)
 
                if ((status & MY_RBU) || (status & MY_RxErr)) {
                        /* rx buffer unavailable or rx error */
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
 #ifdef foo
                        my_stop(sc);
                        my_reset(sc);
@@ -1623,7 +1624,7 @@ my_watchdog(struct ifnet * ifp)
                crit_exit();
                return;
        }
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        kprintf("my%d: watchdog timeout\n", sc->my_unit);
        if (!(my_phy_readreg(sc, PHY_BMSR) & PHY_BMSR_LINKSTAT))
                kprintf("my%d: no carrier - transceiver cable problem?\n",
index 6751a0e..d373f3b 100644 (file)
@@ -1450,7 +1450,7 @@ ndis_rxeof(ndis_handle adapter, ndis_packet **packets, uint32_t pktcnt)
                                p->np_oob.npo_status = NDIS_STATUS_PENDING;
                        m_freem(m0);
                        if (m == NULL) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                continue;
                        }
                        m0 = m;
@@ -1552,9 +1552,9 @@ ndis_txeof(ndis_handle adapter, ndis_packet *packet, ndis_status status)
        sc->ndis_txpending++;
 
        if (status == NDIS_STATUS_SUCCESS)
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
        else
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
 
        sc->ndis_tx_timer = 0;
        ifq_clr_oactive(&ifp->if_snd);
@@ -1652,7 +1652,7 @@ ndis_tick(void *xsc)
        }
 
        if (sc->ndis_tx_timer && --sc->ndis_tx_timer == 0) {
-               sc->ifp->if_oerrors++;
+               IFNET_STAT_INC(sc->ifp, oerrors, 1);
                device_printf(sc->ndis_dev, "watchdog timeout\n");
 
                IoQueueWorkItem(sc->ndis_resetitem,
index ab11def..2f9735a 100644 (file)
@@ -1120,7 +1120,7 @@ nfe_rxeof(struct nfe_softc *sc)
                }
 
                if (flags & NFE_RX_ERROR) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1131,7 +1131,7 @@ nfe_rxeof(struct nfe_softc *sc)
                else
                        error = nfe_newbuf_std(sc, ring, ring->cur, 0);
                if (error) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1155,7 +1155,7 @@ nfe_rxeof(struct nfe_softc *sc)
                        }
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                ifp->if_input(ifp, m);
 skip:
                nfe_set_ready_rxdesc(sc, ring, ring->cur);
@@ -1191,9 +1191,9 @@ nfe_txeof(struct nfe_softc *sc, int start)
                        if ((flags & NFE_TX_ERROR_V1) != 0) {
                                if_printf(ifp, "tx v1 error 0x%4b\n", flags,
                                          NFE_V1_TXERR);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                        } else {
-                               ifp->if_opackets++;
+                               IFNET_STAT_INC(ifp, opackets, 1);
                        }
                } else {
                        if (!(flags & NFE_TX_LASTFRAG_V2) && data->m == NULL)
@@ -1202,9 +1202,9 @@ nfe_txeof(struct nfe_softc *sc, int start)
                        if ((flags & NFE_TX_ERROR_V2) != 0) {
                                if_printf(ifp, "tx v2 error 0x%4b\n", flags,
                                          NFE_V2_TXERR);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                        } else {
-                               ifp->if_opackets++;
+                               IFNET_STAT_INC(ifp, opackets, 1);
                        }
                }
 
@@ -1392,7 +1392,7 @@ nfe_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
 
                error = nfe_encap(sc, ring, m0);
                if (error) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (error == EFBIG) {
                                if (oactive) {
                                        ifq_set_oactive(&ifp->if_snd);
@@ -1443,7 +1443,7 @@ nfe_watchdog(struct ifnet *ifp)
 
        nfe_init(ifp->if_softc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 }
 
 static void
index b8a932a..e26f769 100644 (file)
@@ -1231,7 +1231,7 @@ nge_rxeof(struct nge_softc *sc)
                 * comes up in the ring.
                 */
                if ((rxstat & NGE_CMDSTS_PKT_OK) == 0) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        nge_newbuf(sc, cur_rx, m);
                        continue;
                }
@@ -1259,7 +1259,7 @@ nge_rxeof(struct nge_softc *sc)
                                kprintf("nge%d: no receive buffers "
                                    "available -- packet dropped!\n",
                                    sc->nge_unit);
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                continue;
                        }
                        m_adj(m0, ETHER_ALIGN);
@@ -1271,7 +1271,7 @@ nge_rxeof(struct nge_softc *sc)
                }
 #endif
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 
                /* Do IP checksum checking. */
                if (extsts & NGE_RXEXTSTS_IPPKT)
@@ -1335,17 +1335,17 @@ nge_txeof(struct nge_softc *sc)
                }
 
                if (!(cur_tx->nge_ctl & NGE_CMDSTS_PKT_OK)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (cur_tx->nge_txstat & NGE_TXSTAT_EXCESSCOLLS)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (cur_tx->nge_txstat & NGE_TXSTAT_OUTOFWINCOLL)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                }
 
-               ifp->if_collisions +=
-                   (cur_tx->nge_txstat & NGE_TXSTAT_COLLCNT) >> 16;
+               IFNET_STAT_INC(ifp, collisions,
+                   (cur_tx->nge_txstat & NGE_TXSTAT_COLLCNT) >> 16);
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                if (cur_tx->nge_mbuf != NULL) {
                        m_freem(cur_tx->nge_mbuf);
                        cur_tx->nge_mbuf = NULL;
@@ -2061,7 +2061,7 @@ nge_watchdog(struct ifnet *ifp)
 {
        struct nge_softc *sc = ifp->if_softc;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        kprintf("nge%d: watchdog timeout\n", sc->nge_unit);
 
        nge_stop(sc);
index 5c9d215..3bd01b5 100644 (file)
@@ -777,7 +777,7 @@ pcn_rxeof(struct pcn_softc *sc)
                 * comes up in the ring.
                 */
                if (cur_rx->pcn_rxstat & PCN_RXSTAT_ERR) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        pcn_newbuf(sc, i, m);
                        PCN_INC(i, PCN_RX_LIST_CNT);
                        continue;
@@ -786,7 +786,7 @@ pcn_rxeof(struct pcn_softc *sc)
                if (pcn_newbuf(sc, i, NULL)) {
                        /* Ran out of mbufs; recycle this one. */
                        pcn_newbuf(sc, i, m);
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        PCN_INC(i, PCN_RX_LIST_CNT);
                        continue;
                }
@@ -794,7 +794,7 @@ pcn_rxeof(struct pcn_softc *sc)
                PCN_INC(i, PCN_RX_LIST_CNT);
 
                /* No errors; receive the packet. */
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                m->m_len = m->m_pkthdr.len =
                    cur_rx->pcn_rxlen - ETHER_CRC_LEN;
                m->m_pkthdr.rcvif = ifp;
@@ -839,17 +839,17 @@ pcn_txeof(struct pcn_softc *sc)
                }
 
                if (cur_tx->pcn_txctl & PCN_TXCTL_ERR) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (cur_tx->pcn_txstat & PCN_TXSTAT_EXDEF)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (cur_tx->pcn_txstat & PCN_TXSTAT_RTRY)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                }
 
-               ifp->if_collisions +=
-                   cur_tx->pcn_txstat & PCN_TXSTAT_TRC;
+               IFNET_STAT_INC(ifp, collisions,
+                   cur_tx->pcn_txstat & PCN_TXSTAT_TRC);
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                if (sc->pcn_cdata.pcn_tx_chain[idx] != NULL) {
                        m_freem(sc->pcn_cdata.pcn_tx_chain[idx]);
                        sc->pcn_cdata.pcn_tx_chain[idx] = NULL;
@@ -1302,7 +1302,7 @@ pcn_watchdog(struct ifnet *ifp)
 
        sc = ifp->if_softc;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        kprintf("pcn%d: watchdog timeout\n", sc->pcn_unit);
 
        pcn_stop(sc);
index f50e47b..3acb4a5 100644 (file)
@@ -492,8 +492,8 @@ lp_intr (void *arg)
            sc->sc_iferrs = 0;
 
            len -= CLPIPHDRLEN;
-           sc->sc_if.if_ipackets++;
-           sc->sc_if.if_ibytes += len;
+           IFNET_STAT_INC(&sc->sc_if, ipackets, 1);
+           IFNET_STAT_INC(&sc->sc_if, ibytes, len);
            top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0);
            if (top) {
                if (sc->sc_if.if_bpf)
@@ -537,8 +537,8 @@ lp_intr (void *arg)
            sc->sc_iferrs = 0;
 
            len -= LPIPHDRLEN;
-           sc->sc_if.if_ipackets++;
-           sc->sc_if.if_ibytes += len;
+           IFNET_STAT_INC(&sc->sc_if, ipackets, 1);
+           IFNET_STAT_INC(&sc->sc_if, ibytes, len);
            top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0);
            if (top) {
                if (sc->sc_if.if_bpf)
@@ -551,7 +551,7 @@ lp_intr (void *arg)
     err:
        ppb_wdtr(ppbus, 0);
        lprintf("R");
-       sc->sc_if.if_ierrors++;
+       IFNET_STAT_INC(&sc->sc_if, ierrors, 1);
        sc->sc_iferrs++;
 
        /*
@@ -671,11 +671,11 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
 
        nend:
        if (err)  {                             /* if we didn't timeout... */
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                lprintf("X");
        } else {
-               ifp->if_opackets++;
-               ifp->if_obytes += m->m_pkthdr.len;
+               IFNET_STAT_INC(ifp, opackets, 1);
+               IFNET_STAT_INC(ifp, obytes, m->m_pkthdr.len);
                if (ifp->if_bpf)
                    lptap(ifp, m);
        }
@@ -716,11 +716,11 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
     ppb_wdtr(ppbus, txmitl[*cp] ^ 0x17);
 
     if (err)  {                                /* if we didn't timeout... */
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
         lprintf("X");
     } else {
-       ifp->if_opackets++;
-       ifp->if_obytes += m->m_pkthdr.len;
+       IFNET_STAT_INC(ifp, opackets, 1);
+       IFNET_STAT_INC(ifp, obytes, m->m_pkthdr.len);
        if (ifp->if_bpf)
            lptap(ifp, m);
     }
index fbdcfe2..4d3c16e 100644 (file)
@@ -959,7 +959,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
                                ieee80211_ratectl_tx_complete(vap, ni,
                                    IEEE80211_RATECTL_TX_SUCCESS,
                                    &retrycnt, NULL);
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        break;
 
                case RT2560_TX_SUCCESS_RETRY:
@@ -971,7 +971,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
                                ieee80211_ratectl_tx_complete(vap, ni,
                                    IEEE80211_RATECTL_TX_SUCCESS,
                                    &retrycnt, NULL);
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        break;
 
                case RT2560_TX_FAIL_RETRY:
@@ -983,7 +983,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
                                ieee80211_ratectl_tx_complete(vap, ni,
                                    IEEE80211_RATECTL_TX_FAILURE,
                                    &retrycnt, NULL);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        break;
 
                case RT2560_TX_FAIL_INVALID:
@@ -991,7 +991,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
                default:
                        device_printf(sc->sc_dev, "sending data frame failed "
                            "0x%08x\n", flags);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                }
 
                bus_dmamap_sync(sc->txq.data_dmat, data->map,
@@ -1145,13 +1145,13 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
                        break;
 
                if (data->drop) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
                if ((le32toh(desc->flags) & RT2560_RX_CIPHER_MASK) != 0 &&
                    (le32toh(desc->flags) & RT2560_RX_ICV_ERROR)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1164,7 +1164,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
                 */
                mnew = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
                if (mnew == NULL) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1187,7 +1187,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc)
                                panic("%s: could not load old rx mbuf",
                                    device_get_name(sc->sc_dev));
                        }
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1928,7 +1928,7 @@ rt2560_start_locked(struct ifnet *ifp)
                ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
                if (rt2560_tx_data(sc, m, ni) != 0) {
                        ieee80211_free_node(ni);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        break;
                }
 
@@ -1960,7 +1960,7 @@ rt2560_watchdog_callout(void *arg)
        if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
                if_printf(ifp, "device timeout\n");
                rt2560_init_locked(sc);
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                /* NB: callout is reset in rt2560_init() */
                return;
        }
@@ -2763,7 +2763,7 @@ rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
                return ENOBUFS;         /* XXX */
        }
 
-       ifp->if_opackets++;
+       IFNET_STAT_INC(ifp, opackets, 1);
 
        if (params == NULL) {
                /*
@@ -2784,7 +2784,7 @@ rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
 
        return 0;
 bad:
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        ieee80211_free_node(ni);
        return EIO;             /* XXX */
 }
index 36623e5..976a7c2 100644 (file)
@@ -919,7 +919,7 @@ rt2661_tx_intr(struct rt2661_softc *sc)
                                ieee80211_ratectl_tx_complete(vap, ni,
                                    IEEE80211_RATECTL_TX_SUCCESS,
                                    &retrycnt, NULL);
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                        break;
 
                case RT2661_TX_RETRY_FAIL:
@@ -931,14 +931,14 @@ rt2661_tx_intr(struct rt2661_softc *sc)
                                ieee80211_ratectl_tx_complete(vap, ni,
                                    IEEE80211_RATECTL_TX_FAILURE,
                                    &retrycnt, NULL);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        break;
 
                default:
                        /* other failure */
                        device_printf(sc->sc_dev,
                            "sending data frame failed 0x%08x\n", val);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                }
 
                DPRINTFN(sc, 15, "tx done q=%d idx=%u\n", qid, txq->stat);
@@ -1025,12 +1025,12 @@ rt2661_rx_intr(struct rt2661_softc *sc)
                         */
                        DPRINTFN(sc, 5, "PHY or CRC error flags 0x%08x\n",
                            le32toh(desc->flags));
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
                if ((le32toh(desc->flags) & RT2661_RX_CIPHER_MASK) != 0) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1043,7 +1043,7 @@ rt2661_rx_intr(struct rt2661_softc *sc)
                 */
                mnew = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
                if (mnew == NULL) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1066,7 +1066,7 @@ rt2661_rx_intr(struct rt2661_softc *sc)
                                panic("%s: could not load old rx mbuf",
                                    device_get_name(sc->sc_dev));
                        }
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto skip;
                }
 
@@ -1633,7 +1633,7 @@ rt2661_start_locked(struct ifnet *ifp)
                ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
                if (rt2661_tx_data(sc, m, ni, ac) != 0) {
                        ieee80211_free_node(ni);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        break;
                }
 
@@ -1669,7 +1669,7 @@ rt2661_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
                return ENOBUFS;         /* XXX */
        }
 
-       ifp->if_opackets++;
+       IFNET_STAT_INC(ifp, opackets, 1);
 
        /*
         * Legacy path; interpret frame contents to decide
@@ -1682,7 +1682,7 @@ rt2661_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
 
        return 0;
 bad:
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        ieee80211_free_node(ni);
        return EIO;             /* XXX */
 }
@@ -1701,7 +1701,7 @@ rt2661_watchdog_callout(void *arg)
        if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
                if_printf(ifp, "device timeout\n");
                rt2661_init_locked(sc);
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                /* NB: callout is reset in rt2661_init() */
                return;
        }
index 8094865..d9872b2 100644 (file)
@@ -1959,7 +1959,7 @@ re_rxeof(struct re_softc *sc)
                        rxstat >>= 1;
 
                if (rxstat & RE_RDESC_STAT_RXERRSUM) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        /*
                         * If this is part of a multi-fragment packet,
                         * discard all the pieces.
@@ -1975,7 +1975,7 @@ re_rxeof(struct re_softc *sc)
                 */
 
                if (sc->re_newbuf(sc, i, 0)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        continue;
                }
 
@@ -2003,7 +2003,7 @@ re_rxeof(struct re_softc *sc)
                            (total_len - ETHER_CRC_LEN);
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                m->m_pkthdr.rcvif = ifp;
 
                /* Do RX checksumming if enabled */
@@ -2080,11 +2080,11 @@ re_tx_collect(struct re_softc *sc)
                        sc->re_ldata.re_tx_mbuf[idx] = NULL;
                        if (txstat & (RE_TDESC_STAT_EXCESSCOL|
                            RE_TDESC_STAT_COLCNT))
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (txstat & RE_TDESC_STAT_TXERRSUM)
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                        else
-                               ifp->if_opackets++;
+                               IFNET_STAT_INC(ifp, opackets, 1);
                }
                sc->re_ldata.re_tx_free++;
        }
@@ -2479,7 +2479,7 @@ re_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                error = re_encap(sc, &m_head, &idx);
                if (error) {
                        /* m_head is freed by re_encap(), if we reach here */
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
 
                        if (error == EFBIG && !oactive) {
                                if (re_tx_collect(sc)) {
@@ -2827,7 +2827,7 @@ re_watchdog(struct ifnet *ifp)
 
        if_printf(ifp, "watchdog timeout\n");
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        re_txeof(sc);
        re_rxeof(sc);
index d85568d..5e5e226 100644 (file)
@@ -1024,7 +1024,7 @@ rl_rxeof(struct rl_softc *sc)
                        break;
        
                if ((rxstat & RL_RXSTAT_RXOK) == 0) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        rl_init(sc);
                        return;
                }
@@ -1066,7 +1066,7 @@ rl_rxeof(struct rl_softc *sc)
                        m = m_devget(rxbufpos - RL_ETHER_ALIGN,
                            wrap + RL_ETHER_ALIGN, 0, ifp, NULL);
                        if (m == NULL) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                        } else {
                                m_adj(m, RL_ETHER_ALIGN);
                                m_copyback(m, wrap, total_len - wrap,
@@ -1077,7 +1077,7 @@ rl_rxeof(struct rl_softc *sc)
                        m = m_devget(rxbufpos - RL_ETHER_ALIGN,
                            total_len + RL_ETHER_ALIGN, 0, ifp, NULL);
                        if (m == NULL) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                        } else
                                m_adj(m, RL_ETHER_ALIGN);
                        cur_rx += total_len + 4 + ETHER_CRC_LEN;
@@ -1092,7 +1092,7 @@ rl_rxeof(struct rl_softc *sc)
                if (m == NULL)
                        continue;
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 
                ifp->if_input(ifp, m);
        }
@@ -1122,7 +1122,8 @@ rl_txeof(struct rl_softc *sc)
                               RL_TXSTAT_TXABRT)) == 0)
                        break;
 
-               ifp->if_collisions += (txstat & RL_TXSTAT_COLLCNT) >> 24;
+               IFNET_STAT_INC(ifp, collisions,
+                   (txstat & RL_TXSTAT_COLLCNT) >> 24);
 
                bus_dmamap_unload(sc->rl_cdata.rl_tx_tag, RL_LAST_DMAMAP(sc));
                m_freem(RL_LAST_TXMBUF(sc));
@@ -1136,9 +1137,9 @@ rl_txeof(struct rl_softc *sc)
                }
 
                if (txstat & RL_TXSTAT_TX_OK) {
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                } else {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (txstat & (RL_TXSTAT_TXABRT | RL_TXSTAT_OUTOFWIN))
                                CSR_WRITE_4(sc, RL_TXCFG, RL_TXCFG_CONFIG);
                }
@@ -1562,7 +1563,7 @@ rl_watchdog(struct ifnet *ifp)
 
        device_printf(sc->rl_dev, "watchdog timeout\n");
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        rl_txeof(sc);
        rl_rxeof(sc);
index fa87fb9..56fd4df 100644 (file)
@@ -1419,7 +1419,7 @@ rtw_intr_rx(struct rtw_softc *sc, uint16_t isr)
                        if_printf(ifp, "DMA error/FIFO overflow %08x, "
                                  "rx descriptor %d\n",
                                  hstat & RTW_RXSTAT_IOERROR, next);
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto next;
                }
 
@@ -1436,7 +1436,7 @@ rtw_intr_rx(struct rtw_softc *sc, uint16_t isr)
                if (hwrate >= NELEM(ratetbl)) {
                        if_printf(ifp, "unknown rate #%d\n",
                                  __SHIFTOUT(hstat, RTW_RXSTAT_RATE_MASK));
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        goto next;
                }
                rate = ratetbl[hwrate];
@@ -1594,7 +1594,7 @@ rtw_collect_txpkt(struct rtw_softc *sc, struct rtw_txdesc_blk *tdb,
                condstring = "ok";
                error = 0;
        } else {
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                condstring = "error";
                error = 1;
        }
@@ -2997,11 +2997,11 @@ rtw_dequeue(struct ifnet *ifp, struct rtw_txsoft_blk **tsbp,
                DPRINTF(sc, RTW_DEBUG_XMIT,
                        ("%s: encap error\n", ifp->if_xname));
                ieee80211_free_node(*nip);
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                return -1;
        }
 
-       ifp->if_opackets++;
+       IFNET_STAT_INC(ifp, opackets, 1);
        DPRINTF(sc, RTW_DEBUG_XMIT,
                ("%s: leave %s\n", ifp->if_xname, __func__));
        *mp = m0;
@@ -3414,7 +3414,7 @@ rtw_watchdog(struct ifnet *ifp)
                        if (STAILQ_EMPTY(&tsb->tsb_dirtyq))
                                continue;
                        if_printf(ifp, "transmit timeout, priority %d\n", pri);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        tx_timeouts++;
                } else {
                        ifp->if_timer = 1;
index 0d1893a..f4c2752 100644 (file)
@@ -745,9 +745,9 @@ rue_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
 
        usbd_get_xfer_status(xfer, NULL, (void **)&p, NULL, NULL);
 
-       ifp->if_ierrors += p->rue_rxlost_cnt;
-       ifp->if_ierrors += p->rue_crcerr_cnt;
-       ifp->if_collisions += p->rue_col_cnt;
+       IFNET_STAT_INC(ifp, ierrors, p->rue_rxlost_cnt);
+       IFNET_STAT_INC(ifp, ierrors, p->rue_crcerr_cnt);
+       IFNET_STAT_INC(ifp, collisions, p->rue_col_cnt);
 
        RUE_UNLOCK(sc);
 }
@@ -764,7 +764,7 @@ rue_rxstart(struct ifnet *ifp)
        c = &sc->rue_cdata.rue_rx_chain[sc->rue_cdata.rue_rx_prod];
 
        if (rue_newbuf(sc, c, NULL) == ENOBUFS) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                RUE_UNLOCK(sc);
                return;
        }
@@ -820,7 +820,7 @@ rue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
 
        if (total_len <= ETHER_CRC_LEN) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
@@ -829,14 +829,14 @@ rue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
 
        /* Check recieve packet was valid or not */
        if ((r.rue_rxstat & RUE_RXSTAT_VALID) == 0) {
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto done;
        }
 
        /* No errors; receive the packet. */
        total_len -= ETHER_CRC_LEN;
 
-       ifp->if_ipackets++;
+       IFNET_STAT_INC(ifp, ipackets, 1);
        m->m_pkthdr.rcvif = ifp;
        m->m_pkthdr.len = m->m_len = total_len;
 
@@ -895,9 +895,9 @@ rue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        }
 
        if (err)
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
        else
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
 
        if (!ifq_is_empty(&ifp->if_snd))
                if_devstart(ifp);
@@ -1246,7 +1246,7 @@ rue_watchdog(struct ifnet *ifp)
 
        RUE_LOCK(sc);
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        if_printf(ifp, "watchdog timeout\n");
 
        c = &sc->rue_cdata.rue_tx_chain[0];
index 9ea13d2..b81aeab 100644 (file)
@@ -766,7 +766,7 @@ rum_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
                if (status == USBD_STALLED)
                        usbd_clear_endpoint_stall_async(sc->sc_tx_pipeh);
 
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                crit_exit();
                return;
        }
@@ -778,7 +778,7 @@ rum_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
 
        bzero(data->buf, sizeof(struct rum_tx_data));
        sc->tx_queued--;
-       ifp->if_opackets++;     /* XXX may fail too */
+       IFNET_STAT_INC(ifp, opackets, 1);       /* XXX may fail too */
 
        DPRINTFN(10, ("tx done\n"));
 
@@ -827,7 +827,7 @@ rum_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        if (len < RT2573_RX_DESC_SIZE + sizeof(struct ieee80211_frame_min)) {
                DPRINTF(("%s: xfer too short %d\n", device_get_nameunit(sc->sc_dev),
                    len));
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto skip;
        }
 
@@ -839,7 +839,7 @@ rum_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
                 * those frames when we filled RT2573_TXRX_CSR0.
                 */
                DPRINTFN(5, ("CRC error\n"));
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto skip;
        }
 
@@ -847,7 +847,7 @@ rum_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
        if (mnew == NULL) {
                kprintf("%s: could not allocate rx mbuf\n",
                    device_get_nameunit(sc->sc_dev));
-               ifp->if_ierrors++;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto skip;
        }
 
@@ -1179,7 +1179,7 @@ rum_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
                        if (m0->m_len < sizeof(struct ether_header)) {
                                m0 = m_pullup(m0, sizeof(struct ether_header));
                                if (m0 == NULL) {
-                                       ifp->if_oerrors++;
+                                       IFNET_STAT_INC(ifp, oerrors, 1);
                                        continue;
                                }
                        }
@@ -1204,7 +1204,7 @@ rum_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
 
                        if (rum_tx_data(sc, m0, ni) != 0) {
                                ieee80211_free_node(ni);
-                               ifp->if_oerrors++;
+                               IFNET_STAT_INC(ifp, oerrors, 1);
                                break;
                        }
                }
@@ -1231,7 +1231,7 @@ rum_watchdog(struct ifnet *ifp)
                if (--sc->sc_tx_timer == 0) {
                        kprintf("%s: device timeout\n", device_get_nameunit(sc->sc_dev));
                        /*rum_init(sc); XXX needs a process context! */
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
 
                        crit_exit();
                        return;
@@ -2188,7 +2188,7 @@ rum_stats_update(usbd_xfer_handle xfer, usbd_private_handle priv,
        crit_enter();
 
        /* count TX retry-fail as Tx errors */
-       ifp->if_oerrors += RUM_TX_PKT_FAIL(sc);
+       IFNET_STAT_INC(ifp, oerrors, RUM_TX_PKT_FAIL(sc));
 
        stats->stats_pkt_noretry += RUM_TX_PKT_NO_RETRY(sc);
        stats->stats_pkt_ok += RUM_TX_PKT_NO_RETRY(sc) +
index ebd3cd1..1d06143 100644 (file)
@@ -555,7 +555,7 @@ upload_data(struct sbni_softc *sc, u_int framelen, u_int frameno,
                } else if ((frame_ok = skip_tail(sc, framelen, crc)) != 0) {
                        sc->wait_frameno = 0;
                        sc->inppos = 0;
-                       sc->arpcom.ac_if.if_ierrors++;
+                       IFNET_STAT_INC(&sc->arpcom.ac_if, ierrors, 1);
                        /* now skip all frames until is_first != 0 */
                }
        } else
@@ -567,7 +567,7 @@ upload_data(struct sbni_softc *sc, u_int framelen, u_int frameno,
                 * is_first already... Drop entire packet.
                 */
                sc->wait_frameno = 0;
-               sc->arpcom.ac_if.if_ierrors++;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, ierrors, 1);
        }
 
        return (frame_ok);
@@ -581,7 +581,7 @@ send_complete(struct sbni_softc *sc)
 {
        m_freem(sc->tx_buf_p);
        sc->tx_buf_p = NULL;
-       sc->arpcom.ac_if.if_opackets++;
+       IFNET_STAT_INC(&sc->arpcom.ac_if, opackets, 1);
 }
 
 
@@ -632,7 +632,7 @@ append_frame_to_pkt(struct sbni_softc *sc, u_int framelen, u_int32_t crc)
        sc->inppos += framelen - 4;
        if (--sc->wait_frameno == 0) {          /* last frame received */
                indicate_pkt(sc);
-               sc->arpcom.ac_if.if_ipackets++;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, ipackets, 1);
        }
 
        return (1);
@@ -695,7 +695,7 @@ drop_xmit_queue(struct sbni_softc *sc)
        if (sc->tx_buf_p) {
                m_freem(sc->tx_buf_p);
                sc->tx_buf_p = NULL;
-               sc->arpcom.ac_if.if_oerrors++;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, oerrors, 1);
        }
 
        ifq_purge(&sc->arpcom.ac_if.if_snd);
@@ -911,7 +911,7 @@ static void
 sbni_watchdog(struct ifnet *ifp)
 {
        log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 }
 
 
index 597884b..d603bd7 100644 (file)
@@ -558,7 +558,7 @@ sbsh_intr(void *arg)
                resume_tx(sc);
                sc->regs->SR = UFL;
                ++sc->in_stats.ufl_errs;
-               ++sc->arpcom.ac_if.if_oerrors;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, oerrors, 1);
        }
 
        if (status & RXS) {
@@ -574,13 +574,13 @@ sbsh_intr(void *arg)
 
        if (status & CRC) {
                ++sc->in_stats.crc_errs;
-               ++sc->arpcom.ac_if.if_ierrors;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, ierrors, 1);
                sc->regs->SR = CRC;
        }
 
        if (status & OFL) {
                ++sc->in_stats.ofl_errs;
-               ++sc->arpcom.ac_if.if_ierrors;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, ierrors, 1);
                sc->regs->SR = OFL;
        }
 }
@@ -673,7 +673,7 @@ look_for_nonzero:
 
        sc->regs->LTDR = cur_tbd;
        ++sc->in_stats.sent_pkts;
-       ++sc->arpcom.ac_if.if_opackets;
+       IFNET_STAT_INC(&sc->arpcom.ac_if, opackets, 1);
 }
 
 static struct mbuf *
@@ -783,7 +783,7 @@ indicate_frames(struct sbsh_softc *sc)
 
                ifp->if_input(ifp, m);
                ++sc->in_stats.rcvd_pkts;
-               ++ifp->if_ipackets;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 
                sc->head_rdesc = (sc->head_rdesc + 1) & 0x7f;
        }
index 998f37e..5ee350f 100644 (file)
@@ -943,7 +943,7 @@ sf_rxeof(struct sf_softc *sc)
                SF_INC(bufprodidx, SF_RX_DLIST_CNT);
 
                if (!(cur_rx->sf_status1 & SF_RXSTAT1_OK)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        sf_newbuf(sc, desc, m);
                        continue;
                }
@@ -952,13 +952,13 @@ sf_rxeof(struct sf_softc *sc)
                    cur_rx->sf_len + ETHER_ALIGN, 0, ifp, NULL);
                sf_newbuf(sc, desc, m);
                if (m0 == NULL) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        continue;
                }
                m_adj(m0, ETHER_ALIGN);
                m = m0;
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
 
                ifp->if_input(ifp, m);
        }
@@ -998,11 +998,11 @@ sf_txeof(struct sf_softc *sc)
                cur_tx = &sc->sf_ldata->sf_tx_dlist[cur_cmp->sf_index >> 7];
 
                if (cur_cmp->sf_txstat & SF_TXSTAT_TX_OK)
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                else {
                        if (cur_cmp->sf_txstat & SF_TXSTAT_TX_UNDERRUN)
                                sf_txthresh_adjust(sc);
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                }
 
                sc->sf_tx_cnt--;
@@ -1404,8 +1404,8 @@ sf_stats_update(void *xsc)
                csr_write_4(sc, SF_STATS_BASE +
                    (i + sizeof(u_int32_t)), 0);
 
-       ifp->if_collisions += stats.sf_tx_single_colls +
-           stats.sf_tx_multi_colls + stats.sf_tx_excess_colls;
+       IFNET_STAT_INC(ifp, collisions, stats.sf_tx_single_colls +
+           stats.sf_tx_multi_colls + stats.sf_tx_excess_colls);
 
        mii_tick(mii);
        if (!sc->sf_link) {
@@ -1430,7 +1430,7 @@ sf_watchdog(struct ifnet *ifp)
 
        sc = ifp->if_softc;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        kprintf("sf%d: watchdog timeout\n", sc->sf_unit);
 
        sf_stop(sc);
index ff152a6..0820896 100644 (file)
@@ -1384,9 +1384,9 @@ sis_rxeof(struct sis_softc *sc)
                 * comes up in the ring.
                 */
                if (!(rxstat & SIS_CMDSTS_PKT_OK)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        if (rxstat & SIS_RXSTAT_COLL)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        sis_setup_rxdesc(sc, idx);
                        continue;
                }
@@ -1396,12 +1396,12 @@ sis_rxeof(struct sis_softc *sc)
                        m->m_pkthdr.len = m->m_len = total_len;
                        m->m_pkthdr.rcvif = ifp;
                } else {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        sis_setup_rxdesc(sc, idx);
                        continue;
                }
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                ifp->if_input(ifp, m);
        }
        sc->sis_cdata.sis_rx_prod = i;
@@ -1445,17 +1445,17 @@ sis_txeof(struct sis_softc *sc)
                        continue;
 
                if (!(cur_tx->sis_ctl & SIS_CMDSTS_PKT_OK)) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (cur_tx->sis_txstat & SIS_TXSTAT_EXCESSCOLLS)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                        if (cur_tx->sis_txstat & SIS_TXSTAT_OUTOFWINCOLL)
-                               ifp->if_collisions++;
+                               IFNET_STAT_INC(ifp, collisions, 1);
                }
 
-               ifp->if_collisions +=
-                   (cur_tx->sis_txstat & SIS_TXSTAT_COLLCNT) >> 16;
+               IFNET_STAT_INC(ifp, collisions,
+                   (cur_tx->sis_txstat & SIS_TXSTAT_COLLCNT) >> 16);
 
-               ifp->if_opackets++;
+               IFNET_STAT_INC(ifp, opackets, 1);
                if (td->sis_mbuf != NULL) {
                        bus_dmamap_unload(cd->sis_txbuf_tag, td->sis_map);
                        m_freem(td->sis_mbuf);
@@ -1726,7 +1726,7 @@ sis_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
 
                error = sis_encap(sc, &m_head, &idx);
                if (error) {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if (sc->sis_cdata.sis_tx_cnt == 0) {
                                continue;
                        } else {
@@ -2007,7 +2007,7 @@ sis_watchdog(struct ifnet *ifp)
 
        sc = ifp->if_softc;
 
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
        if_printf(ifp, "watchdog timeout\n");
 
        sis_stop(sc);
index 8167fdc..03343f2 100644 (file)
@@ -1766,7 +1766,7 @@ sk_watchdog(struct ifnet *ifp)
        sk_txeof(sc_if);
        if (sc_if->sk_cdata.sk_tx_cnt != 0) {
                if_printf(&sc_if->arpcom.ac_if, "watchdog timeout\n");
-               ifp->if_oerrors++;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                ifp->if_flags &= ~IFF_RUNNING;
                sk_init(sc_if);
        }
@@ -1871,7 +1871,7 @@ sk_rxeof(struct sk_if_softc *sc_if)
                    SK_RXCTL_FIRSTFRAG | SK_RXCTL_LASTFRAG) ||
                    total_len < SK_MIN_FRAMELEN || total_len > max_frmlen ||
                    sk_rxvalid(sc, rxstat, total_len) == 0) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        cur_desc->sk_ctl = htole32(m->m_pkthdr.len | SK_RXSTAT);
                        continue;
                }
@@ -1884,7 +1884,7 @@ sk_rxeof(struct sk_if_softc *sc_if)
                 * the packet.
                 */
                if (sk_newbuf(sc_if, cur, 0)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        cur_desc->sk_ctl = htole32(m->m_pkthdr.len | SK_RXSTAT);
                        continue;
                } else {
@@ -1896,7 +1896,7 @@ sk_rxeof(struct sk_if_softc *sc_if)
                sk_rxcsum(ifp, m, csum1, csum2);
 #endif
 
-               ifp->if_ipackets++;
+               IFNET_STAT_INC(ifp, ipackets, 1);
                ifp->if_input(ifp, m);
        }
 }
@@ -2022,7 +2022,7 @@ sk_txeof(struct sk_if_softc *sc_if)
                if (sk_ctl & SK_TXCTL_OWN)
                        break;
                if (sk_ctl & SK_TXCTL_LASTFRAG)
-                       ifp->if_opackets++;
+                       IFNET_STAT_INC(ifp, opackets, 1);
                if (cd->sk_tx_mbuf[idx] != NULL) {
                        bus_dmamap_unload(cd->sk_tx_dtag, cd->sk_tx_dmap[idx]);
                        m_freem(cd->sk_tx_mbuf[idx]);
index b705540..a817f19 100644 (file)
@@ -850,6 +850,10 @@ sln_rx(struct sln_softc *sc)
        rx_offset = (dirty_rx - vtophys(sc->sln_bufdata.sln_rx_buf)) & (u_long) (SL_RX_BUFLEN - 1);
 
        while (rx_len > 0) {
+#ifdef SLN_DEBUG
+               u_long ipkts;
+#endif
+
                rx_bufpos = sc->sln_bufdata.sln_rx_buf + rx_offset;
                rxstat = *(uint32_t *) rx_bufpos;
                rx_size = (rxstat >> 20) & 0x0FFF;
@@ -861,7 +865,7 @@ sln_rx(struct sln_softc *sc)
 
                /* errors receive packets caculatation */
                if (rxstat == 0 || rx_size < 16 || !(rxstat & SL_RXSTAT_RXOK)) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
 
                        if (!(rxstat & SL_RXSTAT_RXOK))
                                if_printf(ifp, "receiver ok error\n");
@@ -909,7 +913,7 @@ sln_rx(struct sln_softc *sc)
                                                                                         * align */
 
                        if (m == NULL) {
-                               ifp->if_ierrors++;
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                if_printf(ifp,
                                    "out of mbufs, tried to copy %ld bytes\n",
                                    rx_space);
@@ -921,19 +925,25 @@ sln_rx(struct sln_softc *sc)
                        m = m_devget(rx_bufpos - 2, pkt_size + 2, 0, ifp, NULL);
 
                        if (m == NULL) {
-                               ifp->if_ierrors++;
+                               u_long ierr;
+
+                               IFNET_STAT_INC(ifp, ierrors, 1);
                                if_printf(ifp,
                                    "out of mbufs, tried to copy %ld bytes\n",
                                    pkt_size);
-                               if_printf(ifp, "ierrors = %ld\n", ifp->if_ierrors);
 
+                               IFNET_STAT_GET(ifp, ierrors, ierr);
+                               if_printf(ifp, "ierrors = %lu\n", ierr);
                        } else {
                                m_adj(m, 2);
                        }
                }
 
-               ifp->if_ipackets++;
-               PDEBUG("ipackets = %ld\n", ifp->if_ipackets);
+               IFNET_STAT_INC(ifp, ipackets, 1);
+#ifdef SLN_DEBUG
+               IFNET_STAT_GET(ifp, ipackets, ipkts);
+               PDEBUG("ipackets = %lu\n", ipkts);
+#endif
 
                ifp->if_input(ifp, m);
 
@@ -969,12 +979,20 @@ sln_tx_intr(struct sln_softc *sc)
                        SL_DIRTY_TXBUF(sc) = NULL;
                }
                if (txstat & SL_TXSD_TOK) {
-                       ifp->if_opackets++;
-                       ifp->if_obytes += txstat & SL_TXSD_LENMASK;
-                       PDEBUG("opackets = %ld\n", ifp->if_opackets);
-                       ifp->if_collisions += (txstat & SL_TXSD_NCC) >> 22;
+#ifdef SLN_DEBUG
+                       u_long opkts;
+#endif
+
+                       IFNET_STAT_INC(ifp, opackets, 1);
+                       IFNET_STAT_INC(ifp, obytes, txstat & SL_TXSD_LENMASK);
+#ifdef SLN_DEBUG
+                       IFNET_STAT_GET(ifp, opackets, opkts);
+                       PDEBUG("opackets = %lu\n", opkts);
+#endif
+                       IFNET_STAT_INC(ifp, collisions,
+                           (txstat & SL_TXSD_NCC) >> 22);
                } else {
-                       ifp->if_oerrors++;
+                       IFNET_STAT_INC(ifp, oerrors, 1);
                        if ((txstat & (SL_TXSD_TABT | SL_TXSD_OWC))) {
                                sc->txcfg = TX_CFG_DEFAULT;
 
@@ -1075,7 +1093,7 @@ sln_interrupt(void *arg)
                        sln_tx_intr(sc);
 
                if (int_status & SL_INT_RBO) {
-                       ifp->if_ierrors++;
+                       IFNET_STAT_INC(ifp, ierrors, 1);
                        PDEBUG("rx buffer is overflow\n");
                }
 
@@ -1143,7 +1161,7 @@ sln_watchdog(struct ifnet *ifp)
        ASSERT_SERIALIZED(ifp->if_serializer);
 
        if_printf(ifp, "watchdog timeout!\n");
-       ifp->if_oerrors++;
+       IFNET_STAT_INC(ifp, oerrors, 1);
 
        sln_tx_intr(sc);
        sln_rx(sc);
index 09d5e82..487504b 100644 (file)
@@ -383,7 +383,7 @@ startagain:
         */
        if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) {
                kprintf("%s: large packet discarded (A)\n", ifp->if_xname);
-               ++sc->arpcom.ac_if.if_oerrors;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, oerrors, 1);
                m_freem(top);
                goto readcheck;
        }
@@ -523,7 +523,7 @@ startagain:
 
        BPF_MTAP(ifp, top);
 
-       ifp->if_opackets++;
+       IFNET_STAT_INC(ifp, opackets, 1);
        m_freem(top);
 
 readcheck:
@@ -592,7 +592,7 @@ snresume(struct ifnet *ifp)
         */
        if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) {
                kprintf("%s: large packet discarded (B)\n", ifp->if_xname);
-               ++ifp->if_oerrors;
+               IFNET_STAT_INC(ifp, oerrors, 1);
                m_freem(top);
                return;
        }
@@ -711,7 +711,7 @@ snresume(struct ifnet *ifp)
 
        BPF_MTAP(ifp, top);
 
-       ifp->if_opackets++;
+       IFNET_STAT_INC(ifp, opackets, 1);
        m_freem(top);
 
 try_start:
@@ -782,7 +782,7 @@ sn_intr(void *arg)
                SMC_SELECT_BANK(2);
                outb(BASE + INTR_ACK_REG_B, IM_RX_OVRN_INT);
 
-               ++sc->arpcom.ac_if.if_ierrors;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, ierrors, 1);
        }
        /*
         * Got a packet.
@@ -854,11 +854,11 @@ sn_intr(void *arg)
                        device_printf(sc->dev, 
                            "Successful packet caused interrupt\n");
                } else {
-                       ++sc->arpcom.ac_if.if_oerrors;
+                       IFNET_STAT_INC(&sc->arpcom.ac_if, oerrors, 1);
                }
 
                if (tx_status & EPHSR_LATCOL)
-                       ++sc->arpcom.ac_if.if_collisions;
+                       IFNET_STAT_INC(&sc->arpcom.ac_if, collisions, 1);
 
                /*
                 * Some of these errors will have disabled transmit.
@@ -909,12 +909,14 @@ sn_intr(void *arg)
                /*
                 * Single collisions
                 */
-               sc->arpcom.ac_if.if_collisions += card_stats & ECR_COLN_MASK;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, collisions,
+                   card_stats & ECR_COLN_MASK);
 
                /*
                 * Multiple collisions
                 */
-               sc->arpcom.ac_if.if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4;
+               IFNET_STAT_INC(&sc->arpcom.ac_if, collisions,
+                   (card_stats & ECR_MCOLN_MASK) >> 4);
 
                SMC_SELECT_BANK(2);
 
@@ -998,7 +1000,7 @@ read_another:
         * Account for receive errors and discard.
         */
        if (status & RS_ERRORS) {
-               ++ifp->if_ierrors;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                goto out;
        }
        /*
@@ -1031,7 +1033,7 @@ read_another:
         */
        if ((m->m_flags & M_EXT) == 0) {
                m_freem(m);
-               ++ifp->if_ierrors;
+               IFNET_STAT_INC(ifp, ierrors, 1);
                kprintf("sn: snread() kernel memory allocation problem\n");
                goto out;
        }
@@ -1046,7 +1048,7 @@ read_another:
                data += packet_length & ~1;
                *data = inb(BASE + DATA_REG_B);
        }
-       ++ifp->if_ipackets;
+       IFNET_STAT_INC(ifp, ipackets, 1);
 
        m->m_pkthdr.len = m->m_len = packet_length;
 
index a704024..8fc8796 100644 (file)
@@ -874,7 +874,7 @@ top_srstart:
                 */
                m_freem(mtx);
 #ifndef NETGRAPH
-               ++sc->ifsppp.pp_if.if_opackets;
+               IFNET_STAT_INC(&sc->ifsppp.pp_if, opackets, 1);
 #else  /* NETGRAPH */
                sc->opackets++;
 #endif /* NETGRAPH */
@@ -1064,7 +1064,7 @@ srwatchdog(struct sr_softc *sc)
        if (!(ifp->if_flags & IFF_RUNNING))
                return;
 
-       ifp->if_oerrors++;      /* update output error count */
+       IFNET_STAT_INC(ifp, oerrors, 1);        /* update output error count */
 #else  /* NETGRAPH */
        sc->oerrors++;  /* update output error count */
 #endif /* NETGRAPH */