debug.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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_ANY = 0xffffffff
  32. };
  33. #define DBG_DEFAULT (ATH_DBG_FATAL)
  34. #ifdef CONFIG_ATH9K_DEBUG
  35. /**
  36. * struct ath_interrupt_stats - Contains statistics about interrupts
  37. * @total: Total no. of interrupts generated so far
  38. * @rxok: RX with no errors
  39. * @rxeol: RX with no more RXDESC available
  40. * @rxorn: RX FIFO overrun
  41. * @txok: TX completed at the requested rate
  42. * @txurn: TX FIFO underrun
  43. * @mib: MIB regs reaching its threshold
  44. * @rxphyerr: RX with phy errors
  45. * @rx_keycache_miss: RX with key cache misses
  46. * @swba: Software Beacon Alert
  47. * @bmiss: Beacon Miss
  48. * @bnr: Beacon Not Ready
  49. * @cst: Carrier Sense TImeout
  50. * @gtt: Global TX Timeout
  51. * @tim: RX beacon TIM occurrence
  52. * @cabend: RX End of CAB traffic
  53. * @dtimsync: DTIM sync lossage
  54. * @dtim: RX Beacon with DTIM
  55. */
  56. struct ath_interrupt_stats {
  57. u32 total;
  58. u32 rxok;
  59. u32 rxeol;
  60. u32 rxorn;
  61. u32 txok;
  62. u32 txeol;
  63. u32 txurn;
  64. u32 mib;
  65. u32 rxphyerr;
  66. u32 rx_keycache_miss;
  67. u32 swba;
  68. u32 bmiss;
  69. u32 bnr;
  70. u32 cst;
  71. u32 gtt;
  72. u32 tim;
  73. u32 cabend;
  74. u32 dtimsync;
  75. u32 dtim;
  76. };
  77. struct ath_rc_stats {
  78. u32 success;
  79. u32 retries;
  80. u32 xretries;
  81. u8 per;
  82. };
  83. struct ath_stats {
  84. struct ath_interrupt_stats istats;
  85. struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
  86. };
  87. struct ath9k_debug {
  88. int debug_mask;
  89. struct dentry *debugfs_phy;
  90. struct dentry *debugfs_debug;
  91. struct dentry *debugfs_dma;
  92. struct dentry *debugfs_interrupt;
  93. struct dentry *debugfs_rcstat;
  94. struct dentry *debugfs_wiphy;
  95. struct ath_stats stats;
  96. };
  97. void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
  98. int ath9k_init_debug(struct ath_softc *sc);
  99. void ath9k_exit_debug(struct ath_softc *sc);
  100. int ath9k_debug_create_root(void);
  101. void ath9k_debug_remove_root(void);
  102. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  103. void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
  104. void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  105. int xretries, int retries, u8 per);
  106. #else
  107. static inline void DPRINTF(struct ath_softc *sc, int dbg_mask,
  108. const char *fmt, ...)
  109. {
  110. }
  111. static inline int ath9k_init_debug(struct ath_softc *sc)
  112. {
  113. return 0;
  114. }
  115. static inline void ath9k_exit_debug(struct ath_softc *sc)
  116. {
  117. }
  118. static inline int ath9k_debug_create_root(void)
  119. {
  120. return 0;
  121. }
  122. static inline void ath9k_debug_remove_root(void)
  123. {
  124. }
  125. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  126. enum ath9k_int status)
  127. {
  128. }
  129. static inline void ath_debug_stat_rc(struct ath_softc *sc,
  130. struct sk_buff *skb)
  131. {
  132. }
  133. static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  134. int xretries, int retries, u8 per)
  135. {
  136. }
  137. #endif /* CONFIG_ATH9K_DEBUG */
  138. #endif /* DEBUG_H */