xref: /openbmc/linux/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1*4273a380SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2e705c121SKalle Valo /******************************************************************************
3e705c121SKalle Valo  *
4e705c121SKalle Valo  * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
5e705c121SKalle Valo  * Copyright(c) 2015 Intel Mobile Communications GmbH
68790fce4SJohannes Berg  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
738bd7e58SMordechay Goodstein  * Copyright(c) 2018        Intel Corporation
8e705c121SKalle Valo  *****************************************************************************/
9e705c121SKalle Valo 
10e705c121SKalle Valo #if !defined(__IWLWIFI_DEVICE_TRACE_IWLWIFI) || defined(TRACE_HEADER_MULTI_READ)
11e705c121SKalle Valo #define __IWLWIFI_DEVICE_TRACE_IWLWIFI
12e705c121SKalle Valo 
13e705c121SKalle Valo #include <linux/tracepoint.h>
14e705c121SKalle Valo 
15e705c121SKalle Valo #undef TRACE_SYSTEM
16e705c121SKalle Valo #define TRACE_SYSTEM iwlwifi
17e705c121SKalle Valo 
18e705c121SKalle Valo TRACE_EVENT(iwlwifi_dev_hcmd,
19e705c121SKalle Valo 	TP_PROTO(const struct device *dev,
20e705c121SKalle Valo 		 struct iwl_host_cmd *cmd, u16 total_size,
21e705c121SKalle Valo 		 struct iwl_cmd_header_wide *hdr),
22e705c121SKalle Valo 	TP_ARGS(dev, cmd, total_size, hdr),
23e705c121SKalle Valo 	TP_STRUCT__entry(
24e705c121SKalle Valo 		DEV_ENTRY
25e705c121SKalle Valo 		__dynamic_array(u8, hcmd, total_size)
26e705c121SKalle Valo 		__field(u32, flags)
27e705c121SKalle Valo 	),
28e705c121SKalle Valo 	TP_fast_assign(
29e705c121SKalle Valo 		int i, offset = sizeof(struct iwl_cmd_header);
30e705c121SKalle Valo 
31e705c121SKalle Valo 		if (hdr->group_id)
32e705c121SKalle Valo 			offset = sizeof(struct iwl_cmd_header_wide);
33e705c121SKalle Valo 
34e705c121SKalle Valo 		DEV_ASSIGN;
35e705c121SKalle Valo 		__entry->flags = cmd->flags;
36e705c121SKalle Valo 		memcpy(__get_dynamic_array(hcmd), hdr, offset);
37e705c121SKalle Valo 
38e705c121SKalle Valo 		for (i = 0; i < IWL_MAX_CMD_TBS_PER_TFD; i++) {
39e705c121SKalle Valo 			if (!cmd->len[i])
40e705c121SKalle Valo 				continue;
41e705c121SKalle Valo 			memcpy((u8 *)__get_dynamic_array(hcmd) + offset,
42e705c121SKalle Valo 			       cmd->data[i], cmd->len[i]);
43e705c121SKalle Valo 			offset += cmd->len[i];
44e705c121SKalle Valo 		}
45e705c121SKalle Valo 	),
46e705c121SKalle Valo 	TP_printk("[%s] hcmd %#.2x.%#.2x (%ssync)",
47e705c121SKalle Valo 		  __get_str(dev), ((u8 *)__get_dynamic_array(hcmd))[1],
48e705c121SKalle Valo 		  ((u8 *)__get_dynamic_array(hcmd))[0],
49e705c121SKalle Valo 		  __entry->flags & CMD_ASYNC ? "a" : "")
50e705c121SKalle Valo );
51e705c121SKalle Valo 
52e705c121SKalle Valo TRACE_EVENT(iwlwifi_dev_rx,
53e705c121SKalle Valo 	TP_PROTO(const struct device *dev, const struct iwl_trans *trans,
54e705c121SKalle Valo 		 struct iwl_rx_packet *pkt, size_t len),
55e705c121SKalle Valo 	TP_ARGS(dev, trans, pkt, len),
56e705c121SKalle Valo 	TP_STRUCT__entry(
57e705c121SKalle Valo 		DEV_ENTRY
58e0d8fdecSSara Sharon 		__field(u16, cmd)
5938bd7e58SMordechay Goodstein 		__field(u8, hdr_offset)
6038bd7e58SMordechay Goodstein 		__dynamic_array(u8, rxbuf,
6138bd7e58SMordechay Goodstein 				iwl_rx_trace_len(trans, pkt, len, NULL))
62e705c121SKalle Valo 	),
63e705c121SKalle Valo 	TP_fast_assign(
6438bd7e58SMordechay Goodstein 		size_t hdr_offset = 0;
6538bd7e58SMordechay Goodstein 
66e705c121SKalle Valo 		DEV_ASSIGN;
67e0d8fdecSSara Sharon 		__entry->cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
68e705c121SKalle Valo 		memcpy(__get_dynamic_array(rxbuf), pkt,
6938bd7e58SMordechay Goodstein 		       iwl_rx_trace_len(trans, pkt, len, &hdr_offset));
7038bd7e58SMordechay Goodstein 		__entry->hdr_offset = hdr_offset;
71e705c121SKalle Valo 	),
72e705c121SKalle Valo 	TP_printk("[%s] RX cmd %#.2x",
73e705c121SKalle Valo 		  __get_str(dev), __entry->cmd)
74e705c121SKalle Valo );
75e705c121SKalle Valo 
76e705c121SKalle Valo TRACE_EVENT(iwlwifi_dev_tx,
77e705c121SKalle Valo 	TP_PROTO(const struct device *dev, struct sk_buff *skb,
78e705c121SKalle Valo 		 void *tfd, size_t tfdlen,
79e705c121SKalle Valo 		 void *buf0, size_t buf0_len,
808790fce4SJohannes Berg 		 int hdr_len),
818790fce4SJohannes Berg 	TP_ARGS(dev, skb, tfd, tfdlen, buf0, buf0_len, hdr_len),
82e705c121SKalle Valo 	TP_STRUCT__entry(
83e705c121SKalle Valo 		DEV_ENTRY
849829303fSMordechay Goodstein 		__field(void *, skbaddr)
85e705c121SKalle Valo 		__field(size_t, framelen)
86e705c121SKalle Valo 		__dynamic_array(u8, tfd, tfdlen)
87e705c121SKalle Valo 
88e705c121SKalle Valo 		/*
89e705c121SKalle Valo 		 * Do not insert between or below these items,
90e705c121SKalle Valo 		 * we want to keep the frame together (except
91e705c121SKalle Valo 		 * for the possible padding).
92e705c121SKalle Valo 		 */
93e705c121SKalle Valo 		__dynamic_array(u8, buf0, buf0_len)
948790fce4SJohannes Berg 		__dynamic_array(u8, buf1, hdr_len > 0 && iwl_trace_data(skb) ?
958790fce4SJohannes Berg 						0 : skb->len - hdr_len)
96e705c121SKalle Valo 	),
97e705c121SKalle Valo 	TP_fast_assign(
98e705c121SKalle Valo 		DEV_ASSIGN;
999829303fSMordechay Goodstein 		__entry->skbaddr = skb;
1008790fce4SJohannes Berg 		__entry->framelen = buf0_len;
1018790fce4SJohannes Berg 		if (hdr_len > 0)
1028790fce4SJohannes Berg 			__entry->framelen += skb->len - hdr_len;
103e705c121SKalle Valo 		memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
104e705c121SKalle Valo 		memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
1058790fce4SJohannes Berg 		if (hdr_len > 0 && !iwl_trace_data(skb))
1068790fce4SJohannes Berg 			skb_copy_bits(skb, hdr_len,
1078790fce4SJohannes Berg 				      __get_dynamic_array(buf1),
1088790fce4SJohannes Berg 				      skb->len - hdr_len);
109e705c121SKalle Valo 	),
1109829303fSMordechay Goodstein 	TP_printk("[%s] TX %.2x (%zu bytes) skbaddr=%p",
111e705c121SKalle Valo 		  __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0],
1129829303fSMordechay Goodstein 		  __entry->framelen, __entry->skbaddr)
113e705c121SKalle Valo );
114e705c121SKalle Valo 
115e705c121SKalle Valo TRACE_EVENT(iwlwifi_dev_ucode_event,
116e705c121SKalle Valo 	TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev),
117e705c121SKalle Valo 	TP_ARGS(dev, time, data, ev),
118e705c121SKalle Valo 	TP_STRUCT__entry(
119e705c121SKalle Valo 		DEV_ENTRY
120e705c121SKalle Valo 
121e705c121SKalle Valo 		__field(u32, time)
122e705c121SKalle Valo 		__field(u32, data)
123e705c121SKalle Valo 		__field(u32, ev)
124e705c121SKalle Valo 	),
125e705c121SKalle Valo 	TP_fast_assign(
126e705c121SKalle Valo 		DEV_ASSIGN;
127e705c121SKalle Valo 		__entry->time = time;
128e705c121SKalle Valo 		__entry->data = data;
129e705c121SKalle Valo 		__entry->ev = ev;
130e705c121SKalle Valo 	),
131e705c121SKalle Valo 	TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u",
132e705c121SKalle Valo 		  __get_str(dev), __entry->time, __entry->data, __entry->ev)
133e705c121SKalle Valo );
134e705c121SKalle Valo #endif /* __IWLWIFI_DEVICE_TRACE_IWLWIFI */
135e705c121SKalle Valo 
136e705c121SKalle Valo #undef TRACE_INCLUDE_PATH
137e705c121SKalle Valo #define TRACE_INCLUDE_PATH .
138e705c121SKalle Valo #undef TRACE_INCLUDE_FILE
139e705c121SKalle Valo #define TRACE_INCLUDE_FILE iwl-devtrace-iwlwifi
140e705c121SKalle Valo #include <trace/define_trace.h>
141