Linux-libre 3.14.42-gnu
[librecmc/linux-libre.git] / drivers / staging / rtl8188eu / include / 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  * 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
26 /*  */
27 /*      Define the debug levels */
28 /*  */
29 /*      1. DBG_TRACE and DBG_LOUD are used for normal cases. */
30 /*      They can help SW engineer to develop 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 /*      Never used in a call to ODM_RT_TRACE()! */
38 #define ODM_DBG_OFF                             1
39
40 /*      Fatal bug. */
41 /*      For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */
42 /*      resource allocation failed, unexpected HW behavior, HW BUG and so on. */
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 #define ODM_DBG_WARNING                         3
48
49 /*      Normal case with useful information about current SW or HW state. */
50 /*      For example, Tx/Rx descriptor to fill, Tx/Rx descr. completed status, */
51 /*      SW protocol state change, dynamic mechanism state change and so on. */
52 /*  */
53 #define ODM_DBG_LOUD                                    4
54
55 /*      Normal case with detail execution flow or information. */
56 #define ODM_DBG_TRACE                                   5
57
58 /*  Define the tracing components */
59 /* BB Functions */
60 #define ODM_COMP_DIG                                    BIT0
61 #define ODM_COMP_RA_MASK                                BIT1
62 #define ODM_COMP_DYNAMIC_TXPWR                          BIT2
63 #define ODM_COMP_FA_CNT                                 BIT3
64 #define ODM_COMP_RSSI_MONITOR                           BIT4
65 #define ODM_COMP_CCK_PD                                 BIT5
66 #define ODM_COMP_ANT_DIV                                BIT6
67 #define ODM_COMP_PWR_SAVE                               BIT7
68 #define ODM_COMP_PWR_TRA                                BIT8
69 #define ODM_COMP_RATE_ADAPTIVE                          BIT9
70 #define ODM_COMP_PATH_DIV                               BIT10
71 #define ODM_COMP_PSD                                    BIT11
72 #define ODM_COMP_DYNAMIC_PRICCA                         BIT12
73 #define ODM_COMP_RXHP                                   BIT13
74 /* MAC Functions */
75 #define ODM_COMP_EDCA_TURBO                             BIT16
76 #define ODM_COMP_EARLY_MODE                             BIT17
77 /* RF Functions */
78 #define ODM_COMP_TX_PWR_TRACK                           BIT24
79 #define ODM_COMP_RX_GAIN_TRACK                          BIT25
80 #define ODM_COMP_CALIBRATION                            BIT26
81 /* Common Functions */
82 #define ODM_COMP_COMMON                                 BIT30
83 #define ODM_COMP_INIT                                   BIT31
84
85 /*------------------------Export Marco Definition---------------------------*/
86 #define DbgPrint        pr_info
87 #define RT_PRINTK(fmt, args...)                         \
88         DbgPrint( "%s(): " fmt, __func__, ## args);
89
90 #ifndef ASSERT
91         #define ASSERT(expr)
92 #endif
93
94 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)                         \
95         if (((comp) & pDM_Odm->DebugComponents) &&                      \
96             (level <= pDM_Odm->DebugLevel)) {                           \
97                 DbgPrint("[ODM-8188E] ");                               \
98                 RT_PRINTK fmt;                                          \
99         }
100
101 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)                       \
102         if (((comp) & pDM_Odm->DebugComponents) &&                      \
103             (level <= pDM_Odm->DebugLevel)) {                           \
104                 RT_PRINTK fmt;                                          \
105         }
106
107 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)                               \
108         if (!(expr)) {                                                  \
109                 DbgPrint( "Assertion failed! %s at ......\n", #expr);   \
110                 DbgPrint( "      ......%s,%s,line=%d\n", __FILE__,      \
111                         __func__, __LINE__);                            \
112                 RT_PRINTK fmt;                                          \
113                 ASSERT(false);                                          \
114         }
115 #define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); }
116 #define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); }
117 #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); }
118
119 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)            \
120         if (((comp) & pDM_Odm->DebugComponents) &&                      \
121             (level <= pDM_Odm->DebugLevel)) {                           \
122                 int __i;                                                \
123                 u8 *__ptr = (u8 *)ptr;                                  \
124                 DbgPrint("[ODM] ");                                     \
125                 DbgPrint(title_str);                                    \
126                 DbgPrint(" ");                                          \
127                 for (__i = 0; __i < 6; __i++)                           \
128                         DbgPrint("%02X%s", __ptr[__i], (__i == 5)?"":"-");\
129                 DbgPrint("\n");                                         \
130         }
131
132 void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm);
133
134 #endif  /*  __ODM_DBG_H__ */