1 /* SPDX-License-Identifier: ISC */
2 /*
3  * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4  */
5 
6 #if !defined(__MT76x02_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
7 #define __MT76x02_TRACE_H
8 
9 #include <linux/tracepoint.h>
10 #include "mt76x02.h"
11 
12 #undef TRACE_SYSTEM
13 #define TRACE_SYSTEM mt76x02
14 
15 #define MAXNAME		32
16 #define DEV_ENTRY	__array(char, wiphy_name, 32)
17 #define DEV_ASSIGN	strlcpy(__entry->wiphy_name,	\
18 				wiphy_name(mt76_hw(dev)->wiphy), MAXNAME)
19 #define DEV_PR_FMT	"%s"
20 #define DEV_PR_ARG	__entry->wiphy_name
21 
22 #define TXID_ENTRY	__field(u8, wcid) __field(u8, pktid)
23 #define TXID_ASSIGN	__entry->wcid = wcid; __entry->pktid = pktid
24 #define TXID_PR_FMT	" [%d:%d]"
25 #define TXID_PR_ARG	__entry->wcid, __entry->pktid
26 
27 DECLARE_EVENT_CLASS(dev_evt,
28 	TP_PROTO(struct mt76x02_dev *dev),
29 	TP_ARGS(dev),
30 	TP_STRUCT__entry(
31 		DEV_ENTRY
32 	),
33 	TP_fast_assign(
34 		DEV_ASSIGN;
35 	),
36 	TP_printk(DEV_PR_FMT, DEV_PR_ARG)
37 );
38 
39 DECLARE_EVENT_CLASS(dev_txid_evt,
40 	TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
41 	TP_ARGS(dev, wcid, pktid),
42 	TP_STRUCT__entry(
43 		DEV_ENTRY
44 		TXID_ENTRY
45 	),
46 	TP_fast_assign(
47 		DEV_ASSIGN;
48 		TXID_ASSIGN;
49 	),
50 	TP_printk(
51 		DEV_PR_FMT TXID_PR_FMT,
52 		DEV_PR_ARG, TXID_PR_ARG
53 	)
54 );
55 
56 DEFINE_EVENT(dev_txid_evt, mac_txdone_add,
57 	TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
58 	TP_ARGS(dev, wcid, pktid)
59 );
60 
61 DEFINE_EVENT(dev_evt, mac_txstat_poll,
62 	TP_PROTO(struct mt76x02_dev *dev),
63 	TP_ARGS(dev)
64 );
65 
66 TRACE_EVENT(mac_txstat_fetch,
67 	TP_PROTO(struct mt76x02_dev *dev,
68 		 struct mt76x02_tx_status *stat),
69 
70 	TP_ARGS(dev, stat),
71 
72 	TP_STRUCT__entry(
73 		DEV_ENTRY
74 		TXID_ENTRY
75 		__field(bool, success)
76 		__field(bool, aggr)
77 		__field(bool, ack_req)
78 		__field(u16, rate)
79 		__field(u8, retry)
80 	),
81 
82 	TP_fast_assign(
83 		DEV_ASSIGN;
84 		__entry->success = stat->success;
85 		__entry->aggr = stat->aggr;
86 		__entry->ack_req = stat->ack_req;
87 		__entry->wcid = stat->wcid;
88 		__entry->pktid = stat->pktid;
89 		__entry->rate = stat->rate;
90 		__entry->retry = stat->retry;
91 	),
92 
93 	TP_printk(
94 		DEV_PR_FMT TXID_PR_FMT
95 		" success:%d aggr:%d ack_req:%d"
96 		" rate:%04x retry:%d",
97 		DEV_PR_ARG, TXID_PR_ARG,
98 		__entry->success, __entry->aggr, __entry->ack_req,
99 		__entry->rate, __entry->retry
100 	)
101 );
102 
103 TRACE_EVENT(dev_irq,
104 	TP_PROTO(struct mt76x02_dev *dev, u32 val, u32 mask),
105 
106 	TP_ARGS(dev, val, mask),
107 
108 	TP_STRUCT__entry(
109 		DEV_ENTRY
110 		__field(u32, val)
111 		__field(u32, mask)
112 	),
113 
114 	TP_fast_assign(
115 		DEV_ASSIGN;
116 		__entry->val = val;
117 		__entry->mask = mask;
118 	),
119 
120 	TP_printk(
121 		DEV_PR_FMT " %08x & %08x",
122 		DEV_PR_ARG, __entry->val, __entry->mask
123 	)
124 );
125 
126 #endif
127 
128 #undef TRACE_INCLUDE_PATH
129 #define TRACE_INCLUDE_PATH .
130 #undef TRACE_INCLUDE_FILE
131 #define TRACE_INCLUDE_FILE mt76x02_trace
132 
133 #include <trace/define_trace.h>
134