• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: ISC
2 /*
3  * Copyright (c) 2013 Broadcom Corporation
4  */
5 #if !defined(BRCMF_TRACEPOINT_H_) || defined(TRACE_HEADER_MULTI_READ)
6 #define BRCMF_TRACEPOINT_H_
7 
8 #include <linux/types.h>
9 #include <linux/tracepoint.h>
10 
11 #ifndef CONFIG_BRCM_TRACING
12 
13 #undef TRACE_EVENT
14 #define TRACE_EVENT(name, proto, ...) \
15 static inline void trace_ ## name(proto) {}
16 
17 #undef DECLARE_EVENT_CLASS
18 #define DECLARE_EVENT_CLASS(...)
19 
20 #undef DEFINE_EVENT
21 #define DEFINE_EVENT(evt_class, name, proto, ...) \
22 static inline void trace_ ## name(proto) {}
23 
24 #endif /* CONFIG_BRCM_TRACING */
25 
26 #undef TRACE_SYSTEM
27 #define TRACE_SYSTEM	brcmfmac
28 
29 #define MAX_MSG_LEN		100
30 
31 TRACE_EVENT(brcmf_err,
32 	TP_PROTO(const char *func, struct va_format *vaf),
33 	TP_ARGS(func, vaf),
34 	TP_STRUCT__entry(
35 		__string(func, func)
36 		__dynamic_array(char, msg, MAX_MSG_LEN)
37 	),
38 	TP_fast_assign(
39 		__assign_str(func, func);
40 		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
41 				       MAX_MSG_LEN, vaf->fmt,
42 				       *vaf->va) >= MAX_MSG_LEN);
43 	),
44 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
45 );
46 
47 TRACE_EVENT(brcmf_dbg,
48 	TP_PROTO(u32 level, const char *func, struct va_format *vaf),
49 	TP_ARGS(level, func, vaf),
50 	TP_STRUCT__entry(
51 		__field(u32, level)
52 		__string(func, func)
53 		__dynamic_array(char, msg, MAX_MSG_LEN)
54 	),
55 	TP_fast_assign(
56 		__entry->level = level;
57 		__assign_str(func, func);
58 		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
59 				       MAX_MSG_LEN, vaf->fmt,
60 				       *vaf->va) >= MAX_MSG_LEN);
61 	),
62 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
63 );
64 
65 TRACE_EVENT(brcmf_hexdump,
66 	TP_PROTO(void *data, size_t len),
67 	TP_ARGS(data, len),
68 	TP_STRUCT__entry(
69 		__field(unsigned long, len)
70 		__field(unsigned long, addr)
71 		__dynamic_array(u8, hdata, len)
72 	),
73 	TP_fast_assign(
74 		__entry->len = len;
75 		__entry->addr = (unsigned long)data;
76 		memcpy(__get_dynamic_array(hdata), data, len);
77 	),
78 	TP_printk("hexdump [addr=%lx, length=%lu]", __entry->addr, __entry->len)
79 );
80 
81 TRACE_EVENT(brcmf_bcdchdr,
82 	TP_PROTO(void *data),
83 	TP_ARGS(data),
84 	TP_STRUCT__entry(
85 		__field(u8, flags)
86 		__field(u8, prio)
87 		__field(u8, flags2)
88 		__field(u32, siglen)
89 		__dynamic_array(u8, signal, *((u8 *)data + 3) * 4)
90 	),
91 	TP_fast_assign(
92 		__entry->flags = *(u8 *)data;
93 		__entry->prio = *((u8 *)data + 1);
94 		__entry->flags2 = *((u8 *)data + 2);
95 		__entry->siglen = *((u8 *)data + 3) * 4;
96 		memcpy(__get_dynamic_array(signal),
97 		       (u8 *)data + 4, __entry->siglen);
98 	),
99 	TP_printk("bcdc: prio=%d siglen=%d", __entry->prio, __entry->siglen)
100 );
101 
102 #ifndef SDPCM_RX
103 #define SDPCM_RX	0
104 #endif
105 #ifndef SDPCM_TX
106 #define SDPCM_TX	1
107 #endif
108 #ifndef SDPCM_GLOM
109 #define SDPCM_GLOM	2
110 #endif
111 
112 TRACE_EVENT(brcmf_sdpcm_hdr,
113 	TP_PROTO(u8 dir, void *data),
114 	TP_ARGS(dir, data),
115 	TP_STRUCT__entry(
116 		__field(u8, dir)
117 		__field(u16, len)
118 		__dynamic_array(u8, hdr, dir == SDPCM_GLOM ? 20 : 12)
119 	),
120 	TP_fast_assign(
121 		memcpy(__get_dynamic_array(hdr), data, dir == SDPCM_GLOM ? 20 : 12);
122 		__entry->len = *(u8 *)data | (*((u8 *)data + 1) << 8);
123 		__entry->dir = dir;
124 	),
125 	TP_printk("sdpcm: %s len %u, seq %d",
126 		  __entry->dir == SDPCM_RX ? "RX" : "TX",
127 		  __entry->len, ((u8 *)__get_dynamic_array(hdr))[4])
128 );
129 
130 #ifdef CONFIG_BRCM_TRACING
131 
132 #undef TRACE_INCLUDE_PATH
133 #define TRACE_INCLUDE_PATH .
134 #undef TRACE_INCLUDE_FILE
135 #define TRACE_INCLUDE_FILE tracepoint
136 
137 #include <trace/define_trace.h>
138 
139 #endif /* CONFIG_BRCM_TRACING */
140 
141 #endif /* BRCMF_TRACEPOINT_H_ */
142