xref: /freebsd/sys/contrib/dev/mediatek/mt76/mt76x02_trace.h (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
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	strscpy(__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_PR_FMT	" [%d:%d]"
24 #define TXID_PR_ARG	__entry->wcid, __entry->pktid
25 
26 DECLARE_EVENT_CLASS(dev_evt,
27 	TP_PROTO(struct mt76x02_dev *dev),
28 	TP_ARGS(dev),
29 	TP_STRUCT__entry(
30 		DEV_ENTRY
31 	),
32 	TP_fast_assign(
33 		DEV_ASSIGN;
34 	),
35 	TP_printk(DEV_PR_FMT, DEV_PR_ARG)
36 );
37 
38 DEFINE_EVENT(dev_evt, mac_txstat_poll,
39 	TP_PROTO(struct mt76x02_dev *dev),
40 	TP_ARGS(dev)
41 );
42 
43 TRACE_EVENT(mac_txstat_fetch,
44 	TP_PROTO(struct mt76x02_dev *dev,
45 		 struct mt76x02_tx_status *stat),
46 
47 	TP_ARGS(dev, stat),
48 
49 	TP_STRUCT__entry(
50 		DEV_ENTRY
51 		TXID_ENTRY
52 		__field(bool, success)
53 		__field(bool, aggr)
54 		__field(bool, ack_req)
55 		__field(u16, rate)
56 		__field(u8, retry)
57 	),
58 
59 	TP_fast_assign(
60 		DEV_ASSIGN;
61 		__entry->success = stat->success;
62 		__entry->aggr = stat->aggr;
63 		__entry->ack_req = stat->ack_req;
64 		__entry->wcid = stat->wcid;
65 		__entry->pktid = stat->pktid;
66 		__entry->rate = stat->rate;
67 		__entry->retry = stat->retry;
68 	),
69 
70 	TP_printk(
71 		DEV_PR_FMT TXID_PR_FMT
72 		" success:%d aggr:%d ack_req:%d"
73 		" rate:%04x retry:%d",
74 		DEV_PR_ARG, TXID_PR_ARG,
75 		__entry->success, __entry->aggr, __entry->ack_req,
76 		__entry->rate, __entry->retry
77 	)
78 );
79 
80 #endif
81 
82 #undef TRACE_INCLUDE_PATH
83 #define TRACE_INCLUDE_PATH .
84 #undef TRACE_INCLUDE_FILE
85 #define TRACE_INCLUDE_FILE mt76x02_trace
86 
87 #include <trace/define_trace.h>
88