odm_debug.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This 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. * This 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. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __ODM_DBG_H__
  21. #define __ODM_DBG_H__
  22. //-----------------------------------------------------------------------------
  23. // Define the debug levels
  24. //
  25. // 1. DBG_TRACE and DBG_LOUD are used for normal cases.
  26. // So that, they can help SW engineer to develope or trace states changed
  27. // and also help HW enginner to trace every operation to and from HW,
  28. // e.g IO, Tx, Rx.
  29. //
  30. // 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases,
  31. // which help us to debug SW or HW.
  32. //
  33. //-----------------------------------------------------------------------------
  34. //
  35. // Never used in a call to ODM_RT_TRACE()!
  36. //
  37. #define ODM_DBG_OFF 1
  38. //
  39. // Fatal bug.
  40. // For example, Tx/Rx/IO locked up, OS hangs, memory access violation,
  41. // resource allocation failed, unexpected HW behavior, HW BUG and so on.
  42. //
  43. #define ODM_DBG_SERIOUS 2
  44. //
  45. // Abnormal, rare, or unexpeted cases.
  46. // For example, IRP/Packet/OID canceled, device suprisely unremoved and so on.
  47. //
  48. #define ODM_DBG_WARNING 3
  49. //
  50. // Normal case with useful information about current SW or HW state.
  51. // For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status,
  52. // SW protocol state change, dynamic mechanism state change and so on.
  53. //
  54. #define ODM_DBG_LOUD 4
  55. //
  56. // Normal case with detail execution flow or information.
  57. //
  58. #define ODM_DBG_TRACE 5
  59. //-----------------------------------------------------------------------------
  60. // Define the tracing components
  61. //
  62. //-----------------------------------------------------------------------------
  63. //BB Functions
  64. #define ODM_COMP_DIG BIT0
  65. #define ODM_COMP_RA_MASK BIT1
  66. #define ODM_COMP_DYNAMIC_TXPWR BIT2
  67. #define ODM_COMP_FA_CNT BIT3
  68. #define ODM_COMP_RSSI_MONITOR BIT4
  69. #define ODM_COMP_CCK_PD BIT5
  70. #define ODM_COMP_ANT_DIV BIT6
  71. #define ODM_COMP_PWR_SAVE BIT7
  72. #define ODM_COMP_PWR_TRAIN BIT8
  73. #define ODM_COMP_RATE_ADAPTIVE BIT9
  74. #define ODM_COMP_PATH_DIV BIT10
  75. #define ODM_COMP_PSD BIT11
  76. #define ODM_COMP_DYNAMIC_PRICCA BIT12
  77. #define ODM_COMP_RXHP BIT13
  78. #define ODM_COMP_MP BIT14
  79. #define ODM_COMP_DYNAMIC_ATC BIT15
  80. //MAC Functions
  81. #define ODM_COMP_EDCA_TURBO BIT16
  82. #define ODM_COMP_EARLY_MODE BIT17
  83. //RF Functions
  84. #define ODM_COMP_TX_PWR_TRACK BIT24
  85. #define ODM_COMP_RX_GAIN_TRACK BIT25
  86. #define ODM_COMP_CALIBRATION BIT26
  87. //Common Functions
  88. #define ODM_COMP_COMMON BIT30
  89. #define ODM_COMP_INIT BIT31
  90. /*------------------------Export Marco Definition---------------------------*/
  91. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  92. #define RT_PRINTK DbgPrint
  93. #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
  94. #define DbgPrint printk
  95. #define RT_PRINTK(fmt, args...) DbgPrint( "%s(): " fmt, __FUNCTION__, ## args);
  96. #define RT_DISP(dbgtype, dbgflag, printstr)
  97. #else
  98. #define DbgPrint panic_printk
  99. #define RT_PRINTK(fmt, args...) DbgPrint( "%s(): " fmt, __FUNCTION__, ## args);
  100. #endif
  101. #ifndef ASSERT
  102. #define ASSERT(expr)
  103. #endif
  104. #if DBG
  105. #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \
  106. if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel || level == ODM_DBG_SERIOUS)) \
  107. { \
  108. RT_PRINTK fmt; \
  109. }
  110. #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \
  111. if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \
  112. { \
  113. RT_PRINTK fmt; \
  114. }
  115. #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \
  116. if(!(expr)) { \
  117. DbgPrint( "Assertion failed! %s at ......\n", #expr); \
  118. DbgPrint( " ......%s,%s,line=%d\n",__FILE__,__FUNCTION__,__LINE__); \
  119. RT_PRINTK fmt; \
  120. ASSERT(FALSE); \
  121. }
  122. #define ODM_dbg_enter() { DbgPrint("==> %s\n", __FUNCTION__); }
  123. #define ODM_dbg_exit() { DbgPrint("<== %s\n", __FUNCTION__); }
  124. #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __FUNCTION__, str); }
  125. #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \
  126. if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \
  127. { \
  128. int __i; \
  129. pu1Byte __ptr = (pu1Byte)ptr; \
  130. DbgPrint("[ODM] "); \
  131. DbgPrint(title_str); \
  132. DbgPrint(" "); \
  133. for( __i=0; __i<6; __i++ ) \
  134. DbgPrint("%02X%s", __ptr[__i], (__i==5)?"":"-"); \
  135. DbgPrint("\n"); \
  136. }
  137. #else
  138. #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)
  139. #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)
  140. #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)
  141. #define ODM_dbg_enter()
  142. #define ODM_dbg_exit()
  143. #define ODM_dbg_trace(str)
  144. #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)
  145. #endif
  146. VOID
  147. ODM_InitDebugSetting(
  148. IN PDM_ODM_T pDM_Odm
  149. );
  150. #if 0
  151. #if DBG
  152. #define DbgPrint printk
  153. #define PRINT_DATA(_TitleString, _HexData, _HexDataLen) \
  154. { \
  155. char *szTitle = _TitleString; \
  156. pu1Byte pbtHexData = _HexData; \
  157. u4Byte u4bHexDataLen = _HexDataLen; \
  158. u4Byte __i; \
  159. DbgPrint("%s", szTitle); \
  160. for (__i=0;__i<u4bHexDataLen;__i++) \
  161. { \
  162. if ((__i & 15) == 0) \
  163. { \
  164. DbgPrint("\n"); \
  165. } \
  166. DbgPrint("%02X%s", pbtHexData[__i], ( ((__i&3)==3) ? " " : " ") ); \
  167. } \
  168. DbgPrint("\n"); \
  169. }
  170. // RT_PRINT_XXX macros: implemented for debugging purpose.
  171. // Added by Annie, 2005-11-21.
  172. #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \
  173. if(((_Comp) & ODM_GlobalDebugComponents) && (_Level <= ODM_GlobalDebugLevel)) \
  174. { \
  175. int __i; \
  176. pu1Byte ptr = (pu1Byte)_HexData; \
  177. DbgPrint("Rtl819x: "); \
  178. DbgPrint(_TitleString); \
  179. for( __i=0; __i<(int)_HexDataLen; __i++ ) \
  180. { \
  181. DbgPrint("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" "); \
  182. if (((__i + 1) % 16) == 0) DbgPrint("\n"); \
  183. } \
  184. DbgPrint("\n"); \
  185. }
  186. #define RT_PRINT_ADDR(_Comp, _Level, _TitleString, _Ptr) \
  187. if(((_Comp) & ODM_GlobalDebugComponents) && (_Level <= ODM_GlobalDebugLevel)) \
  188. { \
  189. int __i; \
  190. pu1Byte ptr = (pu1Byte)_Ptr; \
  191. DbgPrint("Rtl819x: "); \
  192. DbgPrint(_TitleString); \
  193. DbgPrint(" "); \
  194. for( __i=0; __i<6; __i++ ) \
  195. DbgPrint("%02X%s", ptr[__i], (__i==5)?"":"-"); \
  196. DbgPrint("\n"); \
  197. }
  198. #define RT_PRINT_ADDRS(_Comp, _Level, _TitleString, _Ptr, _AddNum) \
  199. if(((_Comp) & ODM_GlobalDebugComponents) && (_Level <= ODM_GlobalDebugLevel)) \
  200. { \
  201. int __i, __j; \
  202. pu1Byte ptr = (pu1Byte)_Ptr; \
  203. DbgPrint("Rtl819x: "); \
  204. DbgPrint(_TitleString); \
  205. DbgPrint("\n"); \
  206. for( __i=0; __i<(int)_AddNum; __i++ ) \
  207. { \
  208. for( __j=0; __j<6; __j++ ) \
  209. DbgPrint("%02X%s", ptr[__i*6+__j], (__j==5)?"":"-"); \
  210. DbgPrint("\n"); \
  211. } \
  212. }
  213. // Added by Annie, 2005-11-22.
  214. #define MAX_STR_LEN 64
  215. #define PRINTABLE(_ch) (_ch>=' ' &&_ch<='~' ) // I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.
  216. #define RT_PRINT_STR(_Comp, _Level, _TitleString, _Ptr, _Len) \
  217. if(((_Comp) & ODM_GlobalDebugComponents) && (_Level <= ODM_GlobalDebugLevel)) \
  218. { \
  219. int __i; \
  220. u1Byte buffer[MAX_STR_LEN]; \
  221. int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \
  222. PlatformZeroMemory( buffer, MAX_STR_LEN ); \
  223. PlatformMoveMemory( buffer, (pu1Byte)_Ptr, length ); \
  224. for( __i=0; __i<MAX_STR_LEN; __i++ ) \
  225. { \
  226. if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \
  227. } \
  228. buffer[length] = '\0'; \
  229. DbgPrint("Rtl819x: "); \
  230. DbgPrint(_TitleString); \
  231. DbgPrint(": %d, <%s>\n", _Len, buffer); \
  232. }
  233. #else // of #if DBG
  234. #define DbgPrint(...)
  235. #define PRINT_DATA(_TitleString, _HexData, _HexDataLen)
  236. #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen)
  237. #define RT_PRINT_ADDR(_Comp, _Level, _TitleString, _Ptr)
  238. #define RT_PRINT_ADDRS(_Comp, _Level, _TitleString, _Ptr, _AddNum)
  239. #define RT_PRINT_STR(_Comp, _Level, _TitleString, _Ptr, _Len)
  240. #endif // of #if DBG
  241. #endif
  242. #if 0
  243. /* Define debug print header for every service module.*/
  244. typedef struct tag_ODM_DBGP_Service_Module_Header_Name_Structure
  245. {
  246. const char *pMANS;
  247. const char *pRTOS;
  248. const char *pALM;
  249. const char *pPEM;
  250. const char *pCMPK;
  251. const char *pRAPD;
  252. const char *pTXPB;
  253. const char *pQUMG;
  254. }ODM_DBGP_HEAD_T;
  255. /* Define different debug flag for dedicated service modules in debug flag array. */
  256. // Each module has independt 32 bit debug flag you cnn define the flag as yout require.
  257. typedef enum tag_ODM_DBGP_Flag_Type_Definition
  258. {
  259. ODM_FTX = 0,
  260. ODM_FRX ,
  261. ODM_FPHY ,
  262. ODM_FPWR ,
  263. ODM_FDM ,
  264. ODM_FC2H ,
  265. ODM_FBT ,
  266. ODM_DBGP_TYPE_MAX
  267. }ODM_DBGP_FLAG_E;
  268. // Define TX relative debug bit --> FTX
  269. #define ODM_TX_DESC BIT0
  270. #define ODM_TX_DESC_TID BIT1
  271. #define ODM_TX_PATH BIT2
  272. // Define RX relative debug bit --> FRX
  273. #define ODM_RX_DATA BIT0
  274. #define ODM_RX_PHY_STS BIT1
  275. #define ODM_RX_PHY_SS BIT2
  276. #define ODM_RX_PHY_SQ BIT3
  277. #define ODM_RX_PHY_ASTS BIT4
  278. #define ODM_RX_ERR_LEN BIT5
  279. #define ODM_RX_DEFRAG BIT6
  280. #define ODM_RX_ERR_RATE BIT7
  281. #define ODM_RX_PATH BIT8
  282. #define ODM_RX_BEACON BIT9
  283. // Define PHY-BB/RF/MAC check module bit --> FPHY
  284. #define ODM_PHY_BBR BIT0
  285. #define ODM_PHY_BBW BIT1
  286. #define ODM_PHY_RFR BIT2
  287. #define ODM_PHY_RFW BIT3
  288. #define ODM_PHY_MACR BIT4
  289. #define ODM_PHY_MACW BIT5
  290. #define ODM_PHY_ALLR BIT6
  291. #define ODM_PHY_ALLW BIT7
  292. #define ODM_PHY_TXPWR BIT8
  293. #define ODM_PHY_PWRDIFF BIT9
  294. #define ODM_PHY_SICR BIT10
  295. #define ODM_PHY_SICW BIT11
  296. extern u4Byte ODM_GlobalDebugLevel;
  297. #if DBG
  298. extern u8Byte ODM_GlobalDebugComponents;
  299. #endif
  300. #endif
  301. #if 0
  302. //-----------------------------------------------------------------------------
  303. // Define the debug levels
  304. //
  305. // 1. DBG_TRACE and DBG_LOUD are used for normal cases.
  306. // So that, they can help SW engineer to develope or trace states changed
  307. // and also help HW enginner to trace every operation to and from HW,
  308. // e.g IO, Tx, Rx.
  309. //
  310. // 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases,
  311. // which help us to debug SW or HW.
  312. //
  313. //-----------------------------------------------------------------------------
  314. //
  315. // Never used in a call to ODM_RT_TRACE(pDM_Odm,)!
  316. //
  317. #define DBG_OFF 0
  318. //
  319. // Deprecated! Don't use it!
  320. // TODO: fix related debug message!
  321. //
  322. //#define DBG_SEC 1
  323. //
  324. // Fatal bug.
  325. // For example, Tx/Rx/IO locked up, OS hangs, memory access violation,
  326. // resource allocation failed, unexpected HW behavior, HW BUG and so on.
  327. //
  328. #define DBG_SERIOUS 2
  329. //
  330. // Abnormal, rare, or unexpeted cases.
  331. // For example, IRP/Packet/OID canceled, device suprisely unremoved and so on.
  332. //
  333. #define DBG_WARNING 3
  334. //
  335. // Normal case with useful information about current SW or HW state.
  336. // For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status,
  337. // SW protocol state change, dynamic mechanism state change and so on.
  338. //
  339. #define DBG_LOUD 4
  340. //
  341. // Normal case with detail execution flow or information.
  342. //
  343. #define DBG_TRACE 5
  344. //-----------------------------------------------------------------------------
  345. // Define the tracing components
  346. //
  347. //-----------------------------------------------------------------------------
  348. #define COMP_TRACE BIT0 // For function call tracing.
  349. #define COMP_DBG BIT1 // Only for temporary debug message.
  350. #define COMP_INIT BIT2 // during driver initialization / halt / reset.
  351. #define COMP_OID_QUERY BIT3 // Query OID.
  352. #define COMP_OID_SET BIT4 // Set OID.
  353. #define COMP_RECV BIT5 // Reveive part data path.
  354. #define COMP_SEND BIT6 // Send part path.
  355. #define COMP_IO BIT7 // I/O Related. Added by Annie, 2006-03-02.
  356. #define COMP_POWER BIT8 // 802.11 Power Save mode or System/Device Power state related.
  357. #define COMP_MLME BIT9 // 802.11 link related: join/start BSS, leave BSS.
  358. #define COMP_SCAN BIT10 // For site survey.
  359. #define COMP_SYSTEM BIT11 // For general platform function.
  360. #define COMP_SEC BIT12 // For Security.
  361. #define COMP_AP BIT13 // For AP mode related.
  362. #define COMP_TURBO BIT14 // For Turbo Mode related. By Annie, 2005-10-21.
  363. #define COMP_QOS BIT15 // For QoS.
  364. #define COMP_AUTHENTICATOR BIT16 // For AP mode Authenticator. Added by Annie, 2006-01-30.
  365. #define COMP_BEACON BIT17 // For Beacon related, by rcnjko.
  366. #define COMP_ANTENNA BIT18 // For Antenna diversity related, by rcnjko.
  367. #define COMP_RATE BIT19 // For Rate Adaptive mechanism, 2006.07.02, by rcnjko. #define COMP_EVENTS 0x00000080 // Event handling
  368. #define COMP_EVENTS BIT20 // Event handling
  369. #define COMP_FPGA BIT21 // For FPGA verfication
  370. #define COMP_RM BIT22 // For Radio Measurement.
  371. #define COMP_MP BIT23 // For mass production test, by shien chang, 2006.07.13
  372. #define COMP_RXDESC BIT24 // Show Rx desc information for SD3 debug. Added by Annie, 2006-07-15.
  373. #define COMP_CKIP BIT25 // For CCX 1 S13: CKIP. Added by Annie, 2006-08-14.
  374. #define COMP_DIG BIT26 // For DIG, 2006.09.25, by rcnjko.
  375. #define COMP_TXAGC BIT27 // For Tx power, 060928, by rcnjko.
  376. #define COMP_HIPWR BIT28 // For High Power Mechanism, 060928, by rcnjko.
  377. #define COMP_HALDM BIT29 // For HW Dynamic Mechanism, 061010, by rcnjko.
  378. #define COMP_RSNA BIT30 // For RSNA IBSS , 061201, by CCW.
  379. #define COMP_INDIC BIT31 // For link indication
  380. #define COMP_LED BIT32 // For LED.
  381. #define COMP_RF BIT33 // For RF.
  382. //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
  383. //1//1Attention Please!!!<11n or 8190 specific code should be put below this line>
  384. //1!!!!!!!!!!!!!!!!!!!!!!!!!!!
  385. #define COMP_HT BIT34 // For 802.11n HT related information. by Emily 2006-8-11
  386. #define COMP_POWER_TRACKING BIT35 //FOR 8190 TX POWER TRACKING
  387. #define COMP_RX_REORDER BIT36 // 8190 Rx Reorder
  388. #define COMP_AMSDU BIT37 // For A-MSDU Debugging
  389. #define COMP_WPS BIT38 //WPS Debug Message
  390. #define COMP_RATR BIT39
  391. #define COMP_RESET BIT40
  392. // For debug command to print on dbgview!!
  393. #define COMP_CMD BIT41
  394. #define COMP_EFUSE BIT42
  395. #define COMP_MESH_INTERWORKING BIT43
  396. #define COMP_CCX BIT44 //CCX Debug Flag
  397. #define COMP_IOCTL BIT45 // IO Control
  398. #define COMP_GP BIT46 // For generic parser.
  399. #define COMP_TXAGG BIT47
  400. #define COMP_HVL BIT48 // For Ndis 6.2 Context Swirch and Hardware Virtualiztion Layer
  401. #define COMP_TEST BIT49
  402. #define COMP_BB_POWERSAVING BIT50
  403. #define COMP_SWAS BIT51 // For SW Antenna Switch
  404. #define COMP_P2P BIT52
  405. #define COMP_MUX BIT53
  406. #define COMP_FUNC BIT54
  407. #define COMP_TDLS BIT55
  408. #define COMP_OMNIPEEK BIT56
  409. #define COMP_DUALMACSWITCH BIT60 // 2010/12/27 Add for Dual mac mode debug
  410. #define COMP_EASY_CONCURRENT BIT61 // 2010/12/27 Add for easy cncurrent mode debug
  411. #define COMP_PSD BIT63 //2011/3/9 Add for WLAN PSD for BT AFH
  412. #define COMP_DFS BIT62
  413. #define COMP_ALL UINT64_C(0xFFFFFFFFFFFFFFFF) // All components
  414. // For debug print flag to use
  415. /*------------------------------Define structure----------------------------*/
  416. /* 2007/07/13 MH *//*------For DeBuG Print modeue------*/
  417. /* Defnie structure to store different debug flag variable. Every debug flag
  418. is a UINT32 integer and you can assign 32 different events. */
  419. typedef struct tag_DBGP_Debug_Flag_Structure
  420. {
  421. u4Byte Mans; /* Main Scheduler module. */
  422. u4Byte Rtos; /* RTOS module. */
  423. u4Byte Alarm; /* Alarm module. */
  424. u4Byte Pm; /* Performance monitor module. */
  425. }DBGP_FLAG_T;
  426. /* Define debug print header for every service module.*/
  427. typedef struct tag_DBGP_Service_Module_Header_Name_Structure
  428. {
  429. const char *pMANS;
  430. const char *pRTOS;
  431. const char *pALM;
  432. const char *pPEM;
  433. const char *pCMPK;
  434. const char *pRAPD;
  435. const char *pTXPB;
  436. const char *pQUMG;
  437. }DBGP_HEAD_T;
  438. /* Define different debug flag for dedicated service modules in debug flag array. */
  439. // Each module has independt 32 bit debug flag you cnn define the flag as yout require.
  440. typedef enum tag_DBGP_Flag_Type_Definition
  441. {
  442. FQoS = 0,
  443. FTX = 1,
  444. FRX = 2,
  445. FSEC = 3,
  446. FMGNT = 4,
  447. FMLME = 5,
  448. FRESOURCE = 6,
  449. FBEACON = 7,
  450. FISR = 8,
  451. FPHY = 9,
  452. FMP = 10,
  453. FEEPROM = 11,
  454. FPWR = 12,
  455. FDM = 13,
  456. FDBG_CTRL = 14,
  457. FC2H = 15,
  458. FBT = 16,
  459. FINIT = 17,
  460. FIOCTL = 18,
  461. FSHORT_CUT = 19,
  462. DBGP_TYPE_MAX
  463. }DBGP_FLAG_E;
  464. // Define Qos Relative debug flag bit --> FQoS
  465. #define QoS_INIT BIT0
  466. #define QoS_VISTA BIT1
  467. // Define TX relative debug bit --> FTX
  468. #define TX_DESC BIT0
  469. #define TX_DESC_TID BIT1
  470. #define TX_PATH BIT2
  471. // Define RX relative debug bit --> FRX
  472. #define RX_DATA BIT0
  473. #define RX_PHY_STS BIT1
  474. #define RX_PHY_SS BIT2
  475. #define RX_PHY_SQ BIT3
  476. #define RX_PHY_ASTS BIT4
  477. #define RX_ERR_LEN BIT5
  478. #define RX_DEFRAG BIT6
  479. #define RX_ERR_RATE BIT7
  480. #define RX_PATH BIT8
  481. #define RX_BEACON BIT9
  482. // Define Security relative debug bit --> FSEC
  483. // Define MGNT relative debug bit --> FMGNT
  484. // Define MLME relative debug bit --> FMLME
  485. #define MEDIA_STS BIT0
  486. #define LINK_STS BIT1
  487. // Define OS resource check module bit --> FRESOURCE
  488. #define OS_CHK BIT0
  489. // Define beacon content check module bit --> FBEACON
  490. #define BCN_SHOW BIT0
  491. #define BCN_PEER BIT1
  492. // Define ISR/IMR check module bit --> FISR
  493. #define ISR_CHK BIT0
  494. // Define PHY-BB/RF/MAC check module bit --> FPHY
  495. #define PHY_BBR BIT0
  496. #define PHY_BBW BIT1
  497. #define PHY_RFR BIT2
  498. #define PHY_RFW BIT3
  499. #define PHY_MACR BIT4
  500. #define PHY_MACW BIT5
  501. #define PHY_ALLR BIT6
  502. #define PHY_ALLW BIT7
  503. #define PHY_TXPWR BIT8
  504. #define PHY_PWRDIFF BIT9
  505. #define PHY_SICR BIT10
  506. #define PHY_SICW BIT11
  507. // Define MPT driver check module bit --> FMP
  508. #define MP_RX BIT0
  509. #define MP_SWICH_CH BIT1
  510. // Define EEPROM and EFUSE check module bit --> FEEPROM
  511. #define EEPROM_W BIT0
  512. #define EFUSE_PG BIT1
  513. #define EFUSE_READ_ALL BIT2
  514. #define EFUSE_ANALYSIS BIT3
  515. #define EFUSE_PG_DETAIL BIT4
  516. // Define power save check module bit --> FPWR
  517. #define LPS BIT0
  518. #define IPS BIT1
  519. #define PWRSW BIT2
  520. #define PWRHW BIT3
  521. #define PWRHAL BIT4
  522. // Define Dynamic Mechanism check module bit --> FDM
  523. #define WA_IOT BIT0
  524. #define DM_PWDB BIT1
  525. #define DM_Monitor BIT2
  526. #define DM_DIG BIT3
  527. #define DM_EDCA_Turbo BIT4
  528. #define DM_BT30 BIT5
  529. // Define Dbg Control module bit --> FDBG_CTRL
  530. #define DBG_CTRL_TRACE BIT0
  531. #define DBG_CTRL_INBAND_NOISE BIT1
  532. // Define FW C2H Cmd check module bit --> FC2H
  533. #define C2H_Summary BIT0
  534. #define C2H_PacketData BIT1
  535. #define C2H_ContentData BIT2
  536. // Define BT Cmd check module bit --> FBT
  537. #define BT_TRACE BIT0
  538. #define BT_RFPoll BIT1
  539. // Define init check for module bit --> FINIT
  540. #define INIT_EEPROM BIT0
  541. #define INIT_TxPower BIT1
  542. #define INIT_IQK BIT2
  543. #define INIT_RF BIT3
  544. // Define IOCTL Cmd check module bit --> FIOCTL
  545. // section 1 : IRP related
  546. #define IOCTL_IRP BIT0
  547. #define IOCTL_IRP_DETAIL BIT1
  548. #define IOCTL_IRP_STATISTICS BIT2
  549. #define IOCTL_IRP_HANDLE BIT3
  550. // section 2 : HCI command/event
  551. #define IOCTL_BT_HCICMD BIT8
  552. #define IOCTL_BT_HCICMD_DETAIL BIT9
  553. #define IOCTL_BT_HCICMD_EXT BIT10
  554. #define IOCTL_BT_EVENT BIT11
  555. #define IOCTL_BT_EVENT_DETAIL BIT12
  556. #define IOCTL_BT_EVENT_PERIODICAL BIT13
  557. // section 3 : BT tx/rx data and throughput
  558. #define IOCTL_BT_TX_ACLDATA BIT16
  559. #define IOCTL_BT_TX_ACLDATA_DETAIL BIT17
  560. #define IOCTL_BT_RX_ACLDATA BIT18
  561. #define IOCTL_BT_RX_ACLDATA_DETAIL BIT19
  562. #define IOCTL_BT_TP BIT20
  563. // section 4 : BT connection state machine.
  564. #define IOCTL_STATE BIT21
  565. #define IOCTL_BT_LOGO BIT22
  566. // section 5 : BT function trace
  567. #define IOCTL_CALLBACK_FUN BIT24
  568. #define IOCTL_PARSE_BT_PKT BIT25
  569. #define IOCTL_BT_TX_PKT BIT26
  570. #define IOCTL_BT_FLAG_MON BIT27
  571. //
  572. // Define init check for module bit --> FSHORT_CUT
  573. // 2011/07/20 MH Add for short but definition.
  574. //
  575. #define SHCUT_TX BIT0
  576. #define SHCUT_RX BIT1
  577. /* 2007/07/13 MH *//*------For DeBuG Print modeue------*/
  578. /*------------------------------Define structure----------------------------*/
  579. /*------------------------Export Marco Definition---------------------------*/
  580. #if (DM_ODM_SUPPORT_TYPE != ODM_WIN)
  581. #define RT_PRINTK(fmt, args...) printk( "%s(): " fmt, __FUNCTION__, ## args);
  582. #if DBG
  583. #define ODM_RT_TRACE(pDM_Odm,comp, level, fmt) \
  584. if(((comp) & GlobalDebugComponents) && (level <= GlobalDebugLevel)) \
  585. { \
  586. RT_PRINTK fmt; \
  587. }
  588. #define RT_TRACE_F(comp, level, fmt) \
  589. if(((comp) & GlobalDebugComponents) && (level <= GlobalDebugLevel)) \
  590. { \
  591. RT_PRINTK fmt; \
  592. }
  593. #define RT_ASSERT(expr,fmt) \
  594. if(!(expr)) { \
  595. printk( "Assertion failed! %s at ......\n", #expr); \
  596. printk( " ......%s,%s,line=%d\n",__FILE__,__FUNCTION__,__LINE__); \
  597. }
  598. #define dbg_enter() { printk("==> %s\n", __FUNCTION__); }
  599. #define dbg_exit() { printk("<== %s\n", __FUNCTION__); }
  600. #define dbg_trace(str) { printk("%s:%s\n", __FUNCTION__, str); }
  601. #else
  602. #define ODM_RT_TRACE(pDM_Odm,comp, level, fmt)
  603. #define RT_TRACE_F(comp, level, fmt)
  604. #define RT_ASSERT(expr, fmt)
  605. #define dbg_enter()
  606. #define dbg_exit()
  607. #define dbg_trace(str)
  608. #endif
  609. #if DBG
  610. #define DbgPrint printk
  611. #define PRINT_DATA(_TitleString, _HexData, _HexDataLen) \
  612. { \
  613. char *szTitle = _TitleString; \
  614. pu1Byte pbtHexData = _HexData; \
  615. u4Byte u4bHexDataLen = _HexDataLen; \
  616. u4Byte __i; \
  617. DbgPrint("%s", szTitle); \
  618. for (__i=0;__i<u4bHexDataLen;__i++) \
  619. { \
  620. if ((__i & 15) == 0) \
  621. { \
  622. DbgPrint("\n"); \
  623. } \
  624. DbgPrint("%02X%s", pbtHexData[__i], ( ((__i&3)==3) ? " " : " ") ); \
  625. } \
  626. DbgPrint("\n"); \
  627. }
  628. // RT_PRINT_XXX macros: implemented for debugging purpose.
  629. // Added by Annie, 2005-11-21.
  630. #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \
  631. if(((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel)) \
  632. { \
  633. int __i; \
  634. pu1Byte ptr = (pu1Byte)_HexData; \
  635. DbgPrint("Rtl819x: "); \
  636. DbgPrint(_TitleString); \
  637. for( __i=0; __i<(int)_HexDataLen; __i++ ) \
  638. { \
  639. DbgPrint("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" "); \
  640. if (((__i + 1) % 16) == 0) DbgPrint("\n"); \
  641. } \
  642. DbgPrint("\n"); \
  643. }
  644. #define RT_PRINT_ADDR(_Comp, _Level, _TitleString, _Ptr) \
  645. if(((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel)) \
  646. { \
  647. int __i; \
  648. pu1Byte ptr = (pu1Byte)_Ptr; \
  649. DbgPrint("Rtl819x: "); \
  650. DbgPrint(_TitleString); \
  651. DbgPrint(" "); \
  652. for( __i=0; __i<6; __i++ ) \
  653. DbgPrint("%02X%s", ptr[__i], (__i==5)?"":"-"); \
  654. DbgPrint("\n"); \
  655. }
  656. #define RT_PRINT_ADDRS(_Comp, _Level, _TitleString, _Ptr, _AddNum) \
  657. if(((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel)) \
  658. { \
  659. int __i, __j; \
  660. pu1Byte ptr = (pu1Byte)_Ptr; \
  661. DbgPrint("Rtl819x: "); \
  662. DbgPrint(_TitleString); \
  663. DbgPrint("\n"); \
  664. for( __i=0; __i<(int)_AddNum; __i++ ) \
  665. { \
  666. for( __j=0; __j<6; __j++ ) \
  667. DbgPrint("%02X%s", ptr[__i*6+__j], (__j==5)?"":"-"); \
  668. DbgPrint("\n"); \
  669. } \
  670. }
  671. // Added by Annie, 2005-11-22.
  672. #define MAX_STR_LEN 64
  673. #define PRINTABLE(_ch) (_ch>=' ' &&_ch<='~' ) // I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.
  674. #define RT_PRINT_STR(_Comp, _Level, _TitleString, _Ptr, _Len) \
  675. if(((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel)) \
  676. { \
  677. int __i; \
  678. u1Byte buffer[MAX_STR_LEN]; \
  679. int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \
  680. PlatformZeroMemory( buffer, MAX_STR_LEN ); \
  681. PlatformMoveMemory( buffer, (pu1Byte)_Ptr, length ); \
  682. for( __i=0; __i<MAX_STR_LEN; __i++ ) \
  683. { \
  684. if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \
  685. } \
  686. buffer[length] = '\0'; \
  687. DbgPrint("Rtl819x: "); \
  688. DbgPrint(_TitleString); \
  689. DbgPrint(": %d, <%s>\n", _Len, buffer); \
  690. }
  691. #else // of #if DBG
  692. #define DbgPrint(...)
  693. #define PRINT_DATA(_TitleString, _HexData, _HexDataLen)
  694. #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen)
  695. #define RT_PRINT_ADDR(_Comp, _Level, _TitleString, _Ptr)
  696. #define RT_PRINT_ADDRS(_Comp, _Level, _TitleString, _Ptr, _AddNum)
  697. #define RT_PRINT_STR(_Comp, _Level, _TitleString, _Ptr, _Len)
  698. #endif // of #if DBG
  699. #endif // #if (DM_ODM_SUPPORT_TYPE != ODM_WIN)
  700. #define DEBUG_PRINT 1
  701. // Please add new OS's print API by yourself
  702. //#if (RT_PLATFORM==PLATFORM_WINDOWS)
  703. #if (DEBUG_PRINT == 1) && DBG
  704. #define RT_DISP(dbgtype, dbgflag, printstr)\
  705. {\
  706. if (DBGP_Type[dbgtype] & dbgflag)\
  707. {\
  708. DbgPrint printstr;\
  709. }\
  710. }
  711. #define RT_DISP_ADDR(dbgtype, dbgflag, printstr, _Ptr)\
  712. {\
  713. if (DBGP_Type[dbgtype] & dbgflag)\
  714. {\
  715. int __i; \
  716. pu1Byte ptr = (pu1Byte)_Ptr; \
  717. DbgPrint printstr; \
  718. DbgPrint(" "); \
  719. for( __i=0; __i<6; __i++ ) \
  720. DbgPrint("%02X%s", ptr[__i], (__i==5)?"":"-"); \
  721. DbgPrint("\n"); \
  722. }\
  723. }
  724. #define RT_DISP_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)\
  725. {\
  726. if (DBGP_Type[dbgtype] & dbgflag)\
  727. {\
  728. int __i; \
  729. pu1Byte ptr = (pu1Byte)_HexData; \
  730. DbgPrint(_TitleString); \
  731. for( __i=0; __i<(int)_HexDataLen; __i++ ) \
  732. { \
  733. DbgPrint("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" ");\
  734. if (((__i + 1) % 16) == 0) DbgPrint("\n");\
  735. } \
  736. DbgPrint("\n"); \
  737. }\
  738. }
  739. #define FunctionIn(_comp) ODM_RT_TRACE(pDM_Odm,(_comp), DBG_LOUD, ("==========> %s\n", __FUNCTION__))
  740. #define FunctionOut(_comp) ODM_RT_TRACE(pDM_Odm,(_comp), DBG_LOUD, ("<========== %s\n", __FUNCTION__))
  741. #else
  742. #define RT_DISP(dbgtype, dbgflag, printstr)
  743. #define RT_DISP_ADDR(dbgtype, dbgflag, printstr, _Ptr)
  744. #define RT_DISP_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)
  745. #define FunctionIn(_comp)
  746. #define FunctionOut(_comp)
  747. #endif
  748. /*------------------------Export Marco Definition---------------------------*/
  749. /*------------------------Export global variable----------------------------*/
  750. extern u4Byte DBGP_Type[DBGP_TYPE_MAX];
  751. extern DBGP_HEAD_T DBGP_Head;
  752. /*------------------------Export global variable----------------------------*/
  753. /*--------------------------Exported Function prototype---------------------*/
  754. extern void DBGP_Flag_Init(void);
  755. extern void DBG_PrintAllFlag(void);
  756. extern void DBG_PrintAllComp(void);
  757. extern void DBG_PrintFlagEvent(u1Byte DbgFlag);
  758. extern void DBG_DumpMem(const u1Byte DbgComp,
  759. const u1Byte DbgLevel,
  760. pu1Byte pMem,
  761. u2Byte Len);
  762. /*--------------------------Exported Function prototype---------------------*/
  763. extern u4Byte GlobalDebugLevel;
  764. extern u8Byte GlobalDebugComponents;
  765. #endif
  766. #endif // __ODM_DBG_H__