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