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(__MT76_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
18 #define __MT76_TRACE_H
19 
20 #include <linux/tracepoint.h>
21 #include "mt76.h"
22 
23 #undef TRACE_SYSTEM
24 #define TRACE_SYSTEM mt76
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	" %04x=%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, 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, reg_wr,
60 	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
61 	TP_ARGS(dev, reg, val)
62 );
63 
64 #endif
65 
66 #undef TRACE_INCLUDE_PATH
67 #define TRACE_INCLUDE_PATH .
68 #undef TRACE_INCLUDE_FILE
69 #define TRACE_INCLUDE_FILE trace
70 
71 #include <trace/define_trace.h>
72