debug.h 5.3 KB

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