Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci restructure wm(4) evcnt to support multiqueue ev...
details: https://anonhg.NetBSD.org/src/rev/4db99600384f
branches: trunk
changeset: 346998:4db99600384f
user: knakahara <knakahara%NetBSD.org@localhost>
date: Wed Aug 10 04:52:40 2016 +0000
description:
restructure wm(4) evcnt to support multiqueue evcnt.
ok by msaitou@n.o.
diffstat:
sys/dev/pci/if_wm.c | 243 +++++++++++++++++++++++++++++----------------------
1 files changed, 138 insertions(+), 105 deletions(-)
diffs (truncated from 544 to 300 lines):
diff -r a064f86583f6 -r 4db99600384f sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Wed Aug 10 04:24:17 2016 +0000
+++ b/sys/dev/pci/if_wm.c Wed Aug 10 04:52:40 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.416 2016/07/11 06:14:51 knakahara Exp $ */
+/* $NetBSD: if_wm.c,v 1.417 2016/08/10 04:52:40 knakahara Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -81,11 +81,10 @@
* - Set LED correctly (based on contents in EEPROM)
* - Rework how parameters are loaded from the EEPROM.
* - Image Unique ID
- * - restructure evcnt
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.416 2016/07/11 06:14:51 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.417 2016/08/10 04:52:40 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -254,6 +253,28 @@
struct wm_softc;
+#ifdef WM_EVENT_COUNTERS
+#define WM_Q_EVCNT_DEFINE(qname, evname) \
+ char qname##_##evname##_evcnt_name[sizeof("qname##XX##evname")]; \
+ struct evcnt qname##_ev_##evname;
+
+#define WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, evtype) \
+ do{ \
+ snprintf((q)->qname##_##evname##_evcnt_name, \
+ sizeof((q)->qname##_##evname##_evcnt_name), \
+ "%s%02d%s", #qname, (qnum), #evname); \
+ evcnt_attach_dynamic(&(q)->qname##_ev_##evname, \
+ (evtype), NULL, (xname), \
+ (q)->qname##_##evname##_evcnt_name); \
+ }while(0)
+
+#define WM_Q_MISC_EVCNT_ATTACH(qname, evname, q, qnum, xname) \
+ WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, EVCNT_TYPE_MISC)
+
+#define WM_Q_INTR_EVCNT_ATTACH(qname, evname, q, qnum, xname) \
+ WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, EVCNT_TYPE_INTR)
+#endif /* WM_EVENT_COUNTERS */
+
struct wm_txqueue {
kmutex_t *txq_lock; /* lock for tx operations */
@@ -302,7 +323,28 @@
int txq_flags; /* flags for H/W queue, see below */
#define WM_TXQ_NO_SPACE 0x1
- /* XXX which event counter is required? */
+#ifdef WM_EVENT_COUNTERS
+ WM_Q_EVCNT_DEFINE(txq, txsstall) /* Tx stalled due to no txs */
+ WM_Q_EVCNT_DEFINE(txq, txdstall) /* Tx stalled due to no txd */
+ WM_Q_EVCNT_DEFINE(txq, txfifo_stall) /* Tx FIFO stalls (82547) */
+ WM_Q_EVCNT_DEFINE(txq, txdw) /* Tx descriptor interrupts */
+ WM_Q_EVCNT_DEFINE(txq, txqe) /* Tx queue empty interrupts */
+ /* XXX not used? */
+
+ WM_Q_EVCNT_DEFINE(txq, txipsum) /* IP checksums comp. out-bound */
+ WM_Q_EVCNT_DEFINE(txq,txtusum) /* TCP/UDP cksums comp. out-bound */
+ WM_Q_EVCNT_DEFINE(txq, txtusum6) /* TCP/UDP v6 cksums comp. out-bound */
+ WM_Q_EVCNT_DEFINE(txq, txtso) /* TCP seg offload out-bound (IPv4) */
+ WM_Q_EVCNT_DEFINE(txq, txtso6) /* TCP seg offload out-bound (IPv6) */
+ WM_Q_EVCNT_DEFINE(txq, txtsopain) /* painful header manip. for TSO */
+
+ WM_Q_EVCNT_DEFINE(txq, txdrop) /* Tx packets dropped(too many segs) */
+
+ WM_Q_EVCNT_DEFINE(txq, tu) /* Tx underrun */
+
+ char txq_txseg_evcnt_names[WM_NTXSEGS][sizeof("txqXXtxsegXXX")];
+ struct evcnt txq_ev_txseg[WM_NTXSEGS]; /* Tx packets w/ N segments */
+#endif /* WM_EVENT_COUNTERS */
};
struct wm_rxqueue {
@@ -330,7 +372,12 @@
struct mbuf *rxq_tail;
struct mbuf **rxq_tailp;
- /* XXX which event counter is required? */
+#ifdef WM_EVENT_COUNTERS
+ WM_Q_EVCNT_DEFINE(rxq, rxintr); /* Rx interrupts */
+
+ WM_Q_EVCNT_DEFINE(rxq, rxipsum); /* IP checksums checked in-bound */
+ WM_Q_EVCNT_DEFINE(rxq, rxtusum); /* TCP/UDP cksums checked in-bound */
+#endif
};
struct wm_queue {
@@ -412,28 +459,9 @@
#ifdef WM_EVENT_COUNTERS
/* Event counters. */
- struct evcnt sc_ev_txsstall; /* Tx stalled due to no txs */
- struct evcnt sc_ev_txdstall; /* Tx stalled due to no txd */
- struct evcnt sc_ev_txfifo_stall;/* Tx FIFO stalls (82547) */
- struct evcnt sc_ev_txdw; /* Tx descriptor interrupts */
- struct evcnt sc_ev_txqe; /* Tx queue empty interrupts */
- struct evcnt sc_ev_rxintr; /* Rx interrupts */
struct evcnt sc_ev_linkintr; /* Link interrupts */
- struct evcnt sc_ev_rxipsum; /* IP checksums checked in-bound */
- struct evcnt sc_ev_rxtusum; /* TCP/UDP cksums checked in-bound */
- struct evcnt sc_ev_txipsum; /* IP checksums comp. out-bound */
- struct evcnt sc_ev_txtusum; /* TCP/UDP cksums comp. out-bound */
- struct evcnt sc_ev_txtusum6; /* TCP/UDP v6 cksums comp. out-bound */
- struct evcnt sc_ev_txtso; /* TCP seg offload out-bound (IPv4) */
- struct evcnt sc_ev_txtso6; /* TCP seg offload out-bound (IPv6) */
- struct evcnt sc_ev_txtsopain; /* painful header manip. for TSO */
-
- struct evcnt sc_ev_txseg[WM_NTXSEGS]; /* Tx packets w/ N segments */
- struct evcnt sc_ev_txdrop; /* Tx packets dropped(too many segs) */
-
- struct evcnt sc_ev_tu; /* Tx underrun */
-
+ /* WM_T_82542_2_1 only */
struct evcnt sc_ev_tx_xoff; /* Tx PAUSE(!0) frames */
struct evcnt sc_ev_tx_xon; /* Tx PAUSE(0) frames */
struct evcnt sc_ev_rx_xoff; /* Rx PAUSE(!0) frames */
@@ -496,10 +524,18 @@
#ifdef WM_EVENT_COUNTERS
#define WM_EVCNT_INCR(ev) (ev)->ev_count++
#define WM_EVCNT_ADD(ev, val) (ev)->ev_count += (val)
-#else
+
+#define WM_Q_EVCNT_INCR(qname, evname) \
+ WM_EVCNT_INCR(&(qname)->qname##_ev_##evname)
+#define WM_Q_EVCNT_ADD(qname, evname, val) \
+ WM_EVCNT_ADD(&(qname)->qname##_ev_##evname, (val))
+#else /* !WM_EVENT_COUNTERS */
#define WM_EVCNT_INCR(ev) /* nothing */
#define WM_EVCNT_ADD(ev, val) /* nothing */
-#endif
+
+#define WM_Q_EVCNT_INCR(qname, evname) /* nothing */
+#define WM_Q_EVCNT_ADD(qname, evname, val) /* nothing */
+#endif /* !WM_EVENT_COUNTERS */
#define CSR_READ(sc, reg) \
bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
@@ -1333,11 +1369,6 @@
0, 0 },
};
-#ifdef WM_EVENT_COUNTERS
-static char wm_txseg_evcnt_names[WM_NTXSEGS][sizeof("txsegXXX")];
-#endif /* WM_EVENT_COUNTERS */
-
-
/*
* Register read/write functions.
* Other than CSR_{READ|WRITE}().
@@ -2522,52 +2553,9 @@
#ifdef WM_EVENT_COUNTERS
/* Attach event counters. */
- evcnt_attach_dynamic(&sc->sc_ev_txsstall, EVCNT_TYPE_MISC,
- NULL, xname, "txsstall");
- evcnt_attach_dynamic(&sc->sc_ev_txdstall, EVCNT_TYPE_MISC,
- NULL, xname, "txdstall");
- evcnt_attach_dynamic(&sc->sc_ev_txfifo_stall, EVCNT_TYPE_MISC,
- NULL, xname, "txfifo_stall");
- evcnt_attach_dynamic(&sc->sc_ev_txdw, EVCNT_TYPE_INTR,
- NULL, xname, "txdw");
- evcnt_attach_dynamic(&sc->sc_ev_txqe, EVCNT_TYPE_INTR,
- NULL, xname, "txqe");
- evcnt_attach_dynamic(&sc->sc_ev_rxintr, EVCNT_TYPE_INTR,
- NULL, xname, "rxintr");
evcnt_attach_dynamic(&sc->sc_ev_linkintr, EVCNT_TYPE_INTR,
NULL, xname, "linkintr");
- evcnt_attach_dynamic(&sc->sc_ev_rxipsum, EVCNT_TYPE_MISC,
- NULL, xname, "rxipsum");
- evcnt_attach_dynamic(&sc->sc_ev_rxtusum, EVCNT_TYPE_MISC,
- NULL, xname, "rxtusum");
- evcnt_attach_dynamic(&sc->sc_ev_txipsum, EVCNT_TYPE_MISC,
- NULL, xname, "txipsum");
- evcnt_attach_dynamic(&sc->sc_ev_txtusum, EVCNT_TYPE_MISC,
- NULL, xname, "txtusum");
- evcnt_attach_dynamic(&sc->sc_ev_txtusum6, EVCNT_TYPE_MISC,
- NULL, xname, "txtusum6");
-
- evcnt_attach_dynamic(&sc->sc_ev_txtso, EVCNT_TYPE_MISC,
- NULL, xname, "txtso");
- evcnt_attach_dynamic(&sc->sc_ev_txtso6, EVCNT_TYPE_MISC,
- NULL, xname, "txtso6");
- evcnt_attach_dynamic(&sc->sc_ev_txtsopain, EVCNT_TYPE_MISC,
- NULL, xname, "txtsopain");
-
- for (i = 0; i < WM_NTXSEGS; i++) {
- snprintf(wm_txseg_evcnt_names[i],
- sizeof(wm_txseg_evcnt_names[i]), "txseg%d", i);
- evcnt_attach_dynamic(&sc->sc_ev_txseg[i], EVCNT_TYPE_MISC,
- NULL, xname, wm_txseg_evcnt_names[i]);
- }
-
- evcnt_attach_dynamic(&sc->sc_ev_txdrop, EVCNT_TYPE_MISC,
- NULL, xname, "txdrop");
-
- evcnt_attach_dynamic(&sc->sc_ev_tu, EVCNT_TYPE_MISC,
- NULL, xname, "tu");
-
evcnt_attach_dynamic(&sc->sc_ev_tx_xoff, EVCNT_TYPE_MISC,
NULL, xname, "tx_xoff");
evcnt_attach_dynamic(&sc->sc_ev_tx_xon, EVCNT_TYPE_MISC,
@@ -5531,6 +5519,10 @@
error = 0;
tx_done = 0;
for (i = 0; i < sc->sc_nqueues; i++) {
+#ifdef WM_EVENT_COUNTERS
+ int j;
+ const char *xname;
+#endif
struct wm_txqueue *txq = &sc->sc_queue[i].wmq_txq;
txq->txq_sc = sc;
txq->txq_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
@@ -5550,6 +5542,35 @@
error = ENOMEM;
break;
}
+
+#ifdef WM_EVENT_COUNTERS
+ xname = device_xname(sc->sc_dev);
+
+ WM_Q_MISC_EVCNT_ATTACH(txq, txsstall, txq, i, xname);
+ WM_Q_MISC_EVCNT_ATTACH(txq, txdstall, txq, i, xname);
+ WM_Q_MISC_EVCNT_ATTACH(txq, txfifo_stall, txq, i, xname);
+ WM_Q_INTR_EVCNT_ATTACH(txq, txdw, txq, i, xname);
+ WM_Q_INTR_EVCNT_ATTACH(txq, txqe, txq, i, xname);
+
+ WM_Q_MISC_EVCNT_ATTACH(txq, txipsum, txq, i, xname);
+ WM_Q_MISC_EVCNT_ATTACH(txq, txtusum, txq, i, xname);
+ WM_Q_MISC_EVCNT_ATTACH(txq, txtusum6, txq, i, xname);
+ WM_Q_MISC_EVCNT_ATTACH(txq, txtso, txq, i, xname);
+ WM_Q_MISC_EVCNT_ATTACH(txq, txtso6, txq, i, xname);
+ WM_Q_MISC_EVCNT_ATTACH(txq, txtsopain, txq, i, xname);
+
+ for (j = 0; j < WM_NTXSEGS; j++) {
+ snprintf(txq->txq_txseg_evcnt_names[j],
+ sizeof(txq->txq_txseg_evcnt_names[j]), "txq%02dtxseg%d", i, j);
+ evcnt_attach_dynamic(&txq->txq_ev_txseg[j], EVCNT_TYPE_MISC,
+ NULL, xname, txq->txq_txseg_evcnt_names[j]);
+ }
+
+ WM_Q_MISC_EVCNT_ATTACH(txq, txdrop, txq, i, xname);
+
+ WM_Q_MISC_EVCNT_ATTACH(txq, tu, txq, i, xname);
+#endif /* WM_EVENT_COUNTERS */
+
tx_done++;
}
if (error)
@@ -5561,6 +5582,9 @@
error = 0;
rx_done = 0;
for (i = 0; i < sc->sc_nqueues; i++) {
+#ifdef WM_EVENT_COUNTERS
+ const char *xname;
+#endif
struct wm_rxqueue *rxq = &sc->sc_queue[i].wmq_rxq;
rxq->rxq_sc = sc;
rxq->rxq_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
@@ -5575,6 +5599,15 @@
break;
}
+#ifdef WM_EVENT_COUNTERS
+ xname = device_xname(sc->sc_dev);
+
+ WM_Q_INTR_EVCNT_ATTACH(rxq, rxintr, rxq, i, xname);
+
+ WM_Q_INTR_EVCNT_ATTACH(rxq, rxipsum, rxq, i, xname);
+ WM_Q_INTR_EVCNT_ATTACH(rxq, rxtusum, rxq, i, xname);
+#endif /* WM_EVENT_COUNTERS */
+
rx_done++;
}
if (error)
@@ -5944,7 +5977,7 @@
*/
struct tcphdr th;
- WM_EVCNT_INCR(&sc->sc_ev_txtsopain);
+ WM_Q_EVCNT_INCR(txq, txtsopain);
m_copydata(m0, hlen, sizeof(th), &th);
if (v4) {
@@ -6000,10 +6033,10 @@
}
if (v4) {
- WM_EVCNT_INCR(&sc->sc_ev_txtso);
+ WM_Q_EVCNT_INCR(txq, txtso);
cmdlen |= WTX_TCPIP_CMD_IP;
Home |
Main Index |
Thread Index |
Old Index