xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/dbglog_host.h (revision 1f55ed1a9f5050d8da228aa8dd3fff7c0242aa71)
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 /** 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 /** Enable/Disable the logging for VAP */
133 int
134 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
135 		      A_BOOL isenable);
136 /** Enable/Disable logging for Module */
137 int
138 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
139 			 A_BOOL isenable);
140 
141 /** set vap enablie bitmap */
142 void
143 dbglog_set_vap_enable_bitmap(wmi_unified_t wmi_handle,
144 			     uint32_t vap_enable_bitmap);
145 
146 /** set log level for all the modules specified in the bitmap.
147  *  for all other modules with 0 in the bitmap (or) outside the bitmap,
148  *  the log level be reset to DBGLOG_ERR.
149  */
150 void
151 dbglog_set_mod_enable_bitmap(wmi_unified_t wmi_handle,
152 			     uint32_t log_level,
153 			     uint32_t *mod_enable_bitmap,
154 			     uint32_t bitmap_len);
155 
156 int
157 dbglog_parse_debug_logs(ol_scn_t scn, u_int8_t *datap,
158 					u_int32_t len);
159 
160 /**
161  * cnss_diag_activate_service() - API to register CNSS diag cmd handler
162  *
163  * API to register the handler for the NL message received from cnss_diag
164  * application.
165  *
166  * Return: 0
167  */
168 int cnss_diag_activate_service(void);
169 
170 /**
171  * cnss_diag_deactivate_service() - API to deregister CNSS diag cmd handler
172  *
173  * API to deregister the handler for the NL message received from cnss_diag
174  * application.
175  *
176  * Return: 0
177  */
178 int cnss_diag_deactivate_service(void);
179 
180 #else
181 static inline int
182 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type)
183 {
184 	return A_OK;
185 }
186 
187 static inline int
188 dbglog_init(wmi_unified_t wmi_handle)
189 {
190 	return A_OK;
191 }
192 
193 static inline int
194 dbglog_deinit(wmi_unified_t wmi_handle)
195 {
196 	return A_OK;
197 }
198 
199 static inline int
200 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable)
201 {
202 	return A_OK;
203 }
204 
205 static inline int
206 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl)
207 {
208 	return A_OK;
209 }
210 
211 static inline int cnss_diag_activate_service(void)
212 {
213 	return A_OK;
214 }
215 
216 static inline int cnss_diag_deactivate_service(void)
217 {
218 	return A_OK;
219 }
220 
221 static inline int
222 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
223 			 A_BOOL isenable)
224 {
225 	return A_OK;
226 }
227 
228 static inline int
229 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
230 		      A_BOOL isenable)
231 {
232 	return A_OK;
233 }
234 
235 static inline int
236 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl)
237 {
238 	return A_OK;
239 }
240 #endif /* FEATURE_FW_LOG_PARSING */
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif /* _DBGLOG_HOST_H_ */
247