xref: /freebsd/sys/contrib/dev/mediatek/mt76/trace.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1 /* SPDX-License-Identifier: ISC */
2 /*
3  * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4  */
5 
6 #if !defined(__MT76_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
7 #define __MT76_TRACE_H
8 
9 #include <linux/tracepoint.h>
10 #include "mt76.h"
11 
12 #undef TRACE_SYSTEM
13 #define TRACE_SYSTEM mt76
14 
15 #define MAXNAME		32
16 #define DEV_ENTRY	__array(char, wiphy_name, 32)
17 #define DEVICE_ASSIGN	strlcpy(__entry->wiphy_name,	\
18 				wiphy_name(dev->hw->wiphy), MAXNAME)
19 #define DEV_PR_FMT	"%s"
20 #define DEV_PR_ARG	__entry->wiphy_name
21 
22 #define REG_ENTRY	__field(u32, reg) __field(u32, val)
23 #define REG_ASSIGN	__entry->reg = reg; __entry->val = val
24 #define REG_PR_FMT	" %04x=%08x"
25 #define REG_PR_ARG	__entry->reg, __entry->val
26 
27 #define TXID_ENTRY	__field(u8, wcid) __field(u8, pktid)
28 #define TXID_ASSIGN	__entry->wcid = wcid; __entry->pktid = pktid
29 #define TXID_PR_FMT	" [%d:%d]"
30 #define TXID_PR_ARG	__entry->wcid, __entry->pktid
31 
32 DECLARE_EVENT_CLASS(dev_reg_evt,
33 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
34 	TP_ARGS(dev, reg, val),
35 	TP_STRUCT__entry(
36 		DEV_ENTRY
37 		REG_ENTRY
38 	),
39 	TP_fast_assign(
40 		DEVICE_ASSIGN;
41 		REG_ASSIGN;
42 	),
43 	TP_printk(
44 		DEV_PR_FMT REG_PR_FMT,
45 		DEV_PR_ARG, REG_PR_ARG
46 	)
47 );
48 
49 DEFINE_EVENT(dev_reg_evt, reg_rr,
50 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
51 	TP_ARGS(dev, reg, val)
52 );
53 
54 DEFINE_EVENT(dev_reg_evt, reg_wr,
55 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
56 	TP_ARGS(dev, reg, val)
57 );
58 
59 TRACE_EVENT(dev_irq,
60 	TP_PROTO(struct mt76_dev *dev, u32 val, u32 mask),
61 
62 	TP_ARGS(dev, val, mask),
63 
64 	TP_STRUCT__entry(
65 		DEV_ENTRY
66 		__field(u32, val)
67 		__field(u32, mask)
68 	),
69 
70 	TP_fast_assign(
71 		DEVICE_ASSIGN;
72 		__entry->val = val;
73 		__entry->mask = mask;
74 	),
75 
76 	TP_printk(
77 		DEV_PR_FMT " %08x & %08x",
78 		DEV_PR_ARG, __entry->val, __entry->mask
79 	)
80 );
81 
82 DECLARE_EVENT_CLASS(dev_txid_evt,
83 	TP_PROTO(struct mt76_dev *dev, u8 wcid, u8 pktid),
84 	TP_ARGS(dev, wcid, pktid),
85 	TP_STRUCT__entry(
86 		DEV_ENTRY
87 		TXID_ENTRY
88 	),
89 	TP_fast_assign(
90 		DEVICE_ASSIGN;
91 		TXID_ASSIGN;
92 	),
93 	TP_printk(
94 		DEV_PR_FMT TXID_PR_FMT,
95 		DEV_PR_ARG, TXID_PR_ARG
96 	)
97 );
98 
99 DEFINE_EVENT(dev_txid_evt, mac_txdone,
100 	TP_PROTO(struct mt76_dev *dev, u8 wcid, u8 pktid),
101 	TP_ARGS(dev, wcid, pktid)
102 );
103 
104 #endif
105 
106 #undef TRACE_INCLUDE_PATH
107 #define TRACE_INCLUDE_PATH .
108 #undef TRACE_INCLUDE_FILE
109 #define TRACE_INCLUDE_FILE trace
110 
111 #include <trace/define_trace.h>
112