Adopt <net/if_stats.h>.

This commit is contained in:
thorpej 2020-01-29 05:20:26 +00:00
parent b331a82b58
commit 1a2cab1766
7 changed files with 67 additions and 64 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_es.c,v 1.64 2019/05/29 10:07:28 msaitoh Exp $ */
/* $NetBSD: if_es.c,v 1.65 2020/01/29 05:23:16 thorpej Exp $ */
/*
* Copyright (c) 1995 Michael L. Hitch
@ -33,7 +33,7 @@
#include "opt_ns.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.64 2019/05/29 10:07:28 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.65 2020/01/29 05:23:16 thorpej Exp $");
#include <sys/param.h>
@ -389,7 +389,7 @@ esintr(void *arg)
intsts);
smc->b2.ist = ACK_RX_OVRN;
printf ("->%02x\n", smc->b2.ist);
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
}
if (intact & IST_TX_EMPTY) {
u_short ecr;
@ -417,8 +417,8 @@ esintr(void *arg)
smc->b0.bsr = BSR_BANK0;
ecr = smc->b0.ecr; /* Get error counters */
if (ecr & 0xff00)
ifp->if_collisions += ((ecr >> 8) & 15) +
((ecr >> 11) & 0x1e);
if_statadd(ifp, if_collisions,
((ecr >> 8) & 15) + ((ecr >> 11) & 0x1e));
smc->b2.bsr = BSR_BANK2;
#if 0
smc->b2.mmucr = MMUCR_RESET_TX; /* XXX reset TX FIFO */
@ -468,7 +468,7 @@ zzzz:
smc->b0.bsr = BSR_BANK0;
smc->b0.tcr |= TCR_TXENA;
smc->b2.bsr = BSR_BANK2;
ifp->if_oerrors++;
if_statinc(ifp, if_oerrors);
sc->sc_intctl |= MSK_TX_EMPTY | MSK_TX;
} else {
/*
@ -509,7 +509,7 @@ zzzz:
}
}
if (intact & IST_EPHINT) {
ifp->if_oerrors++;
if_statinc(ifp, if_oerrors);
esreset(sc);
}
/* output packets */
@ -601,7 +601,7 @@ esrint(struct es_softc *sc)
smc->b2.mmucr = MMUCR_REMRLS_RX;
while (smc->b2.mmucr & MMUCR_BUSY)
;
++ifp->if_ierrors;
if_statinc(ifp, if_ierrors);
#ifdef ESDEBUG
if (--sc->sc_smcbusy) {
printf("%s: esrintr busy on bad packet exit\n",
@ -922,7 +922,8 @@ esstart(struct ifnet *ifp)
device_xname(sc->sc_dev), active_pnr, smc->b2.pnr);
bpf_mtap(&sc->sc_ethercom.ec_if, m0, BPF_D_OUT);
m_freem(m0);
sc->sc_ethercom.ec_if.if_opackets++; /* move to interrupt? */
/* move to interrupt? */
if_statinc(&sc->sc_ethercom.ec_if, if_opackets);
sc->sc_intctl |= MSK_TX_EMPTY | MSK_TX;
sc->sc_ethercom.ec_if.if_timer = 5;
}
@ -1048,7 +1049,7 @@ eswatchdog(struct ifnet *ifp)
struct es_softc *sc = ifp->if_softc;
log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
++ifp->if_oerrors;
if_statinc(ifp, if_oerrors);
esreset(sc);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_qn.c,v 1.48 2019/11/12 13:17:43 msaitoh Exp $ */
/* $NetBSD: if_qn.c,v 1.49 2020/01/29 05:23:16 thorpej Exp $ */
/*
* Copyright (c) 1995 Mika Kortelainen
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.48 2019/11/12 13:17:43 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.49 2020/01/29 05:23:16 thorpej Exp $");
#include "qn.h"
#if NQN > 0
@ -305,7 +305,7 @@ qnwatchdog(struct ifnet *ifp)
struct qn_softc *sc = ifp->if_softc;
log(LOG_INFO, "qn: device timeout (watchdog)\n");
++sc->sc_ethercom.ec_if.if_oerrors;
if_statinc(ifp, if_oerrors);
qnreset(sc);
}
@ -613,19 +613,19 @@ qn_rint(struct qn_softc *sc, u_short rstat)
#ifdef QN_DEBUG
log(LOG_INFO, "Overflow\n");
#endif
++sc->sc_ethercom.ec_if.if_ierrors;
if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
}
if (rstat & R_INT_CRC_ERR) {
#ifdef QN_DEBUG
log(LOG_INFO, "CRC Error\n");
#endif
++sc->sc_ethercom.ec_if.if_ierrors;
if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
}
if (rstat & R_INT_ALG_ERR) {
#ifdef QN_DEBUG
log(LOG_INFO, "Alignment error\n");
#endif
++sc->sc_ethercom.ec_if.if_ierrors;
if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
}
if (rstat & R_INT_SRT_PKT) {
/* Short packet (these may occur and are
@ -635,13 +635,13 @@ qn_rint(struct qn_softc *sc, u_short rstat)
#ifdef QN_DEBUG
log(LOG_INFO, "Short packet\n");
#endif
++sc->sc_ethercom.ec_if.if_ierrors;
if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
}
if (rstat & 0x4040) {
#ifdef QN_DEBUG
log(LOG_INFO, "Bus read error\n");
#endif
++sc->sc_ethercom.ec_if.if_ierrors;
if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
qnreset(sc);
}
@ -677,7 +677,7 @@ qn_rint(struct qn_softc *sc, u_short rstat)
"%s: received a %s packet? (%u bytes)\n",
device_xname(sc->sc_dev),
len < ETHER_HDR_LEN ? "partial" : "big", len);
++sc->sc_ethercom.ec_if.if_ierrors;
if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
continue;
}
#endif
@ -742,7 +742,7 @@ qnintr(void *arg)
* Update total number of successfully
* transmitted packets.
*/
sc->sc_ethercom.ec_if.if_opackets++;
if_statinc(&sc->sc_ethercom.ec_if, if_opackets);
}
if (tint & T_SIXTEEN_COL) {
@ -753,8 +753,8 @@ qnintr(void *arg)
#ifdef QN_DEBUG1
qn_dump(sc);
#endif
sc->sc_ethercom.ec_if.if_oerrors++;
sc->sc_ethercom.ec_if.if_collisions += 16;
if_statadd2(&sc->sc_ethercom.ec_if,
if_oerrors, 1, if_collisions, 16);
sc->transmit_pending = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_mc.c,v 1.52 2019/12/27 09:32:09 msaitoh Exp $ */
/* $NetBSD: if_mc.c,v 1.53 2020/01/29 05:25:41 thorpej Exp $ */
/*-
* Copyright (c) 1997 David Huang <khym@azeotrope.org>
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.52 2019/12/27 09:32:09 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.53 2020/01/29 05:25:41 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@ -266,7 +266,7 @@ mcstart(struct ifnet *ifp)
ifp->if_flags |= IFF_OACTIVE;
maceput(sc, m);
ifp->if_opackets++; /* # of pkts */
if_statinc(ifp, if_opackets); /* # of pkts */
}
}
@ -434,21 +434,21 @@ struct mc_softc *sc = arg;
#ifdef MCDEBUG
printf("%s: jabber error\n", device_xname(sc->sc_dev));
#endif
sc->sc_if.if_oerrors++;
if_statinc(&sc->sc_if, if_oerrors);
}
if (ir & BABL) {
#ifdef MCDEBUG
printf("%s: babble\n", device_xname(sc->sc_dev));
#endif
sc->sc_if.if_oerrors++;
if_statinc(&sc->sc_if, if_oerrors);
}
if (ir & CERR) {
#ifdef MCDEBUG
printf("%s: collision error\n", device_xname(sc->sc_dev));
#endif
sc->sc_if.if_collisions++;
if_statinc(&sc->sc_if, if_collisions);
}
/*
@ -481,29 +481,33 @@ mc_tint(struct mc_softc *sc)
return;
}
net_stat_ref_t nsr = IF_STAT_GETREF(&sc->sc_if);
if (xmtfs & LCOL) {
printf("%s: late collision\n", device_xname(sc->sc_dev));
sc->sc_if.if_oerrors++;
sc->sc_if.if_collisions++;
if_statinc_ref(nsr, if_oerrors);
if_statinc_ref(nsr, if_collisions);
}
if (xmtfs & MORE)
/* Real number is unknown. */
sc->sc_if.if_collisions += 2;
if_statadd_ref(nsr, if_collsions, 2);
else if (xmtfs & ONE)
sc->sc_if.if_collisions++;
if_statinc_ref(nsr, if_collisions);
else if (xmtfs & RTRY) {
printf("%s: excessive collisions\n", device_xname(sc->sc_dev));
sc->sc_if.if_collisions += 16;
sc->sc_if.if_oerrors++;
if_statadd_ref(nsr, if_collsions, 16);
if_statinc_ref(nsr, if_oerrors);
}
if (xmtfs & LCAR) {
sc->sc_havecarrier = 0;
printf("%s: lost carrier\n", device_xname(sc->sc_dev));
sc->sc_if.if_oerrors++;
if_statinc_ref(nsr, if_oerrors);
}
IF_STAT_PUTREF(&sc->sc_if);
sc->sc_if.if_flags &= ~IFF_OACTIVE;
sc->sc_if.if_timer = 0;
if_schedule_deferred_start(&sc->sc_if);
@ -526,18 +530,18 @@ mc_rint(struct mc_softc *sc)
if (rxf.rx_rcvsts & OFLO) {
printf("%s: receive FIFO overflow\n", device_xname(sc->sc_dev));
sc->sc_if.if_ierrors++;
if_statinc(&sc->sc_if, if_ierrors);
return;
}
if (rxf.rx_rcvsts & CLSN)
sc->sc_if.if_collisions++;
if_statinc(&sc->sc_if, if_collisions);
if (rxf.rx_rcvsts & FRAM) {
#ifdef MCDEBUG
printf("%s: framing error\n", device_xname(sc->sc_dev));
#endif
sc->sc_if.if_ierrors++;
if_statinc(&sc->sc_if, if_ierrors);
return;
}
@ -545,7 +549,7 @@ mc_rint(struct mc_softc *sc)
#ifdef MCDEBUG
printf("%s: frame control checksum error\n", device_xname(sc->sc_dev));
#endif
sc->sc_if.if_ierrors++;
if_statinc(&sc->sc_if, if_ierrors);
return;
}
@ -565,13 +569,13 @@ mace_read(struct mc_softc *sc, void *pkt, int len)
printf("%s: invalid packet size %d; dropping\n",
device_xname(sc->sc_dev), len);
#endif
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
return;
}
m = mace_get(sc, pkt, len);
if (m == NULL) {
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_netdock_nubus.c,v 1.31 2019/10/21 08:22:06 msaitoh Exp $ */
/* $NetBSD: if_netdock_nubus.c,v 1.32 2020/01/29 05:25:42 thorpej Exp $ */
/*
* Copyright (C) 2000,2002 Daishi Kato <daishi@axlight.com>
@ -43,7 +43,7 @@
/***********************/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.31 2019/10/21 08:22:06 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.32 2020/01/29 05:25:42 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -458,7 +458,7 @@ netdock_start(struct ifnet *ifp)
return;
}
ifp->if_opackets++;
if_statinc(ifp, if_opackets);
}
}
@ -726,9 +726,9 @@ netdock_rxint(struct netdock_softc *sc)
if ((regdata1 & 0x00ac) == 0) {
if (netdock_read(sc, len) == 0)
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
} else {
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
if (regdata1 & REG_DATA_BIT_02)
NIC_GET_4(sc, REG_EFD00);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_input.c,v 1.115 2018/12/22 13:11:37 maxv Exp $ */
/* $NetBSD: ieee80211_input.c,v 1.116 2020/01/29 05:21:14 thorpej Exp $ */
/*
* Copyright (c) 2001 Atsushi Onoe
@ -37,7 +37,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.81 2005/08/10 16:22:29 sam Exp $");
#endif
#ifdef __NetBSD__
__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.115 2018/12/22 13:11:37 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.116 2020/01/29 05:21:14 thorpej Exp $");
#endif
#ifdef _KERNEL_OPT
@ -361,7 +361,7 @@ ieee80211_input_data(struct ieee80211com *ic, struct mbuf **mp,
}
}
ifp->if_ipackets++;
if_statinc(ifp, if_ipackets);
IEEE80211_NODE_STAT(ni, rx_data);
IEEE80211_NODE_STAT_ADD(ni, rx_bytes, m->m_pkthdr.len);
@ -371,7 +371,7 @@ ieee80211_input_data(struct ieee80211com *ic, struct mbuf **mp,
return 0;
err:
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
out:
*mp = m;
return -1;
@ -460,7 +460,7 @@ ieee80211_input_management(struct ieee80211com *ic, struct mbuf **mp,
return 0;
err:
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
out:
*mp = m;
return -1;
@ -742,7 +742,7 @@ ieee80211_input(struct ieee80211com *ic, struct mbuf *m,
}
err:
ifp->if_ierrors++;
if_statinc(ifp, if_ierrors);
out:
if (m != NULL) {
@ -868,7 +868,7 @@ ieee80211_deliver_data(struct ieee80211com *ic,
if (ETHER_IS_MULTICAST(eh->ether_dhost)) {
m1 = m_copypacket(m, M_DONTWAIT);
if (m1 == NULL)
ifp->if_oerrors++;
if_statinc(ifp, if_oerrors);
else
m1->m_flags |= M_MCAST;
} else {
@ -907,11 +907,11 @@ ieee80211_deliver_data(struct ieee80211com *ic,
len = m1->m_pkthdr.len;
IFQ_ENQUEUE(&ifp->if_snd, m1, error);
if (error) {
ifp->if_oerrors++;
if_statinc(ifp, if_oerrors);
m_freem(m);
m = NULL;
}
ifp->if_obytes += len;
if_statadd(ifp, if_obytes, len);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: can.c,v 1.8 2019/08/19 03:24:38 ozaki-r Exp $ */
/* $NetBSD: can.c,v 1.9 2020/01/29 05:20:26 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.8 2019/08/19 03:24:38 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.9 2020/01/29 05:20:26 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -249,7 +249,7 @@ can_output(struct mbuf *m, struct canpcb *canp)
sotag = m_tag_get(PACKET_TAG_SO, sizeof(struct socket *), PR_NOWAIT);
if (sotag == NULL) {
ifp->if_oerrors++;
if_statinc(ifp, if_oerrors);
return ENOMEM;
}
mutex_enter(&canp->canp_mtx);
@ -307,8 +307,7 @@ can_input(struct ifnet *ifp, struct mbuf *m)
} else {
IF_ENQUEUE(inq, m);
IFQ_UNLOCK(inq);
ifp->if_ipackets++;
ifp->if_ibytes += m->m_pkthdr.len;
if_statadd2(ifp, if_ipackets, 1, if_ibytes, m->m_pkthdr.len);
schednetisr(NETISR_CAN);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_canloop.c,v 1.8 2019/04/27 08:49:19 pgoyette Exp $ */
/* $NetBSD: if_canloop.c,v 1.9 2020/01/29 05:20:26 thorpej Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_canloop.c,v 1.8 2019/04/27 08:49:19 pgoyette Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_canloop.c,v 1.9 2020/01/29 05:20:26 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_can.h"
@ -170,8 +170,7 @@ canloop_ifstart(struct ifnet *ifp)
can_bpf_mtap(ifp, m, 0);
pktlen = m->m_pkthdr.len;
ifp->if_opackets++;
ifp->if_obytes += pktlen;
if_statadd2(ifp, if_opackets, 1, if_obytes, pktlen);
#ifdef CAN
can_mbuf_tag_clean(m);