xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/inc/fw_dbglog_api.h (revision 901120c066e139c7f8a2c8e4820561fdd83c67ef)
1 /*
2  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _FW_DBGLOG_API_H_
21 #define _FW_DBGLOG_API_H_
22 
23 #include "target_if.h"
24 
25 /**
26  * fwdbg_set_log_lvl() - API to set debug log level
27  * @dbg_handle: Debug module handle
28  * @scn: scn handle
29  * @log_lvl: value of log level
30  *
31  * Send wmi configuration command to set debug log level.
32  *
33  * Return: None
34  */
35 void fwdbg_set_log_lvl(struct common_dbglog_handle *dbg_handle, ol_scn_t scn,
36 		uint32_t log_lvl);
37 
38 /**
39  * fwdbg_fw_handler() - Firmware handler interface
40  * @dbg_handle: Debug module handle
41  * @sc: soc handle
42  * @data: Reference to command data
43  * @datalen: length of data
44  *
45  * Return: 0 success
46  */
47 int fwdbg_fw_handler(struct common_dbglog_handle *dbg_handle, ol_scn_t sc,
48 			uint8_t *data, uint32_t datalen);
49 
50 /**
51  * fwdbg_parse_debug_logs() - API to parse firmware debug logs
52  * @dbg_handle: Debug module handle
53  * @soc: soc handle
54  * @datap: Reference to log data
55  * @len: length of data
56  * @context: log context
57  *
58  * API parse firmware debug log messages and prints to console.
59  *
60  * Return: 0 success
61  */
62 int fwdbg_parse_debug_logs(struct common_dbglog_handle *dbg_handle,
63 				ol_scn_t soc, uint8_t *datap,
64 				uint16_t len, void *context);
65 
66 /**
67  * fwdbg_ratelimit_set() - API to set rate limit
68  * @dbg_handle: Debug module handle
69  * @burst_limit: burst limit
70  *
71  * Return: None
72  */
73 void fwdbg_ratelimit_set(struct common_dbglog_handle *dbg_handle,
74 			uint32_t burst_limit);
75 
76 /**
77  * fwdbg_vap_log_enable() - API to Enable/Disable the logging for VAP
78  * @dbg_handle: Debug module handle
79  * @scn: scn handle
80  * @vap_id: VAP id
81  * @isenable: Enable/disable
82  *
83  * API allows to enable or disable debuglogs at VAP level. It encodes wmi
84  * config command based on VAP id and sends wmi command to firmware to
85  * enable/disable debuglog.
86  *
87  * Return: None
88  */
89 void fwdbg_vap_log_enable(struct common_dbglog_handle *dbg_handle, ol_scn_t scn,
90 				uint16_t vap_id, bool isenable);
91 
92 /**
93  * fwdbg_set_timestamp_resolution - Set the resolution for time stamp
94  * @dbg_handle: Debug module handle
95  * @scn: scn handle
96  * @tsr: time stamp resolution
97  *
98  * Set the resolution for time stamp in debug logs. It encodes wmi
99  * config command to desired timestamp resolution and sends wmi command to
100  * firmware.
101  *
102  * Return: None
103  */
104 void fwdbg_set_timestamp_resolution(struct common_dbglog_handle *dbg_handle,
105 				ol_scn_t scn, uint16_t tsr);
106 
107 /**
108  * fwdbg_reporting_enable() - Enable reporting.
109  * @dbg_handle: Debug module handle
110  * @scn: scn handle
111  * @isenable: Enable/disable
112  *
113  * API to enable debug information reporting. It encodes wmi config command
114  * to enable reporting. If set to false then Target won't deliver any debug
115  * information.
116  *
117  * Return: None
118  */
119 void fwdbg_reporting_enable(struct common_dbglog_handle *dbg_handle,
120 				ol_scn_t scn, bool isenable);
121 
122 /**
123  * fwdbg_module_log_enable() - Enable/Disable logging for Module.
124  * @dbg_handle: Debug module handle
125  * @scn: scn handle
126  * @mod_id: Module id
127  * @isenable: Enable/disable
128  *
129  * API allows to enable or disable debuglogs per module. It encodes wmi
130  * config command based on module id and sends wmi command to firmware to
131  * enable/disable debuglog for that module.
132  *
133  * Return: None
134  */
135 void fwdbg_module_log_enable(struct common_dbglog_handle *dbg_handle,
136 			ol_scn_t scn, uint32_t mod_id, bool isenable);
137 
138 /**
139  * fwdbg_init() - Initialize debuglog.
140  * @dbg_handle: Debug module handle
141  * @soc: soc handle
142  *
143  * It initializes debuglog print function for set of modules and
144  * initializes WMI event handler for debuglog message event.
145  *
146  * Return: None
147  */
148 void fwdbg_init(struct common_dbglog_handle *dbg_handle, void *soc);
149 
150 /**
151  * fwdbg_free() - Free debug handler.
152  * @dbg_handle: Debug module handle
153  * @soc: soc handle
154  *
155  * Return: None
156  */
157 void fwdbg_free(struct common_dbglog_handle *dbg_handle, void *soc);
158 
159 /**
160  * fwdbg_set_report_size() - set the size of the report size
161  * @dbg_handle: Debug module handle
162  * @scn: soc handler
163  * @size: Report size
164  *
165  * Set the debug log report size. It encodes wmi config command to
166  * desired report size and sends wmi command to firmware.
167  *
168  * Return: None
169  */
170 void fwdbg_set_report_size(struct common_dbglog_handle *dbg_handle,
171 				ol_scn_t scn, uint16_t size);
172 
173 /**
174  * fwdbg_smartlog_init() - initialize smart logging feature
175  * @dbg_handle: Debug module handle
176  * @ic: ic handler
177  *
178  * Return: 0 Success
179  */
180 int fwdbg_smartlog_init(struct common_dbglog_handle *dbg_handle, void *icp);
181 
182 /**
183  * fwdbg_smartlog_deinit() - uninitializes smart logging feature
184  * @dbg_handle: Debug module handle
185  * @sc: sc handler
186  *
187  * Return: None
188  */
189 void fwdbg_smartlog_deinit(struct common_dbglog_handle *dbg_handle, void *sc);
190 
191 /**
192  * fwdbg_smartlog_dump() - dumps smart logs
193  * @dev: dev handler
194  * @dbg_handle: Debug module handle
195  * @attr: dev handler attributes
196  * @buf: destination buffer to dump smart logs
197  *
198  * Return: 0 success
199  */
200 ssize_t fwdbg_smartlog_dump(struct common_dbglog_handle *dbg_handle,
201 			    struct device *dev,
202 			    struct device_attribute *attr, char *buf);
203 #endif /* _FW_DBGLOG_API_H_ */
204