Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Kalle Valo | 416cf0b | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 2 | #if !defined(_ATH6KL_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) |
| 3 | |
| 4 | #include <net/cfg80211.h> |
| 5 | #include <linux/skbuff.h> |
| 6 | #include <linux/tracepoint.h> |
| 7 | #include "wmi.h" |
Kalle Valo | e60c815 | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 8 | #include "hif.h" |
Kalle Valo | 416cf0b | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 9 | |
| 10 | #if !defined(_ATH6KL_TRACE_H) |
| 11 | static inline unsigned int ath6kl_get_wmi_id(void *buf, size_t buf_len) |
| 12 | { |
| 13 | struct wmi_cmd_hdr *hdr = buf; |
| 14 | |
| 15 | if (buf_len < sizeof(*hdr)) |
| 16 | return 0; |
| 17 | |
| 18 | return le16_to_cpu(hdr->cmd_id); |
| 19 | } |
| 20 | #endif /* __ATH6KL_TRACE_H */ |
| 21 | |
| 22 | #define _ATH6KL_TRACE_H |
| 23 | |
| 24 | /* create empty functions when tracing is disabled */ |
| 25 | #if !defined(CONFIG_ATH6KL_TRACING) |
| 26 | #undef TRACE_EVENT |
| 27 | #define TRACE_EVENT(name, proto, ...) \ |
| 28 | static inline void trace_ ## name(proto) {} |
Kalle Valo | da01d53 | 2013-03-18 13:42:22 +0200 | [diff] [blame] | 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) {} |
Kalle Valo | 416cf0b | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 34 | #endif /* !CONFIG_ATH6KL_TRACING || __CHECKER__ */ |
| 35 | |
| 36 | #undef TRACE_SYSTEM |
| 37 | #define TRACE_SYSTEM ath6kl |
| 38 | |
| 39 | TRACE_EVENT(ath6kl_wmi_cmd, |
| 40 | TP_PROTO(void *buf, size_t buf_len), |
| 41 | |
| 42 | TP_ARGS(buf, buf_len), |
| 43 | |
| 44 | TP_STRUCT__entry( |
| 45 | __field(unsigned int, id) |
| 46 | __field(size_t, buf_len) |
| 47 | __dynamic_array(u8, buf, buf_len) |
| 48 | ), |
| 49 | |
| 50 | TP_fast_assign( |
| 51 | __entry->id = ath6kl_get_wmi_id(buf, buf_len); |
| 52 | __entry->buf_len = buf_len; |
| 53 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
| 54 | ), |
| 55 | |
| 56 | TP_printk( |
Kalle Valo | 0d4e671 | 2013-03-19 15:25:20 +0200 | [diff] [blame] | 57 | "id %d len %zd", |
Kalle Valo | 416cf0b | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 58 | __entry->id, __entry->buf_len |
| 59 | ) |
| 60 | ); |
| 61 | |
| 62 | TRACE_EVENT(ath6kl_wmi_event, |
| 63 | TP_PROTO(void *buf, size_t buf_len), |
| 64 | |
| 65 | TP_ARGS(buf, buf_len), |
| 66 | |
| 67 | TP_STRUCT__entry( |
| 68 | __field(unsigned int, id) |
| 69 | __field(size_t, buf_len) |
| 70 | __dynamic_array(u8, buf, buf_len) |
| 71 | ), |
| 72 | |
| 73 | TP_fast_assign( |
| 74 | __entry->id = ath6kl_get_wmi_id(buf, buf_len); |
| 75 | __entry->buf_len = buf_len; |
| 76 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
| 77 | ), |
| 78 | |
| 79 | TP_printk( |
Kalle Valo | 0d4e671 | 2013-03-19 15:25:20 +0200 | [diff] [blame] | 80 | "id %d len %zd", |
Kalle Valo | 416cf0b | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 81 | __entry->id, __entry->buf_len |
| 82 | ) |
| 83 | ); |
| 84 | |
Kalle Valo | e60c815 | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 85 | TRACE_EVENT(ath6kl_sdio, |
| 86 | TP_PROTO(unsigned int addr, int flags, |
| 87 | void *buf, size_t buf_len), |
| 88 | |
| 89 | TP_ARGS(addr, flags, buf, buf_len), |
| 90 | |
| 91 | TP_STRUCT__entry( |
| 92 | __field(unsigned int, tx) |
| 93 | __field(unsigned int, addr) |
| 94 | __field(int, flags) |
| 95 | __field(size_t, buf_len) |
| 96 | __dynamic_array(u8, buf, buf_len) |
| 97 | ), |
| 98 | |
| 99 | TP_fast_assign( |
| 100 | __entry->addr = addr; |
| 101 | __entry->flags = flags; |
| 102 | __entry->buf_len = buf_len; |
| 103 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
| 104 | |
| 105 | if (flags & HIF_WRITE) |
| 106 | __entry->tx = 1; |
| 107 | else |
| 108 | __entry->tx = 0; |
| 109 | ), |
| 110 | |
| 111 | TP_printk( |
Kalle Valo | 0d4e671 | 2013-03-19 15:25:20 +0200 | [diff] [blame] | 112 | "%s addr 0x%x flags 0x%x len %zd\n", |
Kalle Valo | e60c815 | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 113 | __entry->tx ? "tx" : "rx", |
| 114 | __entry->addr, |
| 115 | __entry->flags, |
| 116 | __entry->buf_len |
| 117 | ) |
| 118 | ); |
| 119 | |
| 120 | TRACE_EVENT(ath6kl_sdio_scat, |
| 121 | TP_PROTO(unsigned int addr, int flags, unsigned int total_len, |
| 122 | unsigned int entries, struct hif_scatter_item *list), |
| 123 | |
| 124 | TP_ARGS(addr, flags, total_len, entries, list), |
| 125 | |
| 126 | TP_STRUCT__entry( |
| 127 | __field(unsigned int, tx) |
| 128 | __field(unsigned int, addr) |
| 129 | __field(int, flags) |
| 130 | __field(unsigned int, entries) |
| 131 | __field(size_t, total_len) |
| 132 | __dynamic_array(unsigned int, len_array, entries) |
| 133 | __dynamic_array(u8, data, total_len) |
| 134 | ), |
| 135 | |
| 136 | TP_fast_assign( |
| 137 | unsigned int *len_array; |
| 138 | int i, offset = 0; |
| 139 | size_t len; |
| 140 | |
| 141 | __entry->addr = addr; |
| 142 | __entry->flags = flags; |
| 143 | __entry->entries = entries; |
| 144 | __entry->total_len = total_len; |
| 145 | |
| 146 | if (flags & HIF_WRITE) |
| 147 | __entry->tx = 1; |
| 148 | else |
| 149 | __entry->tx = 0; |
| 150 | |
| 151 | len_array = __get_dynamic_array(len_array); |
| 152 | |
| 153 | for (i = 0; i < entries; i++) { |
| 154 | len = list[i].len; |
| 155 | |
| 156 | memcpy((u8 *) __get_dynamic_array(data) + offset, |
| 157 | list[i].buf, len); |
| 158 | |
| 159 | len_array[i] = len; |
| 160 | offset += len; |
| 161 | } |
| 162 | ), |
| 163 | |
| 164 | TP_printk( |
Kalle Valo | 0d4e671 | 2013-03-19 15:25:20 +0200 | [diff] [blame] | 165 | "%s addr 0x%x flags 0x%x entries %d total_len %zd\n", |
Kalle Valo | e60c815 | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 166 | __entry->tx ? "tx" : "rx", |
| 167 | __entry->addr, |
| 168 | __entry->flags, |
| 169 | __entry->entries, |
| 170 | __entry->total_len |
| 171 | ) |
| 172 | ); |
| 173 | |
Kalle Valo | d57f093 | 2013-03-18 13:42:21 +0200 | [diff] [blame] | 174 | TRACE_EVENT(ath6kl_sdio_irq, |
| 175 | TP_PROTO(void *buf, size_t buf_len), |
| 176 | |
| 177 | TP_ARGS(buf, buf_len), |
| 178 | |
| 179 | TP_STRUCT__entry( |
| 180 | __field(size_t, buf_len) |
| 181 | __dynamic_array(u8, buf, buf_len) |
| 182 | ), |
| 183 | |
| 184 | TP_fast_assign( |
| 185 | __entry->buf_len = buf_len; |
| 186 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
| 187 | ), |
| 188 | |
| 189 | TP_printk( |
Kalle Valo | 0d4e671 | 2013-03-19 15:25:20 +0200 | [diff] [blame] | 190 | "irq len %zd\n", __entry->buf_len |
Kalle Valo | d57f093 | 2013-03-18 13:42:21 +0200 | [diff] [blame] | 191 | ) |
| 192 | ); |
| 193 | |
Kalle Valo | 4771979 | 2013-03-18 13:42:21 +0200 | [diff] [blame] | 194 | TRACE_EVENT(ath6kl_htc_rx, |
| 195 | TP_PROTO(int status, int endpoint, void *buf, |
| 196 | size_t buf_len), |
| 197 | |
| 198 | TP_ARGS(status, endpoint, buf, buf_len), |
| 199 | |
| 200 | TP_STRUCT__entry( |
| 201 | __field(int, status) |
| 202 | __field(int, endpoint) |
| 203 | __field(size_t, buf_len) |
| 204 | __dynamic_array(u8, buf, buf_len) |
| 205 | ), |
| 206 | |
| 207 | TP_fast_assign( |
| 208 | __entry->status = status; |
| 209 | __entry->endpoint = endpoint; |
| 210 | __entry->buf_len = buf_len; |
| 211 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
| 212 | ), |
| 213 | |
| 214 | TP_printk( |
Kalle Valo | 0d4e671 | 2013-03-19 15:25:20 +0200 | [diff] [blame] | 215 | "status %d endpoint %d len %zd\n", |
Kalle Valo | 4771979 | 2013-03-18 13:42:21 +0200 | [diff] [blame] | 216 | __entry->status, |
| 217 | __entry->endpoint, |
| 218 | __entry->buf_len |
| 219 | ) |
| 220 | ); |
| 221 | |
| 222 | TRACE_EVENT(ath6kl_htc_tx, |
| 223 | TP_PROTO(int status, int endpoint, void *buf, |
| 224 | size_t buf_len), |
| 225 | |
| 226 | TP_ARGS(status, endpoint, buf, buf_len), |
| 227 | |
| 228 | TP_STRUCT__entry( |
| 229 | __field(int, status) |
| 230 | __field(int, endpoint) |
| 231 | __field(size_t, buf_len) |
| 232 | __dynamic_array(u8, buf, buf_len) |
| 233 | ), |
| 234 | |
| 235 | TP_fast_assign( |
| 236 | __entry->status = status; |
| 237 | __entry->endpoint = endpoint; |
| 238 | __entry->buf_len = buf_len; |
| 239 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
| 240 | ), |
| 241 | |
| 242 | TP_printk( |
Kalle Valo | 0d4e671 | 2013-03-19 15:25:20 +0200 | [diff] [blame] | 243 | "status %d endpoint %d len %zd\n", |
Kalle Valo | 4771979 | 2013-03-18 13:42:21 +0200 | [diff] [blame] | 244 | __entry->status, |
| 245 | __entry->endpoint, |
| 246 | __entry->buf_len |
| 247 | ) |
| 248 | ); |
| 249 | |
Kalle Valo | da01d53 | 2013-03-18 13:42:22 +0200 | [diff] [blame] | 250 | #define ATH6KL_MSG_MAX 200 |
| 251 | |
| 252 | DECLARE_EVENT_CLASS(ath6kl_log_event, |
| 253 | TP_PROTO(struct va_format *vaf), |
| 254 | TP_ARGS(vaf), |
| 255 | TP_STRUCT__entry( |
| 256 | __dynamic_array(char, msg, ATH6KL_MSG_MAX) |
| 257 | ), |
| 258 | TP_fast_assign( |
| 259 | WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), |
| 260 | ATH6KL_MSG_MAX, |
| 261 | vaf->fmt, |
| 262 | *vaf->va) >= ATH6KL_MSG_MAX); |
| 263 | ), |
| 264 | TP_printk("%s", __get_str(msg)) |
| 265 | ); |
| 266 | |
| 267 | DEFINE_EVENT(ath6kl_log_event, ath6kl_log_err, |
| 268 | TP_PROTO(struct va_format *vaf), |
| 269 | TP_ARGS(vaf) |
| 270 | ); |
| 271 | |
| 272 | DEFINE_EVENT(ath6kl_log_event, ath6kl_log_warn, |
| 273 | TP_PROTO(struct va_format *vaf), |
| 274 | TP_ARGS(vaf) |
| 275 | ); |
| 276 | |
| 277 | DEFINE_EVENT(ath6kl_log_event, ath6kl_log_info, |
| 278 | TP_PROTO(struct va_format *vaf), |
| 279 | TP_ARGS(vaf) |
| 280 | ); |
| 281 | |
Kalle Valo | aa8705f | 2013-03-18 13:42:22 +0200 | [diff] [blame] | 282 | TRACE_EVENT(ath6kl_log_dbg, |
| 283 | TP_PROTO(unsigned int level, struct va_format *vaf), |
| 284 | TP_ARGS(level, vaf), |
| 285 | TP_STRUCT__entry( |
| 286 | __field(unsigned int, level) |
| 287 | __dynamic_array(char, msg, ATH6KL_MSG_MAX) |
| 288 | ), |
| 289 | TP_fast_assign( |
| 290 | __entry->level = level; |
| 291 | WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), |
| 292 | ATH6KL_MSG_MAX, |
| 293 | vaf->fmt, |
| 294 | *vaf->va) >= ATH6KL_MSG_MAX); |
| 295 | ), |
| 296 | TP_printk("%s", __get_str(msg)) |
| 297 | ); |
| 298 | |
| 299 | TRACE_EVENT(ath6kl_log_dbg_dump, |
| 300 | TP_PROTO(const char *msg, const char *prefix, |
| 301 | const void *buf, size_t buf_len), |
| 302 | |
| 303 | TP_ARGS(msg, prefix, buf, buf_len), |
| 304 | |
| 305 | TP_STRUCT__entry( |
| 306 | __string(msg, msg) |
| 307 | __string(prefix, prefix) |
| 308 | __field(size_t, buf_len) |
| 309 | __dynamic_array(u8, buf, buf_len) |
| 310 | ), |
| 311 | |
| 312 | TP_fast_assign( |
| 313 | __assign_str(msg, msg); |
| 314 | __assign_str(prefix, prefix); |
| 315 | __entry->buf_len = buf_len; |
| 316 | memcpy(__get_dynamic_array(buf), buf, buf_len); |
| 317 | ), |
| 318 | |
| 319 | TP_printk( |
| 320 | "%s/%s\n", __get_str(prefix), __get_str(msg) |
| 321 | ) |
| 322 | ); |
| 323 | |
Kalle Valo | 416cf0b | 2013-03-18 13:42:20 +0200 | [diff] [blame] | 324 | #endif /* _ ATH6KL_TRACE_H || TRACE_HEADER_MULTI_READ*/ |
| 325 | |
| 326 | /* we don't want to use include/trace/events */ |
| 327 | #undef TRACE_INCLUDE_PATH |
| 328 | #define TRACE_INCLUDE_PATH . |
| 329 | #undef TRACE_INCLUDE_FILE |
| 330 | #define TRACE_INCLUDE_FILE trace |
| 331 | |
| 332 | /* This part must be outside protection */ |
| 333 | #include <trace/define_trace.h> |