1 /******************************************************************************
3 * Copyright(c) 2009 - 2013 Intel Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *****************************************************************************/
27 #if !defined(__IWLWIFI_DEVICE_TRACE) || defined(TRACE_HEADER_MULTI_READ)
28 #include <linux/skbuff.h>
29 #include <linux/ieee80211.h>
30 #include <net/cfg80211.h>
31 #include "iwl-trans.h"
32 #if !defined(__IWLWIFI_DEVICE_TRACE)
33 static inline bool iwl_trace_data(struct sk_buff
*skb
)
35 struct ieee80211_hdr
*hdr
= (void *)skb
->data
;
37 if (ieee80211_is_data(hdr
->frame_control
))
38 return skb
->protocol
!= cpu_to_be16(ETH_P_PAE
);
42 static inline size_t iwl_rx_trace_len(const struct iwl_trans
*trans
,
43 void *rxbuf
, size_t len
)
45 struct iwl_cmd_header
*cmd
= (void *)((u8
*)rxbuf
+ sizeof(__le32
));
46 struct ieee80211_hdr
*hdr
;
48 if (cmd
->cmd
!= trans
->rx_mpdu_cmd
)
51 hdr
= (void *)((u8
*)cmd
+ sizeof(struct iwl_cmd_header
) +
52 trans
->rx_mpdu_cmd_hdr_size
);
53 if (!ieee80211_is_data(hdr
->frame_control
))
55 /* maybe try to identify EAPOL frames? */
56 return sizeof(__le32
) + sizeof(*cmd
) + trans
->rx_mpdu_cmd_hdr_size
+
57 ieee80211_hdrlen(hdr
->frame_control
);
61 #define __IWLWIFI_DEVICE_TRACE
63 #include <linux/tracepoint.h>
64 #include <linux/device.h>
65 #include "iwl-trans.h"
68 #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
70 #define TRACE_EVENT(name, proto, ...) \
71 static inline void trace_ ## name(proto) {}
72 #undef DECLARE_EVENT_CLASS
73 #define DECLARE_EVENT_CLASS(...)
75 #define DEFINE_EVENT(evt_class, name, proto, ...) \
76 static inline void trace_ ## name(proto) {}
79 #define DEV_ENTRY __string(dev, dev_name(dev))
80 #define DEV_ASSIGN __assign_str(dev, dev_name(dev))
83 #define TRACE_SYSTEM iwlwifi_io
85 TRACE_EVENT(iwlwifi_dev_ioread32
,
86 TP_PROTO(const struct device
*dev
, u32 offs
, u32 val
),
87 TP_ARGS(dev
, offs
, val
),
98 TP_printk("[%s] read io[%#x] = %#x",
99 __get_str(dev
), __entry
->offs
, __entry
->val
)
102 TRACE_EVENT(iwlwifi_dev_iowrite8
,
103 TP_PROTO(const struct device
*dev
, u32 offs
, u8 val
),
104 TP_ARGS(dev
, offs
, val
),
112 __entry
->offs
= offs
;
115 TP_printk("[%s] write io[%#x] = %#x)",
116 __get_str(dev
), __entry
->offs
, __entry
->val
)
119 TRACE_EVENT(iwlwifi_dev_iowrite32
,
120 TP_PROTO(const struct device
*dev
, u32 offs
, u32 val
),
121 TP_ARGS(dev
, offs
, val
),
129 __entry
->offs
= offs
;
132 TP_printk("[%s] write io[%#x] = %#x)",
133 __get_str(dev
), __entry
->offs
, __entry
->val
)
136 TRACE_EVENT(iwlwifi_dev_iowrite_prph32
,
137 TP_PROTO(const struct device
*dev
, u32 offs
, u32 val
),
138 TP_ARGS(dev
, offs
, val
),
146 __entry
->offs
= offs
;
149 TP_printk("[%s] write PRPH[%#x] = %#x)",
150 __get_str(dev
), __entry
->offs
, __entry
->val
)
153 TRACE_EVENT(iwlwifi_dev_ioread_prph32
,
154 TP_PROTO(const struct device
*dev
, u32 offs
, u32 val
),
155 TP_ARGS(dev
, offs
, val
),
163 __entry
->offs
= offs
;
166 TP_printk("[%s] read PRPH[%#x] = %#x",
167 __get_str(dev
), __entry
->offs
, __entry
->val
)
170 TRACE_EVENT(iwlwifi_dev_irq
,
171 TP_PROTO(const struct device
*dev
),
179 /* TP_printk("") doesn't compile */
183 TRACE_EVENT(iwlwifi_dev_ict_read
,
184 TP_PROTO(const struct device
*dev
, u32 index
, u32 value
),
185 TP_ARGS(dev
, index
, value
),
193 __entry
->index
= index
;
194 __entry
->value
= value
;
196 TP_printk("[%s] read ict[%d] = %#.8x",
197 __get_str(dev
), __entry
->index
, __entry
->value
)
201 #define TRACE_SYSTEM iwlwifi_ucode
203 TRACE_EVENT(iwlwifi_dev_ucode_cont_event
,
204 TP_PROTO(const struct device
*dev
, u32 time
, u32 data
, u32 ev
),
205 TP_ARGS(dev
, time
, data
, ev
),
215 __entry
->time
= time
;
216 __entry
->data
= data
;
219 TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
220 __get_str(dev
), __entry
->time
, __entry
->data
, __entry
->ev
)
223 TRACE_EVENT(iwlwifi_dev_ucode_wrap_event
,
224 TP_PROTO(const struct device
*dev
, u32 wraps
, u32 n_entry
, u32 p_entry
),
225 TP_ARGS(dev
, wraps
, n_entry
, p_entry
),
230 __field(u32
, n_entry
)
231 __field(u32
, p_entry
)
235 __entry
->wraps
= wraps
;
236 __entry
->n_entry
= n_entry
;
237 __entry
->p_entry
= p_entry
;
239 TP_printk("[%s] wraps=#%02d n=0x%X p=0x%X",
240 __get_str(dev
), __entry
->wraps
, __entry
->n_entry
,
245 #define TRACE_SYSTEM iwlwifi_msg
247 #define MAX_MSG_LEN 110
249 DECLARE_EVENT_CLASS(iwlwifi_msg_event
,
250 TP_PROTO(struct va_format
*vaf
),
253 __dynamic_array(char, msg
, MAX_MSG_LEN
)
256 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg
),
257 MAX_MSG_LEN
, vaf
->fmt
,
258 *vaf
->va
) >= MAX_MSG_LEN
);
260 TP_printk("%s", __get_str(msg
))
263 DEFINE_EVENT(iwlwifi_msg_event
, iwlwifi_err
,
264 TP_PROTO(struct va_format
*vaf
),
268 DEFINE_EVENT(iwlwifi_msg_event
, iwlwifi_warn
,
269 TP_PROTO(struct va_format
*vaf
),
273 DEFINE_EVENT(iwlwifi_msg_event
, iwlwifi_info
,
274 TP_PROTO(struct va_format
*vaf
),
278 DEFINE_EVENT(iwlwifi_msg_event
, iwlwifi_crit
,
279 TP_PROTO(struct va_format
*vaf
),
283 TRACE_EVENT(iwlwifi_dbg
,
284 TP_PROTO(u32 level
, bool in_interrupt
, const char *function
,
285 struct va_format
*vaf
),
286 TP_ARGS(level
, in_interrupt
, function
, vaf
),
289 __field(u8
, in_interrupt
)
290 __string(function
, function
)
291 __dynamic_array(char, msg
, MAX_MSG_LEN
)
294 __entry
->level
= level
;
295 __entry
->in_interrupt
= in_interrupt
;
296 __assign_str(function
, function
);
297 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg
),
298 MAX_MSG_LEN
, vaf
->fmt
,
299 *vaf
->va
) >= MAX_MSG_LEN
);
301 TP_printk("%s", __get_str(msg
))
305 #define TRACE_SYSTEM iwlwifi_data
307 TRACE_EVENT(iwlwifi_dev_tx_data
,
308 TP_PROTO(const struct device
*dev
,
310 void *data
, size_t data_len
),
311 TP_ARGS(dev
, skb
, data
, data_len
),
315 __dynamic_array(u8
, data
, iwl_trace_data(skb
) ? data_len
: 0)
319 if (iwl_trace_data(skb
))
320 memcpy(__get_dynamic_array(data
), data
, data_len
);
322 TP_printk("[%s] TX frame data", __get_str(dev
))
325 TRACE_EVENT(iwlwifi_dev_rx_data
,
326 TP_PROTO(const struct device
*dev
,
327 const struct iwl_trans
*trans
,
328 void *rxbuf
, size_t len
),
329 TP_ARGS(dev
, trans
, rxbuf
, len
),
333 __dynamic_array(u8
, data
,
334 len
- iwl_rx_trace_len(trans
, rxbuf
, len
))
337 size_t offs
= iwl_rx_trace_len(trans
, rxbuf
, len
);
340 memcpy(__get_dynamic_array(data
),
341 ((u8
*)rxbuf
) + offs
, len
- offs
);
343 TP_printk("[%s] RX frame data", __get_str(dev
))
347 #define TRACE_SYSTEM iwlwifi
349 TRACE_EVENT(iwlwifi_dev_hcmd
,
350 TP_PROTO(const struct device
*dev
,
351 struct iwl_host_cmd
*cmd
, u16 total_size
,
352 struct iwl_cmd_header
*hdr
),
353 TP_ARGS(dev
, cmd
, total_size
, hdr
),
356 __dynamic_array(u8
, hcmd
, total_size
)
360 int i
, offset
= sizeof(*hdr
);
363 __entry
->flags
= cmd
->flags
;
364 memcpy(__get_dynamic_array(hcmd
), hdr
, sizeof(*hdr
));
366 for (i
= 0; i
< IWL_MAX_CMD_TBS_PER_TFD
; i
++) {
369 memcpy((u8
*)__get_dynamic_array(hcmd
) + offset
,
370 cmd
->data
[i
], cmd
->len
[i
]);
371 offset
+= cmd
->len
[i
];
374 TP_printk("[%s] hcmd %#.2x (%ssync)",
375 __get_str(dev
), ((u8
*)__get_dynamic_array(hcmd
))[0],
376 __entry
->flags
& CMD_ASYNC
? "a" : "")
379 TRACE_EVENT(iwlwifi_dev_rx
,
380 TP_PROTO(const struct device
*dev
, const struct iwl_trans
*trans
,
381 void *rxbuf
, size_t len
),
382 TP_ARGS(dev
, trans
, rxbuf
, len
),
385 __dynamic_array(u8
, rxbuf
, iwl_rx_trace_len(trans
, rxbuf
, len
))
389 memcpy(__get_dynamic_array(rxbuf
), rxbuf
,
390 iwl_rx_trace_len(trans
, rxbuf
, len
));
392 TP_printk("[%s] RX cmd %#.2x",
393 __get_str(dev
), ((u8
*)__get_dynamic_array(rxbuf
))[4])
396 TRACE_EVENT(iwlwifi_dev_tx
,
397 TP_PROTO(const struct device
*dev
, struct sk_buff
*skb
,
398 void *tfd
, size_t tfdlen
,
399 void *buf0
, size_t buf0_len
,
400 void *buf1
, size_t buf1_len
),
401 TP_ARGS(dev
, skb
, tfd
, tfdlen
, buf0
, buf0_len
, buf1
, buf1_len
),
405 __field(size_t, framelen
)
406 __dynamic_array(u8
, tfd
, tfdlen
)
409 * Do not insert between or below these items,
410 * we want to keep the frame together (except
411 * for the possible padding).
413 __dynamic_array(u8
, buf0
, buf0_len
)
414 __dynamic_array(u8
, buf1
, iwl_trace_data(skb
) ? 0 : buf1_len
)
418 __entry
->framelen
= buf0_len
+ buf1_len
;
419 memcpy(__get_dynamic_array(tfd
), tfd
, tfdlen
);
420 memcpy(__get_dynamic_array(buf0
), buf0
, buf0_len
);
421 if (!iwl_trace_data(skb
))
422 memcpy(__get_dynamic_array(buf1
), buf1
, buf1_len
);
424 TP_printk("[%s] TX %.2x (%zu bytes)",
425 __get_str(dev
), ((u8
*)__get_dynamic_array(buf0
))[0],
429 TRACE_EVENT(iwlwifi_dev_ucode_error
,
430 TP_PROTO(const struct device
*dev
, u32 desc
, u32 tsf_low
,
431 u32 data1
, u32 data2
, u32 line
, u32 blink1
,
432 u32 blink2
, u32 ilink1
, u32 ilink2
, u32 bcon_time
,
433 u32 gp1
, u32 gp2
, u32 gp3
, u32 ucode_ver
, u32 hw_ver
,
435 TP_ARGS(dev
, desc
, tsf_low
, data1
, data2
, line
,
436 blink1
, blink2
, ilink1
, ilink2
, bcon_time
, gp1
, gp2
,
437 gp3
, ucode_ver
, hw_ver
, brd_ver
),
441 __field(u32
, tsf_low
)
449 __field(u32
, bcon_time
)
453 __field(u32
, ucode_ver
)
455 __field(u32
, brd_ver
)
459 __entry
->desc
= desc
;
460 __entry
->tsf_low
= tsf_low
;
461 __entry
->data1
= data1
;
462 __entry
->data2
= data2
;
463 __entry
->line
= line
;
464 __entry
->blink1
= blink1
;
465 __entry
->blink2
= blink2
;
466 __entry
->ilink1
= ilink1
;
467 __entry
->ilink2
= ilink2
;
468 __entry
->bcon_time
= bcon_time
;
472 __entry
->ucode_ver
= ucode_ver
;
473 __entry
->hw_ver
= hw_ver
;
474 __entry
->brd_ver
= brd_ver
;
476 TP_printk("[%s] #%02d %010u data 0x%08X 0x%08X line %u, "
477 "blink 0x%05X 0x%05X ilink 0x%05X 0x%05X "
478 "bcon_tm %010u gp 0x%08X 0x%08X 0x%08X uCode 0x%08X "
479 "hw 0x%08X brd 0x%08X",
480 __get_str(dev
), __entry
->desc
, __entry
->tsf_low
,
482 __entry
->data2
, __entry
->line
, __entry
->blink1
,
483 __entry
->blink2
, __entry
->ilink1
, __entry
->ilink2
,
484 __entry
->bcon_time
, __entry
->gp1
, __entry
->gp2
,
485 __entry
->gp3
, __entry
->ucode_ver
, __entry
->hw_ver
,
489 TRACE_EVENT(iwlwifi_dev_ucode_event
,
490 TP_PROTO(const struct device
*dev
, u32 time
, u32 data
, u32 ev
),
491 TP_ARGS(dev
, time
, data
, ev
),
501 __entry
->time
= time
;
502 __entry
->data
= data
;
505 TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
506 __get_str(dev
), __entry
->time
, __entry
->data
, __entry
->ev
)
508 #endif /* __IWLWIFI_DEVICE_TRACE */
510 #undef TRACE_INCLUDE_PATH
511 #define TRACE_INCLUDE_PATH .
512 #undef TRACE_INCLUDE_FILE
513 #define TRACE_INCLUDE_FILE iwl-devtrace
514 #include <trace/define_trace.h>