debug.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. int8_t rs_rssi_ctl0;
  161. int8_t rs_rssi_ctl1;
  162. int8_t rs_rssi_ctl2;
  163. int8_t rs_rssi_ext0;
  164. int8_t rs_rssi_ext1;
  165. int8_t rs_rssi_ext2;
  166. u8 rs_antenna;
  167. };
  168. enum ath_reset_type {
  169. RESET_TYPE_BB_HANG,
  170. RESET_TYPE_BB_WATCHDOG,
  171. RESET_TYPE_FATAL_INT,
  172. RESET_TYPE_TX_ERROR,
  173. RESET_TYPE_TX_HANG,
  174. RESET_TYPE_PLL_HANG,
  175. __RESET_TYPE_MAX
  176. };
  177. struct ath_stats {
  178. struct ath_interrupt_stats istats;
  179. struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
  180. struct ath_rx_stats rxstats;
  181. struct ath_dfs_stats dfs_stats;
  182. u32 reset[__RESET_TYPE_MAX];
  183. };
  184. #define ATH_DBG_MAX_SAMPLES 10
  185. struct ath_dbg_bb_mac_samp {
  186. u32 dma_dbg_reg_vals[ATH9K_NUM_DMA_DEBUG_REGS];
  187. u32 pcu_obs, pcu_cr, noise;
  188. struct {
  189. u64 jiffies;
  190. int8_t rssi_ctl0;
  191. int8_t rssi_ctl1;
  192. int8_t rssi_ctl2;
  193. int8_t rssi_ext0;
  194. int8_t rssi_ext1;
  195. int8_t rssi_ext2;
  196. int8_t rssi;
  197. bool isok;
  198. u8 rts_fail_cnt;
  199. u8 data_fail_cnt;
  200. u8 rateindex;
  201. u8 qid;
  202. u8 tid;
  203. u32 ba_low;
  204. u32 ba_high;
  205. } ts[ATH_DBG_MAX_SAMPLES];
  206. struct {
  207. u64 jiffies;
  208. int8_t rssi_ctl0;
  209. int8_t rssi_ctl1;
  210. int8_t rssi_ctl2;
  211. int8_t rssi_ext0;
  212. int8_t rssi_ext1;
  213. int8_t rssi_ext2;
  214. int8_t rssi;
  215. bool is_mybeacon;
  216. u8 antenna;
  217. u8 rate;
  218. } rs[ATH_DBG_MAX_SAMPLES];
  219. struct ath_cycle_counters cc;
  220. struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
  221. };
  222. struct ath9k_debug {
  223. struct dentry *debugfs_phy;
  224. u32 regidx;
  225. struct ath_stats stats;
  226. spinlock_t samp_lock;
  227. struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES];
  228. u8 sampidx;
  229. u8 tsidx;
  230. u8 rsidx;
  231. };
  232. int ath9k_init_debug(struct ath_hw *ah);
  233. void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
  234. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  235. void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
  236. struct ath_tx_status *ts, struct ath_txq *txq,
  237. unsigned int flags);
  238. void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
  239. #else
  240. static inline int ath9k_init_debug(struct ath_hw *ah)
  241. {
  242. return 0;
  243. }
  244. static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
  245. {
  246. }
  247. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  248. enum ath9k_int status)
  249. {
  250. }
  251. static inline void ath_debug_stat_tx(struct ath_softc *sc,
  252. struct ath_buf *bf,
  253. struct ath_tx_status *ts,
  254. struct ath_txq *txq,
  255. unsigned int flags)
  256. {
  257. }
  258. static inline void ath_debug_stat_rx(struct ath_softc *sc,
  259. struct ath_rx_status *rs)
  260. {
  261. }
  262. #endif /* CONFIG_ATH9K_DEBUGFS */
  263. #endif /* DEBUG_H */