1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Tracepoints definitions.
5 * Copyright (c) 2018-2019, 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. Instanciate that list_names:
39 * 4. Redefine xxx_name() as a entry of array for __print_symbolic()
42 * #define xxx_name(msg) { msg, #msg },
44 * 5. list_name can now nearlu 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_WAKEUP_PERIOD) \
108 hif_mib_name(BLOCK_ACK_POLICY) \
109 hif_mib_name(CONFIG_DATA_FILTER) \
110 hif_mib_name(COUNTERS_TABLE) \
111 hif_mib_name(CURRENT_TX_POWER_LEVEL) \
112 hif_mib_name(DOT11_MAC_ADDRESS) \
113 hif_mib_name(DOT11_MAX_RECEIVE_LIFETIME) \
114 hif_mib_name(DOT11_MAX_TRANSMIT_MSDU_LIFETIME) \
115 hif_mib_name(DOT11_RTS_THRESHOLD) \
116 hif_mib_name(DOT11_WEP_DEFAULT_KEY_ID) \
117 hif_mib_name(GL_BLOCK_ACK_INFO) \
118 hif_mib_name(GL_OPERATIONAL_POWER_MODE) \
119 hif_mib_name(GL_SET_MULTI_MSG) \
120 hif_mib_name(INACTIVITY_TIMER) \
121 hif_mib_name(INTERFACE_PROTECTION) \
122 hif_mib_name(IPV4_ADDR_DATAFRAME_CONDITION) \
123 hif_mib_name(IPV6_ADDR_DATAFRAME_CONDITION) \
124 hif_mib_name(KEEP_ALIVE_PERIOD) \
125 hif_mib_name(MAC_ADDR_DATAFRAME_CONDITION) \
126 hif_mib_name(NON_ERP_PROTECTION) \
127 hif_mib_name(NS_IP_ADDRESSES_TABLE) \
128 hif_mib_name(OVERRIDE_INTERNAL_TX_RATE) \
129 hif_mib_name(PROTECTED_MGMT_POLICY) \
130 hif_mib_name(RX_FILTER) \
131 hif_mib_name(RCPI_RSSI_THRESHOLD) \
132 hif_mib_name(SET_ASSOCIATION_MODE) \
133 hif_mib_name(SET_DATA_FILTERING) \
134 hif_mib_name(ETHERTYPE_DATAFRAME_CONDITION) \
135 hif_mib_name(SET_HT_PROTECTION) \
136 hif_mib_name(MAGIC_DATAFRAME_CONDITION) \
137 hif_mib_name(SET_TX_RATE_RETRY_POLICY) \
138 hif_mib_name(SET_UAPSD_INFORMATION) \
139 hif_mib_name(PORT_DATAFRAME_CONDITION) \
140 hif_mib_name(SLOT_TIME) \
141 hif_mib_name(STATISTICS_TABLE) \
142 hif_mib_name(TEMPLATE_FRAME) \
143 hif_mib_name(TSF_COUNTER) \
144 hif_mib_name(UC_MC_BC_DATAFRAME_CONDITION)
146 #define hif_mib_list_enum _hif_mib_list
149 #define hif_mib_name(mib) TRACE_DEFINE_ENUM(HIF_MIB_ID_##mib);
152 #define hif_mib_name(mib) { HIF_MIB_ID_##mib, #mib },
153 #define hif_mib_list hif_mib_list_enum { -1, NULL }
155 DECLARE_EVENT_CLASS(hif_data
,
156 TP_PROTO(const struct hif_msg
*hif
, int tx_fill_level
, bool is_recv
),
157 TP_ARGS(hif
, tx_fill_level
, is_recv
),
159 __field(int, tx_fill_level
)
161 __field(const char *, msg_type
)
162 __field(int, msg_len
)
163 __field(int, buf_len
)
166 __array(u8
, buf
, 128)
171 __entry
->tx_fill_level
= tx_fill_level
;
172 __entry
->msg_len
= hif
->len
;
173 __entry
->msg_id
= hif
->id
;
174 __entry
->if_id
= hif
->interface
;
176 __entry
->msg_type
= __entry
->msg_id
& 0x80 ? "IND" : "CNF";
178 __entry
->msg_type
= "REQ";
180 (__entry
->msg_id
== HIF_REQ_ID_READ_MIB
||
181 __entry
->msg_id
== HIF_REQ_ID_WRITE_MIB
)) {
182 __entry
->mib
= le16_to_cpup((u16
*) hif
->body
);
188 __entry
->buf_len
= min_t(int, __entry
->msg_len
,
189 sizeof(__entry
->buf
))
190 - sizeof(struct hif_msg
) - header_len
;
191 memcpy(__entry
->buf
, hif
->body
+ header_len
, __entry
->buf_len
);
193 TP_printk("%d:%d:%s_%s%s%s: %s%s (%d bytes)",
194 __entry
->tx_fill_level
,
196 __print_symbolic(__entry
->msg_id
, hif_msg_list
),
198 __entry
->mib
!= -1 ? "/" : "",
199 __entry
->mib
!= -1 ? __print_symbolic(__entry
->mib
, hif_mib_list
) : "",
200 __print_hex(__entry
->buf
, __entry
->buf_len
),
201 __entry
->msg_len
> sizeof(__entry
->buf
) ? " ..." : "",
205 DEFINE_EVENT(hif_data
, hif_send
,
206 TP_PROTO(const struct hif_msg
*hif
, int tx_fill_level
, bool is_recv
),
207 TP_ARGS(hif
, tx_fill_level
, is_recv
));
208 #define _trace_hif_send(hif, tx_fill_level)\
209 trace_hif_send(hif, tx_fill_level, false)
210 DEFINE_EVENT(hif_data
, hif_recv
,
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_recv(hif, tx_fill_level)\
214 trace_hif_recv(hif, tx_fill_level, true)
216 #define wfx_reg_list_enum \
217 wfx_reg_name(WFX_REG_CONFIG, "CONFIG") \
218 wfx_reg_name(WFX_REG_CONTROL, "CONTROL") \
219 wfx_reg_name(WFX_REG_IN_OUT_QUEUE, "QUEUE") \
220 wfx_reg_name(WFX_REG_AHB_DPORT, "AHB") \
221 wfx_reg_name(WFX_REG_BASE_ADDR, "BASE_ADDR") \
222 wfx_reg_name(WFX_REG_SRAM_DPORT, "SRAM") \
223 wfx_reg_name(WFX_REG_SET_GEN_R_W, "SET_GEN_R_W") \
224 wfx_reg_name(WFX_REG_FRAME_OUT, "FRAME_OUT")
227 #define wfx_reg_name(sym, name) TRACE_DEFINE_ENUM(sym);
230 #define wfx_reg_name(sym, name) { sym, name },
231 #define wfx_reg_list wfx_reg_list_enum { -1, NULL }
233 DECLARE_EVENT_CLASS(io_data
,
234 TP_PROTO(int reg
, int addr
, const void *io_buf
, size_t len
),
235 TP_ARGS(reg
, addr
, io_buf
, len
),
239 __field(int, msg_len
)
240 __field(int, buf_len
)
242 __array(u8
, addr_str
, 10)
246 __entry
->addr
= addr
;
247 __entry
->msg_len
= len
;
248 __entry
->buf_len
= min_t(int, sizeof(__entry
->buf
),
250 memcpy(__entry
->buf
, io_buf
, __entry
->buf_len
);
252 snprintf(__entry
->addr_str
, 10, "/%08x", addr
);
254 __entry
->addr_str
[0] = 0;
256 TP_printk("%s%s: %s%s (%d bytes)",
257 __print_symbolic(__entry
->reg
, wfx_reg_list
),
259 __print_hex(__entry
->buf
, __entry
->buf_len
),
260 __entry
->msg_len
> sizeof(__entry
->buf
) ? " ..." : "",
264 DEFINE_EVENT(io_data
, io_write
,
265 TP_PROTO(int reg
, int addr
, const void *io_buf
, size_t len
),
266 TP_ARGS(reg
, addr
, io_buf
, len
));
267 #define _trace_io_ind_write(reg, addr, io_buf, len)\
268 trace_io_write(reg, addr, io_buf, len)
269 #define _trace_io_write(reg, io_buf, len) trace_io_write(reg, -1, io_buf, len)
270 DEFINE_EVENT(io_data
, io_read
,
271 TP_PROTO(int reg
, int addr
, const void *io_buf
, size_t len
),
272 TP_ARGS(reg
, addr
, io_buf
, len
));
273 #define _trace_io_ind_read(reg, addr, io_buf, len)\
274 trace_io_read(reg, addr, io_buf, len)
275 #define _trace_io_read(reg, io_buf, len) trace_io_read(reg, -1, io_buf, len)
277 DECLARE_EVENT_CLASS(io_data32
,
278 TP_PROTO(int reg
, int addr
, u32 val
),
279 TP_ARGS(reg
, addr
, val
),
284 __array(u8
, addr_str
, 10)
288 __entry
->addr
= addr
;
291 snprintf(__entry
->addr_str
, 10, "/%08x", addr
);
293 __entry
->addr_str
[0] = 0;
295 TP_printk("%s%s: %08x",
296 __print_symbolic(__entry
->reg
, wfx_reg_list
),
301 DEFINE_EVENT(io_data32
, io_write32
,
302 TP_PROTO(int reg
, int addr
, u32 val
),
303 TP_ARGS(reg
, addr
, val
));
304 #define _trace_io_ind_write32(reg, addr, val) trace_io_write32(reg, addr, val)
305 #define _trace_io_write32(reg, val) trace_io_write32(reg, -1, val)
306 DEFINE_EVENT(io_data32
, io_read32
,
307 TP_PROTO(int reg
, int addr
, u32 val
),
308 TP_ARGS(reg
, addr
, val
));
309 #define _trace_io_ind_read32(reg, addr, val) trace_io_read32(reg, addr, val)
310 #define _trace_io_read32(reg, val) trace_io_read32(reg, -1, val)
312 DECLARE_EVENT_CLASS(piggyback
,
313 TP_PROTO(u32 val
, bool ignored
),
314 TP_ARGS(val
, ignored
),
317 __field(bool, ignored
)
321 __entry
->ignored
= ignored
;
323 TP_printk("CONTROL: %08x%s",
325 __entry
->ignored
? " (ignored)" : ""
328 DEFINE_EVENT(piggyback
, piggyback
,
329 TP_PROTO(u32 val
, bool ignored
),
330 TP_ARGS(val
, ignored
));
331 #define _trace_piggyback(val, ignored) trace_piggyback(val, ignored)
333 TRACE_EVENT(bh_stats
,
334 TP_PROTO(int ind
, int req
, int cnf
, int busy
, bool release
),
335 TP_ARGS(ind
, req
, cnf
, busy
, release
),
341 __field(bool, release
)
347 __entry
->busy
= busy
;
348 __entry
->release
= release
;
350 TP_printk("IND/REQ/CNF:%3d/%3d/%3d, REQ in progress:%3d, WUP: %s",
355 __entry
->release
? "release" : "keep"
358 #define _trace_bh_stats(ind, req, cnf, busy, release)\
359 trace_bh_stats(ind, req, cnf, busy, release)
361 TRACE_EVENT(tx_stats
,
362 TP_PROTO(const struct hif_cnf_tx
*tx_cnf
, const struct sk_buff
*skb
,
364 TP_ARGS(tx_cnf
, skb
, delay
),
367 __field(int, delay_media
)
368 __field(int, delay_queue
)
369 __field(int, delay_fw
)
370 __field(int, ack_failures
)
372 __array(int, rate
, 4)
373 __array(int, tx_count
, 4)
376 // Keep sync with wfx_rates definition in main.c
377 static const int hw_rate
[] = { 0, 1, 2, 3, 6, 7, 8, 9,
379 const struct ieee80211_tx_info
*tx_info
=
380 (const struct ieee80211_tx_info
*)skb
->cb
;
381 const struct ieee80211_tx_rate
*rates
= tx_info
->driver_rates
;
384 __entry
->pkt_id
= tx_cnf
->packet_id
;
385 __entry
->delay_media
= tx_cnf
->media_delay
;
386 __entry
->delay_queue
= tx_cnf
->tx_queue_delay
;
387 __entry
->delay_fw
= delay
;
388 __entry
->ack_failures
= tx_cnf
->ack_failures
;
389 if (!tx_cnf
->status
|| __entry
->ack_failures
)
390 __entry
->ack_failures
+= 1;
392 for (i
= 0; i
< IEEE80211_NUM_ACS
; i
++) {
393 if (rates
[0].flags
& IEEE80211_TX_RC_MCS
)
394 __entry
->rate
[i
] = rates
[i
].idx
;
396 __entry
->rate
[i
] = hw_rate
[rates
[i
].idx
];
397 __entry
->tx_count
[i
] = rates
[i
].count
;
400 if (rates
[0].flags
& IEEE80211_TX_RC_MCS
)
401 __entry
->flags
|= 0x01;
402 if (rates
[0].flags
& IEEE80211_TX_RC_SHORT_GI
)
403 __entry
->flags
|= 0x02;
404 if (rates
[0].flags
& IEEE80211_TX_RC_GREEN_FIELD
)
405 __entry
->flags
|= 0x04;
406 if (rates
[0].flags
& IEEE80211_TX_RC_USE_RTS_CTS
)
407 __entry
->flags
|= 0x08;
408 if (tx_info
->flags
& IEEE80211_TX_CTL_SEND_AFTER_DTIM
)
409 __entry
->flags
|= 0x10;
411 __entry
->flags
|= 0x20;
412 if (tx_cnf
->status
== HIF_REQUEUE
)
413 __entry
->flags
|= 0x40;
415 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 __print_flags(__entry
->flags
, NULL
,
418 { 0x01, "M" }, { 0x02, "S" }, { 0x04, "G" },
419 { 0x08, "R" }, { 0x10, "D" }, { 0x20, "F" },
422 __entry
->tx_count
[0],
424 __entry
->tx_count
[1],
426 __entry
->tx_count
[2],
428 __entry
->tx_count
[3],
429 __entry
->ack_failures
,
430 __entry
->delay_media
,
431 __entry
->delay_queue
,
435 #define _trace_tx_stats(tx_cnf, skb, delay) trace_tx_stats(tx_cnf, skb, delay)
439 /* This part must be outside protection */
440 #undef TRACE_INCLUDE_PATH
441 #define TRACE_INCLUDE_PATH .
442 #undef TRACE_INCLUDE_FILE
443 #define TRACE_INCLUDE_FILE traces
445 #include <trace/define_trace.h>