iwl-devtrace.h 10.2 KB
Newer Older
1 2
/******************************************************************************
 *
W
Wey-Yi Guy 已提交
3
 * Copyright(c) 2009 - 2012 Intel Corporation. All rights reserved.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 *  Intel Linux Wireless <ilw@linux.intel.com>
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *
 *****************************************************************************/

J
Johannes Berg 已提交
27 28 29 30
#if !defined(__IWLWIFI_DEVICE_TRACE) || defined(TRACE_HEADER_MULTI_READ)
#define __IWLWIFI_DEVICE_TRACE

#include <linux/tracepoint.h>
31
#include <linux/device.h>
J
Johannes Berg 已提交
32

33

J
Johannes Berg 已提交
34 35 36 37
#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
#undef TRACE_EVENT
#define TRACE_EVENT(name, proto, ...) \
static inline void trace_ ## name(proto) {}
J
Johannes Berg 已提交
38 39 40 41 42
#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(...)
#undef DEFINE_EVENT
#define DEFINE_EVENT(evt_class, name, proto, ...) \
static inline void trace_ ## name(proto) {}
J
Johannes Berg 已提交
43 44
#endif

45 46
#define DEV_ENTRY	__string(dev, dev_name(dev))
#define DEV_ASSIGN	__assign_str(dev, dev_name(dev))
J
Johannes Berg 已提交
47 48

#undef TRACE_SYSTEM
J
Johannes Berg 已提交
49
#define TRACE_SYSTEM iwlwifi_io
J
Johannes Berg 已提交
50 51

TRACE_EVENT(iwlwifi_dev_ioread32,
52 53
	TP_PROTO(const struct device *dev, u32 offs, u32 val),
	TP_ARGS(dev, offs, val),
J
Johannes Berg 已提交
54
	TP_STRUCT__entry(
55
		DEV_ENTRY
J
Johannes Berg 已提交
56 57 58 59
		__field(u32, offs)
		__field(u32, val)
	),
	TP_fast_assign(
60
		DEV_ASSIGN;
J
Johannes Berg 已提交
61 62 63
		__entry->offs = offs;
		__entry->val = val;
	),
64 65
	TP_printk("[%s] read io[%#x] = %#x",
		  __get_str(dev), __entry->offs, __entry->val)
J
Johannes Berg 已提交
66 67
);

B
Ben Cahill 已提交
68
TRACE_EVENT(iwlwifi_dev_iowrite8,
69 70
	TP_PROTO(const struct device *dev, u32 offs, u8 val),
	TP_ARGS(dev, offs, val),
B
Ben Cahill 已提交
71
	TP_STRUCT__entry(
72
		DEV_ENTRY
B
Ben Cahill 已提交
73 74 75 76
		__field(u32, offs)
		__field(u8, val)
	),
	TP_fast_assign(
77
		DEV_ASSIGN;
B
Ben Cahill 已提交
78 79 80
		__entry->offs = offs;
		__entry->val = val;
	),
81 82
	TP_printk("[%s] write io[%#x] = %#x)",
		  __get_str(dev), __entry->offs, __entry->val)
B
Ben Cahill 已提交
83 84
);

J
Johannes Berg 已提交
85
TRACE_EVENT(iwlwifi_dev_iowrite32,
86 87
	TP_PROTO(const struct device *dev, u32 offs, u32 val),
	TP_ARGS(dev, offs, val),
J
Johannes Berg 已提交
88
	TP_STRUCT__entry(
89
		DEV_ENTRY
J
Johannes Berg 已提交
90 91 92 93
		__field(u32, offs)
		__field(u32, val)
	),
	TP_fast_assign(
94
		DEV_ASSIGN;
J
Johannes Berg 已提交
95 96 97
		__entry->offs = offs;
		__entry->val = val;
	),
98 99
	TP_printk("[%s] write io[%#x] = %#x)",
		  __get_str(dev), __entry->offs, __entry->val)
J
Johannes Berg 已提交
100 101
);

