xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/dbglog_host.h (revision a175314c51a4ce5cec2835cc8a8c7dc0c1810915)
1 /*
2  * Copyright (c) 2011, 2014-2018 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 Traget wont deliver
106  * any debug information
107  */
108 int
109 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable);
110 
111 #ifdef CONFIG_MCL
112 /*
113  * enum DBGLOG_LOG_LVL is not converged between WIN and MCL.
114  * So this function declaration needs to be disabled from WIN side.
115  */
116 
117 /** Set the log level
118  * @brief DBGLOG_INFO - Information lowest log level
119  * @brief DBGLOG_WARNING
120  * @brief DBGLOG_ERROR - default log level
121  */
122 int
123 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl);
124 #endif
125 
126 /*
127  * set the debug log level for a given module
128  *  mod_id_lvl : the format is more user friendly.
129  *    module_id =  mod_id_lvl/10;
130  *    log_level =  mod_id_lvl%10;
131  * example : mod_id_lvl is 153. then module id is 15 and log level is 3.
132  *           this format allows user to pass a sinlge value
133  *           (which is the most convenient way for most of the OSs)
134  *           to be passed from user to the driver.
135  */
136 int
137 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl);
138 
139 /** Enable/Disable the logging for VAP */
140 int
141 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
142 		      A_BOOL isenable);
143 /** Enable/Disable logging for Module */
144 int
145 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
146 			 A_BOOL isenable);
147 
148 /** set vap enablie bitmap */
149 void
150 dbglog_set_vap_enable_bitmap(wmi_unified_t wmi_handle,
151 			     uint32_t vap_enable_bitmap);
152 
153 /** set log level for all the modules specified in the bitmap.
154  *  for all other modules with 0 in the bitmap (or) outside the bitmap,
155  *  the log level be reset to DBGLOG_ERR.
156  */
157 void
158 dbglog_set_mod_enable_bitmap(wmi_unified_t wmi_handle,
159 			     uint32_t log_level,
160 			     uint32_t *mod_enable_bitmap,
161 			     uint32_t bitmap_len);
162 
163 int
164 dbglog_parse_debug_logs(ol_scn_t scn, u_int8_t *datap,
165 					u_int32_t len);
166 
167 /**
168  * cnss_diag_activate_service() - API to register CNSS diag cmd handler
169  *
170  * API to register the handler for the NL message received from cnss_diag
171  * application.
172  *
173  * Return: 0
174  */
175 int cnss_diag_activate_service(void);
176 
177 /**
178  * cnss_diag_deactivate_service() - API to deregister CNSS diag cmd handler
179  *
180  * API to deregister the handler for the NL message received from cnss_diag
181  * application.
182  *
183  * Return: 0
184  */
185 int cnss_diag_deactivate_service(void);
186 
187 #else
188 static inline int
189 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type)
190 {
191 	return A_OK;
192 }
193 
194 static inline int
195 dbglog_init(wmi_unified_t wmi_handle)
196 {
197 	return A_OK;
198 }
199 
200 static inline int
201 dbglog_deinit(wmi_unified_t wmi_handle)
202 {
203 	return A_OK;
204 }
205 
206 static inline int
207 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable)
208 {
209 	return A_OK;
210 }
211 
212 #ifdef CONFIG_MCL
213 static inline int
214 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl)
215 {
216 	return A_OK;
217 }
218 #endif
219 
220 static inline int cnss_diag_activate_service(void)
221 {
222 	return A_OK;
223 }
224 
225 static inline int cnss_diag_deactivate_service(void)
226 {
227 	return A_OK;
228 }
229 
230 static inline int
231 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
232 			 A_BOOL isenable)
233 {
234 	return A_OK;
235 }
236 
237 static inline int
238 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
239 		      A_BOOL isenable)
240 {
241 	return A_OK;
242 }
243 
244 static inline int
245 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl)
246 {
247 	return A_OK;
248 }
249 #endif /* FEATURE_FW_LOG_PARSING */
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 
255 #endif /* _DBGLOG_HOST_H_ */
256