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 22 #define _TRACE_H_ 23 24 /* create empty functions when tracing is disabled */ 25 #if !defined(CONFIG_ATH10K_TRACING) 26 #undef TRACE_EVENT 27 #define TRACE_EVENT(name, proto, ...) \ 28 static inline void trace_ ## name(proto) {} 29 #undef DECLARE_EVENT_CLASS 30 #define DECLARE_EVENT_CLASS(...) 31 #undef DEFINE_EVENT 32 #define DEFINE_EVENT(evt_class, name, proto, ...) \ 33 static inline void trace_ ## name(proto) {} 34 #endif /* !CONFIG_ATH10K_TRACING || __CHECKER__ */ 35 36 #undef TRACE_SYSTEM 37 #define TRACE_SYSTEM ath10k 38 39 #define ATH10K_MSG_MAX 200 40 41 DECLARE_EVENT_CLASS(ath10k_log_event, 42 TP_PROTO(struct va_format *vaf), 43 TP_ARGS(vaf), 44 TP_STRUCT__entry( 45 __dynamic_array(char, msg, ATH10K_MSG_MAX) 46 ), 47 TP_fast_assign( 48 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 49 ATH10K_MSG_MAX, 50 vaf->fmt, 51 *vaf->va) >= ATH10K_MSG_MAX); 52 ), 53 TP_printk("%s", __get_str(msg)) 54 ); 55 56 DEFINE_EVENT(ath10k_log_event, ath10k_log_err, 57 TP_PROTO(struct va_format *vaf), 58 TP_ARGS(vaf) 59 ); 60 61 DEFINE_EVENT(ath10k_log_event, ath10k_log_warn, 62 TP_PROTO(struct va_format *vaf), 63 TP_ARGS(vaf) 64 ); 65 66 DEFINE_EVENT(ath10k_log_event, ath10k_log_info, 67 TP_PROTO(struct va_format *vaf), 68 TP_ARGS(vaf) 69 ); 70 71 TRACE_EVENT(ath10k_log_dbg, 72 TP_PROTO(unsigned int level, struct va_format *vaf), 73 TP_ARGS(level, vaf), 74 TP_STRUCT__entry( 75 __field(unsigned int, level) 76 __dynamic_array(char, msg, ATH10K_MSG_MAX) 77 ), 78 TP_fast_assign( 79 __entry->level = level; 80 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 81 ATH10K_MSG_MAX, 82 vaf->fmt, 83 *vaf->va) >= ATH10K_MSG_MAX); 84 ), 85 TP_printk("%s", __get_str(msg)) 86 ); 87 88 TRACE_EVENT(ath10k_log_dbg_dump, 89 TP_PROTO(const char *msg, const char *prefix, 90 const void *buf, size_t buf_len), 91 92 TP_ARGS(msg, prefix, buf, buf_len), 93 94 TP_STRUCT__entry( 95 __string(msg, msg) 96 __string(prefix, prefix) 97 __field(size_t, buf_len) 98 __dynamic_array(u8, buf, buf_len) 99 ), 100 101 TP_fast_assign( 102 __assign_str(msg, msg); 103 __assign_str(prefix, prefix); 104 __entry->buf_len = buf_len; 105 memcpy(__get_dynamic_array(buf), buf, buf_len); 106 ), 107 108 TP_printk( 109 "%s/%s\n", __get_str(prefix), __get_str(msg) 110 ) 111 ); 112 113 TRACE_EVENT(ath10k_wmi_cmd, 114 TP_PROTO(int id, void *buf, size_t buf_len, int ret), 115 116 TP_ARGS(id, buf, buf_len, ret), 117 118 TP_STRUCT__entry( 119 __field(unsigned int, id) 120 __field(size_t, buf_len) 121 __dynamic_array(u8, buf, buf_len) 122 __field(int, ret) 123 ), 124 125 TP_fast_assign( 126 __entry->id = id; 127 __entry->buf_len = buf_len; 128 __entry->ret = ret; 129 memcpy(__get_dynamic_array(buf), buf, buf_len); 130 ), 131 132 TP_printk( 133 "id %d len %zu ret %d", 134 __entry->id, 135 __entry->buf_len, 136 __entry->ret 137 ) 138 ); 139 140 TRACE_EVENT(ath10k_wmi_event, 141 TP_PROTO(int id, void *buf, size_t buf_len), 142 143 TP_ARGS(id, buf, buf_len), 144 145 TP_STRUCT__entry( 146 __field(unsigned int, id) 147 __field(size_t, buf_len) 148 __dynamic_array(u8, buf, buf_len) 149 ), 150 151 TP_fast_assign( 152 __entry->id = id; 153 __entry->buf_len = buf_len; 154 memcpy(__get_dynamic_array(buf), buf, buf_len); 155 ), 156 157 TP_printk( 158 "id %d len %zu", 159 __entry->id, 160 __entry->buf_len 161 ) 162 ); 163 164 TRACE_EVENT(ath10k_htt_stats, 165 TP_PROTO(void *buf, size_t buf_len), 166 167 TP_ARGS(buf, buf_len), 168 169 TP_STRUCT__entry( 170 __field(size_t, buf_len) 171 __dynamic_array(u8, buf, buf_len) 172 ), 173 174 TP_fast_assign( 175 __entry->buf_len = buf_len; 176 memcpy(__get_dynamic_array(buf), buf, buf_len); 177 ), 178 179 TP_printk( 180 "len %zu", 181 __entry->buf_len 182 ) 183 ); 184 185 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/ 186 187 /* we don't want to use include/trace/events */ 188 #undef TRACE_INCLUDE_PATH 189 #define TRACE_INCLUDE_PATH . 190 #undef TRACE_INCLUDE_FILE 191 #define TRACE_INCLUDE_FILE trace 192 193 /* This part must be outside protection */ 194 #include <trace/define_trace.h> 195