traces.h (16342B)
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Tracepoints definitions. 4 * 5 * Copyright (c) 2018-2020, Silicon Laboratories, Inc. 6 */ 7 8#undef TRACE_SYSTEM 9#define TRACE_SYSTEM wfx 10 11#if !defined(_WFX_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) 12#define _WFX_TRACE_H 13 14#include <linux/tracepoint.h> 15#include <net/mac80211.h> 16 17#include "bus.h" 18#include "hif_api_cmd.h" 19#include "hif_api_mib.h" 20 21/* The hell below need some explanations. For each symbolic number, we need to define it with 22 * TRACE_DEFINE_ENUM() and in a list for __print_symbolic. 23 * 24 * 1. Define a new macro that call TRACE_DEFINE_ENUM(): 25 * 26 * #define xxx_name(sym) TRACE_DEFINE_ENUM(sym); 27 * 28 * 2. Define list of all symbols: 29 * 30 * #define list_names \ 31 * ... \ 32 * xxx_name(XXX) \ 33 * ... 34 * 35 * 3. Instantiate that list_names: 36 * 37 * list_names 38 * 39 * 4. Redefine xxx_name() as an entry of array for __print_symbolic() 40 * 41 * #undef xxx_name 42 * #define xxx_name(msg) { msg, #msg }, 43 * 44 * 5. list_name can now nearly be used with __print_symbolic() but, __print_symbolic() dislike 45 * last comma of list. So we define a new list with a dummy element: 46 * 47 * #define list_for_print_symbolic list_names { -1, NULL } 48 */ 49 50#define _hif_msg_list \ 51 hif_cnf_name(ADD_KEY) \ 52 hif_cnf_name(BEACON_TRANSMIT) \ 53 hif_cnf_name(EDCA_QUEUE_PARAMS) \ 54 hif_cnf_name(JOIN) \ 55 hif_cnf_name(MAP_LINK) \ 56 hif_cnf_name(READ_MIB) \ 57 hif_cnf_name(REMOVE_KEY) \ 58 hif_cnf_name(RESET) \ 59 hif_cnf_name(SET_BSS_PARAMS) \ 60 hif_cnf_name(SET_PM_MODE) \ 61 hif_cnf_name(START) \ 62 hif_cnf_name(START_SCAN) \ 63 hif_cnf_name(STOP_SCAN) \ 64 hif_cnf_name(TX) \ 65 hif_cnf_name(MULTI_TRANSMIT) \ 66 hif_cnf_name(UPDATE_IE) \ 67 hif_cnf_name(WRITE_MIB) \ 68 hif_cnf_name(CONFIGURATION) \ 69 hif_cnf_name(CONTROL_GPIO) \ 70 hif_cnf_name(PREVENT_ROLLBACK) \ 71 hif_cnf_name(SET_SL_MAC_KEY) \ 72 hif_cnf_name(SL_CONFIGURE) \ 73 hif_cnf_name(SL_EXCHANGE_PUB_KEYS) \ 74 hif_cnf_name(SHUT_DOWN) \ 75 hif_ind_name(EVENT) \ 76 hif_ind_name(JOIN_COMPLETE) \ 77 hif_ind_name(RX) \ 78 hif_ind_name(SCAN_CMPL) \ 79 hif_ind_name(SET_PM_MODE_CMPL) \ 80 hif_ind_name(SUSPEND_RESUME_TX) \ 81 hif_ind_name(SL_EXCHANGE_PUB_KEYS) \ 82 hif_ind_name(ERROR) \ 83 hif_ind_name(EXCEPTION) \ 84 hif_ind_name(GENERIC) \ 85 hif_ind_name(WAKEUP) \ 86 hif_ind_name(STARTUP) 87 88#define hif_msg_list_enum _hif_msg_list 89 90#undef hif_cnf_name 91#undef hif_ind_name 92#define hif_cnf_name(msg) TRACE_DEFINE_ENUM(HIF_CNF_ID_##msg); 93#define hif_ind_name(msg) TRACE_DEFINE_ENUM(HIF_IND_ID_##msg); 94hif_msg_list_enum 95#undef hif_cnf_name 96#undef hif_ind_name 97#define hif_cnf_name(msg) { HIF_CNF_ID_##msg, #msg }, 98#define hif_ind_name(msg) { HIF_IND_ID_##msg, #msg }, 99#define hif_msg_list hif_msg_list_enum { -1, NULL } 100 101#define _hif_mib_list \ 102 hif_mib_name(ARP_IP_ADDRESSES_TABLE) \ 103 hif_mib_name(ARP_KEEP_ALIVE_PERIOD) \ 104 hif_mib_name(BEACON_FILTER_ENABLE) \ 105 hif_mib_name(BEACON_FILTER_TABLE) \ 106 hif_mib_name(BEACON_STATS) \ 107 hif_mib_name(BEACON_WAKEUP_PERIOD) \ 108 hif_mib_name(BLOCK_ACK_POLICY) \ 109 hif_mib_name(CCA_CONFIG) \ 110 hif_mib_name(CONFIG_DATA_FILTER) \ 111 hif_mib_name(COUNTERS_TABLE) \ 112 hif_mib_name(CURRENT_TX_POWER_LEVEL) \ 113 hif_mib_name(DOT11_MAC_ADDRESS) \ 114 hif_mib_name(DOT11_MAX_RECEIVE_LIFETIME) \ 115 hif_mib_name(DOT11_MAX_TRANSMIT_MSDU_LIFETIME) \ 116 hif_mib_name(DOT11_RTS_THRESHOLD) \ 117 hif_mib_name(DOT11_WEP_DEFAULT_KEY_ID) \ 118 hif_mib_name(ETHERTYPE_DATAFRAME_CONDITION) \ 119 hif_mib_name(EXTENDED_COUNTERS_TABLE) \ 120 hif_mib_name(GL_BLOCK_ACK_INFO) \ 121 hif_mib_name(GL_OPERATIONAL_POWER_MODE) \ 122 hif_mib_name(GL_SET_MULTI_MSG) \ 123 hif_mib_name(GRP_SEQ_COUNTER) \ 124 hif_mib_name(INACTIVITY_TIMER) \ 125 hif_mib_name(INTERFACE_PROTECTION) \ 126 hif_mib_name(IPV4_ADDR_DATAFRAME_CONDITION) \ 127 hif_mib_name(IPV6_ADDR_DATAFRAME_CONDITION) \ 128 hif_mib_name(KEEP_ALIVE_PERIOD) \ 129 hif_mib_name(MAC_ADDR_DATAFRAME_CONDITION) \ 130 hif_mib_name(MAGIC_DATAFRAME_CONDITION) \ 131 hif_mib_name(MAX_TX_POWER_LEVEL) \ 132 hif_mib_name(NON_ERP_PROTECTION) \ 133 hif_mib_name(NS_IP_ADDRESSES_TABLE) \ 134 hif_mib_name(OVERRIDE_INTERNAL_TX_RATE) \ 135 hif_mib_name(PORT_DATAFRAME_CONDITION) \ 136 hif_mib_name(PROTECTED_MGMT_POLICY) \ 137 hif_mib_name(RCPI_RSSI_THRESHOLD) \ 138 hif_mib_name(RX_FILTER) \ 139 hif_mib_name(SET_ASSOCIATION_MODE) \ 140 hif_mib_name(SET_DATA_FILTERING) \ 141 hif_mib_name(SET_HT_PROTECTION) \ 142 hif_mib_name(SET_TX_RATE_RETRY_POLICY) \ 143 hif_mib_name(SET_UAPSD_INFORMATION) \ 144 hif_mib_name(SLOT_TIME) \ 145 hif_mib_name(STATISTICS_TABLE) \ 146 hif_mib_name(TEMPLATE_FRAME) \ 147 hif_mib_name(TSF_COUNTER) \ 148 hif_mib_name(UC_MC_BC_DATAFRAME_CONDITION) 149 150#define hif_mib_list_enum _hif_mib_list 151 152#undef hif_mib_name 153#define hif_mib_name(mib) TRACE_DEFINE_ENUM(HIF_MIB_ID_##mib); 154hif_mib_list_enum 155#undef hif_mib_name 156#define hif_mib_name(mib) { HIF_MIB_ID_##mib, #mib }, 157#define hif_mib_list hif_mib_list_enum { -1, NULL } 158 159DECLARE_EVENT_CLASS(hif_data, 160 TP_PROTO(const struct wfx_hif_msg *hif, int tx_fill_level, bool is_recv), 161 TP_ARGS(hif, tx_fill_level, is_recv), 162 TP_STRUCT__entry( 163 __field(int, tx_fill_level) 164 __field(int, msg_id) 165 __field(const char *, msg_type) 166 __field(int, msg_len) 167 __field(int, buf_len) 168 __field(int, if_id) 169 __field(int, mib) 170 __array(u8, buf, 128) 171 ), 172 TP_fast_assign( 173 int header_len; 174 175 __entry->tx_fill_level = tx_fill_level; 176 __entry->msg_len = le16_to_cpu(hif->len); 177 __entry->msg_id = hif->id; 178 __entry->if_id = hif->interface; 179 if (is_recv) 180 __entry->msg_type = __entry->msg_id & 0x80 ? "IND" : "CNF"; 181 else 182 __entry->msg_type = "REQ"; 183 if (!is_recv && 184 (__entry->msg_id == HIF_REQ_ID_READ_MIB || 185 __entry->msg_id == HIF_REQ_ID_WRITE_MIB)) { 186 __entry->mib = le16_to_cpup((__le16 *)hif->body); 187 header_len = 4; 188 } else { 189 __entry->mib = -1; 190 header_len = 0; 191 } 192 __entry->buf_len = min_t(int, __entry->msg_len, sizeof(__entry->buf)) 193 - sizeof(struct wfx_hif_msg) - header_len; 194 memcpy(__entry->buf, hif->body + header_len, __entry->buf_len); 195 ), 196 TP_printk("%d:%d:%s_%s%s%s: %s%s (%d bytes)", 197 __entry->tx_fill_level, 198 __entry->if_id, 199 __entry->msg_type, 200 __print_symbolic(__entry->msg_id, hif_msg_list), 201 __entry->mib != -1 ? "/" : "", 202 __entry->mib != -1 ? __print_symbolic(__entry->mib, hif_mib_list) : "", 203 __print_hex(__entry->buf, __entry->buf_len), 204 __entry->msg_len > sizeof(__entry->buf) ? " ..." : "", 205 __entry->msg_len 206 ) 207); 208DEFINE_EVENT(hif_data, hif_send, 209 TP_PROTO(const struct wfx_hif_msg *hif, int tx_fill_level, bool is_recv), 210 TP_ARGS(hif, tx_fill_level, is_recv)); 211#define _trace_hif_send(hif, tx_fill_level)\ 212 trace_hif_send(hif, tx_fill_level, false) 213DEFINE_EVENT(hif_data, hif_recv, 214 TP_PROTO(const struct wfx_hif_msg *hif, int tx_fill_level, bool is_recv), 215 TP_ARGS(hif, tx_fill_level, is_recv)); 216#define _trace_hif_recv(hif, tx_fill_level)\ 217 trace_hif_recv(hif, tx_fill_level, true) 218 219#define wfx_reg_list_enum \ 220 wfx_reg_name(WFX_REG_CONFIG, "CONFIG") \ 221 wfx_reg_name(WFX_REG_CONTROL, "CONTROL") \ 222 wfx_reg_name(WFX_REG_IN_OUT_QUEUE, "QUEUE") \ 223 wfx_reg_name(WFX_REG_AHB_DPORT, "AHB") \ 224 wfx_reg_name(WFX_REG_BASE_ADDR, "BASE_ADDR") \ 225 wfx_reg_name(WFX_REG_SRAM_DPORT, "SRAM") \ 226 wfx_reg_name(WFX_REG_SET_GEN_R_W, "SET_GEN_R_W") \ 227 wfx_reg_name(WFX_REG_FRAME_OUT, "FRAME_OUT") 228 229#undef wfx_reg_name 230#define wfx_reg_name(sym, name) TRACE_DEFINE_ENUM(sym); 231wfx_reg_list_enum 232#undef wfx_reg_name 233#define wfx_reg_name(sym, name) { sym, name }, 234#define wfx_reg_list wfx_reg_list_enum { -1, NULL } 235 236DECLARE_EVENT_CLASS(io_data, 237 TP_PROTO(int reg, int addr, const void *io_buf, size_t len), 238 TP_ARGS(reg, addr, io_buf, len), 239 TP_STRUCT__entry( 240 __field(int, reg) 241 __field(int, addr) 242 __field(int, msg_len) 243 __field(int, buf_len) 244 __array(u8, buf, 32) 245 __array(u8, addr_str, 10) 246 ), 247 TP_fast_assign( 248 __entry->reg = reg; 249 __entry->addr = addr; 250 __entry->msg_len = len; 251 __entry->buf_len = min_t(int, sizeof(__entry->buf), __entry->msg_len); 252 memcpy(__entry->buf, io_buf, __entry->buf_len); 253 if (addr >= 0) 254 snprintf(__entry->addr_str, 10, "/%08x", addr); 255 else 256 __entry->addr_str[0] = 0; 257 ), 258 TP_printk("%s%s: %s%s (%d bytes)", 259 __print_symbolic(__entry->reg, wfx_reg_list), 260 __entry->addr_str, 261 __print_hex(__entry->buf, __entry->buf_len), 262 __entry->msg_len > sizeof(__entry->buf) ? " ..." : "", 263 __entry->msg_len 264 ) 265); 266DEFINE_EVENT(io_data, io_write, 267 TP_PROTO(int reg, int addr, const void *io_buf, size_t len), 268 TP_ARGS(reg, addr, io_buf, len)); 269#define _trace_io_ind_write(reg, addr, io_buf, len)\ 270 trace_io_write(reg, addr, io_buf, len) 271#define _trace_io_write(reg, io_buf, len) trace_io_write(reg, -1, io_buf, len) 272DEFINE_EVENT(io_data, io_read, 273 TP_PROTO(int reg, int addr, const void *io_buf, size_t len), 274 TP_ARGS(reg, addr, io_buf, len)); 275#define _trace_io_ind_read(reg, addr, io_buf, len)\ 276 trace_io_read(reg, addr, io_buf, len) 277#define _trace_io_read(reg, io_buf, len) trace_io_read(reg, -1, io_buf, len) 278 279DECLARE_EVENT_CLASS(io_data32, 280 TP_PROTO(int reg, int addr, u32 val), 281 TP_ARGS(reg, addr, val), 282 TP_STRUCT__entry( 283 __field(int, reg) 284 __field(int, addr) 285 __field(int, val) 286 __array(u8, addr_str, 10) 287 ), 288 TP_fast_assign( 289 __entry->reg = reg; 290 __entry->addr = addr; 291 __entry->val = val; 292 if (addr >= 0) 293 snprintf(__entry->addr_str, 10, "/%08x", addr); 294 else 295 __entry->addr_str[0] = 0; 296 ), 297 TP_printk("%s%s: %08x", 298 __print_symbolic(__entry->reg, wfx_reg_list), 299 __entry->addr_str, 300 __entry->val 301 ) 302); 303DEFINE_EVENT(io_data32, io_write32, 304 TP_PROTO(int reg, int addr, u32 val), 305 TP_ARGS(reg, addr, val)); 306#define _trace_io_ind_write32(reg, addr, val) trace_io_write32(reg, addr, val) 307#define _trace_io_write32(reg, val) trace_io_write32(reg, -1, val) 308DEFINE_EVENT(io_data32, io_read32, 309 TP_PROTO(int reg, int addr, u32 val), 310 TP_ARGS(reg, addr, val)); 311#define _trace_io_ind_read32(reg, addr, val) trace_io_read32(reg, addr, val) 312#define _trace_io_read32(reg, val) trace_io_read32(reg, -1, val) 313 314DECLARE_EVENT_CLASS(piggyback, 315 TP_PROTO(u32 val, bool ignored), 316 TP_ARGS(val, ignored), 317 TP_STRUCT__entry( 318 __field(int, val) 319 __field(bool, ignored) 320 ), 321 TP_fast_assign( 322 __entry->val = val; 323 __entry->ignored = ignored; 324 ), 325 TP_printk("CONTROL: %08x%s", 326 __entry->val, 327 __entry->ignored ? " (ignored)" : "" 328 ) 329); 330DEFINE_EVENT(piggyback, piggyback, 331 TP_PROTO(u32 val, bool ignored), 332 TP_ARGS(val, ignored)); 333#define _trace_piggyback(val, ignored) trace_piggyback(val, ignored) 334 335TRACE_EVENT(bh_stats, 336 TP_PROTO(int ind, int req, int cnf, int busy, bool release), 337 TP_ARGS(ind, req, cnf, busy, release), 338 TP_STRUCT__entry( 339 __field(int, ind) 340 __field(int, req) 341 __field(int, cnf) 342 __field(int, busy) 343 __field(bool, release) 344 ), 345 TP_fast_assign( 346 __entry->ind = ind; 347 __entry->req = req; 348 __entry->cnf = cnf; 349 __entry->busy = busy; 350 __entry->release = release; 351 ), 352 TP_printk("IND/REQ/CNF:%3d/%3d/%3d, REQ in progress:%3d, WUP: %s", 353 __entry->ind, 354 __entry->req, 355 __entry->cnf, 356 __entry->busy, 357 __entry->release ? "release" : "keep" 358 ) 359); 360#define _trace_bh_stats(ind, req, cnf, busy, release)\ 361 trace_bh_stats(ind, req, cnf, busy, release) 362 363TRACE_EVENT(tx_stats, 364 TP_PROTO(const struct wfx_hif_cnf_tx *tx_cnf, const struct sk_buff *skb, 365 int delay), 366 TP_ARGS(tx_cnf, skb, delay), 367 TP_STRUCT__entry( 368 __field(int, pkt_id) 369 __field(int, delay_media) 370 __field(int, delay_queue) 371 __field(int, delay_fw) 372 __field(int, ack_failures) 373 __field(int, flags) 374 __array(int, rate, 4) 375 __array(int, tx_count, 4) 376 ), 377 TP_fast_assign( 378 /* Keep sync with wfx_rates definition in main.c */ 379 static const int hw_rate[] = { 0, 1, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13 }; 380 const struct ieee80211_tx_info *tx_info = 381 (const struct ieee80211_tx_info *)skb->cb; 382 const struct ieee80211_tx_rate *rates = tx_info->driver_rates; 383 int i; 384 385 __entry->pkt_id = tx_cnf->packet_id; 386 __entry->delay_media = le32_to_cpu(tx_cnf->media_delay); 387 __entry->delay_queue = le32_to_cpu(tx_cnf->tx_queue_delay); 388 __entry->delay_fw = delay; 389 __entry->ack_failures = tx_cnf->ack_failures; 390 if (!tx_cnf->status || __entry->ack_failures) 391 __entry->ack_failures += 1; 392 393 for (i = 0; i < IEEE80211_NUM_ACS; i++) { 394 if (rates[0].flags & IEEE80211_TX_RC_MCS) 395 __entry->rate[i] = rates[i].idx; 396 else 397 __entry->rate[i] = hw_rate[rates[i].idx]; 398 __entry->tx_count[i] = rates[i].count; 399 } 400 __entry->flags = 0; 401 if (rates[0].flags & IEEE80211_TX_RC_MCS) 402 __entry->flags |= 0x01; 403 if (rates[0].flags & IEEE80211_TX_RC_SHORT_GI) 404 __entry->flags |= 0x02; 405 if (rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD) 406 __entry->flags |= 0x04; 407 if (rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) 408 __entry->flags |= 0x08; 409 if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) 410 __entry->flags |= 0x10; 411 if (tx_cnf->status) 412 __entry->flags |= 0x20; 413 if (tx_cnf->status == HIF_STATUS_TX_FAIL_REQUEUE) 414 __entry->flags |= 0x40; 415 ), 416 TP_printk("packet ID: %08x, rate policy: %s %d|%d %d|%d %d|%d %d|%d -> %d attempt, Delays media/queue/total: %4dus/%4dus/%4dus", 417 __entry->pkt_id, 418 __print_flags(__entry->flags, NULL, 419 { 0x01, "M" }, { 0x02, "S" }, { 0x04, "G" }, { 0x08, "R" }, 420 { 0x10, "D" }, { 0x20, "F" }, { 0x40, "Q" }), 421 __entry->rate[0], 422 __entry->tx_count[0], 423 __entry->rate[1], 424 __entry->tx_count[1], 425 __entry->rate[2], 426 __entry->tx_count[2], 427 __entry->rate[3], 428 __entry->tx_count[3], 429 __entry->ack_failures, 430 __entry->delay_media, 431 __entry->delay_queue, 432 __entry->delay_fw 433 ) 434); 435#define _trace_tx_stats(tx_cnf, skb, delay) trace_tx_stats(tx_cnf, skb, delay) 436 437TRACE_EVENT(queues_stats, 438 TP_PROTO(struct wfx_dev *wdev, const struct wfx_queue *elected_queue), 439 TP_ARGS(wdev, elected_queue), 440 TP_STRUCT__entry( 441 __field(int, vif_id) 442 __field(int, queue_id) 443 __array(int, hw, IEEE80211_NUM_ACS * 2) 444 __array(int, drv, IEEE80211_NUM_ACS * 2) 445 __array(int, cab, IEEE80211_NUM_ACS * 2) 446 ), 447 TP_fast_assign( 448 const struct wfx_queue *queue; 449 struct wfx_vif *wvif; 450 int i, j; 451 452 for (j = 0; j < IEEE80211_NUM_ACS * 2; j++) { 453 __entry->hw[j] = -1; 454 __entry->drv[j] = -1; 455 __entry->cab[j] = -1; 456 } 457 __entry->vif_id = -1; 458 __entry->queue_id = -1; 459 wvif = NULL; 460 while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { 461 for (i = 0; i < IEEE80211_NUM_ACS; i++) { 462 j = wvif->id * IEEE80211_NUM_ACS + i; 463 WARN_ON(j >= IEEE80211_NUM_ACS * 2); 464 queue = &wvif->tx_queue[i]; 465 __entry->hw[j] = atomic_read(&queue->pending_frames); 466 __entry->drv[j] = skb_queue_len(&queue->normal); 467 __entry->cab[j] = skb_queue_len(&queue->cab); 468 if (queue == elected_queue) { 469 __entry->vif_id = wvif->id; 470 __entry->queue_id = i; 471 } 472 } 473 } 474 ), 475 TP_printk("got skb from %d/%d, pend. hw/norm/cab: [ %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d ] [ %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d ]", 476 __entry->vif_id, __entry->queue_id, 477 __entry->hw[0], __entry->drv[0], __entry->cab[0], 478 __entry->hw[1], __entry->drv[1], __entry->cab[1], 479 __entry->hw[2], __entry->drv[2], __entry->cab[2], 480 __entry->hw[3], __entry->drv[3], __entry->cab[3], 481 __entry->hw[4], __entry->drv[4], __entry->cab[4], 482 __entry->hw[5], __entry->drv[5], __entry->cab[5], 483 __entry->hw[6], __entry->drv[6], __entry->cab[6], 484 __entry->hw[7], __entry->drv[7], __entry->cab[7] 485 ) 486); 487 488#endif 489 490/* This part must be outside protection */ 491#undef TRACE_INCLUDE_PATH 492#define TRACE_INCLUDE_PATH . 493#undef TRACE_INCLUDE_FILE 494#define TRACE_INCLUDE_FILE traces 495 496#include <trace/define_trace.h>