1 /* 2 * Copyright (c) 2011 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 17 #if !defined(__TRACE_BRCMSMAC_H) || defined(TRACE_HEADER_MULTI_READ) 18 19 #define __TRACE_BRCMSMAC_H 20 21 #include <linux/types.h> 22 #include <linux/device.h> 23 #include <linux/tracepoint.h> 24 #include "mac80211_if.h" 25 26 #ifndef CONFIG_BRCM_TRACING 27 #undef TRACE_EVENT 28 #define TRACE_EVENT(name, proto, ...) \ 29 static inline void trace_ ## name(proto) {} 30 #undef DECLARE_EVENT_CLASS 31 #define DECLARE_EVENT_CLASS(...) 32 #undef DEFINE_EVENT 33 #define DEFINE_EVENT(evt_class, name, proto, ...) \ 34 static inline void trace_ ## name(proto) {} 35 #endif 36 37 #undef TRACE_SYSTEM 38 #define TRACE_SYSTEM brcmsmac 39 40 /* 41 * We define a tracepoint, its arguments, its printk format and its 42 * 'fast binary record' layout. 43 */ 44 TRACE_EVENT(brcms_timer, 45 /* TPPROTO is the prototype of the function called by this tracepoint */ 46 TP_PROTO(struct brcms_timer *t), 47 /* 48 * TPARGS(firstarg, p) are the parameters names, same as found in the 49 * prototype. 50 */ 51 TP_ARGS(t), 52 /* 53 * Fast binary tracing: define the trace record via TP_STRUCT__entry(). 54 * You can think about it like a regular C structure local variable 55 * definition. 56 */ 57 TP_STRUCT__entry( 58 __field(uint, ms) 59 __field(uint, set) 60 __field(uint, periodic) 61 ), 62 TP_fast_assign( 63 __entry->ms = t->ms; 64 __entry->set = t->set; 65 __entry->periodic = t->periodic; 66 ), 67 TP_printk( 68 "ms=%u set=%u periodic=%u", 69 __entry->ms, __entry->set, __entry->periodic 70 ) 71 ); 72 73 TRACE_EVENT(brcms_dpc, 74 TP_PROTO(unsigned long data), 75 TP_ARGS(data), 76 TP_STRUCT__entry( 77 __field(unsigned long, data) 78 ), 79 TP_fast_assign( 80 __entry->data = data; 81 ), 82 TP_printk( 83 "data=%p", 84 (void *)__entry->data 85 ) 86 ); 87 88 TRACE_EVENT(brcms_macintstatus, 89 TP_PROTO(const struct device *dev, int in_isr, u32 macintstatus, 90 u32 mask), 91 TP_ARGS(dev, in_isr, macintstatus, mask), 92 TP_STRUCT__entry( 93 __string(dev, dev_name(dev)) 94 __field(int, in_isr) 95 __field(u32, macintstatus) 96 __field(u32, mask) 97 ), 98 TP_fast_assign( 99 __assign_str(dev, dev_name(dev)); 100 __entry->in_isr = in_isr; 101 __entry->macintstatus = macintstatus; 102 __entry->mask = mask; 103 ), 104 TP_printk("[%s] in_isr=%d macintstatus=%#x mask=%#x", __get_str(dev), 105 __entry->in_isr, __entry->macintstatus, __entry->mask) 106 ); 107 108 #undef TRACE_SYSTEM 109 #define TRACE_SYSTEM brcmsmac_tx 110 111 TRACE_EVENT(brcms_txdesc, 112 TP_PROTO(const struct device *dev, 113 void *txh, size_t txh_len), 114 TP_ARGS(dev, txh, txh_len), 115 TP_STRUCT__entry( 116 __string(dev, dev_name(dev)) 117 __dynamic_array(u8, txh, txh_len) 118 ), 119 TP_fast_assign( 120 __assign_str(dev, dev_name(dev)); 121 memcpy(__get_dynamic_array(txh), txh, txh_len); 122 ), 123 TP_printk("[%s] txdesc", __get_str(dev)) 124 ); 125 126 TRACE_EVENT(brcms_txstatus, 127 TP_PROTO(const struct device *dev, u16 framelen, u16 frameid, 128 u16 status, u16 lasttxtime, u16 sequence, u16 phyerr, 129 u16 ackphyrxsh), 130 TP_ARGS(dev, framelen, frameid, status, lasttxtime, sequence, phyerr, 131 ackphyrxsh), 132 TP_STRUCT__entry( 133 __string(dev, dev_name(dev)) 134 __field(u16, framelen) 135 __field(u16, frameid) 136 __field(u16, status) 137 __field(u16, lasttxtime) 138 __field(u16, sequence) 139 __field(u16, phyerr) 140 __field(u16, ackphyrxsh) 141 ), 142 TP_fast_assign( 143 __assign_str(dev, dev_name(dev)); 144 __entry->framelen = framelen; 145 __entry->frameid = frameid; 146 __entry->status = status; 147 __entry->lasttxtime = lasttxtime; 148 __entry->sequence = sequence; 149 __entry->phyerr = phyerr; 150 __entry->ackphyrxsh = ackphyrxsh; 151 ), 152 TP_printk("[%s] FrameId %#04x TxStatus %#04x LastTxTime %#04x " 153 "Seq %#04x PHYTxStatus %#04x RxAck %#04x", 154 __get_str(dev), __entry->frameid, __entry->status, 155 __entry->lasttxtime, __entry->sequence, __entry->phyerr, 156 __entry->ackphyrxsh) 157 ); 158 159 TRACE_EVENT(brcms_ampdu_session, 160 TP_PROTO(const struct device *dev, unsigned max_ampdu_len, 161 u16 max_ampdu_frames, u16 ampdu_len, u16 ampdu_frames, 162 u16 dma_len), 163 TP_ARGS(dev, max_ampdu_len, max_ampdu_frames, ampdu_len, ampdu_frames, 164 dma_len), 165 TP_STRUCT__entry( 166 __string(dev, dev_name(dev)) 167 __field(unsigned, max_ampdu_len) 168 __field(u16, max_ampdu_frames) 169 __field(u16, ampdu_len) 170 __field(u16, ampdu_frames) 171 __field(u16, dma_len) 172 ), 173 TP_fast_assign( 174 __assign_str(dev, dev_name(dev)); 175 __entry->max_ampdu_len = max_ampdu_len; 176 __entry->max_ampdu_frames = max_ampdu_frames; 177 __entry->ampdu_len = ampdu_len; 178 __entry->ampdu_frames = ampdu_frames; 179 __entry->dma_len = dma_len; 180 ), 181 TP_printk("[%s] ampdu session max_len=%u max_frames=%u len=%u frames=%u dma_len=%u", 182 __get_str(dev), __entry->max_ampdu_len, 183 __entry->max_ampdu_frames, __entry->ampdu_len, 184 __entry->ampdu_frames, __entry->dma_len) 185 ); 186 187 #undef TRACE_SYSTEM 188 #define TRACE_SYSTEM brcmsmac_msg 189 190 #define MAX_MSG_LEN 100 191 192 DECLARE_EVENT_CLASS(brcms_msg_event, 193 TP_PROTO(struct va_format *vaf), 194 TP_ARGS(vaf), 195 TP_STRUCT__entry( 196 __dynamic_array(char, msg, MAX_MSG_LEN) 197 ), 198 TP_fast_assign( 199 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 200 MAX_MSG_LEN, vaf->fmt, 201 *vaf->va) >= MAX_MSG_LEN); 202 ), 203 TP_printk("%s", __get_str(msg)) 204 ); 205 206 DEFINE_EVENT(brcms_msg_event, brcms_info, 207 TP_PROTO(struct va_format *vaf), 208 TP_ARGS(vaf) 209 ); 210 211 DEFINE_EVENT(brcms_msg_event, brcms_warn, 212 TP_PROTO(struct va_format *vaf), 213 TP_ARGS(vaf) 214 ); 215 216 DEFINE_EVENT(brcms_msg_event, brcms_err, 217 TP_PROTO(struct va_format *vaf), 218 TP_ARGS(vaf) 219 ); 220 221 DEFINE_EVENT(brcms_msg_event, brcms_crit, 222 TP_PROTO(struct va_format *vaf), 223 TP_ARGS(vaf) 224 ); 225 226 TRACE_EVENT(brcms_dbg, 227 TP_PROTO(u32 level, const char *func, struct va_format *vaf), 228 TP_ARGS(level, func, vaf), 229 TP_STRUCT__entry( 230 __field(u32, level) 231 __string(func, func) 232 __dynamic_array(char, msg, MAX_MSG_LEN) 233 ), 234 TP_fast_assign( 235 __entry->level = level; 236 __assign_str(func, func); 237 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 238 MAX_MSG_LEN, vaf->fmt, 239 *vaf->va) >= MAX_MSG_LEN); 240 ), 241 TP_printk("%s: %s", __get_str(func), __get_str(msg)) 242 ); 243 244 #endif /* __TRACE_BRCMSMAC_H */ 245 246 #ifdef CONFIG_BRCM_TRACING 247 248 #undef TRACE_INCLUDE_PATH 249 #define TRACE_INCLUDE_PATH . 250 #undef TRACE_INCLUDE_FILE 251 #define TRACE_INCLUDE_FILE brcms_trace_events 252 253 #include <trace/define_trace.h> 254 255 #endif /* CONFIG_BRCM_TRACING */ 256