1 /******************************************************************************
2  *
3  * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
4  * Copyright(c) 2015 Intel Mobile Communications GmbH
5  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
6  * Copyright(c) 2018        Intel Corporation
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of version 2 of the GNU General Public License as
10  * published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  *
17  * The full GNU General Public License is included in this distribution in the
18  * file called LICENSE.
19  *
20  * Contact Information:
21  *  Intel Linux Wireless <linuxwifi@intel.com>
22  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
23  *
24  *****************************************************************************/
25 
26 #if !defined(__IWLWIFI_DEVICE_TRACE_IWLWIFI) || defined(TRACE_HEADER_MULTI_READ)
27 #define __IWLWIFI_DEVICE_TRACE_IWLWIFI
28 
29 #include <linux/tracepoint.h>
30 
31 #undef TRACE_SYSTEM
32 #define TRACE_SYSTEM iwlwifi
33 
34 TRACE_EVENT(iwlwifi_dev_hcmd,
35 	TP_PROTO(const struct device *dev,
36 		 struct iwl_host_cmd *cmd, u16 total_size,
37 		 struct iwl_cmd_header_wide *hdr),
38 	TP_ARGS(dev, cmd, total_size, hdr),
39 	TP_STRUCT__entry(
40 		DEV_ENTRY
41 		__dynamic_array(u8, hcmd, total_size)
42 		__field(u32, flags)
43 	),
44 	TP_fast_assign(
45 		int i, offset = sizeof(struct iwl_cmd_header);
46 
47 		if (hdr->group_id)
48 			offset = sizeof(struct iwl_cmd_header_wide);
49 
50 		DEV_ASSIGN;
51 		__entry->flags = cmd->flags;
52 		memcpy(__get_dynamic_array(hcmd), hdr, offset);
53 
54 		for (i = 0; i < IWL_MAX_CMD_TBS_PER_TFD; i++) {
55 			if (!cmd->len[i])
56 				continue;
57 			memcpy((u8 *)__get_dynamic_array(hcmd) + offset,
58 			       cmd->data[i], cmd->len[i]);
59 			offset += cmd->len[i];
60 		}
61 	),
62 	TP_printk("[%s] hcmd %#.2x.%#.2x (%ssync)",
63 		  __get_str(dev), ((u8 *)__get_dynamic_array(hcmd))[1],
64 		  ((u8 *)__get_dynamic_array(hcmd))[0],
65 		  __entry->flags & CMD_ASYNC ? "a" : "")
66 );
67 
68 TRACE_EVENT(iwlwifi_dev_rx,
69 	TP_PROTO(const struct device *dev, const struct iwl_trans *trans,
70 		 struct iwl_rx_packet *pkt, size_t len),
71 	TP_ARGS(dev, trans, pkt, len),
72 	TP_STRUCT__entry(
73 		DEV_ENTRY
74 		__field(u16, cmd)
75 		__field(u8, hdr_offset)
76 		__dynamic_array(u8, rxbuf,
77 				iwl_rx_trace_len(trans, pkt, len, NULL))
78 	),
79 	TP_fast_assign(
80 		size_t hdr_offset = 0;
81 
82 		DEV_ASSIGN;
83 		__entry->cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
84 		memcpy(__get_dynamic_array(rxbuf), pkt,
85 		       iwl_rx_trace_len(trans, pkt, len, &hdr_offset));
86 		__entry->hdr_offset = hdr_offset;
87 	),
88 	TP_printk("[%s] RX cmd %#.2x",
89 		  __get_str(dev), __entry->cmd)
90 );
91 
92 TRACE_EVENT(iwlwifi_dev_tx,
93 	TP_PROTO(const struct device *dev, struct sk_buff *skb,
94 		 void *tfd, size_t tfdlen,
95 		 void *buf0, size_t buf0_len,
96 		 int hdr_len),
97 	TP_ARGS(dev, skb, tfd, tfdlen, buf0, buf0_len, hdr_len),
98 	TP_STRUCT__entry(
99 		DEV_ENTRY
100 		__field(void *, skbaddr)
101 		__field(size_t, framelen)
102 		__dynamic_array(u8, tfd, tfdlen)
103 
104 		/*
105 		 * Do not insert between or below these items,
106 		 * we want to keep the frame together (except
107 		 * for the possible padding).
108 		 */
109 		__dynamic_array(u8, buf0, buf0_len)
110 		__dynamic_array(u8, buf1, hdr_len > 0 && iwl_trace_data(skb) ?
111 						0 : skb->len - hdr_len)
112 	),
113 	TP_fast_assign(
114 		DEV_ASSIGN;
115 		__entry->skbaddr = skb;
116 		__entry->framelen = buf0_len;
117 		if (hdr_len > 0)
118 			__entry->framelen += skb->len - hdr_len;
119 		memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
120 		memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
121 		if (hdr_len > 0 && !iwl_trace_data(skb))
122 			skb_copy_bits(skb, hdr_len,
123 				      __get_dynamic_array(buf1),
124 				      skb->len - hdr_len);
125 	),
126 	TP_printk("[%s] TX %.2x (%zu bytes) skbaddr=%p",
127 		  __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0],
128 		  __entry->framelen, __entry->skbaddr)
129 );
130 
131 TRACE_EVENT(iwlwifi_dev_ucode_event,
132 	TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
133 	TP_ARGS(dev, time, data, ev),
134 	TP_STRUCT__entry(
135 		DEV_ENTRY
136 
137 		__field(u32, time)
138 		__field(u32, data)
139 		__field(u32, ev)
140 	),
141 	TP_fast_assign(
142 		DEV_ASSIGN;
143 		__entry->time = time;
144 		__entry->data = data;
145 		__entry->ev = ev;
146 	),
147 	TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
148 		  __get_str(dev), __entry->time, __entry->data, __entry->ev)
149 );
150 #endif /* __IWLWIFI_DEVICE_TRACE_IWLWIFI */
151 
152 #undef TRACE_INCLUDE_PATH
153 #define TRACE_INCLUDE_PATH .
154 #undef TRACE_INCLUDE_FILE
155 #define TRACE_INCLUDE_FILE iwl-devtrace-iwlwifi
156 #include <trace/define_trace.h>
157