112f961f4SSam Leffler /*- 210ad9a77SSam Leffler * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 312f961f4SSam Leffler * All rights reserved. 412f961f4SSam Leffler * 512f961f4SSam Leffler * Redistribution and use in source and binary forms, with or without 612f961f4SSam Leffler * modification, are permitted provided that the following conditions 712f961f4SSam Leffler * are met: 812f961f4SSam Leffler * 1. Redistributions of source code must retain the above copyright 912f961f4SSam Leffler * notice, this list of conditions and the following disclaimer, 1012f961f4SSam Leffler * without modification. 1112f961f4SSam Leffler * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1212f961f4SSam Leffler * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 1312f961f4SSam Leffler * redistribution must be conditioned upon including a substantially 1412f961f4SSam Leffler * similar Disclaimer requirement for further binary redistribution. 1512f961f4SSam Leffler * 1612f961f4SSam Leffler * NO WARRANTY 1712f961f4SSam Leffler * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812f961f4SSam Leffler * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912f961f4SSam Leffler * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 2012f961f4SSam Leffler * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 2112f961f4SSam Leffler * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 2212f961f4SSam Leffler * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2312f961f4SSam Leffler * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2412f961f4SSam Leffler * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 2512f961f4SSam Leffler * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2612f961f4SSam Leffler * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 2712f961f4SSam Leffler * THE POSSIBILITY OF SUCH DAMAGES. 2812f961f4SSam Leffler * 2912f961f4SSam Leffler * $FreeBSD$ 3012f961f4SSam Leffler */ 3112f961f4SSam Leffler 3212f961f4SSam Leffler /* 332f549d72SSam Leffler * ath statistics class. 3412f961f4SSam Leffler */ 3512f961f4SSam Leffler #include <sys/types.h> 3612f961f4SSam Leffler #include <sys/file.h> 3712f961f4SSam Leffler #include <sys/sockio.h> 3812f961f4SSam Leffler #include <sys/socket.h> 3912f961f4SSam Leffler #include <net/if.h> 4012f961f4SSam Leffler #include <net/if_media.h> 4112f961f4SSam Leffler #include <net/if_var.h> 4212f961f4SSam Leffler 4312f961f4SSam Leffler #include <stdio.h> 44207ae002SSam Leffler #include <stdlib.h> 4512f961f4SSam Leffler #include <signal.h> 462f549d72SSam Leffler #include <string.h> 472f549d72SSam Leffler #include <unistd.h> 482f549d72SSam Leffler #include <err.h> 4912f961f4SSam Leffler 50207ae002SSam Leffler #include "ah.h" 51207ae002SSam Leffler #include "ah_desc.h" 52207ae002SSam Leffler #include "ieee80211_ioctl.h" 53207ae002SSam Leffler #include "ieee80211_radiotap.h" 54207ae002SSam Leffler #include "if_athioctl.h" 5512f961f4SSam Leffler 562f549d72SSam Leffler #include "athstats.h" 572f549d72SSam Leffler 584d490647SSam Leffler #ifdef ATH_SUPPORT_ANI 594d490647SSam Leffler #define HAL_EP_RND(x,mul) \ 604d490647SSam Leffler ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul)) 614d490647SSam Leffler #define HAL_RSSI(x) HAL_EP_RND(x, HAL_RSSI_EP_MULTIPLIER) 624d490647SSam Leffler #endif 634d490647SSam Leffler 642f549d72SSam Leffler #define NOTPRESENT { 0, "", "" } 652f549d72SSam Leffler 66207ae002SSam Leffler #define AFTER(prev) ((prev)+1) 67207ae002SSam Leffler 682f549d72SSam Leffler static const struct fmt athstats[] = { 692f549d72SSam Leffler #define S_INPUT 0 7095d7bf0fSSam Leffler { 8, "input", "input", "data frames received" }, 71207ae002SSam Leffler #define S_OUTPUT AFTER(S_INPUT) 7295d7bf0fSSam Leffler { 8, "output", "output", "data frames transmit" }, 73207ae002SSam Leffler #define S_TX_ALTRATE AFTER(S_OUTPUT) 742f549d72SSam Leffler { 7, "altrate", "altrate", "tx frames with an alternate rate" }, 75207ae002SSam Leffler #define S_TX_SHORTRETRY AFTER(S_TX_ALTRATE) 7695d7bf0fSSam Leffler { 7, "short", "short", "short on-chip tx retries" }, 77207ae002SSam Leffler #define S_TX_LONGRETRY AFTER(S_TX_SHORTRETRY) 7895d7bf0fSSam Leffler { 7, "long", "long", "long on-chip tx retries" }, 79207ae002SSam Leffler #define S_TX_XRETRIES AFTER(S_TX_LONGRETRY) 802f549d72SSam Leffler { 6, "xretry", "xretry", "tx failed 'cuz too many retries" }, 81207ae002SSam Leffler #define S_MIB AFTER(S_TX_XRETRIES) 822f549d72SSam Leffler { 5, "mib", "mib", "mib overflow interrupts" }, 832f549d72SSam Leffler #ifndef __linux__ 84207ae002SSam Leffler #define S_TX_LINEAR AFTER(S_MIB) 852f549d72SSam Leffler { 5, "txlinear", "txlinear", "tx linearized to cluster" }, 86207ae002SSam Leffler #define S_BSTUCK AFTER(S_TX_LINEAR) 872f549d72SSam Leffler { 5, "bstuck", "bstuck", "stuck beacon conditions" }, 88207ae002SSam Leffler #define S_INTRCOAL AFTER(S_BSTUCK) 892f549d72SSam Leffler { 5, "intrcoal", "intrcoal", "interrupts coalesced" }, 90207ae002SSam Leffler #define S_RATE AFTER(S_INTRCOAL) 912f549d72SSam Leffler #else 92207ae002SSam Leffler #define S_RATE AFTER(S_MIB) 932f549d72SSam Leffler #endif 944d490647SSam Leffler { 5, "rate", "rate", "current transmit rate" }, 95207ae002SSam Leffler #define S_WATCHDOG AFTER(S_RATE) 962f549d72SSam Leffler { 5, "wdog", "wdog", "watchdog timeouts" }, 97207ae002SSam Leffler #define S_FATAL AFTER(S_WATCHDOG) 982f549d72SSam Leffler { 5, "fatal", "fatal", "hardware error interrupts" }, 99207ae002SSam Leffler #define S_BMISS AFTER(S_FATAL) 1002f549d72SSam Leffler { 5, "bmiss", "bmiss", "beacon miss interrupts" }, 101207ae002SSam Leffler #define S_RXORN AFTER(S_BMISS) 1022f549d72SSam Leffler { 5, "rxorn", "rxorn", "recv overrun interrupts" }, 103207ae002SSam Leffler #define S_RXEOL AFTER(S_RXORN) 1042f549d72SSam Leffler { 5, "rxeol", "rxeol", "recv eol interrupts" }, 105207ae002SSam Leffler #define S_TXURN AFTER(S_RXEOL) 1062f549d72SSam Leffler { 5, "txurn", "txurn", "txmit underrun interrupts" }, 107207ae002SSam Leffler #define S_TX_MGMT AFTER(S_TXURN) 1082f549d72SSam Leffler { 5, "txmgt", "txmgt", "tx management frames" }, 109207ae002SSam Leffler #define S_TX_DISCARD AFTER(S_TX_MGMT) 1102f549d72SSam Leffler { 5, "txdisc", "txdisc", "tx frames discarded prior to association" }, 111207ae002SSam Leffler #define S_TX_INVALID AFTER(S_TX_DISCARD) 1122f549d72SSam Leffler { 5, "txinv", "txinv", "tx invalid (19)" }, 113207ae002SSam Leffler #define S_TX_QSTOP AFTER(S_TX_INVALID) 1142f549d72SSam Leffler { 5, "qstop", "qstop", "tx stopped 'cuz no xmit buffer" }, 115207ae002SSam Leffler #define S_TX_ENCAP AFTER(S_TX_QSTOP) 1162f549d72SSam Leffler { 5, "txencode", "txencode", "tx encapsulation failed" }, 117207ae002SSam Leffler #define S_TX_NONODE AFTER(S_TX_ENCAP) 1182f549d72SSam Leffler { 5, "txnonode", "txnonode", "tx failed 'cuz no node" }, 11941e449dbSSam Leffler #define S_TX_NOBUF AFTER(S_TX_NONODE) 12041e449dbSSam Leffler { 5, "txnobuf", "txnobuf", "tx failed 'cuz dma buffer allocation failed" }, 12141e449dbSSam Leffler #define S_TX_NOFRAG AFTER(S_TX_NOBUF) 12241e449dbSSam Leffler { 5, "txnofrag", "txnofrag", "tx failed 'cuz frag buffer allocation(s) failed" }, 12341e449dbSSam Leffler #define S_TX_NOMBUF AFTER(S_TX_NOFRAG) 1242f549d72SSam Leffler { 5, "txnombuf", "txnombuf", "tx failed 'cuz mbuf allocation failed" }, 1252f549d72SSam Leffler #ifndef __linux__ 126207ae002SSam Leffler #define S_TX_NOMCL AFTER(S_TX_NOMBUF) 1272f549d72SSam Leffler { 5, "txnomcl", "txnomcl", "tx failed 'cuz cluster allocation failed" }, 128207ae002SSam Leffler #define S_TX_FIFOERR AFTER(S_TX_NOMCL) 1292f549d72SSam Leffler #else 130207ae002SSam Leffler #define S_TX_FIFOERR AFTER(S_TX_NOMBUF) 1312f549d72SSam Leffler #endif 1322f549d72SSam Leffler { 5, "efifo", "efifo", "tx failed 'cuz FIFO underrun" }, 133207ae002SSam Leffler #define S_TX_FILTERED AFTER(S_TX_FIFOERR) 1342f549d72SSam Leffler { 5, "efilt", "efilt", "tx failed 'cuz destination filtered" }, 135207ae002SSam Leffler #define S_TX_BADRATE AFTER(S_TX_FILTERED) 1362f549d72SSam Leffler { 5, "txbadrate", "txbadrate", "tx failed 'cuz bogus xmit rate" }, 137207ae002SSam Leffler #define S_TX_NOACK AFTER(S_TX_BADRATE) 1382f549d72SSam Leffler { 5, "noack", "noack", "tx frames with no ack marked" }, 139207ae002SSam Leffler #define S_TX_RTS AFTER(S_TX_NOACK) 1402f549d72SSam Leffler { 5, "rts", "rts", "tx frames with rts enabled" }, 141207ae002SSam Leffler #define S_TX_CTS AFTER(S_TX_RTS) 1422f549d72SSam Leffler { 5, "cts", "cts", "tx frames with cts enabled" }, 143207ae002SSam Leffler #define S_TX_SHORTPRE AFTER(S_TX_CTS) 1442f549d72SSam Leffler { 5, "shpre", "shpre", "tx frames with short preamble" }, 145207ae002SSam Leffler #define S_TX_PROTECT AFTER(S_TX_SHORTPRE) 1462f549d72SSam Leffler { 5, "protect", "protect", "tx frames with 11g protection" }, 147207ae002SSam Leffler #define S_RX_ORN AFTER(S_TX_PROTECT) 1482f549d72SSam Leffler { 5, "rxorn", "rxorn", "rx failed 'cuz of desc overrun" }, 149207ae002SSam Leffler #define S_RX_CRC_ERR AFTER(S_RX_ORN) 1502f549d72SSam Leffler { 6, "crcerr", "crcerr", "rx failed 'cuz of bad CRC" }, 151207ae002SSam Leffler #define S_RX_FIFO_ERR AFTER(S_RX_CRC_ERR) 1522f549d72SSam Leffler { 5, "rxfifo", "rxfifo", "rx failed 'cuz of FIFO overrun" }, 153207ae002SSam Leffler #define S_RX_CRYPTO_ERR AFTER(S_RX_FIFO_ERR) 1542f549d72SSam Leffler { 5, "crypt", "crypt", "rx failed 'cuz decryption" }, 155207ae002SSam Leffler #define S_RX_MIC_ERR AFTER(S_RX_CRYPTO_ERR) 1562f549d72SSam Leffler { 4, "mic", "mic", "rx failed 'cuz MIC failure" }, 157207ae002SSam Leffler #define S_RX_TOOSHORT AFTER(S_RX_MIC_ERR) 1582f549d72SSam Leffler { 5, "rxshort", "rxshort", "rx failed 'cuz frame too short" }, 159207ae002SSam Leffler #define S_RX_NOMBUF AFTER(S_RX_TOOSHORT) 1602f549d72SSam Leffler { 5, "rxnombuf", "rxnombuf", "rx setup failed 'cuz no mbuf" }, 161207ae002SSam Leffler #define S_RX_MGT AFTER(S_RX_NOMBUF) 1622f549d72SSam Leffler { 5, "rxmgt", "rxmgt", "rx management frames" }, 163207ae002SSam Leffler #define S_RX_CTL AFTER(S_RX_MGT) 1642f549d72SSam Leffler { 5, "rxctl", "rxctl", "rx control frames" }, 165207ae002SSam Leffler #define S_RX_PHY_ERR AFTER(S_RX_CTL) 1662f549d72SSam Leffler { 7, "phyerr", "phyerr", "rx failed 'cuz of PHY err" }, 167207ae002SSam Leffler #define S_RX_PHY_UNDERRUN AFTER(S_RX_PHY_ERR) 1684d490647SSam Leffler { 4, "phyund", "TUnd", "transmit underrun" }, 169207ae002SSam Leffler #define S_RX_PHY_TIMING AFTER(S_RX_PHY_UNDERRUN) 1704d490647SSam Leffler { 4, "phytim", "Tim", "timing error" }, 171207ae002SSam Leffler #define S_RX_PHY_PARITY AFTER(S_RX_PHY_TIMING) 1724d490647SSam Leffler { 4, "phypar", "IPar", "illegal parity" }, 173207ae002SSam Leffler #define S_RX_PHY_RATE AFTER(S_RX_PHY_PARITY) 1744d490647SSam Leffler { 4, "phyrate", "IRate", "illegal rate" }, 175207ae002SSam Leffler #define S_RX_PHY_LENGTH AFTER(S_RX_PHY_RATE) 1764d490647SSam Leffler { 4, "phylen", "ILen", "illegal length" }, 177207ae002SSam Leffler #define S_RX_PHY_RADAR AFTER(S_RX_PHY_LENGTH) 1784d490647SSam Leffler { 4, "phyradar", "Radar", "radar detect" }, 179207ae002SSam Leffler #define S_RX_PHY_SERVICE AFTER(S_RX_PHY_RADAR) 1804d490647SSam Leffler { 4, "physervice", "Service", "illegal service" }, 181207ae002SSam Leffler #define S_RX_PHY_TOR AFTER(S_RX_PHY_SERVICE) 1824d490647SSam Leffler { 4, "phytor", "TOR", "transmit override receive" }, 183207ae002SSam Leffler #define S_RX_PHY_OFDM_TIMING AFTER(S_RX_PHY_TOR) 1842f549d72SSam Leffler { 6, "ofdmtim", "ofdmtim", "OFDM timing" }, 185207ae002SSam Leffler #define S_RX_PHY_OFDM_SIGNAL_PARITY AFTER(S_RX_PHY_OFDM_TIMING) 1862f549d72SSam Leffler { 6, "ofdmsig", "ofdmsig", "OFDM illegal parity" }, 187207ae002SSam Leffler #define S_RX_PHY_OFDM_RATE_ILLEGAL AFTER(S_RX_PHY_OFDM_SIGNAL_PARITY) 1882f549d72SSam Leffler { 6, "ofdmrate", "ofdmrate", "OFDM illegal rate" }, 189207ae002SSam Leffler #define S_RX_PHY_OFDM_POWER_DROP AFTER(S_RX_PHY_OFDM_RATE_ILLEGAL) 1902f549d72SSam Leffler { 6, "ofdmpow", "ofdmpow", "OFDM power drop" }, 191207ae002SSam Leffler #define S_RX_PHY_OFDM_SERVICE AFTER(S_RX_PHY_OFDM_POWER_DROP) 1922f549d72SSam Leffler { 6, "ofdmservice", "ofdmservice", "OFDM illegal service" }, 193207ae002SSam Leffler #define S_RX_PHY_OFDM_RESTART AFTER(S_RX_PHY_OFDM_SERVICE) 1942f549d72SSam Leffler { 6, "ofdmrestart", "ofdmrestart", "OFDM restart" }, 195207ae002SSam Leffler #define S_RX_PHY_CCK_TIMING AFTER(S_RX_PHY_OFDM_RESTART) 1962f549d72SSam Leffler { 6, "ccktim", "ccktim", "CCK timing" }, 197207ae002SSam Leffler #define S_RX_PHY_CCK_HEADER_CRC AFTER(S_RX_PHY_CCK_TIMING) 1982f549d72SSam Leffler { 6, "cckhead", "cckhead", "CCK header crc" }, 199207ae002SSam Leffler #define S_RX_PHY_CCK_RATE_ILLEGAL AFTER(S_RX_PHY_CCK_HEADER_CRC) 2002f549d72SSam Leffler { 6, "cckrate", "cckrate", "CCK illegal rate" }, 201207ae002SSam Leffler #define S_RX_PHY_CCK_SERVICE AFTER(S_RX_PHY_CCK_RATE_ILLEGAL) 2022f549d72SSam Leffler { 6, "cckservice", "cckservice", "CCK illegal service" }, 203207ae002SSam Leffler #define S_RX_PHY_CCK_RESTART AFTER(S_RX_PHY_CCK_SERVICE) 2042f549d72SSam Leffler { 6, "cckrestar", "cckrestar", "CCK restart" }, 205207ae002SSam Leffler #define S_BE_NOMBUF AFTER(S_RX_PHY_CCK_RESTART) 2062f549d72SSam Leffler { 4, "benombuf", "benombuf", "beacon setup failed 'cuz no mbuf" }, 207207ae002SSam Leffler #define S_BE_XMIT AFTER(S_BE_NOMBUF) 20895d7bf0fSSam Leffler { 7, "bexmit", "bexmit", "beacons transmitted" }, 209207ae002SSam Leffler #define S_PER_CAL AFTER(S_BE_XMIT) 2102f549d72SSam Leffler { 4, "pcal", "pcal", "periodic calibrations" }, 211207ae002SSam Leffler #define S_PER_CALFAIL AFTER(S_PER_CAL) 2122f549d72SSam Leffler { 4, "pcalf", "pcalf", "periodic calibration failures" }, 213207ae002SSam Leffler #define S_PER_RFGAIN AFTER(S_PER_CALFAIL) 2142f549d72SSam Leffler { 4, "prfga", "prfga", "rfgain value change" }, 215207ae002SSam Leffler #if ATH_SUPPORT_TDMA 216207ae002SSam Leffler #define S_TDMA_UPDATE AFTER(S_PER_RFGAIN) 21795d7bf0fSSam Leffler { 5, "tdmau", "tdmau", "TDMA slot timing updates" }, 218207ae002SSam Leffler #define S_TDMA_TIMERS AFTER(S_TDMA_UPDATE) 21995d7bf0fSSam Leffler { 5, "tdmab", "tdmab", "TDMA slot update set beacon timers" }, 220207ae002SSam Leffler #define S_TDMA_TSF AFTER(S_TDMA_TIMERS) 22195d7bf0fSSam Leffler { 5, "tdmat", "tdmat", "TDMA slot update set TSF" }, 22210ad9a77SSam Leffler #define S_TDMA_TSFADJ AFTER(S_TDMA_TSF) 22395d7bf0fSSam Leffler { 8, "tdmadj", "tdmadj", "TDMA slot adjust (usecs, smoothed)" }, 224cc5912f8SSam Leffler #define S_TDMA_ACK AFTER(S_TDMA_TSFADJ) 225cc5912f8SSam Leffler { 5, "tdmack", "tdmack", "TDMA tx failed 'cuz ACK required" }, 226cc5912f8SSam Leffler #define S_RATE_CALLS AFTER(S_TDMA_ACK) 2272f549d72SSam Leffler #else 228207ae002SSam Leffler #define S_RATE_CALLS AFTER(S_PER_RFGAIN) 2292f549d72SSam Leffler #endif 2302f549d72SSam Leffler { 5, "ratec", "ratec", "rate control checks" }, 231207ae002SSam Leffler #define S_RATE_RAISE AFTER(S_RATE_CALLS) 2322f549d72SSam Leffler { 5, "rate+", "rate+", "rate control raised xmit rate" }, 233207ae002SSam Leffler #define S_RATE_DROP AFTER(S_RATE_RAISE) 2342f549d72SSam Leffler { 5, "rate-", "rate-", "rate control dropped xmit rate" }, 235207ae002SSam Leffler #define S_TX_RSSI AFTER(S_RATE_DROP) 2362f549d72SSam Leffler { 4, "arssi", "arssi", "rssi of last ack" }, 237207ae002SSam Leffler #define S_RX_RSSI AFTER(S_TX_RSSI) 2382f549d72SSam Leffler { 4, "rssi", "rssi", "avg recv rssi" }, 239207ae002SSam Leffler #define S_RX_NOISE AFTER(S_RX_RSSI) 2402f549d72SSam Leffler { 5, "noise", "noise", "rx noise floor" }, 241207ae002SSam Leffler #define S_BMISS_PHANTOM AFTER(S_RX_NOISE) 2422f549d72SSam Leffler { 5, "bmissphantom", "bmissphantom", "phantom beacon misses" }, 243207ae002SSam Leffler #define S_TX_RAW AFTER(S_BMISS_PHANTOM) 2442f549d72SSam Leffler { 5, "txraw", "txraw", "tx frames through raw api" }, 245cc5912f8SSam Leffler #define S_TX_RAW_FAIL AFTER(S_TX_RAW) 246cc5912f8SSam Leffler { 5, "txrawfail", "txrawfail", "raw tx failed 'cuz interface/hw down" }, 247cc5912f8SSam Leffler #define S_RX_TOOBIG AFTER(S_TX_RAW_FAIL) 2482f549d72SSam Leffler { 5, "rx2big", "rx2big", "rx failed 'cuz frame too large" }, 2492f549d72SSam Leffler #ifndef __linux__ 250207ae002SSam Leffler #define S_CABQ_XMIT AFTER(S_RX_TOOBIG) 2512f549d72SSam Leffler { 5, "cabxmit", "cabxmit", "cabq frames transmitted" }, 252207ae002SSam Leffler #define S_CABQ_BUSY AFTER(S_CABQ_XMIT) 2532f549d72SSam Leffler { 5, "cabqbusy", "cabqbusy", "cabq xmit overflowed beacon interval" }, 254207ae002SSam Leffler #define S_TX_NODATA AFTER(S_CABQ_BUSY) 2552f549d72SSam Leffler { 5, "txnodata", "txnodata", "tx discarded empty frame" }, 256207ae002SSam Leffler #define S_TX_BUSDMA AFTER(S_TX_NODATA) 2572f549d72SSam Leffler { 5, "txbusdma", "txbusdma", "tx failed for dma resrcs" }, 258207ae002SSam Leffler #define S_RX_BUSDMA AFTER(S_TX_BUSDMA) 2592f549d72SSam Leffler { 5, "rxbusdma", "rxbusdma", "rx setup failed for dma resrcs" }, 260207ae002SSam Leffler #define S_FF_TXOK AFTER(S_RX_BUSDMA) 2612f549d72SSam Leffler #else 262207ae002SSam Leffler #define S_FF_TXOK AFTER(S_RX_PHY_UNDERRUN) 2632f549d72SSam Leffler #endif 2642f549d72SSam Leffler { 5, "fftxok", "fftxok", "fast frames xmit successfully" }, 265207ae002SSam Leffler #define S_FF_TXERR AFTER(S_FF_TXOK) 2662f549d72SSam Leffler { 5, "fftxerr", "fftxerr", "fast frames not xmit due to error" }, 267207ae002SSam Leffler #define S_FF_RX AFTER(S_FF_TXERR) 2682f549d72SSam Leffler { 5, "ffrx", "ffrx", "fast frames received" }, 269207ae002SSam Leffler #define S_FF_FLUSH AFTER(S_FF_RX) 2702f549d72SSam Leffler { 5, "ffflush", "ffflush", "fast frames flushed from staging q" }, 271207ae002SSam Leffler #define S_TX_QFULL AFTER(S_FF_FLUSH) 272207ae002SSam Leffler { 5, "txqfull", "txqfull", "tx discarded 'cuz queue is full" }, 273207ae002SSam Leffler #define S_ANT_DEFSWITCH AFTER(S_TX_QFULL) 2742f549d72SSam Leffler { 5, "defsw", "defsw", "switched default/rx antenna" }, 275207ae002SSam Leffler #define S_ANT_TXSWITCH AFTER(S_ANT_DEFSWITCH) 2762f549d72SSam Leffler { 5, "txsw", "txsw", "tx used alternate antenna" }, 2774d490647SSam Leffler #ifdef ATH_SUPPORT_ANI 2784d490647SSam Leffler #define S_ANI_NOISE AFTER(S_ANT_TXSWITCH) 2794d490647SSam Leffler { 2, "ni", "NI", "noise immunity level" }, 2804d490647SSam Leffler #define S_ANI_SPUR AFTER(S_ANI_NOISE) 2814d490647SSam Leffler { 2, "si", "SI", "spur immunity level" }, 2824d490647SSam Leffler #define S_ANI_STEP AFTER(S_ANI_SPUR) 2834d490647SSam Leffler { 2, "step", "ST", "first step level" }, 2844d490647SSam Leffler #define S_ANI_OFDM AFTER(S_ANI_STEP) 2854d490647SSam Leffler { 4, "owsd", "OWSD", "OFDM weak signal detect" }, 2864d490647SSam Leffler #define S_ANI_CCK AFTER(S_ANI_OFDM) 2874d490647SSam Leffler { 4, "cwst", "CWST", "CCK weak signal threshold" }, 2884d490647SSam Leffler #define S_ANI_MAXSPUR AFTER(S_ANI_CCK) 2894d490647SSam Leffler { 3, "maxsi","MSI", "max spur immunity level" }, 2904d490647SSam Leffler #define S_ANI_LISTEN AFTER(S_ANI_MAXSPUR) 2914d490647SSam Leffler { 6, "listen","LISTEN", "listen time" }, 2924d490647SSam Leffler #define S_ANI_NIUP AFTER(S_ANI_LISTEN) 2934d490647SSam Leffler { 4, "ni+", "NI-", "ANI increased noise immunity" }, 2944d490647SSam Leffler #define S_ANI_NIDOWN AFTER(S_ANI_NIUP) 2954d490647SSam Leffler { 4, "ni-", "NI-", "ANI decrease noise immunity" }, 2964d490647SSam Leffler #define S_ANI_SIUP AFTER(S_ANI_NIDOWN) 2974d490647SSam Leffler { 4, "si+", "SI+", "ANI increased spur immunity" }, 2984d490647SSam Leffler #define S_ANI_SIDOWN AFTER(S_ANI_SIUP) 2994d490647SSam Leffler { 4, "si-", "SI-", "ANI decrease spur immunity" }, 3004d490647SSam Leffler #define S_ANI_OFDMON AFTER(S_ANI_SIDOWN) 3014d490647SSam Leffler { 5, "ofdm+","OFDM+", "ANI enabled OFDM weak signal detect" }, 3024d490647SSam Leffler #define S_ANI_OFDMOFF AFTER(S_ANI_OFDMON) 3034d490647SSam Leffler { 5, "ofdm-","OFDM-", "ANI disabled OFDM weak signal detect" }, 3044d490647SSam Leffler #define S_ANI_CCKHI AFTER(S_ANI_OFDMOFF) 3054d490647SSam Leffler { 5, "cck+", "CCK+", "ANI enabled CCK weak signal threshold" }, 3064d490647SSam Leffler #define S_ANI_CCKLO AFTER(S_ANI_CCKHI) 3074d490647SSam Leffler { 5, "cck-", "CCK-", "ANI disabled CCK weak signal threshold" }, 3084d490647SSam Leffler #define S_ANI_STEPUP AFTER(S_ANI_CCKLO) 3094d490647SSam Leffler { 5, "step+","STEP+", "ANI increased first step level" }, 3104d490647SSam Leffler #define S_ANI_STEPDOWN AFTER(S_ANI_STEPUP) 3114d490647SSam Leffler { 5, "step-","STEP-", "ANI decreased first step level" }, 3124d490647SSam Leffler #define S_ANI_OFDMERRS AFTER(S_ANI_STEPDOWN) 31395d7bf0fSSam Leffler { 8, "ofdm", "OFDM", "cumulative OFDM phy error count" }, 3144d490647SSam Leffler #define S_ANI_CCKERRS AFTER(S_ANI_OFDMERRS) 31595d7bf0fSSam Leffler { 8, "cck", "CCK", "cumulative CCK phy error count" }, 3164d490647SSam Leffler #define S_ANI_RESET AFTER(S_ANI_CCKERRS) 3174d490647SSam Leffler { 5, "reset","RESET", "ANI parameters zero'd for non-STA operation" }, 3184d490647SSam Leffler #define S_ANI_LZERO AFTER(S_ANI_RESET) 3194d490647SSam Leffler { 5, "lzero","LZERO", "ANI forced listen time to zero" }, 3204d490647SSam Leffler #define S_ANI_LNEG AFTER(S_ANI_LZERO) 3214d490647SSam Leffler { 5, "lneg", "LNEG", "ANI calculated listen time < 0" }, 3224d490647SSam Leffler #define S_MIB_ACKBAD AFTER(S_ANI_LNEG) 32395d7bf0fSSam Leffler { 5, "ackbad","ACKBAD", "missing ACK's" }, 3244d490647SSam Leffler #define S_MIB_RTSBAD AFTER(S_MIB_ACKBAD) 32595d7bf0fSSam Leffler { 5, "rtsbad","RTSBAD", "RTS without CTS" }, 3264d490647SSam Leffler #define S_MIB_RTSGOOD AFTER(S_MIB_RTSBAD) 32795d7bf0fSSam Leffler { 5, "rtsgood","RTSGOOD", "successful RTS" }, 3284d490647SSam Leffler #define S_MIB_FCSBAD AFTER(S_MIB_RTSGOOD) 32995d7bf0fSSam Leffler { 5, "fcsbad","FCSBAD", "bad FCS" }, 3304d490647SSam Leffler #define S_MIB_BEACONS AFTER(S_MIB_FCSBAD) 33195d7bf0fSSam Leffler { 5, "beacons","beacons", "beacons received" }, 3324d490647SSam Leffler #define S_NODE_AVGBRSSI AFTER(S_MIB_BEACONS) 3334d490647SSam Leffler { 3, "avgbrssi","BSI", "average rssi (beacons only)" }, 3344d490647SSam Leffler #define S_NODE_AVGRSSI AFTER(S_NODE_AVGBRSSI) 3354d490647SSam Leffler { 3, "avgrssi","DSI", "average rssi (all rx'd frames)" }, 3364d490647SSam Leffler #define S_NODE_AVGARSSI AFTER(S_NODE_AVGRSSI) 3374d490647SSam Leffler { 3, "avgtxrssi","TSI", "average rssi (ACKs only)" }, 3384d490647SSam Leffler #define S_ANT_TX0 AFTER(S_NODE_AVGARSSI) 3394d490647SSam Leffler #else 340207ae002SSam Leffler #define S_ANT_TX0 AFTER(S_ANT_TXSWITCH) 3414d490647SSam Leffler #endif /* ATH_SUPPORT_ANI */ 34295d7bf0fSSam Leffler { 8, "tx0", "ant0(tx)", "frames tx on antenna 0" }, 343207ae002SSam Leffler #define S_ANT_TX1 AFTER(S_ANT_TX0) 34495d7bf0fSSam Leffler { 8, "tx1", "ant1(tx)", "frames tx on antenna 1" }, 345207ae002SSam Leffler #define S_ANT_TX2 AFTER(S_ANT_TX1) 34695d7bf0fSSam Leffler { 8, "tx2", "ant2(tx)", "frames tx on antenna 2" }, 347207ae002SSam Leffler #define S_ANT_TX3 AFTER(S_ANT_TX2) 34895d7bf0fSSam Leffler { 8, "tx3", "ant3(tx)", "frames tx on antenna 3" }, 349207ae002SSam Leffler #define S_ANT_TX4 AFTER(S_ANT_TX3) 35095d7bf0fSSam Leffler { 8, "tx4", "ant4(tx)", "frames tx on antenna 4" }, 351207ae002SSam Leffler #define S_ANT_TX5 AFTER(S_ANT_TX4) 35295d7bf0fSSam Leffler { 8, "tx5", "ant5(tx)", "frames tx on antenna 5" }, 353207ae002SSam Leffler #define S_ANT_TX6 AFTER(S_ANT_TX5) 35495d7bf0fSSam Leffler { 8, "tx6", "ant6(tx)", "frames tx on antenna 6" }, 355207ae002SSam Leffler #define S_ANT_TX7 AFTER(S_ANT_TX6) 35695d7bf0fSSam Leffler { 8, "tx7", "ant7(tx)", "frames tx on antenna 7" }, 357207ae002SSam Leffler #define S_ANT_RX0 AFTER(S_ANT_TX7) 35895d7bf0fSSam Leffler { 8, "rx0", "ant0(rx)", "frames rx on antenna 0" }, 359207ae002SSam Leffler #define S_ANT_RX1 AFTER(S_ANT_RX0) 36095d7bf0fSSam Leffler { 8, "rx1", "ant1(rx)", "frames rx on antenna 1" }, 361207ae002SSam Leffler #define S_ANT_RX2 AFTER(S_ANT_RX1) 36295d7bf0fSSam Leffler { 8, "rx2", "ant2(rx)", "frames rx on antenna 2" }, 363207ae002SSam Leffler #define S_ANT_RX3 AFTER(S_ANT_RX2) 36495d7bf0fSSam Leffler { 8, "rx3", "ant3(rx)", "frames rx on antenna 3" }, 365207ae002SSam Leffler #define S_ANT_RX4 AFTER(S_ANT_RX3) 36695d7bf0fSSam Leffler { 8, "rx4", "ant4(rx)", "frames rx on antenna 4" }, 367207ae002SSam Leffler #define S_ANT_RX5 AFTER(S_ANT_RX4) 36895d7bf0fSSam Leffler { 8, "rx5", "ant5(rx)", "frames rx on antenna 5" }, 369207ae002SSam Leffler #define S_ANT_RX6 AFTER(S_ANT_RX5) 37095d7bf0fSSam Leffler { 8, "rx6", "ant6(rx)", "frames rx on antenna 6" }, 371207ae002SSam Leffler #define S_ANT_RX7 AFTER(S_ANT_RX6) 37295d7bf0fSSam Leffler { 8, "rx7", "ant7(rx)", "frames rx on antenna 7" }, 373207ae002SSam Leffler #define S_TX_SIGNAL AFTER(S_ANT_RX7) 3742f549d72SSam Leffler { 4, "asignal", "asig", "signal of last ack (dBm)" }, 375207ae002SSam Leffler #define S_RX_SIGNAL AFTER(S_TX_SIGNAL) 3762f549d72SSam Leffler { 4, "signal", "sig", "avg recv signal (dBm)" }, 37712f961f4SSam Leffler }; 3782f549d72SSam Leffler #define S_PHY_MIN S_RX_PHY_UNDERRUN 3792f549d72SSam Leffler #define S_PHY_MAX S_RX_PHY_CCK_RESTART 3802f549d72SSam Leffler #define S_LAST S_ANT_TX0 3812f549d72SSam Leffler #define S_MAX S_ANT_RX7+1 38212f961f4SSam Leffler 383207ae002SSam Leffler struct _athstats { 384207ae002SSam Leffler struct ath_stats ath; 3854d490647SSam Leffler #ifdef ATH_SUPPORT_ANI 3864d490647SSam Leffler struct { 3874d490647SSam Leffler uint32_t ast_ani_niup; /* increased noise immunity */ 3884d490647SSam Leffler uint32_t ast_ani_nidown; /* decreased noise immunity */ 3894d490647SSam Leffler uint32_t ast_ani_spurup; /* increased spur immunity */ 3904d490647SSam Leffler uint32_t ast_ani_spurdown; /* descreased spur immunity */ 3914d490647SSam Leffler uint32_t ast_ani_ofdmon; /* OFDM weak signal detect on */ 3924d490647SSam Leffler uint32_t ast_ani_ofdmoff; /* OFDM weak signal detect off*/ 3934d490647SSam Leffler uint32_t ast_ani_cckhigh; /* CCK weak signal thr high */ 3944d490647SSam Leffler uint32_t ast_ani_ccklow; /* CCK weak signal thr low */ 3954d490647SSam Leffler uint32_t ast_ani_stepup; /* increased first step level */ 3964d490647SSam Leffler uint32_t ast_ani_stepdown; /* decreased first step level */ 3974d490647SSam Leffler uint32_t ast_ani_ofdmerrs; /* cumulative ofdm phy err cnt*/ 3984d490647SSam Leffler uint32_t ast_ani_cckerrs; /* cumulative cck phy err cnt */ 3994d490647SSam Leffler uint32_t ast_ani_reset; /* params zero'd for non-STA */ 4004d490647SSam Leffler uint32_t ast_ani_lzero; /* listen time forced to zero */ 4014d490647SSam Leffler uint32_t ast_ani_lneg; /* listen time calculated < 0 */ 4024d490647SSam Leffler HAL_MIB_STATS ast_mibstats; /* MIB counter stats */ 4034d490647SSam Leffler HAL_NODE_STATS ast_nodestats; /* latest rssi stats */ 4044d490647SSam Leffler } ani_stats; 4054d490647SSam Leffler struct { 4064d490647SSam Leffler uint8_t noiseImmunityLevel; 4074d490647SSam Leffler uint8_t spurImmunityLevel; 4084d490647SSam Leffler uint8_t firstepLevel; 4094d490647SSam Leffler uint8_t ofdmWeakSigDetectOff; 41004fc88d5SSam Leffler uint8_t cckWeakSigThreshold; 4114d490647SSam Leffler uint32_t listenTime; 4124d490647SSam Leffler } ani_state; 4134d490647SSam Leffler #endif 414207ae002SSam Leffler }; 415207ae002SSam Leffler 4162f549d72SSam Leffler struct athstatfoo_p { 4172f549d72SSam Leffler struct athstatfoo base; 41812f961f4SSam Leffler int s; 419207ae002SSam Leffler int optstats; 4204d490647SSam Leffler #define ATHSTATS_ANI 0x0001 42112f961f4SSam Leffler struct ifreq ifr; 422207ae002SSam Leffler struct ath_diag atd; 423207ae002SSam Leffler struct _athstats cur; 424207ae002SSam Leffler struct _athstats total; 4252f549d72SSam Leffler }; 42612f961f4SSam Leffler 4272f549d72SSam Leffler static void 4282f549d72SSam Leffler ath_setifname(struct athstatfoo *wf0, const char *ifname) 4292f549d72SSam Leffler { 4302f549d72SSam Leffler struct athstatfoo_p *wf = (struct athstatfoo_p *) wf0; 43112f961f4SSam Leffler 4322f549d72SSam Leffler strncpy(wf->ifr.ifr_name, ifname, sizeof (wf->ifr.ifr_name)); 4334d490647SSam Leffler #ifdef ATH_SUPPORT_ANI 4344d490647SSam Leffler strncpy(wf->atd.ad_name, ifname, sizeof (wf->atd.ad_name)); 4354d490647SSam Leffler wf->optstats |= ATHSTATS_ANI; 4364d490647SSam Leffler #endif 43712f961f4SSam Leffler } 43812f961f4SSam Leffler 4392f549d72SSam Leffler static void 440207ae002SSam Leffler ath_collect(struct athstatfoo_p *wf, struct _athstats *stats) 4412f549d72SSam Leffler { 442207ae002SSam Leffler wf->ifr.ifr_data = (caddr_t) &stats->ath; 4432f549d72SSam Leffler if (ioctl(wf->s, SIOCGATHSTATS, &wf->ifr) < 0) 4442f549d72SSam Leffler err(1, wf->ifr.ifr_name); 4454d490647SSam Leffler #ifdef ATH_SUPPORT_ANI 4464d490647SSam Leffler if (wf->optstats & ATHSTATS_ANI) { 4474d490647SSam Leffler wf->atd.ad_id = 5; 4484d490647SSam Leffler wf->atd.ad_out_data = (caddr_t) &stats->ani_state; 4494d490647SSam Leffler wf->atd.ad_out_size = sizeof(stats->ani_state); 4504d490647SSam Leffler if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) { 4514d490647SSam Leffler warn(wf->atd.ad_name); 4524d490647SSam Leffler wf->optstats &= ~ATHSTATS_ANI; 4534d490647SSam Leffler } 4544d490647SSam Leffler wf->atd.ad_id = 8; 4554d490647SSam Leffler wf->atd.ad_out_data = (caddr_t) &stats->ani_stats; 4564d490647SSam Leffler wf->atd.ad_out_size = sizeof(stats->ani_stats); 4574d490647SSam Leffler if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) 4584d490647SSam Leffler warn(wf->atd.ad_name); 4594d490647SSam Leffler } 4604d490647SSam Leffler #endif /* ATH_SUPPORT_ANI */ 46112f961f4SSam Leffler } 4622f549d72SSam Leffler 4632f549d72SSam Leffler static void 4642f549d72SSam Leffler ath_collect_cur(struct statfoo *sf) 4652f549d72SSam Leffler { 4662f549d72SSam Leffler struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; 4672f549d72SSam Leffler 4682f549d72SSam Leffler ath_collect(wf, &wf->cur); 4692f549d72SSam Leffler } 4702f549d72SSam Leffler 4712f549d72SSam Leffler static void 4722f549d72SSam Leffler ath_collect_tot(struct statfoo *sf) 4732f549d72SSam Leffler { 4742f549d72SSam Leffler struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; 4752f549d72SSam Leffler 4762f549d72SSam Leffler ath_collect(wf, &wf->total); 4772f549d72SSam Leffler } 4782f549d72SSam Leffler 4792f549d72SSam Leffler static void 4802f549d72SSam Leffler ath_update_tot(struct statfoo *sf) 4812f549d72SSam Leffler { 4822f549d72SSam Leffler struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; 4832f549d72SSam Leffler 4842f549d72SSam Leffler wf->total = wf->cur; 4852f549d72SSam Leffler } 4862f549d72SSam Leffler 4874d490647SSam Leffler static void 4884d490647SSam Leffler snprintrate(char b[], size_t bs, int rate) 4894d490647SSam Leffler { 4904d490647SSam Leffler if (rate & IEEE80211_RATE_MCS) 4914d490647SSam Leffler snprintf(b, bs, "MCS%u", rate &~ IEEE80211_RATE_MCS); 4924d490647SSam Leffler else if (rate & 1) 4934d490647SSam Leffler snprintf(b, bs, "%u.5M", rate / 2); 4944d490647SSam Leffler else 4954d490647SSam Leffler snprintf(b, bs, "%uM", rate / 2); 4964d490647SSam Leffler } 4974d490647SSam Leffler 4982f549d72SSam Leffler static int 4992f549d72SSam Leffler ath_get_curstat(struct statfoo *sf, int s, char b[], size_t bs) 5002f549d72SSam Leffler { 5012f549d72SSam Leffler struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; 5022f549d72SSam Leffler #define STAT(x) \ 503207ae002SSam Leffler snprintf(b, bs, "%u", wf->cur.ath.ast_##x - wf->total.ath.ast_##x); return 1 5042f549d72SSam Leffler #define PHY(x) \ 505207ae002SSam Leffler snprintf(b, bs, "%u", wf->cur.ath.ast_rx_phy[x] - wf->total.ath.ast_rx_phy[x]); return 1 5064d490647SSam Leffler #define ANI(x) \ 5074d490647SSam Leffler snprintf(b, bs, "%u", wf->cur.ani_state.x); return 1 5084d490647SSam Leffler #define ANISTAT(x) \ 5094d490647SSam Leffler snprintf(b, bs, "%u", wf->cur.ani_stats.ast_ani_##x - wf->total.ani_stats.ast_ani_##x); return 1 5104d490647SSam Leffler #define MIBSTAT(x) \ 5114d490647SSam Leffler snprintf(b, bs, "%u", wf->cur.ani_stats.ast_mibstats.x - wf->total.ani_stats.ast_mibstats.x); return 1 5122f549d72SSam Leffler #define TXANT(x) \ 513207ae002SSam Leffler snprintf(b, bs, "%u", wf->cur.ath.ast_ant_tx[x] - wf->total.ath.ast_ant_tx[x]); return 1 5142f549d72SSam Leffler #define RXANT(x) \ 515207ae002SSam Leffler snprintf(b, bs, "%u", wf->cur.ath.ast_ant_rx[x] - wf->total.ath.ast_ant_rx[x]); return 1 5162f549d72SSam Leffler 5172f549d72SSam Leffler switch (s) { 5182f549d72SSam Leffler case S_INPUT: 5192f549d72SSam Leffler snprintf(b, bs, "%lu", 520207ae002SSam Leffler (wf->cur.ath.ast_rx_packets - wf->total.ath.ast_rx_packets) - 521207ae002SSam Leffler (wf->cur.ath.ast_rx_mgt - wf->total.ath.ast_rx_mgt)); 5222f549d72SSam Leffler return 1; 5232f549d72SSam Leffler case S_OUTPUT: 5242f549d72SSam Leffler snprintf(b, bs, "%lu", 525207ae002SSam Leffler wf->cur.ath.ast_tx_packets - wf->total.ath.ast_tx_packets); 5262f549d72SSam Leffler return 1; 5272f549d72SSam Leffler case S_RATE: 5284d490647SSam Leffler snprintrate(b, bs, wf->cur.ath.ast_tx_rate); 5292f549d72SSam Leffler return 1; 5302f549d72SSam Leffler case S_WATCHDOG: STAT(watchdog); 5312f549d72SSam Leffler case S_FATAL: STAT(hardware); 5322f549d72SSam Leffler case S_BMISS: STAT(bmiss); 5332f549d72SSam Leffler case S_BMISS_PHANTOM: STAT(bmiss_phantom); 5342f549d72SSam Leffler #ifdef S_BSTUCK 5352f549d72SSam Leffler case S_BSTUCK: STAT(bstuck); 5362f549d72SSam Leffler #endif 5372f549d72SSam Leffler case S_RXORN: STAT(rxorn); 5382f549d72SSam Leffler case S_RXEOL: STAT(rxeol); 5392f549d72SSam Leffler case S_TXURN: STAT(txurn); 5402f549d72SSam Leffler case S_MIB: STAT(mib); 5412f549d72SSam Leffler #ifdef S_INTRCOAL 5422f549d72SSam Leffler case S_INTRCOAL: STAT(intrcoal); 5432f549d72SSam Leffler #endif 5442f549d72SSam Leffler case S_TX_MGMT: STAT(tx_mgmt); 5452f549d72SSam Leffler case S_TX_DISCARD: STAT(tx_discard); 5462f549d72SSam Leffler case S_TX_QSTOP: STAT(tx_qstop); 5472f549d72SSam Leffler case S_TX_ENCAP: STAT(tx_encap); 5482f549d72SSam Leffler case S_TX_NONODE: STAT(tx_nonode); 54941e449dbSSam Leffler case S_TX_NOBUF: STAT(tx_nobuf); 55041e449dbSSam Leffler case S_TX_NOFRAG: STAT(tx_nofrag); 5512f549d72SSam Leffler case S_TX_NOMBUF: STAT(tx_nombuf); 5522f549d72SSam Leffler #ifdef S_TX_NOMCL 5532f549d72SSam Leffler case S_TX_NOMCL: STAT(tx_nomcl); 5542f549d72SSam Leffler case S_TX_LINEAR: STAT(tx_linear); 5552f549d72SSam Leffler case S_TX_NODATA: STAT(tx_nodata); 5562f549d72SSam Leffler case S_TX_BUSDMA: STAT(tx_busdma); 5572f549d72SSam Leffler #endif 5582f549d72SSam Leffler case S_TX_XRETRIES: STAT(tx_xretries); 5592f549d72SSam Leffler case S_TX_FIFOERR: STAT(tx_fifoerr); 5602f549d72SSam Leffler case S_TX_FILTERED: STAT(tx_filtered); 5612f549d72SSam Leffler case S_TX_SHORTRETRY: STAT(tx_shortretry); 5622f549d72SSam Leffler case S_TX_LONGRETRY: STAT(tx_longretry); 5632f549d72SSam Leffler case S_TX_BADRATE: STAT(tx_badrate); 5642f549d72SSam Leffler case S_TX_NOACK: STAT(tx_noack); 5652f549d72SSam Leffler case S_TX_RTS: STAT(tx_rts); 5662f549d72SSam Leffler case S_TX_CTS: STAT(tx_cts); 5672f549d72SSam Leffler case S_TX_SHORTPRE: STAT(tx_shortpre); 5682f549d72SSam Leffler case S_TX_ALTRATE: STAT(tx_altrate); 5692f549d72SSam Leffler case S_TX_PROTECT: STAT(tx_protect); 570cc5912f8SSam Leffler case S_TX_RAW: STAT(tx_raw); 571cc5912f8SSam Leffler case S_TX_RAW_FAIL: STAT(tx_raw_fail); 5722f549d72SSam Leffler case S_RX_NOMBUF: STAT(rx_nombuf); 5732f549d72SSam Leffler #ifdef S_RX_BUSDMA 5742f549d72SSam Leffler case S_RX_BUSDMA: STAT(rx_busdma); 5752f549d72SSam Leffler #endif 5762f549d72SSam Leffler case S_RX_ORN: STAT(rx_orn); 5772f549d72SSam Leffler case S_RX_CRC_ERR: STAT(rx_crcerr); 5782f549d72SSam Leffler case S_RX_FIFO_ERR: STAT(rx_fifoerr); 5792f549d72SSam Leffler case S_RX_CRYPTO_ERR: STAT(rx_badcrypt); 5802f549d72SSam Leffler case S_RX_MIC_ERR: STAT(rx_badmic); 5812f549d72SSam Leffler case S_RX_PHY_ERR: STAT(rx_phyerr); 5822f549d72SSam Leffler case S_RX_PHY_UNDERRUN: PHY(HAL_PHYERR_UNDERRUN); 5832f549d72SSam Leffler case S_RX_PHY_TIMING: PHY(HAL_PHYERR_TIMING); 5842f549d72SSam Leffler case S_RX_PHY_PARITY: PHY(HAL_PHYERR_PARITY); 5852f549d72SSam Leffler case S_RX_PHY_RATE: PHY(HAL_PHYERR_RATE); 5862f549d72SSam Leffler case S_RX_PHY_LENGTH: PHY(HAL_PHYERR_LENGTH); 5872f549d72SSam Leffler case S_RX_PHY_RADAR: PHY(HAL_PHYERR_RADAR); 5882f549d72SSam Leffler case S_RX_PHY_SERVICE: PHY(HAL_PHYERR_SERVICE); 5892f549d72SSam Leffler case S_RX_PHY_TOR: PHY(HAL_PHYERR_TOR); 5902f549d72SSam Leffler case S_RX_PHY_OFDM_TIMING: PHY(HAL_PHYERR_OFDM_TIMING); 5912f549d72SSam Leffler case S_RX_PHY_OFDM_SIGNAL_PARITY: PHY(HAL_PHYERR_OFDM_SIGNAL_PARITY); 5922f549d72SSam Leffler case S_RX_PHY_OFDM_RATE_ILLEGAL: PHY(HAL_PHYERR_OFDM_RATE_ILLEGAL); 5932f549d72SSam Leffler case S_RX_PHY_OFDM_POWER_DROP: PHY(HAL_PHYERR_OFDM_POWER_DROP); 5942f549d72SSam Leffler case S_RX_PHY_OFDM_SERVICE: PHY(HAL_PHYERR_OFDM_SERVICE); 5952f549d72SSam Leffler case S_RX_PHY_OFDM_RESTART: PHY(HAL_PHYERR_OFDM_RESTART); 5962f549d72SSam Leffler case S_RX_PHY_CCK_TIMING: PHY(HAL_PHYERR_CCK_TIMING); 5972f549d72SSam Leffler case S_RX_PHY_CCK_HEADER_CRC: PHY(HAL_PHYERR_CCK_HEADER_CRC); 5982f549d72SSam Leffler case S_RX_PHY_CCK_RATE_ILLEGAL: PHY(HAL_PHYERR_CCK_RATE_ILLEGAL); 5992f549d72SSam Leffler case S_RX_PHY_CCK_SERVICE: PHY(HAL_PHYERR_CCK_SERVICE); 6002f549d72SSam Leffler case S_RX_PHY_CCK_RESTART: PHY(HAL_PHYERR_CCK_RESTART); 6012f549d72SSam Leffler case S_RX_TOOSHORT: STAT(rx_tooshort); 6022f549d72SSam Leffler case S_RX_TOOBIG: STAT(rx_toobig); 6032f549d72SSam Leffler case S_RX_MGT: STAT(rx_mgt); 6042f549d72SSam Leffler case S_RX_CTL: STAT(rx_ctl); 6052f549d72SSam Leffler case S_TX_RSSI: 606207ae002SSam Leffler snprintf(b, bs, "%d", wf->cur.ath.ast_tx_rssi); 6072f549d72SSam Leffler return 1; 6082f549d72SSam Leffler case S_RX_RSSI: 609207ae002SSam Leffler snprintf(b, bs, "%d", wf->cur.ath.ast_rx_rssi); 6102f549d72SSam Leffler return 1; 6112f549d72SSam Leffler case S_BE_XMIT: STAT(be_xmit); 6122f549d72SSam Leffler case S_BE_NOMBUF: STAT(be_nombuf); 6132f549d72SSam Leffler case S_PER_CAL: STAT(per_cal); 6142f549d72SSam Leffler case S_PER_CALFAIL: STAT(per_calfail); 6152f549d72SSam Leffler case S_PER_RFGAIN: STAT(per_rfgain); 6162f549d72SSam Leffler #ifdef S_TDMA_UPDATE 6172f549d72SSam Leffler case S_TDMA_UPDATE: STAT(tdma_update); 6182f549d72SSam Leffler case S_TDMA_TIMERS: STAT(tdma_timers); 6192f549d72SSam Leffler case S_TDMA_TSF: STAT(tdma_tsf); 62010ad9a77SSam Leffler case S_TDMA_TSFADJ: 62110ad9a77SSam Leffler snprintf(b, bs, "-%d/+%d", 62210ad9a77SSam Leffler wf->cur.ath.ast_tdma_tsfadjm, wf->cur.ath.ast_tdma_tsfadjp); 62310ad9a77SSam Leffler return 1; 624cc5912f8SSam Leffler case S_TDMA_ACK: STAT(tdma_ack); 6252f549d72SSam Leffler #endif 6262f549d72SSam Leffler case S_RATE_CALLS: STAT(rate_calls); 6272f549d72SSam Leffler case S_RATE_RAISE: STAT(rate_raise); 6282f549d72SSam Leffler case S_RATE_DROP: STAT(rate_drop); 6292f549d72SSam Leffler case S_ANT_DEFSWITCH: STAT(ant_defswitch); 6302f549d72SSam Leffler case S_ANT_TXSWITCH: STAT(ant_txswitch); 6314d490647SSam Leffler #ifdef S_ANI_NOISE 6324d490647SSam Leffler case S_ANI_NOISE: ANI(noiseImmunityLevel); 6334d490647SSam Leffler case S_ANI_SPUR: ANI(spurImmunityLevel); 6344d490647SSam Leffler case S_ANI_STEP: ANI(firstepLevel); 6354d490647SSam Leffler case S_ANI_OFDM: ANI(ofdmWeakSigDetectOff); 63604fc88d5SSam Leffler case S_ANI_CCK: ANI(cckWeakSigThreshold); 6374d490647SSam Leffler case S_ANI_LISTEN: ANI(listenTime); 6384d490647SSam Leffler case S_ANI_NIUP: ANISTAT(niup); 6394d490647SSam Leffler case S_ANI_NIDOWN: ANISTAT(nidown); 6404d490647SSam Leffler case S_ANI_SIUP: ANISTAT(spurup); 6414d490647SSam Leffler case S_ANI_SIDOWN: ANISTAT(spurdown); 6424d490647SSam Leffler case S_ANI_OFDMON: ANISTAT(ofdmon); 6434d490647SSam Leffler case S_ANI_OFDMOFF: ANISTAT(ofdmoff); 6444d490647SSam Leffler case S_ANI_CCKHI: ANISTAT(cckhigh); 6454d490647SSam Leffler case S_ANI_CCKLO: ANISTAT(ccklow); 6464d490647SSam Leffler case S_ANI_STEPUP: ANISTAT(stepup); 6474d490647SSam Leffler case S_ANI_STEPDOWN: ANISTAT(stepdown); 6484d490647SSam Leffler case S_ANI_OFDMERRS: ANISTAT(ofdmerrs); 6494d490647SSam Leffler case S_ANI_CCKERRS: ANISTAT(cckerrs); 6504d490647SSam Leffler case S_ANI_RESET: ANISTAT(reset); 6514d490647SSam Leffler case S_ANI_LZERO: ANISTAT(lzero); 6524d490647SSam Leffler case S_ANI_LNEG: ANISTAT(lneg); 6534d490647SSam Leffler case S_MIB_ACKBAD: MIBSTAT(ackrcv_bad); 6544d490647SSam Leffler case S_MIB_RTSBAD: MIBSTAT(rts_bad); 6554d490647SSam Leffler case S_MIB_RTSGOOD: MIBSTAT(rts_good); 6564d490647SSam Leffler case S_MIB_FCSBAD: MIBSTAT(fcs_bad); 6574d490647SSam Leffler case S_MIB_BEACONS: MIBSTAT(beacons); 6584d490647SSam Leffler case S_NODE_AVGBRSSI: 6594d490647SSam Leffler snprintf(b, bs, "%u", 6604d490647SSam Leffler HAL_RSSI(wf->cur.ani_stats.ast_nodestats.ns_avgbrssi)); 6614d490647SSam Leffler return 1; 6624d490647SSam Leffler case S_NODE_AVGRSSI: 6634d490647SSam Leffler snprintf(b, bs, "%u", 6644d490647SSam Leffler HAL_RSSI(wf->cur.ani_stats.ast_nodestats.ns_avgrssi)); 6654d490647SSam Leffler return 1; 6664d490647SSam Leffler case S_NODE_AVGARSSI: 6674d490647SSam Leffler snprintf(b, bs, "%u", 6684d490647SSam Leffler HAL_RSSI(wf->cur.ani_stats.ast_nodestats.ns_avgtxrssi)); 6694d490647SSam Leffler return 1; 6704d490647SSam Leffler #endif 6712f549d72SSam Leffler case S_ANT_TX0: TXANT(0); 6722f549d72SSam Leffler case S_ANT_TX1: TXANT(1); 6732f549d72SSam Leffler case S_ANT_TX2: TXANT(2); 6742f549d72SSam Leffler case S_ANT_TX3: TXANT(3); 6752f549d72SSam Leffler case S_ANT_TX4: TXANT(4); 6762f549d72SSam Leffler case S_ANT_TX5: TXANT(5); 6772f549d72SSam Leffler case S_ANT_TX6: TXANT(6); 6782f549d72SSam Leffler case S_ANT_TX7: TXANT(7); 6792f549d72SSam Leffler case S_ANT_RX0: RXANT(0); 6802f549d72SSam Leffler case S_ANT_RX1: RXANT(1); 6812f549d72SSam Leffler case S_ANT_RX2: RXANT(2); 6822f549d72SSam Leffler case S_ANT_RX3: RXANT(3); 6832f549d72SSam Leffler case S_ANT_RX4: RXANT(4); 6842f549d72SSam Leffler case S_ANT_RX5: RXANT(5); 6852f549d72SSam Leffler case S_ANT_RX6: RXANT(6); 6862f549d72SSam Leffler case S_ANT_RX7: RXANT(7); 6872f549d72SSam Leffler #ifdef S_CABQ_XMIT 6882f549d72SSam Leffler case S_CABQ_XMIT: STAT(cabq_xmit); 6892f549d72SSam Leffler case S_CABQ_BUSY: STAT(cabq_busy); 6902f549d72SSam Leffler #endif 6912f549d72SSam Leffler case S_FF_TXOK: STAT(ff_txok); 6922f549d72SSam Leffler case S_FF_TXERR: STAT(ff_txerr); 693207ae002SSam Leffler case S_FF_RX: STAT(ff_rx); 6942f549d72SSam Leffler case S_FF_FLUSH: STAT(ff_flush); 695207ae002SSam Leffler case S_TX_QFULL: STAT(tx_qfull); 6962f549d72SSam Leffler case S_RX_NOISE: 697207ae002SSam Leffler snprintf(b, bs, "%d", wf->cur.ath.ast_rx_noise); 6982f549d72SSam Leffler return 1; 6992f549d72SSam Leffler case S_TX_SIGNAL: 7002f549d72SSam Leffler snprintf(b, bs, "%d", 701207ae002SSam Leffler wf->cur.ath.ast_tx_rssi + wf->cur.ath.ast_rx_noise); 7022f549d72SSam Leffler return 1; 7032f549d72SSam Leffler case S_RX_SIGNAL: 7042f549d72SSam Leffler snprintf(b, bs, "%d", 705207ae002SSam Leffler wf->cur.ath.ast_rx_rssi + wf->cur.ath.ast_rx_noise); 7062f549d72SSam Leffler return 1; 7072f549d72SSam Leffler } 7082f549d72SSam Leffler b[0] = '\0'; 70912f961f4SSam Leffler return 0; 7102f549d72SSam Leffler #undef RXANT 7112f549d72SSam Leffler #undef TXANT 7124d490647SSam Leffler #undef ANI 7134d490647SSam Leffler #undef ANISTAT 7144d490647SSam Leffler #undef MIBSTAT 7152f549d72SSam Leffler #undef PHY 7162f549d72SSam Leffler #undef STAT 7172f549d72SSam Leffler } 7182f549d72SSam Leffler 7192f549d72SSam Leffler static int 7202f549d72SSam Leffler ath_get_totstat(struct statfoo *sf, int s, char b[], size_t bs) 7212f549d72SSam Leffler { 7222f549d72SSam Leffler struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; 7232f549d72SSam Leffler #define STAT(x) \ 72495d7bf0fSSam Leffler snprintf(b, bs, "%u", wf->total.ath.ast_##x); return 1 7252f549d72SSam Leffler #define PHY(x) \ 72695d7bf0fSSam Leffler snprintf(b, bs, "%u", wf->total.ath.ast_rx_phy[x]); return 1 7274d490647SSam Leffler #define ANI(x) \ 72895d7bf0fSSam Leffler snprintf(b, bs, "%u", wf->total.ani_state.x); return 1 7294d490647SSam Leffler #define ANISTAT(x) \ 73095d7bf0fSSam Leffler snprintf(b, bs, "%u", wf->total.ani_stats.ast_ani_##x); return 1 7314d490647SSam Leffler #define MIBSTAT(x) \ 73295d7bf0fSSam Leffler snprintf(b, bs, "%u", wf->total.ani_stats.ast_mibstats.x); return 1 7332f549d72SSam Leffler #define TXANT(x) \ 73495d7bf0fSSam Leffler snprintf(b, bs, "%u", wf->total.ath.ast_ant_tx[x]); return 1 7352f549d72SSam Leffler #define RXANT(x) \ 73695d7bf0fSSam Leffler snprintf(b, bs, "%u", wf->total.ath.ast_ant_rx[x]); return 1 7372f549d72SSam Leffler 7382f549d72SSam Leffler switch (s) { 7392f549d72SSam Leffler case S_INPUT: 74095d7bf0fSSam Leffler snprintf(b, bs, "%lu", 741207ae002SSam Leffler wf->total.ath.ast_rx_packets - wf->total.ath.ast_rx_mgt); 7422f549d72SSam Leffler return 1; 7432f549d72SSam Leffler case S_OUTPUT: 74495d7bf0fSSam Leffler snprintf(b, bs, "%lu", wf->total.ath.ast_tx_packets); 7452f549d72SSam Leffler return 1; 7462f549d72SSam Leffler case S_RATE: 7474d490647SSam Leffler snprintrate(b, bs, wf->total.ath.ast_tx_rate); 7482f549d72SSam Leffler return 1; 7492f549d72SSam Leffler case S_WATCHDOG: STAT(watchdog); 7502f549d72SSam Leffler case S_FATAL: STAT(hardware); 7512f549d72SSam Leffler case S_BMISS: STAT(bmiss); 7522f549d72SSam Leffler case S_BMISS_PHANTOM: STAT(bmiss_phantom); 7532f549d72SSam Leffler #ifdef S_BSTUCK 7542f549d72SSam Leffler case S_BSTUCK: STAT(bstuck); 7552f549d72SSam Leffler #endif 7562f549d72SSam Leffler case S_RXORN: STAT(rxorn); 7572f549d72SSam Leffler case S_RXEOL: STAT(rxeol); 7582f549d72SSam Leffler case S_TXURN: STAT(txurn); 7592f549d72SSam Leffler case S_MIB: STAT(mib); 7602f549d72SSam Leffler #ifdef S_INTRCOAL 7612f549d72SSam Leffler case S_INTRCOAL: STAT(intrcoal); 7622f549d72SSam Leffler #endif 7632f549d72SSam Leffler case S_TX_MGMT: STAT(tx_mgmt); 7642f549d72SSam Leffler case S_TX_DISCARD: STAT(tx_discard); 7652f549d72SSam Leffler case S_TX_QSTOP: STAT(tx_qstop); 7662f549d72SSam Leffler case S_TX_ENCAP: STAT(tx_encap); 7672f549d72SSam Leffler case S_TX_NONODE: STAT(tx_nonode); 76841e449dbSSam Leffler case S_TX_NOBUF: STAT(tx_nobuf); 76941e449dbSSam Leffler case S_TX_NOFRAG: STAT(tx_nofrag); 7702f549d72SSam Leffler case S_TX_NOMBUF: STAT(tx_nombuf); 7712f549d72SSam Leffler #ifdef S_TX_NOMCL 7722f549d72SSam Leffler case S_TX_NOMCL: STAT(tx_nomcl); 7732f549d72SSam Leffler case S_TX_LINEAR: STAT(tx_linear); 7742f549d72SSam Leffler case S_TX_NODATA: STAT(tx_nodata); 7752f549d72SSam Leffler case S_TX_BUSDMA: STAT(tx_busdma); 7762f549d72SSam Leffler #endif 7772f549d72SSam Leffler case S_TX_XRETRIES: STAT(tx_xretries); 7782f549d72SSam Leffler case S_TX_FIFOERR: STAT(tx_fifoerr); 7792f549d72SSam Leffler case S_TX_FILTERED: STAT(tx_filtered); 7802f549d72SSam Leffler case S_TX_SHORTRETRY: STAT(tx_shortretry); 7812f549d72SSam Leffler case S_TX_LONGRETRY: STAT(tx_longretry); 7822f549d72SSam Leffler case S_TX_BADRATE: STAT(tx_badrate); 7832f549d72SSam Leffler case S_TX_NOACK: STAT(tx_noack); 7842f549d72SSam Leffler case S_TX_RTS: STAT(tx_rts); 7852f549d72SSam Leffler case S_TX_CTS: STAT(tx_cts); 7862f549d72SSam Leffler case S_TX_SHORTPRE: STAT(tx_shortpre); 7872f549d72SSam Leffler case S_TX_ALTRATE: STAT(tx_altrate); 7882f549d72SSam Leffler case S_TX_PROTECT: STAT(tx_protect); 789cc5912f8SSam Leffler case S_TX_RAW: STAT(tx_raw); 790cc5912f8SSam Leffler case S_TX_RAW_FAIL: STAT(tx_raw_fail); 7912f549d72SSam Leffler case S_RX_NOMBUF: STAT(rx_nombuf); 7922f549d72SSam Leffler #ifdef S_RX_BUSDMA 7932f549d72SSam Leffler case S_RX_BUSDMA: STAT(rx_busdma); 7942f549d72SSam Leffler #endif 7952f549d72SSam Leffler case S_RX_ORN: STAT(rx_orn); 7962f549d72SSam Leffler case S_RX_CRC_ERR: STAT(rx_crcerr); 7972f549d72SSam Leffler case S_RX_FIFO_ERR: STAT(rx_fifoerr); 7982f549d72SSam Leffler case S_RX_CRYPTO_ERR: STAT(rx_badcrypt); 7992f549d72SSam Leffler case S_RX_MIC_ERR: STAT(rx_badmic); 8002f549d72SSam Leffler case S_RX_PHY_ERR: STAT(rx_phyerr); 8012f549d72SSam Leffler case S_RX_PHY_UNDERRUN: PHY(HAL_PHYERR_UNDERRUN); 8022f549d72SSam Leffler case S_RX_PHY_TIMING: PHY(HAL_PHYERR_TIMING); 8032f549d72SSam Leffler case S_RX_PHY_PARITY: PHY(HAL_PHYERR_PARITY); 8042f549d72SSam Leffler case S_RX_PHY_RATE: PHY(HAL_PHYERR_RATE); 8052f549d72SSam Leffler case S_RX_PHY_LENGTH: PHY(HAL_PHYERR_LENGTH); 8062f549d72SSam Leffler case S_RX_PHY_RADAR: PHY(HAL_PHYERR_RADAR); 8072f549d72SSam Leffler case S_RX_PHY_SERVICE: PHY(HAL_PHYERR_SERVICE); 8082f549d72SSam Leffler case S_RX_PHY_TOR: PHY(HAL_PHYERR_TOR); 8092f549d72SSam Leffler case S_RX_PHY_OFDM_TIMING: PHY(HAL_PHYERR_OFDM_TIMING); 8102f549d72SSam Leffler case S_RX_PHY_OFDM_SIGNAL_PARITY: PHY(HAL_PHYERR_OFDM_SIGNAL_PARITY); 8112f549d72SSam Leffler case S_RX_PHY_OFDM_RATE_ILLEGAL: PHY(HAL_PHYERR_OFDM_RATE_ILLEGAL); 8122f549d72SSam Leffler case S_RX_PHY_OFDM_POWER_DROP: PHY(HAL_PHYERR_OFDM_POWER_DROP); 8132f549d72SSam Leffler case S_RX_PHY_OFDM_SERVICE: PHY(HAL_PHYERR_OFDM_SERVICE); 8142f549d72SSam Leffler case S_RX_PHY_OFDM_RESTART: PHY(HAL_PHYERR_OFDM_RESTART); 8152f549d72SSam Leffler case S_RX_PHY_CCK_TIMING: PHY(HAL_PHYERR_CCK_TIMING); 8162f549d72SSam Leffler case S_RX_PHY_CCK_HEADER_CRC: PHY(HAL_PHYERR_CCK_HEADER_CRC); 8172f549d72SSam Leffler case S_RX_PHY_CCK_RATE_ILLEGAL: PHY(HAL_PHYERR_CCK_RATE_ILLEGAL); 8182f549d72SSam Leffler case S_RX_PHY_CCK_SERVICE: PHY(HAL_PHYERR_CCK_SERVICE); 8192f549d72SSam Leffler case S_RX_PHY_CCK_RESTART: PHY(HAL_PHYERR_CCK_RESTART); 8202f549d72SSam Leffler case S_RX_TOOSHORT: STAT(rx_tooshort); 8212f549d72SSam Leffler case S_RX_TOOBIG: STAT(rx_toobig); 8222f549d72SSam Leffler case S_RX_MGT: STAT(rx_mgt); 8232f549d72SSam Leffler case S_RX_CTL: STAT(rx_ctl); 8242f549d72SSam Leffler case S_TX_RSSI: 825207ae002SSam Leffler snprintf(b, bs, "%d", wf->total.ath.ast_tx_rssi); 8262f549d72SSam Leffler return 1; 8272f549d72SSam Leffler case S_RX_RSSI: 828207ae002SSam Leffler snprintf(b, bs, "%d", wf->total.ath.ast_rx_rssi); 8292f549d72SSam Leffler return 1; 8302f549d72SSam Leffler case S_BE_XMIT: STAT(be_xmit); 8312f549d72SSam Leffler case S_BE_NOMBUF: STAT(be_nombuf); 8322f549d72SSam Leffler case S_PER_CAL: STAT(per_cal); 8332f549d72SSam Leffler case S_PER_CALFAIL: STAT(per_calfail); 8342f549d72SSam Leffler case S_PER_RFGAIN: STAT(per_rfgain); 8352f549d72SSam Leffler #ifdef S_TDMA_UPDATE 8362f549d72SSam Leffler case S_TDMA_UPDATE: STAT(tdma_update); 8372f549d72SSam Leffler case S_TDMA_TIMERS: STAT(tdma_timers); 8382f549d72SSam Leffler case S_TDMA_TSF: STAT(tdma_tsf); 83910ad9a77SSam Leffler case S_TDMA_TSFADJ: 84010ad9a77SSam Leffler snprintf(b, bs, "-%d/+%d", 84110ad9a77SSam Leffler wf->total.ath.ast_tdma_tsfadjm, 84210ad9a77SSam Leffler wf->total.ath.ast_tdma_tsfadjp); 84310ad9a77SSam Leffler return 1; 844cc5912f8SSam Leffler case S_TDMA_ACK: STAT(tdma_ack); 8452f549d72SSam Leffler #endif 8462f549d72SSam Leffler case S_RATE_CALLS: STAT(rate_calls); 8472f549d72SSam Leffler case S_RATE_RAISE: STAT(rate_raise); 8482f549d72SSam Leffler case S_RATE_DROP: STAT(rate_drop); 8492f549d72SSam Leffler case S_ANT_DEFSWITCH: STAT(ant_defswitch); 8502f549d72SSam Leffler case S_ANT_TXSWITCH: STAT(ant_txswitch); 8514d490647SSam Leffler #ifdef S_ANI_NOISE 8524d490647SSam Leffler case S_ANI_NOISE: ANI(noiseImmunityLevel); 8534d490647SSam Leffler case S_ANI_SPUR: ANI(spurImmunityLevel); 8544d490647SSam Leffler case S_ANI_STEP: ANI(firstepLevel); 85504fc88d5SSam Leffler case S_ANI_OFDM: ANI(ofdmWeakSigDetectOff); 85604fc88d5SSam Leffler case S_ANI_CCK: ANI(cckWeakSigThreshold); 8574d490647SSam Leffler case S_ANI_LISTEN: ANI(listenTime); 8584d490647SSam Leffler case S_ANI_NIUP: ANISTAT(niup); 8594d490647SSam Leffler case S_ANI_NIDOWN: ANISTAT(nidown); 8604d490647SSam Leffler case S_ANI_SIUP: ANISTAT(spurup); 8614d490647SSam Leffler case S_ANI_SIDOWN: ANISTAT(spurdown); 8624d490647SSam Leffler case S_ANI_OFDMON: ANISTAT(ofdmon); 8634d490647SSam Leffler case S_ANI_OFDMOFF: ANISTAT(ofdmoff); 8644d490647SSam Leffler case S_ANI_CCKHI: ANISTAT(cckhigh); 8654d490647SSam Leffler case S_ANI_CCKLO: ANISTAT(ccklow); 8664d490647SSam Leffler case S_ANI_STEPUP: ANISTAT(stepup); 8674d490647SSam Leffler case S_ANI_STEPDOWN: ANISTAT(stepdown); 8684d490647SSam Leffler case S_ANI_OFDMERRS: ANISTAT(ofdmerrs); 8694d490647SSam Leffler case S_ANI_CCKERRS: ANISTAT(cckerrs); 8704d490647SSam Leffler case S_ANI_RESET: ANISTAT(reset); 8714d490647SSam Leffler case S_ANI_LZERO: ANISTAT(lzero); 8724d490647SSam Leffler case S_ANI_LNEG: ANISTAT(lneg); 8734d490647SSam Leffler case S_MIB_ACKBAD: MIBSTAT(ackrcv_bad); 8744d490647SSam Leffler case S_MIB_RTSBAD: MIBSTAT(rts_bad); 8754d490647SSam Leffler case S_MIB_RTSGOOD: MIBSTAT(rts_good); 8764d490647SSam Leffler case S_MIB_FCSBAD: MIBSTAT(fcs_bad); 8774d490647SSam Leffler case S_MIB_BEACONS: MIBSTAT(beacons); 8784d490647SSam Leffler case S_NODE_AVGBRSSI: 8794d490647SSam Leffler snprintf(b, bs, "%u", 8804d490647SSam Leffler HAL_RSSI(wf->total.ani_stats.ast_nodestats.ns_avgbrssi)); 8814d490647SSam Leffler return 1; 8824d490647SSam Leffler case S_NODE_AVGRSSI: 8834d490647SSam Leffler snprintf(b, bs, "%u", 8844d490647SSam Leffler HAL_RSSI(wf->total.ani_stats.ast_nodestats.ns_avgrssi)); 8854d490647SSam Leffler return 1; 8864d490647SSam Leffler case S_NODE_AVGARSSI: 8874d490647SSam Leffler snprintf(b, bs, "%u", 8884d490647SSam Leffler HAL_RSSI(wf->total.ani_stats.ast_nodestats.ns_avgtxrssi)); 8894d490647SSam Leffler return 1; 8904d490647SSam Leffler #endif 8912f549d72SSam Leffler case S_ANT_TX0: TXANT(0); 8922f549d72SSam Leffler case S_ANT_TX1: TXANT(1); 8932f549d72SSam Leffler case S_ANT_TX2: TXANT(2); 8942f549d72SSam Leffler case S_ANT_TX3: TXANT(3); 8952f549d72SSam Leffler case S_ANT_TX4: TXANT(4); 8962f549d72SSam Leffler case S_ANT_TX5: TXANT(5); 8972f549d72SSam Leffler case S_ANT_TX6: TXANT(6); 8982f549d72SSam Leffler case S_ANT_TX7: TXANT(7); 8992f549d72SSam Leffler case S_ANT_RX0: RXANT(0); 9002f549d72SSam Leffler case S_ANT_RX1: RXANT(1); 9012f549d72SSam Leffler case S_ANT_RX2: RXANT(2); 9022f549d72SSam Leffler case S_ANT_RX3: RXANT(3); 9032f549d72SSam Leffler case S_ANT_RX4: RXANT(4); 9042f549d72SSam Leffler case S_ANT_RX5: RXANT(5); 9052f549d72SSam Leffler case S_ANT_RX6: RXANT(6); 9062f549d72SSam Leffler case S_ANT_RX7: RXANT(7); 9072f549d72SSam Leffler #ifdef S_CABQ_XMIT 9082f549d72SSam Leffler case S_CABQ_XMIT: STAT(cabq_xmit); 9092f549d72SSam Leffler case S_CABQ_BUSY: STAT(cabq_busy); 9102f549d72SSam Leffler #endif 9112f549d72SSam Leffler case S_FF_TXOK: STAT(ff_txok); 9122f549d72SSam Leffler case S_FF_TXERR: STAT(ff_txerr); 913207ae002SSam Leffler case S_FF_RX: STAT(ff_rx); 9142f549d72SSam Leffler case S_FF_FLUSH: STAT(ff_flush); 915207ae002SSam Leffler case S_TX_QFULL: STAT(tx_qfull); 9162f549d72SSam Leffler case S_RX_NOISE: 917207ae002SSam Leffler snprintf(b, bs, "%d", wf->total.ath.ast_rx_noise); 9182f549d72SSam Leffler return 1; 9192f549d72SSam Leffler case S_TX_SIGNAL: 9202f549d72SSam Leffler snprintf(b, bs, "%d", 921207ae002SSam Leffler wf->total.ath.ast_tx_rssi + wf->total.ath.ast_rx_noise); 9222f549d72SSam Leffler return 1; 9232f549d72SSam Leffler case S_RX_SIGNAL: 9242f549d72SSam Leffler snprintf(b, bs, "%d", 925207ae002SSam Leffler wf->total.ath.ast_rx_rssi + wf->total.ath.ast_rx_noise); 9262f549d72SSam Leffler return 1; 9272f549d72SSam Leffler } 9282f549d72SSam Leffler b[0] = '\0'; 9292f549d72SSam Leffler return 0; 9302f549d72SSam Leffler #undef RXANT 9312f549d72SSam Leffler #undef TXANT 9324d490647SSam Leffler #undef ANI 9334d490647SSam Leffler #undef ANISTAT 9344d490647SSam Leffler #undef MIBSTAT 9352f549d72SSam Leffler #undef PHY 9362f549d72SSam Leffler #undef STAT 9372f549d72SSam Leffler } 9382f549d72SSam Leffler 9392f549d72SSam Leffler static void 9402f549d72SSam Leffler ath_print_verbose(struct statfoo *sf, FILE *fd) 9412f549d72SSam Leffler { 9422f549d72SSam Leffler struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; 9432f549d72SSam Leffler #define isphyerr(i) (S_PHY_MIN <= i && i <= S_PHY_MAX) 944207ae002SSam Leffler const struct fmt *f; 9452f549d72SSam Leffler char s[32]; 9462f549d72SSam Leffler const char *indent; 947207ae002SSam Leffler int i, width; 9482f549d72SSam Leffler 949207ae002SSam Leffler width = 0; 950207ae002SSam Leffler for (i = 0; i < S_LAST; i++) { 951207ae002SSam Leffler f = &sf->stats[i]; 952207ae002SSam Leffler if (!isphyerr(i) && f->width > width) 953207ae002SSam Leffler width = f->width; 954207ae002SSam Leffler } 9552f549d72SSam Leffler for (i = 0; i < S_LAST; i++) { 9562f549d72SSam Leffler if (ath_get_totstat(sf, i, s, sizeof(s)) && strcmp(s, "0")) { 9572f549d72SSam Leffler if (isphyerr(i)) 9582f549d72SSam Leffler indent = " "; 9592f549d72SSam Leffler else 9602f549d72SSam Leffler indent = ""; 961207ae002SSam Leffler fprintf(fd, "%s%-*s %s\n", indent, width, s, athstats[i].desc); 9622f549d72SSam Leffler } 9632f549d72SSam Leffler } 9642f549d72SSam Leffler fprintf(fd, "Antenna profile:\n"); 9652f549d72SSam Leffler for (i = 0; i < 8; i++) 966207ae002SSam Leffler if (wf->total.ath.ast_ant_rx[i] || wf->total.ath.ast_ant_tx[i]) 9672f549d72SSam Leffler fprintf(fd, "[%u] tx %8u rx %8u\n", i, 968207ae002SSam Leffler wf->total.ath.ast_ant_tx[i], 969207ae002SSam Leffler wf->total.ath.ast_ant_rx[i]); 9702f549d72SSam Leffler #undef isphyerr 9712f549d72SSam Leffler } 9722f549d72SSam Leffler 9732f549d72SSam Leffler STATFOO_DEFINE_BOUNCE(athstatfoo) 9742f549d72SSam Leffler 9752f549d72SSam Leffler struct athstatfoo * 9762f549d72SSam Leffler athstats_new(const char *ifname, const char *fmtstring) 9772f549d72SSam Leffler { 9782f549d72SSam Leffler #define N(a) (sizeof(a) / sizeof(a[0])) 9792f549d72SSam Leffler struct athstatfoo_p *wf; 9802f549d72SSam Leffler 9812f549d72SSam Leffler wf = calloc(1, sizeof(struct athstatfoo_p)); 9822f549d72SSam Leffler if (wf != NULL) { 9832f549d72SSam Leffler statfoo_init(&wf->base.base, "athstats", athstats, N(athstats)); 9842f549d72SSam Leffler /* override base methods */ 9852f549d72SSam Leffler wf->base.base.collect_cur = ath_collect_cur; 9862f549d72SSam Leffler wf->base.base.collect_tot = ath_collect_tot; 9872f549d72SSam Leffler wf->base.base.get_curstat = ath_get_curstat; 9882f549d72SSam Leffler wf->base.base.get_totstat = ath_get_totstat; 9892f549d72SSam Leffler wf->base.base.update_tot = ath_update_tot; 9902f549d72SSam Leffler wf->base.base.print_verbose = ath_print_verbose; 9912f549d72SSam Leffler 9922f549d72SSam Leffler /* setup bounce functions for public methods */ 9932f549d72SSam Leffler STATFOO_BOUNCE(wf, athstatfoo); 9942f549d72SSam Leffler 9952f549d72SSam Leffler /* setup our public methods */ 9962f549d72SSam Leffler wf->base.setifname = ath_setifname; 9972f549d72SSam Leffler #if 0 9982f549d72SSam Leffler wf->base.setstamac = wlan_setstamac; 9992f549d72SSam Leffler #endif 10002f549d72SSam Leffler wf->s = socket(AF_INET, SOCK_DGRAM, 0); 10012f549d72SSam Leffler if (wf->s < 0) 10022f549d72SSam Leffler err(1, "socket"); 10032f549d72SSam Leffler 10042f549d72SSam Leffler ath_setifname(&wf->base, ifname); 10052f549d72SSam Leffler wf->base.setfmt(&wf->base, fmtstring); 10062f549d72SSam Leffler } 10072f549d72SSam Leffler return &wf->base; 10082f549d72SSam Leffler #undef N 100912f961f4SSam Leffler } 1010