xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/dbglog_host.h (revision 7b32946958ccd00534989da3a4b46d0af59a5b5c)
1 /*
2  * Copyright (c) 2011, 2014-2017 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 "ol_defines.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, A_UINT16 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 				A_UINT16 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. this format allows
140  *         user to pass a sinlge value (which is the most convenient way for most of the OSs)
141  *         to be passed from user to the driver.
142  */
143 int
144 dbglog_set_mod_log_lvl(wmi_unified_t wmi_handle, A_UINT32 mod_id_lvl);
145 
146 /** Enable/Disable the logging for VAP */
147 int
148 dbglog_vap_log_enable(wmi_unified_t wmi_handle, A_UINT16 vap_id,
149 		      A_BOOL isenable);
150 /** Enable/Disable logging for Module */
151 int
152 dbglog_module_log_enable(wmi_unified_t wmi_handle, A_UINT32 mod_id,
153 			 A_BOOL isenable);
154 
155 /** set vap enablie bitmap */
156 void
157 dbglog_set_vap_enable_bitmap(wmi_unified_t wmi_handle,
158 			     A_UINT32 vap_enable_bitmap);
159 
160 /** set log level for all the modules specified in the bitmap. for all other modules
161  * with 0 in the bitmap (or) outside the bitmap , the log level be reset to DBGLOG_ERR.
162  */
163 void
164 dbglog_set_mod_enable_bitmap(wmi_unified_t wmi_handle,
165 			     A_UINT32 log_level,
166 			     A_UINT32 *mod_enable_bitmap,
167 			     A_UINT32 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 /** Register the cnss_diag activate with the wlan driver */
175 int cnss_diag_activate_service(void);
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* _DBGLOG_HOST_H_ */
182