1#if !defined(_ATH6KL_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
2
3#include <net/cfg80211.h>
4#include <linux/skbuff.h>
5#include <linux/tracepoint.h>
6#include "wmi.h"
7#include "hif.h"
8
9#if !defined(_ATH6KL_TRACE_H)
10static inline unsigned int ath6kl_get_wmi_id(void *buf, size_t buf_len)
11{
12	struct wmi_cmd_hdr *hdr = buf;
13
14	if (buf_len < sizeof(*hdr))
15		return 0;
16
17	return le16_to_cpu(hdr->cmd_id);
18}
19#endif /* __ATH6KL_TRACE_H */
20
21#define _ATH6KL_TRACE_H
22
23/* create empty functions when tracing is disabled */
24#if !defined(CONFIG_ATH6KL_TRACING)
25#undef TRACE_EVENT
26#define TRACE_EVENT(name, proto, ...) \
27static inline void trace_ ## name(proto) {}
28#undef DECLARE_EVENT_CLASS
29#define DECLARE_EVENT_CLASS(...)
30#undef DEFINE_EVENT
31#define DEFINE_EVENT(evt_class, name, proto, ...) \
32static inline void trace_ ## name(proto) {}
33#endif /* !CONFIG_ATH6KL_TRACING || __CHECKER__ */
34
35#undef TRACE_SYSTEM
36#define TRACE_SYSTEM ath6kl
37
38TRACE_EVENT(ath6kl_wmi_cmd,
39	TP_PROTO(void *buf, size_t buf_len),
40
41	TP_ARGS(buf, buf_len),
42
43	TP_STRUCT__entry(
44		__field(unsigned int, id)
45		__field(size_t, buf_len)
46		__dynamic_array(u8, buf, buf_len)
47	),
48
49	TP_fast_assign(
50		__entry->id = ath6kl_get_wmi_id(buf, buf_len);
51		__entry->buf_len = buf_len;
52		memcpy(__get_dynamic_array(buf), buf, buf_len);
53	),
54
55	TP_printk(
56		"id %d len %zd",
57		__entry->id, __entry->buf_len
58	)
59);
60
61TRACE_EVENT(ath6kl_wmi_event,
62	TP_PROTO(void *buf, size_t buf_len),
63
64	TP_ARGS(buf, buf_len),
65
66	TP_STRUCT__entry(
67		__field(unsigned int, id)
68		__field(size_t, buf_len)
69		__dynamic_array(u8, buf, buf_len)
70	),
71
72	TP_fast_assign(
73		__entry->id = ath6kl_get_wmi_id(buf, buf_len);
74		__entry->buf_len = buf_len;
75		memcpy(__get_dynamic_array(buf), buf, buf_len);
76	),
77
78	TP_printk(
79		"id %d len %zd",
80		__entry->id, __entry->buf_len
81	)
82);
83
84TRACE_EVENT(ath6kl_sdio,
85	TP_PROTO(unsigned int addr, int flags,
86		 void *buf, size_t buf_len),
87
88	TP_ARGS(addr, flags, buf, buf_len),
89
90	TP_STRUCT__entry(
91		__field(unsigned int, tx)
92		__field(unsigned int, addr)
93		__field(int, flags)
94		__field(size_t, buf_len)
95		__dynamic_array(u8, buf, buf_len)
96	),
97
98	TP_fast_assign(
99		__entry->addr = addr;
100		__entry->flags = flags;
101		__entry->buf_len = buf_len;
102		memcpy(__get_dynamic_array(buf), buf, buf_len);
103
104		if (flags & HIF_WRITE)
105			__entry->tx = 1;
106		else
107			__entry->tx = 0;
108	),
109
110	TP_printk(
111		"%s addr 0x%x flags 0x%x len %zd\n",
112		__entry->tx ? "tx" : "rx",
113		__entry->addr,
114		__entry->flags,
115		__entry->buf_len
116	)
117);
118
119TRACE_EVENT(ath6kl_sdio_scat,
120	TP_PROTO(unsigned int addr, int flags, unsigned int total_len,
121		 unsigned int entries, struct hif_scatter_item *list),
122
123	TP_ARGS(addr, flags, total_len, entries, list),
124
125	TP_STRUCT__entry(
126		__field(unsigned int, tx)
127		__field(unsigned int, addr)
128		__field(int, flags)
129		__field(unsigned int, entries)
130		__field(size_t, total_len)
131		__dynamic_array(unsigned int, len_array, entries)
132		__dynamic_array(u8, data, total_len)
133	),
134
135	TP_fast_assign(
136		unsigned int *len_array;
137		int i, offset = 0;
138		size_t len;
139
140		__entry->addr = addr;
141		__entry->flags = flags;
142		__entry->entries = entries;
143		__entry->total_len = total_len;
144
145		if (flags & HIF_WRITE)
146			__entry->tx = 1;
147		else
148			__entry->tx = 0;
149
150		len_array = __get_dynamic_array(len_array);
151
152		for (i = 0; i < entries; i++) {
153			len = list[i].len;
154
155			memcpy((u8 *) __get_dynamic_array(data) + offset,
156			       list[i].buf, len);
157
158			len_array[i] = len;
159			offset += len;
160		}
161	),
162
163	TP_printk(
164		"%s addr 0x%x flags 0x%x entries %d total_len %zd\n",
165		__entry->tx ? "tx" : "rx",
166		__entry->addr,
167		__entry->flags,
168		__entry->entries,
169		__entry->total_len
170	)
171);
172
173TRACE_EVENT(ath6kl_sdio_irq,
174	TP_PROTO(void *buf, size_t buf_len),
175
176	TP_ARGS(buf, buf_len),
177
178	TP_STRUCT__entry(
179		__field(size_t, buf_len)
180		__dynamic_array(u8, buf, buf_len)
181	),
182
183	TP_fast_assign(
184		__entry->buf_len = buf_len;
185		memcpy(__get_dynamic_array(buf), buf, buf_len);
186	),
187
188	TP_printk(
189		"irq len %zd\n", __entry->buf_len
190	)
191);
192
193TRACE_EVENT(ath6kl_htc_rx,
194	TP_PROTO(int status, int endpoint, void *buf,
195		 size_t buf_len),
196
197	TP_ARGS(status, endpoint, buf, buf_len),
198
199	TP_STRUCT__entry(
200		__field(int, status)
201		__field(int, endpoint)
202		__field(size_t, buf_len)
203		__dynamic_array(u8, buf, buf_len)
204	),
205
206	TP_fast_assign(
207		__entry->status = status;
208		__entry->endpoint = endpoint;
209		__entry->buf_len = buf_len;
210		memcpy(__get_dynamic_array(buf), buf, buf_len);
211	),
212
213	TP_printk(
214		"status %d endpoint %d len %zd\n",
215		__entry->status,
216		__entry->endpoint,
217		__entry->buf_len
218	)
219);
220
221TRACE_EVENT(ath6kl_htc_tx,
222	TP_PROTO(int status, int endpoint, void *buf,
223		 size_t buf_len),
224
225	TP_ARGS(status, endpoint, buf, buf_len),
226
227	TP_STRUCT__entry(
228		__field(int, status)
229		__field(int, endpoint)
230		__field(size_t, buf_len)
231		__dynamic_array(u8, buf, buf_len)
232	),
233
234	TP_fast_assign(
235		__entry->status = status;
236		__entry->endpoint = endpoint;
237		__entry->buf_len = buf_len;
238		memcpy(__get_dynamic_array(buf), buf, buf_len);
239	),
240
241	TP_printk(
242		"status %d endpoint %d len %zd\n",
243		__entry->status,
244		__entry->endpoint,
245		__entry->buf_len
246	)
247);
248
249#define ATH6KL_MSG_MAX 200
250
251DECLARE_EVENT_CLASS(ath6kl_log_event,
252	TP_PROTO(struct va_format *vaf),
253	TP_ARGS(vaf),
254	TP_STRUCT__entry(
255		__dynamic_array(char, msg, ATH6KL_MSG_MAX)
256	),
257	TP_fast_assign(
258		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
259				       ATH6KL_MSG_MAX,
260				       vaf->fmt,
261				       *vaf->va) >= ATH6KL_MSG_MAX);
262	),
263	TP_printk("%s", __get_str(msg))
264);
265
266DEFINE_EVENT(ath6kl_log_event, ath6kl_log_err,
267	     TP_PROTO(struct va_format *vaf),
268	     TP_ARGS(vaf)
269);
270
271DEFINE_EVENT(ath6kl_log_event, ath6kl_log_warn,
272	     TP_PROTO(struct va_format *vaf),
273	     TP_ARGS(vaf)
274);
275
276DEFINE_EVENT(ath6kl_log_event, ath6kl_log_info,
277	     TP_PROTO(struct va_format *vaf),
278	     TP_ARGS(vaf)
279);
280
281TRACE_EVENT(ath6kl_log_dbg,
282	TP_PROTO(unsigned int level, struct va_format *vaf),
283	TP_ARGS(level, vaf),
284	TP_STRUCT__entry(
285		__field(unsigned int, level)
286		__dynamic_array(char, msg, ATH6KL_MSG_MAX)
287	),
288	TP_fast_assign(
289		__entry->level = level;
290		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
291				       ATH6KL_MSG_MAX,
292				       vaf->fmt,
293				       *vaf->va) >= ATH6KL_MSG_MAX);
294	),
295	TP_printk("%s", __get_str(msg))
296);
297
298TRACE_EVENT(ath6kl_log_dbg_dump,
299	TP_PROTO(const char *msg, const char *prefix,
300		 const void *buf, size_t buf_len),
301
302	TP_ARGS(msg, prefix, buf, buf_len),
303
304	TP_STRUCT__entry(
305		__string(msg, msg)
306		__string(prefix, prefix)
307		__field(size_t, buf_len)
308		__dynamic_array(u8, buf, buf_len)
309	),
310
311	TP_fast_assign(
312		__assign_str(msg, msg);
313		__assign_str(prefix, prefix);
314		__entry->buf_len = buf_len;
315		memcpy(__get_dynamic_array(buf), buf, buf_len);
316	),
317
318	TP_printk(
319		"%s/%s\n", __get_str(prefix), __get_str(msg)
320	)
321);
322
323#endif /* _ ATH6KL_TRACE_H || TRACE_HEADER_MULTI_READ*/
324
325/* we don't want to use include/trace/events */
326#undef TRACE_INCLUDE_PATH
327#define TRACE_INCLUDE_PATH .
328#undef TRACE_INCLUDE_FILE
329#define TRACE_INCLUDE_FILE trace
330
331/* This part must be outside protection */
332#include <trace/define_trace.h>
333