xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/dbglog_host.h (revision 6ecd284e5a94a1c96e26d571dd47419ac305990d)
1 /*
2  * Copyright (c) 2011, 2014-2018 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27 
28 #ifndef _DBGLOG_HOST_H_
29 #define _DBGLOG_HOST_H_
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include "dbglog_common.h"
36 #include "wmi_unified_param.h"
37 
38 #define DIAG_FWID_OFFSET            24
39 #define DIAG_FWID_MASK              0xFF000000  /* Bit 24-31 */
40 
41 #define DIAG_TIMESTAMP_OFFSET       0
42 #define DIAG_TIMESTAMP_MASK         0x00FFFFFF  /* Bit 0-23 */
43 
44 #define DIAG_ID_OFFSET              16
45 #define DIAG_ID_MASK                0xFFFF0000  /* Bit 16-31 */
46 
47 #define DIAG_VDEVID_OFFSET          11
48 #define DIAG_VDEVID_MASK            0x0000F800  /* Bit 11-15 */
49 #define DIAG_VDEVID_NUM_MAX         16
50 
51 #define DIAG_VDEVLEVEL_OFFSET       8
52 #define DIAG_VDEVLEVEL_MASK         0x00000700  /* Bit 8-10 */
53 
54 #define DIAG_PAYLEN_OFFSET          0
55 #define DIAG_PAYLEN_MASK            0x000000FF  /* Bit 0-7 */
56 
57 #define DIAG_PAYLEN_OFFSET16        0
58 #define DIAG_PAYLEN_MASK16          0x0000FFFF  /* Bit 0-16 */
59 
60 #define DIAG_GET_TYPE(arg) \
61 	((arg & DIAG_FWID_MASK) >> DIAG_FWID_OFFSET)
62 
63 #define DIAG_GET_TIME_STAMP(arg) \
64 	((arg & DIAG_TIMESTAMP_MASK) >> DIAG_TIMESTAMP_OFFSET)
65 
66 #define DIAG_GET_ID(arg) \
67 	((arg & DIAG_ID_MASK) >> DIAG_ID_OFFSET)
68 
69 #define DIAG_GET_VDEVID(arg) \
70 	((arg & DIAG_VDEVID_MASK) >> DIAG_VDEVID_OFFSET)
71 
72 #define DIAG_GET_VDEVLEVEL(arg)	\
73 	((arg & DIAG_VDEVLEVEL_MASK) >> DIAG_VDEVLEVEL_OFFSET)
74 
75 #define DIAG_GET_PAYLEN(arg) \
76 	((arg & DIAG_PAYLEN_MASK) >> DIAG_PAYLEN_OFFSET)
77 
78 #define DIAG_GET_PAYLEN16(arg) \
79 	((arg & DIAG_PAYLEN_MASK16) >> DIAG_PAYLEN_OFFSET16)
80 
81 /*
82  * set the dbglog parser type
83  */int
84 dbglog_parser_type_init(wmi_unified_t wmi_handle, int type);
85 
86 /** dbglog_int - Registers a WMI event handle for WMI_DBGMSG_EVENT
87  * @brief wmi_handle - handle to wmi module
88  */
89 int
90 dbglog_init(wmi_unified_t wmi_handle);
91 
92 /** dbglog_deinit - UnRegisters a WMI event handle for WMI_DBGMSG_EVENT
93  * @brief wmi_handle - handle to wmi module
94  */
95 int
96 dbglog_deinit(wmi_unified_t wmi_handle);
97 
98 /** set the size of the report size
99  * @brief wmi_handle - handle to Wmi module
100  * @brief size - Report size
101  */
102 int
103 dbglog_set_report_size(wmi_unified_t wmi_handle, uint16_t size);
104 
105 /** Set the resolution for time stamp
106  * @brief wmi_handle - handle to Wmi module
107  * @ brief tsr - time stamp resolution
108  */
109 int
110 dbglog_set_timestamp_resolution(wmi_unified_t wmi_handle,
111 				uint16_t tsr);
112 
113 /** Enable reporting. If it is set to false then Traget wont deliver
114  * any debug information
115  */
116 int
117 dbglog_report_enable(wmi_unified_t wmi_handle, A_BOOL isenable);
118 
119 #ifdef CONFIG_MCL
120 /*
121  * enum DBGLOG_LOG_LVL is not converged between WIN and MCL.
122  * So this function declaration needs to be disabled from WIN side.
123  */
124 
125 /** Set the log level
126  * @brief DBGLOG_INFO - Information lowest log level
127  * @brief DBGLOG_WARNING
128  * @brief DBGLOG_ERROR - default log level
129  */
130 int
131 dbglog_set_log_lvl(wmi_unified_t wmi_handle, DBGLOG_LOG_LVL log_lvl);
132 #endif
133 
134 /*
135  * set the debug log level for a given module
136  *  mod_id_lvl : the format is more user friendly.
137  *    module_id =  mod_id_lvl/10;
138  *    log_level =  mod_id_lvl%10;
139  * example : mod_id_lvl is 153. then module id is 15 and log level is 3.
140  *           this format allows user to pass a sinlge value
141  *           (which is the most convenient way for most of the OSs)
142  *           to be passed from user to the driver.
143  */
144 int
145 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, uint32_t mod_id_lvl);
146 
147 /** Enable/Disable the logging for VAP */
148 int
149 dbglog_vap_log_enable(wmi_unified_t wmi_handle, uint16_t vap_id,
150 		      A_BOOL isenable);
151 /** Enable/Disable logging for Module */
152 int
153 dbglog_module_log_enable(wmi_unified_t wmi_handle, uint32_t mod_id,
154 			 A_BOOL isenable);
155 
156 /** set vap enablie bitmap */
157 void
158 dbglog_set_vap_enable_bitmap(wmi_unified_t wmi_handle,
159 			     uint32_t vap_enable_bitmap);
160 
161 /** set log level for all the modules specified in the bitmap.
162  *  for all other modules with 0 in the bitmap (or) outside the bitmap,
163  *  the log level be reset to DBGLOG_ERR.
164  */
165 void
166 dbglog_set_mod_enable_bitmap(wmi_unified_t wmi_handle,
167 			     uint32_t log_level,
168 			     uint32_t *mod_enable_bitmap,
169 			     uint32_t bitmap_len);
170 
171 int
172 dbglog_parse_debug_logs(ol_scn_t scn, u_int8_t *datap,
173 					u_int32_t len);
174 
175 
176 /** Register the cnss_diag activate with the wlan driver */
177 int cnss_diag_activate_service(void);
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* _DBGLOG_HOST_H_ */
184