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