1 /* SPDX-License-Identifier: ISC */
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2016 Qualcomm Atheros, Inc.
7 #if !defined(_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
9 #include <linux/tracepoint.h>
12 #if !defined(_TRACE_H_)
13 static inline u32
ath10k_frm_hdr_len(const void *buf
, size_t len
)
15 const struct ieee80211_hdr
*hdr
= buf
;
17 /* In some rare cases (e.g. fcs error) device reports frame buffer
18 * shorter than what frame header implies (e.g. len = 0). The buffer
19 * can still be accessed so do a simple min() to guarantee caller
20 * doesn't get value greater than len.
22 return min_t(u32
, len
, ieee80211_hdrlen(hdr
->frame_control
));
28 /* create empty functions when tracing is disabled */
29 #if !defined(CONFIG_ATH10K_TRACING)
31 #define TRACE_EVENT(name, proto, ...) \
32 static inline void trace_ ## name(proto) {} \
33 static inline bool trace_##name##_enabled(void) \
37 #undef DECLARE_EVENT_CLASS
38 #define DECLARE_EVENT_CLASS(...)
40 #define DEFINE_EVENT(evt_class, name, proto, ...) \
41 static inline void trace_ ## name(proto) {}
42 #endif /* !CONFIG_ATH10K_TRACING || __CHECKER__ */
45 #define TRACE_SYSTEM ath10k
47 #define ATH10K_MSG_MAX 400
49 DECLARE_EVENT_CLASS(ath10k_log_event
,
50 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
53 __string(device
, dev_name(ar
->dev
))
54 __string(driver
, dev_driver_string(ar
->dev
))
55 __dynamic_array(char, msg
, ATH10K_MSG_MAX
)
58 __assign_str(device
, dev_name(ar
->dev
));
59 __assign_str(driver
, dev_driver_string(ar
->dev
));
60 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg
),
63 *vaf
->va
) >= ATH10K_MSG_MAX
);
73 DEFINE_EVENT(ath10k_log_event
, ath10k_log_err
,
74 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
78 DEFINE_EVENT(ath10k_log_event
, ath10k_log_warn
,
79 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
83 DEFINE_EVENT(ath10k_log_event
, ath10k_log_info
,
84 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
88 TRACE_EVENT(ath10k_log_dbg
,
89 TP_PROTO(struct ath10k
*ar
, unsigned int level
, struct va_format
*vaf
),
90 TP_ARGS(ar
, level
, vaf
),
92 __string(device
, dev_name(ar
->dev
))
93 __string(driver
, dev_driver_string(ar
->dev
))
94 __field(unsigned int, level
)
95 __dynamic_array(char, msg
, ATH10K_MSG_MAX
)
98 __assign_str(device
, dev_name(ar
->dev
));
99 __assign_str(driver
, dev_driver_string(ar
->dev
));
100 __entry
->level
= level
;
101 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg
),
104 *vaf
->va
) >= ATH10K_MSG_MAX
);
114 TRACE_EVENT(ath10k_log_dbg_dump
,
115 TP_PROTO(struct ath10k
*ar
, const char *msg
, const char *prefix
,
116 const void *buf
, size_t buf_len
),
118 TP_ARGS(ar
, msg
, prefix
, buf
, buf_len
),
121 __string(device
, dev_name(ar
->dev
))
122 __string(driver
, dev_driver_string(ar
->dev
))
124 __string(prefix
, prefix
)
125 __field(size_t, buf_len
)
126 __dynamic_array(u8
, buf
, buf_len
)
130 __assign_str(device
, dev_name(ar
->dev
));
131 __assign_str(driver
, dev_driver_string(ar
->dev
));
132 __assign_str(msg
, msg
);
133 __assign_str(prefix
, prefix
);
134 __entry
->buf_len
= buf_len
;
135 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
147 TRACE_EVENT(ath10k_wmi_cmd
,
148 TP_PROTO(struct ath10k
*ar
, int id
, const void *buf
, size_t buf_len
),
150 TP_ARGS(ar
, id
, buf
, buf_len
),
153 __string(device
, dev_name(ar
->dev
))
154 __string(driver
, dev_driver_string(ar
->dev
))
155 __field(unsigned int, id
)
156 __field(size_t, buf_len
)
157 __dynamic_array(u8
, buf
, buf_len
)
161 __assign_str(device
, dev_name(ar
->dev
));
162 __assign_str(driver
, dev_driver_string(ar
->dev
));
164 __entry
->buf_len
= buf_len
;
165 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
169 "%s %s id %d len %zu",
177 TRACE_EVENT(ath10k_wmi_event
,
178 TP_PROTO(struct ath10k
*ar
, int id
, const void *buf
, size_t buf_len
),
180 TP_ARGS(ar
, id
, buf
, buf_len
),
183 __string(device
, dev_name(ar
->dev
))
184 __string(driver
, dev_driver_string(ar
->dev
))
185 __field(unsigned int, id
)
186 __field(size_t, buf_len
)
187 __dynamic_array(u8
, buf
, buf_len
)
191 __assign_str(device
, dev_name(ar
->dev
));
192 __assign_str(driver
, dev_driver_string(ar
->dev
));
194 __entry
->buf_len
= buf_len
;
195 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
199 "%s %s id %d len %zu",
207 TRACE_EVENT(ath10k_htt_stats
,
208 TP_PROTO(struct ath10k
*ar
, const void *buf
, size_t buf_len
),
210 TP_ARGS(ar
, buf
, buf_len
),
213 __string(device
, dev_name(ar
->dev
))
214 __string(driver
, dev_driver_string(ar
->dev
))
215 __field(size_t, buf_len
)
216 __dynamic_array(u8
, buf
, buf_len
)
220 __assign_str(device
, dev_name(ar
->dev
));
221 __assign_str(driver
, dev_driver_string(ar
->dev
));
222 __entry
->buf_len
= buf_len
;
223 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
234 TRACE_EVENT(ath10k_wmi_dbglog
,
235 TP_PROTO(struct ath10k
*ar
, const void *buf
, size_t buf_len
),
237 TP_ARGS(ar
, buf
, buf_len
),
240 __string(device
, dev_name(ar
->dev
))
241 __string(driver
, dev_driver_string(ar
->dev
))
243 __field(size_t, buf_len
)
244 __dynamic_array(u8
, buf
, buf_len
)
248 __assign_str(device
, dev_name(ar
->dev
));
249 __assign_str(driver
, dev_driver_string(ar
->dev
));
250 __entry
->hw_type
= ar
->hw_rev
;
251 __entry
->buf_len
= buf_len
;
252 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
264 TRACE_EVENT(ath10k_htt_pktlog
,
265 TP_PROTO(struct ath10k
*ar
, const void *buf
, u16 buf_len
),
267 TP_ARGS(ar
, buf
, buf_len
),
270 __string(device
, dev_name(ar
->dev
))
271 __string(driver
, dev_driver_string(ar
->dev
))
273 __field(u16
, buf_len
)
274 __dynamic_array(u8
, pktlog
, buf_len
)
278 __assign_str(device
, dev_name(ar
->dev
));
279 __assign_str(driver
, dev_driver_string(ar
->dev
));
280 __entry
->hw_type
= ar
->hw_rev
;
281 __entry
->buf_len
= buf_len
;
282 memcpy(__get_dynamic_array(pktlog
), buf
, buf_len
);
294 TRACE_EVENT(ath10k_htt_tx
,
295 TP_PROTO(struct ath10k
*ar
, u16 msdu_id
, u16 msdu_len
,
298 TP_ARGS(ar
, msdu_id
, msdu_len
, vdev_id
, tid
),
301 __string(device
, dev_name(ar
->dev
))
302 __string(driver
, dev_driver_string(ar
->dev
))
303 __field(u16
, msdu_id
)
304 __field(u16
, msdu_len
)
310 __assign_str(device
, dev_name(ar
->dev
));
311 __assign_str(driver
, dev_driver_string(ar
->dev
));
312 __entry
->msdu_id
= msdu_id
;
313 __entry
->msdu_len
= msdu_len
;
314 __entry
->vdev_id
= vdev_id
;
319 "%s %s msdu_id %d msdu_len %d vdev_id %d tid %d",
329 TRACE_EVENT(ath10k_txrx_tx_unref
,
330 TP_PROTO(struct ath10k
*ar
, u16 msdu_id
),
332 TP_ARGS(ar
, msdu_id
),
335 __string(device
, dev_name(ar
->dev
))
336 __string(driver
, dev_driver_string(ar
->dev
))
337 __field(u16
, msdu_id
)
341 __assign_str(device
, dev_name(ar
->dev
));
342 __assign_str(driver
, dev_driver_string(ar
->dev
));
343 __entry
->msdu_id
= msdu_id
;
354 DECLARE_EVENT_CLASS(ath10k_hdr_event
,
355 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
357 TP_ARGS(ar
, data
, len
),
360 __string(device
, dev_name(ar
->dev
))
361 __string(driver
, dev_driver_string(ar
->dev
))
363 __dynamic_array(u8
, data
, ath10k_frm_hdr_len(data
, len
))
367 __assign_str(device
, dev_name(ar
->dev
));
368 __assign_str(driver
, dev_driver_string(ar
->dev
));
369 __entry
->len
= ath10k_frm_hdr_len(data
, len
);
370 memcpy(__get_dynamic_array(data
), data
, __entry
->len
);
381 DECLARE_EVENT_CLASS(ath10k_payload_event
,
382 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
384 TP_ARGS(ar
, data
, len
),
387 __string(device
, dev_name(ar
->dev
))
388 __string(driver
, dev_driver_string(ar
->dev
))
390 __dynamic_array(u8
, payload
, (len
-
391 ath10k_frm_hdr_len(data
, len
)))
395 __assign_str(device
, dev_name(ar
->dev
));
396 __assign_str(driver
, dev_driver_string(ar
->dev
));
397 __entry
->len
= len
- ath10k_frm_hdr_len(data
, len
);
398 memcpy(__get_dynamic_array(payload
),
399 data
+ ath10k_frm_hdr_len(data
, len
), __entry
->len
);
410 DEFINE_EVENT(ath10k_hdr_event
, ath10k_tx_hdr
,
411 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
412 TP_ARGS(ar
, data
, len
)
415 DEFINE_EVENT(ath10k_payload_event
, ath10k_tx_payload
,
416 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
417 TP_ARGS(ar
, data
, len
)
420 DEFINE_EVENT(ath10k_hdr_event
, ath10k_rx_hdr
,
421 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
422 TP_ARGS(ar
, data
, len
)
425 DEFINE_EVENT(ath10k_payload_event
, ath10k_rx_payload
,
426 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
427 TP_ARGS(ar
, data
, len
)
430 TRACE_EVENT(ath10k_htt_rx_desc
,
431 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
433 TP_ARGS(ar
, data
, len
),
436 __string(device
, dev_name(ar
->dev
))
437 __string(driver
, dev_driver_string(ar
->dev
))
440 __dynamic_array(u8
, rxdesc
, len
)
444 __assign_str(device
, dev_name(ar
->dev
));
445 __assign_str(driver
, dev_driver_string(ar
->dev
));
446 __entry
->hw_type
= ar
->hw_rev
;
448 memcpy(__get_dynamic_array(rxdesc
), data
, len
);
452 "%s %s %d rxdesc len %d",
460 TRACE_EVENT(ath10k_wmi_diag_container
,
461 TP_PROTO(struct ath10k
*ar
,
468 TP_ARGS(ar
, type
, timestamp
, code
, len
, data
),
471 __string(device
, dev_name(ar
->dev
))
472 __string(driver
, dev_driver_string(ar
->dev
))
474 __field(u32
, timestamp
)
477 __dynamic_array(u8
, data
, len
)
481 __assign_str(device
, dev_name(ar
->dev
));
482 __assign_str(driver
, dev_driver_string(ar
->dev
));
483 __entry
->type
= type
;
484 __entry
->timestamp
= timestamp
;
485 __entry
->code
= code
;
487 memcpy(__get_dynamic_array(data
), data
, len
);
491 "%s %s diag container type %hhu timestamp %u code %u len %d",
501 TRACE_EVENT(ath10k_wmi_diag
,
502 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
504 TP_ARGS(ar
, data
, len
),
507 __string(device
, dev_name(ar
->dev
))
508 __string(driver
, dev_driver_string(ar
->dev
))
510 __dynamic_array(u8
, data
, len
)
514 __assign_str(device
, dev_name(ar
->dev
));
515 __assign_str(driver
, dev_driver_string(ar
->dev
));
517 memcpy(__get_dynamic_array(data
), data
, len
);
521 "%s %s tlv diag len %d",
528 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
530 /* we don't want to use include/trace/events */
531 #undef TRACE_INCLUDE_PATH
532 #define TRACE_INCLUDE_PATH .
533 #undef TRACE_INCLUDE_FILE
534 #define TRACE_INCLUDE_FILE trace
536 /* This part must be outside protection */
537 #include <trace/define_trace.h>