debug.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications Inc.
  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. #ifndef DEBUG_H
  17. #define DEBUG_H
  18. #include "hw.h"
  19. #include "rc.h"
  20. #include "dfs_debug.h"
  21. struct ath_txq;
  22. struct ath_buf;
  23. #ifdef CONFIG_ATH9K_DEBUGFS
  24. #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
  25. #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++
  26. #else
  27. #define TX_STAT_INC(q, c) do { } while (0)
  28. #define RESET_STAT_INC(sc, type) do { } while (0)
  29. #endif
  30. #ifdef CONFIG_ATH9K_DEBUGFS
  31. /**
  32. * struct ath_interrupt_stats - Contains statistics about interrupts
  33. * @total: Total no. of interrupts generated so far
  34. * @rxok: RX with no errors
  35. * @rxlp: RX with low priority RX
  36. * @rxhp: RX with high priority, uapsd only
  37. * @rxeol: RX with no more RXDESC available
  38. * @rxorn: RX FIFO overrun
  39. * @txok: TX completed at the requested rate
  40. * @txurn: TX FIFO underrun
  41. * @mib: MIB regs reaching its threshold
  42. * @rxphyerr: RX with phy errors
  43. * @rx_keycache_miss: RX with key cache misses
  44. * @swba: Software Beacon Alert
  45. * @bmiss: Beacon Miss
  46. * @bnr: Beacon Not Ready
  47. * @cst: Carrier Sense TImeout
  48. * @gtt: Global TX Timeout
  49. * @tim: RX beacon TIM occurrence
  50. * @cabend: RX End of CAB traffic
  51. * @dtimsync: DTIM sync lossage
  52. * @dtim: RX Beacon with DTIM
  53. * @bb_watchdog: Baseband watchdog
  54. * @tsfoor: TSF out of range, indicates that the corrected TSF received
  55. * from a beacon differs from the PCU's internal TSF by more than a
  56. * (programmable) threshold
  57. */
  58. struct ath_interrupt_stats {
  59. u32 total;
  60. u32 rxok;
  61. u32 rxlp;
  62. u32 rxhp;
  63. u32 rxeol;
  64. u32 rxorn;
  65. u32 txok;
  66. u32 txeol;
  67. u32 txurn;
  68. u32 mib;
  69. u32 rxphyerr;
  70. u32 rx_keycache_miss;
  71. u32 swba;
  72. u32 bmiss;
  73. u32 bnr;
  74. u32 cst;
  75. u32 gtt;
  76. u32 tim;
  77. u32 cabend;
  78. u32 dtimsync;
  79. u32 dtim;
  80. u32 bb_watchdog;
  81. u32 tsfoor;
  82. };
  83. /**
  84. * struct ath_tx_stats - Statistics about TX
  85. * @tx_pkts_all: No. of total frames transmitted, including ones that
  86. may have had errors.
  87. * @tx_bytes_all: No. of total bytes transmitted, including ones that
  88. may have had errors.
  89. * @queued: Total MPDUs (non-aggr) queued
  90. * @completed: Total MPDUs (non-aggr) completed
  91. * @a_aggr: Total no. of aggregates queued
  92. * @a_queued_hw: Total AMPDUs queued to hardware
  93. * @a_queued_sw: Total AMPDUs queued to software queues
  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. * @puttxbuf: Number of times hardware was given txbuf to write.
  107. * @txstart: Number of times hardware was told to start tx.
  108. * @txprocdesc: Number of times tx descriptor was processed
  109. */
  110. struct ath_tx_stats {
  111. u32 tx_pkts_all;
  112. u32 tx_bytes_all;
  113. u32 queued;
  114. u32 completed;
  115. u32 xretries;
  116. u32 a_aggr;
  117. u32 a_queued_hw;
  118. u32 a_queued_sw;
  119. u32 a_completed;
  120. u32 a_retries;
  121. u32 a_xretries;
  122. u32 fifo_underrun;
  123. u32 xtxop;
  124. u32 timer_exp;
  125. u32 desc_cfg_err;
  126. u32 data_underrun;
  127. u32 delim_underrun;
  128. u32 puttxbuf;
  129. u32 txstart;
  130. u32 txprocdesc;
  131. };
  132. /**
  133. * struct ath_rx_stats - RX Statistics
  134. * @rx_pkts_all: No. of total frames received, including ones that
  135. may have had errors.
  136. * @rx_bytes_all: No. of total bytes received, including ones that
  137. may have had errors.
  138. * @crc_err: No. of frames with incorrect CRC value
  139. * @decrypt_crc_err: No. of frames whose CRC check failed after
  140. decryption process completed
  141. * @phy_err: No. of frames whose reception failed because the PHY
  142. encountered an error
  143. * @mic_err: No. of frames with incorrect TKIP MIC verification failure
  144. * @pre_delim_crc_err: Pre-Frame delimiter CRC error detections
  145. * @post_delim_crc_err: Post-Frame delimiter CRC error detections
  146. * @decrypt_busy_err: Decryption interruptions counter
  147. * @phy_err_stats: Individual PHY error statistics
  148. */
  149. struct ath_rx_stats {
  150. u32 rx_pkts_all;
  151. u32 rx_bytes_all;
  152. u32 crc_err;
  153. u32 decrypt_crc_err;
  154. u32 phy_err;
  155. u32 mic_err;
  156. u32 pre_delim_crc_err;
  157. u32 post_delim_crc_err;
  158. u32 decrypt_busy_err;
  159. u32 phy_err_stats[ATH9K_PHYERR_MAX];
  160. };
  161. enum ath_reset_type {
  162. RESET_TYPE_BB_HANG,
  163. RESET_TYPE_BB_WATCHDOG,
  164. RESET_TYPE_FATAL_INT,
  165. RESET_TYPE_TX_ERROR,
  166. RESET_TYPE_TX_HANG,
  167. RESET_TYPE_PLL_HANG,
  168. __RESET_TYPE_MAX
  169. };
  170. struct ath_stats {
  171. struct ath_interrupt_stats istats;
  172. struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
  173. struct ath_rx_stats rxstats;
  174. struct ath_dfs_stats dfs_stats;
  175. u32 reset[__RESET_TYPE_MAX];
  176. };
  177. #define ATH_DBG_MAX_SAMPLES 10
  178. struct ath_dbg_bb_mac_samp {
  179. u32 dma_dbg_reg_vals[ATH9K_NUM_DMA_DEBUG_REGS];
  180. u32 pcu_obs, pcu_cr, noise;
  181. struct {
  182. u64 jiffies;
  183. int8_t rssi_ctl0;
  184. int8_t rssi_ctl1;
  185. int8_t rssi_ctl2;
  186. int8_t rssi_ext0;
  187. int8_t rssi_ext1;
  188. int8_t rssi_ext2;
  189. int8_t rssi;
  190. bool isok;
  191. u8 rts_fail_cnt;
  192. u8 data_fail_cnt;
  193. u8 rateindex;
  194. u8 qid;
  195. u8 tid;
  196. u32 ba_low;
  197. u32 ba_high;
  198. } ts[ATH_DBG_MAX_SAMPLES];
  199. struct {
  200. u64 jiffies;
  201. int8_t rssi_ctl0;
  202. int8_t rssi_ctl1;
  203. int8_t rssi_ctl2;
  204. int8_t rssi_ext0;
  205. int8_t rssi_ext1;
  206. int8_t rssi_ext2;
  207. int8_t rssi;
  208. bool is_mybeacon;
  209. u8 antenna;
  210. u8 rate;
  211. } rs[ATH_DBG_MAX_SAMPLES];
  212. struct ath_cycle_counters cc;
  213. struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
  214. };
  215. struct ath9k_debug {
  216. struct dentry *debugfs_phy;
  217. u32 regidx;
  218. struct ath_stats stats;
  219. #ifdef CONFIG_ATH9K_MAC_DEBUG
  220. spinlock_t samp_lock;
  221. struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES];
  222. u8 sampidx;
  223. u8 tsidx;
  224. u8 rsidx;
  225. #endif
  226. };
  227. int ath9k_init_debug(struct ath_hw *ah);
  228. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  229. void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
  230. struct ath_tx_status *ts, struct ath_txq *txq,
  231. unsigned int flags);
  232. void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
  233. #else
  234. static inline int ath9k_init_debug(struct ath_hw *ah)
  235. {
  236. return 0;
  237. }
  238. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  239. enum ath9k_int status)
  240. {
  241. }
  242. static inline void ath_debug_stat_tx(struct ath_softc *sc,
  243. struct ath_buf *bf,
  244. struct ath_tx_status *ts,
  245. struct ath_txq *txq,
  246. unsigned int flags)
  247. {
  248. }
  249. static inline void ath_debug_stat_rx(struct ath_softc *sc,
  250. struct ath_rx_status *rs)
  251. {
  252. }
  253. #endif /* CONFIG_ATH9K_DEBUGFS */
  254. #ifdef CONFIG_ATH9K_MAC_DEBUG
  255. void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
  256. #else
  257. static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
  258. {
  259. }
  260. #endif
  261. #endif /* DEBUG_H */