1 /* 2 * Copyright (c) 2005-2011 Atheros Communications Inc. 3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #if !defined(_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ) 19 20 #include <linux/tracepoint.h> 21 #include "core.h" 22 23 #define _TRACE_H_ 24 25 /* create empty functions when tracing is disabled */ 26 #if !defined(CONFIG_ATH10K_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 /* !CONFIG_ATH10K_TRACING || __CHECKER__ */ 36 37 #undef TRACE_SYSTEM 38 #define TRACE_SYSTEM ath10k 39 40 #define ATH10K_MSG_MAX 200 41 42 DECLARE_EVENT_CLASS(ath10k_log_event, 43 TP_PROTO(struct ath10k *ar, struct va_format *vaf), 44 TP_ARGS(ar, vaf), 45 TP_STRUCT__entry( 46 __string(device, dev_name(ar->dev)) 47 __string(driver, dev_driver_string(ar->dev)) 48 __dynamic_array(char, msg, ATH10K_MSG_MAX) 49 ), 50 TP_fast_assign( 51 __assign_str(device, dev_name(ar->dev)); 52 __assign_str(driver, dev_driver_string(ar->dev)); 53 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 54 ATH10K_MSG_MAX, 55 vaf->fmt, 56 *vaf->va) >= ATH10K_MSG_MAX); 57 ), 58 TP_printk( 59 "%s %s %s", 60 __get_str(driver), 61 __get_str(device), 62 __get_str(msg) 63 ) 64 ); 65 66 DEFINE_EVENT(ath10k_log_event, ath10k_log_err, 67 TP_PROTO(struct ath10k *ar, struct va_format *vaf), 68 TP_ARGS(ar, vaf) 69 ); 70 71 DEFINE_EVENT(ath10k_log_event, ath10k_log_warn, 72 TP_PROTO(struct ath10k *ar, struct va_format *vaf), 73 TP_ARGS(ar, vaf) 74 ); 75 76 DEFINE_EVENT(ath10k_log_event, ath10k_log_info, 77 TP_PROTO(struct ath10k *ar, struct va_format *vaf), 78 TP_ARGS(ar, vaf) 79 ); 80 81 TRACE_EVENT(ath10k_log_dbg, 82 TP_PROTO(struct ath10k *ar, unsigned int level, struct va_format *vaf), 83 TP_ARGS(ar, level, vaf), 84 TP_STRUCT__entry( 85 __string(device, dev_name(ar->dev)) 86 __string(driver, dev_driver_string(ar->dev)) 87 __field(unsigned int, level) 88 __dynamic_array(char, msg, ATH10K_MSG_MAX) 89 ), 90 TP_fast_assign( 91 __assign_str(device, dev_name(ar->dev)); 92 __assign_str(driver, dev_driver_string(ar->dev)); 93 __entry->level = level; 94 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 95 ATH10K_MSG_MAX, 96 vaf->fmt, 97 *vaf->va) >= ATH10K_MSG_MAX); 98 ), 99 TP_printk( 100 "%s %s %s", 101 __get_str(driver), 102 __get_str(device), 103 __get_str(msg) 104 ) 105 ); 106 107 TRACE_EVENT(ath10k_log_dbg_dump, 108 TP_PROTO(struct ath10k *ar, const char *msg, const char *prefix, 109 const void *buf, size_t buf_len), 110 111 TP_ARGS(ar, msg, prefix, buf, buf_len), 112 113 TP_STRUCT__entry( 114 __string(device, dev_name(ar->dev)) 115 __string(driver, dev_driver_string(ar->dev)) 116 __string(msg, msg) 117 __string(prefix, prefix) 118 __field(size_t, buf_len) 119 __dynamic_array(u8, buf, buf_len) 120 ), 121 122 TP_fast_assign( 123 __assign_str(device, dev_name(ar->dev)); 124 __assign_str(driver, dev_driver_string(ar->dev)); 125 __assign_str(msg, msg); 126 __assign_str(prefix, prefix); 127 __entry->buf_len = buf_len; 128 memcpy(__get_dynamic_array(buf), buf, buf_len); 129 ), 130 131 TP_printk( 132 "%s %s %s/%s\n", 133 __get_str(driver), 134 __get_str(device), 135 __get_str(prefix), 136 __get_str(msg) 137 ) 138 ); 139 140 TRACE_EVENT(ath10k_wmi_cmd, 141 TP_PROTO(struct ath10k *ar, int id, void *buf, size_t buf_len, int ret), 142 143 TP_ARGS(ar, id, buf, buf_len, ret), 144 145 TP_STRUCT__entry( 146 __string(device, dev_name(ar->dev)) 147 __string(driver, dev_driver_string(ar->dev)) 148 __field(unsigned int, id) 149 __field(size_t, buf_len) 150 __dynamic_array(u8, buf, buf_len) 151 __field(int, ret) 152 ), 153 154 TP_fast_assign( 155 __assign_str(device, dev_name(ar->dev)); 156 __assign_str(driver, dev_driver_string(ar->dev)); 157 __entry->id = id; 158 __entry->buf_len = buf_len; 159 __entry->ret = ret; 160 memcpy(__get_dynamic_array(buf), buf, buf_len); 161 ), 162 163 TP_printk( 164 "%s %s id %d len %zu ret %d", 165 __get_str(driver), 166 __get_str(device), 167 __entry->id, 168 __entry->buf_len, 169 __entry->ret 170 ) 171 ); 172 173 TRACE_EVENT(ath10k_wmi_event, 174 TP_PROTO(struct ath10k *ar, int id, void *buf, size_t buf_len), 175 176 TP_ARGS(ar, id, buf, buf_len), 177 178 TP_STRUCT__entry( 179 __string(device, dev_name(ar->dev)) 180 __string(driver, dev_driver_string(ar->dev)) 181 __field(unsigned int, id) 182 __field(size_t, buf_len) 183 __dynamic_array(u8, buf, buf_len) 184 ), 185 186 TP_fast_assign( 187 __assign_str(device, dev_name(ar->dev)); 188 __assign_str(driver, dev_driver_string(ar->dev)); 189 __entry->id = id; 190 __entry->buf_len = buf_len; 191 memcpy(__get_dynamic_array(buf), buf, buf_len); 192 ), 193 194 TP_printk( 195 "%s %s id %d len %zu", 196 __get_str(driver), 197 __get_str(device), 198 __entry->id, 199 __entry->buf_len 200 ) 201 ); 202 203 TRACE_EVENT(ath10k_htt_stats, 204 TP_PROTO(struct ath10k *ar, void *buf, size_t buf_len), 205 206 TP_ARGS(ar, buf, buf_len), 207 208 TP_STRUCT__entry( 209 __string(device, dev_name(ar->dev)) 210 __string(driver, dev_driver_string(ar->dev)) 211 __field(size_t, buf_len) 212 __dynamic_array(u8, buf, buf_len) 213 ), 214 215 TP_fast_assign( 216 __assign_str(device, dev_name(ar->dev)); 217 __assign_str(driver, dev_driver_string(ar->dev)); 218 __entry->buf_len = buf_len; 219 memcpy(__get_dynamic_array(buf), buf, buf_len); 220 ), 221 222 TP_printk( 223 "%s %s len %zu", 224 __get_str(driver), 225 __get_str(device), 226 __entry->buf_len 227 ) 228 ); 229 230 TRACE_EVENT(ath10k_wmi_dbglog, 231 TP_PROTO(struct ath10k *ar, void *buf, size_t buf_len), 232 233 TP_ARGS(ar, buf, buf_len), 234 235 TP_STRUCT__entry( 236 __string(device, dev_name(ar->dev)) 237 __string(driver, dev_driver_string(ar->dev)) 238 __field(size_t, buf_len) 239 __dynamic_array(u8, buf, buf_len) 240 ), 241 242 TP_fast_assign( 243 __assign_str(device, dev_name(ar->dev)); 244 __assign_str(driver, dev_driver_string(ar->dev)); 245 __entry->buf_len = buf_len; 246 memcpy(__get_dynamic_array(buf), buf, buf_len); 247 ), 248 249 TP_printk( 250 "%s %s len %zu", 251 __get_str(driver), 252 __get_str(device), 253 __entry->buf_len 254 ) 255 ); 256 257 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/ 258 259 /* we don't want to use include/trace/events */ 260 #undef TRACE_INCLUDE_PATH 261 #define TRACE_INCLUDE_PATH . 262 #undef TRACE_INCLUDE_FILE 263 #define TRACE_INCLUDE_FILE trace 264 265 /* This part must be outside protection */ 266 #include <trace/define_trace.h> 267