debug.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 Realtek Corporation.
  4. *
  5. * This 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. * This 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. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *****************************************************************************/
  24. #ifndef __RTL_DEBUG_H__
  25. #define __RTL_DEBUG_H__
  26. /*--------------------------------------------------------------
  27. Debug level
  28. --------------------------------------------------------------*/
  29. /*
  30. *Fatal bug.
  31. *For example, Tx/Rx/IO locked up,
  32. *memory access violation,
  33. *resource allocation failed,
  34. *unexpected HW behavior, HW BUG
  35. *and so on.
  36. */
  37. /*#define DBG_EMERG 0 */
  38. /*
  39. *Abnormal, rare, or unexpeted cases.
  40. *For example, Packet/IO Ctl canceled,
  41. *device suprisely unremoved and so on.
  42. */
  43. #define DBG_WARNING 2
  44. /*
  45. *Normal case driver developer should
  46. *open, we can see link status like
  47. *assoc/AddBA/DHCP/adapter start and
  48. *so on basic and useful infromations.
  49. */
  50. #define DBG_DMESG 3
  51. /*
  52. *Normal case with useful information
  53. *about current SW or HW state.
  54. *For example, Tx/Rx descriptor to fill,
  55. *Tx/Rx descriptor completed status,
  56. *SW protocol state change, dynamic
  57. *mechanism state change and so on.
  58. */
  59. #define DBG_LOUD 4
  60. /*
  61. *Normal case with detail execution
  62. *flow or information.
  63. */
  64. #define DBG_TRACE 5
  65. /*--------------------------------------------------------------
  66. Define the rt_trace components
  67. --------------------------------------------------------------*/
  68. #define COMP_ERR BIT(0)
  69. #define COMP_FW BIT(1)
  70. #define COMP_INIT BIT(2) /*For init/deinit */
  71. #define COMP_RECV BIT(3) /*For Rx. */
  72. #define COMP_SEND BIT(4) /*For Tx. */
  73. #define COMP_MLME BIT(5) /*For MLME. */
  74. #define COMP_SCAN BIT(6) /*For Scan. */
  75. #define COMP_INTR BIT(7) /*For interrupt Related. */
  76. #define COMP_LED BIT(8) /*For LED. */
  77. #define COMP_SEC BIT(9) /*For sec. */
  78. #define COMP_BEACON BIT(10) /*For beacon. */
  79. #define COMP_RATE BIT(11) /*For rate. */
  80. #define COMP_RXDESC BIT(12) /*For rx desc. */
  81. #define COMP_DIG BIT(13) /*For DIG */
  82. #define COMP_TXAGC BIT(14) /*For Tx power */
  83. #define COMP_HIPWR BIT(15) /*For High Power Mechanism */
  84. #define COMP_POWER BIT(16) /*For lps/ips/aspm. */
  85. #define COMP_POWER_TRACKING BIT(17) /*For TX POWER TRACKING */
  86. #define COMP_BB_POWERSAVING BIT(18)
  87. #define COMP_SWAS BIT(19) /*For SW Antenna Switch */
  88. #define COMP_RF BIT(20) /*For RF. */
  89. #define COMP_TURBO BIT(21) /*For EDCA TURBO. */
  90. #define COMP_RATR BIT(22)
  91. #define COMP_CMD BIT(23)
  92. #define COMP_EFUSE BIT(24)
  93. #define COMP_QOS BIT(25)
  94. #define COMP_MAC80211 BIT(26)
  95. #define COMP_REGD BIT(27)
  96. #define COMP_CHAN BIT(28)
  97. #define COMP_USB BIT(29)
  98. #define COMP_EASY_CONCURRENT COMP_USB /* reuse of this bit is OK */
  99. #define COMP_BT_COEXIST BIT(30)
  100. #define COMP_IQK BIT(31)
  101. #define COMP_TX_REPORT BIT_ULL(32)
  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. /* Define Dynamic Mechanism check module bit --> FDM */
  126. #define WA_IOT BIT(0)
  127. #define DM_PWDB BIT(1)
  128. #define DM_MONITOR BIT(2)
  129. #define DM_DIG BIT(3)
  130. #define DM_EDCA_TURBO BIT(4)
  131. #define DM_PWDB BIT(1)
  132. enum dbgp_flag_e {
  133. FQOS = 0,
  134. FTX = 1,
  135. FRX = 2,
  136. FSEC = 3,
  137. FMGNT = 4,
  138. FMLME = 5,
  139. FRESOURCE = 6,
  140. FBEACON = 7,
  141. FISR = 8,
  142. FPHY = 9,
  143. FMP = 10,
  144. FEEPROM = 11,
  145. FPWR = 12,
  146. FDM = 13,
  147. FDBGCtrl = 14,
  148. FC2H = 15,
  149. FBT = 16,
  150. FINIT = 17,
  151. FIOCTL = 18,
  152. DBGP_TYPE_MAX
  153. };
  154. #ifdef CONFIG_RTLWIFI_DEBUG
  155. struct rtl_priv;
  156. __printf(4, 5)
  157. void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
  158. const char *fmt, ...);
  159. __printf(4, 5)
  160. void _rtl_dbg_print(struct rtl_priv *rtlpriv, u64 comp, int level,
  161. const char *fmt, ...);
  162. void _rtl_dbg_print_data(struct rtl_priv *rtlpriv, u64 comp, int level,
  163. const char *titlestring,
  164. const void *hexdata, int hexdatalen);
  165. #define RT_TRACE(rtlpriv, comp, level, fmt, ...) \
  166. _rtl_dbg_trace(rtlpriv, comp, level, \
  167. fmt, ##__VA_ARGS__)
  168. #define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \
  169. _rtl_dbg_print(rtlpriv, dbgtype, dbgflag, fmt, ##__VA_ARGS__)
  170. #define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \
  171. _hexdatalen) \
  172. _rtl_dbg_print_data(rtlpriv, _comp, _level, \
  173. _titlestring, _hexdata, _hexdatalen)
  174. #else
  175. struct rtl_priv;
  176. __printf(4, 5)
  177. static inline void RT_TRACE(struct rtl_priv *rtlpriv,
  178. u64 comp, int level,
  179. const char *fmt, ...)
  180. {
  181. }
  182. __printf(4, 5)
  183. static inline void RTPRINT(struct rtl_priv *rtlpriv,
  184. int dbgtype, int dbgflag,
  185. const char *fmt, ...)
  186. {
  187. }
  188. static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
  189. u64 comp, int level,
  190. const char *titlestring,
  191. const void *hexdata, size_t hexdatalen)
  192. {
  193. }
  194. #endif
  195. #ifdef CONFIG_RTLWIFI_DEBUG
  196. void rtl_debug_add_one(struct ieee80211_hw *hw);
  197. void rtl_debug_remove_one(struct ieee80211_hw *hw);
  198. void rtl_debugfs_add_topdir(void);
  199. void rtl_debugfs_remove_topdir(void);
  200. #else
  201. #define rtl_debug_add_one(hw)
  202. #define rtl_debug_remove_one(hw)
  203. #define rtl_debugfs_add_topdir()
  204. #define rtl_debugfs_remove_topdir()
  205. #endif
  206. #endif