GNU Linux-libre 4.19.286-gnu1
[releases.git] / drivers / staging / rtlwifi / debug.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2009-2012  Realtek Corporation.
5  *
6  * Contact Information:
7  * wlanfae <wlanfae@realtek.com>
8  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
9  * Hsinchu 300, Taiwan.
10  *
11  * Larry Finger <Larry.Finger@lwfinger.net>
12  *****************************************************************************/
13
14 #ifndef __RTL_DEBUG_H__
15 #define __RTL_DEBUG_H__
16
17 /*--------------------------------------------------------------
18  *                      Debug level
19  *------------------------------------------------------------
20  *
21  *Fatal bug.
22  *For example, Tx/Rx/IO locked up,
23  *memory access violation,
24  *resource allocation failed,
25  *unexpected HW behavior, HW BUG
26  *and so on.
27  */
28 /*#define DBG_EMERG                     0 */
29
30 /*Abnormal, rare, or unexpected cases.
31  *For example, Packet/IO Ctl canceled,
32  *device surprisingly removed and so on.
33  */
34 #define DBG_WARNING                     2
35
36 /*Normal case driver developer should
37  *open, we can see link status like
38  *assoc/AddBA/DHCP/adapter start and
39  *so on basic and useful infromations.
40  */
41 #define DBG_DMESG                       3
42
43 /*Normal case with useful information
44  *about current SW or HW state.
45  *For example, Tx/Rx descriptor to fill,
46  *Tx/Rx descriptor completed status,
47  *SW protocol state change, dynamic
48  *mechanism state change and so on.
49  */
50 #define DBG_LOUD                        4
51
52 /*Normal case with detail execution
53  *flow or information.
54  */
55 #define DBG_TRACE                       5
56
57 /*--------------------------------------------------------------
58  *              Define the rt_trace components
59  *--------------------------------------------------------------
60  */
61 #define COMP_ERR                        BIT(0)
62 #define COMP_FW                         BIT(1)
63 #define COMP_INIT                       BIT(2)  /*For init/deinit */
64 #define COMP_RECV                       BIT(3)  /*For Rx. */
65 #define COMP_SEND                       BIT(4)  /*For Tx. */
66 #define COMP_MLME                       BIT(5)  /*For MLME. */
67 #define COMP_SCAN                       BIT(6)  /*For Scan. */
68 #define COMP_INTR                       BIT(7)  /*For interrupt Related. */
69 #define COMP_LED                        BIT(8)  /*For LED. */
70 #define COMP_SEC                        BIT(9)  /*For sec. */
71 #define COMP_BEACON                     BIT(10) /*For beacon. */
72 #define COMP_RATE                       BIT(11) /*For rate. */
73 #define COMP_RXDESC                     BIT(12) /*For rx desc. */
74 #define COMP_DIG                        BIT(13) /*For DIG */
75 #define COMP_TXAGC                      BIT(14) /*For Tx power */
76 #define COMP_HIPWR                      BIT(15) /*For High Power Mechanism */
77 #define COMP_POWER                      BIT(16) /*For lps/ips/aspm. */
78 #define COMP_POWER_TRACKING     BIT(17) /*For TX POWER TRACKING */
79 #define COMP_BB_POWERSAVING     BIT(18)
80 #define COMP_SWAS                       BIT(19) /*For SW Antenna Switch */
81 #define COMP_RF                         BIT(20) /*For RF. */
82 #define COMP_TURBO                      BIT(21) /*For EDCA TURBO. */
83 #define COMP_RATR                       BIT(22)
84 #define COMP_CMD                        BIT(23)
85 #define COMP_EFUSE                      BIT(24)
86 #define COMP_QOS                        BIT(25)
87 #define COMP_MAC80211           BIT(26)
88 #define COMP_REGD                       BIT(27)
89 #define COMP_CHAN                       BIT(28)
90 #define COMP_USB                        BIT(29)
91 #define COMP_EASY_CONCURRENT    COMP_USB /* reuse of this bit is OK */
92 #define COMP_BT_COEXIST                 BIT(30)
93 #define COMP_IQK                        BIT(31)
94 #define COMP_TX_REPORT                  BIT_ULL(32)
95 #define COMP_HALMAC                     BIT_ULL(34)
96 #define COMP_PHYDM                      BIT_ULL(35)
97
98 /*--------------------------------------------------------------
99  *              Define the rt_print components
100  *--------------------------------------------------------------
101  */
102 /* Define EEPROM and EFUSE  check module bit*/
103 #define EEPROM_W                        BIT(0)
104 #define EFUSE_PG                        BIT(1)
105 #define EFUSE_READ_ALL                  BIT(2)
106
107 /* Define init check for module bit*/
108 #define INIT_EEPROM                     BIT(0)
109 #define INIT_TXPOWER                    BIT(1)
110 #define INIT_IQK                        BIT(2)
111 #define INIT_RF                         BIT(3)
112
113 /* Define PHY-BB/RF/MAC check module bit */
114 #define PHY_BBR                         BIT(0)
115 #define PHY_BBW                         BIT(1)
116 #define PHY_RFR                         BIT(2)
117 #define PHY_RFW                         BIT(3)
118 #define PHY_MACR                        BIT(4)
119 #define PHY_MACW                        BIT(5)
120 #define PHY_ALLR                        BIT(6)
121 #define PHY_ALLW                        BIT(7)
122 #define PHY_TXPWR                       BIT(8)
123 #define PHY_PWRDIFF                     BIT(9)
124
125 /* Define Dynamic Mechanism check module bit --> FDM */
126 #define WA_IOT                          BIT(0)
127 #define DM_PWDB                         BIT(1)
128 #define DM_MONITOR                      BIT(2)
129 #define DM_DIG                          BIT(3)
130 #define DM_EDCA_TURBO                   BIT(4)
131
132 #define DM_PWDB                         BIT(1)
133
134 enum dbgp_flag_e {
135         FQOS = 0,
136         FTX = 1,
137         FRX = 2,
138         FSEC = 3,
139         FMGNT = 4,
140         FMLME = 5,
141         FRESOURCE = 6,
142         FBEACON = 7,
143         FISR = 8,
144         FPHY = 9,
145         FMP = 10,
146         FEEPROM = 11,
147         FPWR = 12,
148         FDM = 13,
149         FDBGCTRL = 14,
150         FC2H = 15,
151         FBT = 16,
152         FINIT = 17,
153         FIOCTL = 18,
154         DBGP_TYPE_MAX
155 };
156
157 #ifdef CONFIG_RTLWIFI_DEBUG_ST
158
159 struct rtl_priv;
160
161 __printf(4, 5)
162 void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level,
163                     const char *fmt, ...);
164
165 __printf(4, 5)
166 void _rtl_dbg_print(struct rtl_priv *rtlpriv, u64 comp, int level,
167                     const char *fmt, ...);
168
169 void _rtl_dbg_print_data(struct rtl_priv *rtlpriv, u64 comp, int level,
170                          const char *titlestring,
171                          const void *hexdata, int hexdatalen);
172
173 #define RT_TRACE(rtlpriv, comp, level, fmt, ...)                        \
174         _rtl_dbg_trace(rtlpriv, comp, level,                            \
175                        fmt, ##__VA_ARGS__)
176
177 #define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...)                    \
178         _rtl_dbg_print(rtlpriv, dbgtype, dbgflag, fmt, ##__VA_ARGS__)
179
180 #define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata,   \
181                       _hexdatalen)                                      \
182         _rtl_dbg_print_data(rtlpriv, _comp, _level,                     \
183                             _titlestring, _hexdata, _hexdatalen)
184
185 #else
186
187 struct rtl_priv;
188
189 __printf(4, 5)
190 static inline void RT_TRACE(struct rtl_priv *rtlpriv,
191                             u64 comp, int level,
192                             const char *fmt, ...)
193 {
194 }
195
196 __printf(4, 5)
197 static inline void RTPRINT(struct rtl_priv *rtlpriv,
198                            int dbgtype, int dbgflag,
199                            const char *fmt, ...)
200 {
201 }
202
203 static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
204                                  u64 comp, int level,
205                                  const char *titlestring,
206                                  const void *hexdata, size_t hexdatalen)
207 {
208 }
209
210 #endif
211
212 #ifdef CONFIG_RTLWIFI_DEBUG_ST
213 void rtl_debug_add_one(struct ieee80211_hw *hw);
214 void rtl_debug_remove_one(struct ieee80211_hw *hw);
215 void rtl_debugfs_add_topdir(void);
216 void rtl_debugfs_remove_topdir(void);
217 #else
218 #define rtl_debug_add_one(hw)
219 #define rtl_debug_remove_one(hw)
220 #define rtl_debugfs_add_topdir()
221 #define rtl_debugfs_remove_topdir()
222 #endif
223 #endif