debug.h 7.3 KB

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