debug.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. enum dbgp_flag_e {
  128. FQOS = 0,
  129. FTX = 1,
  130. FRX = 2,
  131. FSEC = 3,
  132. FMGNT = 4,
  133. FMLME = 5,
  134. FRESOURCE = 6,
  135. FBEACON = 7,
  136. FISR = 8,
  137. FPHY = 9,
  138. FMP = 10,
  139. FEEPROM = 11,
  140. FPWR = 12,
  141. FDM = 13,
  142. FDBGCtrl = 14,
  143. FC2H = 15,
  144. FBT = 16,
  145. FINIT = 17,
  146. FIOCTL = 18,
  147. DBGP_TYPE_MAX
  148. };
  149. #ifdef CONFIG_RTLWIFI_DEBUG
  150. #define RT_ASSERT(_exp, fmt, ...) \
  151. do { \
  152. if (!(_exp)) { \
  153. printk(KERN_DEBUG KBUILD_MODNAME ":%s(): " fmt, \
  154. __func__, ##__VA_ARGS__); \
  155. } \
  156. } while (0)
  157. #define RT_TRACE(rtlpriv, comp, level, fmt, ...) \
  158. do { \
  159. if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \
  160. ((level) <= rtlpriv->dbg.global_debuglevel))) { \
  161. printk(KERN_DEBUG KBUILD_MODNAME ":%s():<%lx-%x> " fmt, \
  162. __func__, in_interrupt(), in_atomic(), \
  163. ##__VA_ARGS__); \
  164. } \
  165. } while (0)
  166. #define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \
  167. do { \
  168. if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \
  169. printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, \
  170. ##__VA_ARGS__); \
  171. } \
  172. } while (0)
  173. #define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \
  174. _hexdatalen) \
  175. do { \
  176. if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) && \
  177. (_level <= rtlpriv->dbg.global_debuglevel))) { \
  178. printk(KERN_DEBUG "%s: In process \"%s\" (pid %i): %s\n", \
  179. KBUILD_MODNAME, current->comm, current->pid, \
  180. _titlestring); \
  181. print_hex_dump_bytes("", DUMP_PREFIX_NONE, \
  182. _hexdata, _hexdatalen); \
  183. } \
  184. } while (0)
  185. #else
  186. struct rtl_priv;
  187. __printf(2, 3)
  188. static inline void RT_ASSERT(int exp, const char *fmt, ...)
  189. {
  190. }
  191. __printf(4, 5)
  192. static inline void RT_TRACE(struct rtl_priv *rtlpriv,
  193. int comp, int level,
  194. const char *fmt, ...)
  195. {
  196. }
  197. __printf(4, 5)
  198. static inline void RTPRINT(struct rtl_priv *rtlpriv,
  199. int dbgtype, int dbgflag,
  200. const char *fmt, ...)
  201. {
  202. }
  203. static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
  204. int comp, int level,
  205. const char *titlestring,
  206. const void *hexdata, size_t hexdatalen)
  207. {
  208. }
  209. #endif
  210. void rtl_dbgp_flag_init(struct ieee80211_hw *hw);
  211. #endif