xref: /linux/drivers/net/wireless/mediatek/mt7601u/trace.h (revision 34dc1baba215b826e454b8d19e4f24adbeb7d00d)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
4  * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
5  */
6 
7 #if !defined(__MT7601U_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
8 #define __MT7601U_TRACE_H
9 
10 #include <linux/tracepoint.h>
11 #include "mt7601u.h"
12 #include "mac.h"
13 
14 #undef TRACE_SYSTEM
15 #define TRACE_SYSTEM mt7601u
16 
17 #define MAXNAME		32
18 #define DEV_ENTRY	__array(char, wiphy_name, 32)
19 #define DEV_ASSIGN	strscpy(__entry->wiphy_name,			\
20 				wiphy_name(dev->hw->wiphy), MAXNAME)
21 #define DEV_PR_FMT	"%s "
22 #define DEV_PR_ARG	__entry->wiphy_name
23 
24 #define REG_ENTRY	__field(u32, reg) __field(u32, val)
25 #define REG_ASSIGN	__entry->reg = reg; __entry->val = val
26 #define REG_PR_FMT	"%04x=%08x"
27 #define REG_PR_ARG	__entry->reg, __entry->val
28 
29 DECLARE_EVENT_CLASS(dev_reg_evtu,
30 	TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
31 	TP_ARGS(dev, reg, val),
32 	TP_STRUCT__entry(
33 		DEV_ENTRY
34 		REG_ENTRY
35 	),
36 	TP_fast_assign(
37 		DEV_ASSIGN;
38 		REG_ASSIGN;
39 	),
40 	TP_printk(
41 		DEV_PR_FMT REG_PR_FMT,
42 		DEV_PR_ARG, REG_PR_ARG
43 	)
44 );
45 
46 DEFINE_EVENT(dev_reg_evtu, reg_read,
47 	TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
48 	TP_ARGS(dev, reg, val)
49 );
50 
51 DEFINE_EVENT(dev_reg_evtu, reg_write,
52 	TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
53 	TP_ARGS(dev, reg, val)
54 );
55 
56 TRACE_EVENT(mt_submit_urb,
57 	TP_PROTO(struct mt7601u_dev *dev, struct urb *u),
58 	TP_ARGS(dev, u),
59 	TP_STRUCT__entry(
60 		DEV_ENTRY __field(unsigned, pipe) __field(u32, len)
61 	),
62 	TP_fast_assign(
63 		DEV_ASSIGN;
64 		__entry->pipe = u->pipe;
65 		__entry->len = u->transfer_buffer_length;
66 	),
67 	TP_printk(DEV_PR_FMT "p:%08x len:%u",
68 		  DEV_PR_ARG, __entry->pipe, __entry->len)
69 );
70 
71 #define trace_mt_submit_urb_sync(__dev, __pipe, __len) ({	\
72 	struct urb u;					\
73 	u.pipe = __pipe;				\
74 	u.transfer_buffer_length = __len;		\
75 	trace_mt_submit_urb(__dev, &u);			\
76 })
77 
78 TRACE_EVENT(mt_mcu_msg_send,
79 	TP_PROTO(struct mt7601u_dev *dev,
80 		 struct sk_buff *skb, u32 csum, bool resp),
81 	TP_ARGS(dev, skb, csum, resp),
82 	TP_STRUCT__entry(
83 		DEV_ENTRY
84 		__field(u32, info)
85 		__field(u32, csum)
86 		__field(bool, resp)
87 	),
88 	TP_fast_assign(
89 		DEV_ASSIGN;
90 		__entry->info = *(u32 *)skb->data;
91 		__entry->csum = csum;
92 		__entry->resp = resp;
93 	),
94 	TP_printk(DEV_PR_FMT "i:%08x c:%08x r:%d",
95 		  DEV_PR_ARG, __entry->info, __entry->csum, __entry->resp)
96 );
97 
98 TRACE_EVENT(mt_vend_req,
99 	TP_PROTO(struct mt7601u_dev *dev, unsigned pipe, u8 req, u8 req_type,
100 		 u16 val, u16 offset, void *buf, size_t buflen, int ret),
101 	TP_ARGS(dev, pipe, req, req_type, val, offset, buf, buflen, ret),
102 	TP_STRUCT__entry(
103 		DEV_ENTRY
104 		__field(unsigned, pipe) __field(u8, req) __field(u8, req_type)
105 		__field(u16, val) __field(u16, offset) __field(void*, buf)
106 		__field(int, buflen) __field(int, ret)
107 	),
108 	TP_fast_assign(
109 		DEV_ASSIGN;
110 		__entry->pipe = pipe;
111 		__entry->req = req;
112 		__entry->req_type = req_type;
113 		__entry->val = val;
114 		__entry->offset = offset;
115 		__entry->buf = buf;
116 		__entry->buflen = buflen;
117 		__entry->ret = ret;
118 	),
119 	TP_printk(DEV_PR_FMT
120 		  "%d p:%08x req:%02hhx %02hhx val:%04hx %04hx buf:%d %d",
121 		  DEV_PR_ARG, __entry->ret, __entry->pipe, __entry->req,
122 		  __entry->req_type, __entry->val, __entry->offset,
123 		  !!__entry->buf, __entry->buflen)
124 );
125 
126 TRACE_EVENT(ee_read,
127 	TP_PROTO(struct mt7601u_dev *dev, int offset, u16 val),
128 	TP_ARGS(dev, offset, val),
129 	TP_STRUCT__entry(
130 		DEV_ENTRY
131 		__field(int, o) __field(u16, v)
132 	),
133 	TP_fast_assign(
134 		DEV_ASSIGN;
135 		__entry->o = offset;
136 		__entry->v = val;
137 	),
138 	TP_printk(DEV_PR_FMT "%04x=%04x", DEV_PR_ARG, __entry->o, __entry->v)
139 );
140 
141 DECLARE_EVENT_CLASS(dev_rf_reg_evt,
142 	TP_PROTO(struct mt7601u_dev *dev, u8 bank, u8 reg, u8 val),
143 	TP_ARGS(dev, bank, reg, val),
144 	TP_STRUCT__entry(
145 		DEV_ENTRY
146 		__field(u8, bank)
147 		__field(u8, reg)
148 		__field(u8, val)
149 	),
150 	TP_fast_assign(
151 		DEV_ASSIGN;
152 		REG_ASSIGN;
153 		__entry->bank = bank;
154 	),
155 	TP_printk(
156 		DEV_PR_FMT "%02hhx:%02hhx=%02hhx",
157 		DEV_PR_ARG, __entry->bank, __entry->reg, __entry->val
158 	)
159 );
160 
161 DEFINE_EVENT(dev_rf_reg_evt, rf_read,
162 	TP_PROTO(struct mt7601u_dev *dev, u8 bank, u8 reg, u8 val),
163 	TP_ARGS(dev, bank, reg, val)
164 );
165 
166 DEFINE_EVENT(dev_rf_reg_evt, rf_write,
167 	TP_PROTO(struct mt7601u_dev *dev, u8 bank, u8 reg, u8 val),
168 	TP_ARGS(dev, bank, reg, val)
169 );
170 
171 DECLARE_EVENT_CLASS(dev_bbp_reg_evt,
172 	TP_PROTO(struct mt7601u_dev *dev, u8 reg, u8 val),
173 	TP_ARGS(dev, reg, val),
174 	TP_STRUCT__entry(
175 		DEV_ENTRY
176 		__field(u8, reg)
177 		__field(u8, val)
178 	),
179 	TP_fast_assign(
180 		DEV_ASSIGN;
181 		REG_ASSIGN;
182 	),
183 	TP_printk(
184 		DEV_PR_FMT "%02hhx=%02hhx",
185 		DEV_PR_ARG, __entry->reg, __entry->val
186 	)
187 );
188 
189 DEFINE_EVENT(dev_bbp_reg_evt, bbp_read,
190 	TP_PROTO(struct mt7601u_dev *dev, u8 reg, u8 val),
191 	TP_ARGS(dev, reg, val)
192 );
193 
194 DEFINE_EVENT(dev_bbp_reg_evt, bbp_write,
195 	TP_PROTO(struct mt7601u_dev *dev, u8 reg, u8 val),
196 	TP_ARGS(dev, reg, val)
197 );
198 
199 DECLARE_EVENT_CLASS(dev_simple_evt,
200 	TP_PROTO(struct mt7601u_dev *dev, u8 val),
201 	TP_ARGS(dev, val),
202 	TP_STRUCT__entry(
203 		DEV_ENTRY
204 		__field(u8, val)
205 	),
206 	TP_fast_assign(
207 		DEV_ASSIGN;
208 		__entry->val = val;
209 	),
210 	TP_printk(
211 		DEV_PR_FMT "%02hhx", DEV_PR_ARG, __entry->val
212 	)
213 );
214 
215 DEFINE_EVENT(dev_simple_evt, temp_mode,
216 	TP_PROTO(struct mt7601u_dev *dev, u8 val),
217 	TP_ARGS(dev, val)
218 );
219 
220 DEFINE_EVENT(dev_simple_evt, read_temp,
221 	TP_PROTO(struct mt7601u_dev *dev, u8 val),
222 	TP_ARGS(dev, val)
223 );
224 
225 DEFINE_EVENT(dev_simple_evt, freq_cal_adjust,
226 	TP_PROTO(struct mt7601u_dev *dev, u8 val),
227 	TP_ARGS(dev, val)
228 );
229 
230 TRACE_EVENT(freq_cal_offset,
231 	TP_PROTO(struct mt7601u_dev *dev, u8 phy_mode, s8 freq_off),
232 	TP_ARGS(dev, phy_mode, freq_off),
233 	TP_STRUCT__entry(
234 		DEV_ENTRY
235 		__field(u8, phy_mode)
236 		__field(s8, freq_off)
237 	),
238 	TP_fast_assign(
239 		DEV_ASSIGN;
240 		__entry->phy_mode = phy_mode;
241 		__entry->freq_off = freq_off;
242 	),
243 	TP_printk(DEV_PR_FMT "phy:%02hhx off:%02hhx",
244 		  DEV_PR_ARG, __entry->phy_mode, __entry->freq_off)
245 );
246 
247 TRACE_EVENT(mt_rx,
248 	TP_PROTO(struct mt7601u_dev *dev, struct mt7601u_rxwi *rxwi, u32 f),
249 	TP_ARGS(dev, rxwi, f),
250 	TP_STRUCT__entry(
251 		DEV_ENTRY
252 		__field_struct(struct mt7601u_rxwi, rxwi)
253 		__field(u32, fce_info)
254 	),
255 	TP_fast_assign(
256 		DEV_ASSIGN;
257 		__entry->rxwi = *rxwi;
258 		__entry->fce_info = f;
259 	),
260 	TP_printk(DEV_PR_FMT "rxi:%08x ctl:%08x frag_sn:%04hx rate:%04hx "
261 		  "uknw:%02hhx z:%02hhx%02hhx%02hhx snr:%02hhx "
262 		  "ant:%02hhx gain:%02hhx freq_o:%02hhx "
263 		  "r:%08x ea:%08x fce:%08x", DEV_PR_ARG,
264 		  le32_to_cpu(__entry->rxwi.rxinfo),
265 		  le32_to_cpu(__entry->rxwi.ctl),
266 		  le16_to_cpu(__entry->rxwi.frag_sn),
267 		  le16_to_cpu(__entry->rxwi.rate),
268 		  __entry->rxwi.unknown,
269 		  __entry->rxwi.zero[0], __entry->rxwi.zero[1],
270 		  __entry->rxwi.zero[2],
271 		  __entry->rxwi.snr, __entry->rxwi.ant,
272 		  __entry->rxwi.gain, __entry->rxwi.freq_off,
273 		  __entry->rxwi.resv2, __entry->rxwi.expert_ant,
274 		  __entry->fce_info)
275 );
276 
277 TRACE_EVENT(mt_tx,
278 	TP_PROTO(struct mt7601u_dev *dev, struct sk_buff *skb,
279 		 struct mt76_sta *sta, struct mt76_txwi *h),
280 	TP_ARGS(dev, skb, sta, h),
281 	TP_STRUCT__entry(
282 		DEV_ENTRY
283 		__field_struct(struct mt76_txwi, h)
284 		__field(struct sk_buff *, skb)
285 		__field(struct mt76_sta *, sta)
286 	),
287 	TP_fast_assign(
288 		DEV_ASSIGN;
289 		__entry->h = *h;
290 		__entry->skb = skb;
291 		__entry->sta = sta;
292 	),
293 	TP_printk(DEV_PR_FMT "skb:%p sta:%p  flg:%04hx rate_ctl:%04hx "
294 		  "ack:%02hhx wcid:%02hhx len_ctl:%05hx", DEV_PR_ARG,
295 		  __entry->skb, __entry->sta,
296 		  le16_to_cpu(__entry->h.flags),
297 		  le16_to_cpu(__entry->h.rate_ctl),
298 		  __entry->h.ack_ctl, __entry->h.wcid,
299 		  le16_to_cpu(__entry->h.len_ctl))
300 );
301 
302 TRACE_EVENT(mt_tx_dma_done,
303 	TP_PROTO(struct mt7601u_dev *dev, struct sk_buff *skb),
304 	TP_ARGS(dev, skb),
305 	TP_STRUCT__entry(
306 		DEV_ENTRY
307 		__field(struct sk_buff *, skb)
308 	),
309 	TP_fast_assign(
310 		DEV_ASSIGN;
311 		__entry->skb = skb;
312 	),
313 	TP_printk(DEV_PR_FMT "%p", DEV_PR_ARG, __entry->skb)
314 );
315 
316 TRACE_EVENT(mt_tx_status_cleaned,
317 	TP_PROTO(struct mt7601u_dev *dev, int cleaned),
318 	TP_ARGS(dev, cleaned),
319 	TP_STRUCT__entry(
320 		DEV_ENTRY
321 		__field(int, cleaned)
322 	),
323 	TP_fast_assign(
324 		DEV_ASSIGN;
325 		__entry->cleaned = cleaned;
326 	),
327 	TP_printk(DEV_PR_FMT "%d", DEV_PR_ARG, __entry->cleaned)
328 );
329 
330 TRACE_EVENT(mt_tx_status,
331 	TP_PROTO(struct mt7601u_dev *dev, u32 stat1, u32 stat2),
332 	TP_ARGS(dev, stat1, stat2),
333 	TP_STRUCT__entry(
334 		DEV_ENTRY
335 		__field(u32, stat1)	__field(u32, stat2)
336 	),
337 	TP_fast_assign(
338 		DEV_ASSIGN;
339 		__entry->stat1 = stat1;
340 		__entry->stat2 = stat2;
341 	),
342 	TP_printk(DEV_PR_FMT "%08x %08x",
343 		  DEV_PR_ARG, __entry->stat1, __entry->stat2)
344 );
345 
346 TRACE_EVENT(mt_rx_dma_aggr,
347 	TP_PROTO(struct mt7601u_dev *dev, int cnt, bool paged),
348 	TP_ARGS(dev, cnt, paged),
349 	TP_STRUCT__entry(
350 		DEV_ENTRY
351 		__field(u8, cnt)
352 		__field(bool, paged)
353 	),
354 	TP_fast_assign(
355 		DEV_ASSIGN;
356 		__entry->cnt = cnt;
357 		__entry->paged = paged;
358 	),
359 	TP_printk(DEV_PR_FMT "cnt:%d paged:%d",
360 		  DEV_PR_ARG, __entry->cnt, __entry->paged)
361 );
362 
363 DEFINE_EVENT(dev_simple_evt, set_key,
364 	TP_PROTO(struct mt7601u_dev *dev, u8 val),
365 	TP_ARGS(dev, val)
366 );
367 
368 TRACE_EVENT(set_shared_key,
369 	TP_PROTO(struct mt7601u_dev *dev, u8 vid, u8 key),
370 	TP_ARGS(dev, vid, key),
371 	TP_STRUCT__entry(
372 		DEV_ENTRY
373 		__field(u8, vid)
374 		__field(u8, key)
375 	),
376 	TP_fast_assign(
377 		DEV_ASSIGN;
378 		__entry->vid = vid;
379 		__entry->key = key;
380 	),
381 	TP_printk(DEV_PR_FMT "phy:%02hhx off:%02hhx",
382 		  DEV_PR_ARG, __entry->vid, __entry->key)
383 );
384 
385 #endif
386 
387 #undef TRACE_INCLUDE_PATH
388 #define TRACE_INCLUDE_PATH .
389 #undef TRACE_INCLUDE_FILE
390 #define TRACE_INCLUDE_FILE trace
391 
392 #include <trace/define_trace.h>
393