debug.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 Realtek Corporation.
  4. *
  5. * Tmis program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * Tmis program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * tmis program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * Tme full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * wlanfae <wlanfae@realtek.com>
  23. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  24. * Hsinchu 300, Taiwan.
  25. *
  26. * Larry Finger <Larry.Finger@lwfinger.net>
  27. *****************************************************************************/
  28. #ifndef __RTL_DEBUG_H__
  29. #define __RTL_DEBUG_H__
  30. /*--------------------------------------------------------------
  31. Debug level
  32. --------------------------------------------------------------*/
  33. /*
  34. *Fatal bug.
  35. *For example, Tx/Rx/IO locked up,
  36. *memory access violation,
  37. *resource allocation failed,
  38. *unexpected HW behavior, HW BUG
  39. *and so on.
  40. */
  41. #define DBG_EMERG 0
  42. /*
  43. *Abnormal, rare, or unexpeted cases.
  44. *For example, Packet/IO Ctl canceled,
  45. *device suprisely unremoved and so on.
  46. */
  47. #define DBG_WARNING 2
  48. /*
  49. *Normal case driver developer should
  50. *open, we can see link status like
  51. *assoc/AddBA/DHCP/adapter start and
  52. *so on basic and useful infromations.
  53. */
  54. #define DBG_DMESG 3
  55. /*
  56. *Normal case with useful information
  57. *about current SW or HW state.
  58. *For example, Tx/Rx descriptor to fill,
  59. *Tx/Rx descriptor completed status,
  60. *SW protocol state change, dynamic
  61. *mechanism state change and so on.
  62. */
  63. #define DBG_LOUD 4
  64. /*
  65. *Normal case with detail execution
  66. *flow or information.
  67. */
  68. #define DBG_TRACE 5
  69. /*--------------------------------------------------------------
  70. Define the rt_trace components
  71. --------------------------------------------------------------*/
  72. #define COMP_ERR BIT(0)
  73. #define COMP_FW BIT(1)
  74. #define COMP_INIT BIT(2) /*For init/deinit */
  75. #define COMP_RECV BIT(3) /*For Rx. */
  76. #define COMP_SEND BIT(4) /*For Tx. */
  77. #define COMP_MLME BIT(5) /*For MLME. */
  78. #define COMP_SCAN BIT(6) /*For Scan. */
  79. #define COMP_INTR BIT(7) /*For interrupt Related. */
  80. #define COMP_LED BIT(8) /*For LED. */
  81. #define COMP_SEC BIT(9) /*For sec. */
  82. #define COMP_BEACON BIT(10) /*For beacon. */
  83. #define COMP_RATE BIT(11) /*For rate. */
  84. #define COMP_RXDESC BIT(12) /*For rx desc. */
  85. #define COMP_DIG BIT(13) /*For DIG */
  86. #define COMP_TXAGC BIT(14) /*For Tx power */
  87. #define COMP_HIPWR BIT(15) /*For High Power Mechanism */
  88. #define COMP_POWER BIT(16) /*For lps/ips/aspm. */
  89. #define COMP_POWER_TRACKING BIT(17) /*For TX POWER TRACKING */
  90. #define COMP_BB_POWERSAVING BIT(18)
  91. #define COMP_SWAS BIT(19) /*For SW Antenna Switch */
  92. #define COMP_RF BIT(20) /*For RF. */
  93. #define COMP_TURBO BIT(21) /*For EDCA TURBO. */
  94. #define COMP_RATR BIT(22)
  95. #define COMP_CMD BIT(23)
  96. #define COMP_EFUSE BIT(24)
  97. #define COMP_QOS BIT(25)
  98. #define COMP_MAC80211 BIT(26)
  99. #define COMP_REGD BIT(27)
  100. #define COMP_CHAN BIT(28)
  101. #define COMP_USB BIT(29)
  102. /*--------------------------------------------------------------
  103. Define the rt_print components
  104. --------------------------------------------------------------*/
  105. /* Define EEPROM and EFUSE check module bit*/
  106. #define EEPROM_W BIT(0)
  107. #define EFUSE_PG BIT(1)
  108. #define EFUSE_READ_ALL BIT(2)
  109. /* Define init check for module bit*/
  110. #define INIT_EEPROM BIT(0)
  111. #define INIT_TxPower BIT(1)
  112. #define INIT_IQK BIT(2)
  113. #define INIT_RF BIT(3)
  114. /* Define PHY-BB/RF/MAC check module bit */
  115. #define PHY_BBR BIT(0)
  116. #define PHY_BBW BIT(1)
  117. #define PHY_RFR BIT(2)
  118. #define PHY_RFW BIT(3)
  119. #define PHY_MACR BIT(4)
  120. #define PHY_MACW BIT(5)
  121. #define PHY_ALLR BIT(6)
  122. #define PHY_ALLW BIT(7)
  123. #define PHY_TXPWR BIT(8)
  124. #define PHY_PWRDIFF BIT(9)
  125. enum dbgp_flag_e {
  126. FQOS = 0,
  127. FTX = 1,
  128. FRX = 2,
  129. FSEC = 3,
  130. FMGNT = 4,
  131. FMLME = 5,
  132. FRESOURCE = 6,
  133. FBEACON = 7,
  134. FISR = 8,
  135. FPHY = 9,
  136. FMP = 10,
  137. FEEPROM = 11,
  138. FPWR = 12,
  139. FDM = 13,
  140. FDBGCtrl = 14,
  141. FC2H = 15,
  142. FBT = 16,
  143. FINIT = 17,
  144. FIOCTL = 18,
  145. DBGP_TYPE_MAX
  146. };
  147. #ifdef CONFIG_RTLWIFI_DEBUG
  148. #define RT_ASSERT(_exp, fmt, ...) \
  149. do { \
  150. if (!(_exp)) { \
  151. printk(KERN_DEBUG KBUILD_MODNAME ":%s(): " fmt, \
  152. __func__, ##__VA_ARGS__); \
  153. } \
  154. } while (0)
  155. #define RT_TRACE(rtlpriv, comp, level, fmt, ...) \
  156. do { \
  157. if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \
  158. ((level) <= rtlpriv->dbg.global_debuglevel))) { \
  159. printk(KERN_DEBUG KBUILD_MODNAME ":%s():<%lx-%x> " fmt, \
  160. __func__, in_interrupt(), in_atomic(), \
  161. ##__VA_ARGS__); \
  162. } \
  163. } while (0)
  164. #define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \
  165. do { \
  166. if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \
  167. printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, \
  168. ##__VA_ARGS__); \
  169. } \
  170. } while (0)
  171. #define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \
  172. _hexdatalen) \
  173. do { \
  174. if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) && \
  175. (_level <= rtlpriv->dbg.global_debuglevel))) { \
  176. printk(KERN_DEBUG "%s: In process \"%s\" (pid %i): %s\n", \
  177. KBUILD_MODNAME, current->comm, current->pid, \
  178. _titlestring); \
  179. print_hex_dump_bytes("", DUMP_PREFIX_NONE, \
  180. _hexdata, _hexdatalen); \
  181. } \
  182. } while (0)
  183. #else
  184. struct rtl_priv;
  185. __printf(2, 3)
  186. static inline void RT_ASSERT(int exp, const char *fmt, ...)
  187. {
  188. }
  189. __printf(4, 5)
  190. static inline void RT_TRACE(struct rtl_priv *rtlpriv,
  191. int comp, int level,
  192. const char *fmt, ...)
  193. {
  194. }
  195. __printf(4, 5)
  196. static inline void RTPRINT(struct rtl_priv *rtlpriv,
  197. int dbgtype, int dbgflag,
  198. const char *fmt, ...)
  199. {
  200. }
  201. static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
  202. int comp, int level,
  203. const char *titlestring,
  204. const void *hexdata, size_t hexdatalen)
  205. {
  206. }
  207. #endif
  208. void rtl_dbgp_flag_init(struct ieee80211_hw *hw);
  209. #endif