J
Johannes Berg 已提交
102
TRACE_EVENT(iwlwifi_dev_irq,
103 104
	TP_PROTO(const struct device *dev),
	TP_ARGS(dev),
J
Johannes Berg 已提交
105
	TP_STRUCT__entry(
106
		DEV_ENTRY
J
Johannes Berg 已提交
107 108
	),
	TP_fast_assign(
109
		DEV_ASSIGN;
J
Johannes Berg 已提交
110 111 112 113 114 115
	),
	/* TP_printk("") doesn't compile */
	TP_printk("%d", 0)
);

TRACE_EVENT(iwlwifi_dev_ict_read,
116 117
	TP_PROTO(const struct device *dev, u32 index, u32 value),
	TP_ARGS(dev, index, value),
J
Johannes Berg 已提交
118
	TP_STRUCT__entry(
119
		DEV_ENTRY
J
Johannes Berg 已提交
120 121 122 123
		__field(u32, index)
		__field(u32, value)
	),
	TP_fast_assign(
124
		DEV_ASSIGN;
J
Johannes Berg 已提交
125 126 127
		__entry->index = index;
		__entry->value = value;
	),
128 129
	TP_printk("[%s] read ict[%d] = %#.8x",
		  __get_str(dev), __entry->index, __entry->value)
J
Johannes Berg 已提交
130 131
);

132 133 134 135
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi_ucode

TRACE_EVENT(iwlwifi_dev_ucode_cont_event,
136 137
	TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
	TP_ARGS(dev, time, data, ev),
138
	TP_STRUCT__entry(
139
		DEV_ENTRY
140 141 142 143 144 145

		__field(u32, time)
		__field(u32, data)
		__field(u32, ev)
	),
	TP_fast_assign(
146
		DEV_ASSIGN;
147 148 149 150
		__entry->time = time;
		__entry->data = data;
		__entry->ev = ev;
	),
151 152
	TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
		  __get_str(dev), __entry->time, __entry->data, __entry->ev)
153 154 155
);

TRACE_EVENT(iwlwifi_dev_ucode_wrap_event,
156 157
	TP_PROTO(const struct device *dev, u32 wraps, u32 n_entry, u32 p_entry),
	TP_ARGS(dev, wraps, n_entry, p_entry),
158
	TP_STRUCT__entry(
159
		DEV_ENTRY
160 161 162 163 164 165

		__field(u32, wraps)
		__field(u32, n_entry)
		__field(u32, p_entry)
	),
	TP_fast_assign(
166
		DEV_ASSIGN;
167 168 169 170
		__entry->wraps = wraps;
		__entry->n_entry = n_entry;
		__entry->p_entry = p_entry;
	),
171 172
	TP_printk("[%s] wraps=#%02d n=0x%X p=0x%X",
		  __get_str(dev), __entry->wraps, __entry->n_entry,
173 174 175
		  __entry->p_entry)
);

J
Johannes Berg 已提交
176 177 178
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi_msg

179
#define MAX_MSG_LEN	110
J
Johannes Berg 已提交
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235

DECLARE_EVENT_CLASS(iwlwifi_msg_event,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf),
	TP_STRUCT__entry(
		__dynamic_array(char, msg, MAX_MSG_LEN)
	),
	TP_fast_assign(
		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
				       MAX_MSG_LEN, vaf->fmt,
				       *vaf->va) >= MAX_MSG_LEN);
	),
	TP_printk("%s", (char *)__get_dynamic_array(msg))
);

DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_err,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_warn,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_info,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_crit,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

TRACE_EVENT(iwlwifi_dbg,
	TP_PROTO(u32 level, bool in_interrupt, const char *function,
		 struct va_format *vaf),
	TP_ARGS(level, in_interrupt, function, vaf),
	TP_STRUCT__entry(
		__field(u32, level)
		__field(u8, in_interrupt)
		__string(function, function)
		__dynamic_array(char, msg, MAX_MSG_LEN)
	),
	TP_fast_assign(
		__entry->level = level;
		__entry->in_interrupt = in_interrupt;
		__assign_str(function, function);
		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
				       MAX_MSG_LEN, vaf->fmt,
				       *vaf->va) >= MAX_MSG_LEN);
	),
	TP_printk("%s", (char *)__get_dynamic_array(msg))
);

J
Johannes Berg 已提交
236 237 238
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi

