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 #pragma GCC diagnostic push 32 #ifndef __clang__ 33 #pragma GCC diagnostic ignored "-Wsuggest-attribute=format" 34 #endif 35 36 TRACE_EVENT(brcmf_err, 37 TP_PROTO(const char *func, struct va_format *vaf), 38 TP_ARGS(func, vaf), 39 TP_STRUCT__entry( 40 __string(func, func) 41 __vstring(msg, vaf->fmt, vaf->va) 42 ), 43 TP_fast_assign( 44 __assign_str(func); 45 __assign_vstr(msg, vaf->fmt, vaf->va); 46 ), 47 TP_printk("%s: %s", __get_str(func), __get_str(msg)) 48 ); 49 50 TRACE_EVENT(brcmf_dbg, 51 TP_PROTO(u32 level, const char *func, struct va_format *vaf), 52 TP_ARGS(level, func, vaf), 53 TP_STRUCT__entry( 54 __field(u32, level) 55 __string(func, func) 56 __vstring(msg, vaf->fmt, vaf->va) 57 ), 58 TP_fast_assign( 59 __entry->level = level; 60 __assign_str(func); 61 __assign_vstr(msg, vaf->fmt, vaf->va); 62 ), 63 TP_printk("%s: %s", __get_str(func), __get_str(msg)) 64 ); 65 66 TRACE_EVENT(brcmf_hexdump, 67 TP_PROTO(void *data, size_t len), 68 TP_ARGS(data, len), 69 TP_STRUCT__entry( 70 __field(unsigned long, len) 71 __field(unsigned long, addr) 72 __dynamic_array(u8, hdata, len) 73 ), 74 TP_fast_assign( 75 __entry->len = len; 76 __entry->addr = (unsigned long)data; 77 memcpy(__get_dynamic_array(hdata), data, len); 78 ), 79 TP_printk("hexdump [addr=%lx, length=%lu]", __entry->addr, __entry->len) 80 ); 81 82 TRACE_EVENT(brcmf_bcdchdr, 83 TP_PROTO(void *data), 84 TP_ARGS(data), 85 TP_STRUCT__entry( 86 __field(u8, flags) 87 __field(u8, prio) 88 __field(u8, flags2) 89 __field(u32, siglen) 90 __dynamic_array(u8, signal, *((u8 *)data + 3) * 4) 91 ), 92 TP_fast_assign( 93 __entry->flags = *(u8 *)data; 94 __entry->prio = *((u8 *)data + 1); 95 __entry->flags2 = *((u8 *)data + 2); 96 __entry->siglen = *((u8 *)data + 3) * 4; 97 memcpy(__get_dynamic_array(signal), 98 (u8 *)data + 4, __entry->siglen); 99 ), 100 TP_printk("bcdc: prio=%d siglen=%d", __entry->prio, __entry->siglen) 101 ); 102 103 #ifndef SDPCM_RX 104 #define SDPCM_RX 0 105 #endif 106 #ifndef SDPCM_TX 107 #define SDPCM_TX 1 108 #endif 109 #ifndef SDPCM_GLOM 110 #define SDPCM_GLOM 2 111 #endif 112 113 TRACE_EVENT(brcmf_sdpcm_hdr, 114 TP_PROTO(u8 dir, void *data), 115 TP_ARGS(dir, data), 116 TP_STRUCT__entry( 117 __field(u8, dir) 118 __field(u16, len) 119 __dynamic_array(u8, hdr, dir == SDPCM_GLOM ? 20 : 12) 120 ), 121 TP_fast_assign( 122 memcpy(__get_dynamic_array(hdr), data, dir == SDPCM_GLOM ? 20 : 12); 123 __entry->len = *(u8 *)data | (*((u8 *)data + 1) << 8); 124 __entry->dir = dir; 125 ), 126 TP_printk("sdpcm: %s len %u, seq %d", 127 __entry->dir == SDPCM_RX ? "RX" : "TX", 128 __entry->len, ((u8 *)__get_dynamic_array(hdr))[4]) 129 ); 130 131 #pragma GCC diagnostic pop 132 133 #ifdef CONFIG_BRCM_TRACING 134 135 #undef TRACE_INCLUDE_PATH 136 #define TRACE_INCLUDE_PATH . 137 #undef TRACE_INCLUDE_FILE 138 #define TRACE_INCLUDE_FILE tracepoint 139 140 #include <trace/define_trace.h> 141 142 #endif /* CONFIG_BRCM_TRACING */ 143 144 #endif /* BRCMF_TRACEPOINT_H_ */ 145