treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / staging / wfx / traces.h
blob30c6a13f0e220e2a706de48a67f393c3d28783ca
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Tracepoints definitions.
5 * Copyright (c) 2018-2019, Silicon Laboratories, Inc.
6 */
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM wfx
11 #if !defined(_WFX_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _WFX_TRACE_H
14 #include <linux/tracepoint.h>
15 #include <net/mac80211.h>
17 #include "bus.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 \
31 * ... \
32 * xxx_name(XXX) \
33 * ...
35 * 3. Instanciate that list_names:
37 * list_names
39 * 4. Redefine xxx_name() as a entry of array for __print_symbolic()
41 * #undef xxx_name
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) \
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)
89 #define hif_msg_list_enum _hif_msg_list
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 }
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
148 #undef hif_mib_name
149 #define hif_mib_name(mib) TRACE_DEFINE_ENUM(HIF_MIB_ID_##mib);
150 hif_mib_list_enum
151 #undef hif_mib_name
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),
158 TP_STRUCT__entry(
159 __field(int, tx_fill_level)
160 __field(int, msg_id)
161 __field(const char *, msg_type)
162 __field(int, msg_len)
163 __field(int, buf_len)
164 __field(int, if_id)
165 __field(int, mib)
166 __array(u8, buf, 128)
168 TP_fast_assign(
169 int header_len;
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;
175 if (is_recv)
176 __entry->msg_type = __entry->msg_id & 0x80 ? "IND" : "CNF";
177 else
178 __entry->msg_type = "REQ";
179 if (!is_recv &&
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);
183 header_len = 4;
184 } else {
185 __entry->mib = -1;
186 header_len = 0;
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,
195 __entry->if_id,
196 __print_symbolic(__entry->msg_id, hif_msg_list),
197 __entry->msg_type,
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) ? " ..." : "",
202 __entry->msg_len
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")
226 #undef wfx_reg_name
227 #define wfx_reg_name(sym, name) TRACE_DEFINE_ENUM(sym);
228 wfx_reg_list_enum
229 #undef wfx_reg_name
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),
236 TP_STRUCT__entry(
237 __field(int, reg)
238 __field(int, addr)
239 __field(int, msg_len)
240 __field(int, buf_len)
241 __array(u8, buf, 32)
242 __array(u8, addr_str, 10)
244 TP_fast_assign(
245 __entry->reg = reg;
246 __entry->addr = addr;
247 __entry->msg_len = len;
248 __entry->buf_len = min_t(int, sizeof(__entry->buf),
249 __entry->msg_len);
250 memcpy(__entry->buf, io_buf, __entry->buf_len);
251 if (addr >= 0)
252 snprintf(__entry->addr_str, 10, "/%08x", addr);
253 else
254 __entry->addr_str[0] = 0;
256 TP_printk("%s%s: %s%s (%d bytes)",
257 __print_symbolic(__entry->reg, wfx_reg_list),
258 __entry->addr_str,
259 __print_hex(__entry->buf, __entry->buf_len),
260 __entry->msg_len > sizeof(__entry->buf) ? " ..." : "",
261 __entry->msg_len
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),
280 TP_STRUCT__entry(
281 __field(int, reg)
282 __field(int, addr)
283 __field(int, val)
284 __array(u8, addr_str, 10)
286 TP_fast_assign(
287 __entry->reg = reg;
288 __entry->addr = addr;
289 __entry->val = val;
290 if (addr >= 0)
291 snprintf(__entry->addr_str, 10, "/%08x", addr);
292 else
293 __entry->addr_str[0] = 0;
295 TP_printk("%s%s: %08x",
296 __print_symbolic(__entry->reg, wfx_reg_list),
297 __entry->addr_str,
298 __entry->val
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),
315 TP_STRUCT__entry(
316 __field(int, val)
317 __field(bool, ignored)
319 TP_fast_assign(
320 __entry->val = val;
321 __entry->ignored = ignored;
323 TP_printk("CONTROL: %08x%s",
324 __entry->val,
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),
336 TP_STRUCT__entry(
337 __field(int, ind)
338 __field(int, req)
339 __field(int, cnf)
340 __field(int, busy)
341 __field(bool, release)
343 TP_fast_assign(
344 __entry->ind = ind;
345 __entry->req = req;
346 __entry->cnf = cnf;
347 __entry->busy = busy;
348 __entry->release = release;
350 TP_printk("IND/REQ/CNF:%3d/%3d/%3d, REQ in progress:%3d, WUP: %s",
351 __entry->ind,
352 __entry->req,
353 __entry->cnf,
354 __entry->busy,
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,
363 int delay),
364 TP_ARGS(tx_cnf, skb, delay),
365 TP_STRUCT__entry(
366 __field(int, pkt_id)
367 __field(int, delay_media)
368 __field(int, delay_queue)
369 __field(int, delay_fw)
370 __field(int, ack_failures)
371 __field(int, flags)
372 __array(int, rate, 4)
373 __array(int, tx_count, 4)
375 TP_fast_assign(
376 // Keep sync with wfx_rates definition in main.c
377 static const int hw_rate[] = { 0, 1, 2, 3, 6, 7, 8, 9,
378 10, 11, 12, 13 };
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;
382 int i;
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;
395 else
396 __entry->rate[i] = hw_rate[rates[i].idx];
397 __entry->tx_count[i] = rates[i].count;
399 __entry->flags = 0;
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;
410 if (tx_cnf->status)
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",
416 __entry->pkt_id,
417 __print_flags(__entry->flags, NULL,
418 { 0x01, "M" }, { 0x02, "S" }, { 0x04, "G" },
419 { 0x08, "R" }, { 0x10, "D" }, { 0x20, "F" },
420 { 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
435 #define _trace_tx_stats(tx_cnf, skb, delay) trace_tx_stats(tx_cnf, skb, delay)
437 #endif
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>