2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
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.
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.
18 #if !defined(_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
20 #include <linux/tracepoint.h>
23 #if !defined(_TRACE_H_)
24 static inline u32
ath10k_frm_hdr_len(const void *buf
, size_t len
)
26 const struct ieee80211_hdr
*hdr
= buf
;
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.
33 return min_t(u32
, len
, ieee80211_hdrlen(hdr
->frame_control
));
39 /* create empty functions when tracing is disabled */
40 #if !defined(CONFIG_ATH10K_TRACING)
42 #define TRACE_EVENT(name, proto, ...) \
43 static inline void trace_ ## name(proto) {}
44 #undef DECLARE_EVENT_CLASS
45 #define DECLARE_EVENT_CLASS(...)
47 #define DEFINE_EVENT(evt_class, name, proto, ...) \
48 static inline void trace_ ## name(proto) {}
49 #endif /* !CONFIG_ATH10K_TRACING || __CHECKER__ */
52 #define TRACE_SYSTEM ath10k
54 #define ATH10K_MSG_MAX 400
56 DECLARE_EVENT_CLASS(ath10k_log_event
,
57 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
60 __string(device
, dev_name(ar
->dev
))
61 __string(driver
, dev_driver_string(ar
->dev
))
62 __dynamic_array(char, msg
, ATH10K_MSG_MAX
)
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
),
70 *vaf
->va
) >= ATH10K_MSG_MAX
);
80 DEFINE_EVENT(ath10k_log_event
, ath10k_log_err
,
81 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
85 DEFINE_EVENT(ath10k_log_event
, ath10k_log_warn
,
86 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
90 DEFINE_EVENT(ath10k_log_event
, ath10k_log_info
,
91 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
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
),
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
)
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
),
111 *vaf
->va
) >= ATH10K_MSG_MAX
);
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
),
125 TP_ARGS(ar
, msg
, prefix
, buf
, buf_len
),
128 __string(device
, dev_name(ar
->dev
))
129 __string(driver
, dev_driver_string(ar
->dev
))
131 __string(prefix
, prefix
)
132 __field(size_t, buf_len
)
133 __dynamic_array(u8
, buf
, buf_len
)
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
);
154 TRACE_EVENT(ath10k_wmi_cmd
,
155 TP_PROTO(struct ath10k
*ar
, int id
, const void *buf
, size_t buf_len
,
158 TP_ARGS(ar
, id
, buf
, buf_len
, ret
),
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
)
170 __assign_str(device
, dev_name(ar
->dev
));
171 __assign_str(driver
, dev_driver_string(ar
->dev
));
173 __entry
->buf_len
= buf_len
;
175 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
179 "%s %s id %d len %zu ret %d",
188 TRACE_EVENT(ath10k_wmi_event
,
189 TP_PROTO(struct ath10k
*ar
, int id
, const void *buf
, size_t buf_len
),
191 TP_ARGS(ar
, id
, buf
, buf_len
),
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
)
202 __assign_str(device
, dev_name(ar
->dev
));
203 __assign_str(driver
, dev_driver_string(ar
->dev
));
205 __entry
->buf_len
= buf_len
;
206 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
210 "%s %s id %d len %zu",
218 TRACE_EVENT(ath10k_htt_stats
,
219 TP_PROTO(struct ath10k
*ar
, const void *buf
, size_t buf_len
),
221 TP_ARGS(ar
, buf
, buf_len
),
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
)
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
);
245 TRACE_EVENT(ath10k_wmi_dbglog
,
246 TP_PROTO(struct ath10k
*ar
, const void *buf
, size_t buf_len
),
248 TP_ARGS(ar
, buf
, buf_len
),
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
)
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
);
272 TRACE_EVENT(ath10k_htt_pktlog
,
273 TP_PROTO(struct ath10k
*ar
, const void *buf
, u16 buf_len
),
275 TP_ARGS(ar
, buf
, buf_len
),
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
)
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
);
299 TRACE_EVENT(ath10k_htt_tx
,
300 TP_PROTO(struct ath10k
*ar
, u16 msdu_id
, u16 msdu_len
,
303 TP_ARGS(ar
, msdu_id
, msdu_len
, vdev_id
, tid
),
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
)
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
;
324 "%s %s msdu_id %d msdu_len %d vdev_id %d tid %d",
334 TRACE_EVENT(ath10k_txrx_tx_unref
,
335 TP_PROTO(struct ath10k
*ar
, u16 msdu_id
),
337 TP_ARGS(ar
, msdu_id
),
340 __string(device
, dev_name(ar
->dev
))
341 __string(driver
, dev_driver_string(ar
->dev
))
342 __field(u16
, msdu_id
)
346 __assign_str(device
, dev_name(ar
->dev
));
347 __assign_str(driver
, dev_driver_string(ar
->dev
));
348 __entry
->msdu_id
= msdu_id
;
359 DECLARE_EVENT_CLASS(ath10k_hdr_event
,
360 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
362 TP_ARGS(ar
, data
, len
),
365 __string(device
, dev_name(ar
->dev
))
366 __string(driver
, dev_driver_string(ar
->dev
))
368 __dynamic_array(u8
, data
, ath10k_frm_hdr_len(data
, len
))
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
);
386 DECLARE_EVENT_CLASS(ath10k_payload_event
,
387 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
389 TP_ARGS(ar
, data
, len
),
392 __string(device
, dev_name(ar
->dev
))
393 __string(driver
, dev_driver_string(ar
->dev
))
395 __dynamic_array(u8
, payload
, (len
-
396 ath10k_frm_hdr_len(data
, len
)))
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
);
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
)
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
)
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
)
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
)
435 TRACE_EVENT(ath10k_htt_rx_desc
,
436 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
438 TP_ARGS(ar
, data
, len
),
441 __string(device
, dev_name(ar
->dev
))
442 __string(driver
, dev_driver_string(ar
->dev
))
444 __dynamic_array(u8
, rxdesc
, len
)
448 __assign_str(device
, dev_name(ar
->dev
));
449 __assign_str(driver
, dev_driver_string(ar
->dev
));
451 memcpy(__get_dynamic_array(rxdesc
), data
, len
);
455 "%s %s rxdesc len %d",
462 TRACE_EVENT(ath10k_wmi_diag_container
,
463 TP_PROTO(struct ath10k
*ar
,
470 TP_ARGS(ar
, type
, timestamp
, code
, len
, data
),
473 __string(device
, dev_name(ar
->dev
))
474 __string(driver
, dev_driver_string(ar
->dev
))
476 __field(u32
, timestamp
)
479 __dynamic_array(u8
, data
, len
)
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
;
489 memcpy(__get_dynamic_array(data
), data
, len
);
493 "%s %s diag container type %hhu timestamp %u code %u len %d",
503 TRACE_EVENT(ath10k_wmi_diag
,
504 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
506 TP_ARGS(ar
, data
, len
),
509 __string(device
, dev_name(ar
->dev
))
510 __string(driver
, dev_driver_string(ar
->dev
))
512 __dynamic_array(u8
, data
, len
)
516 __assign_str(device
, dev_name(ar
->dev
));
517 __assign_str(driver
, dev_driver_string(ar
->dev
));
519 memcpy(__get_dynamic_array(data
), data
, len
);
523 "%s %s tlv diag len %d",
530 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
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
538 /* This part must be outside protection */
539 #include <trace/define_trace.h>