debug.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. enum ATH_DEBUG {
  19. ATH_DBG_RESET = 0x00000001,
  20. ATH_DBG_QUEUE = 0x00000002,
  21. ATH_DBG_EEPROM = 0x00000004,
  22. ATH_DBG_CALIBRATE = 0x00000008,
  23. ATH_DBG_INTERRUPT = 0x00000010,
  24. ATH_DBG_REGULATORY = 0x00000020,
  25. ATH_DBG_ANI = 0x00000040,
  26. ATH_DBG_XMIT = 0x00000080,
  27. ATH_DBG_BEACON = 0x00000100,
  28. ATH_DBG_CONFIG = 0x00000200,
  29. ATH_DBG_FATAL = 0x00000400,
  30. ATH_DBG_PS = 0x00000800,
  31. ATH_DBG_HWTIMER = 0x00001000,
  32. ATH_DBG_ANY = 0xffffffff
  33. };
  34. #define DBG_DEFAULT (ATH_DBG_FATAL)
  35. struct ath_txq;
  36. struct ath_buf;
  37. #ifdef CONFIG_ATH9K_DEBUG
  38. #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
  39. #else
  40. #define TX_STAT_INC(q, c) do { } while (0)
  41. #endif
  42. #ifdef CONFIG_ATH9K_DEBUG
  43. /**
  44. * struct ath_interrupt_stats - Contains statistics about interrupts
  45. * @total: Total no. of interrupts generated so far
  46. * @rxok: RX with no errors
  47. * @rxeol: RX with no more RXDESC available
  48. * @rxorn: RX FIFO overrun
  49. * @txok: TX completed at the requested rate
  50. * @txurn: TX FIFO underrun
  51. * @mib: MIB regs reaching its threshold
  52. * @rxphyerr: RX with phy errors
  53. * @rx_keycache_miss: RX with key cache misses
  54. * @swba: Software Beacon Alert
  55. * @bmiss: Beacon Miss
  56. * @bnr: Beacon Not Ready
  57. * @cst: Carrier Sense TImeout
  58. * @gtt: Global TX Timeout
  59. * @tim: RX beacon TIM occurrence
  60. * @cabend: RX End of CAB traffic
  61. * @dtimsync: DTIM sync lossage
  62. * @dtim: RX Beacon with DTIM
  63. */
  64. struct ath_interrupt_stats {
  65. u32 total;
  66. u32 rxok;
  67. u32 rxeol;
  68. u32 rxorn;
  69. u32 txok;
  70. u32 txeol;
  71. u32 txurn;
  72. u32 mib;
  73. u32 rxphyerr;
  74. u32 rx_keycache_miss;
  75. u32 swba;
  76. u32 bmiss;
  77. u32 bnr;
  78. u32 cst;
  79. u32 gtt;
  80. u32 tim;
  81. u32 cabend;
  82. u32 dtimsync;
  83. u32 dtim;
  84. };
  85. struct ath_rc_stats {
  86. u32 success;
  87. u32 retries;
  88. u32 xretries;
  89. u8 per;
  90. };
  91. /**
  92. * struct ath_tx_stats - Statistics about TX
  93. * @queued: Total MPDUs (non-aggr) queued
  94. * @completed: Total MPDUs (non-aggr) completed
  95. * @a_aggr: Total no. of aggregates queued
  96. * @a_queued: Total AMPDUs queued
  97. * @a_completed: Total AMPDUs completed
  98. * @a_retries: No. of AMPDUs retried (SW)
  99. * @a_xretries: No. of AMPDUs dropped due to xretries
  100. * @fifo_underrun: FIFO underrun occurrences
  101. Valid only for:
  102. - non-aggregate condition.
  103. - first packet of aggregate.
  104. * @xtxop: No. of frames filtered because of TXOP limit
  105. * @timer_exp: Transmit timer expiry
  106. * @desc_cfg_err: Descriptor configuration errors
  107. * @data_urn: TX data underrun errors
  108. * @delim_urn: TX delimiter underrun errors
  109. */
  110. struct ath_tx_stats {
  111. u32 queued;
  112. u32 completed;
  113. u32 a_aggr;
  114. u32 a_queued;
  115. u32 a_completed;
  116. u32 a_retries;
  117. u32 a_xretries;
  118. u32 fifo_underrun;
  119. u32 xtxop;
  120. u32 timer_exp;
  121. u32 desc_cfg_err;
  122. u32 data_underrun;
  123. u32 delim_underrun;
  124. };
  125. struct ath_stats {
  126. struct ath_interrupt_stats istats;
  127. struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
  128. struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
  129. };
  130. struct ath9k_debug {
  131. int debug_mask;
  132. struct dentry *debugfs_phy;
  133. struct dentry *debugfs_debug;
  134. struct dentry *debugfs_dma;
  135. struct dentry *debugfs_interrupt;
  136. struct dentry *debugfs_rcstat;
  137. struct dentry *debugfs_wiphy;
  138. struct dentry *debugfs_xmit;
  139. struct ath_stats stats;
  140. };
  141. void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
  142. int ath9k_init_debug(struct ath_softc *sc);
  143. void ath9k_exit_debug(struct ath_softc *sc);
  144. int ath9k_debug_create_root(void);
  145. void ath9k_debug_remove_root(void);
  146. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  147. void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
  148. void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
  149. struct ath_buf *bf);
  150. void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  151. int xretries, int retries, u8 per);
  152. #else
  153. static inline void DPRINTF(struct ath_softc *sc, int dbg_mask,
  154. const char *fmt, ...)
  155. {
  156. }
  157. static inline int ath9k_init_debug(struct ath_softc *sc)
  158. {
  159. return 0;
  160. }
  161. static inline void ath9k_exit_debug(struct ath_softc *sc)
  162. {
  163. }
  164. static inline int ath9k_debug_create_root(void)
  165. {
  166. return 0;
  167. }
  168. static inline void ath9k_debug_remove_root(void)
  169. {
  170. }
  171. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  172. enum ath9k_int status)
  173. {
  174. }
  175. static inline void ath_debug_stat_rc(struct ath_softc *sc,
  176. struct sk_buff *skb)
  177. {
  178. }
  179. static inline void ath_debug_stat_tx(struct ath_softc *sc,
  180. struct ath_txq *txq,
  181. struct ath_buf *bf)
  182. {
  183. }
  184. static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  185. int xretries, int retries, u8 per)
  186. {
  187. }
  188. #endif /* CONFIG_ATH9K_DEBUG */
  189. #endif /* DEBUG_H */