net: wireless: rockchip_wlan: add rtl8188eu support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8188eu / hal / phydm / phydm_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  * 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
21
22 #ifndef __ODM_DBG_H__
23 #define __ODM_DBG_H__
24
25 #define DEBUG_VERSION   "1.0"  /*2015.01.13 Dino*/
26 //-----------------------------------------------------------------------------
27 //      Define the debug levels
28 //
29 //      1.      DBG_TRACE and DBG_LOUD are used for normal cases.
30 //      So that, they can help SW engineer to develope or trace states changed 
31 //      and also help HW enginner to trace every operation to and from HW, 
32 //      e.g IO, Tx, Rx. 
33 //
34 //      2.      DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, 
35 //      which help us to debug SW or HW.
36 //
37 //-----------------------------------------------------------------------------
38 //
39 //      Never used in a call to ODM_RT_TRACE()!
40 //
41 #define ODM_DBG_OFF                                     1
42
43 //
44 //      Fatal bug. 
45 //      For example, Tx/Rx/IO locked up, OS hangs, memory access violation, 
46 //      resource allocation failed, unexpected HW behavior, HW BUG and so on.
47 //
48 #define ODM_DBG_SERIOUS                         2
49
50 //
51 //      Abnormal, rare, or unexpeted cases.
52 //      For example, IRP/Packet/OID canceled, device suprisely unremoved and so on.
53 //
54 #define ODM_DBG_WARNING                         3
55
56 //
57 //      Normal case with useful information about current SW or HW state. 
58 //      For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status, 
59 //      SW protocol state change, dynamic mechanism state change and so on.
60 //
61 #define ODM_DBG_LOUD                                    4
62
63 //
64 //      Normal case with detail execution flow or information.
65 //
66 #define ODM_DBG_TRACE                                   5
67
68 /*FW DBG MSG*/
69 #define RATE_DECISION   BIT0
70 #define INIT_RA_TABLE   BIT1
71 #define RATE_UP                 BIT2
72 #define RATE_DOWN               BIT3
73 #define TRY_DONE                BIT4
74 #define F_RATE_AP_RPT   BIT7
75
76 //-----------------------------------------------------------------------------
77 // Define the tracing components
78 //
79 //-----------------------------------------------------------------------------
80 //BB Functions
81 #define ODM_COMP_DIG                                    BIT0    
82 #define ODM_COMP_RA_MASK                                BIT1    
83 #define ODM_COMP_DYNAMIC_TXPWR          BIT2
84 #define ODM_COMP_FA_CNT                         BIT3
85 #define ODM_COMP_RSSI_MONITOR           BIT4
86 #define ODM_COMP_CCK_PD                         BIT5
87 #define ODM_COMP_ANT_DIV                                BIT6
88 #define ODM_COMP_PWR_SAVE                       BIT7
89 #define ODM_COMP_PWR_TRAIN                      BIT8
90 #define ODM_COMP_RATE_ADAPTIVE          BIT9
91 #define ODM_COMP_PATH_DIV                       BIT10
92 #define ODM_COMP_PSD                                    BIT11
93 #define ODM_COMP_DYNAMIC_PRICCA         BIT12
94 #define ODM_COMP_RXHP                                   BIT13
95 #define ODM_COMP_MP                                     BIT14
96 #define ODM_COMP_CFO_TRACKING           BIT15
97 #define ODM_COMP_ACS                                    BIT16
98 #define PHYDM_COMP_ADAPTIVITY           BIT17
99 #define PHYDM_COMP_RA_DBG                       BIT18
100 #define PHYDM_COMP_TXBF                         BIT19
101 //MAC Functions
102 #define ODM_COMP_EDCA_TURBO                     BIT20
103 #define ODM_COMP_EARLY_MODE                     BIT21
104 #define ODM_FW_DEBUG_TRACE                      BIT22
105 //RF Functions
106 #define ODM_COMP_TX_PWR_TRACK           BIT24
107 #define ODM_COMP_RX_GAIN_TRACK          BIT25
108 #define ODM_COMP_CALIBRATION                    BIT26
109 //Common Functions
110 #define ODM_PHY_CONFIG                          BIT28
111 #define BEAMFORMING_DEBUG                               BIT29
112 #define ODM_COMP_COMMON                         BIT30
113 #define ODM_COMP_INIT                                   BIT31
114 #define ODM_COMP_NOISY_DETECT           BIT32
115
116 /*------------------------Export Marco Definition---------------------------*/
117 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
118         #define RT_PRINTK                               DbgPrint
119 #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
120         #define DbgPrint        printk
121         #define RT_PRINTK(fmt, args...) DbgPrint( "%s(): " fmt, __FUNCTION__, ## args);
122         #define RT_DISP(dbgtype, dbgflag, printstr)
123 #else
124         #define DbgPrint        panic_printk
125         #define RT_PRINTK(fmt, args...) DbgPrint( "%s(): " fmt, __FUNCTION__, ## args);
126 #endif
127
128 #ifndef ASSERT
129         #define ASSERT(expr)
130 #endif
131
132 #if DBG
133 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)                                                                 \
134         do {    \
135                 if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel || level == ODM_DBG_SERIOUS))   \
136                 {                                                                                                                                                       \
137                         if(pDM_Odm->SupportICType == ODM_RTL8192C)                                                              \
138                                 DbgPrint("[ODM-92C] ");                                                                                         \
139                         else if(pDM_Odm->SupportICType == ODM_RTL8192D)                                                 \
140                                 DbgPrint("[ODM-92D] ");                                                                                         \
141                         else if(pDM_Odm->SupportICType == ODM_RTL8723A)                                                 \
142                                 DbgPrint("[ODM-8723A] ");                                                                                       \
143                         else if(pDM_Odm->SupportICType == ODM_RTL8188E)                                                 \
144                                 DbgPrint("[ODM-8188E] ");                                                                                       \
145                         else if(pDM_Odm->SupportICType == ODM_RTL8192E)                                                 \
146                                 DbgPrint("[ODM-8192E] ");                                                                                       \
147                         else if(pDM_Odm->SupportICType == ODM_RTL8812)                                                  \
148                                 DbgPrint("[ODM-8812] ");                                                                                        \
149                         else if(pDM_Odm->SupportICType == ODM_RTL8821)                                                  \
150                                 DbgPrint("[ODM-8821] ");                                                                                        \
151                         else if(pDM_Odm->SupportICType == ODM_RTL8814A)                                                 \
152                                 DbgPrint("[ODM-8814] ");                                                                                        \
153                         else if(pDM_Odm->SupportICType == ODM_RTL8703B)                                                 \
154                                 DbgPrint("[ODM-8703B] ");                                                                                       \
155                         else if(pDM_Odm->SupportICType == ODM_RTL8822B)                                                 \
156                                 DbgPrint("[ODM-8822] ");                                                                                        \
157                         else if (pDM_Odm->SupportICType == ODM_RTL8188F)                                                        \
158                                 DbgPrint("[ODM-8188F] ");                                                                                       \
159                         RT_PRINTK fmt;                                                                                                                  \
160                 }       \
161         } while (0)
162         
163 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)                                                                       \
164                 if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel))       \
165                 {                                                                                                                                                       \
166                         RT_PRINTK fmt;                                                                                                                  \
167                 }
168
169 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)                                                                                       \
170                 if(!(expr)) {                                                                                                                                   \
171                         DbgPrint( "Assertion failed! %s at ......\n", #expr);                                                           \
172                         DbgPrint( "      ......%s,%s,line=%d\n",__FILE__,__FUNCTION__,__LINE__);                        \
173                         RT_PRINTK fmt;                                                                                                                  \
174                         ASSERT(FALSE);                                                                                                                  \
175                 }
176 #define ODM_dbg_enter() { DbgPrint("==> %s\n", __FUNCTION__); }
177 #define ODM_dbg_exit() { DbgPrint("<== %s\n", __FUNCTION__); }
178 #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __FUNCTION__, str); }
179
180 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)                                                    \
181                         if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel))       \
182                         {                                                                                                                                               \
183                                 int __i;                                                                                                                                \
184                                 pu1Byte __ptr = (pu1Byte)ptr;                                                                                   \
185                                 DbgPrint("[ODM] ");                                                                                                     \
186                                 DbgPrint(title_str);                                                                                                    \
187                                 DbgPrint(" ");                                                                                                          \
188                                 for( __i=0; __i<6; __i++ )                                                                                              \
189                                         DbgPrint("%02X%s", __ptr[__i], (__i==5)?"":"-");                                                \
190                                 DbgPrint("\n");                                                                                                         \
191                         }
192 #else
193 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)
194 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)
195 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)
196 #define ODM_dbg_enter()
197 #define ODM_dbg_exit()
198 #define ODM_dbg_trace(str)
199 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)
200 #endif
201
202
203 VOID 
204 PHYDM_InitDebugSetting(IN               PDM_ODM_T               pDM_Odm);
205
206 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
207 VOID phydm_BB_RxHang_Info(IN PDM_ODM_T pDM_Odm);
208 #endif
209
210 #define BB_TMP_BUF_SIZE         100
211 VOID phydm_BB_Debug_Info(IN PDM_ODM_T pDM_Odm);
212 VOID phydm_BasicDbgMessage(     IN              PVOID                   pDM_VOID);
213
214 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
215 #define PHYDM_DBGPRINT          0
216 #define PHYDM_SSCANF(x, y, z)   DCMD_Scanf(x, y, z)
217 #if (PHYDM_DBGPRINT == 1)
218 #define PHYDM_SNPRINTF(msg)     \
219                 do {\
220                         rsprintf msg;\
221                         DbgPrint(output);\
222                 } while (0)
223 #else
224 #define PHYDM_SNPRINTF(msg)     \
225                 do {\
226                         rsprintf msg;\
227                         DCMD_Printf(output);\
228                 } while (0)
229 #endif
230 #else
231 #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
232 #define PHYDM_DBGPRINT          0
233 #else
234 #define PHYDM_DBGPRINT          1
235 #endif
236 #define MAX_ARGC                                20
237 #define MAX_ARGV                                16
238 #define DCMD_DECIMAL                    "%d"
239 #define DCMD_CHAR                               "%c"
240 #define DCMD_HEX                                "%x"
241
242 #define PHYDM_SSCANF(x, y, z)   sscanf(x, y, z)
243 #if (PHYDM_DBGPRINT == 1)
244 #define PHYDM_SNPRINTF(msg)\
245                 do {\
246                         snprintf msg;\
247                         DbgPrint(output);\
248                 } while (0)
249 #else
250 #define PHYDM_SNPRINTF(msg)\
251                 do {\
252                         if(out_len > used)\
253                                 used+=snprintf msg;\
254                 } while (0)
255 #endif
256 #endif
257
258
259 VOID phydm_BasicProfile(
260         IN              PVOID                   pDM_VOID,
261         IN              u4Byte                  *_used,
262         OUT             char                            *output,
263         IN              u4Byte                  *_out_len
264         );
265 #if(DM_ODM_SUPPORT_TYPE & (ODM_CE|ODM_AP))
266 s4Byte
267 phydm_cmd(
268         IN PDM_ODM_T    pDM_Odm,
269         IN char         *input,
270         IN u4Byte       in_len,
271         IN u1Byte       flag,
272         OUT char        *output,
273         IN u4Byte       out_len
274 );
275 #endif
276 VOID
277 phydm_cmd_parser(
278         IN PDM_ODM_T    pDM_Odm,
279         IN char         input[][16],
280         IN u4Byte       input_num,
281         IN u1Byte       flag,
282         OUT char        *output,
283         IN u4Byte       out_len
284 );
285
286 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
287 void phydm_sbd_check(
288         IN      PDM_ODM_T                                       pDM_Odm
289         );
290
291 void phydm_sbd_callback(
292         PRT_TIMER               pTimer
293         );
294
295 void phydm_sbd_workitem_callback(
296     IN PVOID            pContext
297         );
298 #endif
299
300 VOID
301 phydm_fw_trace_en_h2c(
302         IN      PVOID   pDM_VOID,
303         IN      BOOLEAN         enable,
304         IN      u4Byte          monitor_mode,
305         IN      u4Byte          macid
306 );
307
308 VOID
309 phydm_fw_trace_handler(
310         IN              PVOID   pDM_VOID,
311         IN              pu1Byte CmdBuf,
312         IN              u1Byte  CmdLen
313 );
314
315 VOID
316 phydm_fw_trace_handler_code(
317         IN      PVOID   pDM_VOID,
318         IN      pu1Byte Buffer,
319         IN      u1Byte  CmdLen
320 );
321
322 VOID
323 phydm_fw_trace_handler_8051(
324         IN      PVOID   pDM_VOID,
325         IN      pu1Byte CmdBuf,
326         IN      u1Byte  CmdLen
327 );
328
329 #endif  // __ODM_DBG_H__
330