xref: /wlan-driver/qca-wifi-host-cmn/wmi/inc/wmi_filtered_logging.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2015-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 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 WMI_FILTERED_LOGGING_H
21 #define WMI_FILTERED_LOGGING_H
22 
23 #include <qdf_debugfs.h>
24 #include "wmi_unified_priv.h"
25 
26 #ifdef WMI_INTERFACE_FILTERED_EVENT_LOGGING
27 /**
28  * wmi_specific_cmd_record() - Record user specified command
29  * @wmi_handle: handle to WMI
30  * @id: cmd id
31  * @buf: buf containing cmd details
32  *
33  * Check if the command id is in target list,
34  * if found, record it.
35  *
36  * Context: the function will not sleep, caller is expected to hold
37  * proper locking.
38  *
39  * Return: none
40  */
41 void wmi_specific_cmd_record(wmi_unified_t wmi_handle,
42 			     uint32_t id, uint8_t *buf);
43 
44 /**
45  * wmi_specific_evt_record() - Record user specified event
46  * @wmi_handle: handle to WMI
47  * @id: cmd id
48  * @buf: buf containing event details
49  *
50  * Check if the event id is in target list,
51  * if found, record it.
52  *
53  * Context: the function will not sleep, caller is expected to hold
54  * proper locking.
55  *
56  * Return: none
57  */
58 void wmi_specific_evt_record(wmi_unified_t wmi_handle,
59 			     uint32_t id, uint8_t *buf);
60 
61 /**
62  * wmi_filtered_logging_init() - initialize filtered logging
63  * @wmi_handle: handle to WMI
64  *
65  * Context: the function will not sleep, no lock needed
66  *
67  * Return: none
68  */
69 void wmi_filtered_logging_init(wmi_unified_t wmi_handle);
70 
71 /**
72  * wmi_filtered_logging_free() - free the buffers for filtered logging
73  * @wmi_handle: handle to WMI
74  *
75  * Context: the function will not sleep, no lock needed
76  *
77  * Return: none
78  */
79 void wmi_filtered_logging_free(wmi_unified_t wmi_handle);
80 
81 /*
82  * Debugfs read/write functions
83  */
84 /**
85  * debug_filtered_wmi_cmds_show() - debugfs read function for filtered_wmi_cmds
86  * @m: seq_file handle
87  * @v: not used, offset of read
88  * Return: number of bytes read
89  */
90 int debug_filtered_wmi_cmds_show(qdf_debugfs_file_t m, void *v);
91 
92 /**
93  * debug_filtered_wmi_evts_show() - debugfs read function for filtered_wmi_evts
94  * @m: seq_file handle
95  * @v: not used, offset of read
96  * Return: number of bytes read
97  */
98 int debug_filtered_wmi_evts_show(qdf_debugfs_file_t m, void *v);
99 
100 /**
101  * debug_wmi_filtered_command_log_show() - debugfs read function for
102  * wmi_filtered_command_log
103  * @m: seq_file handle
104  * @v: not used, offset of read
105  * Return: number of bytes read
106  */
107 int debug_wmi_filtered_command_log_show(qdf_debugfs_file_t m, void *v);
108 
109 /**
110  * debug_wmi_filtered_event_log_show() - debugfs read function for
111  * wmi_filtered_event_log
112  * @m: seq_file handle
113  * @v: not used, offset of read
114  * Return: number of bytes read
115  */
116 int debug_wmi_filtered_event_log_show(qdf_debugfs_file_t m, void *v);
117 
118 /**
119  * debug_filtered_wmi_cmds_write() - debugfs write for filtered_wmi_cmds
120  *
121  * @file: file handler to access wmi_handle
122  * @buf: received data buffer
123  * @count: length of received buffer
124  * @ppos: Not used
125  *
126  * Return: count
127  */
128 ssize_t debug_filtered_wmi_cmds_write(struct file *file,
129 				      const char __user *buf,
130 				      size_t count, loff_t *ppos);
131 
132 /**
133  * debug_filtered_wmi_evts_write() - debugfs write for filtered_wmi_evts
134  *
135  * @file: file handler to access wmi_handle
136  * @buf: received data buffer
137  * @count: length of received buffer
138  * @ppos: Not used
139  *
140  * Return: count
141  */
142 ssize_t debug_filtered_wmi_evts_write(struct file *file,
143 				      const char __user *buf,
144 				      size_t count, loff_t *ppos);
145 
146 /**
147  * debug_wmi_filtered_command_log_write() - debugfs write for
148  * filtered_command_log
149  *
150  * @file: file handler to access wmi_handle
151  * @buf: received data buffer
152  * @count: length of received buffer
153  * @ppos: Not used
154  *
155  * Return: count
156  */
157 ssize_t debug_wmi_filtered_command_log_write(struct file *file,
158 					     const char __user *buf,
159 					     size_t count, loff_t *ppos);
160 
161 /**
162  * debug_wmi_filtered_event_log_write() - debugfs write for filtered_event_log
163  *
164  * @file: file handler to access wmi_handle
165  * @buf: received data buffer
166  * @count: length of received buffer
167  * @ppos: Not used
168  *
169  * Return: count
170  */
171 ssize_t debug_wmi_filtered_event_log_write(struct file *file,
172 					   const char __user *buf,
173 					   size_t count, loff_t *ppos);
174 
175 #else /* WMI_INTERFACE_FILTERED_EVENT_LOGGING */
176 
wmi_specific_cmd_record(wmi_unified_t wmi_handle,uint32_t id,uint8_t * buf)177 static inline void wmi_specific_cmd_record(wmi_unified_t wmi_handle,
178 					   uint32_t id, uint8_t *buf)
179 {
180 	/* do nothing */
181 }
182 
wmi_specific_evt_record(wmi_unified_t wmi_handle,uint32_t id,uint8_t * buf)183 static inline void wmi_specific_evt_record(wmi_unified_t wmi_handle,
184 					   uint32_t id, uint8_t *buf)
185 {
186 	/* do nothing */
187 }
188 
wmi_filtered_logging_init(wmi_unified_t wmi_handle)189 static inline void wmi_filtered_logging_init(wmi_unified_t wmi_handle)
190 {
191 	/* do nothing */
192 }
193 
wmi_filtered_logging_free(wmi_unified_t wmi_handle)194 static inline void wmi_filtered_logging_free(wmi_unified_t wmi_handle)
195 {
196 	/* do nothing */
197 }
198 #endif /* end of WMI_INTERFACE_FILTERED_EVENT_LOGGING */
199 
200 #endif /*WMI_FILTERED_LOGGING_H*/
201