xref: /linux/drivers/net/wireless/ath/ath10k/trace.h (revision e58e871becec2d3b04ed91c0c16fe8deac9c9dfa)
1 /*
2  * Copyright (c) 2005-2011 Atheros Communications Inc.
3  * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #if !defined(_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
19 
20 #include <linux/tracepoint.h>
21 #include "core.h"
22 
23 #if !defined(_TRACE_H_)
24 static inline u32 ath10k_frm_hdr_len(const void *buf, size_t len)
25 {
26 	const struct ieee80211_hdr *hdr = buf;
27 
28 	/* In some rare cases (e.g. fcs error) device reports frame buffer
29 	 * shorter than what frame header implies (e.g. len = 0). The buffer
30 	 * can still be accessed so do a simple min() to guarantee caller
31 	 * doesn't get value greater than len.
32 	 */
33 	return min_t(u32, len, ieee80211_hdrlen(hdr->frame_control));
34 }
35 #endif
36 
37 #define _TRACE_H_
38 
39 /* create empty functions when tracing is disabled */
40 #if !defined(CONFIG_ATH10K_TRACING)
41 #undef TRACE_EVENT
42 #define TRACE_EVENT(name, proto, ...) \
43 static inline void trace_ ## name(proto) {}
44 #undef DECLARE_EVENT_CLASS
45 #define DECLARE_EVENT_CLASS(...)
46 #undef DEFINE_EVENT
47 #define DEFINE_EVENT(evt_class, name, proto, ...) \
48 static inline void trace_ ## name(proto) {}
49 #endif /* !CONFIG_ATH10K_TRACING || __CHECKER__ */
50 
51 #undef TRACE_SYSTEM
52 #define TRACE_SYSTEM ath10k
53 
54 #define ATH10K_MSG_MAX 400
55 
56 DECLARE_EVENT_CLASS(ath10k_log_event,
57 	TP_PROTO(struct ath10k *ar, struct va_format *vaf),
58 	TP_ARGS(ar, vaf),
59 	TP_STRUCT__entry(
60 		__string(device, dev_name(ar->dev))
61 		__string(driver, dev_driver_string(ar->dev))
62 		__dynamic_array(char, msg, ATH10K_MSG_MAX)
63 	),
64 	TP_fast_assign(
65 		__assign_str(device, dev_name(ar->dev));
66 		__assign_str(driver, dev_driver_string(ar->dev));
67 		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
68 				       ATH10K_MSG_MAX,
69 				       vaf->fmt,
70 				       *vaf->va) >= ATH10K_MSG_MAX);
71 	),
72 	TP_printk(
73 		"%s %s %s",
74 		__get_str(driver),
75 		__get_str(device),
76 		__get_str(msg)
77 	)
78 );
79 
80 DEFINE_EVENT(ath10k_log_event, ath10k_log_err,
81 	     TP_PROTO(struct ath10k *ar, struct va_format *vaf),
82 	     TP_ARGS(ar, vaf)
83 );
84 
85 DEFINE_EVENT(ath10k_log_event, ath10k_log_warn,
86 	     TP_PROTO(struct ath10k *ar, struct va_format *vaf),
87 	     TP_ARGS(ar, vaf)
88 );
89 
90 DEFINE_EVENT(ath10k_log_event, ath10k_log_info,
91 	     TP_PROTO(struct ath10k *ar, struct va_format *vaf),
92 	     TP_ARGS(ar, vaf)
93 );
94 
95 TRACE_EVENT(ath10k_log_dbg,
96 	TP_PROTO(struct ath10k *ar, unsigned int level, struct va_format *vaf),
97 	TP_ARGS(ar, level, vaf),
98 	TP_STRUCT__entry(
99 		__string(device, dev_name(ar->dev))
100 		__string(driver, dev_driver_string(ar->dev))
101 		__field(unsigned int, level)
102 		__dynamic_array(char, msg, ATH10K_MSG_MAX)
103 	),
104 	TP_fast_assign(
105 		__assign_str(device, dev_name(ar->dev));
106 		__assign_str(driver, dev_driver_string(ar->dev));
107 		__entry->level = level;
108 		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
109 				       ATH10K_MSG_MAX,
110 				       vaf->fmt,
111 				       *vaf->va) >= ATH10K_MSG_MAX);
112 	),
113 	TP_printk(
114 		"%s %s %s",
115 		__get_str(driver),
116 		__get_str(device),
117 		__get_str(msg)
118 	)
119 );
120 
121 TRACE_EVENT(ath10k_log_dbg_dump,
122 	TP_PROTO(struct ath10k *ar, const char *msg, const char *prefix,
123 		 const void *buf, size_t buf_len),
124 
125 	TP_ARGS(ar, msg, prefix, buf, buf_len),
126 
127 	TP_STRUCT__entry(
128 		__string(device, dev_name(ar->dev))
129 		__string(driver, dev_driver_string(ar->dev))
130 		__string(msg, msg)
131 		__string(prefix, prefix)
132 		__field(size_t, buf_len)
133 		__dynamic_array(u8, buf, buf_len)
134 	),
135 
136 	TP_fast_assign(
137 		__assign_str(device, dev_name(ar->dev));
138 		__assign_str(driver, dev_driver_string(ar->dev));
139 		__assign_str(msg, msg);
140 		__assign_str(prefix, prefix);
141 		__entry->buf_len = buf_len;
142 		memcpy(__get_dynamic_array(buf), buf, buf_len);
143 	),
144 
145 	TP_printk(
146 		"%s %s %s/%s\n",
147 		__get_str(driver),
148 		__get_str(device),
149 		__get_str(prefix),
150 		__get_str(msg)
151 	)
152 );
153 
154 TRACE_EVENT(ath10k_wmi_cmd,
155 	TP_PROTO(struct ath10k *ar, int id, const void *buf, size_t buf_len,
156 		 int ret),
157 
158 	TP_ARGS(ar, id, buf, buf_len, ret),
159 
160 	TP_STRUCT__entry(
161 		__string(device, dev_name(ar->dev))
162 		__string(driver, dev_driver_string(ar->dev))
163 		__field(unsigned int, id)
164 		__field(size_t, buf_len)
165 		__dynamic_array(u8, buf, buf_len)
166 		__field(int, ret)
167 	),
168 
169 	TP_fast_assign(
170 		__assign_str(device, dev_name(ar->dev));
171 		__assign_str(driver, dev_driver_string(ar->dev));
172 		__entry->id = id;
173 		__entry->buf_len = buf_len;
174 		__entry->ret = ret;
175 		memcpy(__get_dynamic_array(buf), buf, buf_len);
176 	),
177 
178 	TP_printk(
179 		"%s %s id %d len %zu ret %d",
180 		__get_str(driver),
181 		__get_str(device),
182 		__entry->id,
183 		__entry->buf_len,
184 		__entry->ret
185 	)
186 );
187 
188 TRACE_EVENT(ath10k_wmi_event,
189 	TP_PROTO(struct ath10k *ar, int id, const void *buf, size_t buf_len),
190 
191 	TP_ARGS(ar, id, buf, buf_len),
192 
193 	TP_STRUCT__entry(
194 		__string(device, dev_name(ar->dev))
195 		__string(driver, dev_driver_string(ar->dev))
196 		__field(unsigned int, id)
197 		__field(size_t, buf_len)
198 		__dynamic_array(u8, buf, buf_len)
199 	),
200 
201 	TP_fast_assign(
202 		__assign_str(device, dev_name(ar->dev));
203 		__assign_str(driver, dev_driver_string(ar->dev));
204 		__entry->id = id;
205 		__entry->buf_len = buf_len;
206 		memcpy(__get_dynamic_array(buf), buf, buf_len);
207 	),
208 
209 	TP_printk(
210 		"%s %s id %d len %zu",
211 		__get_str(driver),
212 		__get_str(device),
213 		__entry->id,
214 		__entry->buf_len
215 	)
216 );
217 
218 TRACE_EVENT(ath10k_htt_stats,
219 	TP_PROTO(struct ath10k *ar, const void *buf, size_t buf_len),
220 
221 	TP_ARGS(ar, buf, buf_len),
222 
223 	TP_STRUCT__entry(
224 		__string(device, dev_name(ar->dev))
225 		__string(driver, dev_driver_string(ar->dev))
226 		__field(size_t, buf_len)
227 		__dynamic_array(u8, buf, buf_len)
228 	),
229 
230 	TP_fast_assign(
231 		__assign_str(device, dev_name(ar->dev));
232 		__assign_str(driver, dev_driver_string(ar->dev));
233 		__entry->buf_len = buf_len;
234 		memcpy(__get_dynamic_array(buf), buf, buf_len);
235 	),
236 
237 	TP_printk(
238 		"%s %s len %zu",
239 		__get_str(driver),
240 		__get_str(device),
241 		__entry->buf_len
242 	)
243 );
244 
245 TRACE_EVENT(ath10k_wmi_dbglog,
246 	TP_PROTO(struct ath10k *ar, const void *buf, size_t buf_len),
247 
248 	TP_ARGS(ar, buf, buf_len),
249 
250 	TP_STRUCT__entry(
251 		__string(device, dev_name(ar->dev))
252 		__string(driver, dev_driver_string(ar->dev))
253 		__field(u8, hw_type);
254 		__field(size_t, buf_len)
255 		__dynamic_array(u8, buf, buf_len)
256 	),
257 
258 	TP_fast_assign(
259 		__assign_str(device, dev_name(ar->dev));
260 		__assign_str(driver, dev_driver_string(ar->dev));
261 		__entry->hw_type = ar->hw_rev;
262 		__entry->buf_len = buf_len;
263 		memcpy(__get_dynamic_array(buf), buf, buf_len);
264 	),
265 
266 	TP_printk(
267 		"%s %s %d len %zu",
268 		__get_str(driver),
269 		__get_str(device),
270 		__entry->hw_type,
271 		__entry->buf_len
272 	)
273 );
274 
275 TRACE_EVENT(ath10k_htt_pktlog,
276 	    TP_PROTO(struct ath10k *ar, const void *buf, u16 buf_len),
277 
278 	TP_ARGS(ar, buf, buf_len),
279 
280 	TP_STRUCT__entry(
281 		__string(device, dev_name(ar->dev))
282 		__string(driver, dev_driver_string(ar->dev))
283 		__field(u8, hw_type);
284 		__field(u16, buf_len)
285 		__dynamic_array(u8, pktlog, buf_len)
286 	),
287 
288 	TP_fast_assign(
289 		__assign_str(device, dev_name(ar->dev));
290 		__assign_str(driver, dev_driver_string(ar->dev));
291 		__entry->hw_type = ar->hw_rev;
292 		__entry->buf_len = buf_len;
293 		memcpy(__get_dynamic_array(pktlog), buf, buf_len);
294 	),
295 
296 	TP_printk(
297 		"%s %s %d size %hu",
298 		__get_str(driver),
299 		__get_str(device),
300 		__entry->hw_type,
301 		__entry->buf_len
302 	 )
303 );
304 
305 TRACE_EVENT(ath10k_htt_tx,
306 	    TP_PROTO(struct ath10k *ar, u16 msdu_id, u16 msdu_len,
307 		     u8 vdev_id, u8 tid),
308 
309 	TP_ARGS(ar, msdu_id, msdu_len, vdev_id, tid),
310 
311 	TP_STRUCT__entry(
312 		__string(device, dev_name(ar->dev))
313 		__string(driver, dev_driver_string(ar->dev))
314 		__field(u16, msdu_id)
315 		__field(u16, msdu_len)
316 		__field(u8, vdev_id)
317 		__field(u8, tid)
318 	),
319 
320 	TP_fast_assign(
321 		__assign_str(device, dev_name(ar->dev));
322 		__assign_str(driver, dev_driver_string(ar->dev));
323 		__entry->msdu_id = msdu_id;
324 		__entry->msdu_len = msdu_len;
325 		__entry->vdev_id = vdev_id;
326 		__entry->tid = tid;
327 	),
328 
329 	TP_printk(
330 		"%s %s msdu_id %d msdu_len %d vdev_id %d tid %d",
331 		__get_str(driver),
332 		__get_str(device),
333 		__entry->msdu_id,
334 		__entry->msdu_len,
335 		__entry->vdev_id,
336 		__entry->tid
337 	 )
338 );
339 
340 TRACE_EVENT(ath10k_txrx_tx_unref,
341 	    TP_PROTO(struct ath10k *ar, u16 msdu_id),
342 
343 	TP_ARGS(ar, msdu_id),
344 
345 	TP_STRUCT__entry(
346 		__string(device, dev_name(ar->dev))
347 		__string(driver, dev_driver_string(ar->dev))
348 		__field(u16, msdu_id)
349 	),
350 
351 	TP_fast_assign(
352 		__assign_str(device, dev_name(ar->dev));
353 		__assign_str(driver, dev_driver_string(ar->dev));
354 		__entry->msdu_id = msdu_id;
355 	),
356 
357 	TP_printk(
358 		"%s %s msdu_id %d",
359 		__get_str(driver),
360 		__get_str(device),
361 		__entry->msdu_id
362 	 )
363 );
364 
365 DECLARE_EVENT_CLASS(ath10k_hdr_event,
366 		    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
367 
368 	TP_ARGS(ar, data, len),
369 
370 	TP_STRUCT__entry(
371 		__string(device, dev_name(ar->dev))
372 		__string(driver, dev_driver_string(ar->dev))
373 		__field(size_t, len)
374 		__dynamic_array(u8, data, ath10k_frm_hdr_len(data, len))
375 	),
376 
377 	TP_fast_assign(
378 		__assign_str(device, dev_name(ar->dev));
379 		__assign_str(driver, dev_driver_string(ar->dev));
380 		__entry->len = ath10k_frm_hdr_len(data, len);
381 		memcpy(__get_dynamic_array(data), data, __entry->len);
382 	),
383 
384 	TP_printk(
385 		"%s %s len %zu\n",
386 		__get_str(driver),
387 		__get_str(device),
388 		__entry->len
389 	)
390 );
391 
392 DECLARE_EVENT_CLASS(ath10k_payload_event,
393 		    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
394 
395 	TP_ARGS(ar, data, len),
396 
397 	TP_STRUCT__entry(
398 		__string(device, dev_name(ar->dev))
399 		__string(driver, dev_driver_string(ar->dev))
400 		__field(size_t, len)
401 		__dynamic_array(u8, payload, (len -
402 					      ath10k_frm_hdr_len(data, len)))
403 	),
404 
405 	TP_fast_assign(
406 		__assign_str(device, dev_name(ar->dev));
407 		__assign_str(driver, dev_driver_string(ar->dev));
408 		__entry->len = len - ath10k_frm_hdr_len(data, len);
409 		memcpy(__get_dynamic_array(payload),
410 		       data + ath10k_frm_hdr_len(data, len), __entry->len);
411 	),
412 
413 	TP_printk(
414 		"%s %s len %zu\n",
415 		__get_str(driver),
416 		__get_str(device),
417 		__entry->len
418 	)
419 );
420 
421 DEFINE_EVENT(ath10k_hdr_event, ath10k_tx_hdr,
422 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
423 	     TP_ARGS(ar, data, len)
424 );
425 
426 DEFINE_EVENT(ath10k_payload_event, ath10k_tx_payload,
427 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
428 	     TP_ARGS(ar, data, len)
429 );
430 
431 DEFINE_EVENT(ath10k_hdr_event, ath10k_rx_hdr,
432 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
433 	     TP_ARGS(ar, data, len)
434 );
435 
436 DEFINE_EVENT(ath10k_payload_event, ath10k_rx_payload,
437 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
438 	     TP_ARGS(ar, data, len)
439 );
440 
441 TRACE_EVENT(ath10k_htt_rx_desc,
442 	    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
443 
444 	TP_ARGS(ar, data, len),
445 
446 	TP_STRUCT__entry(
447 		__string(device, dev_name(ar->dev))
448 		__string(driver, dev_driver_string(ar->dev))
449 		__field(u8, hw_type);
450 		__field(u16, len)
451 		__dynamic_array(u8, rxdesc, len)
452 	),
453 
454 	TP_fast_assign(
455 		__assign_str(device, dev_name(ar->dev));
456 		__assign_str(driver, dev_driver_string(ar->dev));
457 		__entry->hw_type = ar->hw_rev;
458 		__entry->len = len;
459 		memcpy(__get_dynamic_array(rxdesc), data, len);
460 	),
461 
462 	TP_printk(
463 		"%s %s %d rxdesc len %d",
464 		__get_str(driver),
465 		__get_str(device),
466 		__entry->hw_type,
467 		__entry->len
468 	 )
469 );
470 
471 TRACE_EVENT(ath10k_wmi_diag_container,
472 	    TP_PROTO(struct ath10k *ar,
473 		     u8 type,
474 		     u32 timestamp,
475 		     u32 code,
476 		     u16 len,
477 		     const void *data),
478 
479 	TP_ARGS(ar, type, timestamp, code, len, data),
480 
481 	TP_STRUCT__entry(
482 		__string(device, dev_name(ar->dev))
483 		__string(driver, dev_driver_string(ar->dev))
484 		__field(u8, type)
485 		__field(u32, timestamp)
486 		__field(u32, code)
487 		__field(u16, len)
488 		__dynamic_array(u8, data, len)
489 	),
490 
491 	TP_fast_assign(
492 		__assign_str(device, dev_name(ar->dev));
493 		__assign_str(driver, dev_driver_string(ar->dev));
494 		__entry->type = type;
495 		__entry->timestamp = timestamp;
496 		__entry->code = code;
497 		__entry->len = len;
498 		memcpy(__get_dynamic_array(data), data, len);
499 	),
500 
501 	TP_printk(
502 		"%s %s diag container type %hhu timestamp %u code %u len %d",
503 		__get_str(driver),
504 		__get_str(device),
505 		__entry->type,
506 		__entry->timestamp,
507 		__entry->code,
508 		__entry->len
509 	)
510 );
511 
512 TRACE_EVENT(ath10k_wmi_diag,
513 	    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
514 
515 	TP_ARGS(ar, data, len),
516 
517 	TP_STRUCT__entry(
518 		__string(device, dev_name(ar->dev))
519 		__string(driver, dev_driver_string(ar->dev))
520 		__field(u16, len)
521 		__dynamic_array(u8, data, len)
522 	),
523 
524 	TP_fast_assign(
525 		__assign_str(device, dev_name(ar->dev));
526 		__assign_str(driver, dev_driver_string(ar->dev));
527 		__entry->len = len;
528 		memcpy(__get_dynamic_array(data), data, len);
529 	),
530 
531 	TP_printk(
532 		"%s %s tlv diag len %d",
533 		__get_str(driver),
534 		__get_str(device),
535 		__entry->len
536 	)
537 );
538 
539 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
540 
541 /* we don't want to use include/trace/events */
542 #undef TRACE_INCLUDE_PATH
543 #define TRACE_INCLUDE_PATH .
544 #undef TRACE_INCLUDE_FILE
545 #define TRACE_INCLUDE_FILE trace
546 
547 /* This part must be outside protection */
548 #include <trace/define_trace.h>
549