Module Name: src
Committed By: thorpej
Date: Thu Jan 30 13:59:25 UTC 2020
Modified Files:
src/sys/dev/pci: if_age.c if_alc.c if_ale.c
Log Message:
Adopt <net/if_stats.h>.
To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pci/if_age.c
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pci/if_alc.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/pci/if_ale.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/if_age.c
diff -u src/sys/dev/pci/if_age.c:1.65 src/sys/dev/pci/if_age.c:1.66
--- src/sys/dev/pci/if_age.c:1.65 Sun Dec 1 08:16:49 2019
+++ src/sys/dev/pci/if_age.c Thu Jan 30 13:59:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_age.c,v 1.65 2019/12/01 08:16:49 msaitoh Exp $ */
+/* $NetBSD: if_age.c,v 1.66 2020/01/30 13:59:24 thorpej Exp $ */
/* $OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $ */
/*-
@@ -31,7 +31,7 @@
/* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.65 2019/12/01 08:16:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.66 2020/01/30 13:59:24 thorpej Exp $");
#include "vlan.h"
@@ -1079,7 +1079,7 @@ age_watchdog(struct ifnet *ifp)
if ((sc->age_flags & AGE_FLAG_LINK) == 0) {
printf("%s: watchdog timeout (missed link)\n",
device_xname(sc->sc_dev));
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
age_init(ifp);
return;
}
@@ -1092,7 +1092,7 @@ age_watchdog(struct ifnet *ifp)
}
printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
age_init(ifp);
age_start(ifp);
}
@@ -1411,7 +1411,7 @@ age_rxeof(struct age_softc *sc, struct r
desc = rxd->rx_desc;
/* Add a new receive buffer to the ring. */
if (age_newbuf(sc, rxd, 0) != 0) {
- ifp->if_iqdrops++;
+ if_statinc(ifp, if_iqdrops);
/* Reuse Rx buffers. */
if (sc->age_cdata.age_rxhead != NULL) {
m_freem(sc->age_cdata.age_rxhead);
@@ -2033,20 +2033,27 @@ 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;
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
- ifp->if_collisions += smb->tx_single_colls +
+ if_statadd_ref(nsr, if_opackets, smb->tx_frames);
+
+ if_statadd_ref(nsr, if_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 +
+ if_statadd_ref(nsr, if_oerrors,
+ smb->tx_excess_colls +
smb->tx_late_colls + smb->tx_underrun +
- smb->tx_pkts_truncated;
+ smb->tx_pkts_truncated);
- ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+ if_statadd_ref(nsr, if_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);
+
+ IF_STAT_PUTREF(ifp);
/* Update done, clear. */
smb->updated = 0;
Index: src/sys/dev/pci/if_alc.c
diff -u src/sys/dev/pci/if_alc.c:1.46 src/sys/dev/pci/if_alc.c:1.47
--- src/sys/dev/pci/if_alc.c:1.46 Wed Dec 18 13:25:00 2019
+++ src/sys/dev/pci/if_alc.c Thu Jan 30 13:59:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_alc.c,v 1.46 2019/12/18 13:25:00 msaitoh Exp $ */
+/* $NetBSD: if_alc.c,v 1.47 2020/01/30 13:59:24 thorpej Exp $ */
/* $OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $ */
/*-
* Copyright (c) 2009, Pyun YongHyeon <[email protected]>
@@ -2059,13 +2059,13 @@ alc_watchdog(struct ifnet *ifp)
if ((sc->alc_flags & ALC_FLAG_LINK) == 0) {
printf("%s: watchdog timeout (missed link)\n",
device_xname(sc->sc_dev));
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
alc_init_backend(ifp, false);
return;
}
printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
alc_init_backend(ifp, false);
alc_start(ifp);
}
@@ -2267,19 +2267,26 @@ 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;
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
- ifp->if_collisions += smb->tx_single_colls +
+ if_statadd_ref(nsr, if_opackets, smb->tx_frames);
+
+ if_statadd_ref(nsr, if_collisions,
+ smb->tx_single_colls +
smb->tx_multi_colls * 2 + 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_late_colls + smb->tx_excess_colls +
- smb->tx_underrun + smb->tx_pkts_truncated;
+ if_statadd_ref(nsr, if_oerrors,
+ smb->tx_late_colls + smb->tx_excess_colls +
+ smb->tx_underrun + smb->tx_pkts_truncated);
- ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+ if_statadd_ref(nsr, if_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_STAT_PUTREF(ifp);
if ((sc->alc_flags & ALC_FLAG_SMB_BUG) == 0) {
/* Update done, clear. */
@@ -2551,7 +2558,7 @@ alc_rxeof(struct alc_softc *sc, struct r
mp = rxd->rx_m;
/* Add a new receive buffer to the ring. */
if (alc_newbuf(sc, rxd, false) != 0) {
- ifp->if_iqdrops++;
+ if_statinc(ifp, if_iqdrops);
/* Reuse Rx buffers. */
if (sc->alc_cdata.alc_rxhead != NULL)
m_freem(sc->alc_cdata.alc_rxhead);
Index: src/sys/dev/pci/if_ale.c
diff -u src/sys/dev/pci/if_ale.c:1.37 src/sys/dev/pci/if_ale.c:1.38
--- src/sys/dev/pci/if_ale.c:1.37 Sun Dec 1 08:16:49 2019
+++ src/sys/dev/pci/if_ale.c Thu Jan 30 13:59:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ale.c,v 1.37 2019/12/01 08:16:49 msaitoh Exp $ */
+/* $NetBSD: if_ale.c,v 1.38 2020/01/30 13:59:24 thorpej Exp $ */
/*-
* Copyright (c) 2008, Pyun YongHyeon <[email protected]>
@@ -32,7 +32,7 @@
/* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.37 2019/12/01 08:16:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.38 2020/01/30 13:59:24 thorpej Exp $");
#include "vlan.h"
@@ -1098,13 +1098,13 @@ ale_watchdog(struct ifnet *ifp)
if ((sc->ale_flags & ALE_FLAG_LINK) == 0) {
printf("%s: watchdog timeout (missed link)\n",
device_xname(sc->sc_dev));
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
ale_init(ifp);
return;
}
printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
ale_init(ifp);
if (!IFQ_IS_EMPTY(&ifp->if_snd))
@@ -1257,11 +1257,14 @@ 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;
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
- ifp->if_collisions += smb->tx_single_colls +
+ if_statadd_ref(nsr, if_opackets, smb->tx_frames);
+
+ if_statadd_ref(nsr, if_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
@@ -1270,13 +1273,17 @@ 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;
+ if_statadd_ref(nsr, if_oerrors,
+ smb->tx_abort + smb->tx_late_colls +
+ smb->tx_underrun);
- ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+ if_statadd_ref(nsr, if_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_STAT_PUTREF(ifp);
}
static int
@@ -1532,7 +1539,7 @@ ale_rxeof(struct ale_softc *sc)
m = m_devget((char *)(rs + 1), length - ETHER_CRC_LEN,
0, ifp);
if (m == NULL) {
- ifp->if_iqdrops++;
+ if_statinc(ifp, if_iqdrops);
ale_rx_update_page(sc, &rx_page, length, &prod);
continue;
}