debug.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * Copyright (c) 2008-2009 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. #else
  25. #define TX_STAT_INC(q, c) do { } while (0)
  26. #endif
  27. #ifdef CONFIG_ATH9K_DEBUGFS
  28. /**
  29. * struct ath_interrupt_stats - Contains statistics about interrupts
  30. * @total: Total no. of interrupts generated so far
  31. * @rxok: RX with no errors
  32. * @rxlp: RX with low priority RX
  33. * @rxhp: RX with high priority, uapsd only
  34. * @rxeol: RX with no more RXDESC available
  35. * @rxorn: RX FIFO overrun
  36. * @txok: TX completed at the requested rate
  37. * @txurn: TX FIFO underrun
  38. * @mib: MIB regs reaching its threshold
  39. * @rxphyerr: RX with phy errors
  40. * @rx_keycache_miss: RX with key cache misses
  41. * @swba: Software Beacon Alert
  42. * @bmiss: Beacon Miss
  43. * @bnr: Beacon Not Ready
  44. * @cst: Carrier Sense TImeout
  45. * @gtt: Global TX Timeout
  46. * @tim: RX beacon TIM occurrence
  47. * @cabend: RX End of CAB traffic
  48. * @dtimsync: DTIM sync lossage
  49. * @dtim: RX Beacon with DTIM
  50. * @bb_watchdog: Baseband watchdog
  51. */
  52. struct ath_interrupt_stats {
  53. u32 total;
  54. u32 rxok;
  55. u32 rxlp;
  56. u32 rxhp;
  57. u32 rxeol;
  58. u32 rxorn;
  59. u32 txok;
  60. u32 txeol;
  61. u32 txurn;
  62. u32 mib;
  63. u32 rxphyerr;
  64. u32 rx_keycache_miss;
  65. u32 swba;
  66. u32 bmiss;
  67. u32 bnr;
  68. u32 cst;
  69. u32 gtt;
  70. u32 tim;
  71. u32 cabend;
  72. u32 dtimsync;
  73. u32 dtim;
  74. u32 bb_watchdog;
  75. };
  76. struct ath_rc_stats {
  77. u32 success;
  78. u32 retries;
  79. u32 xretries;
  80. u8 per;
  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: Total AMPDUs queued
  92. * @a_completed: Total AMPDUs completed
  93. * @a_retries: No. of AMPDUs retried (SW)
  94. * @a_xretries: No. of AMPDUs dropped due to xretries
  95. * @fifo_underrun: FIFO underrun occurrences
  96. Valid only for:
  97. - non-aggregate condition.
  98. - first packet of aggregate.
  99. * @xtxop: No. of frames filtered because of TXOP limit
  100. * @timer_exp: Transmit timer expiry
  101. * @desc_cfg_err: Descriptor configuration errors
  102. * @data_urn: TX data underrun errors
  103. * @delim_urn: TX delimiter underrun errors
  104. */
  105. struct ath_tx_stats {
  106. u32 tx_pkts_all;
  107. u32 tx_bytes_all;
  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. /**
  123. * struct ath_rx_stats - RX Statistics
  124. * @rx_pkts_all: No. of total frames received, including ones that
  125. may have had errors.
  126. * @rx_bytes_all: No. of total bytes received, including ones that
  127. may have had errors.
  128. * @crc_err: No. of frames with incorrect CRC value
  129. * @decrypt_crc_err: No. of frames whose CRC check failed after
  130. decryption process completed
  131. * @phy_err: No. of frames whose reception failed because the PHY
  132. encountered an error
  133. * @mic_err: No. of frames with incorrect TKIP MIC verification failure
  134. * @pre_delim_crc_err: Pre-Frame delimiter CRC error detections
  135. * @post_delim_crc_err: Post-Frame delimiter CRC error detections
  136. * @decrypt_busy_err: Decryption interruptions counter
  137. * @phy_err_stats: Individual PHY error statistics
  138. */
  139. struct ath_rx_stats {
  140. u32 rx_pkts_all;
  141. u32 rx_bytes_all;
  142. u32 crc_err;
  143. u32 decrypt_crc_err;
  144. u32 phy_err;
  145. u32 mic_err;
  146. u32 pre_delim_crc_err;
  147. u32 post_delim_crc_err;
  148. u32 decrypt_busy_err;
  149. u32 phy_err_stats[ATH9K_PHYERR_MAX];
  150. };
  151. struct ath_stats {
  152. struct ath_interrupt_stats istats;
  153. struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
  154. struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
  155. struct ath_rx_stats rxstats;
  156. };
  157. struct ath9k_debug {
  158. struct dentry *debugfs_phy;
  159. u32 regidx;
  160. struct ath_stats stats;
  161. };
  162. int ath9k_init_debug(struct ath_hw *ah);
  163. void ath9k_exit_debug(struct ath_hw *ah);
  164. int ath9k_debug_create_root(void);
  165. void ath9k_debug_remove_root(void);
  166. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  167. void ath_debug_stat_rc(struct ath_softc *sc, int final_rate);
  168. void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
  169. struct ath_buf *bf, struct ath_tx_status *ts);
  170. void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
  171. void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  172. int xretries, int retries, u8 per);
  173. #else
  174. static inline int ath9k_init_debug(struct ath_hw *ah)
  175. {
  176. return 0;
  177. }
  178. static inline void ath9k_exit_debug(struct ath_hw *ah)
  179. {
  180. }
  181. static inline int ath9k_debug_create_root(void)
  182. {
  183. return 0;
  184. }
  185. static inline void ath9k_debug_remove_root(void)
  186. {
  187. }
  188. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  189. enum ath9k_int status)
  190. {
  191. }
  192. static inline void ath_debug_stat_rc(struct ath_softc *sc,
  193. int final_rate)
  194. {
  195. }
  196. static inline void ath_debug_stat_tx(struct ath_softc *sc,
  197. struct ath_txq *txq,
  198. struct ath_buf *bf,
  199. struct ath_tx_status *ts)
  200. {
  201. }
  202. static inline void ath_debug_stat_rx(struct ath_softc *sc,
  203. struct ath_rx_status *rs)
  204. {
  205. }
  206. static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  207. int xretries, int retries, u8 per)
  208. {
  209. }
  210. #endif /* CONFIG_ATH9K_DEBUGFS */
  211. #endif /* DEBUG_H */