xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/dbglog_host.h (revision 4865edfd190c086bbe2c69aae12a8226f877b91e)
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 /*
73  * set the dbglog parser type
74  */int
75 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type);
76 
77 /** dbglog_int - Registers a WMI event handle for WMI_DBGMSG_EVENT
78  * @brief wmi_handle - handle to wmi module
79  */
80 int
81 dbglog_init(wmi_unified_t wmi_handle);
82 
83 /** dbglog_deinit - UnRegisters a WMI event handle for WMI_DBGMSG_EVENT
84  * @brief wmi_handle - handle to wmi module
85  */
86 int
87 dbglog_deinit(wmi_unified_t wmi_handle);
88 
89 /** set the size of the report size
90  * @brief wmi_handle - handle to Wmi module
91  * @brief size - Report size
92  */
93 int
94 dbglog_set_report_size(wmi_unified_t wmi_handle, uint16_t size);
95 
96 /** Set the resolution for time stamp
97  * @brief wmi_handle - handle to Wmi module
98  * @ brief tsr - time stamp resolution
99  */
100 int
101 dbglog_set_timestamp_resolution(wmi_unified_t wmi_handle,
102 				uint16_t tsr);
103 
104 /** Enable reporting. If it is set to false then Traget wont deliver
105  * any debug information
106  */
107 int
108 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable);
109 
110 #ifdef CONFIG_MCL
111 /*
112  * enum DBGLOG_LOG_LVL is not converged between WIN and MCL.
113  * So this function declaration needs to be disabled from WIN side.
114  */
115 
116 /** Set the log level
117  * @brief DBGLOG_INFO - Information lowest log level
118  * @brief DBGLOG_WARNING
119  * @brief DBGLOG_ERROR - default log level
120  */
121 int
122 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl);
123 #endif
124 
125 /*
126  * set the debug log level for a given module
127  *  mod_id_lvl : the format is more user friendly.
128  *    module_id =  mod_id_lvl/10;
129  *    log_level =  mod_id_lvl%10;
130  * example : mod_id_lvl is 153. then module id is 15 and log level is 3.
131  *           this format allows user to pass a sinlge value
132  *           (which is the most convenient way for most of the OSs)
133  *           to be passed from user to the driver.
134  */
135 int
136 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl);
137 
138 /** Enable/Disable the logging for VAP */
139 int
140 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
141 		      A_BOOL isenable);
142 /** Enable/Disable logging for Module */
143 int
144 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
145 			 A_BOOL isenable);
146 
147 /** set vap enablie bitmap */
148 void
149 dbglog_set_vap_enable_bitmap(wmi_unified_t wmi_handle,
150 			     uint32_t vap_enable_bitmap);
151 
152 /** set log level for all the modules specified in the bitmap.
153  *  for all other modules with 0 in the bitmap (or) outside the bitmap,
154  *  the log level be reset to DBGLOG_ERR.
155  */
156 void
157 dbglog_set_mod_enable_bitmap(wmi_unified_t wmi_handle,
158 			     uint32_t log_level,
159 			     uint32_t *mod_enable_bitmap,
160 			     uint32_t bitmap_len);
161 
162 int
163 dbglog_parse_debug_logs(ol_scn_t scn, u_int8_t *datap,
164 					u_int32_t len);
165 
166 
167 /** Register the cnss_diag activate with the wlan driver */
168 int cnss_diag_activate_service(void);
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 #endif /* _DBGLOG_HOST_H_ */
175