2 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #if !defined(__MT7601U_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
16 #define __MT7601U_TRACE_H
18 #include <linux/tracepoint.h>
23 #define TRACE_SYSTEM mt7601u
26 #define DEV_ENTRY __array(char, wiphy_name, 32)
27 #define DEV_ASSIGN strlcpy(__entry->wiphy_name, \
28 wiphy_name(dev->hw->wiphy), MAXNAME)
29 #define DEV_PR_FMT "%s "
30 #define DEV_PR_ARG __entry->wiphy_name
32 #define REG_ENTRY __field(u32, reg) __field(u32, val)
33 #define REG_ASSIGN __entry->reg = reg; __entry->val = val
34 #define REG_PR_FMT "%04x=%08x"
35 #define REG_PR_ARG __entry->reg, __entry->val
37 DECLARE_EVENT_CLASS(dev_reg_evt
,
38 TP_PROTO(struct mt7601u_dev
*dev
, u32 reg
, u32 val
),
39 TP_ARGS(dev
, reg
, val
),
49 DEV_PR_FMT REG_PR_FMT
,
50 DEV_PR_ARG
, REG_PR_ARG
54 DEFINE_EVENT(dev_reg_evt
, reg_read
,
55 TP_PROTO(struct mt7601u_dev
*dev
, u32 reg
, u32 val
),
56 TP_ARGS(dev
, reg
, val
)
59 DEFINE_EVENT(dev_reg_evt
, reg_write
,
60 TP_PROTO(struct mt7601u_dev
*dev
, u32 reg
, u32 val
),
61 TP_ARGS(dev
, reg
, val
)
64 TRACE_EVENT(mt_submit_urb
,
65 TP_PROTO(struct mt7601u_dev
*dev
, struct urb
*u
),
68 DEV_ENTRY
__field(unsigned, pipe
) __field(u32
, len
)
72 __entry
->pipe
= u
->pipe
;
73 __entry
->len
= u
->transfer_buffer_length
;
75 TP_printk(DEV_PR_FMT
"p:%08x len:%u",
76 DEV_PR_ARG
, __entry
->pipe
, __entry
->len
)
79 #define trace_mt_submit_urb_sync(__dev, __pipe, __len) ({ \
82 u.transfer_buffer_length = __len; \
83 trace_mt_submit_urb(__dev, &u); \
86 TRACE_EVENT(mt_mcu_msg_send
,
87 TP_PROTO(struct mt7601u_dev
*dev
,
88 struct sk_buff
*skb
, u32 csum
, bool resp
),
89 TP_ARGS(dev
, skb
, csum
, resp
),
98 __entry
->info
= *(u32
*)skb
->data
;
100 __entry
->resp
= resp
;
102 TP_printk(DEV_PR_FMT
"i:%08x c:%08x r:%d",
103 DEV_PR_ARG
, __entry
->info
, __entry
->csum
, __entry
->resp
)
106 TRACE_EVENT(mt_vend_req
,
107 TP_PROTO(struct mt7601u_dev
*dev
, unsigned pipe
, u8 req
, u8 req_type
,
108 u16 val
, u16 offset
, void *buf
, size_t buflen
, int ret
),
109 TP_ARGS(dev
, pipe
, req
, req_type
, val
, offset
, buf
, buflen
, ret
),
112 __field(unsigned, pipe
) __field(u8
, req
) __field(u8
, req_type
)
113 __field(u16
, val
) __field(u16
, offset
) __field(void*, buf
)
114 __field(int, buflen
) __field(int, ret
)
118 __entry
->pipe
= pipe
;
120 __entry
->req_type
= req_type
;
122 __entry
->offset
= offset
;
124 __entry
->buflen
= buflen
;
128 "%d p:%08x req:%02hhx %02hhx val:%04hx %04hx buf:%d %d",
129 DEV_PR_ARG
, __entry
->ret
, __entry
->pipe
, __entry
->req
,
130 __entry
->req_type
, __entry
->val
, __entry
->offset
,
131 !!__entry
->buf
, __entry
->buflen
)
135 TP_PROTO(struct mt7601u_dev
*dev
, int offset
, u16 val
),
136 TP_ARGS(dev
, offset
, val
),
139 __field(int, o
) __field(u16
, v
)
146 TP_printk(DEV_PR_FMT
"%04x=%04x", DEV_PR_ARG
, __entry
->o
, __entry
->v
)
149 DECLARE_EVENT_CLASS(dev_rf_reg_evt
,
150 TP_PROTO(struct mt7601u_dev
*dev
, u8 bank
, u8 reg
, u8 val
),
151 TP_ARGS(dev
, bank
, reg
, val
),
161 __entry
->bank
= bank
;
164 DEV_PR_FMT
"%02hhx:%02hhx=%02hhx",
165 DEV_PR_ARG
, __entry
->bank
, __entry
->reg
, __entry
->val
169 DEFINE_EVENT(dev_rf_reg_evt
, rf_read
,
170 TP_PROTO(struct mt7601u_dev
*dev
, u8 bank
, u8 reg
, u8 val
),
171 TP_ARGS(dev
, bank
, reg
, val
)
174 DEFINE_EVENT(dev_rf_reg_evt
, rf_write
,
175 TP_PROTO(struct mt7601u_dev
*dev
, u8 bank
, u8 reg
, u8 val
),
176 TP_ARGS(dev
, bank
, reg
, val
)
179 DECLARE_EVENT_CLASS(dev_bbp_reg_evt
,
180 TP_PROTO(struct mt7601u_dev
*dev
, u8 reg
, u8 val
),
181 TP_ARGS(dev
, reg
, val
),
192 DEV_PR_FMT
"%02hhx=%02hhx",
193 DEV_PR_ARG
, __entry
->reg
, __entry
->val
197 DEFINE_EVENT(dev_bbp_reg_evt
, bbp_read
,
198 TP_PROTO(struct mt7601u_dev
*dev
, u8 reg
, u8 val
),
199 TP_ARGS(dev
, reg
, val
)
202 DEFINE_EVENT(dev_bbp_reg_evt
, bbp_write
,
203 TP_PROTO(struct mt7601u_dev
*dev
, u8 reg
, u8 val
),
204 TP_ARGS(dev
, reg
, val
)
207 DECLARE_EVENT_CLASS(dev_simple_evt
,
208 TP_PROTO(struct mt7601u_dev
*dev
, u8 val
),
219 DEV_PR_FMT
"%02hhx", DEV_PR_ARG
, __entry
->val
223 DEFINE_EVENT(dev_simple_evt
, temp_mode
,
224 TP_PROTO(struct mt7601u_dev
*dev
, u8 val
),
228 DEFINE_EVENT(dev_simple_evt
, read_temp
,
229 TP_PROTO(struct mt7601u_dev
*dev
, u8 val
),
233 DEFINE_EVENT(dev_simple_evt
, freq_cal_adjust
,
234 TP_PROTO(struct mt7601u_dev
*dev
, u8 val
),
238 TRACE_EVENT(freq_cal_offset
,
239 TP_PROTO(struct mt7601u_dev
*dev
, u8 phy_mode
, s8 freq_off
),
240 TP_ARGS(dev
, phy_mode
, freq_off
),
243 __field(u8
, phy_mode
)
244 __field(s8
, freq_off
)
248 __entry
->phy_mode
= phy_mode
;
249 __entry
->freq_off
= freq_off
;
251 TP_printk(DEV_PR_FMT
"phy:%02hhx off:%02hhx",
252 DEV_PR_ARG
, __entry
->phy_mode
, __entry
->freq_off
)
256 TP_PROTO(struct mt7601u_dev
*dev
, struct mt7601u_rxwi
*rxwi
, u32 f
),
257 TP_ARGS(dev
, rxwi
, f
),
260 __field_struct(struct mt7601u_rxwi
, rxwi
)
261 __field(u32
, fce_info
)
265 __entry
->rxwi
= *rxwi
;
266 __entry
->fce_info
= f
;
268 TP_printk(DEV_PR_FMT
"rxi:%08x ctl:%08x frag_sn:%04hx rate:%04hx "
269 "uknw:%02hhx z:%02hhx%02hhx%02hhx snr:%02hhx "
270 "ant:%02hhx gain:%02hhx freq_o:%02hhx "
271 "r:%08x ea:%08x fce:%08x", DEV_PR_ARG
,
272 le32_to_cpu(__entry
->rxwi
.rxinfo
),
273 le32_to_cpu(__entry
->rxwi
.ctl
),
274 le16_to_cpu(__entry
->rxwi
.frag_sn
),
275 le16_to_cpu(__entry
->rxwi
.rate
),
276 __entry
->rxwi
.unknown
,
277 __entry
->rxwi
.zero
[0], __entry
->rxwi
.zero
[1],
278 __entry
->rxwi
.zero
[2],
279 __entry
->rxwi
.snr
, __entry
->rxwi
.ant
,
280 __entry
->rxwi
.gain
, __entry
->rxwi
.freq_off
,
281 __entry
->rxwi
.resv2
, __entry
->rxwi
.expert_ant
,
286 TP_PROTO(struct mt7601u_dev
*dev
, struct sk_buff
*skb
,
287 struct mt76_sta
*sta
, struct mt76_txwi
*h
),
288 TP_ARGS(dev
, skb
, sta
, h
),
291 __field_struct(struct mt76_txwi
, h
)
292 __field(struct sk_buff
*, skb
)
293 __field(struct mt76_sta
*, sta
)
301 TP_printk(DEV_PR_FMT
"skb:%p sta:%p flg:%04hx rate_ctl:%04hx "
302 "ack:%02hhx wcid:%02hhx len_ctl:%05hx", DEV_PR_ARG
,
303 __entry
->skb
, __entry
->sta
,
304 le16_to_cpu(__entry
->h
.flags
),
305 le16_to_cpu(__entry
->h
.rate_ctl
),
306 __entry
->h
.ack_ctl
, __entry
->h
.wcid
,
307 le16_to_cpu(__entry
->h
.len_ctl
))
310 TRACE_EVENT(mt_tx_dma_done
,
311 TP_PROTO(struct mt7601u_dev
*dev
, struct sk_buff
*skb
),
315 __field(struct sk_buff
*, skb
)
321 TP_printk(DEV_PR_FMT
"%p", DEV_PR_ARG
, __entry
->skb
)
324 TRACE_EVENT(mt_tx_status_cleaned
,
325 TP_PROTO(struct mt7601u_dev
*dev
, int cleaned
),
326 TP_ARGS(dev
, cleaned
),
329 __field(int, cleaned
)
333 __entry
->cleaned
= cleaned
;
335 TP_printk(DEV_PR_FMT
"%d", DEV_PR_ARG
, __entry
->cleaned
)
338 TRACE_EVENT(mt_tx_status
,
339 TP_PROTO(struct mt7601u_dev
*dev
, u32 stat1
, u32 stat2
),
340 TP_ARGS(dev
, stat1
, stat2
),
343 __field(u32
, stat1
) __field(u32
, stat2
)
347 __entry
->stat1
= stat1
;
348 __entry
->stat2
= stat2
;
350 TP_printk(DEV_PR_FMT
"%08x %08x",
351 DEV_PR_ARG
, __entry
->stat1
, __entry
->stat2
)
354 TRACE_EVENT(mt_rx_dma_aggr
,
355 TP_PROTO(struct mt7601u_dev
*dev
, int cnt
, bool paged
),
356 TP_ARGS(dev
, cnt
, paged
),
365 __entry
->paged
= paged
;
367 TP_printk(DEV_PR_FMT
"cnt:%d paged:%d",
368 DEV_PR_ARG
, __entry
->cnt
, __entry
->paged
)
371 DEFINE_EVENT(dev_simple_evt
, set_key
,
372 TP_PROTO(struct mt7601u_dev
*dev
, u8 val
),
376 TRACE_EVENT(set_shared_key
,
377 TP_PROTO(struct mt7601u_dev
*dev
, u8 vid
, u8 key
),
378 TP_ARGS(dev
, vid
, key
),
389 TP_printk(DEV_PR_FMT
"phy:%02hhx off:%02hhx",
390 DEV_PR_ARG
, __entry
->vid
, __entry
->key
)
395 #undef TRACE_INCLUDE_PATH
396 #define TRACE_INCLUDE_PATH .
397 #undef TRACE_INCLUDE_FILE
398 #define TRACE_INCLUDE_FILE trace
400 #include <trace/define_trace.h>