debug.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. #define COMP_EASY_CONCURRENT COMP_USB /* reuse of this bit is OK */
  103. #define COMP_BT_COEXIST BIT(30)
  104. /*--------------------------------------------------------------
  105. Define the rt_print components
  106. --------------------------------------------------------------*/
  107. /* Define EEPROM and EFUSE check module bit*/
  108. #define EEPROM_W BIT(0)
  109. #define EFUSE_PG BIT(1)
  110. #define EFUSE_READ_ALL BIT(2)
  111. /* Define init check for module bit*/
  112. #define INIT_EEPROM BIT(0)
  113. #define INIT_TXPOWER BIT(1)
  114. #define INIT_IQK BIT(2)
  115. #define INIT_RF BIT(3)
  116. /* Define PHY-BB/RF/MAC check module bit */
  117. #define PHY_BBR BIT(0)
  118. #define PHY_BBW BIT(1)
  119. #define PHY_RFR BIT(2)
  120. #define PHY_RFW BIT(3)
  121. #define PHY_MACR BIT(4)
  122. #define PHY_MACW BIT(5)
  123. #define PHY_ALLR BIT(6)
  124. #define PHY_ALLW BIT(7)
  125. #define PHY_TXPWR BIT(8)
  126. #define PHY_PWRDIFF BIT(9)
  127. /* Define Dynamic Mechanism check module bit --> FDM */
  128. #define WA_IOT BIT(0)
  129. #define DM_PWDB BIT(1)
  130. #define DM_MONITOR BIT(2)
  131. #define DM_DIG BIT(3)
  132. #define DM_EDCA_TURBO BIT(4)
  133. #define DM_PWDB BIT(1)
  134. enum dbgp_flag_e {
  135. FQOS = 0,
  136. FTX = 1,
  137. FRX = 2,
  138. FSEC = 3,
  139. FMGNT = 4,
  140. FMLME = 5,
  141. FRESOURCE = 6,
  142. FBEACON = 7,
  143. FISR = 8,
  144. FPHY = 9,
  145. FMP = 10,
  146. FEEPROM = 11,
  147. FPWR = 12,
  148. FDM = 13,
  149. FDBGCtrl = 14,
  150. FC2H = 15,
  151. FBT = 16,
  152. FINIT = 17,
  153. FIOCTL = 18,
  154. DBGP_TYPE_MAX
  155. };
  156. #ifdef CONFIG_RTLWIFI_DEBUG
  157. #define RT_ASSERT(_exp, fmt, ...) \
  158. do { \
  159. if (!(_exp)) { \
  160. printk(KERN_DEBUG KBUILD_MODNAME ":%s(): " fmt, \
  161. __func__, ##__VA_ARGS__); \
  162. } \
  163. } while (0)
  164. #define RT_TRACE(rtlpriv, comp, level, fmt, ...) \
  165. do { \
  166. if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \
  167. ((level) <= rtlpriv->dbg.global_debuglevel))) { \
  168. printk(KERN_DEBUG KBUILD_MODNAME ":%s():<%lx-%x> " fmt, \
  169. __func__, in_interrupt(), in_atomic(), \
  170. ##__VA_ARGS__); \
  171. } \
  172. } while (0)
  173. #define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \
  174. do { \
  175. if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \
  176. printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, \
  177. ##__VA_ARGS__); \
  178. } \
  179. } while (0)
  180. #define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \
  181. _hexdatalen) \
  182. do { \
  183. if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) && \
  184. (_level <= rtlpriv->dbg.global_debuglevel))) { \
  185. printk(KERN_DEBUG "%s: In process \"%s\" (pid %i): %s\n", \
  186. KBUILD_MODNAME, current->comm, current->pid, \
  187. _titlestring); \
  188. print_hex_dump_bytes("", DUMP_PREFIX_NONE, \
  189. _hexdata, _hexdatalen); \
  190. } \
  191. } while (0)
  192. #else
  193. struct rtl_priv;
  194. __printf(2, 3)
  195. static inline void RT_ASSERT(int exp, const char *fmt, ...)
  196. {
  197. }
  198. __printf(4, 5)
  199. static inline void RT_TRACE(struct rtl_priv *rtlpriv,
  200. int comp, int level,
  201. const char *fmt, ...)
  202. {
  203. }
  204. __printf(4, 5)
  205. static inline void RTPRINT(struct rtl_priv *rtlpriv,
  206. int dbgtype, int dbgflag,
  207. const char *fmt, ...)
  208. {
  209. }
  210. static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
  211. int comp, int level,
  212. const char *titlestring,
  213. const void *hexdata, size_t hexdatalen)
  214. {
  215. }
  216. #endif
  217. void rtl_dbgp_flag_init(struct ieee80211_hw *hw);
  218. #endif