xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/dbglog_host.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2011, 2014-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _DBGLOG_HOST_H_
20 #define _DBGLOG_HOST_H_
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include "dbglog_common.h"
27 #include "wmi_unified_param.h"
28 
29 #define DIAG_FWID_OFFSET            24
30 #define DIAG_FWID_MASK              0xFF000000  /* Bit 24-31 */
31 
32 #define DIAG_TIMESTAMP_OFFSET       0
33 #define DIAG_TIMESTAMP_MASK         0x00FFFFFF  /* Bit 0-23 */
34 
35 #define DIAG_ID_OFFSET              16
36 #define DIAG_ID_MASK                0xFFFF0000  /* Bit 16-31 */
37 
38 #define DIAG_VDEVID_OFFSET          11
39 #define DIAG_VDEVID_MASK            0x0000F800  /* Bit 11-15 */
40 #define DIAG_VDEVID_NUM_MAX         16
41 
42 #define DIAG_VDEVLEVEL_OFFSET       8
43 #define DIAG_VDEVLEVEL_MASK         0x00000700  /* Bit 8-10 */
44 
45 #define DIAG_PAYLEN_OFFSET          0
46 #define DIAG_PAYLEN_MASK            0x000000FF  /* Bit 0-7 */
47 
48 #define DIAG_PAYLEN_OFFSET16        0
49 #define DIAG_PAYLEN_MASK16          0x0000FFFF  /* Bit 0-16 */
50 
51 #define DIAG_GET_TYPE(arg) \
52 	((arg & DIAG_FWID_MASK) >> DIAG_FWID_OFFSET)
53 
54 #define DIAG_GET_TIME_STAMP(arg) \
55 	((arg & DIAG_TIMESTAMP_MASK) >> DIAG_TIMESTAMP_OFFSET)
56 
57 #define DIAG_GET_ID(arg) \
58 	((arg & DIAG_ID_MASK) >> DIAG_ID_OFFSET)
59 
60 #define DIAG_GET_VDEVID(arg) \
61 	((arg & DIAG_VDEVID_MASK) >> DIAG_VDEVID_OFFSET)
62 
63 #define DIAG_GET_VDEVLEVEL(arg)	\
64 	((arg & DIAG_VDEVLEVEL_MASK) >> DIAG_VDEVLEVEL_OFFSET)
65 
66 #define DIAG_GET_PAYLEN(arg) \
67 	((arg & DIAG_PAYLEN_MASK) >> DIAG_PAYLEN_OFFSET)
68 
69 #define DIAG_GET_PAYLEN16(arg) \
70 	((arg & DIAG_PAYLEN_MASK16) >> DIAG_PAYLEN_OFFSET16)
71 
72 #define diag_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DIAG, params)
73 #define diag_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DIAG, params)
74 #define diag_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DIAG, params)
75 #define diag_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_DIAG, params)
76 #define diag_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DIAG, params)
77 
78 #define diag_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_DIAG, params)
79 
80 #ifdef FEATURE_FW_LOG_PARSING
81 /*
82  * set the dbglog parser type
83  */int
84 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type);
85 
86 /** dbglog_int - Registers a WMI event handle for WMI_DBGMSG_EVENT
87  * @brief wmi_handle - handle to wmi module
88  */
89 int
90 dbglog_init(wmi_unified_t wmi_handle);
91 
92 /** dbglog_deinit - UnRegisters a WMI event handle for WMI_DBGMSG_EVENT
93  * @brief wmi_handle - handle to wmi module
94  */
95 int
96 dbglog_deinit(wmi_unified_t wmi_handle);
97 
98 /** set the size of the report size
99  * @brief wmi_handle - handle to Wmi module
100  * @brief size - Report size
101  */
102 int
103 dbglog_set_report_size(wmi_unified_t wmi_handle, uint16_t size);
104 
105 /** Set the resolution for time stamp
106  * @brief wmi_handle - handle to Wmi module
107  * @ brief tsr - time stamp resolution
108  */
109 int
110 dbglog_set_timestamp_resolution(wmi_unified_t wmi_handle,
111 				uint16_t tsr);
112 
113 /** Enable reporting. If it is set to false then Target wont deliver
114  * any debug information
115  */
116 int
117 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable);
118 
119 /** Set the log level
120  * @brief DBGLOG_INFO - Information lowest log level
121  * @brief DBGLOG_WARNING
122  * @brief DBGLOG_ERROR - default log level
123  */
124 int
125 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl);
126 
127 /*
128  * set the debug log level for a given module
129  *  mod_id_lvl : the format is more user friendly.
130  *    module_id =  mod_id_lvl/10;
131  *    log_level =  mod_id_lvl%10;
132  * example : mod_id_lvl is 153. then module id is 15 and log level is 3.
133  *           this format allows user to pass a sinlge value
134  *           (which is the most convenient way for most of the OSs)
135  *           to be passed from user to the driver.
136  */
137 int
138 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl);
139 
140 /*
141  * set the debug log level for wow module
142  *  mod_id_lvl : the format is more user friendly.
143  *    module_id =  mod_id_lvl/10;
144  *    log_level =  mod_id_lvl%10;
145  * example : mod_id_lvl is 153. then module id is 15 and log level is 3.
146  *           this format allows user to pass a sinlge value
147  *           (which is the most convenient way for most of the OSs)
148  *           to be passed from user to the driver.
149  */
150 int
151 dbglog_set_mod_wow_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl);
152 
153 /** Enable/Disable the logging for VAP */
154 int
155 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
156 		      A_BOOL isenable);
157 /** Enable/Disable logging for Module */
158 int
159 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
160 			 A_BOOL isenable);
161 
162 /** set vap enablie bitmap */
163 void
164 dbglog_set_vap_enable_bitmap(wmi_unified_t wmi_handle,
165 			     uint32_t vap_enable_bitmap);
166 
167 /** set log level for all the modules specified in the bitmap.
168  *  for all other modules with 0 in the bitmap (or) outside the bitmap,
169  *  the log level be reset to DBGLOG_ERR.
170  */
171 void
172 dbglog_set_mod_enable_bitmap(wmi_unified_t wmi_handle,
173 			     uint32_t log_level,
174 			     uint32_t *mod_enable_bitmap,
175 			     uint32_t bitmap_len);
176 
177 int
178 dbglog_parse_debug_logs(ol_scn_t scn, u_int8_t *datap,
179 					u_int32_t len);
180 
181 /**
182  * cnss_diag_activate_service() - API to register CNSS diag cmd handler
183  *
184  * API to register the handler for the NL message received from cnss_diag
185  * application.
186  *
187  * Return: 0
188  */
189 int cnss_diag_activate_service(void);
190 
191 /**
192  * cnss_diag_deactivate_service() - API to deregister CNSS diag cmd handler
193  *
194  * API to deregister the handler for the NL message received from cnss_diag
195  * application.
196  *
197  * Return: 0
198  */
199 int cnss_diag_deactivate_service(void);
200 
201 #else
202 static inline int
203 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type)
204 {
205 	return A_OK;
206 }
207 
208 static inline int
209 dbglog_init(wmi_unified_t wmi_handle)
210 {
211 	return A_OK;
212 }
213 
214 static inline int
215 dbglog_deinit(wmi_unified_t wmi_handle)
216 {
217 	return A_OK;
218 }
219 
220 static inline int
221 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable)
222 {
223 	return A_OK;
224 }
225 
226 static inline int
227 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl)
228 {
229 	return A_OK;
230 }
231 
232 static inline int cnss_diag_activate_service(void)
233 {
234 	return A_OK;
235 }
236 
237 static inline int cnss_diag_deactivate_service(void)
238 {
239 	return A_OK;
240 }
241 
242 static inline int
243 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
244 			 A_BOOL isenable)
245 {
246 	return A_OK;
247 }
248 
249 static inline int
250 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
251 		      A_BOOL isenable)
252 {
253 	return A_OK;
254 }
255 
256 static inline int
257 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl)
258 {
259 	return A_OK;
260 }
261 
262 static inline int
263 dbglog_set_mod_wow_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl)
264 {
265 	return A_OK;
266 }
267 #endif /* FEATURE_FW_LOG_PARSING */
268 
269 #ifdef __cplusplus
270 }
271 #endif
272 
273 #endif /* _DBGLOG_HOST_H_ */
274