xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/dbglog_host.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
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 #ifdef FEATURE_FW_LOG_PARSING
73 /*
74  * set the dbglog parser type
75  */int
76 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type);
77 
78 /** dbglog_int - Registers a WMI event handle for WMI_DBGMSG_EVENT
79  * @brief wmi_handle - handle to wmi module
80  */
81 int
82 dbglog_init(wmi_unified_t wmi_handle);
83 
84 /** dbglog_deinit - UnRegisters a WMI event handle for WMI_DBGMSG_EVENT
85  * @brief wmi_handle - handle to wmi module
86  */
87 int
88 dbglog_deinit(wmi_unified_t wmi_handle);
89 
90 /** set the size of the report size
91  * @brief wmi_handle - handle to Wmi module
92  * @brief size - Report size
93  */
94 int
95 dbglog_set_report_size(wmi_unified_t wmi_handle, uint16_t size);
96 
97 /** Set the resolution for time stamp
98  * @brief wmi_handle - handle to Wmi module
99  * @ brief tsr - time stamp resolution
100  */
101 int
102 dbglog_set_timestamp_resolution(wmi_unified_t wmi_handle,
103 				uint16_t tsr);
104 
105 /** Enable reporting. If it is set to false then Target wont deliver
106  * any debug information
107  */
108 int
109 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable);
110 
111 /** Set the log level
112  * @brief DBGLOG_INFO - Information lowest log level
113  * @brief DBGLOG_WARNING
114  * @brief DBGLOG_ERROR - default log level
115  */
116 int
117 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl);
118 
119 /*
120  * set the debug log level for a given module
121  *  mod_id_lvl : the format is more user friendly.
122  *    module_id =  mod_id_lvl/10;
123  *    log_level =  mod_id_lvl%10;
124  * example : mod_id_lvl is 153. then module id is 15 and log level is 3.
125  *           this format allows user to pass a sinlge value
126  *           (which is the most convenient way for most of the OSs)
127  *           to be passed from user to the driver.
128  */
129 int
130 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl);
131 
132 /*
133  * set the debug log level for wow module
134  *  mod_id_lvl : the format is more user friendly.
135  *    module_id =  mod_id_lvl/10;
136  *    log_level =  mod_id_lvl%10;
137  * example : mod_id_lvl is 153. then module id is 15 and log level is 3.
138  *           this format allows user to pass a sinlge value
139  *           (which is the most convenient way for most of the OSs)
140  *           to be passed from user to the driver.
141  */
142 int
143 dbglog_set_mod_wow_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl);
144 
145 /** Enable/Disable the logging for VAP */
146 int
147 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
148 		      A_BOOL isenable);
149 /** Enable/Disable logging for Module */
150 int
151 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
152 			 A_BOOL isenable);
153 
154 /** set vap enablie bitmap */
155 void
156 dbglog_set_vap_enable_bitmap(wmi_unified_t wmi_handle,
157 			     uint32_t vap_enable_bitmap);
158 
159 /** set log level for all the modules specified in the bitmap.
160  *  for all other modules with 0 in the bitmap (or) outside the bitmap,
161  *  the log level be reset to DBGLOG_ERR.
162  */
163 void
164 dbglog_set_mod_enable_bitmap(wmi_unified_t wmi_handle,
165 			     uint32_t log_level,
166 			     uint32_t *mod_enable_bitmap,
167 			     uint32_t bitmap_len);
168 
169 int
170 dbglog_parse_debug_logs(ol_scn_t scn, u_int8_t *datap,
171 					u_int32_t len);
172 
173 /**
174  * cnss_diag_activate_service() - API to register CNSS diag cmd handler
175  *
176  * API to register the handler for the NL message received from cnss_diag
177  * application.
178  *
179  * Return: 0
180  */
181 int cnss_diag_activate_service(void);
182 
183 /**
184  * cnss_diag_deactivate_service() - API to deregister CNSS diag cmd handler
185  *
186  * API to deregister the handler for the NL message received from cnss_diag
187  * application.
188  *
189  * Return: 0
190  */
191 int cnss_diag_deactivate_service(void);
192 
193 #else
194 static inline int
195 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type)
196 {
197 	return A_OK;
198 }
199 
200 static inline int
201 dbglog_init(wmi_unified_t wmi_handle)
202 {
203 	return A_OK;
204 }
205 
206 static inline int
207 dbglog_deinit(wmi_unified_t wmi_handle)
208 {
209 	return A_OK;
210 }
211 
212 static inline int
213 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable)
214 {
215 	return A_OK;
216 }
217 
218 static inline int
219 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl)
220 {
221 	return A_OK;
222 }
223 
224 static inline int cnss_diag_activate_service(void)
225 {
226 	return A_OK;
227 }
228 
229 static inline int cnss_diag_deactivate_service(void)
230 {
231 	return A_OK;
232 }
233 
234 static inline int
235 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
236 			 A_BOOL isenable)
237 {
238 	return A_OK;
239 }
240 
241 static inline int
242 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
243 		      A_BOOL isenable)
244 {
245 	return A_OK;
246 }
247 
248 static inline int
249 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl)
250 {
251 	return A_OK;
252 }
253 
254 static inline int
255 dbglog_set_mod_wow_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl)
256 {
257 	return A_OK;
258 }
259 #endif /* FEATURE_FW_LOG_PARSING */
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif /* _DBGLOG_HOST_H_ */
266