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  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of version 2 of the GNU General Public License as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  *
20  * The full GNU General Public License is included in this distribution in the
21  * file called LICENSE.
22  *
23  * Contact Information:
24  *  Intel Linux Wireless <linuxwifi@intel.com>
25  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26  *
27  *****************************************************************************/
28 
29 #if !defined(__IWLWIFI_DEVICE_TRACE_IWLWIFI) || defined(TRACE_HEADER_MULTI_READ)
30 #define __IWLWIFI_DEVICE_TRACE_IWLWIFI
31 
32 #include <linux/tracepoint.h>
33 
34 #undef TRACE_SYSTEM
35 #define TRACE_SYSTEM iwlwifi
36 
37 TRACE_EVENT(iwlwifi_dev_hcmd,
38 	TP_PROTO(const struct device *dev,
39 		 struct iwl_host_cmd *cmd, u16 total_size,
40 		 struct iwl_cmd_header_wide *hdr),
41 	TP_ARGS(dev, cmd, total_size, hdr),
42 	TP_STRUCT__entry(
43 		DEV_ENTRY
44 		__dynamic_array(u8, hcmd, total_size)
45 		__field(u32, flags)
46 	),
47 	TP_fast_assign(
48 		int i, offset = sizeof(struct iwl_cmd_header);
49 
50 		if (hdr->group_id)
51 			offset = sizeof(struct iwl_cmd_header_wide);
52 
53 		DEV_ASSIGN;
54 		__entry->flags = cmd->flags;
55 		memcpy(__get_dynamic_array(hcmd), hdr, offset);
56 
57 		for (i = 0; i < IWL_MAX_CMD_TBS_PER_TFD; i++) {
58 			if (!cmd->len[i])
59 				continue;
60 			memcpy((u8 *)__get_dynamic_array(hcmd) + offset,
61 			       cmd->data[i], cmd->len[i]);
62 			offset += cmd->len[i];
63 		}
64 	),
65 	TP_printk("[%s] hcmd %#.2x.%#.2x (%ssync)",
66 		  __get_str(dev), ((u8 *)__get_dynamic_array(hcmd))[1],
67 		  ((u8 *)__get_dynamic_array(hcmd))[0],
68 		  __entry->flags & CMD_ASYNC ? "a" : "")
69 );
70 
71 TRACE_EVENT(iwlwifi_dev_rx,
72 	TP_PROTO(const struct device *dev, const struct iwl_trans *trans,
73 		 struct iwl_rx_packet *pkt, size_t len),
74 	TP_ARGS(dev, trans, pkt, len),
75 	TP_STRUCT__entry(
76 		DEV_ENTRY
77 		__field(u16, cmd)
78 		__dynamic_array(u8, rxbuf, iwl_rx_trace_len(trans, pkt, len))
79 	),
80 	TP_fast_assign(
81 		DEV_ASSIGN;
82 		__entry->cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
83 		memcpy(__get_dynamic_array(rxbuf), pkt,
84 		       iwl_rx_trace_len(trans, pkt, len));
85 	),
86 	TP_printk("[%s] RX cmd %#.2x",
87 		  __get_str(dev), __entry->cmd)
88 );
89 
90 TRACE_EVENT(iwlwifi_dev_tx,
91 	TP_PROTO(const struct device *dev, struct sk_buff *skb,
92 		 void *tfd, size_t tfdlen,
93 		 void *buf0, size_t buf0_len,
94 		 int hdr_len),
95 	TP_ARGS(dev, skb, tfd, tfdlen, buf0, buf0_len, hdr_len),
96 	TP_STRUCT__entry(
97 		DEV_ENTRY
98 
99 		__field(size_t, framelen)
100 		__dynamic_array(u8, tfd, tfdlen)
101 
102 		/*
103 		 * Do not insert between or below these items,
104 		 * we want to keep the frame together (except
105 		 * for the possible padding).
106 		 */
107 		__dynamic_array(u8, buf0, buf0_len)
108 		__dynamic_array(u8, buf1, hdr_len > 0 && iwl_trace_data(skb) ?
109 						0 : skb->len - hdr_len)
110 	),
111 	TP_fast_assign(
112 		DEV_ASSIGN;
113 		__entry->framelen = buf0_len;
114 		if (hdr_len > 0)
115 			__entry->framelen += skb->len - hdr_len;
116 		memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
117 		memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
118 		if (hdr_len > 0 && !iwl_trace_data(skb))
119 			skb_copy_bits(skb, hdr_len,
120 				      __get_dynamic_array(buf1),
121 				      skb->len - hdr_len);
122 	),
123 	TP_printk("[%s] TX %.2x (%zu bytes)",
124 		  __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0],
125 		  __entry->framelen)
126 );
127 
128 TRACE_EVENT(iwlwifi_dev_ucode_error,
129 	TP_PROTO(const struct device *dev, u32 desc, u32 tsf_low,
130 		 u32 data1, u32 data2, u32 line, u32 blink2, u32 ilink1,
131 		 u32 ilink2, u32 bcon_time, u32 gp1, u32 gp2, u32 rev_type,
132 		 u32 major, u32 minor, u32 hw_ver, u32 brd_ver),
133 	TP_ARGS(dev, desc, tsf_low, data1, data2, line,
134 		 blink2, ilink1, ilink2, bcon_time, gp1, gp2,
135 		 rev_type, major, minor, hw_ver, brd_ver),
136 	TP_STRUCT__entry(
137 		DEV_ENTRY
138 		__field(u32, desc)
139 		__field(u32, tsf_low)
140 		__field(u32, data1)
141 		__field(u32, data2)
142 		__field(u32, line)
143 		__field(u32, blink2)
144 		__field(u32, ilink1)
145 		__field(u32, ilink2)
146 		__field(u32, bcon_time)
147 		__field(u32, gp1)
148 		__field(u32, gp2)
149 		__field(u32, rev_type)
150 		__field(u32, major)
151 		__field(u32, minor)
152 		__field(u32, hw_ver)
153 		__field(u32, brd_ver)
154 	),
155 	TP_fast_assign(
156 		DEV_ASSIGN;
157 		__entry->desc = desc;
158 		__entry->tsf_low = tsf_low;
159 		__entry->data1 = data1;
160 		__entry->data2 = data2;
161 		__entry->line = line;
162 		__entry->blink2 = blink2;
163 		__entry->ilink1 = ilink1;
164 		__entry->ilink2 = ilink2;
165 		__entry->bcon_time = bcon_time;
166 		__entry->gp1 = gp1;
167 		__entry->gp2 = gp2;
168 		__entry->rev_type = rev_type;
169 		__entry->major = major;
170 		__entry->minor = minor;
171 		__entry->hw_ver = hw_ver;
172 		__entry->brd_ver = brd_ver;
173 	),
174 	TP_printk("[%s] #%02d %010u data 0x%08X 0x%08X line %u, "
175 		  "blink2 0x%05X ilink 0x%05X 0x%05X "
176 		  "bcon_tm %010u gp 0x%08X 0x%08X rev_type 0x%08X major 0x%08X "
177 		  "minor 0x%08X hw 0x%08X brd 0x%08X",
178 		  __get_str(dev), __entry->desc, __entry->tsf_low,
179 		  __entry->data1, __entry->data2, __entry->line,
180 		  __entry->blink2, __entry->ilink1, __entry->ilink2,
181 		  __entry->bcon_time, __entry->gp1, __entry->gp2,
182 		  __entry->rev_type, __entry->major, __entry->minor,
183 		  __entry->hw_ver, __entry->brd_ver)
184 );
185 
186 TRACE_EVENT(iwlwifi_dev_ucode_event,
187 	TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
188 	TP_ARGS(dev, time, data, ev),
189 	TP_STRUCT__entry(
190 		DEV_ENTRY
191 
192 		__field(u32, time)
193 		__field(u32, data)
194 		__field(u32, ev)
195 	),
196 	TP_fast_assign(
197 		DEV_ASSIGN;
198 		__entry->time = time;
199 		__entry->data = data;
200 		__entry->ev = ev;
201 	),
202 	TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
203 		  __get_str(dev), __entry->time, __entry->data, __entry->ev)
204 );
205 #endif /* __IWLWIFI_DEVICE_TRACE_IWLWIFI */
206 
207 #undef TRACE_INCLUDE_PATH
208 #define TRACE_INCLUDE_PATH .
209 #undef TRACE_INCLUDE_FILE
210 #define TRACE_INCLUDE_FILE iwl-devtrace-iwlwifi
211 #include <trace/define_trace.h>
212