Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Adopt <net/if_stats.h>.
details: https://anonhg.NetBSD.org/src/rev/a240a40bdfb7
branches: trunk
changeset: 744425:a240a40bdfb7
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Feb 01 12:45:05 2020 +0000
description:
Adopt <net/if_stats.h>.
diffstat:
sys/dev/pci/if_ixl.c | 82 ++++++++++++---------------------------------------
1 files changed, 20 insertions(+), 62 deletions(-)
diffs (172 lines):
diff -r f78c6cf7b678 -r a240a40bdfb7 sys/dev/pci/if_ixl.c
--- a/sys/dev/pci/if_ixl.c Sat Feb 01 09:21:49 2020 +0000
+++ b/sys/dev/pci/if_ixl.c Sat Feb 01 12:45:05 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ixl.c,v 1.34 2020/01/31 03:30:37 yamaguchi Exp $ */
+/* $NetBSD: if_ixl.c,v 1.35 2020/02/01 12:45:05 thorpej Exp $ */
/*
* Copyright (c) 2013-2015, Intel Corporation
@@ -434,11 +434,6 @@
pcq_t *txr_intrq;
void *txr_si;
- uint64_t txr_oerrors; /* if_oerrors */
- uint64_t txr_opackets; /* if_opackets */
- uint64_t txr_obytes; /* if_obytes */
- uint64_t txr_omcasts; /* if_omcasts */
-
struct evcnt txr_defragged;
struct evcnt txr_defrag_failed;
struct evcnt txr_pcqdrop;
@@ -467,11 +462,6 @@
bus_size_t rxr_tail;
unsigned int rxr_qid;
- uint64_t rxr_ipackets; /* if_ipackets */
- uint64_t rxr_ibytes; /* if_ibytes */
- uint64_t rxr_iqdrops; /* iqdrops */
- uint64_t rxr_ierrors; /* if_ierrors */
-
struct evcnt rxr_mgethdr_failed;
struct evcnt rxr_mgetcl_failed;
struct evcnt rxr_mbuf_load_failed;
@@ -1842,12 +1832,10 @@
{
struct ifreq *ifr = (struct ifreq *)data;
struct ixl_softc *sc = (struct ixl_softc *)ifp->if_softc;
- struct ixl_tx_ring *txr;
- struct ixl_rx_ring *rxr;
const struct sockaddr *sa;
uint8_t addrhi[ETHER_ADDR_LEN], addrlo[ETHER_ADDR_LEN];
int s, error = 0;
- unsigned int i, nmtu;
+ unsigned int nmtu;
switch (cmd) {
case SIOCSIFMTU:
@@ -1891,45 +1879,6 @@
}
break;
- case SIOCGIFDATA:
- case SIOCZIFDATA:
- ifp->if_ipackets = 0;
- ifp->if_ibytes = 0;
- ifp->if_iqdrops = 0;
- ifp->if_ierrors = 0;
- ifp->if_opackets = 0;
- ifp->if_obytes = 0;
- ifp->if_omcasts = 0;
-
- for (i = 0; i < sc->sc_nqueue_pairs_max; i++) {
- txr = sc->sc_qps[i].qp_txr;
- rxr = sc->sc_qps[i].qp_rxr;
-
- mutex_enter(&rxr->rxr_lock);
- ifp->if_ipackets += rxr->rxr_ipackets;
- ifp->if_ibytes += rxr->rxr_ibytes;
- ifp->if_iqdrops += rxr->rxr_iqdrops;
- ifp->if_ierrors += rxr->rxr_ierrors;
- if (cmd == SIOCZIFDATA) {
- rxr->rxr_ipackets = 0;
- rxr->rxr_ibytes = 0;
- rxr->rxr_iqdrops = 0;
- rxr->rxr_ierrors = 0;
- }
- mutex_exit(&rxr->rxr_lock);
-
- mutex_enter(&txr->txr_lock);
- ifp->if_opackets += txr->txr_opackets;
- ifp->if_obytes += txr->txr_obytes;
- ifp->if_omcasts += txr->txr_omcasts;
- if (cmd == SIOCZIFDATA) {
- txr->txr_opackets = 0;
- txr->txr_obytes = 0;
- txr->txr_omcasts = 0;
- }
- mutex_exit(&txr->txr_lock);
- }
- /* FALLTHROUGH */
default:
s = splnet();
error = ether_ioctl(ifp, cmd, data);
@@ -2787,7 +2736,7 @@
map = txm->txm_map;
if (ixl_load_mbuf(sc->sc_dmat, map, &m, txr) != 0) {
- txr->txr_oerrors++;
+ if_statinc(ifp, if_oerrors);
m_freem(m);
continue;
}
@@ -2870,6 +2819,8 @@
ring = IXL_DMA_KVA(&txr->txr_mem);
mask = sc->sc_tx_ring_ndescs - 1;
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
do {
if (txlimit-- <= 0) {
more = 1;
@@ -2892,10 +2843,10 @@
m = txm->txm_m;
if (m != NULL) {
- txr->txr_opackets++;
- txr->txr_obytes += m->m_pkthdr.len;
+ if_statinc_ref(nsr, if_opackets);
+ if_statadd_ref(nsr, if_obytes, m->m_pkthdr.len);
if (ISSET(m->m_flags, M_MCAST))
- txr->txr_omcasts++;
+ if_statinc_ref(nsr, if_omcasts);
m_freem(m);
}
@@ -2907,6 +2858,8 @@
done = 1;
} while (cons != prod);
+ IF_STAT_PUTREF(ifp);
+
bus_dmamap_sync(sc->sc_dmat, IXL_DMA_MAP(&txr->txr_mem),
0, IXL_DMA_LEN(&txr->txr_mem), BUS_DMASYNC_PREREAD);
@@ -3260,6 +3213,8 @@
ring = IXL_DMA_KVA(&rxr->rxr_mem);
mask = sc->sc_rx_ring_ndescs - 1;
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
do {
if (rxlimit-- <= 0) {
more = 1;
@@ -3310,11 +3265,12 @@
if (!ISSET(word,
IXL_RX_DESC_RXE | IXL_RX_DESC_OVERSIZE)) {
m_set_rcvif(m, ifp);
- rxr->rxr_ipackets++;
- rxr->rxr_ibytes += m->m_pkthdr.len;
+ if_statinc_ref(nsr, if_ipackets);
+ if_statadd_ref(nsr, if_ibytes,
+ m->m_pkthdr.len);
if_percpuq_enqueue(ifp->if_percpuq, m);
} else {
- rxr->rxr_ierrors++;
+ if_statinc_ref(nsr, if_ierrors);
m_freem(m);
}
@@ -3331,8 +3287,10 @@
if (done) {
rxr->rxr_cons = cons;
if (ixl_rxfill(sc, rxr) == -1)
- rxr->rxr_iqdrops++;
- }
+ if_statinc_ref(nsr, if_iqdrops);
+ }
+
+ IF_STAT_PUTREF(ifp);
bus_dmamap_sync(sc->sc_dmat, IXL_DMA_MAP(&rxr->rxr_mem),
0, IXL_DMA_LEN(&rxr->rxr_mem),
Home |
Main Index |
Thread Index |
Old Index