OSDN Git Service

staging: rtl8723bs: update to the latest driver
[android-x86/kernel.git] / drivers / staging / rtl8723bs / hal / odm_debug.h
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  ******************************************************************************/
15
16 #ifndef __ODM_DBG_H__
17 #define __ODM_DBG_H__
18
19
20 /*  */
21 /*      Define the debug levels */
22 /*  */
23 /*      1.      DBG_TRACE and DBG_LOUD are used for normal cases. */
24 /*      So that, they can help SW engineer to develope or trace states changed */
25 /*      and also help HW enginner to trace every operation to and from HW, */
26 /*      e.g IO, Tx, Rx. */
27 /*  */
28 /*      2.      DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, */
29 /*      which help us to debug SW or HW. */
30 /*  */
31 /*  */
32 /*  */
33 /*      Never used in a call to ODM_RT_TRACE()! */
34 /*  */
35 #define ODM_DBG_OFF                                     1
36
37 /*  */
38 /*      Fatal bug. */
39 /*      For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */
40 /*      resource allocation failed, unexpected HW behavior, HW BUG and so on. */
41 /*  */
42 #define ODM_DBG_SERIOUS                         2
43
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 /*  */
51 /*      Normal case with useful information about current SW or HW state. */
52 /*      For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status, */
53 /*      SW protocol state change, dynamic mechanism state change and so on. */
54 /*  */
55 #define ODM_DBG_LOUD                                    4
56
57 /*  */
58 /*      Normal case with detail execution flow or information. */
59 /*  */
60 #define ODM_DBG_TRACE                                   5
61
62 /*  */
63 /*  Define the tracing components */
64 /*  */
65 /*  */
66 /* BB Functions */
67 #define ODM_COMP_DIG                                    BIT0
68 #define ODM_COMP_RA_MASK                                BIT1
69 #define ODM_COMP_DYNAMIC_TXPWR          BIT2
70 #define ODM_COMP_FA_CNT                         BIT3
71 #define ODM_COMP_RSSI_MONITOR           BIT4
72 #define ODM_COMP_CCK_PD                         BIT5
73 #define ODM_COMP_ANT_DIV                                BIT6
74 #define ODM_COMP_PWR_SAVE                       BIT7
75 #define ODM_COMP_PWR_TRAIN                      BIT8
76 #define ODM_COMP_RATE_ADAPTIVE          BIT9
77 #define ODM_COMP_PATH_DIV                               BIT10
78 #define ODM_COMP_PSD                                    BIT11
79 #define ODM_COMP_DYNAMIC_PRICCA         BIT12
80 #define ODM_COMP_RXHP                                   BIT13
81 #define ODM_COMP_MP                                     BIT14
82 #define ODM_COMP_CFO_TRACKING           BIT15
83 /* MAC Functions */
84 #define ODM_COMP_EDCA_TURBO                     BIT16
85 #define ODM_COMP_EARLY_MODE                     BIT17
86 /* RF Functions */
87 #define ODM_COMP_TX_PWR_TRACK           BIT24
88 #define ODM_COMP_RX_GAIN_TRACK          BIT25
89 #define ODM_COMP_CALIBRATION                    BIT26
90 /* Common Functions */
91 #define ODM_COMP_COMMON                         BIT30
92 #define ODM_COMP_INIT                                   BIT31
93
94 /*------------------------Export Marco Definition---------------------------*/
95         #define DbgPrint        printk
96         #define RT_PRINTK(fmt, args...) DbgPrint("%s(): " fmt, __func__, ## args);
97         #define RT_DISP(dbgtype, dbgflag, printstr)
98
99 #ifndef ASSERT
100         #define ASSERT(expr)
101 #endif
102
103 #if DBG
104 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)                                                                 \
105                 if (((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel || level == ODM_DBG_SERIOUS))  \
106                 {                                                                                                                                                       \
107                         RT_PRINTK fmt;                                                                                                                  \
108                 }
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
116 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)                                                                                       \
117                 if (!(expr)) {                                                                                                                                  \
118                         DbgPrint("Assertion failed! %s at ......\n", #expr);                                                            \
119                         DbgPrint("      ......%s,%s, line =%d\n", __FILE__, __func__, __LINE__);                        \
120                         RT_PRINTK fmt;                                                                                                                  \
121                         ASSERT(false);                                                                                                                  \
122                 }
123 #define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); }
124 #define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); }
125 #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); }
126
127 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)                                                    \
128                         if (((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel))      \
129                         {                                                                                                                                               \
130                                 int __i;                                                                                                                                \
131                                 u8 *__ptr = (u8 *)ptr;                                                                                  \
132                                 DbgPrint("[ODM] ");                                                                                                     \
133                                 DbgPrint(title_str);                                                                                                    \
134                                 DbgPrint(" ");                                                                                                          \
135                                 for (__i = 0; __i<6; __i++)                                                                                             \
136                                         DbgPrint("%02X%s", __ptr[__i], (__i ==5)?"":"-");                                               \
137                                 DbgPrint("\n");                                                                                                         \
138                         }
139 #else
140 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)
141 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)
142 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)
143 #define ODM_dbg_enter()
144 #define ODM_dbg_exit()
145 #define ODM_dbg_trace(str)
146 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)
147 #endif
148
149 void
150 ODM_InitDebugSetting(
151         PDM_ODM_T               pDM_Odm
152         );
153
154 #endif  /*  __ODM_DBG_H__ */