debug.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. * @rxeol: RX with no more RXDESC available
  33. * @rxorn: RX FIFO overrun
  34. * @txok: TX completed at the requested rate
  35. * @txurn: TX FIFO underrun
  36. * @mib: MIB regs reaching its threshold
  37. * @rxphyerr: RX with phy errors
  38. * @rx_keycache_miss: RX with key cache misses
  39. * @swba: Software Beacon Alert
  40. * @bmiss: Beacon Miss
  41. * @bnr: Beacon Not Ready
  42. * @cst: Carrier Sense TImeout
  43. * @gtt: Global TX Timeout
  44. * @tim: RX beacon TIM occurrence
  45. * @cabend: RX End of CAB traffic
  46. * @dtimsync: DTIM sync lossage
  47. * @dtim: RX Beacon with DTIM
  48. */
  49. struct ath_interrupt_stats {
  50. u32 total;
  51. u32 rxok;
  52. u32 rxeol;
  53. u32 rxorn;
  54. u32 txok;
  55. u32 txeol;
  56. u32 txurn;
  57. u32 mib;
  58. u32 rxphyerr;
  59. u32 rx_keycache_miss;
  60. u32 swba;
  61. u32 bmiss;
  62. u32 bnr;
  63. u32 cst;
  64. u32 gtt;
  65. u32 tim;
  66. u32 cabend;
  67. u32 dtimsync;
  68. u32 dtim;
  69. };
  70. struct ath_rc_stats {
  71. u32 success;
  72. u32 retries;
  73. u32 xretries;
  74. u8 per;
  75. };
  76. /**
  77. * struct ath_tx_stats - Statistics about TX
  78. * @queued: Total MPDUs (non-aggr) queued
  79. * @completed: Total MPDUs (non-aggr) completed
  80. * @a_aggr: Total no. of aggregates queued
  81. * @a_queued: Total AMPDUs queued
  82. * @a_completed: Total AMPDUs completed
  83. * @a_retries: No. of AMPDUs retried (SW)
  84. * @a_xretries: No. of AMPDUs dropped due to xretries
  85. * @fifo_underrun: FIFO underrun occurrences
  86. Valid only for:
  87. - non-aggregate condition.
  88. - first packet of aggregate.
  89. * @xtxop: No. of frames filtered because of TXOP limit
  90. * @timer_exp: Transmit timer expiry
  91. * @desc_cfg_err: Descriptor configuration errors
  92. * @data_urn: TX data underrun errors
  93. * @delim_urn: TX delimiter underrun errors
  94. */
  95. struct ath_tx_stats {
  96. u32 queued;
  97. u32 completed;
  98. u32 a_aggr;
  99. u32 a_queued;
  100. u32 a_completed;
  101. u32 a_retries;
  102. u32 a_xretries;
  103. u32 fifo_underrun;
  104. u32 xtxop;
  105. u32 timer_exp;
  106. u32 desc_cfg_err;
  107. u32 data_underrun;
  108. u32 delim_underrun;
  109. };
  110. struct ath_stats {
  111. struct ath_interrupt_stats istats;
  112. struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
  113. struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
  114. };
  115. struct ath9k_debug {
  116. struct dentry *debugfs_phy;
  117. struct dentry *debugfs_debug;
  118. struct dentry *debugfs_dma;
  119. struct dentry *debugfs_interrupt;
  120. struct dentry *debugfs_rcstat;
  121. struct dentry *debugfs_wiphy;
  122. struct dentry *debugfs_xmit;
  123. struct ath_stats stats;
  124. };
  125. int ath9k_init_debug(struct ath_hw *ah);
  126. void ath9k_exit_debug(struct ath_hw *ah);
  127. int ath9k_debug_create_root(void);
  128. void ath9k_debug_remove_root(void);
  129. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  130. void ath_debug_stat_rc(struct ath_softc *sc, int final_rate);
  131. void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
  132. struct ath_buf *bf);
  133. void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  134. int xretries, int retries, u8 per);
  135. #else
  136. static inline int ath9k_init_debug(struct ath_hw *ah)
  137. {
  138. return 0;
  139. }
  140. static inline void ath9k_exit_debug(struct ath_hw *ah)
  141. {
  142. }
  143. static inline int ath9k_debug_create_root(void)
  144. {
  145. return 0;
  146. }
  147. static inline void ath9k_debug_remove_root(void)
  148. {
  149. }
  150. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  151. enum ath9k_int status)
  152. {
  153. }
  154. static inline void ath_debug_stat_rc(struct ath_softc *sc,
  155. int final_rate)
  156. {
  157. }
  158. static inline void ath_debug_stat_tx(struct ath_softc *sc,
  159. struct ath_txq *txq,
  160. struct ath_buf *bf)
  161. {
  162. }
  163. static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  164. int xretries, int retries, u8 per)
  165. {
  166. }
  167. #endif /* CONFIG_ATH9K_DEBUGFS */
  168. #endif /* DEBUG_H */