debug.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * Copyright (c) 2007 Bruno Randolf <bruno@thinktube.com>
  3. *
  4. * This file is free software: you may copy, redistribute and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation, either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This file is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. *
  18. * This file incorporates work covered by the following copyright and
  19. * permission notice:
  20. *
  21. * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  22. * Copyright (c) 2004-2005 Atheros Communications, Inc.
  23. * Copyright (c) 2006 Devicescape Software, Inc.
  24. * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
  25. * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
  26. *
  27. * All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. * 1. Redistributions of source code must retain the above copyright
  33. * notice, this list of conditions and the following disclaimer,
  34. * without modification.
  35. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  36. * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
  37. * redistribution must be conditioned upon including a substantially
  38. * similar Disclaimer requirement for further binary redistribution.
  39. * 3. Neither the names of the above-listed copyright holders nor the names
  40. * of any contributors may be used to endorse or promote products derived
  41. * from this software without specific prior written permission.
  42. *
  43. * Alternatively, this software may be distributed under the terms of the
  44. * GNU General Public License ("GPL") version 2 as published by the Free
  45. * Software Foundation.
  46. *
  47. * NO WARRANTY
  48. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  49. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  50. * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
  51. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  52. * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
  53. * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  54. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  55. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  56. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  57. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  58. * THE POSSIBILITY OF SUCH DAMAGES.
  59. */
  60. #ifndef _ATH5K_DEBUG_H
  61. #define _ATH5K_DEBUG_H
  62. struct ath5k_softc;
  63. struct ath5k_hw;
  64. struct sk_buff;
  65. struct ath5k_buf;
  66. struct ath5k_dbg_info {
  67. unsigned int level; /* debug level */
  68. /* debugfs entries */
  69. struct dentry *debugfs_phydir;
  70. struct dentry *debugfs_debug;
  71. struct dentry *debugfs_registers;
  72. struct dentry *debugfs_beacon;
  73. struct dentry *debugfs_reset;
  74. };
  75. /**
  76. * enum ath5k_debug_level - ath5k debug level
  77. *
  78. * @ATH5K_DEBUG_RESET: reset processing
  79. * @ATH5K_DEBUG_INTR: interrupt handling
  80. * @ATH5K_DEBUG_MODE: mode init/setup
  81. * @ATH5K_DEBUG_XMIT: basic xmit operation
  82. * @ATH5K_DEBUG_BEACON: beacon handling
  83. * @ATH5K_DEBUG_CALIBRATE: periodic calibration
  84. * @ATH5K_DEBUG_TXPOWER: transmit power setting
  85. * @ATH5K_DEBUG_LED: led management
  86. * @ATH5K_DEBUG_DUMP_RX: print received skb content
  87. * @ATH5K_DEBUG_DUMP_TX: print transmit skb content
  88. * @ATH5K_DEBUG_DUMPBANDS: dump bands
  89. * @ATH5K_DEBUG_TRACE: trace function calls
  90. * @ATH5K_DEBUG_ANY: show at any debug level
  91. *
  92. * The debug level is used to control the amount and type of debugging output
  93. * we want to see. The debug level is given in calls to ATH5K_DBG to specify
  94. * where the message should appear, and the user can control the debugging
  95. * messages he wants to see, either by the module parameter 'debug' on module
  96. * load, or dynamically by using debugfs 'ath5k/phyX/debug'. these levels can
  97. * be combined together by bitwise OR.
  98. */
  99. enum ath5k_debug_level {
  100. ATH5K_DEBUG_RESET = 0x00000001,
  101. ATH5K_DEBUG_INTR = 0x00000002,
  102. ATH5K_DEBUG_MODE = 0x00000004,
  103. ATH5K_DEBUG_XMIT = 0x00000008,
  104. ATH5K_DEBUG_BEACON = 0x00000010,
  105. ATH5K_DEBUG_CALIBRATE = 0x00000020,
  106. ATH5K_DEBUG_TXPOWER = 0x00000040,
  107. ATH5K_DEBUG_LED = 0x00000080,
  108. ATH5K_DEBUG_DUMP_RX = 0x00000100,
  109. ATH5K_DEBUG_DUMP_TX = 0x00000200,
  110. ATH5K_DEBUG_DUMPBANDS = 0x00000400,
  111. ATH5K_DEBUG_TRACE = 0x00001000,
  112. ATH5K_DEBUG_ANY = 0xffffffff
  113. };
  114. #ifdef CONFIG_ATH5K_DEBUG
  115. #define ATH5K_TRACE(_sc) do { \
  116. if (unlikely((_sc)->debug.level & ATH5K_DEBUG_TRACE)) \
  117. printk(KERN_DEBUG "ath5k trace %s:%d\n", __func__, __LINE__); \
  118. } while (0)
  119. #define ATH5K_DBG(_sc, _m, _fmt, ...) do { \
  120. if (unlikely((_sc)->debug.level & (_m) && net_ratelimit())) \
  121. ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
  122. __func__, __LINE__, ##__VA_ARGS__); \
  123. } while (0)
  124. #define ATH5K_DBG_UNLIMIT(_sc, _m, _fmt, ...) do { \
  125. if (unlikely((_sc)->debug.level & (_m))) \
  126. ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
  127. __func__, __LINE__, ##__VA_ARGS__); \
  128. } while (0)
  129. void
  130. ath5k_debug_init(void);
  131. void
  132. ath5k_debug_init_device(struct ath5k_softc *sc);
  133. void
  134. ath5k_debug_finish(void);
  135. void
  136. ath5k_debug_finish_device(struct ath5k_softc *sc);
  137. void
  138. ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah);
  139. void
  140. ath5k_debug_dump_bands(struct ath5k_softc *sc);
  141. void
  142. ath5k_debug_dump_skb(struct ath5k_softc *sc,
  143. struct sk_buff *skb, const char *prefix, int tx);
  144. void
  145. ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf);
  146. #else /* no debugging */
  147. #include <linux/compiler.h>
  148. #define ATH5K_TRACE(_sc) typecheck(struct ath5k_softc *, (_sc))
  149. static inline void __attribute__ ((format (printf, 3, 4)))
  150. ATH5K_DBG(struct ath5k_softc *sc, unsigned int m, const char *fmt, ...) {}
  151. static inline void __attribute__ ((format (printf, 3, 4)))
  152. ATH5K_DBG_UNLIMIT(struct ath5k_softc *sc, unsigned int m, const char *fmt, ...)
  153. {}
  154. static inline void
  155. ath5k_debug_init(void) {}
  156. static inline void
  157. ath5k_debug_init_device(struct ath5k_softc *sc) {}
  158. static inline void
  159. ath5k_debug_finish(void) {}
  160. static inline void
  161. ath5k_debug_finish_device(struct ath5k_softc *sc) {}
  162. static inline void
  163. ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah) {}
  164. static inline void
  165. ath5k_debug_dump_bands(struct ath5k_softc *sc) {}
  166. static inline void
  167. ath5k_debug_dump_skb(struct ath5k_softc *sc,
  168. struct sk_buff *skb, const char *prefix, int tx) {}
  169. static inline void
  170. ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf) {}
  171. #endif /* ifdef CONFIG_ATH5K_DEBUG */
  172. #endif /* ifndef _ATH5K_DEBUG_H */