xref: /linux/drivers/net/wireless/ath/ath10k/trace.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
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(size_t, buf_len)
254 		__dynamic_array(u8, buf, buf_len)
255 	),
256 
257 	TP_fast_assign(
258 		__assign_str(device, dev_name(ar->dev));
259 		__assign_str(driver, dev_driver_string(ar->dev));
260 		__entry->buf_len = buf_len;
261 		memcpy(__get_dynamic_array(buf), buf, buf_len);
262 	),
263 
264 	TP_printk(
265 		"%s %s len %zu",
266 		__get_str(driver),
267 		__get_str(device),
268 		__entry->buf_len
269 	)
270 );
271 
272 TRACE_EVENT(ath10k_htt_pktlog,
273 	    TP_PROTO(struct ath10k *ar, const void *buf, u16 buf_len),
274 
275 	TP_ARGS(ar, buf, buf_len),
276 
277 	TP_STRUCT__entry(
278 		__string(device, dev_name(ar->dev))
279 		__string(driver, dev_driver_string(ar->dev))
280 		__field(u16, buf_len)
281 		__dynamic_array(u8, pktlog, buf_len)
282 	),
283 
284 	TP_fast_assign(
285 		__assign_str(device, dev_name(ar->dev));
286 		__assign_str(driver, dev_driver_string(ar->dev));
287 		__entry->buf_len = buf_len;
288 		memcpy(__get_dynamic_array(pktlog), buf, buf_len);
289 	),
290 
291 	TP_printk(
292 		"%s %s size %hu",
293 		__get_str(driver),
294 		__get_str(device),
295 		__entry->buf_len
296 	 )
297 );
298 
299 TRACE_EVENT(ath10k_htt_tx,
300 	    TP_PROTO(struct ath10k *ar, u16 msdu_id, u16 msdu_len,
301 		     u8 vdev_id, u8 tid),
302 
303 	TP_ARGS(ar, msdu_id, msdu_len, vdev_id, tid),
304 
305 	TP_STRUCT__entry(
306 		__string(device, dev_name(ar->dev))
307 		__string(driver, dev_driver_string(ar->dev))
308 		__field(u16, msdu_id)
309 		__field(u16, msdu_len)
310 		__field(u8, vdev_id)
311 		__field(u8, tid)
312 	),
313 
314 	TP_fast_assign(
315 		__assign_str(device, dev_name(ar->dev));
316 		__assign_str(driver, dev_driver_string(ar->dev));
317 		__entry->msdu_id = msdu_id;
318 		__entry->msdu_len = msdu_len;
319 		__entry->vdev_id = vdev_id;
320 		__entry->tid = tid;
321 	),
322 
323 	TP_printk(
324 		"%s %s msdu_id %d msdu_len %d vdev_id %d tid %d",
325 		__get_str(driver),
326 		__get_str(device),
327 		__entry->msdu_id,
328 		__entry->msdu_len,
329 		__entry->vdev_id,
330 		__entry->tid
331 	 )
332 );
333 
334 TRACE_EVENT(ath10k_txrx_tx_unref,
335 	    TP_PROTO(struct ath10k *ar, u16 msdu_id),
336 
337 	TP_ARGS(ar, msdu_id),
338 
339 	TP_STRUCT__entry(
340 		__string(device, dev_name(ar->dev))
341 		__string(driver, dev_driver_string(ar->dev))
342 		__field(u16, msdu_id)
343 	),
344 
345 	TP_fast_assign(
346 		__assign_str(device, dev_name(ar->dev));
347 		__assign_str(driver, dev_driver_string(ar->dev));
348 		__entry->msdu_id = msdu_id;
349 	),
350 
351 	TP_printk(
352 		"%s %s msdu_id %d",
353 		__get_str(driver),
354 		__get_str(device),
355 		__entry->msdu_id
356 	 )
357 );
358 
359 DECLARE_EVENT_CLASS(ath10k_hdr_event,
360 		    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
361 
362 	TP_ARGS(ar, data, len),
363 
364 	TP_STRUCT__entry(
365 		__string(device, dev_name(ar->dev))
366 		__string(driver, dev_driver_string(ar->dev))
367 		__field(size_t, len)
368 		__dynamic_array(u8, data, ath10k_frm_hdr_len(data, len))
369 	),
370 
371 	TP_fast_assign(
372 		__assign_str(device, dev_name(ar->dev));
373 		__assign_str(driver, dev_driver_string(ar->dev));
374 		__entry->len = ath10k_frm_hdr_len(data, len);
375 		memcpy(__get_dynamic_array(data), data, __entry->len);
376 	),
377 
378 	TP_printk(
379 		"%s %s len %zu\n",
380 		__get_str(driver),
381 		__get_str(device),
382 		__entry->len
383 	)
384 );
385 
386 DECLARE_EVENT_CLASS(ath10k_payload_event,
387 		    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
388 
389 	TP_ARGS(ar, data, len),
390 
391 	TP_STRUCT__entry(
392 		__string(device, dev_name(ar->dev))
393 		__string(driver, dev_driver_string(ar->dev))
394 		__field(size_t, len)
395 		__dynamic_array(u8, payload, (len -
396 					      ath10k_frm_hdr_len(data, len)))
397 	),
398 
399 	TP_fast_assign(
400 		__assign_str(device, dev_name(ar->dev));
401 		__assign_str(driver, dev_driver_string(ar->dev));
402 		__entry->len = len - ath10k_frm_hdr_len(data, len);
403 		memcpy(__get_dynamic_array(payload),
404 		       data + ath10k_frm_hdr_len(data, len), __entry->len);
405 	),
406 
407 	TP_printk(
408 		"%s %s len %zu\n",
409 		__get_str(driver),
410 		__get_str(device),
411 		__entry->len
412 	)
413 );
414 
415 DEFINE_EVENT(ath10k_hdr_event, ath10k_tx_hdr,
416 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
417 	     TP_ARGS(ar, data, len)
418 );
419 
420 DEFINE_EVENT(ath10k_payload_event, ath10k_tx_payload,
421 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
422 	     TP_ARGS(ar, data, len)
423 );
424 
425 DEFINE_EVENT(ath10k_hdr_event, ath10k_rx_hdr,
426 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
427 	     TP_ARGS(ar, data, len)
428 );
429 
430 DEFINE_EVENT(ath10k_payload_event, ath10k_rx_payload,
431 	     TP_PROTO(struct ath10k *ar, const void *data, size_t len),
432 	     TP_ARGS(ar, data, len)
433 );
434 
435 TRACE_EVENT(ath10k_htt_rx_desc,
436 	    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
437 
438 	TP_ARGS(ar, data, len),
439 
440 	TP_STRUCT__entry(
441 		__string(device, dev_name(ar->dev))
442 		__string(driver, dev_driver_string(ar->dev))
443 		__field(u16, len)
444 		__dynamic_array(u8, rxdesc, len)
445 	),
446 
447 	TP_fast_assign(
448 		__assign_str(device, dev_name(ar->dev));
449 		__assign_str(driver, dev_driver_string(ar->dev));
450 		__entry->len = len;
451 		memcpy(__get_dynamic_array(rxdesc), data, len);
452 	),
453 
454 	TP_printk(
455 		"%s %s rxdesc len %d",
456 		__get_str(driver),
457 		__get_str(device),
458 		__entry->len
459 	 )
460 );
461 
462 TRACE_EVENT(ath10k_wmi_diag_container,
463 	    TP_PROTO(struct ath10k *ar,
464 		     u8 type,
465 		     u32 timestamp,
466 		     u32 code,
467 		     u16 len,
468 		     const void *data),
469 
470 	TP_ARGS(ar, type, timestamp, code, len, data),
471 
472 	TP_STRUCT__entry(
473 		__string(device, dev_name(ar->dev))
474 		__string(driver, dev_driver_string(ar->dev))
475 		__field(u8, type)
476 		__field(u32, timestamp)
477 		__field(u32, code)
478 		__field(u16, len)
479 		__dynamic_array(u8, data, len)
480 	),
481 
482 	TP_fast_assign(
483 		__assign_str(device, dev_name(ar->dev));
484 		__assign_str(driver, dev_driver_string(ar->dev));
485 		__entry->type = type;
486 		__entry->timestamp = timestamp;
487 		__entry->code = code;
488 		__entry->len = len;
489 		memcpy(__get_dynamic_array(data), data, len);
490 	),
491 
492 	TP_printk(
493 		"%s %s diag container type %hhu timestamp %u code %u len %d",
494 		__get_str(driver),
495 		__get_str(device),
496 		__entry->type,
497 		__entry->timestamp,
498 		__entry->code,
499 		__entry->len
500 	)
501 );
502 
503 TRACE_EVENT(ath10k_wmi_diag,
504 	    TP_PROTO(struct ath10k *ar, const void *data, size_t len),
505 
506 	TP_ARGS(ar, data, len),
507 
508 	TP_STRUCT__entry(
509 		__string(device, dev_name(ar->dev))
510 		__string(driver, dev_driver_string(ar->dev))
511 		__field(u16, len)
512 		__dynamic_array(u8, data, len)
513 	),
514 
515 	TP_fast_assign(
516 		__assign_str(device, dev_name(ar->dev));
517 		__assign_str(driver, dev_driver_string(ar->dev));
518 		__entry->len = len;
519 		memcpy(__get_dynamic_array(data), data, len);
520 	),
521 
522 	TP_printk(
523 		"%s %s tlv diag len %d",
524 		__get_str(driver),
525 		__get_str(device),
526 		__entry->len
527 	)
528 );
529 
530 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
531 
532 /* we don't want to use include/trace/events */
533 #undef TRACE_INCLUDE_PATH
534 #define TRACE_INCLUDE_PATH .
535 #undef TRACE_INCLUDE_FILE
536 #define TRACE_INCLUDE_FILE trace
537 
538 /* This part must be outside protection */
539 #include <trace/define_trace.h>
540