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