1 /*
2  * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
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(__MT76_USB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
18 #define __MT76_USB_TRACE_H
19 
20 #include <linux/tracepoint.h>
21 #include "mt76.h"
22 
23 #undef TRACE_SYSTEM
24 #define TRACE_SYSTEM mt76_usb
25 
26 #define MAXNAME		32
27 #define DEV_ENTRY   __array(char, wiphy_name, 32)
28 #define DEV_ASSIGN  strlcpy(__entry->wiphy_name, wiphy_name(dev->hw->wiphy), MAXNAME)
29 #define DEV_PR_FMT  "%s "
30 #define DEV_PR_ARG  __entry->wiphy_name
31 
32 #define REG_ENTRY	__field(u32, reg) __field(u32, val)
33 #define REG_ASSIGN	__entry->reg = reg; __entry->val = val
34 #define REG_PR_FMT	"reg:0x%04x=0x%08x"
35 #define REG_PR_ARG	__entry->reg, __entry->val
36 
37 DECLARE_EVENT_CLASS(dev_reg_evt,
38 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
39 	TP_ARGS(dev, reg, val),
40 	TP_STRUCT__entry(
41 		DEV_ENTRY
42 		REG_ENTRY
43 	),
44 	TP_fast_assign(
45 		DEV_ASSIGN;
46 		REG_ASSIGN;
47 	),
48 	TP_printk(
49 		DEV_PR_FMT REG_PR_FMT,
50 		DEV_PR_ARG, REG_PR_ARG
51 	)
52 );
53 
54 DEFINE_EVENT(dev_reg_evt, usb_reg_rr,
55 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
56 	TP_ARGS(dev, reg, val)
57 );
58 
59 DEFINE_EVENT(dev_reg_evt, usb_reg_wr,
60 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
61 	TP_ARGS(dev, reg, val)
62 );
63 
64 DECLARE_EVENT_CLASS(urb_transfer,
65 	TP_PROTO(struct mt76_dev *dev, struct urb *u),
66 	TP_ARGS(dev, u),
67 	TP_STRUCT__entry(
68 		DEV_ENTRY __field(unsigned, pipe) __field(u32, len)
69 	),
70 	TP_fast_assign(
71 		DEV_ASSIGN;
72 		__entry->pipe = u->pipe;
73 		__entry->len = u->transfer_buffer_length;
74 	),
75 	TP_printk(DEV_PR_FMT "p:%08x len:%u",
76 		  DEV_PR_ARG, __entry->pipe, __entry->len)
77 );
78 
79 DEFINE_EVENT(urb_transfer, submit_urb,
80 	TP_PROTO(struct mt76_dev *dev, struct urb *u),
81 	TP_ARGS(dev, u)
82 );
83 
84 DEFINE_EVENT(urb_transfer, rx_urb,
85 	TP_PROTO(struct mt76_dev *dev, struct urb *u),
86 	TP_ARGS(dev, u)
87 );
88 
89 #endif
90 
91 #undef TRACE_INCLUDE_PATH
92 #define TRACE_INCLUDE_PATH .
93 #undef TRACE_INCLUDE_FILE
94 #define TRACE_INCLUDE_FILE usb_trace
95 
96 #include <trace/define_trace.h>
97