xref: /linux/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h (revision af50e4ba34f4c45e92535364133d4deb5931c1c5)
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 		__field(void *, skbaddr)
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->skbaddr = skb;
114 		__entry->framelen = buf0_len;
115 		if (hdr_len > 0)
116 			__entry->framelen += skb->len - hdr_len;
117 		memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
118 		memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
119 		if (hdr_len > 0 && !iwl_trace_data(skb))
120 			skb_copy_bits(skb, hdr_len,
121 				      __get_dynamic_array(buf1),
122 				      skb->len - hdr_len);
123 	),
124 	TP_printk("[%s] TX %.2x (%zu bytes) skbaddr=%p",
125 		  __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0],
126 		  __entry->framelen, __entry->skbaddr)
127 );
128 
129 struct iwl_error_event_table;
130 TRACE_EVENT(iwlwifi_dev_ucode_error,
131 	TP_PROTO(const struct device *dev, const struct iwl_error_event_table *table,
132 		 u32 hw_ver, u32 brd_ver),
133 	TP_ARGS(dev, table, hw_ver, brd_ver),
134 	TP_STRUCT__entry(
135 		DEV_ENTRY
136 		__field(u32, desc)
137 		__field(u32, tsf_low)
138 		__field(u32, data1)
139 		__field(u32, data2)
140 		__field(u32, line)
141 		__field(u32, blink2)
142 		__field(u32, ilink1)
143 		__field(u32, ilink2)
144 		__field(u32, bcon_time)
145 		__field(u32, gp1)
146 		__field(u32, gp2)
147 		__field(u32, rev_type)
148 		__field(u32, major)
149 		__field(u32, minor)
150 		__field(u32, hw_ver)
151 		__field(u32, brd_ver)
152 	),
153 	TP_fast_assign(
154 		DEV_ASSIGN;
155 		__entry->desc = table->error_id;
156 		__entry->tsf_low = table->tsf_low;
157 		__entry->data1 = table->data1;
158 		__entry->data2 = table->data2;
159 		__entry->line = table->line;
160 		__entry->blink2 = table->blink2;
161 		__entry->ilink1 = table->ilink1;
162 		__entry->ilink2 = table->ilink2;
163 		__entry->bcon_time = table->bcon_time;
164 		__entry->gp1 = table->gp1;
165 		__entry->gp2 = table->gp2;
166 		__entry->rev_type = table->gp3;
167 		__entry->major = table->ucode_ver;
168 		__entry->minor = table->hw_ver;
169 		__entry->hw_ver = hw_ver;
170 		__entry->brd_ver = brd_ver;
171 	),
172 	TP_printk("[%s] #%02d %010u data 0x%08X 0x%08X line %u, "
173 		  "blink2 0x%05X ilink 0x%05X 0x%05X "
174 		  "bcon_tm %010u gp 0x%08X 0x%08X rev_type 0x%08X major 0x%08X "
175 		  "minor 0x%08X hw 0x%08X brd 0x%08X",
176 		  __get_str(dev), __entry->desc, __entry->tsf_low,
177 		  __entry->data1, __entry->data2, __entry->line,
178 		  __entry->blink2, __entry->ilink1, __entry->ilink2,
179 		  __entry->bcon_time, __entry->gp1, __entry->gp2,
180 		  __entry->rev_type, __entry->major, __entry->minor,
181 		  __entry->hw_ver, __entry->brd_ver)
182 );
183 
184 TRACE_EVENT(iwlwifi_dev_ucode_event,
185 	TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
186 	TP_ARGS(dev, time, data, ev),
187 	TP_STRUCT__entry(
188 		DEV_ENTRY
189 
190 		__field(u32, time)
191 		__field(u32, data)
192 		__field(u32, ev)
193 	),
194 	TP_fast_assign(
195 		DEV_ASSIGN;
196 		__entry->time = time;
197 		__entry->data = data;
198 		__entry->ev = ev;
199 	),
200 	TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
201 		  __get_str(dev), __entry->time, __entry->data, __entry->ev)
202 );
203 #endif /* __IWLWIFI_DEVICE_TRACE_IWLWIFI */
204 
205 #undef TRACE_INCLUDE_PATH
206 #define TRACE_INCLUDE_PATH .
207 #undef TRACE_INCLUDE_FILE
208 #define TRACE_INCLUDE_FILE iwl-devtrace-iwlwifi
209 #include <trace/define_trace.h>
210