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 __vstring(msg
, vaf
->fmt
, vaf
->va
)
60 __assign_vstr(msg
, vaf
->fmt
, vaf
->va
);
70 DEFINE_EVENT(ath10k_log_event
, ath10k_log_err
,
71 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
75 DEFINE_EVENT(ath10k_log_event
, ath10k_log_warn
,
76 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
80 DEFINE_EVENT(ath10k_log_event
, ath10k_log_info
,
81 TP_PROTO(struct ath10k
*ar
, struct va_format
*vaf
),
85 TRACE_EVENT(ath10k_log_dbg
,
86 TP_PROTO(struct ath10k
*ar
, unsigned int level
, struct va_format
*vaf
),
87 TP_ARGS(ar
, level
, vaf
),
89 __string(device
, dev_name(ar
->dev
))
90 __string(driver
, dev_driver_string(ar
->dev
))
91 __field(unsigned int, level
)
92 __vstring(msg
, vaf
->fmt
, vaf
->va
)
97 __entry
->level
= level
;
98 __assign_vstr(msg
, vaf
->fmt
, vaf
->va
);
108 TRACE_EVENT(ath10k_log_dbg_dump
,
109 TP_PROTO(struct ath10k
*ar
, const char *msg
, const char *prefix
,
110 const void *buf
, size_t buf_len
),
112 TP_ARGS(ar
, msg
, prefix
, buf
, buf_len
),
115 __string(device
, dev_name(ar
->dev
))
116 __string(driver
, dev_driver_string(ar
->dev
))
118 __string(prefix
, prefix
)
119 __field(size_t, buf_len
)
120 __dynamic_array(u8
, buf
, buf_len
)
124 __assign_str(device
);
125 __assign_str(driver
);
127 __assign_str(prefix
);
128 __entry
->buf_len
= buf_len
;
129 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
141 TRACE_EVENT(ath10k_wmi_cmd
,
142 TP_PROTO(struct ath10k
*ar
, int id
, const void *buf
, size_t buf_len
),
144 TP_ARGS(ar
, id
, buf
, buf_len
),
147 __string(device
, dev_name(ar
->dev
))
148 __string(driver
, dev_driver_string(ar
->dev
))
149 __field(unsigned int, id
)
150 __field(size_t, buf_len
)
151 __dynamic_array(u8
, buf
, buf_len
)
155 __assign_str(device
);
156 __assign_str(driver
);
158 __entry
->buf_len
= buf_len
;
159 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
163 "%s %s id %d len %zu",
171 TRACE_EVENT(ath10k_wmi_event
,
172 TP_PROTO(struct ath10k
*ar
, int id
, const void *buf
, size_t buf_len
),
174 TP_ARGS(ar
, id
, buf
, buf_len
),
177 __string(device
, dev_name(ar
->dev
))
178 __string(driver
, dev_driver_string(ar
->dev
))
179 __field(unsigned int, id
)
180 __field(size_t, buf_len
)
181 __dynamic_array(u8
, buf
, buf_len
)
185 __assign_str(device
);
186 __assign_str(driver
);
188 __entry
->buf_len
= buf_len
;
189 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
193 "%s %s id %d len %zu",
201 TRACE_EVENT(ath10k_htt_stats
,
202 TP_PROTO(struct ath10k
*ar
, const void *buf
, size_t buf_len
),
204 TP_ARGS(ar
, buf
, buf_len
),
207 __string(device
, dev_name(ar
->dev
))
208 __string(driver
, dev_driver_string(ar
->dev
))
209 __field(size_t, buf_len
)
210 __dynamic_array(u8
, buf
, buf_len
)
214 __assign_str(device
);
215 __assign_str(driver
);
216 __entry
->buf_len
= buf_len
;
217 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
228 TRACE_EVENT(ath10k_wmi_dbglog
,
229 TP_PROTO(struct ath10k
*ar
, const void *buf
, size_t buf_len
),
231 TP_ARGS(ar
, buf
, buf_len
),
234 __string(device
, dev_name(ar
->dev
))
235 __string(driver
, dev_driver_string(ar
->dev
))
237 __field(size_t, buf_len
)
238 __dynamic_array(u8
, buf
, buf_len
)
242 __assign_str(device
);
243 __assign_str(driver
);
244 __entry
->hw_type
= ar
->hw_rev
;
245 __entry
->buf_len
= buf_len
;
246 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
258 TRACE_EVENT(ath10k_htt_pktlog
,
259 TP_PROTO(struct ath10k
*ar
, const void *buf
, u16 buf_len
),
261 TP_ARGS(ar
, buf
, buf_len
),
264 __string(device
, dev_name(ar
->dev
))
265 __string(driver
, dev_driver_string(ar
->dev
))
267 __field(u16
, buf_len
)
268 __dynamic_array(u8
, pktlog
, buf_len
)
272 __assign_str(device
);
273 __assign_str(driver
);
274 __entry
->hw_type
= ar
->hw_rev
;
275 __entry
->buf_len
= buf_len
;
276 memcpy(__get_dynamic_array(pktlog
), buf
, buf_len
);
288 TRACE_EVENT(ath10k_htt_tx
,
289 TP_PROTO(struct ath10k
*ar
, u16 msdu_id
, u16 msdu_len
,
292 TP_ARGS(ar
, msdu_id
, msdu_len
, vdev_id
, tid
),
295 __string(device
, dev_name(ar
->dev
))
296 __string(driver
, dev_driver_string(ar
->dev
))
297 __field(u16
, msdu_id
)
298 __field(u16
, msdu_len
)
304 __assign_str(device
);
305 __assign_str(driver
);
306 __entry
->msdu_id
= msdu_id
;
307 __entry
->msdu_len
= msdu_len
;
308 __entry
->vdev_id
= vdev_id
;
313 "%s %s msdu_id %d msdu_len %d vdev_id %d tid %d",
323 TRACE_EVENT(ath10k_txrx_tx_unref
,
324 TP_PROTO(struct ath10k
*ar
, u16 msdu_id
),
326 TP_ARGS(ar
, msdu_id
),
329 __string(device
, dev_name(ar
->dev
))
330 __string(driver
, dev_driver_string(ar
->dev
))
331 __field(u16
, msdu_id
)
335 __assign_str(device
);
336 __assign_str(driver
);
337 __entry
->msdu_id
= msdu_id
;
348 DECLARE_EVENT_CLASS(ath10k_hdr_event
,
349 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
351 TP_ARGS(ar
, data
, len
),
354 __string(device
, dev_name(ar
->dev
))
355 __string(driver
, dev_driver_string(ar
->dev
))
357 __dynamic_array(u8
, data
, ath10k_frm_hdr_len(data
, len
))
361 __assign_str(device
);
362 __assign_str(driver
);
363 __entry
->len
= ath10k_frm_hdr_len(data
, len
);
364 memcpy(__get_dynamic_array(data
), data
, __entry
->len
);
375 DECLARE_EVENT_CLASS(ath10k_payload_event
,
376 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
378 TP_ARGS(ar
, data
, len
),
381 __string(device
, dev_name(ar
->dev
))
382 __string(driver
, dev_driver_string(ar
->dev
))
384 __dynamic_array(u8
, payload
, (len
-
385 ath10k_frm_hdr_len(data
, len
)))
389 __assign_str(device
);
390 __assign_str(driver
);
391 __entry
->len
= len
- ath10k_frm_hdr_len(data
, len
);
392 memcpy(__get_dynamic_array(payload
),
393 data
+ ath10k_frm_hdr_len(data
, len
), __entry
->len
);
404 DEFINE_EVENT(ath10k_hdr_event
, ath10k_tx_hdr
,
405 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
406 TP_ARGS(ar
, data
, len
)
409 DEFINE_EVENT(ath10k_payload_event
, ath10k_tx_payload
,
410 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
411 TP_ARGS(ar
, data
, len
)
414 DEFINE_EVENT(ath10k_hdr_event
, ath10k_rx_hdr
,
415 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
416 TP_ARGS(ar
, data
, len
)
419 DEFINE_EVENT(ath10k_payload_event
, ath10k_rx_payload
,
420 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
421 TP_ARGS(ar
, data
, len
)
424 TRACE_EVENT(ath10k_htt_rx_desc
,
425 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
427 TP_ARGS(ar
, data
, len
),
430 __string(device
, dev_name(ar
->dev
))
431 __string(driver
, dev_driver_string(ar
->dev
))
434 __dynamic_array(u8
, rxdesc
, len
)
438 __assign_str(device
);
439 __assign_str(driver
);
440 __entry
->hw_type
= ar
->hw_rev
;
442 memcpy(__get_dynamic_array(rxdesc
), data
, len
);
446 "%s %s %d rxdesc len %d",
454 TRACE_EVENT(ath10k_wmi_diag_container
,
455 TP_PROTO(struct ath10k
*ar
,
462 TP_ARGS(ar
, type
, timestamp
, code
, len
, data
),
465 __string(device
, dev_name(ar
->dev
))
466 __string(driver
, dev_driver_string(ar
->dev
))
468 __field(u32
, timestamp
)
471 __dynamic_array(u8
, data
, len
)
475 __assign_str(device
);
476 __assign_str(driver
);
477 __entry
->type
= type
;
478 __entry
->timestamp
= timestamp
;
479 __entry
->code
= code
;
481 memcpy(__get_dynamic_array(data
), data
, len
);
485 "%s %s diag container type %u timestamp %u code %u len %d",
495 TRACE_EVENT(ath10k_wmi_diag
,
496 TP_PROTO(struct ath10k
*ar
, const void *data
, size_t len
),
498 TP_ARGS(ar
, data
, len
),
501 __string(device
, dev_name(ar
->dev
))
502 __string(driver
, dev_driver_string(ar
->dev
))
504 __dynamic_array(u8
, data
, len
)
508 __assign_str(device
);
509 __assign_str(driver
);
511 memcpy(__get_dynamic_array(data
), data
, len
);
515 "%s %s tlv diag len %d",
522 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
524 /* we don't want to use include/trace/events */
525 #undef TRACE_INCLUDE_PATH
526 #define TRACE_INCLUDE_PATH .
527 #undef TRACE_INCLUDE_FILE
528 #define TRACE_INCLUDE_FILE trace
530 /* This part must be outside protection */
531 #include <trace/define_trace.h>