xref: /freebsd/sys/contrib/dev/athk/ath11k/trace.h (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2019 The Linux Foundation. All rights reserved.
4  */
5 
6 #if !defined(_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
7 
8 #include <linux/tracepoint.h>
9 #include "core.h"
10 
11 #define _TRACE_H_
12 
13 /* create empty functions when tracing is disabled */
14 #if !defined(CONFIG_ATH11K_TRACING)
15 #undef TRACE_EVENT
16 #define TRACE_EVENT(name, proto, ...) \
17 static inline void trace_ ## name(proto) {} \
18 static inline bool trace_##name##_enabled(void) \
19 {						\
20 	return false;				\
21 }
22 
23 #undef DECLARE_EVENT_CLASS
24 #define DECLARE_EVENT_CLASS(...)
25 #undef DEFINE_EVENT
26 #define DEFINE_EVENT(evt_class, name, proto, ...) \
27 static inline void trace_ ## name(proto) {}
28 #endif /* !CONFIG_ATH11K_TRACING || __CHECKER__ */
29 
30 #undef TRACE_SYSTEM
31 #define TRACE_SYSTEM ath11k
32 
33 #define ATH11K_MSG_MAX 400
34 
35 TRACE_EVENT(ath11k_htt_pktlog,
36 	    TP_PROTO(struct ath11k *ar, const void *buf, u16 buf_len,
37 		     u32 pktlog_checksum),
38 
39 	TP_ARGS(ar, buf, buf_len, pktlog_checksum),
40 
41 	TP_STRUCT__entry(
42 		__string(device, dev_name(ar->ab->dev))
43 		__string(driver, dev_driver_string(ar->ab->dev))
44 		__field(u16, buf_len)
45 		__field(u32, pktlog_checksum)
46 		__dynamic_array(u8, pktlog, buf_len)
47 	),
48 
49 	TP_fast_assign(
50 		__assign_str(device, dev_name(ar->ab->dev));
51 		__assign_str(driver, dev_driver_string(ar->ab->dev));
52 		__entry->buf_len = buf_len;
53 		__entry->pktlog_checksum = pktlog_checksum;
54 		memcpy(__get_dynamic_array(pktlog), buf, buf_len);
55 	),
56 
57 	TP_printk(
58 		"%s %s size %u pktlog_checksum %d",
59 		__get_str(driver),
60 		__get_str(device),
61 		__entry->buf_len,
62 		__entry->pktlog_checksum
63 	 )
64 );
65 
66 TRACE_EVENT(ath11k_htt_ppdu_stats,
67 	    TP_PROTO(struct ath11k *ar, const void *data, size_t len),
68 
69 	TP_ARGS(ar, data, len),
70 
71 	TP_STRUCT__entry(
72 		__string(device, dev_name(ar->ab->dev))
73 		__string(driver, dev_driver_string(ar->ab->dev))
74 		__field(u16, len)
75 		__dynamic_array(u8, ppdu, len)
76 	),
77 
78 	TP_fast_assign(
79 		__assign_str(device, dev_name(ar->ab->dev));
80 		__assign_str(driver, dev_driver_string(ar->ab->dev));
81 		__entry->len = len;
82 		memcpy(__get_dynamic_array(ppdu), data, len);
83 	),
84 
85 	TP_printk(
86 		"%s %s ppdu len %d",
87 		__get_str(driver),
88 		__get_str(device),
89 		__entry->len
90 	 )
91 );
92 
93 TRACE_EVENT(ath11k_htt_rxdesc,
94 	    TP_PROTO(struct ath11k *ar, const void *data, size_t log_type, size_t len),
95 
96 	TP_ARGS(ar, data, log_type, len),
97 
98 	TP_STRUCT__entry(
99 		__string(device, dev_name(ar->ab->dev))
100 		__string(driver, dev_driver_string(ar->ab->dev))
101 		__field(u16, len)
102 		__field(u16, log_type)
103 		__dynamic_array(u8, rxdesc, len)
104 	),
105 
106 	TP_fast_assign(
107 		__assign_str(device, dev_name(ar->ab->dev));
108 		__assign_str(driver, dev_driver_string(ar->ab->dev));
109 		__entry->len = len;
110 		__entry->log_type = log_type;
111 		memcpy(__get_dynamic_array(rxdesc), data, len);
112 	),
113 
114 	TP_printk(
115 		"%s %s rxdesc len %d type %d",
116 		__get_str(driver),
117 		__get_str(device),
118 		__entry->len,
119 		__entry->log_type
120 	 )
121 );
122 
123 DECLARE_EVENT_CLASS(ath11k_log_event,
124 		    TP_PROTO(struct ath11k_base *ab, struct va_format *vaf),
125 	TP_ARGS(ab, vaf),
126 	TP_STRUCT__entry(
127 		__string(device, dev_name(ab->dev))
128 		__string(driver, dev_driver_string(ab->dev))
129 		__vstring(msg, vaf->fmt, vaf->va)
130 	),
131 	TP_fast_assign(
132 		__assign_str(device, dev_name(ab->dev));
133 		__assign_str(driver, dev_driver_string(ab->dev));
134 		__assign_vstr(msg, vaf->fmt, vaf->va);
135 	),
136 	TP_printk(
137 		"%s %s %s",
138 		__get_str(driver),
139 		__get_str(device),
140 		__get_str(msg)
141 	)
142 );
143 
144 DEFINE_EVENT(ath11k_log_event, ath11k_log_err,
145 	     TP_PROTO(struct ath11k_base *ab, struct va_format *vaf),
146 	     TP_ARGS(ab, vaf)
147 );
148 
149 DEFINE_EVENT(ath11k_log_event, ath11k_log_warn,
150 	     TP_PROTO(struct ath11k_base *ab, struct va_format *vaf),
151 	     TP_ARGS(ab, vaf)
152 );
153 
154 DEFINE_EVENT(ath11k_log_event, ath11k_log_info,
155 	     TP_PROTO(struct ath11k_base *ab, struct va_format *vaf),
156 	     TP_ARGS(ab, vaf)
157 );
158 
159 TRACE_EVENT(ath11k_wmi_cmd,
160 	    TP_PROTO(struct ath11k_base *ab, int id, const void *buf, size_t buf_len),
161 
162 	TP_ARGS(ab, id, buf, buf_len),
163 
164 	TP_STRUCT__entry(
165 		__string(device, dev_name(ab->dev))
166 		__string(driver, dev_driver_string(ab->dev))
167 		__field(unsigned int, id)
168 		__field(size_t, buf_len)
169 		__dynamic_array(u8, buf, buf_len)
170 	),
171 
172 	TP_fast_assign(
173 		__assign_str(device, dev_name(ab->dev));
174 		__assign_str(driver, dev_driver_string(ab->dev));
175 		__entry->id = id;
176 		__entry->buf_len = buf_len;
177 		memcpy(__get_dynamic_array(buf), buf, buf_len);
178 	),
179 
180 	TP_printk(
181 		"%s %s id %d len %zu",
182 		__get_str(driver),
183 		__get_str(device),
184 		__entry->id,
185 		__entry->buf_len
186 	 )
187 );
188 
189 TRACE_EVENT(ath11k_wmi_event,
190 	    TP_PROTO(struct ath11k_base *ab, int id, const void *buf, size_t buf_len),
191 
192 	TP_ARGS(ab, id, buf, buf_len),
193 
194 	TP_STRUCT__entry(
195 		__string(device, dev_name(ab->dev))
196 		__string(driver, dev_driver_string(ab->dev))
197 		__field(unsigned int, id)
198 		__field(size_t, buf_len)
199 		__dynamic_array(u8, buf, buf_len)
200 	),
201 
202 	TP_fast_assign(
203 		__assign_str(device, dev_name(ab->dev));
204 		__assign_str(driver, dev_driver_string(ab->dev));
205 		__entry->id = id;
206 		__entry->buf_len = buf_len;
207 		memcpy(__get_dynamic_array(buf), buf, buf_len);
208 	),
209 
210 	TP_printk(
211 		"%s %s id %d len %zu",
212 		__get_str(driver),
213 		__get_str(device),
214 		__entry->id,
215 		__entry->buf_len
216 	)
217 );
218 
219 TRACE_EVENT(ath11k_log_dbg,
220 	    TP_PROTO(struct ath11k_base *ab, unsigned int level, struct va_format *vaf),
221 
222 	TP_ARGS(ab, level, vaf),
223 
224 	TP_STRUCT__entry(
225 		__string(device, dev_name(ab->dev))
226 		__string(driver, dev_driver_string(ab->dev))
227 		__field(unsigned int, level)
228 		__dynamic_array(char, msg, ATH11K_MSG_MAX)
229 	),
230 
231 	TP_fast_assign(
232 		__assign_str(device, dev_name(ab->dev));
233 		__assign_str(driver, dev_driver_string(ab->dev));
234 		__entry->level = level;
235 		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
236 				       ATH11K_MSG_MAX, vaf->fmt,
237 				       *vaf->va) >= ATH11K_MSG_MAX);
238 	),
239 
240 	TP_printk(
241 		"%s %s %s",
242 		__get_str(driver),
243 		__get_str(device),
244 		__get_str(msg)
245 	)
246 );
247 
248 TRACE_EVENT(ath11k_log_dbg_dump,
249 	    TP_PROTO(struct ath11k_base *ab, const char *msg, const char *prefix,
250 		     const void *buf, size_t buf_len),
251 
252 	TP_ARGS(ab, msg, prefix, buf, buf_len),
253 
254 	TP_STRUCT__entry(
255 		__string(device, dev_name(ab->dev))
256 		__string(driver, dev_driver_string(ab->dev))
257 		__string(msg, msg)
258 		__string(prefix, prefix)
259 		__field(size_t, buf_len)
260 		__dynamic_array(u8, buf, buf_len)
261 	),
262 
263 	TP_fast_assign(
264 		__assign_str(device, dev_name(ab->dev));
265 		__assign_str(driver, dev_driver_string(ab->dev));
266 		__assign_str(msg, msg);
267 		__assign_str(prefix, prefix);
268 		__entry->buf_len = buf_len;
269 		memcpy(__get_dynamic_array(buf), buf, buf_len);
270 	),
271 
272 	TP_printk(
273 		"%s %s %s/%s\n",
274 		__get_str(driver),
275 		__get_str(device),
276 		__get_str(prefix),
277 		__get_str(msg)
278 	)
279 );
280 
281 TRACE_EVENT(ath11k_wmi_diag,
282 	    TP_PROTO(struct ath11k_base *ab, const void *data, size_t len),
283 
284 	TP_ARGS(ab, data, len),
285 
286 	TP_STRUCT__entry(
287 		__string(device, dev_name(ab->dev))
288 		__string(driver, dev_driver_string(ab->dev))
289 		__field(u16, len)
290 		__dynamic_array(u8, data, len)
291 	),
292 
293 	TP_fast_assign(
294 		__assign_str(device, dev_name(ab->dev));
295 		__assign_str(driver, dev_driver_string(ab->dev));
296 		__entry->len = len;
297 		memcpy(__get_dynamic_array(data), data, len);
298 	),
299 
300 	TP_printk(
301 		"%s %s tlv diag len %d",
302 		__get_str(driver),
303 		__get_str(device),
304 		__entry->len
305 	)
306 );
307 
308 TRACE_EVENT(ath11k_ps_timekeeper,
309 	    TP_PROTO(struct ath11k *ar, const void *peer_addr,
310 		     u32 peer_ps_timestamp, u8 peer_ps_state),
311 	TP_ARGS(ar, peer_addr, peer_ps_timestamp, peer_ps_state),
312 
313 	TP_STRUCT__entry(__string(device, dev_name(ar->ab->dev))
314 			 __string(driver, dev_driver_string(ar->ab->dev))
315 			 __dynamic_array(u8, peer_addr, ETH_ALEN)
316 			 __field(u8, peer_ps_state)
317 			 __field(u32, peer_ps_timestamp)
318 	),
319 
320 	TP_fast_assign(__assign_str(device, dev_name(ar->ab->dev));
321 		       __assign_str(driver, dev_driver_string(ar->ab->dev));
322 		       memcpy(__get_dynamic_array(peer_addr), peer_addr,
323 			      ETH_ALEN);
324 		       __entry->peer_ps_state = peer_ps_state;
325 		       __entry->peer_ps_timestamp = peer_ps_timestamp;
326 	),
327 
328 	TP_printk("%s %s %u %u",
329 		  __get_str(driver),
330 		  __get_str(device),
331 		  __entry->peer_ps_state,
332 		  __entry->peer_ps_timestamp
333 	)
334 );
335 
336 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
337 
338 /* we don't want to use include/trace/events */
339 #undef TRACE_INCLUDE_PATH
340 #define TRACE_INCLUDE_PATH .
341 #undef TRACE_INCLUDE_FILE
342 #define TRACE_INCLUDE_FILE trace
343 
344 /* This part must be outside protection */
345 #include <trace/define_trace.h>
346