debug.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/debug.h#1
  3. */
  4. /*! \file debug.h
  5. \brief Definition of SW debugging level.
  6. In this file, it describes the definition of various SW debugging levels and
  7. assert functions.
  8. */
  9. /*
  10. ** Log: debug.h
  11. *
  12. * 12 16 2011 wh.su
  13. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  14. * fixed the Windows DDK free build compiling error.
  15. *
  16. * 11 24 2011 wh.su
  17. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  18. * Adjust code for DBG and CONFIG_XLOG.
  19. *
  20. * 11 11 2011 wh.su
  21. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  22. * modify the xlog related code.
  23. *
  24. * 11 10 2011 wh.su
  25. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  26. * Using the new XLOG define for dum Memory.
  27. *
  28. * 11 03 2011 wh.su
  29. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  30. * Add dumpMemory8 at XLOG support.
  31. *
  32. * 11 02 2011 wh.su
  33. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  34. * adding the code for XLOG.
  35. *
  36. * 08 31 2011 cm.chang
  37. * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
  38. * .
  39. *
  40. * 01 27 2011 tsaiyuan.hsu
  41. * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
  42. * add roaming fsm
  43. * 1. not support 11r, only use strength of signal to determine roaming.
  44. * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
  45. * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
  46. * 4. assume that change of link quality in smooth way.
  47. *
  48. * 01 07 2011 wh.su
  49. * [WCXRP00000326] [MT6620][Wi-Fi][Driver] check in the binary format gl_sec.o.new instead of use change type!!!
  50. * .
  51. *
  52. * 09 23 2010 cp.wu
  53. * NULL
  54. * add BOW index for debugging message and passing compilation
  55. *
  56. * 07 20 2010 wh.su
  57. *
  58. * adding the wapi code.
  59. *
  60. * 07 08 2010 cp.wu
  61. *
  62. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  63. *
  64. * 06 21 2010 yarco.yang
  65. * [WPD00003837][MT6620]Data Path Refine
  66. * Support CFG_MQM_MIGRATION flag
  67. *
  68. * 06 17 2010 yuche.tsai
  69. * [WPD00003839][MT6620 5931][P2P] Feature migration
  70. * Add one more debug moduel for P2P.
  71. *
  72. * 06 14 2010 cp.wu
  73. * [WPD00003833][MT6620 and MT5931] Driver migration
  74. * add management dispatching function table.
  75. *
  76. * 06 11 2010 cp.wu
  77. * [WPD00003833][MT6620 and MT5931] Driver migration
  78. * add bss.c.
  79. *
  80. * 06 11 2010 cp.wu
  81. * [WPD00003833][MT6620 and MT5931] Driver migration
  82. * 1) migrate assoc.c.
  83. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  84. * 3) add configuration options for CNM_MEM and RSN modules
  85. * 4) add data path for management frames
  86. * 5) eliminate rPacketInfo of MSDU_INFO_T
  87. *
  88. * 06 10 2010 cp.wu
  89. * [WPD00003833][MT6620 and MT5931] Driver migration
  90. * add debug module index for cnm and ais.
  91. *
  92. * 06 06 2010 kevin.huang
  93. * [WPD00003832][MT6620 5931] Create driver base
  94. * [MT6620 5931] Create driver base
  95. *
  96. * 05 17 2010 cp.wu
  97. * [WPD00001943]Create WiFi test driver framework on WinXP
  98. * add CFG_STARTUP_DEBUG for debugging starting up issue.
  99. *
  100. * 04 26 2010 cp.wu
  101. * [WPD00001943]Create WiFi test driver framework on WinXP
  102. * 1) surpress compiler warning
  103. * 2) when acqruing LP-own, keep writing WHLPCR whenever OWN is not acquired yet
  104. ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-10-29 19:47:50 GMT mtk01084
  105. ** add emu category
  106. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-04-17 18:12:04 GMT mtk01426
  107. ** Don't use dynamic memory allocate for debug message
  108. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:11:29 GMT mtk01426
  109. ** Init for develop
  110. **
  111. */
  112. #ifndef _DEBUG_H
  113. #define _DEBUG_H
  114. /*******************************************************************************
  115. * C O M P I L E R F L A G S
  116. ********************************************************************************
  117. */
  118. #ifndef BUILD_QA_DBG
  119. #define BUILD_QA_DBG 0
  120. #endif
  121. /*******************************************************************************
  122. * E X T E R N A L R E F E R E N C E S
  123. ********************************************************************************
  124. */
  125. #include "gl_typedef.h"
  126. extern UINT_8 aucDebugModule[];
  127. extern UINT_32 u4DebugModule;
  128. /*******************************************************************************
  129. * C O N S T A N T S
  130. ********************************************************************************
  131. */
  132. /* Define debug category (class):
  133. * (1) ERROR (2) WARN (3) STATE (4) EVENT (5) TRACE (6) INFO (7) LOUD (8) TEMP
  134. */
  135. #define DBG_CLASS_ERROR BIT(0)
  136. #define DBG_CLASS_WARN BIT(1)
  137. #define DBG_CLASS_STATE BIT(2)
  138. #define DBG_CLASS_EVENT BIT(3)
  139. #define DBG_CLASS_TRACE BIT(4)
  140. #define DBG_CLASS_INFO BIT(5)
  141. #define DBG_CLASS_LOUD BIT(6)
  142. #define DBG_CLASS_TEMP BIT(7)
  143. #define DBG_CLASS_MASK BITS(0, 7)
  144. #if defined(LINUX)
  145. #define DBG_PRINTF_64BIT_DEC "lld"
  146. #else /* Windows */
  147. #define DBG_PRINTF_64BIT_DEC "I64d"
  148. #endif
  149. /*******************************************************************************
  150. * D A T A T Y P E S
  151. ********************************************************************************
  152. */
  153. /* Define debug module index */
  154. typedef enum _ENUM_DBG_MODULE_T {
  155. DBG_INIT_IDX = 0, /* For driver initial */
  156. DBG_HAL_IDX, /* For HAL(HW) Layer */
  157. DBG_INTR_IDX, /* For Interrupt */
  158. DBG_REQ_IDX,
  159. DBG_TX_IDX,
  160. DBG_RX_IDX,
  161. DBG_RFTEST_IDX, /* For RF test mode */
  162. DBG_EMU_IDX, /* Developer specific */
  163. DBG_SW1_IDX, /* Developer specific */
  164. DBG_SW2_IDX, /* Developer specific */
  165. DBG_SW3_IDX, /* Developer specific */
  166. DBG_SW4_IDX, /* Developer specific */
  167. DBG_HEM_IDX, /* HEM */
  168. DBG_AIS_IDX, /* AIS */
  169. DBG_RLM_IDX, /* RLM */
  170. DBG_MEM_IDX, /* RLM */
  171. DBG_CNM_IDX, /* CNM */
  172. DBG_RSN_IDX, /* RSN */
  173. DBG_BSS_IDX, /* BSS */
  174. DBG_SCN_IDX, /* SCN */
  175. DBG_SAA_IDX, /* SAA */
  176. DBG_AAA_IDX, /* AAA */
  177. DBG_P2P_IDX, /* P2P */
  178. DBG_QM_IDX, /* QUE_MGT */
  179. DBG_SEC_IDX, /* SEC */
  180. DBG_BOW_IDX, /* BOW */
  181. DBG_WAPI_IDX, /* WAPI */
  182. DBG_ROAMING_IDX, /* ROAMING */
  183. DBG_TDLS_IDX, /* TDLS *//* CFG_SUPPORT_TDLS */
  184. DBG_OID_IDX,
  185. DBG_NIC_IDX,
  186. DBG_MODULE_NUM /* Notice the XLOG check */
  187. } ENUM_DBG_MODULE_T;
  188. /* XLOG */
  189. /* #define XLOG_DBG_MODULE_IDX 28 */ /* DBG_MODULE_NUM */
  190. /* #if (XLOG_DBG_MODULE_IDX != XLOG_DBG_MODULE_IDX) */
  191. /* #error "Please modify the DBG_MODULE_NUM and make sure this include at XLOG" */
  192. /* #endif */
  193. /* Define who owns developer specific index */
  194. #define DBG_YARCO_IDX DBG_SW1_IDX
  195. #define DBG_KEVIN_IDX DBG_SW2_IDX
  196. #define DBG_CMC_IDX DBG_SW3_IDX
  197. #define DBG_GEORGE_IDX DBG_SW4_IDX
  198. /*******************************************************************************
  199. * P U B L I C D A T A
  200. ********************************************************************************
  201. */
  202. /*******************************************************************************
  203. * P R I V A T E D A T A
  204. ********************************************************************************
  205. */
  206. /*******************************************************************************
  207. * M A C R O S
  208. ********************************************************************************
  209. */
  210. /* Debug print format string for the OS system time */
  211. #define OS_SYSTIME_DBG_FORMAT "0x%08x"
  212. /* Debug print argument for the OS system time */
  213. #define OS_SYSTIME_DBG_ARGUMENT(systime) (systime)
  214. /* Debug print format string for the MAC Address */
  215. #define MACSTR "%pM"
  216. /* "%02x:%02x:%02x:%02x:%02x:%02x" */
  217. /* Debug print argument for the MAC Address */
  218. #define MAC2STR(a) a
  219. /* ((PUINT_8)a)[0], ((PUINT_8)a)[1], ((PUINT_8)a)[2], ((PUINT_8)a)[3], ((PUINT_8)a)[4], ((PUINT_8)a)[5] */
  220. /* The pre-defined format to dump the value of a varaible with its name shown. */
  221. #define DUMPVAR(variable, format) (#variable " = " format "\n", variable)
  222. /* The pre-defined format to dump the MAC type value with its name shown. */
  223. #define DUMPMACADDR(addr) (#addr " = %pM\n", (addr))
  224. /* Basiclly, we just do renaming of KAL functions although they should
  225. * be defined as "Nothing to do" if DBG=0. But in some compiler, the macro
  226. * syntax does not support #define LOG_FUNC(x,...)
  227. *
  228. * A caller shall not invoke these three macros when DBG=0.
  229. */
  230. /*LOG_FUNC("[wlan]%s:(" #_Module " " #_Class ") "_Fmt, __func__, ##__VA_ARGS__);*/
  231. #define LOG_FUNC kalPrint
  232. #if defined(LINUX)
  233. #define DBGLOG(_Module, _Class, _Fmt, ...) \
  234. do { \
  235. if ((aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) == 0) \
  236. break; \
  237. LOG_FUNC("%s:(" #_Module " " #_Class ")"_Fmt, __func__, ##__VA_ARGS__); \
  238. } while (0)
  239. #else
  240. #define DBGLOG(_Module, _Class, _Fmt)
  241. #endif
  242. #if DBG
  243. #define TMP_BUF_LEN 256
  244. #define TMP_WBUF_LEN (TMP_BUF_LEN * 2)
  245. extern PINT_16 g_wbuf_p;
  246. extern PINT_8 g_buf_p;
  247. /* If __FUNCTION__ is already defined by compiler, we just use it. */
  248. #if defined(__func__)
  249. #define DEBUGFUNC(_Func)
  250. #else
  251. #define DEBUGFUNC(_Func) \
  252. static const char __func__[] = _Func
  253. #endif
  254. #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length) \
  255. { \
  256. if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
  257. LOG_FUNC("%s: (" #_Module " " #_Class ")\n", __func__); \
  258. dumpMemory8((PUINT_8) (_StartAddr), (UINT_32) (_Length)); \
  259. } \
  260. }
  261. #define DBGLOG_MEM32(_Module, _Class, _StartAddr, _Length) \
  262. { \
  263. if (aucDebugModule[DBG_##_Module##_IDX] & DBG_CLASS_##_Class) { \
  264. LOG_FUNC("%s: (" #_Module " " #_Class ")\n", __func__); \
  265. dumpMemory32((PUINT_32) (_StartAddr), (UINT_32) (_Length)); \
  266. } \
  267. }
  268. /*lint -restore */
  269. /*lint -save -e961 use of '#undef' is discouraged */
  270. #undef ASSERT
  271. /*lint -restore */
  272. #ifdef _lint
  273. #define ASSERT(_exp) \
  274. { \
  275. if (!(_exp)) { \
  276. do {} while (1); \
  277. } \
  278. }
  279. #else
  280. #define ASSERT(_exp) \
  281. { \
  282. if (!(_exp) && !fgIsBusAccessFailed) { \
  283. LOG_FUNC("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #_exp); \
  284. kalBreakPoint(); \
  285. } \
  286. }
  287. #endif /* _lint */
  288. #define ASSERT_REPORT(_exp, _fmt) \
  289. { \
  290. if (!(_exp) && !fgIsBusAccessFailed) { \
  291. LOG_FUNC("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #_exp); \
  292. LOG_FUNC _fmt; \
  293. kalBreakPoint(); \
  294. } \
  295. }
  296. #define DISP_STRING(_str) _str
  297. #else /* !DBG */
  298. #define DEBUGFUNC(_Func)
  299. #define INITLOG(_Fmt)
  300. #define ERRORLOG(_Fmt)
  301. #define WARNLOG(_Fmt)
  302. #define DBGLOG_MEM8(_Module, _Class, _StartAddr, _Length)
  303. #define DBGLOG_MEM32(_Module, _Class, _StartAddr, _Length)
  304. #undef ASSERT
  305. #if BUILD_QA_DBG
  306. #if defined(LINUX) /* For debugging in Linux w/o GDB */
  307. #define ASSERT(_exp) \
  308. { \
  309. if (!(_exp) && !fgIsBusAccessFailed) { \
  310. LOG_FUNC("Assertion failed: %s:%d (%s)\n", __FILE__, __LINE__, #_exp); \
  311. kalBreakPoint(); \
  312. } \
  313. }
  314. #define ASSERT_REPORT(_exp, _fmt) \
  315. { \
  316. if (!(_exp) && !fgIsBusAccessFailed) { \
  317. LOG_FUNC("Assertion failed: %s:%d (%s)\n", __FILE__, __LINE__, #_exp); \
  318. LOG_FUNC _fmt; \
  319. kalBreakPoint(); \
  320. } \
  321. }
  322. #else
  323. #ifdef WINDOWS_CE
  324. #define UNICODE_TEXT(_msg) TEXT(_msg)
  325. #define ASSERT(_exp) \
  326. { \
  327. if (!(_exp) && !fgIsBusAccessFailed) { \
  328. TCHAR rUbuf[256]; \
  329. kalBreakPoint(); \
  330. _stprintf(rUbuf, TEXT("Assertion failed: %s:%d %s\n"), \
  331. UNICODE_TEXT(__FILE__), \
  332. __LINE__, \
  333. UNICODE_TEXT(#_exp)); \
  334. MessageBox(NULL, rUbuf, TEXT("ASSERT!"), MB_OK); \
  335. } \
  336. }
  337. #define ASSERT_REPORT(_exp, _fmt) \
  338. { \
  339. if (!(_exp) && !fgIsBusAccessFailed) { \
  340. TCHAR rUbuf[256]; \
  341. kalBreakPoint(); \
  342. _stprintf(rUbuf, TEXT("Assertion failed: %s:%d %s\n"), \
  343. UNICODE_TEXT(__FILE__), \
  344. __LINE__, \
  345. UNICODE_TEXT(#_exp)); \
  346. MessageBox(NULL, rUbuf, TEXT("ASSERT!"), MB_OK); \
  347. } \
  348. }
  349. #else
  350. #define ASSERT(_exp) \
  351. { \
  352. if (!(_exp) && !fgIsBusAccessFailed) { \
  353. kalBreakPoint(); \
  354. } \
  355. }
  356. #define ASSERT_REPORT(_exp, _fmt) \
  357. { \
  358. if (!(_exp) && !fgIsBusAccessFailed) { \
  359. kalBreakPoint(); \
  360. } \
  361. }
  362. #endif /* WINDOWS_CE */
  363. #endif /* LINUX */
  364. #else
  365. #define ASSERT(_exp) \
  366. { \
  367. if (!(_exp) && !fgIsBusAccessFailed) { \
  368. LOG_FUNC("Warning at %s:%d (%s)\n", __func__, __LINE__, #_exp); \
  369. } \
  370. }
  371. #define ASSERT_REPORT(_exp, _fmt) \
  372. { \
  373. if (!(_exp) && !fgIsBusAccessFailed) { \
  374. LOG_FUNC("Warning at %s:%d (%s)\n", __func__, __LINE__, #_exp); \
  375. LOG_FUNC _fmt; \
  376. } \
  377. }
  378. #endif /* BUILD_QA_DBG */
  379. #define DISP_STRING(_str) ""
  380. #endif /* DBG */
  381. #if CFG_STARTUP_DEBUG
  382. #if defined(LINUX)
  383. #define DBGPRINTF kalPrint
  384. #else
  385. #define DBGPRINTF DbgPrint
  386. #endif
  387. #else
  388. #define DBGPRINTF(...)
  389. #endif
  390. /* The following macro is used for debugging packed structures. */
  391. #ifndef DATA_STRUCT_INSPECTING_ASSERT
  392. #define DATA_STRUCT_INSPECTING_ASSERT(expr) \
  393. { \
  394. switch (0) {case 0: case (expr): default:; } \
  395. }
  396. #endif
  397. /*******************************************************************************
  398. * F U N C T I O N D E C L A R A T I O N S
  399. ********************************************************************************
  400. */
  401. VOID dumpMemory8(IN PUINT_8 pucStartAddr, IN UINT_32 u4Length);
  402. VOID dumpMemory32(IN PUINT_32 pu4StartAddr, IN UINT_32 u4Length);
  403. VOID wlanDebugInit(VOID);
  404. VOID wlanDebugUninit(VOID);
  405. VOID wlanTraceReleaseTcRes(P_ADAPTER_T prAdapter, PUINT_8 aucTxRlsCnt, UINT_8 ucAvailable);
  406. VOID wlanTraceTxCmd(P_ADAPTER_T prAdapter, P_CMD_INFO_T prCmd);
  407. VOID wlanReadFwStatus(P_ADAPTER_T prAdapter);
  408. VOID wlanDumpTcResAndTxedCmd(PUINT_8 pucBuf, UINT_32 maxLen);
  409. VOID wlanDumpCommandFwStatus(VOID);
  410. /*******************************************************************************
  411. * F U N C T I O N S
  412. ********************************************************************************
  413. */
  414. #endif /* _DEBUG_H */