Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 1 | /* |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2009 Atheros Communications Inc. |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #ifndef DEBUG_H |
| 18 | #define DEBUG_H |
| 19 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 20 | #include "hw.h" |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 21 | #include "rc.h" |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 22 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 23 | struct ath_txq; |
| 24 | struct ath_buf; |
| 25 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 26 | #ifdef CONFIG_ATH9K_DEBUGFS |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 27 | #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++ |
| 28 | #else |
| 29 | #define TX_STAT_INC(q, c) do { } while (0) |
| 30 | #endif |
| 31 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 32 | #ifdef CONFIG_ATH9K_DEBUGFS |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * struct ath_interrupt_stats - Contains statistics about interrupts |
| 36 | * @total: Total no. of interrupts generated so far |
| 37 | * @rxok: RX with no errors |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame^] | 38 | * @rxlp: RX with low priority RX |
| 39 | * @rxhp: RX with high priority, uapsd only |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 40 | * @rxeol: RX with no more RXDESC available |
| 41 | * @rxorn: RX FIFO overrun |
| 42 | * @txok: TX completed at the requested rate |
| 43 | * @txurn: TX FIFO underrun |
| 44 | * @mib: MIB regs reaching its threshold |
| 45 | * @rxphyerr: RX with phy errors |
| 46 | * @rx_keycache_miss: RX with key cache misses |
| 47 | * @swba: Software Beacon Alert |
| 48 | * @bmiss: Beacon Miss |
| 49 | * @bnr: Beacon Not Ready |
| 50 | * @cst: Carrier Sense TImeout |
| 51 | * @gtt: Global TX Timeout |
| 52 | * @tim: RX beacon TIM occurrence |
| 53 | * @cabend: RX End of CAB traffic |
| 54 | * @dtimsync: DTIM sync lossage |
| 55 | * @dtim: RX Beacon with DTIM |
| 56 | */ |
| 57 | struct ath_interrupt_stats { |
| 58 | u32 total; |
| 59 | u32 rxok; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame^] | 60 | u32 rxlp; |
| 61 | u32 rxhp; |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 62 | u32 rxeol; |
| 63 | u32 rxorn; |
| 64 | u32 txok; |
| 65 | u32 txeol; |
| 66 | u32 txurn; |
| 67 | u32 mib; |
| 68 | u32 rxphyerr; |
| 69 | u32 rx_keycache_miss; |
| 70 | u32 swba; |
| 71 | u32 bmiss; |
| 72 | u32 bnr; |
| 73 | u32 cst; |
| 74 | u32 gtt; |
| 75 | u32 tim; |
| 76 | u32 cabend; |
| 77 | u32 dtimsync; |
| 78 | u32 dtim; |
| 79 | }; |
| 80 | |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 81 | struct ath_rc_stats { |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 82 | u32 success; |
| 83 | u32 retries; |
| 84 | u32 xretries; |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame] | 85 | u8 per; |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 86 | }; |
| 87 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 88 | /** |
| 89 | * struct ath_tx_stats - Statistics about TX |
| 90 | * @queued: Total MPDUs (non-aggr) queued |
| 91 | * @completed: Total MPDUs (non-aggr) completed |
| 92 | * @a_aggr: Total no. of aggregates queued |
| 93 | * @a_queued: Total AMPDUs queued |
| 94 | * @a_completed: Total AMPDUs completed |
| 95 | * @a_retries: No. of AMPDUs retried (SW) |
| 96 | * @a_xretries: No. of AMPDUs dropped due to xretries |
| 97 | * @fifo_underrun: FIFO underrun occurrences |
| 98 | Valid only for: |
| 99 | - non-aggregate condition. |
| 100 | - first packet of aggregate. |
| 101 | * @xtxop: No. of frames filtered because of TXOP limit |
| 102 | * @timer_exp: Transmit timer expiry |
| 103 | * @desc_cfg_err: Descriptor configuration errors |
| 104 | * @data_urn: TX data underrun errors |
| 105 | * @delim_urn: TX delimiter underrun errors |
| 106 | */ |
| 107 | struct ath_tx_stats { |
| 108 | u32 queued; |
| 109 | u32 completed; |
| 110 | u32 a_aggr; |
| 111 | u32 a_queued; |
| 112 | u32 a_completed; |
| 113 | u32 a_retries; |
| 114 | u32 a_xretries; |
| 115 | u32 fifo_underrun; |
| 116 | u32 xtxop; |
| 117 | u32 timer_exp; |
| 118 | u32 desc_cfg_err; |
| 119 | u32 data_underrun; |
| 120 | u32 delim_underrun; |
| 121 | }; |
| 122 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 123 | /** |
| 124 | * struct ath_rx_stats - RX Statistics |
| 125 | * @crc_err: No. of frames with incorrect CRC value |
| 126 | * @decrypt_crc_err: No. of frames whose CRC check failed after |
| 127 | decryption process completed |
| 128 | * @phy_err: No. of frames whose reception failed because the PHY |
| 129 | encountered an error |
| 130 | * @mic_err: No. of frames with incorrect TKIP MIC verification failure |
| 131 | * @pre_delim_crc_err: Pre-Frame delimiter CRC error detections |
| 132 | * @post_delim_crc_err: Post-Frame delimiter CRC error detections |
| 133 | * @decrypt_busy_err: Decryption interruptions counter |
| 134 | * @phy_err_stats: Individual PHY error statistics |
| 135 | */ |
| 136 | struct ath_rx_stats { |
| 137 | u32 crc_err; |
| 138 | u32 decrypt_crc_err; |
| 139 | u32 phy_err; |
| 140 | u32 mic_err; |
| 141 | u32 pre_delim_crc_err; |
| 142 | u32 post_delim_crc_err; |
| 143 | u32 decrypt_busy_err; |
| 144 | u32 phy_err_stats[ATH9K_PHYERR_MAX]; |
| 145 | }; |
| 146 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 147 | struct ath_stats { |
| 148 | struct ath_interrupt_stats istats; |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 149 | struct ath_rc_stats rcstats[RATE_TABLE_SIZE]; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 150 | struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES]; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 151 | struct ath_rx_stats rxstats; |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | struct ath9k_debug { |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 155 | struct dentry *debugfs_phy; |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 156 | struct dentry *debugfs_debug; |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 157 | struct dentry *debugfs_dma; |
| 158 | struct dentry *debugfs_interrupt; |
| 159 | struct dentry *debugfs_rcstat; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 160 | struct dentry *debugfs_wiphy; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 161 | struct dentry *debugfs_xmit; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 162 | struct dentry *debugfs_recv; |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 163 | struct ath_stats stats; |
| 164 | }; |
| 165 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 166 | int ath9k_init_debug(struct ath_hw *ah); |
| 167 | void ath9k_exit_debug(struct ath_hw *ah); |
| 168 | |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 169 | int ath9k_debug_create_root(void); |
| 170 | void ath9k_debug_remove_root(void); |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 171 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 172 | void ath_debug_stat_rc(struct ath_softc *sc, int final_rate); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 173 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq, |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 174 | struct ath_buf *bf, struct ath_tx_status *ts); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 175 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs); |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 176 | void ath_debug_stat_retries(struct ath_softc *sc, int rix, |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame] | 177 | int xretries, int retries, u8 per); |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 178 | |
| 179 | #else |
| 180 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 181 | static inline int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 182 | { |
| 183 | return 0; |
| 184 | } |
| 185 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 186 | static inline void ath9k_exit_debug(struct ath_hw *ah) |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 187 | { |
| 188 | } |
| 189 | |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 190 | static inline int ath9k_debug_create_root(void) |
| 191 | { |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | static inline void ath9k_debug_remove_root(void) |
| 196 | { |
| 197 | } |
| 198 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 199 | static inline void ath_debug_stat_interrupt(struct ath_softc *sc, |
| 200 | enum ath9k_int status) |
| 201 | { |
| 202 | } |
| 203 | |
| 204 | static inline void ath_debug_stat_rc(struct ath_softc *sc, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 205 | int final_rate) |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 206 | { |
| 207 | } |
| 208 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 209 | static inline void ath_debug_stat_tx(struct ath_softc *sc, |
| 210 | struct ath_txq *txq, |
Felix Fietkau | 32ffb1f | 2010-03-31 15:41:36 -0700 | [diff] [blame] | 211 | struct ath_buf *bf, |
| 212 | struct ath_tx_status *ts) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 213 | { |
| 214 | } |
| 215 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 216 | static inline void ath_debug_stat_rx(struct ath_softc *sc, |
Felix Fietkau | 32ffb1f | 2010-03-31 15:41:36 -0700 | [diff] [blame] | 217 | struct ath_rx_status *rs) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 218 | { |
| 219 | } |
| 220 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 221 | static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix, |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame] | 222 | int xretries, int retries, u8 per) |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 223 | { |
| 224 | } |
| 225 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 226 | #endif /* CONFIG_ATH9K_DEBUGFS */ |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 227 | |
| 228 | #endif /* DEBUG_H */ |