debug.h 5.9 KB

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