diff options
author | sam <sam@FreeBSD.org> | 2007-12-13 01:39:30 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2007-12-13 01:39:30 +0000 |
commit | ec64d39bbd702b2dc3b24292e740cf5385cc0768 (patch) | |
tree | e493fbd5e2b9be222e5a0e54625d31cee84e8fba | |
parent | 225412214c491be0441207ebeefa58180663d08d (diff) | |
download | FreeBSD-src-ec64d39bbd702b2dc3b24292e740cf5385cc0768.zip FreeBSD-src-ec64d39bbd702b2dc3b24292e740cf5385cc0768.tar.gz |
Some overdue tlc:
o push include paths to the Makefile
o use the AFTER trick to simplify adding new items
o prepare stat blocks for additional data
o align values for verbose output
o fillin some missing stats
MFC after: 1 week
-rw-r--r-- | tools/tools/ath/athstats/Makefile | 10 | ||||
-rw-r--r-- | tools/tools/ath/athstats/athstats.c | 333 | ||||
-rw-r--r-- | tools/tools/ath/athstats/statfoo.c | 12 |
3 files changed, 191 insertions, 164 deletions
diff --git a/tools/tools/ath/athstats/Makefile b/tools/tools/ath/athstats/Makefile index 315d7e6..c4d0e93 100644 --- a/tools/tools/ath/athstats/Makefile +++ b/tools/tools/ath/athstats/Makefile @@ -9,9 +9,15 @@ SRCS= main.c statfoo.c athstats.c .include <bsd.prog.mk> CFLAGS+= -I. -CLEANFILES+= opt_ah.h +CLEANFILES+= opt_ah.h ah_osdep.h -athstats.o: opt_ah.h +CFLAGS+=-I../../../../sys/contrib/dev/ath +CFLAGS+=-I../../../../sys/net80211 +CFLAGS+=-I../../../../sys/dev/ath + +athstats.o: opt_ah.h ah_osdep.h opt_ah.h: touch opt_ah.h +ah_osdep.h: + touch ah_osdep.h diff --git a/tools/tools/ath/athstats/athstats.c b/tools/tools/ath/athstats/athstats.c index 29cadfe..0439e91 100644 --- a/tools/tools/ath/athstats/athstats.c +++ b/tools/tools/ath/athstats/athstats.c @@ -41,256 +41,258 @@ #include <net/if_var.h> #include <stdio.h> +#include <stdlib.h> #include <signal.h> #include <string.h> #include <unistd.h> #include <err.h> -#include "../../../../sys/contrib/dev/ath/ah_desc.h" -#include "../../../../sys/net80211/ieee80211_ioctl.h" -#include "../../../../sys/net80211/ieee80211_radiotap.h" -#include "../../../../sys/dev/ath/if_athioctl.h" +#include "ah.h" +#include "ah_desc.h" +#include "ieee80211_ioctl.h" +#include "ieee80211_radiotap.h" +#include "if_athioctl.h" #include "athstats.h" #define NOTPRESENT { 0, "", "" } +#define AFTER(prev) ((prev)+1) + static const struct fmt athstats[] = { #define S_INPUT 0 { 8, "input", "input", "data frames received" }, -#define S_OUTPUT 1 +#define S_OUTPUT AFTER(S_INPUT) { 8, "output", "output", "data frames transmit" }, -#define S_TX_ALTRATE 2 +#define S_TX_ALTRATE AFTER(S_OUTPUT) { 7, "altrate", "altrate", "tx frames with an alternate rate" }, -#define S_TX_SHORTRETRY 3 +#define S_TX_SHORTRETRY AFTER(S_TX_ALTRATE) { 7, "short", "short", "short on-chip tx retries" }, -#define S_TX_LONGRETRY 4 +#define S_TX_LONGRETRY AFTER(S_TX_SHORTRETRY) { 7, "long", "long", "long on-chip tx retries" }, -#define S_TX_XRETRIES 5 +#define S_TX_XRETRIES AFTER(S_TX_LONGRETRY) { 6, "xretry", "xretry", "tx failed 'cuz too many retries" }, -#define S_MIB 6 +#define S_MIB AFTER(S_TX_XRETRIES) { 5, "mib", "mib", "mib overflow interrupts" }, #ifndef __linux__ -#define S_TX_LINEAR 7 +#define S_TX_LINEAR AFTER(S_MIB) { 5, "txlinear", "txlinear", "tx linearized to cluster" }, -#define S_BSTUCK 8 +#define S_BSTUCK AFTER(S_TX_LINEAR) { 5, "bstuck", "bstuck", "stuck beacon conditions" }, -#define S_INTRCOAL 9 +#define S_INTRCOAL AFTER(S_BSTUCK) { 5, "intrcoal", "intrcoal", "interrupts coalesced" }, +#define S_RATE AFTER(S_INTRCOAL) #else - NOTPRESENT, NOTPRESENT, NOTPRESENT, +#define S_RATE AFTER(S_MIB) #endif -#define S_RATE 10 { 4, "rate", "rate", "current transmit rate" }, -#define S_WATCHDOG 11 +#define S_WATCHDOG AFTER(S_RATE) { 5, "wdog", "wdog", "watchdog timeouts" }, -#define S_FATAL 12 +#define S_FATAL AFTER(S_WATCHDOG) { 5, "fatal", "fatal", "hardware error interrupts" }, -#define S_BMISS 13 +#define S_BMISS AFTER(S_FATAL) { 5, "bmiss", "bmiss", "beacon miss interrupts" }, -#define S_RXORN 14 +#define S_RXORN AFTER(S_BMISS) { 5, "rxorn", "rxorn", "recv overrun interrupts" }, -#define S_RXEOL 15 +#define S_RXEOL AFTER(S_RXORN) { 5, "rxeol", "rxeol", "recv eol interrupts" }, -#define S_TXURN 16 +#define S_TXURN AFTER(S_RXEOL) { 5, "txurn", "txurn", "txmit underrun interrupts" }, -#define S_TX_MGMT 17 +#define S_TX_MGMT AFTER(S_TXURN) { 5, "txmgt", "txmgt", "tx management frames" }, -#define S_TX_DISCARD 18 +#define S_TX_DISCARD AFTER(S_TX_MGMT) { 5, "txdisc", "txdisc", "tx frames discarded prior to association" }, -#define S_TX_INVALID 19 +#define S_TX_INVALID AFTER(S_TX_DISCARD) { 5, "txinv", "txinv", "tx invalid (19)" }, -#define S_TX_QSTOP 20 +#define S_TX_QSTOP AFTER(S_TX_INVALID) { 5, "qstop", "qstop", "tx stopped 'cuz no xmit buffer" }, -#define S_TX_ENCAP 21 +#define S_TX_ENCAP AFTER(S_TX_QSTOP) { 5, "txencode", "txencode", "tx encapsulation failed" }, -#define S_TX_NONODE 22 +#define S_TX_NONODE AFTER(S_TX_ENCAP) { 5, "txnonode", "txnonode", "tx failed 'cuz no node" }, -#define S_TX_NOMBUF 23 +#define S_TX_NOMBUF AFTER(S_TX_NONODE) { 5, "txnombuf", "txnombuf", "tx failed 'cuz mbuf allocation failed" }, #ifndef __linux__ -#define S_TX_NOMCL 24 +#define S_TX_NOMCL AFTER(S_TX_NOMBUF) { 5, "txnomcl", "txnomcl", "tx failed 'cuz cluster allocation failed" }, +#define S_TX_FIFOERR AFTER(S_TX_NOMCL) #else - NOTPRESENT, +#define S_TX_FIFOERR AFTER(S_TX_NOMBUF) #endif -#define S_TX_FIFOERR 25 { 5, "efifo", "efifo", "tx failed 'cuz FIFO underrun" }, -#define S_TX_FILTERED 26 +#define S_TX_FILTERED AFTER(S_TX_FIFOERR) { 5, "efilt", "efilt", "tx failed 'cuz destination filtered" }, -#define S_TX_BADRATE 27 +#define S_TX_BADRATE AFTER(S_TX_FILTERED) { 5, "txbadrate", "txbadrate", "tx failed 'cuz bogus xmit rate" }, -#define S_TX_NOACK 28 +#define S_TX_NOACK AFTER(S_TX_BADRATE) { 5, "noack", "noack", "tx frames with no ack marked" }, -#define S_TX_RTS 29 +#define S_TX_RTS AFTER(S_TX_NOACK) { 5, "rts", "rts", "tx frames with rts enabled" }, -#define S_TX_CTS 30 +#define S_TX_CTS AFTER(S_TX_RTS) { 5, "cts", "cts", "tx frames with cts enabled" }, -#define S_TX_SHORTPRE 31 +#define S_TX_SHORTPRE AFTER(S_TX_CTS) { 5, "shpre", "shpre", "tx frames with short preamble" }, -#define S_TX_PROTECT 32 +#define S_TX_PROTECT AFTER(S_TX_SHORTPRE) { 5, "protect", "protect", "tx frames with 11g protection" }, -#define S_RX_ORN 33 +#define S_RX_ORN AFTER(S_TX_PROTECT) { 5, "rxorn", "rxorn", "rx failed 'cuz of desc overrun" }, -#define S_RX_CRC_ERR 34 +#define S_RX_CRC_ERR AFTER(S_RX_ORN) { 6, "crcerr", "crcerr", "rx failed 'cuz of bad CRC" }, -#define S_RX_FIFO_ERR 35 +#define S_RX_FIFO_ERR AFTER(S_RX_CRC_ERR) { 5, "rxfifo", "rxfifo", "rx failed 'cuz of FIFO overrun" }, -#define S_RX_CRYPTO_ERR 36 +#define S_RX_CRYPTO_ERR AFTER(S_RX_FIFO_ERR) { 5, "crypt", "crypt", "rx failed 'cuz decryption" }, -#define S_RX_MIC_ERR 37 +#define S_RX_MIC_ERR AFTER(S_RX_CRYPTO_ERR) { 4, "mic", "mic", "rx failed 'cuz MIC failure" }, -#define S_RX_TOOSHORT 38 +#define S_RX_TOOSHORT AFTER(S_RX_MIC_ERR) { 5, "rxshort", "rxshort", "rx failed 'cuz frame too short" }, -#define S_RX_NOMBUF 39 +#define S_RX_NOMBUF AFTER(S_RX_TOOSHORT) { 5, "rxnombuf", "rxnombuf", "rx setup failed 'cuz no mbuf" }, -#define S_RX_MGT 40 +#define S_RX_MGT AFTER(S_RX_NOMBUF) { 5, "rxmgt", "rxmgt", "rx management frames" }, -#define S_RX_CTL 41 +#define S_RX_CTL AFTER(S_RX_MGT) { 5, "rxctl", "rxctl", "rx control frames" }, -#define S_RX_PHY_ERR 42 +#define S_RX_PHY_ERR AFTER(S_RX_CTL) { 7, "phyerr", "phyerr", "rx failed 'cuz of PHY err" }, -#define S_RX_PHY_UNDERRUN 43 +#define S_RX_PHY_UNDERRUN AFTER(S_RX_PHY_ERR) { 6, "phyund", "phyund", "transmit underrun" }, -#define S_RX_PHY_TIMING 44 +#define S_RX_PHY_TIMING AFTER(S_RX_PHY_UNDERRUN) { 6, "phytim", "phytim", "timing error" }, -#define S_RX_PHY_PARITY 45 +#define S_RX_PHY_PARITY AFTER(S_RX_PHY_TIMING) { 6, "phypar", "phypar", "illegal parity" }, -#define S_RX_PHY_RATE 46 +#define S_RX_PHY_RATE AFTER(S_RX_PHY_PARITY) { 6, "phyrate", "phyrate", "illegal rate" }, -#define S_RX_PHY_LENGTH 47 +#define S_RX_PHY_LENGTH AFTER(S_RX_PHY_RATE) { 6, "phylen", "phylen", "illegal length" }, -#define S_RX_PHY_RADAR 48 +#define S_RX_PHY_RADAR AFTER(S_RX_PHY_LENGTH) { 6, "phyradar", "phyradar", "radar detect" }, -#define S_RX_PHY_SERVICE 49 +#define S_RX_PHY_SERVICE AFTER(S_RX_PHY_RADAR) { 6, "physervice", "physervice", "illegal service" }, -#define S_RX_PHY_TOR 50 +#define S_RX_PHY_TOR AFTER(S_RX_PHY_SERVICE) { 6, "phytor", "phytor", "transmit override receive" }, -#define S_RX_PHY_OFDM_TIMING 51 +#define S_RX_PHY_OFDM_TIMING AFTER(S_RX_PHY_TOR) { 6, "ofdmtim", "ofdmtim", "OFDM timing" }, -#define S_RX_PHY_OFDM_SIGNAL_PARITY 52 +#define S_RX_PHY_OFDM_SIGNAL_PARITY AFTER(S_RX_PHY_OFDM_TIMING) { 6, "ofdmsig", "ofdmsig", "OFDM illegal parity" }, -#define S_RX_PHY_OFDM_RATE_ILLEGAL 53 +#define S_RX_PHY_OFDM_RATE_ILLEGAL AFTER(S_RX_PHY_OFDM_SIGNAL_PARITY) { 6, "ofdmrate", "ofdmrate", "OFDM illegal rate" }, -#define S_RX_PHY_OFDM_POWER_DROP 54 +#define S_RX_PHY_OFDM_POWER_DROP AFTER(S_RX_PHY_OFDM_RATE_ILLEGAL) { 6, "ofdmpow", "ofdmpow", "OFDM power drop" }, -#define S_RX_PHY_OFDM_SERVICE 55 +#define S_RX_PHY_OFDM_SERVICE AFTER(S_RX_PHY_OFDM_POWER_DROP) { 6, "ofdmservice", "ofdmservice", "OFDM illegal service" }, -#define S_RX_PHY_OFDM_RESTART 56 +#define S_RX_PHY_OFDM_RESTART AFTER(S_RX_PHY_OFDM_SERVICE) { 6, "ofdmrestart", "ofdmrestart", "OFDM restart" }, -#define S_RX_PHY_CCK_TIMING 57 +#define S_RX_PHY_CCK_TIMING AFTER(S_RX_PHY_OFDM_RESTART) { 6, "ccktim", "ccktim", "CCK timing" }, -#define S_RX_PHY_CCK_HEADER_CRC 58 +#define S_RX_PHY_CCK_HEADER_CRC AFTER(S_RX_PHY_CCK_TIMING) { 6, "cckhead", "cckhead", "CCK header crc" }, -#define S_RX_PHY_CCK_RATE_ILLEGAL 59 +#define S_RX_PHY_CCK_RATE_ILLEGAL AFTER(S_RX_PHY_CCK_HEADER_CRC) { 6, "cckrate", "cckrate", "CCK illegal rate" }, -#define S_RX_PHY_CCK_SERVICE 60 +#define S_RX_PHY_CCK_SERVICE AFTER(S_RX_PHY_CCK_RATE_ILLEGAL) { 6, "cckservice", "cckservice", "CCK illegal service" }, -#define S_RX_PHY_CCK_RESTART 61 +#define S_RX_PHY_CCK_RESTART AFTER(S_RX_PHY_CCK_SERVICE) { 6, "cckrestar", "cckrestar", "CCK restart" }, -#define S_BE_NOMBUF 62 +#define S_BE_NOMBUF AFTER(S_RX_PHY_CCK_RESTART) { 4, "benombuf", "benombuf", "beacon setup failed 'cuz no mbuf" }, -#define S_BE_XMIT 63 +#define S_BE_XMIT AFTER(S_BE_NOMBUF) { 7, "bexmit", "bexmit", "beacons transmitted" }, -#define S_PER_CAL 64 +#define S_PER_CAL AFTER(S_BE_XMIT) { 4, "pcal", "pcal", "periodic calibrations" }, -#define S_PER_CALFAIL 65 +#define S_PER_CALFAIL AFTER(S_PER_CAL) { 4, "pcalf", "pcalf", "periodic calibration failures" }, -#define S_PER_RFGAIN 66 +#define S_PER_RFGAIN AFTER(S_PER_CALFAIL) { 4, "prfga", "prfga", "rfgain value change" }, -#if 0 -#define S_TDMA_UPDATE 67 +#if ATH_SUPPORT_TDMA +#define S_TDMA_UPDATE AFTER(S_PER_RFGAIN) { 5, "tdmau", "tdmau", "TDMA slot timing updates" }, -#define S_TDMA_TIMERS 68 +#define S_TDMA_TIMERS AFTER(S_TDMA_UPDATE) { 5, "tdmab", "tdmab", "TDMA slot update set beacon timers" }, -#define S_TDMA_TSF 69 +#define S_TDMA_TSF AFTER(S_TDMA_TIMERS) { 5, "tdmat", "tdmat", "TDMA slot update set TSF" }, +#define S_RATE_CALLS AFTER(S_TDMA_TSF) #else - NOTPRESENT, NOTPRESENT, NOTPRESENT, +#define S_RATE_CALLS AFTER(S_PER_RFGAIN) #endif -#define S_RATE_CALLS 70 { 5, "ratec", "ratec", "rate control checks" }, -#define S_RATE_RAISE 71 +#define S_RATE_RAISE AFTER(S_RATE_CALLS) { 5, "rate+", "rate+", "rate control raised xmit rate" }, -#define S_RATE_DROP 72 +#define S_RATE_DROP AFTER(S_RATE_RAISE) { 5, "rate-", "rate-", "rate control dropped xmit rate" }, -#define S_TX_RSSI 73 +#define S_TX_RSSI AFTER(S_RATE_DROP) { 4, "arssi", "arssi", "rssi of last ack" }, -#define S_RX_RSSI 74 +#define S_RX_RSSI AFTER(S_TX_RSSI) { 4, "rssi", "rssi", "avg recv rssi" }, -#define S_RX_NOISE 75 +#define S_RX_NOISE AFTER(S_RX_RSSI) { 5, "noise", "noise", "rx noise floor" }, -#define S_BMISS_PHANTOM 76 +#define S_BMISS_PHANTOM AFTER(S_RX_NOISE) { 5, "bmissphantom", "bmissphantom", "phantom beacon misses" }, -#define S_TX_RAW 77 +#define S_TX_RAW AFTER(S_BMISS_PHANTOM) { 5, "txraw", "txraw", "tx frames through raw api" }, -#define S_RX_TOOBIG 78 +#define S_RX_TOOBIG AFTER(S_TX_RAW) { 5, "rx2big", "rx2big", "rx failed 'cuz frame too large" }, #ifndef __linux__ -#define S_CABQ_XMIT 79 +#define S_CABQ_XMIT AFTER(S_RX_TOOBIG) { 5, "cabxmit", "cabxmit", "cabq frames transmitted" }, -#define S_CABQ_BUSY 80 +#define S_CABQ_BUSY AFTER(S_CABQ_XMIT) { 5, "cabqbusy", "cabqbusy", "cabq xmit overflowed beacon interval" }, -#define S_TX_NODATA 81 +#define S_TX_NODATA AFTER(S_CABQ_BUSY) { 5, "txnodata", "txnodata", "tx discarded empty frame" }, -#define S_TX_BUSDMA 82 +#define S_TX_BUSDMA AFTER(S_TX_NODATA) { 5, "txbusdma", "txbusdma", "tx failed for dma resrcs" }, -#define S_RX_BUSDMA 83 +#define S_RX_BUSDMA AFTER(S_TX_BUSDMA) { 5, "rxbusdma", "rxbusdma", "rx setup failed for dma resrcs" }, +#define S_FF_TXOK AFTER(S_RX_BUSDMA) #else - NOTPRESENT, NOTPRESENT, NOTPRESENT, NOTPRESENT, NOTPRESENT, +#define S_FF_TXOK AFTER(S_RX_PHY_UNDERRUN) #endif -#if 0 -#define S_FF_TXOK 84 { 5, "fftxok", "fftxok", "fast frames xmit successfully" }, -#define S_FF_TXERR 85 +#define S_FF_TXERR AFTER(S_FF_TXOK) { 5, "fftxerr", "fftxerr", "fast frames not xmit due to error" }, -#define S_FF_RX 86 +#define S_FF_RX AFTER(S_FF_TXERR) { 5, "ffrx", "ffrx", "fast frames received" }, -#define S_FF_FLUSH 87 +#define S_FF_FLUSH AFTER(S_FF_RX) { 5, "ffflush", "ffflush", "fast frames flushed from staging q" }, -#else - NOTPRESENT, NOTPRESENT, NOTPRESENT, NOTPRESENT, -#endif -#define S_ANT_DEFSWITCH 88 +#define S_TX_QFULL AFTER(S_FF_FLUSH) + { 5, "txqfull", "txqfull", "tx discarded 'cuz queue is full" }, +#define S_ANT_DEFSWITCH AFTER(S_TX_QFULL) { 5, "defsw", "defsw", "switched default/rx antenna" }, -#define S_ANT_TXSWITCH 89 +#define S_ANT_TXSWITCH AFTER(S_ANT_DEFSWITCH) { 5, "txsw", "txsw", "tx used alternate antenna" }, -#define S_ANT_TX0 90 +#define S_ANT_TX0 AFTER(S_ANT_TXSWITCH) { 8, "tx0", "ant0(tx)", "frames tx on antenna 0" }, -#define S_ANT_TX1 91 +#define S_ANT_TX1 AFTER(S_ANT_TX0) { 8, "tx1", "ant1(tx)", "frames tx on antenna 1" }, -#define S_ANT_TX2 92 +#define S_ANT_TX2 AFTER(S_ANT_TX1) { 8, "tx2", "ant2(tx)", "frames tx on antenna 2" }, -#define S_ANT_TX3 93 +#define S_ANT_TX3 AFTER(S_ANT_TX2) { 8, "tx3", "ant3(tx)", "frames tx on antenna 3" }, -#define S_ANT_TX4 94 +#define S_ANT_TX4 AFTER(S_ANT_TX3) { 8, "tx4", "ant4(tx)", "frames tx on antenna 4" }, -#define S_ANT_TX5 95 +#define S_ANT_TX5 AFTER(S_ANT_TX4) { 8, "tx5", "ant5(tx)", "frames tx on antenna 5" }, -#define S_ANT_TX6 96 +#define S_ANT_TX6 AFTER(S_ANT_TX5) { 8, "tx6", "ant6(tx)", "frames tx on antenna 6" }, -#define S_ANT_TX7 97 +#define S_ANT_TX7 AFTER(S_ANT_TX6) { 8, "tx7", "ant7(tx)", "frames tx on antenna 7" }, -#define S_ANT_RX0 98 +#define S_ANT_RX0 AFTER(S_ANT_TX7) { 8, "rx0", "ant0(rx)", "frames rx on antenna 0" }, -#define S_ANT_RX1 99 +#define S_ANT_RX1 AFTER(S_ANT_RX0) { 8, "rx1", "ant1(rx)", "frames rx on antenna 1" }, -#define S_ANT_RX2 100 +#define S_ANT_RX2 AFTER(S_ANT_RX1) { 8, "rx2", "ant2(rx)", "frames rx on antenna 2" }, -#define S_ANT_RX3 101 +#define S_ANT_RX3 AFTER(S_ANT_RX2) { 8, "rx3", "ant3(rx)", "frames rx on antenna 3" }, -#define S_ANT_RX4 102 +#define S_ANT_RX4 AFTER(S_ANT_RX3) { 8, "rx4", "ant4(rx)", "frames rx on antenna 4" }, -#define S_ANT_RX5 103 +#define S_ANT_RX5 AFTER(S_ANT_RX4) { 8, "rx5", "ant5(rx)", "frames rx on antenna 5" }, -#define S_ANT_RX6 104 +#define S_ANT_RX6 AFTER(S_ANT_RX5) { 8, "rx6", "ant6(rx)", "frames rx on antenna 6" }, -#define S_ANT_RX7 105 +#define S_ANT_RX7 AFTER(S_ANT_RX6) { 8, "rx7", "ant7(rx)", "frames rx on antenna 7" }, -#define S_TX_SIGNAL 106 +#define S_TX_SIGNAL AFTER(S_ANT_RX7) { 4, "asignal", "asig", "signal of last ack (dBm)" }, -#define S_RX_SIGNAL 107 +#define S_RX_SIGNAL AFTER(S_TX_SIGNAL) { 4, "signal", "sig", "avg recv signal (dBm)" }, }; #define S_PHY_MIN S_RX_PHY_UNDERRUN @@ -298,12 +300,18 @@ static const struct fmt athstats[] = { #define S_LAST S_ANT_TX0 #define S_MAX S_ANT_RX7+1 +struct _athstats { + struct ath_stats ath; +}; + struct athstatfoo_p { struct athstatfoo base; int s; + int optstats; struct ifreq ifr; - struct ath_stats cur; - struct ath_stats total; + struct ath_diag atd; + struct _athstats cur; + struct _athstats total; }; static void @@ -315,9 +323,9 @@ ath_setifname(struct athstatfoo *wf0, const char *ifname) } static void -ath_collect(struct athstatfoo_p *wf, struct ath_stats *stats) +ath_collect(struct athstatfoo_p *wf, struct _athstats *stats) { - wf->ifr.ifr_data = (caddr_t) stats; + wf->ifr.ifr_data = (caddr_t) &stats->ath; if (ioctl(wf->s, SIOCGATHSTATS, &wf->ifr) < 0) err(1, wf->ifr.ifr_name); } @@ -351,26 +359,26 @@ ath_get_curstat(struct statfoo *sf, int s, char b[], size_t bs) { struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; #define STAT(x) \ - snprintf(b, bs, "%u", wf->cur.ast_##x - wf->total.ast_##x); return 1 + snprintf(b, bs, "%u", wf->cur.ath.ast_##x - wf->total.ath.ast_##x); return 1 #define PHY(x) \ - snprintf(b, bs, "%u", wf->cur.ast_rx_phy[x] - wf->total.ast_rx_phy[x]); return 1 + snprintf(b, bs, "%u", wf->cur.ath.ast_rx_phy[x] - wf->total.ath.ast_rx_phy[x]); return 1 #define TXANT(x) \ - snprintf(b, bs, "%u", wf->cur.ast_ant_tx[x] - wf->total.ast_ant_tx[x]); return 1 + snprintf(b, bs, "%u", wf->cur.ath.ast_ant_tx[x] - wf->total.ath.ast_ant_tx[x]); return 1 #define RXANT(x) \ - snprintf(b, bs, "%u", wf->cur.ast_ant_rx[x] - wf->total.ast_ant_rx[x]); return 1 + snprintf(b, bs, "%u", wf->cur.ath.ast_ant_rx[x] - wf->total.ath.ast_ant_rx[x]); return 1 switch (s) { case S_INPUT: snprintf(b, bs, "%lu", - (wf->cur.ast_rx_packets - wf->total.ast_rx_packets) - - (wf->cur.ast_rx_mgt - wf->total.ast_rx_mgt)); + (wf->cur.ath.ast_rx_packets - wf->total.ath.ast_rx_packets) - + (wf->cur.ath.ast_rx_mgt - wf->total.ath.ast_rx_mgt)); return 1; case S_OUTPUT: snprintf(b, bs, "%lu", - wf->cur.ast_tx_packets - wf->total.ast_tx_packets); + wf->cur.ath.ast_tx_packets - wf->total.ath.ast_tx_packets); return 1; case S_RATE: - snprintf(b, bs, "%uM", wf->cur.ast_tx_rate / 2); + snprintf(b, bs, "%uM", wf->cur.ath.ast_tx_rate / 2); return 1; case S_WATCHDOG: STAT(watchdog); case S_FATAL: STAT(hardware); @@ -444,10 +452,10 @@ ath_get_curstat(struct statfoo *sf, int s, char b[], size_t bs) case S_RX_MGT: STAT(rx_mgt); case S_RX_CTL: STAT(rx_ctl); case S_TX_RSSI: - snprintf(b, bs, "%d", wf->cur.ast_tx_rssi); + snprintf(b, bs, "%d", wf->cur.ath.ast_tx_rssi); return 1; case S_RX_RSSI: - snprintf(b, bs, "%d", wf->cur.ast_rx_rssi); + snprintf(b, bs, "%d", wf->cur.ath.ast_rx_rssi); return 1; case S_BE_XMIT: STAT(be_xmit); case S_BE_NOMBUF: STAT(be_nombuf); @@ -484,22 +492,21 @@ ath_get_curstat(struct statfoo *sf, int s, char b[], size_t bs) case S_CABQ_XMIT: STAT(cabq_xmit); case S_CABQ_BUSY: STAT(cabq_busy); #endif -#ifdef S_FF_TXOK case S_FF_TXOK: STAT(ff_txok); case S_FF_TXERR: STAT(ff_txerr); + case S_FF_RX: STAT(ff_rx); case S_FF_FLUSH: STAT(ff_flush); - case S_FF_QFULL: STAT(ff_qfull); -#endif + case S_TX_QFULL: STAT(tx_qfull); case S_RX_NOISE: - snprintf(b, bs, "%d", wf->cur.ast_rx_noise); + snprintf(b, bs, "%d", wf->cur.ath.ast_rx_noise); return 1; case S_TX_SIGNAL: snprintf(b, bs, "%d", - wf->cur.ast_tx_rssi + wf->cur.ast_rx_noise); + wf->cur.ath.ast_tx_rssi + wf->cur.ath.ast_rx_noise); return 1; case S_RX_SIGNAL: snprintf(b, bs, "%d", - wf->cur.ast_rx_rssi + wf->cur.ast_rx_noise); + wf->cur.ath.ast_rx_rssi + wf->cur.ath.ast_rx_noise); return 1; } b[0] = '\0'; @@ -515,24 +522,24 @@ ath_get_totstat(struct statfoo *sf, int s, char b[], size_t bs) { struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; #define STAT(x) \ - snprintf(b, bs, "%u", wf->total.ast_##x); return 1 + snprintf(b, bs, "%u", wf->total.ath.ast_##x); return 1 #define PHY(x) \ - snprintf(b, bs, "%u", wf->total.ast_rx_phy[x]); return 1 + snprintf(b, bs, "%u", wf->total.ath.ast_rx_phy[x]); return 1 #define TXANT(x) \ - snprintf(b, bs, "%u", wf->total.ast_ant_tx[x]); return 1 + snprintf(b, bs, "%u", wf->total.ath.ast_ant_tx[x]); return 1 #define RXANT(x) \ - snprintf(b, bs, "%u", wf->total.ast_ant_rx[x]); return 1 + snprintf(b, bs, "%u", wf->total.ath.ast_ant_rx[x]); return 1 switch (s) { case S_INPUT: snprintf(b, bs, "%lu", - wf->total.ast_rx_packets - wf->total.ast_rx_mgt); + wf->total.ath.ast_rx_packets - wf->total.ath.ast_rx_mgt); return 1; case S_OUTPUT: - snprintf(b, bs, "%lu", wf->total.ast_tx_packets); + snprintf(b, bs, "%lu", wf->total.ath.ast_tx_packets); return 1; case S_RATE: - snprintf(b, bs, "%uM", wf->total.ast_tx_rate / 2); + snprintf(b, bs, "%uM", wf->total.ath.ast_tx_rate / 2); return 1; case S_WATCHDOG: STAT(watchdog); case S_FATAL: STAT(hardware); @@ -606,10 +613,10 @@ ath_get_totstat(struct statfoo *sf, int s, char b[], size_t bs) case S_RX_MGT: STAT(rx_mgt); case S_RX_CTL: STAT(rx_ctl); case S_TX_RSSI: - snprintf(b, bs, "%d", wf->total.ast_tx_rssi); + snprintf(b, bs, "%d", wf->total.ath.ast_tx_rssi); return 1; case S_RX_RSSI: - snprintf(b, bs, "%d", wf->total.ast_rx_rssi); + snprintf(b, bs, "%d", wf->total.ath.ast_rx_rssi); return 1; case S_BE_XMIT: STAT(be_xmit); case S_BE_NOMBUF: STAT(be_nombuf); @@ -646,22 +653,21 @@ ath_get_totstat(struct statfoo *sf, int s, char b[], size_t bs) case S_CABQ_XMIT: STAT(cabq_xmit); case S_CABQ_BUSY: STAT(cabq_busy); #endif -#ifdef S_FF_TXOK case S_FF_TXOK: STAT(ff_txok); case S_FF_TXERR: STAT(ff_txerr); + case S_FF_RX: STAT(ff_rx); case S_FF_FLUSH: STAT(ff_flush); - case S_FF_QFULL: STAT(ff_qfull); -#endif + case S_TX_QFULL: STAT(tx_qfull); case S_RX_NOISE: - snprintf(b, bs, "%d", wf->total.ast_rx_noise); + snprintf(b, bs, "%d", wf->total.ath.ast_rx_noise); return 1; case S_TX_SIGNAL: snprintf(b, bs, "%d", - wf->total.ast_tx_rssi + wf->total.ast_rx_noise); + wf->total.ath.ast_tx_rssi + wf->total.ath.ast_rx_noise); return 1; case S_RX_SIGNAL: snprintf(b, bs, "%d", - wf->total.ast_rx_rssi + wf->total.ast_rx_noise); + wf->total.ath.ast_rx_rssi + wf->total.ath.ast_rx_noise); return 1; } b[0] = '\0'; @@ -677,25 +683,32 @@ ath_print_verbose(struct statfoo *sf, FILE *fd) { struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; #define isphyerr(i) (S_PHY_MIN <= i && i <= S_PHY_MAX) + const struct fmt *f; char s[32]; const char *indent; - int i; + int i, width; + width = 0; + for (i = 0; i < S_LAST; i++) { + f = &sf->stats[i]; + if (!isphyerr(i) && f->width > width) + width = f->width; + } for (i = 0; i < S_LAST; i++) { if (ath_get_totstat(sf, i, s, sizeof(s)) && strcmp(s, "0")) { if (isphyerr(i)) indent = " "; else indent = ""; - fprintf(fd, "%s%s %s\n", indent, s, athstats[i].desc); + fprintf(fd, "%s%-*s %s\n", indent, width, s, athstats[i].desc); } } fprintf(fd, "Antenna profile:\n"); for (i = 0; i < 8; i++) - if (wf->total.ast_ant_rx[i] || wf->total.ast_ant_tx[i]) + if (wf->total.ath.ast_ant_rx[i] || wf->total.ath.ast_ant_tx[i]) fprintf(fd, "[%u] tx %8u rx %8u\n", i, - wf->total.ast_ant_tx[i], - wf->total.ast_ant_rx[i]); + wf->total.ath.ast_ant_tx[i], + wf->total.ath.ast_ant_rx[i]); #undef isphyerr } diff --git a/tools/tools/ath/athstats/statfoo.c b/tools/tools/ath/athstats/statfoo.c index 6827790..9963ea0 100644 --- a/tools/tools/ath/athstats/statfoo.c +++ b/tools/tools/ath/athstats/statfoo.c @@ -137,12 +137,20 @@ statfoo_print_total(struct statfoo *sf, FILE *fd) static void statfoo_print_verbose(struct statfoo *sf, FILE *fd) { + const struct fmt *f; char s[32]; - int i; + int i, width; + width = 0; + for (i = 0; i < sf->nstats; i++) { + f = &sf->stats[i]; + if (f->width > width) + width = f->width; + } for (i = 0; i < sf->nstats; i++) { + f = &sf->stats[i]; if (sf->get_totstat(sf, i, s, sizeof(s)) && strcmp(s, "0")) - fprintf(fd, "%s %s\n", s, sf->stats[i].desc); + fprintf(fd, "%-*s %s\n", width, s, f->desc); } } |