J
Johannes Berg 已提交
239
TRACE_EVENT(iwlwifi_dev_hcmd,
240
	TP_PROTO(const struct device *dev, u32 flags,
241 242 243
		 const void *hcmd0, size_t len0,
		 const void *hcmd1, size_t len1,
		 const void *hcmd2, size_t len2),
244
	TP_ARGS(dev, flags, hcmd0, len0, hcmd1, len1, hcmd2, len2),
J
Johannes Berg 已提交
245
	TP_STRUCT__entry(
246
		DEV_ENTRY
247 248 249
		__dynamic_array(u8, hcmd0, len0)
		__dynamic_array(u8, hcmd1, len1)
		__dynamic_array(u8, hcmd2, len2)
J
Johannes Berg 已提交
250 251 252
		__field(u32, flags)
	),
	TP_fast_assign(
253
		DEV_ASSIGN;
254 255 256
		memcpy(__get_dynamic_array(hcmd0), hcmd0, len0);
		memcpy(__get_dynamic_array(hcmd1), hcmd1, len1);
		memcpy(__get_dynamic_array(hcmd2), hcmd2, len2);
J
Johannes Berg 已提交
257 258
		__entry->flags = flags;
	),
259 260
	TP_printk("[%s] hcmd %#.2x (%ssync)",
		  __get_str(dev), ((u8 *)__get_dynamic_array(hcmd0))[0],
J
Johannes Berg 已提交
261 262 263 264
		  __entry->flags & CMD_ASYNC ? "a" : "")
);

TRACE_EVENT(iwlwifi_dev_rx,
265 266
	TP_PROTO(const struct device *dev, void *rxbuf, size_t len),
	TP_ARGS(dev, rxbuf, len),
J
Johannes Berg 已提交
267
	TP_STRUCT__entry(
268
		DEV_ENTRY
J
Johannes Berg 已提交
269 270 271
		__dynamic_array(u8, rxbuf, len)
	),
	TP_fast_assign(
272
		DEV_ASSIGN;
J
Johannes Berg 已提交
273 274
		memcpy(__get_dynamic_array(rxbuf), rxbuf, len);
	),
275 276
	TP_printk("[%s] RX cmd %#.2x",
		  __get_str(dev), ((u8 *)__get_dynamic_array(rxbuf))[4])
J
Johannes Berg 已提交
277 278 279
);

TRACE_EVENT(iwlwifi_dev_tx,
280
	TP_PROTO(const struct device *dev, void *tfd, size_t tfdlen,
J
Johannes Berg 已提交
281 282
		 void *buf0, size_t buf0_len,
		 void *buf1, size_t buf1_len),
283
	TP_ARGS(dev, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len),
J
Johannes Berg 已提交
284
	TP_STRUCT__entry(
285
		DEV_ENTRY
J
Johannes Berg 已提交
286 287 288 289 290 291 292 293 294 295 296 297 298

		__field(size_t, framelen)
		__dynamic_array(u8, tfd, tfdlen)

		/*
		 * Do not insert between or below these items,
		 * we want to keep the frame together (except
		 * for the possible padding).
		 */
		__dynamic_array(u8, buf0, buf0_len)
		__dynamic_array(u8, buf1, buf1_len)
	),
	TP_fast_assign(
299
		DEV_ASSIGN;
J
Johannes Berg 已提交
300 301 302
		__entry->framelen = buf0_len + buf1_len;
		memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
		memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
J
Johannes Berg 已提交
303
		memcpy(__get_dynamic_array(buf1), buf1, buf1_len);
J
Johannes Berg 已提交
304
	),
305 306
	TP_printk("[%s] TX %.2x (%zu bytes)",
		  __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0],
J
Johannes Berg 已提交
307 308 309 310
		  __entry->framelen)
);

