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