From d40991ef14685afbf3a2f143caceb273aa9da6fe Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 13 Feb 2013 14:00:14 +0800 Subject: [PATCH] if: Per-cpu ifnet/ifaddr statistics, step 1/3 Wrap ifnet/ifaddr stats updating, setting and extraction into macros; ease upcoming changes. --- sys/bus/u4b/net/if_axe.c | 12 +- sys/bus/u4b/net/if_udav.c | 10 +- sys/bus/u4b/net/usb_ethernet.c | 6 +- sys/dev/atm/en/midway.c | 6 +- sys/dev/netif/acx/if_acx.c | 20 ++-- sys/dev/netif/ae/if_ae.c | 12 +- sys/dev/netif/age/if_age.c | 22 ++-- sys/dev/netif/alc/if_alc.c | 22 ++-- sys/dev/netif/ale/if_ale.c | 22 ++-- sys/dev/netif/an/if_an.c | 36 +++--- sys/dev/netif/ar/if_ar.c | 95 +++++++++------- sys/dev/netif/ath/ath/if_ath.c | 20 ++-- sys/dev/netif/aue/if_aue.c | 14 +-- sys/dev/netif/axe/if_axe.c | 12 +- sys/dev/netif/bce/if_bce.c | 28 ++--- sys/dev/netif/bfe/if_bfe.c | 18 +-- sys/dev/netif/bge/if_bge.c | 35 +++--- sys/dev/netif/bnx/if_bnx.c | 25 ++-- sys/dev/netif/bwi/if_bwi.c | 22 ++-- sys/dev/netif/cs/if_cs.c | 16 +-- sys/dev/netif/cue/if_cue.c | 23 ++-- sys/dev/netif/dc/if_dc.c | 42 ++++--- sys/dev/netif/de/if_de.c | 10 +- sys/dev/netif/ed/if_ed.c | 16 +-- sys/dev/netif/em/if_em.c | 24 ++-- sys/dev/netif/emx/if_emx.c | 25 ++-- sys/dev/netif/ep/if_ep.c | 14 +-- sys/dev/netif/et/if_et.c | 14 +-- sys/dev/netif/ex/if_ex.c | 20 ++-- sys/dev/netif/fe/if_fe.c | 23 ++-- sys/dev/netif/fwe/if_fwe.c | 10 +- sys/dev/netif/fxp/if_fxp.c | 18 +-- sys/dev/netif/ic/if_ic.c | 16 +-- sys/dev/netif/igb/if_igb.c | 22 ++-- sys/dev/netif/iwi/if_iwi.c | 12 +- sys/dev/netif/iwl/iwl2100.c | 16 +-- sys/dev/netif/iwn/if_iwn.c | 18 +-- sys/dev/netif/ixgbe/ixgbe.c | 21 ++-- sys/dev/netif/jme/if_jme.c | 22 ++-- sys/dev/netif/kue/if_kue.c | 12 +- sys/dev/netif/lge/if_lge.c | 14 +-- sys/dev/netif/lgue/if_lgue.c | 12 +- sys/dev/netif/lnc/am7990.c | 28 ++--- sys/dev/netif/lnc/am79900.c | 26 ++--- sys/dev/netif/lnc/lance.c | 2 +- sys/dev/netif/msk/if_msk.c | 16 +-- sys/dev/netif/mxge/if_mxge.c | 10 +- sys/dev/netif/my/if_my.c | 27 ++--- sys/dev/netif/ndis/if_ndis.c | 8 +- sys/dev/netif/nfe/if_nfe.c | 18 +-- sys/dev/netif/nge/if_nge.c | 20 ++-- sys/dev/netif/pcn/if_pcn.c | 20 ++-- sys/dev/netif/plip/if_plip.c | 22 ++-- sys/dev/netif/ral/rt2560.c | 24 ++-- sys/dev/netif/ral/rt2661.c | 22 ++-- sys/dev/netif/re/if_re.c | 16 +-- sys/dev/netif/rl/if_rl.c | 17 +-- sys/dev/netif/rtw/rtw.c | 12 +- sys/dev/netif/rue/if_rue.c | 20 ++-- sys/dev/netif/rum/if_rum.c | 18 +-- sys/dev/netif/sbni/if_sbni.c | 12 +- sys/dev/netif/sbsh/if_sbsh.c | 10 +- sys/dev/netif/sf/if_sf.c | 16 +-- sys/dev/netif/sis/if_sis.c | 24 ++-- sys/dev/netif/sk/if_sk.c | 10 +- sys/dev/netif/sln/if_sln.c | 44 +++++--- sys/dev/netif/sn/if_sn.c | 26 +++-- sys/dev/netif/sr/if_sr.c | 113 +++++++++++-------- sys/dev/netif/ste/if_ste.c | 18 +-- sys/dev/netif/stge/if_stge.c | 18 +-- sys/dev/netif/ti/if_ti.c | 23 ++-- sys/dev/netif/tl/if_tl.c | 18 +-- sys/dev/netif/tx/if_tx.c | 22 ++-- sys/dev/netif/txp/if_txp.c | 21 ++-- sys/dev/netif/ural/if_ural.c | 18 +-- sys/dev/netif/vge/if_vge.c | 18 +-- sys/dev/netif/vr/if_vr.c | 25 ++-- sys/dev/netif/vx/if_vx.c | 16 +-- sys/dev/netif/wb/if_wb.c | 25 ++-- sys/dev/netif/wi/if_wi.c | 23 ++-- sys/dev/netif/wpi/if_wpi.c | 22 ++-- sys/dev/netif/xe/if_xe.c | 32 +++--- sys/dev/netif/xl/if_xl.c | 35 +++--- sys/dev/virtual/vkernel/net/if_vke.c | 6 +- sys/net/bridge/if_bridge.c | 26 ++--- sys/net/disc/if_disc.c | 4 +- sys/net/ef/if_ef.c | 4 +- sys/net/faith/if_faith.c | 8 +- sys/net/gif/if_gif.c | 10 +- sys/net/gre/if_gre.c | 6 +- sys/net/if.c | 8 +- sys/net/if_atmsubr.c | 2 +- sys/net/if_ethersubr.c | 18 +-- sys/net/if_loop.c | 12 +- sys/net/if_var.h | 20 ++++ sys/net/ifq_var.h | 4 +- sys/net/pf/if_pflog.c | 4 +- sys/net/pf/if_pfsync.c | 4 +- sys/net/ppp/if_ppp.c | 16 +-- sys/net/ppp_layer/ppp_tty.c | 6 +- sys/net/sl/if_sl.c | 33 +++--- sys/net/sppp/if_spppsubr.c | 54 ++++----- sys/net/stf/if_stf.c | 4 +- sys/net/tap/if_tap.c | 8 +- sys/net/tun/if_tun.c | 14 +-- sys/net/vlan/if_vlan.c | 8 +- sys/netgraph/eiface/ng_eiface.c | 6 +- sys/netgraph/fec/ng_fec.c | 8 +- sys/netgraph/iface/ng_iface.c | 8 +- sys/netgraph7/iface/ng_iface.c | 10 +- sys/netinet/ip_carp.c | 18 +-- sys/netinet/ip_gre.c | 8 +- sys/netinet/ip_input.c | 4 +- sys/netinet/ip_output.c | 9 +- sys/netinet6/ip6_input.c | 4 +- sys/netinet6/ip6_output.c | 9 +- sys/netproto/802_11/wlan/ieee80211.c | 2 +- sys/netproto/802_11/wlan/ieee80211_adhoc.c | 2 +- sys/netproto/802_11/wlan/ieee80211_hostap.c | 8 +- sys/netproto/802_11/wlan/ieee80211_input.c | 2 +- sys/netproto/802_11/wlan/ieee80211_mesh.c | 14 ++- sys/netproto/802_11/wlan/ieee80211_monitor.c | 2 +- sys/netproto/802_11/wlan/ieee80211_output.c | 18 +-- sys/netproto/802_11/wlan/ieee80211_sta.c | 2 +- sys/netproto/802_11/wlan/ieee80211_superg.c | 2 +- sys/netproto/802_11/wlan/ieee80211_wds.c | 12 +- sys/netproto/ipx/ipx_ip.c | 16 +-- 127 files changed, 1151 insertions(+), 1064 deletions(-) diff --git a/sys/bus/u4b/net/if_axe.c b/sys/bus/u4b/net/if_axe.c index ab4e16ac0b..47d2b17161 100644 --- a/sys/bus/u4b/net/if_axe.c +++ b/sys/bus/u4b/net/if_axe.c @@ -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 */ diff --git a/sys/bus/u4b/net/if_udav.c b/sys/bus/u4b/net/if_udav.c index 188945ceb6..7acb9dc533 100644 --- a/sys/bus/u4b/net/if_udav.c +++ b/sys/bus/u4b/net/if_udav.c @@ -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); diff --git a/sys/bus/u4b/net/usb_ethernet.c b/sys/bus/u4b/net/usb_ethernet.c index 942b7d1cb1..69376155cb 100644 --- a/sys/bus/u4b/net/usb_ethernet.c +++ b/sys/bus/u4b/net/usb_ethernet.c @@ -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; diff --git a/sys/dev/atm/en/midway.c b/sys/dev/atm/en/midway.c index ff6819344b..d53c7ee030 100644 --- a/sys/dev/atm/en/midway.c +++ b/sys/dev/atm/en/midway.c @@ -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; diff --git a/sys/dev/netif/acx/if_acx.c b/sys/dev/netif/acx/if_acx.c index d0f7af5751..f4ec703d47 100644 --- a/sys/dev/netif/acx/if_acx.c +++ b/sys/dev/netif/acx/if_acx.c @@ -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 && diff --git a/sys/dev/netif/ae/if_ae.c b/sys/dev/netif/ae/if_ae.c index 63209a406f..14ed2402a3 100644 --- a/sys/dev/netif/ae/if_ae.c +++ b/sys/dev/netif/ae/if_ae.c @@ -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)) diff --git a/sys/dev/netif/age/if_age.c b/sys/dev/netif/age/if_age.c index 164eead4e3..e8f04520b1 100644 --- a/sys/dev/netif/age/if_age.c +++ b/sys/dev/netif/age/if_age.c @@ -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); diff --git a/sys/dev/netif/alc/if_alc.c b/sys/dev/netif/alc/if_alc.c index 572c075917..27d7a22265 100644 --- a/sys/dev/netif/alc/if_alc.c +++ b/sys/dev/netif/alc/if_alc.c @@ -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); diff --git a/sys/dev/netif/ale/if_ale.c b/sys/dev/netif/ale/if_ale.c index edd92a3780..e70c1b4314 100644 --- a/sys/dev/netif/ale/if_ale.c +++ b/sys/dev/netif/ale/if_ale.c @@ -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; } diff --git a/sys/dev/netif/an/if_an.c b/sys/dev/netif/an/if_an.c index 08a9524075..dc5735afab 100644 --- a/sys/dev/netif/an/if_an.c +++ b/sys/dev/netif/an/if_an.c @@ -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"); } diff --git a/sys/dev/netif/ar/if_ar.c b/sys/dev/netif/ar/if_ar.c index a2fded9395..6a540bd3a6 100644 --- a/sys/dev/netif/ar/if_ar.c +++ b/sys/dev/netif/ar/if_ar.c @@ -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); } } diff --git a/sys/dev/netif/ath/ath/if_ath.c b/sys/dev/netif/ath/ath/if_ath.c index 0d4f153c8c..c40aada982 100644 --- a/sys/dev/netif/ath/ath/if_ath.c +++ b/sys/dev/netif/ath/ath/if_ath.c @@ -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; diff --git a/sys/dev/netif/aue/if_aue.c b/sys/dev/netif/aue/if_aue.c index 4b0a97e8b3..57e9b70c1c 100644 --- a/sys/dev/netif/aue/if_aue.c +++ b/sys/dev/netif/aue/if_aue.c @@ -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]; diff --git a/sys/dev/netif/axe/if_axe.c b/sys/dev/netif/axe/if_axe.c index 6fd394f1b9..39be2b0715 100644 --- a/sys/dev/netif/axe/if_axe.c +++ b/sys/dev/netif/axe/if_axe.c @@ -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]; diff --git a/sys/dev/netif/bce/if_bce.c b/sys/dev/netif/bce/if_bce.c index 602a4a1db8..9ddb6b87a6 100644 --- a/sys/dev/netif/bce/if_bce.c +++ b/sys/dev/netif/bce/if_bce.c @@ -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__); } diff --git a/sys/dev/netif/bfe/if_bfe.c b/sys/dev/netif/bfe/if_bfe.c index a27ebff0a6..34317f4d7b 100644 --- a/sys/dev/netif/bfe/if_bfe.c +++ b/sys/dev/netif/bfe/if_bfe.c @@ -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 diff --git a/sys/dev/netif/bge/if_bge.c b/sys/dev/netif/bge/if_bge.c index 9e46978d27..10bc56737b 100644 --- a/sys/dev/netif/bge/if_bge.c +++ b/sys/dev/netif/bge/if_bge.c @@ -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); diff --git a/sys/dev/netif/bnx/if_bnx.c b/sys/dev/netif/bnx/if_bnx.c index 6b71bb6453..45d4358ef9 100644 --- a/sys/dev/netif/bnx/if_bnx.c +++ b/sys/dev/netif/bnx/if_bnx.c @@ -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); diff --git a/sys/dev/netif/bwi/if_bwi.c b/sys/dev/netif/bwi/if_bwi.c index 08b725e3f8..5a6b7b36d4 100644 --- a/sys/dev/netif/bwi/if_bwi.c +++ b/sys/dev/netif/bwi/if_bwi.c @@ -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) diff --git a/sys/dev/netif/cs/if_cs.c b/sys/dev/netif/cs/if_cs.c index 44862bf19b..670ae397be 100644 --- a/sys/dev/netif/cs/if_cs.c +++ b/sys/dev/netif/cs/if_cs.c @@ -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 */ diff --git a/sys/dev/netif/cue/if_cue.c b/sys/dev/netif/cue/if_cue.c index e00f4ee20f..8e9475f38b 100644 --- a/sys/dev/netif/cue/if_cue.c +++ b/sys/dev/netif/cue/if_cue.c @@ -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]; diff --git a/sys/dev/netif/dc/if_dc.c b/sys/dev/netif/dc/if_dc.c index e8566e8e0b..231e8d190b 100644 --- a/sys/dev/netif/dc/if_dc.c +++ b/sys/dev/netif/dc/if_dc.c @@ -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); diff --git a/sys/dev/netif/de/if_de.c b/sys/dev/netif/de/if_de.c index 0c38297893..0b571f0da3 100644 --- a/sys/dev/netif/de/if_de.c +++ b/sys/dev/netif/de/if_de.c @@ -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; } diff --git a/sys/dev/netif/ed/if_ed.c b/sys/dev/netif/ed/if_ed.c index c34e4c4463..ec4af3c30b 100644 --- a/sys/dev/netif/ed/if_ed.c +++ b/sys/dev/netif/ed/if_ed.c @@ -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)); diff --git a/sys/dev/netif/em/if_em.c b/sys/dev/netif/em/if_em.c index ecbb696e7e..4318d7de7b 100644 --- a/sys/dev/netif/em/if_em.c +++ b/sys/dev/netif/em/if_em.c @@ -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 diff --git a/sys/dev/netif/emx/if_emx.c b/sys/dev/netif/emx/if_emx.c index e76867857d..b0830b6910 100644 --- a/sys/dev/netif/emx/if_emx.c +++ b/sys/dev/netif/emx/if_emx.c @@ -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 diff --git a/sys/dev/netif/ep/if_ep.c b/sys/dev/netif/ep/if_ep.c index 186b9c78b6..bbd98cabe3 100644 --- a/sys/dev/netif/ep/if_ep.c +++ b/sys/dev/netif/ep/if_ep.c @@ -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; diff --git a/sys/dev/netif/et/if_et.c b/sys/dev/netif/et/if_et.c index 2f0d1a79b7..119d62ca7f 100644 --- a/sys/dev/netif/et/if_et.c +++ b/sys/dev/netif/et/if_et.c @@ -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) { diff --git a/sys/dev/netif/ex/if_ex.c b/sys/dev/netif/ex/if_ex.c index 782175ab7a..64b2c52e9e 100644 --- a/sys/dev/netif/ex/if_ex.c +++ b/sys/dev/netif/ex/if_ex.c @@ -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); diff --git a/sys/dev/netif/fe/if_fe.c b/sys/dev/netif/fe/if_fe.c index c45252bd5d..9ee9173e1f 100644 --- a/sys/dev/netif/fe/if_fe.c +++ b/sys/dev/netif/fe/if_fe.c @@ -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; } diff --git a/sys/dev/netif/fwe/if_fwe.c b/sys/dev/netif/fwe/if_fwe.c index 3dada38ac1..d2c15c0635 100644 --- a/sys/dev/netif/fwe/if_fwe.c +++ b/sys/dev/netif/fwe/if_fwe.c @@ -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); diff --git a/sys/dev/netif/fxp/if_fxp.c b/sys/dev/netif/fxp/if_fxp.c index dc4101cc3b..b6a7450656 100644 --- a/sys/dev/netif/fxp/if_fxp.c +++ b/sys/dev/netif/fxp/if_fxp.c @@ -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); } diff --git a/sys/dev/netif/ic/if_ic.c b/sys/dev/netif/ic/if_ic.c index bd1011ddc4..84dfd71b85 100644 --- a/sys/dev/netif/ic/if_ic.c +++ b/sys/dev/netif/ic/if_ic.c @@ -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; diff --git a/sys/dev/netif/igb/if_igb.c b/sys/dev/netif/igb/if_igb.c index e3fe181ebe..af19a9578f 100644 --- a/sys/dev/netif/igb/if_igb.c +++ b/sys/dev/netif/igb/if_igb.c @@ -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); diff --git a/sys/dev/netif/iwi/if_iwi.c b/sys/dev/netif/iwi/if_iwi.c index 2d34c02fad..53157c5902 100644 --- a/sys/dev/netif/iwi/if_iwi.c +++ b/sys/dev/netif/iwi/if_iwi.c @@ -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(); diff --git a/sys/dev/netif/iwl/iwl2100.c b/sys/dev/netif/iwl/iwl2100.c index 86be329b93..6589b49a42 100644 --- a/sys/dev/netif/iwl/iwl2100.c +++ b/sys/dev/netif/iwl/iwl2100.c @@ -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; } diff --git a/sys/dev/netif/iwn/if_iwn.c b/sys/dev/netif/iwn/if_iwn.c index 10e9e45a79..561c543807 100644 --- a/sys/dev/netif/iwn/if_iwn.c +++ b/sys/dev/netif/iwn/if_iwn.c @@ -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; } diff --git a/sys/dev/netif/ixgbe/ixgbe.c b/sys/dev/netif/ixgbe/ixgbe.c index 8b345777d1..1c2aaebf58 100644 --- a/sys/dev/netif/ixgbe/ixgbe.c +++ b/sys/dev/netif/ixgbe/ixgbe.c @@ -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 diff --git a/sys/dev/netif/jme/if_jme.c b/sys/dev/netif/jme/if_jme.c index 629bb687f1..7bf30dcf85 100644 --- a/sys/dev/netif/jme/if_jme.c +++ b/sys/dev/netif/jme/if_jme.c @@ -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); diff --git a/sys/dev/netif/kue/if_kue.c b/sys/dev/netif/kue/if_kue.c index 6d46427a37..1fc0346fc4 100644 --- a/sys/dev/netif/kue/if_kue.c +++ b/sys/dev/netif/kue/if_kue.c @@ -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]; diff --git a/sys/dev/netif/lge/if_lge.c b/sys/dev/netif/lge/if_lge.c index 38c26d779f..35e783f4f9 100644 --- a/sys/dev/netif/lge/if_lge.c +++ b/sys/dev/netif/lge/if_lge.c @@ -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); diff --git a/sys/dev/netif/lgue/if_lgue.c b/sys/dev/netif/lgue/if_lgue.c index d62be4112a..ce4c98926b 100644 --- a/sys/dev/netif/lgue/if_lgue.c +++ b/sys/dev/netif/lgue/if_lgue.c @@ -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); diff --git a/sys/dev/netif/lnc/am7990.c b/sys/dev/netif/lnc/am7990.c index bfba8d4281..714a4b933d 100644 --- a/sys/dev/netif/lnc/am7990.c +++ b/sys/dev/netif/lnc/am7990.c @@ -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; } diff --git a/sys/dev/netif/lnc/am79900.c b/sys/dev/netif/lnc/am79900.c index a575ae4552..5fbc4bda49 100644 --- a/sys/dev/netif/lnc/am79900.c +++ b/sys/dev/netif/lnc/am79900.c @@ -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; } diff --git a/sys/dev/netif/lnc/lance.c b/sys/dev/netif/lnc/lance.c index 0d24774e92..597ce24683 100644 --- a/sys/dev/netif/lnc/lance.c +++ b/sys/dev/netif/lnc/lance.c @@ -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); } diff --git a/sys/dev/netif/msk/if_msk.c b/sys/dev/netif/msk/if_msk.c index 24aa34335e..ad61266c68 100644 --- a/sys/dev/netif/msk/if_msk.c +++ b/sys/dev/netif/msk/if_msk.c @@ -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); diff --git a/sys/dev/netif/mxge/if_mxge.c b/sys/dev/netif/mxge/if_mxge.c index 37baddacc6..50b2db9971 100644 --- a/sys/dev/netif/mxge/if_mxge.c +++ b/sys/dev/netif/mxge/if_mxge.c @@ -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 diff --git a/sys/dev/netif/my/if_my.c b/sys/dev/netif/my/if_my.c index 53e1b139e7..6047cb496a 100644 --- a/sys/dev/netif/my/if_my.c +++ b/sys/dev/netif/my/if_my.c @@ -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", diff --git a/sys/dev/netif/ndis/if_ndis.c b/sys/dev/netif/ndis/if_ndis.c index 6751a0e96e..d373f3b6f9 100644 --- a/sys/dev/netif/ndis/if_ndis.c +++ b/sys/dev/netif/ndis/if_ndis.c @@ -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, diff --git a/sys/dev/netif/nfe/if_nfe.c b/sys/dev/netif/nfe/if_nfe.c index ab11def666..2f9735a9fd 100644 --- a/sys/dev/netif/nfe/if_nfe.c +++ b/sys/dev/netif/nfe/if_nfe.c @@ -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 diff --git a/sys/dev/netif/nge/if_nge.c b/sys/dev/netif/nge/if_nge.c index b8a932a783..e26f76906c 100644 --- a/sys/dev/netif/nge/if_nge.c +++ b/sys/dev/netif/nge/if_nge.c @@ -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); diff --git a/sys/dev/netif/pcn/if_pcn.c b/sys/dev/netif/pcn/if_pcn.c index 5c9d215599..3bd01b501d 100644 --- a/sys/dev/netif/pcn/if_pcn.c +++ b/sys/dev/netif/pcn/if_pcn.c @@ -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); diff --git a/sys/dev/netif/plip/if_plip.c b/sys/dev/netif/plip/if_plip.c index f50e47b526..3acb4a5fe8 100644 --- a/sys/dev/netif/plip/if_plip.c +++ b/sys/dev/netif/plip/if_plip.c @@ -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); } diff --git a/sys/dev/netif/ral/rt2560.c b/sys/dev/netif/ral/rt2560.c index fbdcfe2351..4d3c16eef2 100644 --- a/sys/dev/netif/ral/rt2560.c +++ b/sys/dev/netif/ral/rt2560.c @@ -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 */ } diff --git a/sys/dev/netif/ral/rt2661.c b/sys/dev/netif/ral/rt2661.c index 36623e56fc..976a7c2ce7 100644 --- a/sys/dev/netif/ral/rt2661.c +++ b/sys/dev/netif/ral/rt2661.c @@ -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; } diff --git a/sys/dev/netif/re/if_re.c b/sys/dev/netif/re/if_re.c index 8094865c41..d9872b2a24 100644 --- a/sys/dev/netif/re/if_re.c +++ b/sys/dev/netif/re/if_re.c @@ -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); diff --git a/sys/dev/netif/rl/if_rl.c b/sys/dev/netif/rl/if_rl.c index d85568d9a3..5e5e226207 100644 --- a/sys/dev/netif/rl/if_rl.c +++ b/sys/dev/netif/rl/if_rl.c @@ -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); diff --git a/sys/dev/netif/rtw/rtw.c b/sys/dev/netif/rtw/rtw.c index fa87fb9a89..56fd4df8ec 100644 --- a/sys/dev/netif/rtw/rtw.c +++ b/sys/dev/netif/rtw/rtw.c @@ -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; diff --git a/sys/dev/netif/rue/if_rue.c b/sys/dev/netif/rue/if_rue.c index 0d1893a3b5..f4c2752477 100644 --- a/sys/dev/netif/rue/if_rue.c +++ b/sys/dev/netif/rue/if_rue.c @@ -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]; diff --git a/sys/dev/netif/rum/if_rum.c b/sys/dev/netif/rum/if_rum.c index 9ea13d2025..b81aeabfc7 100644 --- a/sys/dev/netif/rum/if_rum.c +++ b/sys/dev/netif/rum/if_rum.c @@ -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) + diff --git a/sys/dev/netif/sbni/if_sbni.c b/sys/dev/netif/sbni/if_sbni.c index ebd3cd1f65..1d06143971 100644 --- a/sys/dev/netif/sbni/if_sbni.c +++ b/sys/dev/netif/sbni/if_sbni.c @@ -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); } diff --git a/sys/dev/netif/sbsh/if_sbsh.c b/sys/dev/netif/sbsh/if_sbsh.c index 597884b761..d603bd7235 100644 --- a/sys/dev/netif/sbsh/if_sbsh.c +++ b/sys/dev/netif/sbsh/if_sbsh.c @@ -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; } diff --git a/sys/dev/netif/sf/if_sf.c b/sys/dev/netif/sf/if_sf.c index 998f37ec1f..5ee350fafa 100644 --- a/sys/dev/netif/sf/if_sf.c +++ b/sys/dev/netif/sf/if_sf.c @@ -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); diff --git a/sys/dev/netif/sis/if_sis.c b/sys/dev/netif/sis/if_sis.c index ff152a677c..08208968a6 100644 --- a/sys/dev/netif/sis/if_sis.c +++ b/sys/dev/netif/sis/if_sis.c @@ -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); diff --git a/sys/dev/netif/sk/if_sk.c b/sys/dev/netif/sk/if_sk.c index 8167fdc622..03343f2835 100644 --- a/sys/dev/netif/sk/if_sk.c +++ b/sys/dev/netif/sk/if_sk.c @@ -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]); diff --git a/sys/dev/netif/sln/if_sln.c b/sys/dev/netif/sln/if_sln.c index b705540ba4..a817f19dc8 100644 --- a/sys/dev/netif/sln/if_sln.c +++ b/sys/dev/netif/sln/if_sln.c @@ -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); diff --git a/sys/dev/netif/sn/if_sn.c b/sys/dev/netif/sn/if_sn.c index 09d5e82be1..487504bed1 100644 --- a/sys/dev/netif/sn/if_sn.c +++ b/sys/dev/netif/sn/if_sn.c @@ -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; diff --git a/sys/dev/netif/sr/if_sr.c b/sys/dev/netif/sr/if_sr.c index a7040241a6..8fc87963c1 100644 --- a/sys/dev/netif/sr/if_sr.c +++ b/sys/dev/netif/sr/if_sr.c @@ -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 */ @@ -2043,7 +2043,7 @@ sr_get_packets(struct sr_softc *sc) } #endif sppp_input(ifp, m); - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); #else /* NETGRAPH */ #if BUGGY > 3 @@ -2100,7 +2100,7 @@ sr_get_packets(struct sr_softc *sc) sr_eat_packet(sc, 1); #ifndef NETGRAPH - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); #else sc->ierrors[0]++; #endif /* NETGRAPH */ @@ -2167,6 +2167,8 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) * Transmit channel - DMA Status Register Evaluation */ if (isr1 & 0x0C) { + u_long opkts; + dmac = &sca->dmac[DMAC_TXCH(mch)]; /* @@ -2180,36 +2182,37 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) * Check for (& process) a Counter overflow */ if (dsr & SCA_DSR_COF) { - kprintf("sr%d: TX DMA Counter overflow, " - "txpacket no %lu.\n", #ifndef NETGRAPH - sc->unit, sc->ifsppp.pp_if.if_opackets); - sc->ifsppp.pp_if.if_oerrors++; + IFNET_STAT_GET(&sc->ifsppp.pp_if, opackets, + opkts); + IFNET_STAT_INC(&sc->ifsppp.pp_if, oerrors, 1); #else - sc->unit, sc->opackets); + opkts = sc->opackets; sc->oerrors++; #endif /* NETGRAPH */ + kprintf("sr%d: TX DMA Counter overflow, " + "txpacket no %lu.\n", + sc->unit, opkts); } /* * Check for (& process) a Buffer overflow */ if (dsr & SCA_DSR_BOF) { - kprintf("sr%d: TX DMA Buffer overflow, " - "txpacket no %lu, dsr %02x, " - "cda %04x, eda %04x.\n", #ifndef NETGRAPH - sc->unit, sc->ifsppp.pp_if.if_opackets, + IFNET_STAT_GET(&sc->ifsppp.pp_if, opackets, + opkts); + IFNET_STAT_INC(&sc->ifsppp.pp_if, oerrors, 1); #else - sc->unit, sc->opackets, + opkts = sc->opackets; + sc->oerrors++; #endif /* NETGRAPH */ + kprintf("sr%d: TX DMA Buffer overflow, " + "txpacket no %lu, dsr %02x, " + "cda %04x, eda %04x.\n", + sc->unit, opkts, dsr, SRC_GET16(hc->sca_base, dmac->cda), SRC_GET16(hc->sca_base, dmac->eda)); -#ifndef NETGRAPH - sc->ifsppp.pp_if.if_oerrors++; -#else - sc->oerrors++; -#endif /* NETGRAPH */ } /* * Check for (& process) an End of Transfer (OK) @@ -2244,6 +2247,8 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) * Receive channel processing of DMA Status Register */ if (isr1 & 0x03) { + u_long ipkts; + dmac = &sca->dmac[DMAC_RXCH(mch)]; dsr = SRC_GET8(hc->sca_base, dmac->dsr); @@ -2254,10 +2259,11 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) */ if (dsr & SCA_DSR_EOM) { #if BUGGY > 0 - int tt, ind; + u_long tt, ntt; + int ind; #ifndef NETGRAPH - tt = sc->ifsppp.pp_if.if_ipackets; + IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets, tt); #else /* NETGRAPH */ tt = sc->ipackets; #endif /* NETGRAPH */ @@ -2267,11 +2273,12 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) sr_get_packets(sc); #if BUGGY > 0 #ifndef NETGRAPH - if (tt == sc->ifsppp.pp_if.if_ipackets) + IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets, + ntt); #else /* NETGRAPH */ - if (tt == sc->ipackets) + ntt = sc->ipackets; #endif /* NETGRAPH */ - { + if (tt == ntt) { sca_descriptor *rxdesc; int i; @@ -2305,28 +2312,32 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) * Check for Counter overflow */ if (dsr & SCA_DSR_COF) { - kprintf("sr%d: RX DMA Counter overflow, " - "rxpkts %lu.\n", #ifndef NETGRAPH - sc->unit, sc->ifsppp.pp_if.if_ipackets); - sc->ifsppp.pp_if.if_ierrors++; + IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets, + ipkts); + IFNET_STAT_INC(&sc->ifsppp.pp_if, ierrors, 1); #else /* NETGRAPH */ - sc->unit, sc->ipackets); + ipkts = sc->ipackets; sc->ierrors[1]++; #endif /* NETGRAPH */ + kprintf("sr%d: RX DMA Counter overflow, " + "rxpkts %lu.\n", + sc->unit, ipkts); } /* * Check for Buffer overflow */ if (dsr & SCA_DSR_BOF) { - kprintf("sr%d: RX DMA Buffer overflow, " - "rxpkts %lu, rxind %d, " - "cda %x, eda %x, dsr %x.\n", #ifndef NETGRAPH - sc->unit, sc->ifsppp.pp_if.if_ipackets, + IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets, + ipkts); #else /* NETGRAPH */ - sc->unit, sc->ipackets, + ipkts = sc->ipackets; #endif /* NETGRAPH */ + kprintf("sr%d: RX DMA Buffer overflow, " + "rxpkts %lu, rxind %d, " + "cda %x, eda %x, dsr %x.\n", + sc->unit, ipkts, sc->rxhind, SRC_GET16(hc->sca_base, dmac->cda), SRC_GET16(hc->sca_base, dmac->eda), @@ -2339,7 +2350,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) sr_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 */ @@ -2351,15 +2362,16 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) SRC_PUT8(hc->sca_base, dmac->dsr, SCA_DSR_DE); #if BUGGY > 0 - kprintf("sr%d: RX DMA Buffer overflow, " - "rxpkts %lu, rxind %d, " - "cda %x, eda %x, dsr %x. After\n", - sc->unit, #ifndef NETGRAPH - sc->ipackets, + ipkts = sc->ipackets; #else /* NETGRAPH */ - sc->ifsppp.pp_if.if_ipackets, + IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets, + ipkts); #endif /* NETGRAPH */ + kprintf("sr%d: RX DMA Buffer overflow, " + "rxpkts %lu, rxind %d, " + "cda %x, eda %x, dsr %x. After\n", + sc->unit, ipkts, sc->rxhind, SRC_GET16(hc->sca_base, dmac->cda), SRC_GET16(hc->sca_base, dmac->eda), @@ -2370,6 +2382,16 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) * End of Transfer */ if (dsr & SCA_DSR_EOT) { + u_long ipkts; + +#ifndef NETGRAPH + IFNET_STAT_GET(&sc->ifsppp.pp_if, ipackets, + ipkts); + IFNET_STAT_INC(&sc->ifsppp.pp_if, ierrors, 1); +#else + ipkts = sc->ipackets; + sc->ierrors[3]++; +#endif /* NETGRAPH */ /* * If this happen, it means that we are * receiving faster than what the processor @@ -2378,14 +2400,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1) * XXX We should enable the dma again. */ kprintf("sr%d: RX End of xfer, rxpkts %lu.\n", - sc->unit, -#ifndef NETGRAPH - sc->ifsppp.pp_if.if_ipackets); - sc->ifsppp.pp_if.if_ierrors++; -#else - sc->ipackets); - sc->ierrors[3]++; -#endif /* NETGRAPH */ + sc->unit, ipkts); } } isr1 >>= 4; /* process next half of ISR */ diff --git a/sys/dev/netif/ste/if_ste.c b/sys/dev/netif/ste/if_ste.c index c182228b43..557858d4b5 100644 --- a/sys/dev/netif/ste/if_ste.c +++ b/sys/dev/netif/ste/if_ste.c @@ -655,7 +655,7 @@ ste_rxeof(struct ste_softc *sc) * comes up in the ring. */ if (rxstat & STE_RXSTAT_FRAME_ERR) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); cur_rx->ste_ptr->ste_status = 0; continue; } @@ -667,7 +667,7 @@ ste_rxeof(struct ste_softc *sc) */ if (!(rxstat & STE_RXSTAT_DMADONE)) { if_printf(ifp, "bad receive status -- packet dropped"); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); cur_rx->ste_ptr->ste_status = 0; continue; } @@ -684,12 +684,12 @@ ste_rxeof(struct ste_softc *sc) * can do in this situation. */ if (ste_newbuf(sc, cur_rx, NULL) == ENOBUFS) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); cur_rx->ste_ptr->ste_status = 0; continue; } - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = total_len; @@ -715,7 +715,7 @@ ste_txeoc(struct ste_softc *sc) if (txstat & STE_TXSTATUS_UNDERRUN || txstat & STE_TXSTATUS_EXCESSCOLLS || txstat & STE_TXSTATUS_RECLAIMERR) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if_printf(ifp, "transmission error: %x\n", txstat); ste_reset(sc); @@ -760,7 +760,7 @@ ste_txeof(struct ste_softc *sc) cur_tx->ste_mbuf = NULL; } - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); sc->ste_cdata.ste_tx_cnt--; STE_INC(idx, STE_TX_LIST_CNT); @@ -788,9 +788,9 @@ ste_stats_update(void *xsc) lwkt_serialize_enter(ifp->if_serializer); - ifp->if_collisions += CSR_READ_1(sc, STE_LATE_COLLS) + IFNET_STAT_INC(ifp, collisions, CSR_READ_1(sc, STE_LATE_COLLS) + CSR_READ_1(sc, STE_MULTI_COLLS) - + CSR_READ_1(sc, STE_SINGLE_COLLS); + + CSR_READ_1(sc, STE_SINGLE_COLLS)); if (!sc->ste_link) { mii_pollstat(mii); @@ -1483,7 +1483,7 @@ ste_watchdog(struct ifnet *ifp) sc = ifp->if_softc; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if_printf(ifp, "watchdog timeout\n"); ste_txeoc(sc); diff --git a/sys/dev/netif/stge/if_stge.c b/sys/dev/netif/stge/if_stge.c index 73ea22c9a3..1e16ce6203 100644 --- a/sys/dev/netif/stge/if_stge.c +++ b/sys/dev/netif/stge/if_stge.c @@ -1250,7 +1250,7 @@ stge_watchdog(struct ifnet *ifp) ASSERT_SERIALIZED(ifp->if_serializer); if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); stge_init(ifp->if_softc); } @@ -1609,7 +1609,7 @@ stge_rxeof(struct stge_softc *sc, int count) * Add a new receive buffer to the ring. */ if (stge_newbuf(sc, cons, 0) != 0) { - ifp->if_iqdrops++; + IFNET_STAT_INC(ifp, iqdrops, 1); stge_discard_rxbuf(sc, cons); if (sc->sc_cdata.stge_rxhead != NULL) { m_freem(sc->sc_cdata.stge_rxhead); @@ -1805,22 +1805,22 @@ stge_stats_update(struct stge_softc *sc) CSR_READ_4(sc,STGE_OctetRcvOk); - ifp->if_ipackets += CSR_READ_4(sc, STGE_FramesRcvdOk); + IFNET_STAT_INC(ifp, ipackets, CSR_READ_4(sc, STGE_FramesRcvdOk)); - ifp->if_ierrors += CSR_READ_2(sc, STGE_FramesLostRxErrors); + IFNET_STAT_INC(ifp, ierrors, CSR_READ_2(sc, STGE_FramesLostRxErrors)); CSR_READ_4(sc, STGE_OctetXmtdOk); - ifp->if_opackets += CSR_READ_4(sc, STGE_FramesXmtdOk); + IFNET_STAT_INC(ifp, opackets, CSR_READ_4(sc, STGE_FramesXmtdOk)); - ifp->if_collisions += + IFNET_STAT_INC(ifp, collisions, CSR_READ_4(sc, STGE_LateCollisions) + CSR_READ_4(sc, STGE_MultiColFrames) + - CSR_READ_4(sc, STGE_SingleColFrames); + CSR_READ_4(sc, STGE_SingleColFrames)); - ifp->if_oerrors += + IFNET_STAT_INC(ifp, oerrors, CSR_READ_2(sc, STGE_FramesAbortXSColls) + - CSR_READ_2(sc, STGE_FramesWEXDeferal); + CSR_READ_2(sc, STGE_FramesWEXDeferal)); } /* diff --git a/sys/dev/netif/ti/if_ti.c b/sys/dev/netif/ti/if_ti.c index d75d810ce6..701a41ccaa 100644 --- a/sys/dev/netif/ti/if_ti.c +++ b/sys/dev/netif/ti/if_ti.c @@ -1649,12 +1649,12 @@ ti_rxeof(struct ti_softc *sc) m = sc->ti_cdata.ti_rx_jumbo_chain[rxidx]; sc->ti_cdata.ti_rx_jumbo_chain[rxidx] = NULL; if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); ti_newbuf_jumbo(sc, sc->ti_jumbo, m); continue; } if (ti_newbuf_jumbo(sc, sc->ti_jumbo, NULL) == ENOBUFS) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); ti_newbuf_jumbo(sc, sc->ti_jumbo, m); continue; } @@ -1663,12 +1663,12 @@ ti_rxeof(struct ti_softc *sc) m = sc->ti_cdata.ti_rx_mini_chain[rxidx]; sc->ti_cdata.ti_rx_mini_chain[rxidx] = NULL; if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); ti_newbuf_mini(sc, sc->ti_mini, m); continue; } if (ti_newbuf_mini(sc, sc->ti_mini, NULL) == ENOBUFS) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); ti_newbuf_mini(sc, sc->ti_mini, m); continue; } @@ -1677,19 +1677,19 @@ ti_rxeof(struct ti_softc *sc) m = sc->ti_cdata.ti_rx_std_chain[rxidx]; sc->ti_cdata.ti_rx_std_chain[rxidx] = NULL; if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); ti_newbuf_std(sc, sc->ti_std, m); continue; } if (ti_newbuf_std(sc, sc->ti_std, NULL) == ENOBUFS) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); ti_newbuf_std(sc, sc->ti_std, m); continue; } } m->m_pkthdr.len = m->m_len = cur_rx->ti_len; - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); m->m_pkthdr.rcvif = ifp; if (ifp->if_hwassist) { @@ -1748,7 +1748,7 @@ ti_txeof(struct ti_softc *sc) } else cur_tx = &sc->ti_rdata->ti_tx_ring[idx]; if (cur_tx->ti_flags & TI_BDFLAG_END) - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); if (sc->ti_cdata.ti_tx_chain[idx] != NULL) { m_freem(sc->ti_cdata.ti_tx_chain[idx]); sc->ti_cdata.ti_tx_chain[idx] = NULL; @@ -1800,12 +1800,11 @@ ti_stats_update(struct ti_softc *sc) { struct ifnet *ifp = &sc->arpcom.ac_if; - ifp->if_collisions += + IFNET_STAT_SET(ifp, collisions, (sc->ti_rdata->ti_info.ti_stats.dot3StatsSingleCollisionFrames + sc->ti_rdata->ti_info.ti_stats.dot3StatsMultipleCollisionFrames + sc->ti_rdata->ti_info.ti_stats.dot3StatsExcessiveCollisions + - sc->ti_rdata->ti_info.ti_stats.dot3StatsLateCollisions) - - ifp->if_collisions; + sc->ti_rdata->ti_info.ti_stats.dot3StatsLateCollisions)); } /* @@ -2248,7 +2247,7 @@ ti_watchdog(struct ifnet *ifp) ti_stop(sc); ti_init(sc); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if (!ifq_is_empty(&ifp->if_snd)) if_devstart(ifp); diff --git a/sys/dev/netif/tl/if_tl.c b/sys/dev/netif/tl/if_tl.c index 71283cf134..185aa2f3ff 100644 --- a/sys/dev/netif/tl/if_tl.c +++ b/sys/dev/netif/tl/if_tl.c @@ -1406,7 +1406,7 @@ tl_intvec_rxeof(void *xsc, u_int32_t type) total_len = cur_rx->tl_ptr->tlist_frsize; if (tl_newbuf(sc, cur_rx) == ENOBUFS) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); cur_rx->tl_ptr->tlist_frsize = MCLBYTES; cur_rx->tl_ptr->tlist_cstat = TL_CSTAT_READY; cur_rx->tl_ptr->tl_frag.tlist_dcnt = MCLBYTES; @@ -1698,13 +1698,13 @@ tl_stats_update_serialized(void *xsc) *p++ = CSR_READ_4(sc, TL_DIO_DATA); *p++ = CSR_READ_4(sc, TL_DIO_DATA); - ifp->if_opackets += tl_tx_goodframes(tl_stats); - ifp->if_collisions += tl_stats.tl_tx_single_collision + - tl_stats.tl_tx_multi_collision; - ifp->if_ipackets += tl_rx_goodframes(tl_stats); - ifp->if_ierrors += tl_stats.tl_crc_errors + tl_stats.tl_code_errors + - tl_rx_overrun(tl_stats); - ifp->if_oerrors += tl_tx_underrun(tl_stats); + IFNET_STAT_INC(ifp, opackets, tl_tx_goodframes(tl_stats)); + IFNET_STAT_INC(ifp, collisions, tl_stats.tl_tx_single_collision + + tl_stats.tl_tx_multi_collision); + IFNET_STAT_INC(ifp, ipackets, tl_rx_goodframes(tl_stats)); + IFNET_STAT_INC(ifp, ierrors, tl_stats.tl_crc_errors + + tl_stats.tl_code_errors + tl_rx_overrun(tl_stats)); + IFNET_STAT_INC(ifp, oerrors, tl_tx_underrun(tl_stats)); if (tl_tx_underrun(tl_stats)) { u_int8_t tx_thresh; @@ -2098,7 +2098,7 @@ tl_watchdog(struct ifnet *ifp) if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); tl_softreset(sc, 1); tl_init(sc); diff --git a/sys/dev/netif/tx/if_tx.c b/sys/dev/netif/tx/if_tx.c index d5c0ae9ce0..f97a9289cc 100644 --- a/sys/dev/netif/tx/if_tx.c +++ b/sys/dev/netif/tx/if_tx.c @@ -513,7 +513,7 @@ epic_ifstart(struct ifnet *ifp, struct ifaltq_subque *ifsq) m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR); if (NULL == m) { m_freem(m0); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); continue; } @@ -574,7 +574,7 @@ epic_rx_done(epic_softc_t *sc) * RXE interrupt usually. */ if ((desc->status & 1) == 0) { - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); desc->status = 0x8000; continue; } @@ -588,7 +588,7 @@ epic_rx_done(epic_softc_t *sc) if (NULL == buf->mbuf) { buf->mbuf = m; desc->status = 0x8000; - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); continue; } @@ -604,7 +604,7 @@ epic_rx_done(epic_softc_t *sc) ifp->if_input(ifp, m); /* Successfuly received frame */ - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); } return; @@ -640,9 +640,9 @@ epic_tx_done(epic_softc_t *sc) buf->mbuf = NULL; /* Check for errors and collisions */ - if (status & 0x0001) sc->sc_if.if_opackets++; - else sc->sc_if.if_oerrors++; - sc->sc_if.if_collisions += (status >> 8) & 0x1F; + if (status & 0x0001) IFNET_STAT_INC(&sc->sc_if, opackets, 1); + else IFNET_STAT_INC(&sc->sc_if, oerrors, 1); + IFNET_STAT_INC(&sc->sc_if, collisions, (status >> 8) & 0x1F); #if defined(EPIC_DIAG) if ((status & 0x1001) == 0x1001) { if_printf(&sc->sc_if, @@ -678,7 +678,7 @@ epic_intr(void *arg) #endif if ((CSR_READ_4(sc, COMMAND) & COMMAND_RXQUEUED) == 0) CSR_WRITE_4(sc, COMMAND, COMMAND_RXQUEUED); - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); } } @@ -710,12 +710,12 @@ epic_intr(void *arg) #if defined(EPIC_DIAG) if_printf(sc->sc_if, "CRC/Alignment error\n"); #endif - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); } if (status & INTSTAT_TXU) { epic_tx_underrun(sc); - sc->sc_if.if_oerrors++; + IFNET_STAT_INC(&sc->sc_if, oerrors, 1); } } } @@ -775,7 +775,7 @@ epic_ifwatchdog(struct ifnet *ifp) /* If not successful */ if (sc->pending_txs > 0) { - ifp->if_oerrors+=sc->pending_txs; + IFNET_STAT_INC(ifp, oerrors, sc->pending_txs); /* Reinitialize board */ if_printf(ifp, "reinitialization\n"); diff --git a/sys/dev/netif/txp/if_txp.c b/sys/dev/netif/txp/if_txp.c index 8503f00faa..aac945f372 100644 --- a/sys/dev/netif/txp/if_txp.c +++ b/sys/dev/netif/txp/if_txp.c @@ -664,7 +664,7 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r) if (rxd->rx_flags & RX_FLAGS_ERROR) { if_printf(ifp, "error 0x%x\n", rxd->rx_stat); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); goto next; } @@ -821,7 +821,7 @@ txp_tx_reclaim(struct txp_softc *sc, struct txp_tx_ring *r) m_freem(m); txd->tx_addrlo = 0; txd->tx_addrhi = 0; - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } ifq_clr_oactive(&ifp->if_snd); @@ -1165,14 +1165,15 @@ txp_tick(void *vsc) goto out; ext = (struct txp_ext_desc *)(rsp + 1); - ifp->if_ierrors += ext[3].ext_2 + ext[3].ext_3 + ext[3].ext_4 + - ext[4].ext_1 + ext[4].ext_4; - ifp->if_oerrors += ext[0].ext_1 + ext[1].ext_1 + ext[1].ext_4 + - ext[2].ext_1; - ifp->if_collisions += ext[0].ext_2 + ext[0].ext_3 + ext[1].ext_2 + - ext[1].ext_3; - ifp->if_opackets += rsp->rsp_par2; - ifp->if_ipackets += ext[2].ext_3; + IFNET_STAT_INC(ifp, ierrors, + ext[3].ext_2 + ext[3].ext_3 + ext[3].ext_4 + + ext[4].ext_1 + ext[4].ext_4); + IFNET_STAT_INC(ifp, oerrors, + ext[0].ext_1 + ext[1].ext_1 + ext[1].ext_4 + ext[2].ext_1); + IFNET_STAT_INC(ifp, collisions, + ext[0].ext_2 + ext[0].ext_3 + ext[1].ext_2 + ext[1].ext_3); + IFNET_STAT_INC(ifp, opackets, rsp->rsp_par2); + IFNET_STAT_INC(ifp, ipackets, ext[2].ext_3); out: if (rsp != NULL) diff --git a/sys/dev/netif/ural/if_ural.c b/sys/dev/netif/ural/if_ural.c index 741e04c2fc..1bae0e8983 100644 --- a/sys/dev/netif/ural/if_ural.c +++ b/sys/dev/netif/ural/if_ural.c @@ -923,7 +923,7 @@ ural_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) if (status == USBD_STALLED) usbd_clear_endpoint_stall_async(sc->sc_rx_pipeh); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); crit_exit(); return; } @@ -934,7 +934,7 @@ ural_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) data->ni = NULL; sc->tx_queued--; - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); DPRINTFN(10, ("tx done\n")); @@ -983,7 +983,7 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) if (len < RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN) { 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; } @@ -997,13 +997,13 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) * those frames when we filled RAL_TXRX_CSR2. */ DPRINTFN(5, ("PHY or CRC error\n")); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); goto skip; } mnew = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR); if (mnew == NULL) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); goto skip; } @@ -1423,7 +1423,7 @@ ural_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; } } @@ -1447,7 +1447,7 @@ ural_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) if (ural_tx_data(sc, m0, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); break; } } @@ -1475,7 +1475,7 @@ ural_watchdog(struct ifnet *ifp) if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev, "device timeout\n"); /*ural_init(sc); XXX needs a process context! */ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); crit_exit(); return; @@ -2394,7 +2394,7 @@ ural_stats_update(usbd_xfer_handle xfer, usbd_private_handle priv, crit_enter(); /* count TX retry-fail as Tx errors */ - ifp->if_oerrors += sc->sta[RAL_TX_PKT_FAIL]; + IFNET_STAT_INC(ifp, oerrors, sc->sta[RAL_TX_PKT_FAIL]); stats->stats_pkt_ok += sc->sta[RAL_TX_PKT_NO_RETRY] + sc->sta[RAL_TX_PKT_ONE_RETRY] + diff --git a/sys/dev/netif/vge/if_vge.c b/sys/dev/netif/vge/if_vge.c index 2abf7be140..38eca8fcc0 100644 --- a/sys/dev/netif/vge/if_vge.c +++ b/sys/dev/netif/vge/if_vge.c @@ -1311,7 +1311,7 @@ vge_rxeof(struct vge_softc *sc, int count) */ if (!(rxstat & VGE_RDSTS_RXOK) && !(rxstat & VGE_RDSTS_VIDM) && !(rxstat & VGE_RDSTS_CSUMERR)) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); /* * If this is part of a multi-fragment packet, * discard all the pieces. @@ -1330,7 +1330,7 @@ vge_rxeof(struct vge_softc *sc, int count) * reload the current one. */ if (vge_newbuf(sc, i, NULL)) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); if (sc->vge_head != NULL) { m_freem(sc->vge_head); sc->vge_head = sc->vge_tail = NULL; @@ -1370,7 +1370,7 @@ vge_rxeof(struct vge_softc *sc, int count) #ifdef VGE_FIXUP_RX vge_fixup_rx(m); #endif - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); m->m_pkthdr.rcvif = ifp; /* Do RX checksumming if enabled */ @@ -1437,11 +1437,11 @@ vge_txeof(struct vge_softc *sc) bus_dmamap_unload(sc->vge_ldata.vge_mtag, sc->vge_ldata.vge_tx_dmamap[idx]); if (txstat & (VGE_TDSTS_EXCESSCOLL|VGE_TDSTS_COLL)) - ifp->if_collisions++; + IFNET_STAT_INC(ifp, collisions, 1); if (txstat & VGE_TDSTS_TXERR) - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); else - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); sc->vge_ldata.vge_tx_free++; VGE_TX_DESC_INC(idx); @@ -1519,7 +1519,7 @@ vge_npoll_compat(struct ifnet *ifp, void *arg __unused, int count) vge_init(sc); if (status & (VGE_ISR_RXOFLOW | VGE_ISR_RXNODESC)) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); CSR_WRITE_1(sc, VGE_RXQCSRS, VGE_RXQCSR_RUN); CSR_WRITE_1(sc, VGE_RXQCSRS, VGE_RXQCSR_WAK); } @@ -1582,7 +1582,7 @@ vge_intr(void *arg) if (status & (VGE_ISR_RXOFLOW|VGE_ISR_RXNODESC)) { vge_rxeof(sc, -1); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); CSR_WRITE_1(sc, VGE_RXQCSRS, VGE_RXQCSR_RUN); CSR_WRITE_1(sc, VGE_RXQCSRS, VGE_RXQCSR_WAK); } @@ -2071,7 +2071,7 @@ vge_watchdog(struct ifnet *ifp) struct vge_softc *sc = ifp->if_softc; if_printf(ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); vge_txeof(sc); vge_rxeof(sc, -1); diff --git a/sys/dev/netif/vr/if_vr.c b/sys/dev/netif/vr/if_vr.c index 149b841675..b32e7475f2 100644 --- a/sys/dev/netif/vr/if_vr.c +++ b/sys/dev/netif/vr/if_vr.c @@ -980,7 +980,7 @@ vr_rxeof(struct vr_softc *sc) * comes up in the ring. */ if (rxstat & VR_RXSTAT_RXERR) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); if_printf(ifp, "rx error (%02x):", rxstat & 0x000000ff); if (rxstat & VR_RXSTAT_CRCERR) kprintf(" crc error"); @@ -1017,13 +1017,13 @@ vr_rxeof(struct vr_softc *sc) total_len + ETHER_ALIGN, 0, ifp, NULL); vr_newbuf(sc, cur_rx, 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); } } @@ -1036,7 +1036,7 @@ vr_rxeoc(struct vr_softc *sc) ifp = &sc->arpcom.ac_if; - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_RX_ON); DELAY(10000); @@ -1115,16 +1115,17 @@ vr_txeof(struct vr_softc *sc) break; if (txstat & VR_TXSTAT_ERRSUM) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if (txstat & VR_TXSTAT_DEFER) - ifp->if_collisions++; + IFNET_STAT_INC(ifp, collisions, 1); if (txstat & VR_TXSTAT_LATECOLL) - ifp->if_collisions++; + IFNET_STAT_INC(ifp, collisions, 1); } - ifp->if_collisions += (txstat & VR_TXSTAT_COLLCNT) >> 3; + IFNET_STAT_INC(ifp, collisions, + (txstat & VR_TXSTAT_COLLCNT) >> 3); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); cur_tx->vr_buf = NULL; if (cd->vr_tx_head_idx == cd->vr_tx_tail_idx) { @@ -1212,7 +1213,7 @@ vr_intr(void *arg) if (status & VR_ISR_RX_DROPPED) { if_printf(ifp, "rx packet lost\n"); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); } if ((status & VR_ISR_RX_ERR) || (status & VR_ISR_RX_NOBUF) || @@ -1240,7 +1241,7 @@ vr_intr(void *arg) if ((status & VR_ISR_UDFI) || (status & VR_ISR_TX_ABRT2) || (status & VR_ISR_TX_ABRT)) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if (sc->vr_cdata.vr_tx_head_idx != -1) { VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON); @@ -1602,7 +1603,7 @@ vr_watchdog(struct ifnet *ifp) sc = ifp->if_softc; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if_printf(ifp, "watchdog timeout\n"); vr_stop(sc); diff --git a/sys/dev/netif/vx/if_vx.c b/sys/dev/netif/vx/if_vx.c index 9dfe3c9526..f21a6e3126 100644 --- a/sys/dev/netif/vx/if_vx.c +++ b/sys/dev/netif/vx/if_vx.c @@ -413,7 +413,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(m0); goto readcheck; } @@ -460,7 +460,7 @@ startagain: crit_exit(); - ++ifp->if_opackets; + IFNET_STAT_INC(ifp, opackets, 1); ifp->if_timer = 1; readcheck: @@ -551,12 +551,12 @@ vxtxstat(struct vx_softc *sc) CSR_WRITE_1(sc, VX_W1_TX_STATUS, 0x0); if (i & TXS_JABBER) { - ++ifp->if_oerrors; + IFNET_STAT_INC(ifp, oerrors, 1); if (ifp->if_flags & IFF_DEBUG) if_printf(ifp, "jabber (%x)\n", i); vxreset(sc); } else if (i & TXS_UNDERRUN) { - ++ifp->if_oerrors; + IFNET_STAT_INC(ifp, oerrors, 1); if (ifp->if_flags & IFF_DEBUG) { if_printf(ifp, "fifo underrun (%x) @%d\n", i, sc->tx_start_thresh); @@ -568,7 +568,7 @@ vxtxstat(struct vx_softc *sc) sc->tx_succ_ok = 0; vxreset(sc); } else if (i & TXS_MAX_COLLISION) { - ++ifp->if_collisions; + IFNET_STAT_INC(ifp, collisions, 1); CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE); ifq_clr_oactive(&ifp->if_snd); } else { @@ -662,7 +662,7 @@ again: return; if (len & ERR_RX) { - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); goto abort; } @@ -671,11 +671,11 @@ again: /* Pull packet off interface. */ m = vxget(sc, len); if (m == NULL) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); goto abort; } - ++ifp->if_ipackets; + IFNET_STAT_INC(ifp, ipackets, 1); /* We assume the header fit entirely in one mbuf. */ eh = mtod(m, struct ether_header *); diff --git a/sys/dev/netif/wb/if_wb.c b/sys/dev/netif/wb/if_wb.c index 70d185a515..2515ad7110 100644 --- a/sys/dev/netif/wb/if_wb.c +++ b/sys/dev/netif/wb/if_wb.c @@ -983,7 +983,7 @@ wb_rxeof(struct wb_softc *sc) (WB_RXBYTES(cur_rx->wb_ptr->wb_status) > 1536) || (rxstat & WB_RXSTAT_LASTFRAG) == 0|| (rxstat & WB_RXSTAT_RXCMP) == 0) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); wb_newbuf(sc, cur_rx, m); if_printf(ifp, "receiver babbling: possible chip " "bug, forcing reset\n"); @@ -994,7 +994,7 @@ wb_rxeof(struct wb_softc *sc) } if (rxstat & WB_RXSTAT_RXERR) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); wb_newbuf(sc, cur_rx, m); break; } @@ -1015,13 +1015,13 @@ wb_rxeof(struct wb_softc *sc) total_len + ETHER_ALIGN, 0, ifp, NULL); wb_newbuf(sc, cur_rx, m); if (m0 == NULL) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); break; } m_adj(m0, ETHER_ALIGN); m = m0; - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); ifp->if_input(ifp, m); } } @@ -1068,16 +1068,17 @@ wb_txeof(struct wb_softc *sc) break; if (txstat & WB_TXSTAT_TXERR) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if (txstat & WB_TXSTAT_ABORT) - ifp->if_collisions++; + IFNET_STAT_INC(ifp, collisions, 1); if (txstat & WB_TXSTAT_LATECOLL) - ifp->if_collisions++; + IFNET_STAT_INC(ifp, collisions, 1); } - ifp->if_collisions += (txstat & WB_TXSTAT_COLLCNT) >> 3; + IFNET_STAT_INC(ifp, collisions, + (txstat & WB_TXSTAT_COLLCNT) >> 3); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); m_freem(cur_tx->wb_mbuf); cur_tx->wb_mbuf = NULL; @@ -1133,7 +1134,7 @@ wb_intr(void *arg) break; if ((status & WB_ISR_RX_NOBUF) || (status & WB_ISR_RX_ERR)) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); wb_reset(sc); if (status & WB_ISR_RX_ERR) wb_fixmedia(sc); @@ -1162,7 +1163,7 @@ wb_intr(void *arg) } if (status & WB_ISR_TX_UNDERRUN) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); wb_txeof(sc); WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_TX_ON); /* Jack up TX threshold */ @@ -1559,7 +1560,7 @@ wb_watchdog(struct ifnet *ifp) { struct wb_softc *sc = ifp->if_softc; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); if_printf(ifp, "watchdog timeout\n"); #ifdef foo if ((wb_phy_readreg(sc, PHY_BMSR) & PHY_BMSR_LINKSTAT) == 0) diff --git a/sys/dev/netif/wi/if_wi.c b/sys/dev/netif/wi/if_wi.c index bbacb41724..666717d5e5 100644 --- a/sys/dev/netif/wi/if_wi.c +++ b/sys/dev/netif/wi/if_wi.c @@ -1000,7 +1000,7 @@ wi_start_locked(struct ifnet *ifp) continue; sc->sc_txnext = cur = (cur + 1) % sc->sc_ntxbuf; - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } @@ -1024,7 +1024,7 @@ wi_start_tx(struct ifnet *ifp, struct wi_frame *frmhdr, struct mbuf *m0) || wi_mwrite_bap(sc, fid, off, m0, m0->m_pkthdr.len) != 0; m_freem(m0); if (error) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return -1; } sc->sc_txd[cur].d_len = off; @@ -1146,7 +1146,7 @@ wi_watchdog_callout(void *arg) if (sc->sc_tx_timer && --sc->sc_tx_timer == 0) { if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); wi_init_locked(ifp->if_softc); return; } @@ -1290,7 +1290,7 @@ wi_rx_intr(struct wi_softc *sc) /* First read in the frame header */ if (wi_read_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr))) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); DPRINTF(("wi_rx_intr: read fid %x failed\n", fid)); return; } @@ -1301,7 +1301,7 @@ wi_rx_intr(struct wi_softc *sc) status = le16toh(frmhdr.wi_status); if (status & WI_STAT_ERRSTAT) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); DPRINTF(("wi_rx_intr: fid %x error status %x\n", fid, status)); return; } @@ -1316,7 +1316,7 @@ wi_rx_intr(struct wi_softc *sc) if (off + len > MCLBYTES) { if (ic->ic_opmode != IEEE80211_M_MONITOR) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); DPRINTF(("wi_rx_intr: oversized packet\n")); return; } else @@ -1329,7 +1329,7 @@ wi_rx_intr(struct wi_softc *sc) m = m_gethdr(MB_DONTWAIT, MT_DATA); if (m == NULL) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); DPRINTF(("wi_rx_intr: MGET failed\n")); return; } @@ -1411,10 +1411,10 @@ wi_tx_ex_intr(struct wi_softc *sc) kprintf(", status=0x%x", status); kprintf("\n"); } - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); } else { DPRINTF(("port disconnected\n")); - ifp->if_collisions++; /* XXX */ + IFNET_STAT_INC(ifp, collisions, 1); /* XXX */ } } else DPRINTF(("wi_tx_ex_intr: read fid %x failed\n", fid)); @@ -1515,9 +1515,10 @@ wi_info_intr(struct wi_softc *sc) #endif *ptr += stat; } - ifp->if_collisions = sc->sc_stats.wi_tx_single_retries + + IFNET_STAT_SET(ifp, collisions, + sc->sc_stats.wi_tx_single_retries + sc->sc_stats.wi_tx_multi_retries + - sc->sc_stats.wi_tx_retry_limit; + sc->sc_stats.wi_tx_retry_limit); break; default: DPRINTF(("wi_info_intr: got fid %x type %x len %d\n", fid, diff --git a/sys/dev/netif/wpi/if_wpi.c b/sys/dev/netif/wpi/if_wpi.c index 3ee653bcb1..e98e908298 100644 --- a/sys/dev/netif/wpi/if_wpi.c +++ b/sys/dev/netif/wpi/if_wpi.c @@ -1467,7 +1467,7 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, if (stat->len > WPI_STAT_MAXLEN) { device_printf(sc->sc_dev, "invalid rx statistic header\n"); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); return; } @@ -1483,13 +1483,13 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, if ((le32toh(tail->flags) & WPI_RX_NOERROR) != WPI_RX_NOERROR) { DPRINTFN(WPI_DEBUG_RX, ("%s: rx flags error %x\n", __func__, le32toh(tail->flags))); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); return; } if (le16toh(head->len) < sizeof (struct ieee80211_frame)) { DPRINTFN(WPI_DEBUG_RX, ("%s: frame too short: %d\n", __func__, le16toh(head->len))); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); return; } @@ -1498,7 +1498,7 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, if (mnew == NULL) { DPRINTFN(WPI_DEBUG_RX, ("%s: no mbuf to restock ring\n", __func__)); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); return; } error = bus_dmamap_load(ring->data_dmat, data->map, @@ -1508,7 +1508,7 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, device_printf(sc->sc_dev, "%s: bus_dmamap_load failed, error %d\n", __func__, error); m_freem(mnew); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); return; } bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); @@ -1596,9 +1596,9 @@ wpi_tx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc) /* XXX oerrors should only count errors !maxtries */ if ((le32toh(stat->status) & 0xff) != 1) - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); else - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); bus_dmamap_sync(ring->data_dmat, txdata->map, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(ring->data_dmat, txdata->map); @@ -2049,7 +2049,7 @@ wpi_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (wpi_tx_data(sc, m, ni, ac) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); break; } sc->sc_tx_timer = 5; @@ -2079,7 +2079,7 @@ wpi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return ENOBUFS; /* XXX */ } - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); if (wpi_tx_data(sc, m, ni, 0) != 0) goto bad; sc->sc_tx_timer = 5; @@ -2087,7 +2087,7 @@ wpi_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 */ } @@ -3662,7 +3662,7 @@ wpi_watchdog_callout(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev,"device timeout\n"); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); wlan_serialize_exit(); ieee80211_runtask(ic, &sc->sc_restarttask); wlan_serialize_enter(); diff --git a/sys/dev/netif/xe/if_xe.c b/sys/dev/netif/xe/if_xe.c index 17152a2ac3..b8fa910c30 100644 --- a/sys/dev/netif/xe/if_xe.c +++ b/sys/dev/netif/xe/if_xe.c @@ -649,8 +649,8 @@ xe_intr(void *xscp) if (sent > 0) { scp->tx_tpr = tpr; scp->tx_queued -= sent; - ifp->if_opackets += sent; - ifp->if_collisions += coll; + IFNET_STAT_INC(ifp, opackets, sent); + IFNET_STAT_INC(ifp, collisions, coll); /* * According to the Xircom manual, Dingo will sometimes manage to @@ -689,8 +689,8 @@ xe_intr(void *xscp) #endif /* Excessive collisions -- try sending again */ if (txst0 & XE_TXST0_16_COLLISIONS) { - ifp->if_collisions += 16; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, collisions, 16); + IFNET_STAT_INC(ifp, oerrors, 1); scp->mibdata.dot3StatsExcessiveCollisions++; scp->mibdata.dot3StatsMultipleCollisionFrames++; scp->mibdata.dot3StatsCollFrequencies[15]++; @@ -708,31 +708,31 @@ xe_intr(void *xscp) XE_SELECT_PAGE(0x0); } DPRINTF(1, ("\n")); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); scp->mibdata.dot3StatsInternalMacTransmitErrors++; } /* Late collision -- just complain about it */ if (txst0 & XE_TXST0_LATE_COLLISION) { if_printf(ifp, "late collision\n"); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); scp->mibdata.dot3StatsLateCollisions++; } /* SQE test failure -- just complain about it */ if (txst0 & XE_TXST0_SQE_FAIL) { if_printf(ifp, "SQE test failure\n"); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); scp->mibdata.dot3StatsSQETestErrors++; } /* Packet too long -- what happens to these */ if (rst0 & XE_RST0_LONG_PACKET) { if_printf(ifp, "received giant packet\n"); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); scp->mibdata.dot3StatsFrameTooLongs++; } /* CRC error -- packet dropped */ if (rst0 & XE_RST0_CRC_ERROR) { if_printf(ifp, "CRC error\n"); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); scp->mibdata.dot3StatsFCSErrors++; } } @@ -753,7 +753,7 @@ xe_intr(void *xscp) IFPRINTF(3, (ifp, "intr: receive length = %d\n", len)); if (len == 0) { - ifp->if_iqdrops++; + IFNET_STAT_INC(ifp, iqdrops, 1); continue; } @@ -767,7 +767,7 @@ xe_intr(void *xscp) */ MGETHDR(mbp, MB_DONTWAIT, MT_DATA); if (mbp == NULL) { - ifp->if_iqdrops++; + IFNET_STAT_INC(ifp, iqdrops, 1); continue; } @@ -775,7 +775,7 @@ xe_intr(void *xscp) MCLGET(mbp, MB_DONTWAIT); if ((mbp->m_flags & M_EXT) == 0) { m_freem(mbp); - ifp->if_iqdrops++; + IFNET_STAT_INC(ifp, iqdrops, 1); continue; } } @@ -829,13 +829,13 @@ xe_intr(void *xscp) mbp->m_pkthdr.rcvif = ifp; mbp->m_pkthdr.len = mbp->m_len = len; ifp->if_input(ifp, mbp); - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); } else if (rsr & XE_RSR_ALIGN_ERROR) { /* Packet alignment error -- drop packet */ if_printf(ifp, "alignment error\n"); scp->mibdata.dot3StatsAlignmentErrors++; - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); } /* Skip to next packet, if there is one */ @@ -845,7 +845,7 @@ xe_intr(void *xscp) /* Clear receiver overruns now we have some free buffer space */ if (rst0 & XE_RST0_RX_OVERRUN) { IFPRINTF(1, (ifp, "receive overrun\n")); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); scp->mibdata.dot3StatsInternalMacReceiveErrors++; XE_OUTB(XE_CR, XE_CR_CLEAR_OVERRUN); } @@ -871,7 +871,7 @@ xe_watchdog(struct ifnet *ifp) { if_printf(ifp, "watchdog timeout; resetting card\n"); scp->tx_timeouts++; - ifp->if_oerrors += scp->tx_queued; + IFNET_STAT_INC(ifp, oerrors, scp->tx_queued); xe_stop(scp); xe_reset(scp); xe_init(scp); diff --git a/sys/dev/netif/xl/if_xl.c b/sys/dev/netif/xl/if_xl.c index f3a3327a06..39e26e735f 100644 --- a/sys/dev/netif/xl/if_xl.c +++ b/sys/dev/netif/xl/if_xl.c @@ -1981,7 +1981,7 @@ again: * comes up in the ring. */ if (rxstat & XL_RXSTAT_UP_ERROR) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); cur_rx->xl_ptr->xl_status = 0; continue; } @@ -1994,7 +1994,7 @@ again: if (!(rxstat & XL_RXSTAT_UP_CMPLT)) { if_printf(ifp, "bad receive status -- packet dropped\n"); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); cur_rx->xl_ptr->xl_status = 0; continue; } @@ -2010,12 +2010,12 @@ again: * can do in this situation. */ if (xl_newbuf(sc, cur_rx, 0)) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); cur_rx->xl_ptr->xl_status = 0; continue; } - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = total_len; @@ -2099,7 +2099,7 @@ xl_txeof(struct xl_softc *sc) bus_dmamap_unload(sc->xl_tx_mtag, cur_tx->xl_map); m_freem(cur_tx->xl_mbuf); cur_tx->xl_mbuf = NULL; - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); cur_tx->xl_next = sc->xl_cdata.xl_tx_free; sc->xl_cdata.xl_tx_free = cur_tx; @@ -2144,7 +2144,7 @@ xl_txeof_90xB(struct xl_softc *sc) cur_tx->xl_mbuf = NULL; } - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); sc->xl_cdata.xl_tx_cnt--; XL_INC(idx, XL_TX_LIST_CNT); @@ -2254,7 +2254,7 @@ xl_npoll_compat(struct ifnet *ifp, void *arg __unused, int count) XL_CMD_INTR_ACK | (status & XL_INTRS)); if (status & XL_STAT_TX_COMPLETE) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); xl_txeoc(sc); } @@ -2330,11 +2330,13 @@ xl_intr(void *arg) XL_CMD_INTR_ACK|(status & XL_INTRS)); if (status & XL_STAT_UP_COMPLETE) { - int curpkts; + u_long curpkts, ncurpkts; - curpkts = ifp->if_ipackets; + IFNET_STAT_GET(ifp, ipackets, curpkts); xl_rxeof(sc, -1); - if (curpkts == ifp->if_ipackets) { + IFNET_STAT_GET(ifp, ipackets, ncurpkts); + + if (curpkts == ncurpkts) { while (xl_rx_resync(sc)) xl_rxeof(sc, -1); } @@ -2348,7 +2350,7 @@ xl_intr(void *arg) } if (status & XL_STAT_TX_COMPLETE) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); xl_txeoc(sc); } @@ -2403,11 +2405,12 @@ xl_stats_update_serialized(void *xsc) for (i = 0; i < 16; i++) *p++ = CSR_READ_1(sc, XL_W6_CARRIER_LOST + i); - ifp->if_ierrors += xl_stats.xl_rx_overrun; + IFNET_STAT_INC(ifp, ierrors, xl_stats.xl_rx_overrun); - ifp->if_collisions += xl_stats.xl_tx_multi_collision + - xl_stats.xl_tx_single_collision + - xl_stats.xl_tx_late_collision; + IFNET_STAT_INC(ifp, collisions, + xl_stats.xl_tx_multi_collision + + xl_stats.xl_tx_single_collision + + xl_stats.xl_tx_late_collision); /* * Boomerang and cyclone chips have an extra stats counter @@ -3109,7 +3112,7 @@ xl_watchdog(struct ifnet *ifp) sc = ifp->if_softc; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); XL_SEL_WIN(4); status = CSR_READ_2(sc, XL_W4_MEDIA_STATUS); if_printf(ifp, "watchdog timeout\n"); diff --git a/sys/dev/virtual/vkernel/net/if_vke.c b/sys/dev/virtual/vkernel/net/if_vke.c index 66ae46e66b..ef65b80f0a 100644 --- a/sys/dev/virtual/vkernel/net/if_vke.c +++ b/sys/dev/virtual/vkernel/net/if_vke.c @@ -596,7 +596,7 @@ vke_rx_thread(cothread_t cotd) continue; n = read(sc->sc_fd, mtod(m, void *), MCLBYTES); if (n > 0) { - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = n; cpu_sfence(); @@ -646,9 +646,9 @@ vke_tx_thread(cothread_t cotd) if (write(sc->sc_fd, sc->sc_txbuf, sc->sc_txbuf_len) < 0) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); } else { - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } if (count++ == VKE_CHUNK) { diff --git a/sys/net/bridge/if_bridge.c b/sys/net/bridge/if_bridge.c index 4e014bfb9a..81dd736b1e 100644 --- a/sys/net/bridge/if_bridge.c +++ b/sys/net/bridge/if_bridge.c @@ -2122,7 +2122,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m) if (m->m_len < ETHER_HDR_LEN) { m = m_pullup(m, ETHER_HDR_LEN); if (m == NULL) { - bifp->if_oerrors++; + IFNET_STAT_INC(bifp, oerrors, 1); return (0); } } @@ -2225,7 +2225,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m) } else { mc = m_copypacket(m, MB_DONTWAIT); if (mc == NULL) { - bifp->if_oerrors++; + IFNET_STAT_INC(bifp, oerrors, 1); continue; } } @@ -2317,14 +2317,14 @@ bridge_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; } } eh = mtod(m, struct ether_header *); BPF_MTAP(ifp, m); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); if ((m->m_flags & (M_BCAST|M_MCAST)) == 0) dst_if = bridge_rtlookup(sc, eh->ether_dhost); @@ -2372,8 +2372,8 @@ bridge_forward(struct bridge_softc *sc, struct mbuf *m) ASSERT_IFNET_NOT_SERIALIZED_ALL(ifp); - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); /* * Look up the bridge_iflist. @@ -2465,7 +2465,7 @@ bridge_forward(struct bridge_softc *sc, struct mbuf *m) } } else { /* ...forward it to all interfaces. */ - ifp->if_imcasts++; + IFNET_STAT_INC(ifp, imcasts, 1); dst_if = NULL; } @@ -2550,10 +2550,10 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) BPF_MTAP(bifp, m); /* Update bridge's ifnet statistics */ - bifp->if_ipackets++; - bifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(bifp, ipackets, 1); + IFNET_STAT_INC(bifp, ibytes, m->m_pkthdr.len); if (m->m_flags & (M_MCAST | M_BCAST)) - bifp->if_imcasts++; + IFNET_STAT_INC(bifp, imcasts, 1); m_freem(m); m = NULL; @@ -2921,7 +2921,7 @@ bridge_start_bcast(struct bridge_softc *sc, struct mbuf *m) } else { mc = m_copypacket(m, MB_DONTWAIT); if (mc == NULL) { - bifp->if_oerrors++; + IFNET_STAT_INC(bifp, oerrors, 1); continue; } } @@ -3054,7 +3054,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *src_if, } else { mc = m_copypacket(m, MB_DONTWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + IFNET_STAT_INC(sc->sc_ifp, oerrors, 1); continue; } } @@ -3119,7 +3119,7 @@ bridge_span(struct bridge_softc *sc, struct mbuf *m) mc = m_copypacket(m, MB_DONTWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + IFNET_STAT_INC(sc->sc_ifp, oerrors, 1); continue; } bridge_enqueue(dst_if, mc); diff --git a/sys/net/disc/if_disc.c b/sys/net/disc/if_disc.c index 0fa42ac7ec..98307dcf6a 100644 --- a/sys/net/disc/if_disc.c +++ b/sys/net/disc/if_disc.c @@ -140,8 +140,8 @@ discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, } m->m_pkthdr.rcvif = ifp; - 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); m_freem(m); return 0; diff --git a/sys/net/ef/if_ef.c b/sys/net/ef/if_ef.c index 453176c03d..59fc3c2d96 100644 --- a/sys/net/ef/if_ef.c +++ b/sys/net/ef/if_ef.c @@ -223,7 +223,7 @@ ef_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) ifsq_enqueue(p_ifsq, m, NULL); if (!ifsq_is_oactive(p_ifsq)) { p->if_start(p, p_ifsq); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } ifsq_clr_oactive(ifsq); @@ -362,7 +362,7 @@ ef_input(struct ifnet *ifp, const struct ether_header *eh, struct mbuf *m) eifp = &efp->ef_ac.ac_if; if ((eifp->if_flags & IFF_UP) == 0) return EPROTONOSUPPORT; - eifp->if_ibytes += m->m_pkthdr.len + sizeof (*eh); + IFNET_STAT_INC(eifp, ibytes, m->m_pkthdr.len + sizeof (*eh)); m->m_pkthdr.rcvif = eifp; if (eifp->if_bpf) { diff --git a/sys/net/faith/if_faith.c b/sys/net/faith/if_faith.c index 29813e2542..f9be0af902 100644 --- a/sys/net/faith/if_faith.c +++ b/sys/net/faith/if_faith.c @@ -230,8 +230,8 @@ faithoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, return (rt->rt_flags & RTF_BLACKHOLE ? 0 : rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); } - 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); switch (dst->sa_family) { #ifdef INET case AF_INET: @@ -252,8 +252,8 @@ faithoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, m->m_pkthdr.rcvif = ifp; m->m_flags &= ~M_HASH; - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); netisr_queue(isr, m); return (0); } diff --git a/sys/net/gif/if_gif.c b/sys/net/gif/if_gif.c index c0ce39c411..d71cb0248e 100644 --- a/sys/net/gif/if_gif.c +++ b/sys/net/gif/if_gif.c @@ -359,8 +359,8 @@ gif_output_serialized(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, } bpf_reltoken(); } - 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); /* inner AF-specific encapsulation */ @@ -387,7 +387,7 @@ gif_output_serialized(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, end: called = 0; /* reset recursion counter */ if (error) - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return error; } @@ -458,8 +458,8 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) return; } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); m->m_flags &= ~M_HASH; netisr_queue(isr, m); diff --git a/sys/net/gre/if_gre.c b/sys/net/gre/if_gre.c index 73431a54ec..0045d92afc 100644 --- a/sys/net/gre/if_gre.c +++ b/sys/net/gre/if_gre.c @@ -384,14 +384,14 @@ gre_output_serialized(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, gh->gi_len = m->m_pkthdr.len; } - 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); /* send it off */ error = ip_output(m, NULL, &sc->route, 0, NULL, NULL); end: sc->called = 0; if (error) - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return (error); } diff --git a/sys/net/if.c b/sys/net/if.c index db354a399b..80da8ead7d 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2645,9 +2645,9 @@ ifq_dispatch(struct ifnet *ifp, struct mbuf *m, struct altq_pktattr *pa) if ((stage->stg_flags & IFSQ_STAGE_FLAG_QUED) == 0) ifsq_stage_insert(head, stage); - ifp->if_obytes += len; + IFNET_STAT_INC(ifp, obytes, len); if (mcast) - ifp->if_omcasts++; + IFNET_STAT_INC(ifp, omcasts, 1); return error; } @@ -2660,9 +2660,9 @@ ifq_dispatch(struct ifnet *ifp, struct mbuf *m, struct altq_pktattr *pa) ALTQ_SQ_UNLOCK(ifsq); if (!error) { - ifp->if_obytes += len; + IFNET_STAT_INC(ifp, obytes, len); if (mcast) - ifp->if_omcasts++; + IFNET_STAT_INC(ifp, omcasts, 1); } if (stage != NULL) { diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index a5e75fd575..a8ef1d92ee 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -238,7 +238,7 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m, m_freem(m); return; } - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); if (rxhand) { #ifdef NATM diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index bd6cf5df42..65e71b08eb 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -339,7 +339,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, n->m_pkthdr.csum_data = 0xffff; if_simloop(ifp, n, dst->sa_family, hlen); } else - ifp->if_iqdrops++; + IFNET_STAT_INC(ifp, iqdrops, 1); } else if (bcmp(eh->ether_dhost, eh->ether_shost, ETHER_ADDR_LEN) == 0) { m->m_pkthdr.csum_flags |= csum_flags; @@ -1057,7 +1057,7 @@ post_stats: if (vlan_input_func != NULL) { vlan_input_func(m); } else { - m->m_pkthdr.rcvif->if_noproto++; + IFNET_STAT_INC(m->m_pkthdr.rcvif, noproto, 1); m_freem(m); } return; @@ -1306,10 +1306,10 @@ ether_reinput_oncpu(struct ifnet *ifp, struct mbuf *m, int reinput_flags) } /* Update statistics */ - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); if (m->m_flags & (M_MCAST | M_BCAST)) - ifp->if_imcasts++; + IFNET_STAT_INC(ifp, imcasts, 1); if (reinput_flags & REINPUT_RUNBPF) BPF_MTAP(ifp, m); @@ -1344,7 +1344,7 @@ ether_vlancheck(struct mbuf **m0) * To prevent possible dangerous recursion, * we don't do vlan-in-vlan */ - m->m_pkthdr.rcvif->if_noproto++; + IFNET_STAT_INC(m->m_pkthdr.rcvif, noproto, 1); goto failed; } KKASSERT(ether_type != ETHERTYPE_VLAN); @@ -1413,7 +1413,7 @@ ether_input_handler(netmsg_t nmsg) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + IFNET_STAT_INC(ifp, imcasts, 1); } ether_input_oncpu(ifp, m); @@ -1474,14 +1474,14 @@ ether_input_pkt(struct ifnet *ifp, struct mbuf *m, const struct pktinfo *pi) ETHER_BPF_MTAP(ifp, m); - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); if (ifp->if_flags & IFF_MONITOR) { struct ether_header *eh; eh = mtod(m, struct ether_header *); if (ETHER_IS_MULTICAST(eh->ether_dhost)) - ifp->if_imcasts++; + IFNET_STAT_INC(ifp, imcasts, 1); /* * Interface marked for monitoring; discard packet. diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 2599182e27..2a363e05f9 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -140,8 +140,8 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); } - 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 1 /* XXX */ switch (dst->sa_family) { case AF_INET: @@ -269,8 +269,8 @@ rel: return (EAFNOSUPPORT); } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); netisr_queue(isr, m); return (0); } @@ -322,8 +322,8 @@ lo_altqstart(struct ifnet *ifp, struct ifaltq_subque *ifsq) return; } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); netisr_queue(isr, m); } } diff --git a/sys/net/if_var.h b/sys/net/if_var.h index ff75975507..5eb61cbc0e 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -520,6 +520,26 @@ struct ifmultiaddr { #ifdef _KERNEL +#define IFA_STAT_INC(ifa, name, v) \ +do { \ + (ifa)->if_data.ifi_##name += (v); \ +} while (0) + +#define IFNET_STAT_INC(ifp, name, v) \ +do { \ + (ifp)->if_data.ifi_##name += (v); \ +} while (0) + +#define IFNET_STAT_SET(ifp, name, v) \ +do { \ + (ifp)->if_data.ifi_##name = (v); \ +} while (0) + +#define IFNET_STAT_GET(ifp, name, v) \ +do { \ + (v) = (ifp)->if_data.ifi_##name; \ +} while (0) + #ifndef _SYS_SERIALIZE2_H_ #include #endif diff --git a/sys/net/ifq_var.h b/sys/net/ifq_var.h index decb3cc80a..8befb41b43 100644 --- a/sys/net/ifq_var.h +++ b/sys/net/ifq_var.h @@ -377,9 +377,9 @@ ifq_handoff(struct ifnet *_ifp, struct mbuf *_m, struct altq_pktattr *_pa) ASSERT_IFNET_SERIALIZED_TX(_ifp, _ifsq); _error = ifsq_enqueue(_ifsq, _m, _pa); if (_error == 0) { - _ifp->if_obytes += _m->m_pkthdr.len; + IFNET_STAT_INC(_ifp, obytes, _m->m_pkthdr.len); if (_m->m_flags & M_MCAST) - _ifp->if_omcasts++; + IFNET_STAT_INC(_ifp, omcasts, 1); if (!ifsq_is_oactive(_ifsq)) (*_ifp->if_start)(_ifp, _ifsq); } diff --git a/sys/net/pf/if_pflog.c b/sys/net/pf/if_pflog.c index ab317d9f8c..f00f045599 100644 --- a/sys/net/pf/if_pflog.c +++ b/sys/net/pf/if_pflog.c @@ -298,8 +298,8 @@ pflog_packet(struct pfi_kif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, } #endif /* INET */ - ifn->if_opackets++; - ifn->if_obytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifn, opackets, 1); + IFNET_STAT_INC(ifn, obytes, m->m_pkthdr.len); if (ifn->if_bpf) { bpf_gettoken(); if (ifn->if_bpf) { diff --git a/sys/net/pf/if_pfsync.c b/sys/net/pf/if_pfsync.c index 47c622aa39..2f4aea39f6 100644 --- a/sys/net/pf/if_pfsync.c +++ b/sys/net/pf/if_pfsync.c @@ -1180,7 +1180,7 @@ pfsync_get_mbuf(struct pfsync_softc *sc, u_int8_t action, void **sp) MGETHDR(m, M_WAITOK, MT_DATA); if (m == NULL) { - sc->sc_if.if_oerrors++; + IFNET_STAT_INC(&sc->sc_if, oerrors, 1); return (NULL); } @@ -1219,7 +1219,7 @@ pfsync_get_mbuf(struct pfsync_softc *sc, u_int8_t action, void **sp) MCLGET(m, M_WAITOK); if ((m->m_flags & M_EXT) == 0) { m_free(m); - sc->sc_if.if_oerrors++; + IFNET_STAT_INC(&sc->sc_if, oerrors, 1); return (NULL); } m->m_data += (MCLBYTES - len) &~ (sizeof(long) - 1); diff --git a/sys/net/ppp/if_ppp.c b/sys/net/ppp/if_ppp.c index 2449d50b14..243e62d2a2 100644 --- a/sys/net/ppp/if_ppp.c +++ b/sys/net/ppp/if_ppp.c @@ -882,15 +882,15 @@ pppoutput_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, } if (error) { crit_exit(); - sc->sc_if.if_oerrors++; + IFNET_STAT_INC(&sc->sc_if, oerrors, 1); sc->sc_stats.ppp_oerrors++; return (error); } (*sc->sc_start)(sc); } getmicrotime(&ifp->if_lastchange); - ifp->if_opackets++; - ifp->if_obytes += len; + IFNET_STAT_INC(ifp, opackets, 1); + IFNET_STAT_INC(ifp, obytes, len); crit_exit(); return (0); @@ -958,7 +958,7 @@ ppp_requeue(struct ppp_softc *sc) error = ifsq_enqueue(ifsq, m, NULL); } if (error) { - sc->sc_if.if_oerrors++; + IFNET_STAT_INC(&sc->sc_if, oerrors, 1); sc->sc_stats.ppp_oerrors++; } break; @@ -1555,12 +1555,12 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m) if (!rv) { if (sc->sc_flags & SC_DEBUG) kprintf("%s: input queue full\n", ifp->if_xname); - ifp->if_iqdrops++; + IFNET_STAT_INC(ifp, iqdrops, 1); goto bad; } - ifp->if_ipackets++; - ifp->if_ibytes += ilen; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, ilen); getmicrotime(&ifp->if_lastchange); return; @@ -1568,7 +1568,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m) bad: if (m != NULL) m_freem(m); - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); sc->sc_stats.ppp_ierrors++; } diff --git a/sys/net/ppp_layer/ppp_tty.c b/sys/net/ppp_layer/ppp_tty.c index 5cf573d362..00ab1d2f91 100644 --- a/sys/net/ppp_layer/ppp_tty.c +++ b/sys/net/ppp_layer/ppp_tty.c @@ -949,7 +949,7 @@ pppinput(int c, struct tty *tp) if (sc->sc_flags & SC_DEBUG) kprintf("%s: bad fcs %x, pkt len %d\n", sc->sc_if.if_xname, sc->sc_fcs, ilen); - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); sc->sc_stats.ppp_ierrors++; } else sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED); @@ -963,7 +963,7 @@ pppinput(int c, struct tty *tp) if (sc->sc_flags & SC_DEBUG) kprintf("%s: too short (%d)\n", sc->sc_if.if_xname, ilen); crit_enter(); - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); sc->sc_stats.ppp_ierrors++; sc->sc_flags |= SC_PKTLOST; crit_exit(); @@ -1114,7 +1114,7 @@ pppinput(int c, struct tty *tp) flush: if (!(sc->sc_flags & SC_FLUSH)) { crit_enter(); - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); sc->sc_stats.ppp_ierrors++; sc->sc_flags |= SC_FLUSH; crit_exit(); diff --git a/sys/net/sl/if_sl.c b/sys/net/sl/if_sl.c index 766806c814..4c884aea0c 100644 --- a/sys/net/sl/if_sl.c +++ b/sys/net/sl/if_sl.c @@ -477,7 +477,7 @@ sloutput_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, kprintf("%s: af%d not supported\n", sc->sc_if.if_xname, dst->sa_family); m_freem(m); - sc->sc_if.if_noproto++; + IFNET_STAT_INC(&sc->sc_if, noproto, 1); return (EAFNOSUPPORT); } @@ -510,7 +510,7 @@ sloutput_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, error = ifsq_enqueue(ifsq, m, &pktattr); } if (error) { - sc->sc_if.if_oerrors++; + IFNET_STAT_INC(&sc->sc_if, oerrors, 1); crit_exit(); return (error); } @@ -582,7 +582,7 @@ slstart(struct tty *tp) crit_enter(); IF_DEQUEUE(&sc->sc_fastq, m); if (m) - sc->sc_if.if_omcasts++; /* XXX */ + IFNET_STAT_INC(&sc->sc_if, omcasts, 1); /* XXX */ else m = ifsq_dequeue(ifsq, NULL); crit_exit(); @@ -653,7 +653,7 @@ slstart(struct tty *tp) */ if (cfreecount < CLISTRESERVE + SLTMAX) { m_freem(m); - sc->sc_if.if_collisions++; + IFNET_STAT_INC(&sc->sc_if, collisions, 1); continue; } @@ -664,7 +664,7 @@ slstart(struct tty *tp) * the line may have been idle for some time. */ if (tp->t_outq.c_cc == 0) { - ++sc->sc_if.if_obytes; + IFNET_STAT_INC(&sc->sc_if, obytes, 1); clist_putc(FRAME_END, &tp->t_outq); } @@ -696,7 +696,8 @@ slstart(struct tty *tp) if (b_to_q((char *)bp, cp - bp, &tp->t_outq)) break; - sc->sc_if.if_obytes += cp - bp; + IFNET_STAT_INC(&sc->sc_if, obytes, + cp - bp); } /* * If there are characters left in the mbuf, @@ -712,7 +713,7 @@ slstart(struct tty *tp) clist_unputc(&tp->t_outq); break; } - sc->sc_if.if_obytes += 2; + IFNET_STAT_INC(&sc->sc_if, obytes, 2); } } m = m_free(m); @@ -728,10 +729,10 @@ slstart(struct tty *tp) */ clist_unputc(&tp->t_outq); clist_putc(FRAME_END, &tp->t_outq); - sc->sc_if.if_collisions++; + IFNET_STAT_INC(&sc->sc_if, collisions, 1); } else { - ++sc->sc_if.if_obytes; - sc->sc_if.if_opackets++; + IFNET_STAT_INC(&sc->sc_if, obytes, 1); + IFNET_STAT_INC(&sc->sc_if, opackets, 1); } } lwkt_reltoken(&tty_token); @@ -803,7 +804,7 @@ slinput(int c, struct tty *tp) } c &= TTY_CHARMASK; - ++sc->sc_if.if_ibytes; + IFNET_STAT_INC(&sc->sc_if, ibytes, 1); if (sc->sc_if.if_flags & IFF_DEBUG) { if (c == ABT_ESC) { @@ -923,7 +924,7 @@ slinput(int c, struct tty *tp) if (m == NULL) goto error; - sc->sc_if.if_ipackets++; + IFNET_STAT_INC(&sc->sc_if, ipackets, 1); if ((sc->sc_if.if_flags & IFF_UP) == 0) { m_freem(m); @@ -931,8 +932,8 @@ slinput(int c, struct tty *tp) } if (netisr_queue(NETISR_IP, m)) { - sc->sc_if.if_ierrors++; - sc->sc_if.if_iqdrops++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); + IFNET_STAT_INC(&sc->sc_if, iqdrops, 1); } goto newpack; @@ -948,7 +949,7 @@ slinput(int c, struct tty *tp) sc->sc_flags |= SC_ERROR; error: - sc->sc_if.if_ierrors++; + IFNET_STAT_INC(&sc->sc_if, ierrors, 1); newpack: sc->sc_mp = sc->sc_buf = sc->sc_ep + SLBUFSIZE - SLRMAX; sc->sc_escape = 0; @@ -1059,7 +1060,7 @@ sl_outfill(void *chan) if (sc->sc_outfill && tp != NULL) { if (sc->sc_flags & SC_OUTWAIT) { crit_enter(); - ++sc->sc_if.if_obytes; + IFNET_STAT_INC(&sc->sc_if, obytes, 1); clist_putc(FRAME_END, &tp->t_outq); (*tp->t_oproc)(tp); crit_exit(); diff --git a/sys/net/sppp/if_spppsubr.c b/sys/net/sppp/if_spppsubr.c index e7cbcf2193..533fac83b4 100644 --- a/sys/net/sppp/if_spppsubr.c +++ b/sys/net/sppp/if_spppsubr.c @@ -505,7 +505,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) if (ifp->if_flags & IFF_UP) /* Count received bytes, add FCS and one flag */ - ifp->if_ibytes += m->m_pkthdr.len + 3; + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len + 3); if (m->m_pkthdr.len <= PPP_HEADER_LEN) { /* Too small packet, drop it. */ @@ -516,8 +516,8 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) drop: m_freem (m); drop2: - ++ifp->if_ierrors; - ++ifp->if_iqdrops; + IFNET_STAT_INC(ifp, ierrors, 1); + IFNET_STAT_INC(ifp, iqdrops, 1); return; } @@ -550,7 +550,7 @@ drop2: sppp_cp_send (sp, PPP_LCP, PROTO_REJ, ++sp->pp_seq[IDX_LCP], m->m_pkthdr.len + 2, &h->protocol); - ++ifp->if_noproto; + IFNET_STAT_INC(ifp, noproto, 1); goto drop; case PPP_LCP: sppp_cp_input(&lcp, sp, m); @@ -666,7 +666,7 @@ drop2: } switch (ntohs (h->protocol)) { default: - ++ifp->if_noproto; + IFNET_STAT_INC(ifp, noproto, 1); goto invalid; case CISCO_KEEPALIVE: sppp_cisco_input ((struct sppp*) ifp, m); @@ -858,7 +858,7 @@ sppp_output_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, if (debug) log(LOG_DEBUG, SPP_FMT "no memory for transmit header\n", SPP_ARGS(ifp)); - ++ifp->if_oerrors; + IFNET_STAT_INC(ifp, oerrors, 1); crit_exit(); return (ENOBUFS); } @@ -924,7 +924,7 @@ sppp_output_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, #endif default: m_freem (m); - ++ifp->if_oerrors; + IFNET_STAT_INC(ifp, oerrors, 1); crit_exit(); return (EAFNOSUPPORT); } @@ -946,7 +946,7 @@ sppp_output_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, rv = ifsq_enqueue(ifsq, m, &pktattr); } if (rv) { - ++ifp->if_oerrors; + IFNET_STAT_INC(ifp, oerrors, 1); crit_exit(); return(rv); } @@ -958,7 +958,7 @@ sppp_output_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, * The packet length includes header, FCS and 1 flag, * according to RFC 1333. */ - ifp->if_obytes += m->m_pkthdr.len + 3; + IFNET_STAT_INC(ifp, obytes, m->m_pkthdr.len + 3); /* * Unlike in sppp_input(), we can always bump the timestamp @@ -1390,7 +1390,7 @@ sppp_cisco_send(struct sppp *sp, int type, long par1, long par2) ifsq = ifq_get_subq_default(&ifp->if_snd); if (!ifsq_is_oactive(ifsq)) (*ifp->if_start) (ifp, ifsq); - ifp->if_obytes += m->m_pkthdr.len + 3; + IFNET_STAT_INC(ifp, obytes, m->m_pkthdr.len + 3); } /* @@ -1442,13 +1442,13 @@ sppp_cp_send(struct sppp *sp, u_short proto, u_char type, if (IF_QFULL (&sp->pp_cpq)) { IF_DROP (&sp->pp_fastq); m_freem (m); - ++ifp->if_oerrors; + IFNET_STAT_INC(ifp, oerrors, 1); } else IF_ENQUEUE (&sp->pp_cpq, m); ifsq = ifq_get_subq_default(&ifp->if_snd); if (!ifsq_is_oactive(ifsq)) (*ifp->if_start) (ifp, ifsq); - ifp->if_obytes += m->m_pkthdr.len + 3; + IFNET_STAT_INC(ifp, obytes, m->m_pkthdr.len + 3); } /* @@ -1494,7 +1494,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s invalid conf-req length %d\n", SPP_ARGS(ifp), cp->name, len); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); break; } /* handle states where RCR doesn't get a SCA/SCN */ @@ -1556,7 +1556,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } break; case CONF_ACK: @@ -1565,7 +1565,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s id mismatch 0x%x != 0x%x\n", SPP_ARGS(ifp), cp->name, h->ident, sp->confid[cp->protoidx]); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); break; } switch (sp->state[cp->protoidx]) { @@ -1600,7 +1600,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } break; case CONF_NAK: @@ -1610,7 +1610,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s id mismatch 0x%x != 0x%x\n", SPP_ARGS(ifp), cp->name, h->ident, sp->confid[cp->protoidx]); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); break; } if (h->type == CONF_NAK) @@ -1650,7 +1650,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } break; @@ -1683,7 +1683,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } break; case TERM_ACK: @@ -1714,7 +1714,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } break; case CODE_REJ: @@ -1741,7 +1741,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } break; case PROTO_REJ: @@ -1800,7 +1800,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } break; } @@ -1816,7 +1816,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) if (debug) log(-1, SPP_FMT "lcp echo req but lcp closed\n", SPP_ARGS(ifp)); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); break; } if (len < 8) { @@ -1850,7 +1850,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) if (cp->proto != PPP_LCP) goto illegal; if (h->ident != sp->lcp.echoid) { - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); break; } if (len < 8) { @@ -1875,7 +1875,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, h->type); sppp_cp_send(sp, cp->proto, CODE_REJ, ++sp->pp_seq[cp->protoidx], m->m_pkthdr.len, h); - ++ifp->if_ierrors; + IFNET_STAT_INC(ifp, ierrors, 1); } } @@ -4782,13 +4782,13 @@ sppp_auth_send(const struct cp *cp, struct sppp *sp, if (IF_QFULL (&sp->pp_cpq)) { IF_DROP (&sp->pp_fastq); m_freem (m); - ++ifp->if_oerrors; + IFNET_STAT_INC(ifp, oerrors, 1); } else IF_ENQUEUE (&sp->pp_cpq, m); ifsq = ifq_get_subq_default(&ifp->if_snd); if (!ifsq_is_oactive(ifsq)) (*ifp->if_start) (ifp, ifsq); - ifp->if_obytes += m->m_pkthdr.len + 3; + IFNET_STAT_INC(ifp, obytes, m->m_pkthdr.len + 3); } /* diff --git a/sys/net/stf/if_stf.c b/sys/net/stf/if_stf.c index b957ec3571..bbe31b2ea6 100644 --- a/sys/net/stf/if_stf.c +++ b/sys/net/stf/if_stf.c @@ -600,8 +600,8 @@ in_stf_input(struct mbuf **mp, int *offp, int proto) * See net/if_gif.c for possible issues with packet processing * reorder due to extra queueing. */ - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); netisr_queue(NETISR_IPV6, m); return(IPPROTO_DONE); } diff --git a/sys/net/tap/if_tap.c b/sys/net/tap/if_tap.c index 913e204e0e..113bf3ae31 100644 --- a/sys/net/tap/if_tap.c +++ b/sys/net/tap/if_tap.c @@ -671,11 +671,11 @@ tapifstart(struct ifnet *ifp, struct ifaltq_subque *ifsq) while ((m = ifsq_dequeue(ifsq, NULL)) != NULL) { if (IF_QFULL(ifq)) { IF_DROP(ifq); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(m); } else { IF_ENQUEUE(ifq, m); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); has_data = 1; } } @@ -952,7 +952,7 @@ tapwrite(struct dev_write_args *ap) } } if (error) { - ifp->if_ierrors ++; + IFNET_STAT_INC(ifp, ierrors, 1); if (top) m_freem(top); return (error); @@ -968,7 +968,7 @@ tapwrite(struct dev_write_args *ap) */ ifnet_serialize_all(ifp); ifp->if_input(ifp, top); - ifp->if_ipackets ++; /* ibytes are counted in ether_input */ + IFNET_STAT_INC(ifp, ipackets, 1);/* ibytes are counted in ether_input */ ifnet_deserialize_all(ifp); return (0); diff --git a/sys/net/tun/if_tun.c b/sys/net/tun/if_tun.c index 0846c623a7..d0aa34a4b8 100644 --- a/sys/net/tun/if_tun.c +++ b/sys/net/tun/if_tun.c @@ -360,7 +360,7 @@ tunoutput_serialized(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, /* if allocation failed drop packet */ if (m0 == NULL){ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return (ENOBUFS); } else { bcopy(dst, m0->m_data, dst->sa_len); @@ -373,7 +373,7 @@ tunoutput_serialized(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, /* if allocation failed drop packet */ if (m0 == NULL){ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return ENOBUFS; } else *(u_int32_t *)m0->m_data = htonl(dst->sa_family); @@ -389,9 +389,9 @@ tunoutput_serialized(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, error = ifq_handoff(ifp, m0, &pktattr); if (error) { - ifp->if_collisions++; + IFNET_STAT_INC(ifp, collisions, 1); } else { - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); if (tp->tun_flags & TUN_RWAIT) { tp->tun_flags &= ~TUN_RWAIT; wakeup((caddr_t)tp); @@ -631,7 +631,7 @@ tunwrite(struct dev_write_args *ap) if (error) { if (top) m_freem (top); - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); return error; } @@ -682,8 +682,8 @@ tunwrite(struct dev_write_args *ap) } else family = AF_INET; - ifp->if_ibytes += top->m_pkthdr.len; - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ibytes, top->m_pkthdr.len); + IFNET_STAT_INC(ifp, ipackets, 1); switch (family) { #ifdef INET diff --git a/sys/net/vlan/if_vlan.c b/sys/net/vlan/if_vlan.c index 0e291ef5f7..a3569b2d56 100644 --- a/sys/net/vlan/if_vlan.c +++ b/sys/net/vlan/if_vlan.c @@ -532,7 +532,7 @@ vlan_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) if ((ifp_p->if_flags & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING)) { m_freem(m); - ifp->if_data.ifi_collisions++; + IFNET_STAT_INC(ifp, collisions, 1); continue; } @@ -555,7 +555,7 @@ vlan_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) nmp->base.lmsg.u.ms_resultp = ifp_p; lwkt_sendmsg(p_port, &nmp->base.lmsg); - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } @@ -572,7 +572,7 @@ vlan_input(struct mbuf *m) vlantrunks = rcvif->if_vlantrunks; if (vlantrunks == NULL) { - rcvif->if_noproto++; + IFNET_STAT_INC(rcvif, noproto, 1); m_freem(m); return; } @@ -594,7 +594,7 @@ vlan_input(struct mbuf *m) * or is being destroyed (ifv->ifv_p != rcvif) */ if (ifv == NULL || ifv->ifv_p != rcvif) { - rcvif->if_noproto++; + IFNET_STAT_INC(rcvif, noproto, 1); m_freem(m); return; } diff --git a/sys/netgraph/eiface/ng_eiface.c b/sys/netgraph/eiface/ng_eiface.c index f5f9257da5..23072c2b58 100644 --- a/sys/netgraph/eiface/ng_eiface.c +++ b/sys/netgraph/eiface/ng_eiface.c @@ -258,8 +258,8 @@ ng_eiface_start(struct ifnet *ifp, struct ifaltq_subque *ifsq __unused) /* Update stats */ if (error == 0) { - ifp->if_obytes += len; - ifp->if_opackets++; + IFNET_STAT_INC(ifp, obytes, len); + IFNET_STAT_INC(ifp, opackets, 1); } ifq_clr_oactive(&ifp->if_snd); @@ -510,7 +510,7 @@ ng_eiface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) m->m_pkthdr.rcvif = ifp; /* Update interface stats */ - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); BPF_MTAP(ifp, m); diff --git a/sys/netgraph/fec/ng_fec.c b/sys/netgraph/fec/ng_fec.c index 925ea9bb5e..b77ccdd47c 100644 --- a/sys/netgraph/fec/ng_fec.c +++ b/sys/netgraph/fec/ng_fec.c @@ -757,8 +757,8 @@ ng_fec_input(struct ifnet *ifp, struct mbuf **m0) /* Pretend this is our frame. */ m->m_pkthdr.rcvif = bifp; - bifp->if_ipackets++; - bifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(bifp, ipackets, 1); + IFNET_STAT_INC(bifp, ibytes, m->m_pkthdr.len); if (bifp->if_bpf) { bpf_gettoken(); @@ -998,12 +998,12 @@ ng_fec_start(struct ifnet *ifp, struct ifaltq_subque *ifsq __unused) /* Queue up packet on the proper port. */ error = ng_fec_choose_port(b, m0, &oifp); if (error) { - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); m_freem(m0); priv->if_error = ENOBUFS; return; } - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); /* * Release current iface's serializer to avoid possible dead lock diff --git a/sys/netgraph/iface/ng_iface.c b/sys/netgraph/iface/ng_iface.c index 988ad916d2..c200adbe66 100644 --- a/sys/netgraph/iface/ng_iface.c +++ b/sys/netgraph/iface/ng_iface.c @@ -451,8 +451,8 @@ ng_iface_output_serialized(struct ifnet *ifp, struct mbuf *m, /* Update stats */ if (error == 0) { - ifp->if_obytes += len; - ifp->if_opackets++; + IFNET_STAT_INC(ifp, obytes, len); + IFNET_STAT_INC(ifp, opackets, 1); } return (error); } @@ -758,8 +758,8 @@ ng_iface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) } /* Update interface stats */ - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); /* Note receiving interface */ m->m_pkthdr.rcvif = ifp; diff --git a/sys/netgraph7/iface/ng_iface.c b/sys/netgraph7/iface/ng_iface.c index cfb05ee496..90a5c9d5b5 100644 --- a/sys/netgraph7/iface/ng_iface.c +++ b/sys/netgraph7/iface/ng_iface.c @@ -439,7 +439,7 @@ ng_iface_output(struct ifnet *ifp, struct mbuf *m, if (ifq_is_enabled(&ifp->if_snd)) { M_PREPEND(m, sizeof(sa_family_t), MB_DONTWAIT); if (m == NULL) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return (ENOBUFS); } *(sa_family_t *)m->m_data = dst->sa_family; @@ -519,8 +519,8 @@ ng_iface_send(struct ifnet *ifp, struct mbuf *m, sa_family_t sa) /* Update stats. */ if (error == 0) { - ifp->if_obytes += len; - ifp->if_opackets++; + IFNET_STAT_INC(ifp, obytes, len); + IFNET_STAT_INC(ifp, opackets, 1); } return (error); @@ -790,8 +790,8 @@ ng_iface_rcvdata(hook_p hook, item_p item) } /* Update interface stats */ - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(ifp, ipackets, 1); + IFNET_STAT_INC(ifp, ibytes, m->m_pkthdr.len); /* Note receiving interface */ m->m_pkthdr.rcvif = ifp; diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 2a5e10da1f..6ea62531bc 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1336,7 +1336,7 @@ carp_send_ad(struct carp_softc *sc) MGETHDR(m, MB_DONTWAIT, MT_HEADER); if (m == NULL) { - cifp->if_oerrors++; + IFNET_STAT_INC(cifp, oerrors, 1); carpstats.carps_onomem++; /* XXX maybe less ? */ if (advbase != 255 || advskew != 255) @@ -1369,12 +1369,12 @@ carp_send_ad(struct carp_softc *sc) ch_ptr->carp_cksum = in_cksum_skip(m, len, sizeof(*ip)); getmicrotime(&cifp->if_lastchange); - cifp->if_opackets++; - cifp->if_obytes += len; + IFNET_STAT_INC(cifp, opackets, 1); + IFNET_STAT_INC(cifp, obytes, len); carpstats.carps_opackets++; if (ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL)) { - cifp->if_oerrors++; + IFNET_STAT_INC(cifp, oerrors, 1); if (sc->sc_sendad_errors < INT_MAX) sc->sc_sendad_errors++; if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) { @@ -1403,7 +1403,7 @@ carp_send_ad(struct carp_softc *sc) MGETHDR(m, MB_DONTWAIT, MT_HEADER); if (m == NULL) { - cifp->if_oerrors++; + IFNET_STAT_INC(cifp, oerrors, 1); carpstats.carps_onomem++; /* XXX maybe less ? */ if (advbase != 255 || advskew != 255) @@ -1429,7 +1429,7 @@ carp_send_ad(struct carp_softc *sc) ip6->ip6_dst.s6_addr16[0] = htons(0xff02); ip6->ip6_dst.s6_addr8[15] = 0x12; if (in6_setscope(&ip6->ip6_dst, sc->sc_carpdev, NULL) != 0) { - cifp->if_oerrors++; + IFNET_STAT_INC(cifp, oerrors, 1); m_freem(m); CARP_LOG("%s: in6_setscope failed\n", __func__); return; @@ -1441,12 +1441,12 @@ carp_send_ad(struct carp_softc *sc) ch_ptr->carp_cksum = in_cksum_skip(m, len, sizeof(*ip6)); getmicrotime(&cifp->if_lastchange); - cifp->if_opackets++; - cifp->if_obytes += len; + IFNET_STAT_INC(cifp, opackets, 1); + IFNET_STAT_INC(cifp, obytes, len); carpstats.carps_opackets6++; if (ip6_output(m, NULL, NULL, 0, &sc->sc_im6o, NULL, NULL)) { - cifp->if_oerrors++; + IFNET_STAT_INC(cifp, oerrors, 1); if (sc->sc_sendad_errors < INT_MAX) sc->sc_sendad_errors++; if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) { diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index a7eb053bce..8a6d8df7b3 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -140,8 +140,8 @@ gre_input2(struct mbuf *m ,int hlen, u_char proto) return (0); } - sc->sc_if.if_ipackets++; - sc->sc_if.if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(&sc->sc_if, ipackets, 1); + IFNET_STAT_INC(&sc->sc_if, ibytes, m->m_pkthdr.len); switch (proto) { case IPPROTO_GRE: @@ -216,8 +216,8 @@ gre_mobile_input(struct mbuf **mp, int *offp, int proto) return(IPPROTO_DONE); } - sc->sc_if.if_ipackets++; - sc->sc_if.if_ibytes += m->m_pkthdr.len; + IFNET_STAT_INC(&sc->sc_if, ipackets, 1); + IFNET_STAT_INC(&sc->sc_if, ibytes, m->m_pkthdr.len); if(ntohs(mip->mh.proto) & MOB_H_SBIT) { msiz = MOB_H_SIZ_L; diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 725c6a27ca..dc6dd73b13 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -835,8 +835,8 @@ ours: /* Count the packet in the ip address stats */ if (ia != NULL) { - ia->ia_ifa.if_ipackets++; - ia->ia_ifa.if_ibytes += m->m_pkthdr.len; + IFA_STAT_INC(&ia->ia_ifa, ipackets, 1); + IFA_STAT_INC(&ia->ia_ifa, ibytes, m->m_pkthdr.len); } /* diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 615f31511b..17348bd994 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -926,8 +926,8 @@ pass: /* Record statistics for this interface address. */ if (!(flags & IP_FORWARDING) && ia) { - ia->ia_ifa.if_opackets++; - ia->ia_ifa.if_obytes += m->m_pkthdr.len; + IFA_STAT_INC(&ia->ia_ifa, opackets, 1); + IFA_STAT_INC(&ia->ia_ifa, obytes, m->m_pkthdr.len); } #ifdef IPSEC @@ -999,8 +999,9 @@ pass: if (error == 0) { /* Record statistics for this interface address. */ if (ia != NULL) { - ia->ia_ifa.if_opackets++; - ia->ia_ifa.if_obytes += m->m_pkthdr.len; + IFA_STAT_INC(&ia->ia_ifa, opackets, 1); + IFA_STAT_INC(&ia->ia_ifa, obytes, + m->m_pkthdr.len); } #ifdef MPLS if (!mpls_output_process(m, ro->ro_rt)) diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index f739e29baa..99d08d331a 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -586,8 +586,8 @@ ip6_input(netmsg_t msg) ours = 1; deliverifp = ia6->ia_ifp; /* correct? */ /* Count the packet in the ip address stats */ - ia6->ia_ifa.if_ipackets++; - ia6->ia_ifa.if_ibytes += m->m_pkthdr.len; + IFA_STAT_INC(&ia6->ia_ifa, ipackets, 1); + IFA_STAT_INC(&ia6->ia_ifa, ibytes, m->m_pkthdr.len); goto hbhcheck; } else { /* address is not ready, so discard the packet. */ diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 317f423a1f..f86fc537c3 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -948,8 +948,8 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 *ro, ia6 = in6_ifawithifp(ifp, &ip6->ip6_src); if (ia6) { /* Record statistics for this interface address. */ - ia6->ia_ifa.if_opackets++; - ia6->ia_ifa.if_obytes += m->m_pkthdr.len; + IFA_STAT_INC(&ia6->ia_ifa, opackets, 1); + IFA_STAT_INC(&ia6->ia_ifa, obytes, m->m_pkthdr.len); } #ifdef IPSEC /* clean ipsec history once it goes out of the node */ @@ -1081,8 +1081,9 @@ sendorfree: if (error == 0) { /* Record statistics for this interface address. */ if (ia) { - ia->ia_ifa.if_opackets++; - ia->ia_ifa.if_obytes += m->m_pkthdr.len; + IFA_STAT_INC(&ia->ia_ifa, opackets, 1); + IFA_STAT_INC(&ia->ia_ifa, obytes, + m->m_pkthdr.len); } #ifdef IPSEC /* clean ipsec history once it goes out of the node */ diff --git a/sys/netproto/802_11/wlan/ieee80211.c b/sys/netproto/802_11/wlan/ieee80211.c index c4084d4f7f..6fbeeaea6a 100644 --- a/sys/netproto/802_11/wlan/ieee80211.c +++ b/sys/netproto/802_11/wlan/ieee80211.c @@ -233,7 +233,7 @@ static int null_transmit(struct ifnet *ifp, struct mbuf *m) { m_freem(m); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return EACCES; /* XXX EIO/EPERM? */ } diff --git a/sys/netproto/802_11/wlan/ieee80211_adhoc.c b/sys/netproto/802_11/wlan/ieee80211_adhoc.c index d9b0480948..5b7edade8a 100644 --- a/sys/netproto/802_11/wlan/ieee80211_adhoc.c +++ b/sys/netproto/802_11/wlan/ieee80211_adhoc.c @@ -654,7 +654,7 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/netproto/802_11/wlan/ieee80211_hostap.c b/sys/netproto/802_11/wlan/ieee80211_hostap.c index 14bb8cb60a..3239d08839 100644 --- a/sys/netproto/802_11/wlan/ieee80211_hostap.c +++ b/sys/netproto/802_11/wlan/ieee80211_hostap.c @@ -362,7 +362,7 @@ hostap_deliver_data(struct ieee80211vap *vap, /* * Do accounting. */ - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); IEEE80211_NODE_STAT(ni, rx_data); IEEE80211_NODE_STAT_ADD(ni, rx_bytes, m->m_pkthdr.len); if (ETHER_IS_MULTICAST(eh->ether_dhost)) { @@ -378,7 +378,7 @@ hostap_deliver_data(struct ieee80211vap *vap, if (m->m_flags & M_MCAST) { mcopy = m_dup(m, MB_DONTWAIT); if (mcopy == NULL) - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); else mcopy->m_flags |= M_MCAST; } else { @@ -415,7 +415,7 @@ hostap_deliver_data(struct ieee80211vap *vap, if (err) { /* NB: IFQ_HANDOFF reclaims mcopy */ } else { - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } } @@ -900,7 +900,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/netproto/802_11/wlan/ieee80211_input.c b/sys/netproto/802_11/wlan/ieee80211_input.c index 2b74228005..d70b12150d 100644 --- a/sys/netproto/802_11/wlan/ieee80211_input.c +++ b/sys/netproto/802_11/wlan/ieee80211_input.c @@ -209,7 +209,7 @@ ieee80211_deliver_data(struct ieee80211vap *vap, /* * Do accounting. */ - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); IEEE80211_NODE_STAT(ni, rx_data); IEEE80211_NODE_STAT_ADD(ni, rx_bytes, m->m_pkthdr.len); if (ETHER_IS_MULTICAST(eh->ether_dhost)) { diff --git a/sys/netproto/802_11/wlan/ieee80211_mesh.c b/sys/netproto/802_11/wlan/ieee80211_mesh.c index 3167739acd..b9764340f8 100644 --- a/sys/netproto/802_11/wlan/ieee80211_mesh.c +++ b/sys/netproto/802_11/wlan/ieee80211_mesh.c @@ -843,7 +843,7 @@ mesh_forward(struct ieee80211vap *vap, struct mbuf *m, IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, cannot dup"); vap->iv_stats.is_mesh_fwd_nobuf++; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return; } mcopy = m_pullup(mcopy, ieee80211_hdrspace(ic, wh) + @@ -852,7 +852,7 @@ mesh_forward(struct ieee80211vap *vap, struct mbuf *m, IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, too short"); vap->iv_stats.is_mesh_fwd_tooshort++; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(mcopy); return; } @@ -889,7 +889,7 @@ mesh_forward(struct ieee80211vap *vap, struct mbuf *m, /* NB: IFQ_HANDOFF reclaims mbuf */ ieee80211_free_node(ni); } else { - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } @@ -1259,7 +1259,7 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) @@ -2468,6 +2468,7 @@ mesh_airtime_calc(struct ieee80211_node *ni) static const int nbits = 8192 << M_BITS; uint32_t overhead, rate, errrate; uint64_t res; + u_long oerr, ierr; /* Time to transmit a frame */ rate = ni->ni_txrate; @@ -2475,8 +2476,9 @@ mesh_airtime_calc(struct ieee80211_node *ni) ifp->if_mtu + IEEE80211_MESH_MAXOVERHEAD, rate, 0) << M_BITS; /* Error rate in percentage */ /* XXX assuming small failures are ok */ - errrate = (((ifp->if_oerrors + - ifp->if_ierrors) / 100) << M_BITS) / 100; + IFNET_STAT_GET(ifp, oerrors, oerr); + IFNET_STAT_GET(ifp, ierrors, ierr); + errrate = (((oerr + ierr) / 100) << M_BITS) / 100; res = (overhead + (nbits / rate)) * ((1 << S_FACTOR) / ((1 << M_BITS) - errrate)); diff --git a/sys/netproto/802_11/wlan/ieee80211_monitor.c b/sys/netproto/802_11/wlan/ieee80211_monitor.c index 9de8533b37..defe0e0cad 100644 --- a/sys/netproto/802_11/wlan/ieee80211_monitor.c +++ b/sys/netproto/802_11/wlan/ieee80211_monitor.c @@ -125,7 +125,7 @@ monitor_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) struct ieee80211vap *vap = ni->ni_vap; struct ifnet *ifp = vap->iv_ifp; - ifp->if_ipackets++; + IFNET_STAT_INC(ifp, ipackets, 1); if (ieee80211_radiotap_active_vap(vap)) ieee80211_radiotap_rx(vap, m); diff --git a/sys/netproto/802_11/wlan/ieee80211_output.c b/sys/netproto/802_11/wlan/ieee80211_output.c index f061a0baab..7912f2d5bb 100644 --- a/sys/netproto/802_11/wlan/ieee80211_output.c +++ b/sys/netproto/802_11/wlan/ieee80211_output.c @@ -191,7 +191,7 @@ ieee80211_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, "discard frame, %s\n", "m_pullup failed"); vap->iv_stats.is_tx_nobuf++; /* XXX */ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); continue; } eh = mtod(m, struct ether_header *); @@ -223,7 +223,7 @@ ieee80211_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) ni = ieee80211_find_txnode(vap, eh->ether_dhost); if (ni == NULL) { /* NB: ieee80211_find_txnode does stat+msg */ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(m); continue; } @@ -234,7 +234,7 @@ ieee80211_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) "sta not associated (type 0x%04x)", htons(eh->ether_type)); vap->iv_stats.is_tx_notassoc++; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(m); ieee80211_free_node(ni); continue; @@ -252,7 +252,7 @@ ieee80211_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) eh->ether_dhost, NULL, "%s", "proxy not enabled"); vap->iv_stats.is_mesh_notproxy++; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(m); continue; } @@ -264,7 +264,7 @@ ieee80211_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) * NB: ieee80211_mesh_discover holds/disposes * frame (e.g. queueing on path discovery). */ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); continue; } } @@ -287,7 +287,7 @@ ieee80211_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) eh->ether_dhost, NULL, "%s", "classification failure"); vap->iv_stats.is_tx_classify++; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(m); ieee80211_free_node(ni); continue; @@ -363,7 +363,7 @@ ieee80211_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) /* NB: IFQ_HANDOFF reclaims mbuf */ ieee80211_free_node(ni); } else { - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } ic->ic_lastdata = ticks; } @@ -469,7 +469,7 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m, if (ieee80211_classify(ni, m)) senderr(EIO); /* XXX */ - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); IEEE80211_NODE_STAT(ni, tx_data); if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { IEEE80211_NODE_STAT(ni, tx_mcast); @@ -493,7 +493,7 @@ bad: m_freem(m); if (ni != NULL) ieee80211_free_node(ni); - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); return error; #undef senderr } diff --git a/sys/netproto/802_11/wlan/ieee80211_sta.c b/sys/netproto/802_11/wlan/ieee80211_sta.c index 0c64e9cbd6..da4d826ff0 100644 --- a/sys/netproto/802_11/wlan/ieee80211_sta.c +++ b/sys/netproto/802_11/wlan/ieee80211_sta.c @@ -900,7 +900,7 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/netproto/802_11/wlan/ieee80211_superg.c b/sys/netproto/802_11/wlan/ieee80211_superg.c index 35d6adba88..f32a332d95 100644 --- a/sys/netproto/802_11/wlan/ieee80211_superg.c +++ b/sys/netproto/802_11/wlan/ieee80211_superg.c @@ -512,7 +512,7 @@ ff_transmit(struct ieee80211_node *ni, struct mbuf *m) /* NB: IFQ_HANDOFF reclaims mbuf */ ieee80211_free_node(ni); } else { - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } else ieee80211_free_node(ni); diff --git a/sys/netproto/802_11/wlan/ieee80211_wds.c b/sys/netproto/802_11/wlan/ieee80211_wds.c index b4084ef814..f5b5e9736d 100644 --- a/sys/netproto/802_11/wlan/ieee80211_wds.c +++ b/sys/netproto/802_11/wlan/ieee80211_wds.c @@ -258,14 +258,14 @@ ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m) */ mcopy = m_copypacket(m, MB_DONTWAIT); if (mcopy == NULL) { - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); /* XXX stat + msg */ continue; } ni = ieee80211_find_txnode(vap, eh->ether_dhost); if (ni == NULL) { /* NB: ieee80211_find_txnode does stat+msg */ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(mcopy); continue; } @@ -276,7 +276,7 @@ ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m) eh->ether_dhost, NULL, "%s", "classification failure"); vap->iv_stats.is_tx_classify++; - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); m_freem(mcopy); ieee80211_free_node(ni); continue; @@ -299,10 +299,10 @@ ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m) err = ieee80211_handoff(parent, mcopy); if (err) { /* NB: IFQ_HANDOFF reclaims mbuf */ - ifp->if_oerrors++; + IFNET_STAT_INC(ifp, oerrors, 1); ieee80211_free_node(ni); } else - ifp->if_opackets++; + IFNET_STAT_INC(ifp, opackets, 1); } } @@ -730,7 +730,7 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + IFNET_STAT_INC(ifp, ierrors, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/netproto/ipx/ipx_ip.c b/sys/netproto/ipx/ipx_ip.c index 613a41bad1..dd8c33dce0 100644 --- a/sys/netproto/ipx/ipx_ip.c +++ b/sys/netproto/ipx/ipx_ip.c @@ -177,11 +177,11 @@ ipxip_input(struct mbuf **mp, int *offp, int proto) /* * Get IP and IPX header together in first mbuf. */ - ipxipif.if_ipackets++; + IFNET_STAT_INC(&ipxipif, ipackets, 1); s = sizeof(struct ip) + sizeof(struct ipx); if (((m->m_flags & M_EXT) || m->m_len < s) && (m = m_pullup(m, s)) == NULL) { - ipxipif.if_ierrors++; + IFNET_STAT_INC(&ipxipif, ierrors, 1); return(IPPROTO_DONE); } ip = mtod(m, struct ip *); @@ -189,7 +189,7 @@ ipxip_input(struct mbuf **mp, int *offp, int proto) ip_stripoptions(m); if (m->m_len < s) { if ((m = m_pullup(m, s)) == NULL) { - ipxipif.if_ierrors++; + IFNET_STAT_INC(&ipxipif, ierrors, 1); return(IPPROTO_DONE); } ip = mtod(m, struct ip *); @@ -209,7 +209,7 @@ ipxip_input(struct mbuf **mp, int *offp, int proto) len++; /* Preserve Garbage Byte */ if (ip->ip_len != len) { if (len > ip->ip_len) { - ipxipif.if_ierrors++; + IFNET_STAT_INC(&ipxipif, ierrors, 1); if (ipxip_badlen) m_freem(ipxip_badlen); ipxip_badlen = m; @@ -236,8 +236,8 @@ ipxipoutput_serialized(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct ipx *ipx = mtod(m, struct ipx *); int error; - ifn->ifen_ifnet.if_opackets++; - ipxipif.if_opackets++; + IFNET_STAT_INC(&ifn->ifen_ifnet, opackets, 1); + IFNET_STAT_INC(&ipxipif, opackets, 1); /* * Calculate data length and make space @@ -281,8 +281,8 @@ ipxipoutput_serialized(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, */ error = (ip_output(m, NULL, ro, SO_BROADCAST, NULL, NULL)); if (error) { - ifn->ifen_ifnet.if_oerrors++; - ifn->ifen_ifnet.if_ierrors = error; + IFNET_STAT_INC(&ifn->ifen_ifnet, oerrors, 1); + IFNET_STAT_SET(&ifn->ifen_ifnet, ierrors, error); } return (error); m_freem(m); -- 2.41.0