summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2014-09-18 15:56:14 +0000
committerglebius <glebius@FreeBSD.org>2014-09-18 15:56:14 +0000
commit39fefafe214033dc06483dd023c2485e05ad321c (patch)
tree7a00e00af29505116ade54217ea22b40ed752459
parent7288f5d2fcfc7e772a285573fa4a96957b72f3e5 (diff)
downloadFreeBSD-src-39fefafe214033dc06483dd023c2485e05ad321c.zip
FreeBSD-src-39fefafe214033dc06483dd023c2485e05ad321c.tar.gz
- Use if_inc_counter() to increment various counters.
- Do not ever set a counter to a value. For those counters that we don't increment, but return directly from hardware create cases in if_get_counter() method. Sponsored by: Netflix Sponsored by: Nginx, Inc.
-rw-r--r--sys/dev/bge/if_bge.c48
-rw-r--r--sys/dev/bxe/bxe.c5
-rw-r--r--sys/dev/bxe/bxe_stats.c100
-rw-r--r--sys/dev/bxe/bxe_stats.h1
-rw-r--r--sys/dev/e1000/if_em.c43
-rw-r--r--sys/dev/e1000/if_lem.c41
-rw-r--r--sys/dev/fxp/if_fxp.c17
-rw-r--r--sys/dev/nfe/if_nfe.c30
8 files changed, 162 insertions, 123 deletions
diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 384c8f4..374a419 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -434,6 +434,7 @@ static int bge_shutdown(device_t);
static int bge_ifmedia_upd_locked(if_t);
static int bge_ifmedia_upd(if_t);
static void bge_ifmedia_sts(if_t, struct ifmediareq *);
+static uint64_t bge_get_counter(if_t, ift_counter);
static uint8_t bge_nvram_getbyte(struct bge_softc *, int, uint8_t *);
static int bge_read_nvram(struct bge_softc *, caddr_t, int, int);
@@ -3738,6 +3739,7 @@ bge_attach(device_t dev)
if_setioctlfn(ifp, bge_ioctl);
if_setstartfn(ifp, bge_start);
if_setinitfn(ifp, bge_init);
+ if_setgetcounterfn(ifp, bge_get_counter);
if_setsendqlen(ifp, BGE_TX_RING_CNT - 1);
if_setsendqready(ifp);
if_sethwassist(ifp, sc->bge_csum_features);
@@ -4364,7 +4366,7 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int holdlck)
}
if (bge_newbuf_jumbo(sc, rxidx) != 0) {
bge_rxreuse_jumbo(sc, rxidx);
- if_inciqdrops(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
continue;
}
BGE_INC(sc->bge_jumbo, BGE_JUMBO_RX_RING_CNT);
@@ -4377,13 +4379,13 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int holdlck)
}
if (bge_newbuf_std(sc, rxidx) != 0) {
bge_rxreuse_std(sc, rxidx);
- if_inciqdrops(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
continue;
}
BGE_INC(sc->bge_std, BGE_STD_RX_RING_CNT);
}
- if_incipackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
#ifndef __NO_STRICT_ALIGNMENT
/*
* For architectures with strict alignment we must make sure
@@ -4512,7 +4514,7 @@ bge_txeof(struct bge_softc *sc, uint16_t tx_cons)
idx = sc->bge_tx_saved_considx;
cur_tx = &sc->bge_ldata.bge_tx_ring[idx];
if (cur_tx->bge_flags & BGE_TXBDFLAG_END)
- if_incopackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
if (sc->bge_cdata.bge_tx_chain[idx] != NULL) {
bus_dmamap_sync(sc->bge_cdata.bge_tx_mtag,
sc->bge_cdata.bge_tx_dmamap[idx],
@@ -4917,10 +4919,6 @@ bge_stats_update_regs(struct bge_softc *sc)
stats->RecvThresholdHit +=
CSR_READ_4(sc, BGE_RXLP_LOCSTAT_RXTHRESH_HIT);
- if_setcollisions(ifp, (u_long)stats->etherStatsCollisions);
- if_setierrors(ifp, (u_long)(stats->NoMoreRxBDs + stats->InputDiscards +
- stats->InputErrors));
-
if (sc->bge_flags & BGE_FLAG_RDMA_BUG) {
/*
* If controller transmitted more than BGE_NUM_RDMA_CHANNELS
@@ -4997,21 +4995,21 @@ bge_stats_update(struct bge_softc *sc)
CSR_READ_4(sc, stats + offsetof(struct bge_stats, stat))
cnt = READ_STAT(sc, stats, txstats.etherStatsCollisions.bge_addr_lo);
- if_inccollisions(ifp, (uint32_t)(cnt - sc->bge_tx_collisions));
+ if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cnt - sc->bge_tx_collisions);
sc->bge_tx_collisions = cnt;
cnt = READ_STAT(sc, stats, nicNoMoreRxBDs.bge_addr_lo);
- if_incierrors(ifp, (uint32_t)(cnt - sc->bge_rx_nobds));
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, cnt - sc->bge_rx_nobds);
sc->bge_rx_nobds = cnt;
cnt = READ_STAT(sc, stats, ifInErrors.bge_addr_lo);
- if_incierrors(ifp, (uint32_t)(cnt - sc->bge_rx_inerrs));
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, cnt - sc->bge_rx_inerrs);
sc->bge_rx_inerrs = cnt;
cnt = READ_STAT(sc, stats, ifInDiscards.bge_addr_lo);
- if_incierrors(ifp, (uint32_t)(cnt - sc->bge_rx_discards));
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, cnt - sc->bge_rx_discards);
sc->bge_rx_discards = cnt;
cnt = READ_STAT(sc, stats, txstats.ifOutDiscards.bge_addr_lo);
- if_incoerrors(ifp, (uint32_t)(cnt - sc->bge_tx_discards));
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, cnt - sc->bge_tx_discards);
sc->bge_tx_discards = cnt;
#undef READ_STAT
@@ -5950,7 +5948,7 @@ bge_watchdog(struct bge_softc *sc)
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
bge_init_locked(sc);
- if_incoerrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
}
static void
@@ -6770,3 +6768,25 @@ bge_get_eaddr(struct bge_softc *sc, uint8_t eaddr[])
}
return (*func == NULL ? ENXIO : 0);
}
+
+static uint64_t
+bge_get_counter(if_t ifp, ift_counter cnt)
+{
+ struct bge_softc *sc;
+ struct bge_mac_stats *stats;
+
+ sc = if_getsoftc(ifp);
+ if (!BGE_IS_5705_PLUS(sc))
+ return (if_get_counter_default(ifp, cnt));
+ stats = &sc->bge_mac_stats;
+
+ switch (cnt) {
+ case IFCOUNTER_IERRORS:
+ return (stats->NoMoreRxBDs + stats->InputDiscards +
+ stats->InputErrors);
+ case IFCOUNTER_COLLISIONS:
+ return (stats->etherStatsCollisions);
+ default:
+ return (if_get_counter_default(ifp, cnt));
+ }
+}
diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c
index 50106bf..ac20d78 100644
--- a/sys/dev/bxe/bxe.c
+++ b/sys/dev/bxe/bxe.c
@@ -3222,7 +3222,7 @@ bxe_tpa_stop(struct bxe_softc *sc,
m->m_flags |= M_FLOWID;
#endif
- if_incipackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
fp->eth_q_stats.rx_tpa_pkts++;
/* pass the frame to the stack */
@@ -3465,7 +3465,7 @@ next_rx:
/* pass the frame to the stack */
if (__predict_true(m != NULL)) {
- if_incipackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
rx_pkts++;
if_input(ifp, m);
}
@@ -13279,6 +13279,7 @@ bxe_init_ifnet(struct bxe_softc *sc)
if_setflags(ifp, (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST));
if_setioctlfn(ifp, bxe_ioctl);
if_setstartfn(ifp, bxe_tx_start);
+ if_setgetcounterfn(ifp, bxe_get_counter);
#if __FreeBSD_version >= 800000
if_settransmitfn(ifp, bxe_tx_mq_start);
if_setqflushfn(ifp, bxe_mq_flush);
diff --git a/sys/dev/bxe/bxe_stats.c b/sys/dev/bxe/bxe_stats.c
index f6b2397..3d33fb7 100644
--- a/sys/dev/bxe/bxe_stats.c
+++ b/sys/dev/bxe/bxe_stats.c
@@ -1164,50 +1164,54 @@ bxe_storm_stats_update(struct bxe_softc *sc)
static void
bxe_net_stats_update(struct bxe_softc *sc)
{
- struct bxe_eth_stats *estats = &sc->eth_stats;
- if_t ifnet = sc->ifp;
- int i;
-
- if_setipackets(ifnet,
- bxe_hilo(&estats->total_unicast_packets_received_hi) +
- bxe_hilo(&estats->total_multicast_packets_received_hi) +
- bxe_hilo(&estats->total_broadcast_packets_received_hi));
-
- if_setopackets(ifnet,
- bxe_hilo(&estats->total_unicast_packets_transmitted_hi) +
- bxe_hilo(&estats->total_multicast_packets_transmitted_hi) +
- bxe_hilo(&estats->total_broadcast_packets_transmitted_hi));
-
- if_setibytes(ifnet, bxe_hilo(&estats->total_bytes_received_hi));
-
- if_setobytes(ifnet, bxe_hilo(&estats->total_bytes_transmitted_hi));
- for (i = 0; i < sc->num_queues; i++) {
- struct tstorm_per_queue_stats *old_tclient =
- &sc->fp[i].old_tclient;
- if_inciqdrops(ifnet, le32toh(old_tclient->checksum_discard));
- }
+ for (int i = 0; i < sc->num_queues; i++)
+ if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS,
+ le32toh(sc->fp[i].old_tclient.checksum_discard));
+}
- if_setierrors(ifnet,
- bxe_hilo(&estats->rx_stat_etherstatsundersizepkts_hi) +
- bxe_hilo(&estats->etherstatsoverrsizepkts_hi) +
- bxe_hilo(&estats->brb_drop_hi) +
- bxe_hilo(&estats->brb_truncate_hi) +
- bxe_hilo(&estats->rx_stat_dot3statsfcserrors_hi) +
- bxe_hilo(&estats->rx_stat_dot3statsalignmenterrors_hi) +
- bxe_hilo(&estats->no_buff_discard_hi));
-
- if_setoerrors(ifnet,
- bxe_hilo(&estats->rx_stat_dot3statscarriersenseerrors_hi) +
- bxe_hilo(&estats->tx_stat_dot3statsinternalmactransmiterrors_hi));
-
- if_setimcasts(ifnet,
- bxe_hilo(&estats->total_multicast_packets_received_hi));
-
- if_setcollisions(ifnet,
- bxe_hilo(&estats->tx_stat_etherstatscollisions_hi) +
- bxe_hilo(&estats->tx_stat_dot3statslatecollisions_hi) +
- bxe_hilo(&estats->tx_stat_dot3statsexcessivecollisions_hi));
+uint64_t
+bxe_get_counter(if_t ifp, ift_counter cnt)
+{
+ struct bxe_softc *sc;
+ struct bxe_eth_stats *estats;
+
+ sc = if_getsoftc(ifp);
+ estats = &sc->eth_stats;
+
+ switch (cnt) {
+ case IFCOUNTER_IPACKETS:
+ return (bxe_hilo(&estats->total_unicast_packets_received_hi) +
+ bxe_hilo(&estats->total_multicast_packets_received_hi) +
+ bxe_hilo(&estats->total_broadcast_packets_received_hi));
+ case IFCOUNTER_OPACKETS:
+ return (bxe_hilo(&estats->total_unicast_packets_transmitted_hi) +
+ bxe_hilo(&estats->total_multicast_packets_transmitted_hi) +
+ bxe_hilo(&estats->total_broadcast_packets_transmitted_hi));
+ case IFCOUNTER_IBYTES:
+ return (bxe_hilo(&estats->total_bytes_received_hi));
+ case IFCOUNTER_OBYTES:
+ return (bxe_hilo(&estats->total_bytes_transmitted_hi));
+ case IFCOUNTER_IERRORS:
+ return (bxe_hilo(&estats->rx_stat_etherstatsundersizepkts_hi) +
+ bxe_hilo(&estats->etherstatsoverrsizepkts_hi) +
+ bxe_hilo(&estats->brb_drop_hi) +
+ bxe_hilo(&estats->brb_truncate_hi) +
+ bxe_hilo(&estats->rx_stat_dot3statsfcserrors_hi) +
+ bxe_hilo(&estats->rx_stat_dot3statsalignmenterrors_hi) +
+ bxe_hilo(&estats->no_buff_discard_hi));
+ case IFCOUNTER_OERRORS:
+ return (bxe_hilo(&estats->rx_stat_dot3statscarriersenseerrors_hi) +
+ bxe_hilo(&estats->tx_stat_dot3statsinternalmactransmiterrors_hi));
+ case IFCOUNTER_IMCASTS:
+ return (bxe_hilo(&estats->total_multicast_packets_received_hi));
+ case IFCOUNTER_COLLISIONS:
+ return (bxe_hilo(&estats->tx_stat_etherstatscollisions_hi) +
+ bxe_hilo(&estats->tx_stat_dot3statslatecollisions_hi) +
+ bxe_hilo(&estats->tx_stat_dot3statsexcessivecollisions_hi));
+ default:
+ return (if_get_counter_default(ifp, cnt));
+ }
}
static void
@@ -1669,15 +1673,6 @@ bxe_stats_init(struct bxe_softc *sc)
/* prepare statistics ramrod data */
bxe_prep_fw_stats_req(sc);
- if_setipackets(sc->ifp, 0);
- if_setopackets(sc->ifp, 0);
- if_setibytes(sc->ifp, 0);
- if_setobytes(sc->ifp, 0);
- if_setierrors(sc->ifp, 0);
- if_setoerrors(sc->ifp, 0);
- if_setimcasts(sc->ifp, 0);
- if_setcollisions(sc->ifp, 0);
-
if (sc->stats_init) {
memset(&sc->net_stats_old, 0, sizeof(sc->net_stats_old));
memset(&sc->fw_stats_old, 0, sizeof(sc->fw_stats_old));
@@ -1731,9 +1726,6 @@ bxe_save_statistics(struct bxe_softc *sc)
UPDATE_QSTAT_OLD(total_tpa_bytes_lo);
}
- /* save net_device_stats statistics */
- sc->net_stats_old.rx_dropped = if_getiqdrops(sc->ifp);
-
/* store port firmware statistics */
if (sc->port.pmf) {
struct bxe_eth_stats *estats = &sc->eth_stats;
diff --git a/sys/dev/bxe/bxe_stats.h b/sys/dev/bxe/bxe_stats.h
index cb98201..ed37f55 100644
--- a/sys/dev/bxe/bxe_stats.h
+++ b/sys/dev/bxe/bxe_stats.h
@@ -675,6 +675,7 @@ void bxe_stats_init(struct bxe_softc *sc);
void bxe_stats_handle(struct bxe_softc *sc, enum bxe_stats_event event);
void bxe_save_statistics(struct bxe_softc *sc);
void bxe_afex_collect_stats(struct bxe_softc *sc, void *void_afex_stats, uint32_t stats_type);
+uint64_t bxe_get_counter(if_t, ift_counter);
#endif /* BXE_STATS_H */
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 99ecbf3..d8fc23e 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -215,6 +215,7 @@ static void em_start(if_t);
static void em_start_locked(if_t, struct tx_ring *);
#endif
static int em_ioctl(if_t, u_long, caddr_t);
+static uint64_t em_get_counter(if_t, ift_counter);
static void em_init(void *);
static void em_init_locked(struct adapter *);
static void em_stop(void *);
@@ -934,9 +935,9 @@ em_mq_start_locked(if_t ifp, struct tx_ring *txr, struct mbuf *m)
}
drbr_advance(ifp, txr->br);
enq++;
- if_incobytes(ifp, next->m_pkthdr.len);
+ if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len);
if (next->m_flags & M_MCAST)
- if_incomcasts(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
if_etherbpfmtap(ifp, next);
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
break;
@@ -2940,6 +2941,7 @@ em_setup_interface(device_t dev, struct adapter *adapter)
if_setsoftc(ifp, adapter);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setioctlfn(ifp, em_ioctl);
+ if_setgetcounterfn(ifp, em_get_counter);
#ifdef EM_MULTIQUEUE
/* Multiqueue stack interface */
if_settransmitfn(ifp, em_mq_start);
@@ -3850,7 +3852,7 @@ em_txeof(struct tx_ring *txr)
tx_buffer = &txr->tx_buffers[first];
tx_desc = &txr->tx_base[first];
}
- if_incopackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
/* See if we can continue to the next packet */
last = tx_buffer->next_eop;
if (last != -1) {
@@ -4450,7 +4452,7 @@ em_rxeof(struct rx_ring *rxr, int count, int *done)
--count;
sendmp = rxr->fmp;
if_setrcvif(sendmp, ifp);
- if_incipackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
em_receive_checksum(cur, sendmp);
#ifndef __NO_STRICT_ALIGNMENT
if (adapter->hw.mac.max_frame_size >
@@ -5107,7 +5109,6 @@ em_disable_aspm(struct adapter *adapter)
static void
em_update_stats_counters(struct adapter *adapter)
{
- if_t ifp;
if(adapter->hw.phy.media_type == e1000_media_type_copper ||
(E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) {
@@ -5199,19 +5200,29 @@ em_update_stats_counters(struct adapter *adapter)
adapter->stats.tsctfc +=
E1000_READ_REG(&adapter->hw, E1000_TSCTFC);
}
- ifp = adapter->ifp;
-
- if_setcollisions(ifp, adapter->stats.colc);
+}
- /* Rx Errors */
- if_setierrors(ifp, adapter->dropped_pkts + adapter->stats.rxerrc +
- adapter->stats.crcerrs + adapter->stats.algnerrc +
- adapter->stats.ruc + adapter->stats.roc +
- adapter->stats.mpc + adapter->stats.cexterr);
+static uint64_t
+em_get_counter(if_t ifp, ift_counter cnt)
+{
+ struct adapter *adapter;
- /* Tx Errors */
- if_setoerrors(ifp, adapter->stats.ecol + adapter->stats.latecol +
- adapter->watchdog_events);
+ adapter = if_getsoftc(ifp);
+
+ switch (cnt) {
+ case IFCOUNTER_COLLISIONS:
+ return (adapter->stats.colc);
+ case IFCOUNTER_IERRORS:
+ return (adapter->dropped_pkts + adapter->stats.rxerrc +
+ adapter->stats.crcerrs + adapter->stats.algnerrc +
+ adapter->stats.ruc + adapter->stats.roc +
+ adapter->stats.mpc + adapter->stats.cexterr);
+ case IFCOUNTER_OERRORS:
+ return (adapter->stats.ecol + adapter->stats.latecol +
+ adapter->watchdog_events);
+ default:
+ return (if_get_counter_default(ifp, cnt));
+ }
}
/* Export a single 32-bit register via a read-only sysctl. */
diff --git a/sys/dev/e1000/if_lem.c b/sys/dev/e1000/if_lem.c
index 8424870..3639318 100644
--- a/sys/dev/e1000/if_lem.c
+++ b/sys/dev/e1000/if_lem.c
@@ -180,6 +180,7 @@ static int lem_resume(device_t);
static void lem_start(if_t);
static void lem_start_locked(if_t ifp);
static int lem_ioctl(if_t, u_long, caddr_t);
+static uint64_t lem_get_counter(if_t, ift_counter);
static void lem_init(void *);
static void lem_init_locked(struct adapter *);
static void lem_stop(void *);
@@ -2464,6 +2465,7 @@ lem_setup_interface(device_t dev, struct adapter *adapter)
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setioctlfn(ifp, lem_ioctl);
if_setstartfn(ifp, lem_start);
+ if_setgetcounterfn(ifp, lem_get_counter);
if_setsendqlen(ifp, adapter->num_tx_desc - 1);
if_setsendqready(ifp);
@@ -3122,7 +3124,7 @@ lem_txeof(struct adapter *adapter)
++num_avail;
if (tx_buffer->m_head) {
- if_incopackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
bus_dmamap_sync(adapter->txtag,
tx_buffer->map,
BUS_DMASYNC_POSTWRITE);
@@ -3681,7 +3683,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
if (accept_frame) {
if (lem_get_buf(adapter, i) != 0) {
- if_inciqdrops(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
goto discard;
}
@@ -3712,7 +3714,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
if (eop) {
if_setrcvif(adapter->fmp, ifp);
- if_incipackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
lem_receive_checksum(adapter, current_desc,
adapter->fmp);
#ifndef __NO_STRICT_ALIGNMENT
@@ -4397,7 +4399,6 @@ lem_fill_descriptors (bus_addr_t address, u32 length,
static void
lem_update_stats_counters(struct adapter *adapter)
{
- if_t ifp;
if(adapter->hw.phy.media_type == e1000_media_type_copper ||
(E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) {
@@ -4472,19 +4473,29 @@ lem_update_stats_counters(struct adapter *adapter)
adapter->stats.tsctfc +=
E1000_READ_REG(&adapter->hw, E1000_TSCTFC);
}
- ifp = adapter->ifp;
-
- if_setcollisions(ifp, adapter->stats.colc);
+}
- /* Rx Errors */
- if_setierrors(ifp, adapter->dropped_pkts + adapter->stats.rxerrc +
- adapter->stats.crcerrs + adapter->stats.algnerrc +
- adapter->stats.ruc + adapter->stats.roc +
- adapter->stats.mpc + adapter->stats.cexterr);
+static uint64_t
+lem_get_counter(if_t ifp, ift_counter cnt)
+{
+ struct adapter *adapter;
- /* Tx Errors */
- if_setoerrors(ifp, adapter->stats.ecol + adapter->stats.latecol +
- adapter->watchdog_events);
+ adapter = if_getsoftc(ifp);
+
+ switch (cnt) {
+ case IFCOUNTER_COLLISIONS:
+ return (adapter->stats.colc);
+ case IFCOUNTER_IERRORS:
+ return (adapter->dropped_pkts + adapter->stats.rxerrc +
+ adapter->stats.crcerrs + adapter->stats.algnerrc +
+ adapter->stats.ruc + adapter->stats.roc +
+ adapter->stats.mpc + adapter->stats.cexterr);
+ case IFCOUNTER_OERRORS:
+ return (adapter->stats.ecol + adapter->stats.latecol +
+ adapter->watchdog_events);
+ default:
+ return (if_get_counter_default(ifp, cnt));
+ }
}
/* Export a single 32-bit register via a read-only sysctl. */
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c
index 4b288bc9..48bf8e9 100644
--- a/sys/dev/fxp/if_fxp.c
+++ b/sys/dev/fxp/if_fxp.c
@@ -2012,7 +2012,7 @@ fxp_intr_body(struct fxp_softc *sc, if_t ifp, uint8_t statack,
return (rx_npkts);
} else {
/* Reuse RFA and loaded DMA map. */
- if_inciqdrops(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
fxp_discard_rfabuf(sc, rxp);
}
fxp_add_rfabuf(sc, rxp);
@@ -2070,10 +2070,12 @@ fxp_update_stats(struct fxp_softc *sc)
hsp->tx_tco += le16toh(sp->tx_tco);
hsp->rx_tco += le16toh(sp->rx_tco);
- if_incopackets(ifp, le32toh(sp->tx_good));
- if_inccollisions(ifp, le32toh(sp->tx_total_collisions));
+ if_inc_counter(ifp, IFCOUNTER_OPACKETS, le32toh(sp->tx_good));
+ if_inc_counter(ifp, IFCOUNTER_COLLISIONS,
+ le32toh(sp->tx_total_collisions));
if (sp->rx_good) {
- if_incipackets(ifp, le32toh(sp->rx_good));
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS,
+ le32toh(sp->rx_good));
sc->rx_idle_secs = 0;
} else if (sc->flags & FXP_FLAG_RXBUG) {
/*
@@ -2081,7 +2083,7 @@ fxp_update_stats(struct fxp_softc *sc)
*/
sc->rx_idle_secs++;
}
- if_incierrors(ifp,
+ if_inc_counter(ifp, IFCOUNTER_IERRORS,
le32toh(sp->rx_crc_errors) +
le32toh(sp->rx_alignment_errors) +
le32toh(sp->rx_rnr_errors) +
@@ -2091,7 +2093,8 @@ fxp_update_stats(struct fxp_softc *sc)
* threshold by another 512 bytes (64 * 8).
*/
if (sp->tx_underruns) {
- if_incoerrors(ifp, le32toh(sp->tx_underruns));
+ if_inc_counter(ifp, IFCOUNTER_OERRORS,
+ le32toh(sp->tx_underruns));
if (tx_threshold < 192)
tx_threshold += 64;
}
@@ -2244,7 +2247,7 @@ fxp_watchdog(struct fxp_softc *sc)
return;
device_printf(sc->dev, "device timeout\n");
- if_incoerrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
fxp_init_body(sc, 1);
diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c
index 0c0ae5c..fda21c0 100644
--- a/sys/dev/nfe/if_nfe.c
+++ b/sys/dev/nfe/if_nfe.c
@@ -2149,7 +2149,7 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
prog++;
if ((sc->nfe_flags & (NFE_JUMBO_SUP | NFE_40BIT_ADDR)) == 0) {
if (!(flags & NFE_RX_VALID_V1)) {
- if_incierrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
nfe_discard_rxbuf(sc, sc->rxq.cur);
continue;
}
@@ -2159,7 +2159,7 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
}
} else {
if (!(flags & NFE_RX_VALID_V2)) {
- if_incierrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
nfe_discard_rxbuf(sc, sc->rxq.cur);
continue;
}
@@ -2171,14 +2171,14 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
}
if (flags & NFE_RX_ERROR) {
- if_incierrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
nfe_discard_rxbuf(sc, sc->rxq.cur);
continue;
}
m = data->m;
if (nfe_newbuf(sc, sc->rxq.cur) != 0) {
- if_inciqdrops(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
nfe_discard_rxbuf(sc, sc->rxq.cur);
continue;
}
@@ -2205,7 +2205,7 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
}
}
- if_incipackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
NFE_UNLOCK(sc);
if_input(ifp, m);
@@ -2265,7 +2265,7 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
prog++;
if ((sc->nfe_flags & (NFE_JUMBO_SUP | NFE_40BIT_ADDR)) == 0) {
if (!(flags & NFE_RX_VALID_V1)) {
- if_incierrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
nfe_discard_jrxbuf(sc, sc->jrxq.jcur);
continue;
}
@@ -2275,7 +2275,7 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
}
} else {
if (!(flags & NFE_RX_VALID_V2)) {
- if_incierrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
nfe_discard_jrxbuf(sc, sc->jrxq.jcur);
continue;
}
@@ -2287,14 +2287,14 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
}
if (flags & NFE_RX_ERROR) {
- if_incierrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
nfe_discard_jrxbuf(sc, sc->jrxq.jcur);
continue;
}
m = data->m;
if (nfe_jnewbuf(sc, sc->jrxq.jcur) != 0) {
- if_inciqdrops(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
nfe_discard_jrxbuf(sc, sc->jrxq.jcur);
continue;
}
@@ -2321,7 +2321,7 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp)
}
}
- if_incipackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
NFE_UNLOCK(sc);
if_input(ifp, m);
@@ -2379,18 +2379,18 @@ nfe_txeof(struct nfe_softc *sc)
device_printf(sc->nfe_dev,
"tx v1 error 0x%4b\n", flags, NFE_V1_TXERR);
- if_incoerrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
} else
- if_incopackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
} else {
if ((flags & NFE_TX_LASTFRAG_V2) == 0)
continue;
if ((flags & NFE_TX_ERROR_V2) != 0) {
device_printf(sc->nfe_dev,
"tx v2 error 0x%4b\n", flags, NFE_V2_TXERR);
- if_incoerrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
} else
- if_incopackets(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
}
/* last fragment of the mbuf chain transmitted */
@@ -2723,7 +2723,7 @@ nfe_watchdog(if_t ifp)
if_printf(ifp, "watchdog timeout\n");
if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
- if_incoerrors(ifp, 1);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
nfe_init_locked(sc);
}
OpenPOWER on IntegriCloud