1 /*
2  * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #if !defined(__MT76x02_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
18 #define __MT76x02_TRACE_H
19 
20 #include <linux/tracepoint.h>
21 #include "mt76x02.h"
22 
23 #undef TRACE_SYSTEM
24 #define TRACE_SYSTEM mt76x02
25 
26 #define MAXNAME		32
27 #define DEV_ENTRY	__array(char, wiphy_name, 32)
28 #define DEV_ASSIGN	strlcpy(__entry->wiphy_name, wiphy_name(mt76_hw(dev)->wiphy), MAXNAME)
29 #define DEV_PR_FMT	"%s"
30 #define DEV_PR_ARG	__entry->wiphy_name
31 
32 #define TXID_ENTRY	__field(u8, wcid) __field(u8, pktid)
33 #define TXID_ASSIGN	__entry->wcid = wcid; __entry->pktid = pktid
34 #define TXID_PR_FMT	" [%d:%d]"
35 #define TXID_PR_ARG	__entry->wcid, __entry->pktid
36 
37 DECLARE_EVENT_CLASS(dev_evt,
38 	TP_PROTO(struct mt76x02_dev *dev),
39 	TP_ARGS(dev),
40 	TP_STRUCT__entry(
41 		DEV_ENTRY
42 	),
43 	TP_fast_assign(
44 		DEV_ASSIGN;
45 	),
46 	TP_printk(DEV_PR_FMT, DEV_PR_ARG)
47 );
48 
49 DECLARE_EVENT_CLASS(dev_txid_evt,
50 	TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
51 	TP_ARGS(dev, wcid, pktid),
52 	TP_STRUCT__entry(
53 		DEV_ENTRY
54 		TXID_ENTRY
55 	),
56 	TP_fast_assign(
57 		DEV_ASSIGN;
58 		TXID_ASSIGN;
59 	),
60 	TP_printk(
61 		DEV_PR_FMT TXID_PR_FMT,
62 		DEV_PR_ARG, TXID_PR_ARG
63 	)
64 );
65 
66 DEFINE_EVENT(dev_txid_evt, mac_txdone_add,
67 	TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
68 	TP_ARGS(dev, wcid, pktid)
69 );
70 
71 DEFINE_EVENT(dev_evt, mac_txstat_poll,
72 	TP_PROTO(struct mt76x02_dev *dev),
73 	TP_ARGS(dev)
74 );
75 
76 TRACE_EVENT(mac_txstat_fetch,
77 	TP_PROTO(struct mt76x02_dev *dev,
78 		 struct mt76x02_tx_status *stat),
79 
80 	TP_ARGS(dev, stat),
81 
82 	TP_STRUCT__entry(
83 		DEV_ENTRY
84 		TXID_ENTRY
85 		__field(bool, success)
86 		__field(bool, aggr)
87 		__field(bool, ack_req)
88 		__field(u16, rate)
89 		__field(u8, retry)
90 	),
91 
92 	TP_fast_assign(
93 		DEV_ASSIGN;
94 		__entry->success = stat->success;
95 		__entry->aggr = stat->aggr;
96 		__entry->ack_req = stat->ack_req;
97 		__entry->wcid = stat->wcid;
98 		__entry->pktid = stat->pktid;
99 		__entry->rate = stat->rate;
100 		__entry->retry = stat->retry;
101 	),
102 
103 	TP_printk(
104 		DEV_PR_FMT TXID_PR_FMT
105 		" success:%d aggr:%d ack_req:%d"
106 		" rate:%04x retry:%d",
107 		DEV_PR_ARG, TXID_PR_ARG,
108 		__entry->success, __entry->aggr, __entry->ack_req,
109 		__entry->rate, __entry->retry
110 	)
111 );
112 
113 TRACE_EVENT(dev_irq,
114 	TP_PROTO(struct mt76x02_dev *dev, u32 val, u32 mask),
115 
116 	TP_ARGS(dev, val, mask),
117 
118 	TP_STRUCT__entry(
119 		DEV_ENTRY
120 		__field(u32, val)
121 		__field(u32, mask)
122 	),
123 
124 	TP_fast_assign(
125 		DEV_ASSIGN;
126 		__entry->val = val;
127 		__entry->mask = mask;
128 	),
129 
130 	TP_printk(
131 		DEV_PR_FMT " %08x & %08x",
132 		DEV_PR_ARG, __entry->val, __entry->mask
133 	)
134 );
135 
136 #endif
137 
138 #undef TRACE_INCLUDE_PATH
139 #define TRACE_INCLUDE_PATH .
140 #undef TRACE_INCLUDE_FILE
141 #define TRACE_INCLUDE_FILE mt76x02_trace
142 
143 #include <trace/define_trace.h>
144