1203c4805SLuis R. Rodriguez /* 2203c4805SLuis R. Rodriguez * Copyright (c) 2008-2009 Atheros Communications Inc. 3203c4805SLuis R. Rodriguez * 4203c4805SLuis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 5203c4805SLuis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 6203c4805SLuis R. Rodriguez * copyright notice and this permission notice appear in all copies. 7203c4805SLuis R. Rodriguez * 8203c4805SLuis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9203c4805SLuis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10203c4805SLuis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11203c4805SLuis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12203c4805SLuis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13203c4805SLuis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14203c4805SLuis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15203c4805SLuis R. Rodriguez */ 16203c4805SLuis R. Rodriguez 17203c4805SLuis R. Rodriguez #ifndef DEBUG_H 18203c4805SLuis R. Rodriguez #define DEBUG_H 19203c4805SLuis R. Rodriguez 204d6b228dSLuis R. Rodriguez #include "hw.h" 21545750d3SFelix Fietkau #include "rc.h" 224d6b228dSLuis R. Rodriguez 23fec247c0SSujith struct ath_txq; 24fec247c0SSujith struct ath_buf; 25fec247c0SSujith 26a830df07SFelix Fietkau #ifdef CONFIG_ATH9K_DEBUGFS 27fec247c0SSujith #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++ 28fec247c0SSujith #else 29fec247c0SSujith #define TX_STAT_INC(q, c) do { } while (0) 30fec247c0SSujith #endif 31fec247c0SSujith 32a830df07SFelix Fietkau #ifdef CONFIG_ATH9K_DEBUGFS 33203c4805SLuis R. Rodriguez 34203c4805SLuis R. Rodriguez /** 35203c4805SLuis R. Rodriguez * struct ath_interrupt_stats - Contains statistics about interrupts 36203c4805SLuis R. Rodriguez * @total: Total no. of interrupts generated so far 37203c4805SLuis R. Rodriguez * @rxok: RX with no errors 38a9616f41SLuis R. Rodriguez * @rxlp: RX with low priority RX 39a9616f41SLuis R. Rodriguez * @rxhp: RX with high priority, uapsd only 40203c4805SLuis R. Rodriguez * @rxeol: RX with no more RXDESC available 41203c4805SLuis R. Rodriguez * @rxorn: RX FIFO overrun 42203c4805SLuis R. Rodriguez * @txok: TX completed at the requested rate 43203c4805SLuis R. Rodriguez * @txurn: TX FIFO underrun 44203c4805SLuis R. Rodriguez * @mib: MIB regs reaching its threshold 45203c4805SLuis R. Rodriguez * @rxphyerr: RX with phy errors 46203c4805SLuis R. Rodriguez * @rx_keycache_miss: RX with key cache misses 47203c4805SLuis R. Rodriguez * @swba: Software Beacon Alert 48203c4805SLuis R. Rodriguez * @bmiss: Beacon Miss 49203c4805SLuis R. Rodriguez * @bnr: Beacon Not Ready 50203c4805SLuis R. Rodriguez * @cst: Carrier Sense TImeout 51203c4805SLuis R. Rodriguez * @gtt: Global TX Timeout 52203c4805SLuis R. Rodriguez * @tim: RX beacon TIM occurrence 53203c4805SLuis R. Rodriguez * @cabend: RX End of CAB traffic 54203c4805SLuis R. Rodriguez * @dtimsync: DTIM sync lossage 55203c4805SLuis R. Rodriguez * @dtim: RX Beacon with DTIM 5608578b8fSLuis R. Rodriguez * @bb_watchdog: Baseband watchdog 57203c4805SLuis R. Rodriguez */ 58203c4805SLuis R. Rodriguez struct ath_interrupt_stats { 59203c4805SLuis R. Rodriguez u32 total; 60203c4805SLuis R. Rodriguez u32 rxok; 61a9616f41SLuis R. Rodriguez u32 rxlp; 62a9616f41SLuis R. Rodriguez u32 rxhp; 63203c4805SLuis R. Rodriguez u32 rxeol; 64203c4805SLuis R. Rodriguez u32 rxorn; 65203c4805SLuis R. Rodriguez u32 txok; 66203c4805SLuis R. Rodriguez u32 txeol; 67203c4805SLuis R. Rodriguez u32 txurn; 68203c4805SLuis R. Rodriguez u32 mib; 69203c4805SLuis R. Rodriguez u32 rxphyerr; 70203c4805SLuis R. Rodriguez u32 rx_keycache_miss; 71203c4805SLuis R. Rodriguez u32 swba; 72203c4805SLuis R. Rodriguez u32 bmiss; 73203c4805SLuis R. Rodriguez u32 bnr; 74203c4805SLuis R. Rodriguez u32 cst; 75203c4805SLuis R. Rodriguez u32 gtt; 76203c4805SLuis R. Rodriguez u32 tim; 77203c4805SLuis R. Rodriguez u32 cabend; 78203c4805SLuis R. Rodriguez u32 dtimsync; 79203c4805SLuis R. Rodriguez u32 dtim; 8008578b8fSLuis R. Rodriguez u32 bb_watchdog; 81203c4805SLuis R. Rodriguez }; 82203c4805SLuis R. Rodriguez 83fec247c0SSujith /** 84fec247c0SSujith * struct ath_tx_stats - Statistics about TX 8599c15bf5SBen Greear * @tx_pkts_all: No. of total frames transmitted, including ones that 8699c15bf5SBen Greear may have had errors. 8799c15bf5SBen Greear * @tx_bytes_all: No. of total bytes transmitted, including ones that 8899c15bf5SBen Greear may have had errors. 89fec247c0SSujith * @queued: Total MPDUs (non-aggr) queued 90fec247c0SSujith * @completed: Total MPDUs (non-aggr) completed 91fec247c0SSujith * @a_aggr: Total no. of aggregates queued 92bda8addaSBen Greear * @a_queued_hw: Total AMPDUs queued to hardware 93bda8addaSBen Greear * @a_queued_sw: Total AMPDUs queued to software queues 94fec247c0SSujith * @a_completed: Total AMPDUs completed 95fec247c0SSujith * @a_retries: No. of AMPDUs retried (SW) 96fec247c0SSujith * @a_xretries: No. of AMPDUs dropped due to xretries 97fec247c0SSujith * @fifo_underrun: FIFO underrun occurrences 98fec247c0SSujith Valid only for: 99fec247c0SSujith - non-aggregate condition. 100fec247c0SSujith - first packet of aggregate. 101fec247c0SSujith * @xtxop: No. of frames filtered because of TXOP limit 102fec247c0SSujith * @timer_exp: Transmit timer expiry 103fec247c0SSujith * @desc_cfg_err: Descriptor configuration errors 104fec247c0SSujith * @data_urn: TX data underrun errors 105fec247c0SSujith * @delim_urn: TX delimiter underrun errors 1062dac4fb9SBen Greear * @puttxbuf: Number of times hardware was given txbuf to write. 1072dac4fb9SBen Greear * @txstart: Number of times hardware was told to start tx. 1082dac4fb9SBen Greear * @txprocdesc: Number of times tx descriptor was processed 109fec247c0SSujith */ 110fec247c0SSujith struct ath_tx_stats { 11199c15bf5SBen Greear u32 tx_pkts_all; 11299c15bf5SBen Greear u32 tx_bytes_all; 113fec247c0SSujith u32 queued; 114fec247c0SSujith u32 completed; 115fec247c0SSujith u32 a_aggr; 116bda8addaSBen Greear u32 a_queued_hw; 117bda8addaSBen Greear u32 a_queued_sw; 118fec247c0SSujith u32 a_completed; 119fec247c0SSujith u32 a_retries; 120fec247c0SSujith u32 a_xretries; 121fec247c0SSujith u32 fifo_underrun; 122fec247c0SSujith u32 xtxop; 123fec247c0SSujith u32 timer_exp; 124fec247c0SSujith u32 desc_cfg_err; 125fec247c0SSujith u32 data_underrun; 126fec247c0SSujith u32 delim_underrun; 1272dac4fb9SBen Greear u32 puttxbuf; 1282dac4fb9SBen Greear u32 txstart; 1292dac4fb9SBen Greear u32 txprocdesc; 130fec247c0SSujith }; 131fec247c0SSujith 1321395d3f0SSujith /** 1331395d3f0SSujith * struct ath_rx_stats - RX Statistics 13499c15bf5SBen Greear * @rx_pkts_all: No. of total frames received, including ones that 13599c15bf5SBen Greear may have had errors. 13699c15bf5SBen Greear * @rx_bytes_all: No. of total bytes received, including ones that 13799c15bf5SBen Greear may have had errors. 1381395d3f0SSujith * @crc_err: No. of frames with incorrect CRC value 1391395d3f0SSujith * @decrypt_crc_err: No. of frames whose CRC check failed after 1401395d3f0SSujith decryption process completed 1411395d3f0SSujith * @phy_err: No. of frames whose reception failed because the PHY 1421395d3f0SSujith encountered an error 1431395d3f0SSujith * @mic_err: No. of frames with incorrect TKIP MIC verification failure 1441395d3f0SSujith * @pre_delim_crc_err: Pre-Frame delimiter CRC error detections 1451395d3f0SSujith * @post_delim_crc_err: Post-Frame delimiter CRC error detections 1461395d3f0SSujith * @decrypt_busy_err: Decryption interruptions counter 1471395d3f0SSujith * @phy_err_stats: Individual PHY error statistics 1481395d3f0SSujith */ 1491395d3f0SSujith struct ath_rx_stats { 15099c15bf5SBen Greear u32 rx_pkts_all; 15199c15bf5SBen Greear u32 rx_bytes_all; 1521395d3f0SSujith u32 crc_err; 1531395d3f0SSujith u32 decrypt_crc_err; 1541395d3f0SSujith u32 phy_err; 1551395d3f0SSujith u32 mic_err; 1561395d3f0SSujith u32 pre_delim_crc_err; 1571395d3f0SSujith u32 post_delim_crc_err; 1581395d3f0SSujith u32 decrypt_busy_err; 1591395d3f0SSujith u32 phy_err_stats[ATH9K_PHYERR_MAX]; 1607d755414SSenthil Balasubramanian int8_t rs_rssi_ctl0; 1617d755414SSenthil Balasubramanian int8_t rs_rssi_ctl1; 1627d755414SSenthil Balasubramanian int8_t rs_rssi_ctl2; 1637d755414SSenthil Balasubramanian int8_t rs_rssi_ext0; 1647d755414SSenthil Balasubramanian int8_t rs_rssi_ext1; 1657d755414SSenthil Balasubramanian int8_t rs_rssi_ext2; 1667d755414SSenthil Balasubramanian u8 rs_antenna; 1671395d3f0SSujith }; 1681395d3f0SSujith 169203c4805SLuis R. Rodriguez struct ath_stats { 170203c4805SLuis R. Rodriguez struct ath_interrupt_stats istats; 171fec247c0SSujith struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES]; 1721395d3f0SSujith struct ath_rx_stats rxstats; 173203c4805SLuis R. Rodriguez }; 174203c4805SLuis R. Rodriguez 175203c4805SLuis R. Rodriguez struct ath9k_debug { 176203c4805SLuis R. Rodriguez struct dentry *debugfs_phy; 1779bff0bc4SFelix Fietkau u32 regidx; 178203c4805SLuis R. Rodriguez struct ath_stats stats; 179203c4805SLuis R. Rodriguez }; 180203c4805SLuis R. Rodriguez 1814d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah); 1824d6b228dSLuis R. Rodriguez 183203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); 184066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 1855bec3e5aSFelix Fietkau struct ath_tx_status *ts, struct ath_txq *txq); 1868e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs); 187203c4805SLuis R. Rodriguez 188203c4805SLuis R. Rodriguez #else 189203c4805SLuis R. Rodriguez 1904d6b228dSLuis R. Rodriguez static inline int ath9k_init_debug(struct ath_hw *ah) 191203c4805SLuis R. Rodriguez { 192203c4805SLuis R. Rodriguez return 0; 193203c4805SLuis R. Rodriguez } 194203c4805SLuis R. Rodriguez 195203c4805SLuis R. Rodriguez static inline void ath_debug_stat_interrupt(struct ath_softc *sc, 196203c4805SLuis R. Rodriguez enum ath9k_int status) 197203c4805SLuis R. Rodriguez { 198203c4805SLuis R. Rodriguez } 199203c4805SLuis R. Rodriguez 200fec247c0SSujith static inline void ath_debug_stat_tx(struct ath_softc *sc, 20132ffb1f4SFelix Fietkau struct ath_buf *bf, 2023bf63e59SFelix Fietkau struct ath_tx_status *ts, 2033bf63e59SFelix Fietkau struct ath_txq *txq) 204fec247c0SSujith { 205fec247c0SSujith } 206fec247c0SSujith 2071395d3f0SSujith static inline void ath_debug_stat_rx(struct ath_softc *sc, 20832ffb1f4SFelix Fietkau struct ath_rx_status *rs) 2091395d3f0SSujith { 2101395d3f0SSujith } 2111395d3f0SSujith 212a830df07SFelix Fietkau #endif /* CONFIG_ATH9K_DEBUGFS */ 213203c4805SLuis R. Rodriguez 214203c4805SLuis R. Rodriguez #endif /* DEBUG_H */ 215