1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Tracepoints definitions.
5 * Copyright (c) 2018-2020, Silicon Laboratories, Inc.
9 #define TRACE_SYSTEM wfx
11 #if !defined(_WFX_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
14 #include <linux/tracepoint.h>
15 #include <net/mac80211.h>
18 #include "hif_api_cmd.h"
19 #include "hif_api_mib.h"
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.
24 * 1. Define a new macro that call TRACE_DEFINE_ENUM():
26 * #define xxx_name(sym) TRACE_DEFINE_ENUM(sym);
28 * 2. Define list of all symbols:
30 * #define list_names \
35 * 3. Instantiate that list_names:
39 * 4. Redefine xxx_name() as an entry of array for __print_symbolic()
42 * #define xxx_name(msg) { msg, #msg },
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:
48 * #define list_for_print_symbolic list_names { -1, NULL }
51 #define _hif_msg_list \
52 hif_cnf_name(ADD_KEY) \
53 hif_cnf_name(BEACON_TRANSMIT) \
54 hif_cnf_name(EDCA_QUEUE_PARAMS) \
56 hif_cnf_name(MAP_LINK) \
57 hif_cnf_name(READ_MIB) \
58 hif_cnf_name(REMOVE_KEY) \
60 hif_cnf_name(SET_BSS_PARAMS) \
61 hif_cnf_name(SET_PM_MODE) \
63 hif_cnf_name(START_SCAN) \
64 hif_cnf_name(STOP_SCAN) \
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) \
77 hif_ind_name(JOIN_COMPLETE) \
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) \
84 hif_ind_name(EXCEPTION) \
85 hif_ind_name(GENERIC) \
86 hif_ind_name(WAKEUP) \
89 #define hif_msg_list_enum _hif_msg_list
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);
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 }
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)
151 #define hif_mib_list_enum _hif_mib_list
154 #define hif_mib_name(mib) TRACE_DEFINE_ENUM(HIF_MIB_ID_##mib);
157 #define hif_mib_name(mib) { HIF_MIB_ID_##mib, #mib },
158 #define hif_mib_list hif_mib_list_enum { -1, NULL }
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
),
164 __field(int, tx_fill_level
)
166 __field(const char *, msg_type
)
167 __field(int, msg_len
)
168 __field(int, buf_len
)
171 __array(u8
, buf
, 128)
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
;
181 __entry
->msg_type
= __entry
->msg_id
& 0x80 ? "IND" : "CNF";
183 __entry
->msg_type
= "REQ";
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
);
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
);
198 TP_printk("%d:%d:%s_%s%s%s: %s%s (%d bytes)",
199 __entry
->tx_fill_level
,
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
) ? " ..." : "",
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)
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")
232 #define wfx_reg_name(sym, name) TRACE_DEFINE_ENUM(sym);
235 #define wfx_reg_name(sym, name) { sym, name },
236 #define wfx_reg_list wfx_reg_list_enum { -1, NULL }
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
),
244 __field(int, msg_len
)
245 __field(int, buf_len
)
247 __array(u8
, addr_str
, 10)
251 __entry
->addr
= addr
;
252 __entry
->msg_len
= len
;
253 __entry
->buf_len
= min_t(int, sizeof(__entry
->buf
),
255 memcpy(__entry
->buf
, io_buf
, __entry
->buf_len
);
257 snprintf(__entry
->addr_str
, 10, "/%08x", addr
);
259 __entry
->addr_str
[0] = 0;
261 TP_printk("%s%s: %s%s (%d bytes)",
262 __print_symbolic(__entry
->reg
, wfx_reg_list
),
264 __print_hex(__entry
->buf
, __entry
->buf_len
),
265 __entry
->msg_len
> sizeof(__entry
->buf
) ? " ..." : "",
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)
282 DECLARE_EVENT_CLASS(io_data32
,
283 TP_PROTO(int reg
, int addr
, u32 val
),
284 TP_ARGS(reg
, addr
, val
),
289 __array(u8
, addr_str
, 10)
293 __entry
->addr
= addr
;
296 snprintf(__entry
->addr_str
, 10, "/%08x", addr
);
298 __entry
->addr_str
[0] = 0;
300 TP_printk("%s%s: %08x",
301 __print_symbolic(__entry
->reg
, wfx_reg_list
),
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)
317 DECLARE_EVENT_CLASS(piggyback
,
318 TP_PROTO(u32 val
, bool ignored
),
319 TP_ARGS(val
, ignored
),
322 __field(bool, ignored
)
326 __entry
->ignored
= ignored
;
328 TP_printk("CONTROL: %08x%s",
330 __entry
->ignored
? " (ignored)" : ""
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)
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
),
346 __field(bool, release
)
352 __entry
->busy
= busy
;
353 __entry
->release
= release
;
355 TP_printk("IND/REQ/CNF:%3d/%3d/%3d, REQ in progress:%3d, WUP: %s",
360 __entry
->release
? "release" : "keep"
363 #define _trace_bh_stats(ind, req, cnf, busy, release)\
364 trace_bh_stats(ind, req, cnf, busy, release)
366 TRACE_EVENT(tx_stats
,
367 TP_PROTO(const struct hif_cnf_tx
*tx_cnf
, const struct sk_buff
*skb
,
369 TP_ARGS(tx_cnf
, skb
, delay
),
372 __field(int, delay_media
)
373 __field(int, delay_queue
)
374 __field(int, delay_fw
)
375 __field(int, ack_failures
)
377 __array(int, rate
, 4)
378 __array(int, tx_count
, 4)
381 // Keep sync with wfx_rates definition in main.c
382 static const int hw_rate
[] = { 0, 1, 2, 3, 6, 7, 8, 9,
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
;
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;
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
;
401 __entry
->rate
[i
] = hw_rate
[rates
[i
].idx
];
402 __entry
->tx_count
[i
] = rates
[i
].count
;
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;
416 __entry
->flags
|= 0x20;
417 if (tx_cnf
->status
== HIF_STATUS_TX_FAIL_REQUEUE
)
418 __entry
->flags
|= 0x40;
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",
422 __print_flags(__entry
->flags
, NULL
,
423 { 0x01, "M" }, { 0x02, "S" }, { 0x04, "G" },
424 { 0x08, "R" }, { 0x10, "D" }, { 0x20, "F" },
427 __entry
->tx_count
[0],
429 __entry
->tx_count
[1],
431 __entry
->tx_count
[2],
433 __entry
->tx_count
[3],
434 __entry
->ack_failures
,
435 __entry
->delay_media
,
436 __entry
->delay_queue
,
440 #define _trace_tx_stats(tx_cnf, skb, delay) trace_tx_stats(tx_cnf, skb, delay)
442 TRACE_EVENT(queues_stats
,
443 TP_PROTO(struct wfx_dev
*wdev
, const struct wfx_queue
*elected_queue
),
444 TP_ARGS(wdev
, elected_queue
),
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)
453 const struct wfx_queue
*queue
;
454 struct wfx_vif
*wvif
;
457 for (j
= 0; j
< IEEE80211_NUM_ACS
* 2; j
++) {
459 __entry
->drv
[j
] = -1;
460 __entry
->cab
[j
] = -1;
462 __entry
->vif_id
= -1;
463 __entry
->queue_id
= -1;
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
;
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]
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
501 #include <trace/define_trace.h>