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