TRACE_EVENT(iwlwifi_dev_ucode_error,
311
	TP_PROTO(const struct device *dev, u32 desc, u32 tsf_low,
J
Johannes Berg 已提交
312
		 u32 data1, u32 data2, u32 line, u32 blink1,
W
Wey-Yi Guy 已提交
313 314 315
		 u32 blink2, u32 ilink1, u32 ilink2, u32 bcon_time,
		 u32 gp1, u32 gp2, u32 gp3, u32 ucode_ver, u32 hw_ver,
		 u32 brd_ver),
316
	TP_ARGS(dev, desc, tsf_low, data1, data2, line,
W
Wey-Yi Guy 已提交
317 318
		blink1, blink2, ilink1, ilink2, bcon_time, gp1, gp2,
		gp3, ucode_ver, hw_ver, brd_ver),
J
Johannes Berg 已提交
319
	TP_STRUCT__entry(
320
		DEV_ENTRY
J
Johannes Berg 已提交
321
		__field(u32, desc)
W
Wey-Yi Guy 已提交
322
		__field(u32, tsf_low)
J
Johannes Berg 已提交
323 324 325 326 327 328 329
		__field(u32, data1)
		__field(u32, data2)
		__field(u32, line)
		__field(u32, blink1)
		__field(u32, blink2)
		__field(u32, ilink1)
		__field(u32, ilink2)
W
Wey-Yi Guy 已提交
330 331 332 333 334 335 336
		__field(u32, bcon_time)
		__field(u32, gp1)
		__field(u32, gp2)
		__field(u32, gp3)
		__field(u32, ucode_ver)
		__field(u32, hw_ver)
		__field(u32, brd_ver)
J
Johannes Berg 已提交
337 338
	),
	TP_fast_assign(
339
		DEV_ASSIGN;
J
Johannes Berg 已提交
340
		__entry->desc = desc;
W
Wey-Yi Guy 已提交
341
		__entry->tsf_low = tsf_low;
J
Johannes Berg 已提交
342 343 344 345 346 347 348
		__entry->data1 = data1;
		__entry->data2 = data2;
		__entry->line = line;
		__entry->blink1 = blink1;
		__entry->blink2 = blink2;
		__entry->ilink1 = ilink1;
		__entry->ilink2 = ilink2;
W
Wey-Yi Guy 已提交
349 350 351 352 353 354 355
		__entry->bcon_time = bcon_time;
		__entry->gp1 = gp1;
		__entry->gp2 = gp2;
		__entry->gp3 = gp3;
		__entry->ucode_ver = ucode_ver;
		__entry->hw_ver = hw_ver;
		__entry->brd_ver = brd_ver;
J
Johannes Berg 已提交
356
	),
357
	TP_printk("[%s] #%02d %010u data 0x%08X 0x%08X line %u, "
W
Wey-Yi Guy 已提交
358 359 360
		  "blink 0x%05X 0x%05X ilink 0x%05X 0x%05X "
		  "bcon_tm %010u gp 0x%08X 0x%08X 0x%08X uCode 0x%08X "
		  "hw 0x%08X brd 0x%08X",
361
		  __get_str(dev), __entry->desc, __entry->tsf_low,
W
Wey-Yi Guy 已提交
362
		  __entry->data1,
J
Johannes Berg 已提交
363
		  __entry->data2, __entry->line, __entry->blink1,
W
Wey-Yi Guy 已提交
364 365 366 367
		  __entry->blink2, __entry->ilink1, __entry->ilink2,
		  __entry->bcon_time, __entry->gp1, __entry->gp2,
		  __entry->gp3, __entry->ucode_ver, __entry->hw_ver,
		  __entry->brd_ver)
J
Johannes Berg 已提交
368 369 370
);

TRACE_EVENT(iwlwifi_dev_ucode_event,
371 372
	TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
	TP_ARGS(dev, time, data, ev),
J
Johannes Berg 已提交
373
	TP_STRUCT__entry(
374
		DEV_ENTRY
J
Johannes Berg 已提交
375 376 377 378 379 380

		__field(u32, time)
		__field(u32, data)
		__field(u32, ev)
	),
	TP_fast_assign(
381
		DEV_ASSIGN;
J
Johannes Berg 已提交
382 383 384 385
		__entry->time = time;
		__entry->data = data;
		__entry->ev = ev;
	),
386 387
	TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
		  __get_str(dev), __entry->time, __entry->data, __entry->ev)
J
Johannes Berg 已提交
388 389 390 391 392 393 394 395
);
#endif /* __IWLWIFI_DEVICE_TRACE */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE iwl-devtrace
#include <trace/define_trace.h>