debug.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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_REG_IO = 0x00000002,
  21. ATH_DBG_QUEUE = 0x00000004,
  22. ATH_DBG_EEPROM = 0x00000008,
  23. ATH_DBG_CALIBRATE = 0x00000010,
  24. ATH_DBG_CHANNEL = 0x00000020,
  25. ATH_DBG_INTERRUPT = 0x00000040,
  26. ATH_DBG_REGULATORY = 0x00000080,
  27. ATH_DBG_ANI = 0x00000100,
  28. ATH_DBG_POWER_MGMT = 0x00000200,
  29. ATH_DBG_XMIT = 0x00000400,
  30. ATH_DBG_BEACON = 0x00001000,
  31. ATH_DBG_CONFIG = 0x00002000,
  32. ATH_DBG_KEYCACHE = 0x00004000,
  33. ATH_DBG_FATAL = 0x00008000,
  34. ATH_DBG_ANY = 0xffffffff
  35. };
  36. #define DBG_DEFAULT (ATH_DBG_FATAL)
  37. #ifdef CONFIG_ATH9K_DEBUG
  38. /**
  39. * struct ath_interrupt_stats - Contains statistics about interrupts
  40. * @total: Total no. of interrupts generated so far
  41. * @rxok: RX with no errors
  42. * @rxeol: RX with no more RXDESC available
  43. * @rxorn: RX FIFO overrun
  44. * @txok: TX completed at the requested rate
  45. * @txurn: TX FIFO underrun
  46. * @mib: MIB regs reaching its threshold
  47. * @rxphyerr: RX with phy errors
  48. * @rx_keycache_miss: RX with key cache misses
  49. * @swba: Software Beacon Alert
  50. * @bmiss: Beacon Miss
  51. * @bnr: Beacon Not Ready
  52. * @cst: Carrier Sense TImeout
  53. * @gtt: Global TX Timeout
  54. * @tim: RX beacon TIM occurrence
  55. * @cabend: RX End of CAB traffic
  56. * @dtimsync: DTIM sync lossage
  57. * @dtim: RX Beacon with DTIM
  58. */
  59. struct ath_interrupt_stats {
  60. u32 total;
  61. u32 rxok;
  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. };
  80. struct ath_legacy_rc_stats {
  81. u32 success;
  82. };
  83. struct ath_11n_rc_stats {
  84. u32 success;
  85. u32 retries;
  86. u32 xretries;
  87. u8 per;
  88. };
  89. struct ath_stats {
  90. struct ath_interrupt_stats istats;
  91. struct ath_legacy_rc_stats legacy_rcstats[12]; /* max(11a,11b,11g) */
  92. struct ath_11n_rc_stats n_rcstats[16]; /* 0..15 MCS rates */
  93. };
  94. struct ath9k_debug {
  95. int debug_mask;
  96. struct dentry *debugfs_phy;
  97. struct dentry *debugfs_dma;
  98. struct dentry *debugfs_interrupt;
  99. struct dentry *debugfs_rcstat;
  100. struct dentry *debugfs_wiphy;
  101. struct ath_stats stats;
  102. };
  103. void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
  104. int ath9k_init_debug(struct ath_softc *sc);
  105. void ath9k_exit_debug(struct ath_softc *sc);
  106. int ath9k_debug_create_root(void);
  107. void ath9k_debug_remove_root(void);
  108. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  109. void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
  110. void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  111. int xretries, int retries, u8 per);
  112. #else
  113. static inline void DPRINTF(struct ath_softc *sc, int dbg_mask,
  114. const char *fmt, ...)
  115. {
  116. }
  117. static inline int ath9k_init_debug(struct ath_softc *sc)
  118. {
  119. return 0;
  120. }
  121. static inline void ath9k_exit_debug(struct ath_softc *sc)
  122. {
  123. }
  124. static inline int ath9k_debug_create_root(void)
  125. {
  126. return 0;
  127. }
  128. static inline void ath9k_debug_remove_root(void)
  129. {
  130. }
  131. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  132. enum ath9k_int status)
  133. {
  134. }
  135. static inline void ath_debug_stat_rc(struct ath_softc *sc,
  136. struct sk_buff *skb)
  137. {
  138. }
  139. static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  140. int xretries, int retries, u8 per)
  141. {
  142. }
  143. #endif /* CONFIG_ATH9K_DEBUG */
  144. #endif /* DEBUG_H */