1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */ 2 /* 3 * Copyright (c) 2019 The Linux Foundation. All rights reserved. 4 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 5 */ 6 7 #if !defined(_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ) 8 9 #include <linux/tracepoint.h> 10 #include "core.h" 11 12 #define _TRACE_H_ 13 14 /* create empty functions when tracing is disabled */ 15 #if !defined(CONFIG_ATH11K_TRACING) 16 #undef TRACE_EVENT 17 #define TRACE_EVENT(name, proto, ...) \ 18 static inline void trace_ ## name(proto) {} \ 19 static inline bool trace_##name##_enabled(void) \ 20 { \ 21 return false; \ 22 } 23 24 #undef DECLARE_EVENT_CLASS 25 #define DECLARE_EVENT_CLASS(...) 26 #undef DEFINE_EVENT 27 #define DEFINE_EVENT(evt_class, name, proto, ...) \ 28 static inline void trace_ ## name(proto) {} 29 #endif /* !CONFIG_ATH11K_TRACING || __CHECKER__ */ 30 31 #undef TRACE_SYSTEM 32 #define TRACE_SYSTEM ath11k 33 34 #define ATH11K_MSG_MAX 400 35 36 TRACE_EVENT(ath11k_htt_pktlog, 37 TP_PROTO(struct ath11k *ar, const void *buf, u16 buf_len, 38 u32 pktlog_checksum), 39 40 TP_ARGS(ar, buf, buf_len, pktlog_checksum), 41 42 TP_STRUCT__entry( 43 __string(device, dev_name(ar->ab->dev)) 44 __string(driver, dev_driver_string(ar->ab->dev)) 45 __field(u16, buf_len) 46 __field(u32, pktlog_checksum) 47 __dynamic_array(u8, pktlog, buf_len) 48 ), 49 50 TP_fast_assign( 51 __assign_str(device, dev_name(ar->ab->dev)); 52 __assign_str(driver, dev_driver_string(ar->ab->dev)); 53 __entry->buf_len = buf_len; 54 __entry->pktlog_checksum = pktlog_checksum; 55 memcpy(__get_dynamic_array(pktlog), buf, buf_len); 56 ), 57 58 TP_printk( 59 "%s %s size %u pktlog_checksum %d", 60 __get_str(driver), 61 __get_str(device), 62 __entry->buf_len, 63 __entry->pktlog_checksum 64 ) 65 ); 66 67 TRACE_EVENT(ath11k_htt_ppdu_stats, 68 TP_PROTO(struct ath11k *ar, const void *data, size_t len), 69 70 TP_ARGS(ar, data, len), 71 72 TP_STRUCT__entry( 73 __string(device, dev_name(ar->ab->dev)) 74 __string(driver, dev_driver_string(ar->ab->dev)) 75 __field(u16, len) 76 __dynamic_array(u8, ppdu, len) 77 ), 78 79 TP_fast_assign( 80 __assign_str(device, dev_name(ar->ab->dev)); 81 __assign_str(driver, dev_driver_string(ar->ab->dev)); 82 __entry->len = len; 83 memcpy(__get_dynamic_array(ppdu), data, len); 84 ), 85 86 TP_printk( 87 "%s %s ppdu len %d", 88 __get_str(driver), 89 __get_str(device), 90 __entry->len 91 ) 92 ); 93 94 TRACE_EVENT(ath11k_htt_rxdesc, 95 TP_PROTO(struct ath11k *ar, const void *data, size_t log_type, size_t len), 96 97 TP_ARGS(ar, data, log_type, len), 98 99 TP_STRUCT__entry( 100 __string(device, dev_name(ar->ab->dev)) 101 __string(driver, dev_driver_string(ar->ab->dev)) 102 __field(u16, len) 103 __field(u16, log_type) 104 __dynamic_array(u8, rxdesc, len) 105 ), 106 107 TP_fast_assign( 108 __assign_str(device, dev_name(ar->ab->dev)); 109 __assign_str(driver, dev_driver_string(ar->ab->dev)); 110 __entry->len = len; 111 __entry->log_type = log_type; 112 memcpy(__get_dynamic_array(rxdesc), data, len); 113 ), 114 115 TP_printk( 116 "%s %s rxdesc len %d type %d", 117 __get_str(driver), 118 __get_str(device), 119 __entry->len, 120 __entry->log_type 121 ) 122 ); 123 124 DECLARE_EVENT_CLASS(ath11k_log_event, 125 TP_PROTO(struct ath11k_base *ab, struct va_format *vaf), 126 TP_ARGS(ab, vaf), 127 TP_STRUCT__entry( 128 __string(device, dev_name(ab->dev)) 129 __string(driver, dev_driver_string(ab->dev)) 130 __vstring(msg, vaf->fmt, vaf->va) 131 ), 132 TP_fast_assign( 133 __assign_str(device, dev_name(ab->dev)); 134 __assign_str(driver, dev_driver_string(ab->dev)); 135 __assign_vstr(msg, vaf->fmt, vaf->va); 136 ), 137 TP_printk( 138 "%s %s %s", 139 __get_str(driver), 140 __get_str(device), 141 __get_str(msg) 142 ) 143 ); 144 145 DEFINE_EVENT(ath11k_log_event, ath11k_log_err, 146 TP_PROTO(struct ath11k_base *ab, struct va_format *vaf), 147 TP_ARGS(ab, vaf) 148 ); 149 150 DEFINE_EVENT(ath11k_log_event, ath11k_log_warn, 151 TP_PROTO(struct ath11k_base *ab, struct va_format *vaf), 152 TP_ARGS(ab, vaf) 153 ); 154 155 DEFINE_EVENT(ath11k_log_event, ath11k_log_info, 156 TP_PROTO(struct ath11k_base *ab, struct va_format *vaf), 157 TP_ARGS(ab, vaf) 158 ); 159 160 TRACE_EVENT(ath11k_wmi_cmd, 161 TP_PROTO(struct ath11k_base *ab, int id, const void *buf, size_t buf_len), 162 163 TP_ARGS(ab, id, buf, buf_len), 164 165 TP_STRUCT__entry( 166 __string(device, dev_name(ab->dev)) 167 __string(driver, dev_driver_string(ab->dev)) 168 __field(unsigned int, id) 169 __field(size_t, buf_len) 170 __dynamic_array(u8, buf, buf_len) 171 ), 172 173 TP_fast_assign( 174 __assign_str(device, dev_name(ab->dev)); 175 __assign_str(driver, dev_driver_string(ab->dev)); 176 __entry->id = id; 177 __entry->buf_len = buf_len; 178 memcpy(__get_dynamic_array(buf), buf, buf_len); 179 ), 180 181 TP_printk( 182 "%s %s id %d len %zu", 183 __get_str(driver), 184 __get_str(device), 185 __entry->id, 186 __entry->buf_len 187 ) 188 ); 189 190 TRACE_EVENT(ath11k_wmi_event, 191 TP_PROTO(struct ath11k_base *ab, int id, const void *buf, size_t buf_len), 192 193 TP_ARGS(ab, id, buf, buf_len), 194 195 TP_STRUCT__entry( 196 __string(device, dev_name(ab->dev)) 197 __string(driver, dev_driver_string(ab->dev)) 198 __field(unsigned int, id) 199 __field(size_t, buf_len) 200 __dynamic_array(u8, buf, buf_len) 201 ), 202 203 TP_fast_assign( 204 __assign_str(device, dev_name(ab->dev)); 205 __assign_str(driver, dev_driver_string(ab->dev)); 206 __entry->id = id; 207 __entry->buf_len = buf_len; 208 memcpy(__get_dynamic_array(buf), buf, buf_len); 209 ), 210 211 TP_printk( 212 "%s %s id %d len %zu", 213 __get_str(driver), 214 __get_str(device), 215 __entry->id, 216 __entry->buf_len 217 ) 218 ); 219 220 TRACE_EVENT(ath11k_log_dbg, 221 TP_PROTO(struct ath11k_base *ab, unsigned int level, struct va_format *vaf), 222 223 TP_ARGS(ab, level, vaf), 224 225 TP_STRUCT__entry( 226 __string(device, dev_name(ab->dev)) 227 __string(driver, dev_driver_string(ab->dev)) 228 __field(unsigned int, level) 229 __dynamic_array(char, msg, ATH11K_MSG_MAX) 230 ), 231 232 TP_fast_assign( 233 __assign_str(device, dev_name(ab->dev)); 234 __assign_str(driver, dev_driver_string(ab->dev)); 235 __entry->level = level; 236 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), 237 ATH11K_MSG_MAX, vaf->fmt, 238 *vaf->va) >= ATH11K_MSG_MAX); 239 ), 240 241 TP_printk( 242 "%s %s %s", 243 __get_str(driver), 244 __get_str(device), 245 __get_str(msg) 246 ) 247 ); 248 249 TRACE_EVENT(ath11k_log_dbg_dump, 250 TP_PROTO(struct ath11k_base *ab, const char *msg, const char *prefix, 251 const void *buf, size_t buf_len), 252 253 TP_ARGS(ab, msg, prefix, buf, buf_len), 254 255 TP_STRUCT__entry( 256 __string(device, dev_name(ab->dev)) 257 __string(driver, dev_driver_string(ab->dev)) 258 __string(msg, msg) 259 __string(prefix, prefix) 260 __field(size_t, buf_len) 261 __dynamic_array(u8, buf, buf_len) 262 ), 263 264 TP_fast_assign( 265 __assign_str(device, dev_name(ab->dev)); 266 __assign_str(driver, dev_driver_string(ab->dev)); 267 __assign_str(msg, msg); 268 __assign_str(prefix, prefix); 269 __entry->buf_len = buf_len; 270 memcpy(__get_dynamic_array(buf), buf, buf_len); 271 ), 272 273 TP_printk( 274 "%s %s %s/%s\n", 275 __get_str(driver), 276 __get_str(device), 277 __get_str(prefix), 278 __get_str(msg) 279 ) 280 ); 281 282 TRACE_EVENT(ath11k_wmi_diag, 283 TP_PROTO(struct ath11k_base *ab, const void *data, size_t len), 284 285 TP_ARGS(ab, data, len), 286 287 TP_STRUCT__entry( 288 __string(device, dev_name(ab->dev)) 289 __string(driver, dev_driver_string(ab->dev)) 290 __field(u16, len) 291 __dynamic_array(u8, data, len) 292 ), 293 294 TP_fast_assign( 295 __assign_str(device, dev_name(ab->dev)); 296 __assign_str(driver, dev_driver_string(ab->dev)); 297 __entry->len = len; 298 memcpy(__get_dynamic_array(data), data, len); 299 ), 300 301 TP_printk( 302 "%s %s tlv diag len %d", 303 __get_str(driver), 304 __get_str(device), 305 __entry->len 306 ) 307 ); 308 309 TRACE_EVENT(ath11k_ps_timekeeper, 310 TP_PROTO(struct ath11k *ar, const void *peer_addr, 311 u32 peer_ps_timestamp, u8 peer_ps_state), 312 TP_ARGS(ar, peer_addr, peer_ps_timestamp, peer_ps_state), 313 314 TP_STRUCT__entry(__string(device, dev_name(ar->ab->dev)) 315 __string(driver, dev_driver_string(ar->ab->dev)) 316 __dynamic_array(u8, peer_addr, ETH_ALEN) 317 __field(u8, peer_ps_state) 318 __field(u32, peer_ps_timestamp) 319 ), 320 321 TP_fast_assign(__assign_str(device, dev_name(ar->ab->dev)); 322 __assign_str(driver, dev_driver_string(ar->ab->dev)); 323 memcpy(__get_dynamic_array(peer_addr), peer_addr, 324 ETH_ALEN); 325 __entry->peer_ps_state = peer_ps_state; 326 __entry->peer_ps_timestamp = peer_ps_timestamp; 327 ), 328 329 TP_printk("%s %s %u %u", 330 __get_str(driver), 331 __get_str(device), 332 __entry->peer_ps_state, 333 __entry->peer_ps_timestamp 334 ) 335 ); 336 337 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/ 338 339 /* we don't want to use include/trace/events */ 340 #undef TRACE_INCLUDE_PATH 341 #define TRACE_INCLUDE_PATH . 342 #undef TRACE_INCLUDE_FILE 343 #define TRACE_INCLUDE_FILE trace 344 345 /* This part must be outside protection */ 346 #include <trace/define_trace.h> 347