1 /* SPDX-License-Identifier: ISC */
2 #if !defined(_ATH6KL_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
4 #include <net/cfg80211.h>
5 #include <linux/skbuff.h>
6 #include <linux/tracepoint.h>
10 #if !defined(_ATH6KL_TRACE_H)
11 static inline unsigned int ath6kl_get_wmi_id(void *buf
, size_t buf_len
)
13 struct wmi_cmd_hdr
*hdr
= buf
;
15 if (buf_len
< sizeof(*hdr
))
18 return le16_to_cpu(hdr
->cmd_id
);
20 #endif /* __ATH6KL_TRACE_H */
22 #define _ATH6KL_TRACE_H
24 /* create empty functions when tracing is disabled */
25 #if !defined(CONFIG_ATH6KL_TRACING)
27 #define TRACE_EVENT(name, proto, ...) \
28 static inline void trace_ ## name(proto) {}
29 #undef DECLARE_EVENT_CLASS
30 #define DECLARE_EVENT_CLASS(...)
32 #define DEFINE_EVENT(evt_class, name, proto, ...) \
33 static inline void trace_ ## name(proto) {}
34 #endif /* !CONFIG_ATH6KL_TRACING || __CHECKER__ */
37 #define TRACE_SYSTEM ath6kl
39 TRACE_EVENT(ath6kl_wmi_cmd
,
40 TP_PROTO(void *buf
, size_t buf_len
),
42 TP_ARGS(buf
, buf_len
),
45 __field(unsigned int, id
)
46 __field(size_t, buf_len
)
47 __dynamic_array(u8
, buf
, buf_len
)
51 __entry
->id
= ath6kl_get_wmi_id(buf
, buf_len
);
52 __entry
->buf_len
= buf_len
;
53 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
58 __entry
->id
, __entry
->buf_len
62 TRACE_EVENT(ath6kl_wmi_event
,
63 TP_PROTO(void *buf
, size_t buf_len
),
65 TP_ARGS(buf
, buf_len
),
68 __field(unsigned int, id
)
69 __field(size_t, buf_len
)
70 __dynamic_array(u8
, buf
, buf_len
)
74 __entry
->id
= ath6kl_get_wmi_id(buf
, buf_len
);
75 __entry
->buf_len
= buf_len
;
76 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
81 __entry
->id
, __entry
->buf_len
85 TRACE_EVENT(ath6kl_sdio
,
86 TP_PROTO(unsigned int addr
, int flags
,
87 void *buf
, size_t buf_len
),
89 TP_ARGS(addr
, flags
, buf
, buf_len
),
92 __field(unsigned int, tx
)
93 __field(unsigned int, addr
)
95 __field(size_t, buf_len
)
96 __dynamic_array(u8
, buf
, buf_len
)
100 __entry
->addr
= addr
;
101 __entry
->flags
= flags
;
102 __entry
->buf_len
= buf_len
;
103 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
105 if (flags
& HIF_WRITE
)
112 "%s addr 0x%x flags 0x%x len %zd\n",
113 __entry
->tx
? "tx" : "rx",
120 TRACE_EVENT(ath6kl_sdio_scat
,
121 TP_PROTO(unsigned int addr
, int flags
, unsigned int total_len
,
122 unsigned int entries
, struct hif_scatter_item
*list
),
124 TP_ARGS(addr
, flags
, total_len
, entries
, list
),
127 __field(unsigned int, tx
)
128 __field(unsigned int, addr
)
130 __field(unsigned int, entries
)
131 __field(size_t, total_len
)
132 __dynamic_array(unsigned int, len_array
, entries
)
133 __dynamic_array(u8
, data
, total_len
)
137 unsigned int *len_array
;
141 __entry
->addr
= addr
;
142 __entry
->flags
= flags
;
143 __entry
->entries
= entries
;
144 __entry
->total_len
= total_len
;
146 if (flags
& HIF_WRITE
)
151 len_array
= __get_dynamic_array(len_array
);
153 for (i
= 0; i
< entries
; i
++) {
156 memcpy((u8
*) __get_dynamic_array(data
) + offset
,
165 "%s addr 0x%x flags 0x%x entries %d total_len %zd\n",
166 __entry
->tx
? "tx" : "rx",
174 TRACE_EVENT(ath6kl_sdio_irq
,
175 TP_PROTO(void *buf
, size_t buf_len
),
177 TP_ARGS(buf
, buf_len
),
180 __field(size_t, buf_len
)
181 __dynamic_array(u8
, buf
, buf_len
)
185 __entry
->buf_len
= buf_len
;
186 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
190 "irq len %zd\n", __entry
->buf_len
194 TRACE_EVENT(ath6kl_htc_rx
,
195 TP_PROTO(int status
, int endpoint
, void *buf
,
198 TP_ARGS(status
, endpoint
, buf
, buf_len
),
202 __field(int, endpoint
)
203 __field(size_t, buf_len
)
204 __dynamic_array(u8
, buf
, buf_len
)
208 __entry
->status
= status
;
209 __entry
->endpoint
= endpoint
;
210 __entry
->buf_len
= buf_len
;
211 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
215 "status %d endpoint %d len %zd\n",
222 TRACE_EVENT(ath6kl_htc_tx
,
223 TP_PROTO(int status
, int endpoint
, void *buf
,
226 TP_ARGS(status
, endpoint
, buf
, buf_len
),
230 __field(int, endpoint
)
231 __field(size_t, buf_len
)
232 __dynamic_array(u8
, buf
, buf_len
)
236 __entry
->status
= status
;
237 __entry
->endpoint
= endpoint
;
238 __entry
->buf_len
= buf_len
;
239 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
243 "status %d endpoint %d len %zd\n",
250 #define ATH6KL_MSG_MAX 200
252 DECLARE_EVENT_CLASS(ath6kl_log_event
,
253 TP_PROTO(struct va_format
*vaf
),
256 __dynamic_array(char, msg
, ATH6KL_MSG_MAX
)
259 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg
),
262 *vaf
->va
) >= ATH6KL_MSG_MAX
);
264 TP_printk("%s", __get_str(msg
))
267 DEFINE_EVENT(ath6kl_log_event
, ath6kl_log_err
,
268 TP_PROTO(struct va_format
*vaf
),
272 DEFINE_EVENT(ath6kl_log_event
, ath6kl_log_warn
,
273 TP_PROTO(struct va_format
*vaf
),
277 DEFINE_EVENT(ath6kl_log_event
, ath6kl_log_info
,
278 TP_PROTO(struct va_format
*vaf
),
282 TRACE_EVENT(ath6kl_log_dbg
,
283 TP_PROTO(unsigned int level
, struct va_format
*vaf
),
286 __field(unsigned int, level
)
287 __dynamic_array(char, msg
, ATH6KL_MSG_MAX
)
290 __entry
->level
= level
;
291 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg
),
294 *vaf
->va
) >= ATH6KL_MSG_MAX
);
296 TP_printk("%s", __get_str(msg
))
299 TRACE_EVENT(ath6kl_log_dbg_dump
,
300 TP_PROTO(const char *msg
, const char *prefix
,
301 const void *buf
, size_t buf_len
),
303 TP_ARGS(msg
, prefix
, buf
, buf_len
),
307 __string(prefix
, prefix
)
308 __field(size_t, buf_len
)
309 __dynamic_array(u8
, buf
, buf_len
)
313 __assign_str(msg
, msg
);
314 __assign_str(prefix
, prefix
);
315 __entry
->buf_len
= buf_len
;
316 memcpy(__get_dynamic_array(buf
), buf
, buf_len
);
320 "%s/%s\n", __get_str(prefix
), __get_str(msg
)
324 #endif /* _ ATH6KL_TRACE_H || TRACE_HEADER_MULTI_READ*/
326 /* we don't want to use include/trace/events */
327 #undef TRACE_INCLUDE_PATH
328 #define TRACE_INCLUDE_PATH .
329 #undef TRACE_INCLUDE_FILE
330 #define TRACE_INCLUDE_FILE trace
332 /* This part must be outside protection */
333 #include <trace/define_trace.h>