1 /* SPDX-License-Identifier: ISC */
2 /*
3  * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
4  */
5 
6 #if !defined(__MT76_USB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
7 #define __MT76_USB_TRACE_H
8 
9 #include <linux/tracepoint.h>
10 #include "mt76.h"
11 
12 #undef TRACE_SYSTEM
13 #define TRACE_SYSTEM mt76_usb
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(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	"reg:0x%04x=0x%08x"
25 #define REG_PR_ARG	__entry->reg, __entry->val
26 
27 DECLARE_EVENT_CLASS(dev_reg_evt,
28 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
29 	TP_ARGS(dev, reg, val),
30 	TP_STRUCT__entry(
31 		DEV_ENTRY
32 		REG_ENTRY
33 	),
34 	TP_fast_assign(
35 		DEV_ASSIGN;
36 		REG_ASSIGN;
37 	),
38 	TP_printk(
39 		DEV_PR_FMT REG_PR_FMT,
40 		DEV_PR_ARG, REG_PR_ARG
41 	)
42 );
43 
44 DEFINE_EVENT(dev_reg_evt, usb_reg_rr,
45 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
46 	TP_ARGS(dev, reg, val)
47 );
48 
49 DEFINE_EVENT(dev_reg_evt, usb_reg_wr,
50 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
51 	TP_ARGS(dev, reg, val)
52 );
53 
54 DECLARE_EVENT_CLASS(urb_transfer,
55 	TP_PROTO(struct mt76_dev *dev, struct urb *u),
56 	TP_ARGS(dev, u),
57 	TP_STRUCT__entry(
58 		DEV_ENTRY __field(unsigned int, pipe) __field(u32, len)
59 	),
60 	TP_fast_assign(
61 		DEV_ASSIGN;
62 		__entry->pipe = u->pipe;
63 		__entry->len = u->transfer_buffer_length;
64 	),
65 	TP_printk(DEV_PR_FMT "p:%08x len:%u",
66 		  DEV_PR_ARG, __entry->pipe, __entry->len)
67 );
68 
69 DEFINE_EVENT(urb_transfer, submit_urb,
70 	TP_PROTO(struct mt76_dev *dev, struct urb *u),
71 	TP_ARGS(dev, u)
72 );
73 
74 DEFINE_EVENT(urb_transfer, rx_urb,
75 	TP_PROTO(struct mt76_dev *dev, struct urb *u),
76 	TP_ARGS(dev, u)
77 );
78 
79 #endif
80 
81 #undef TRACE_INCLUDE_PATH
82 #define TRACE_INCLUDE_PATH .
83 #undef TRACE_INCLUDE_FILE
84 #define TRACE_INCLUDE_FILE usb_trace
85 
86 #include <trace/define_trace.h>
87