summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwmc3200wifi/trace.h
blob: abb4805fa8dfe2b82d8aee77ece564524ca7f596 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#if !defined(__IWM_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
#define __IWM_TRACE_H__

#include <linux/tracepoint.h>

#if !defined(CONFIG_IWM_TRACING)
#undef TRACE_EVENT
#define TRACE_EVENT(name, proto, ...) \
static inline void trace_ ## name(proto) {}
#endif

#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwm

#define IWM_ENTRY	__array(char, ndev_name, 16)
#define IWM_ASSIGN	strlcpy(__entry->ndev_name, iwm_to_ndev(iwm)->name, 16)
#define IWM_PR_FMT	"%s"
#define IWM_PR_ARG	__entry->ndev_name

TRACE_EVENT(iwm_tx_nonwifi_cmd,
	TP_PROTO(struct iwm_priv *iwm, struct iwm_udma_out_nonwifi_hdr *hdr),

	TP_ARGS(iwm, hdr),

	TP_STRUCT__entry(
		IWM_ENTRY
		__field(u8, opcode)
		__field(u8, resp)
		__field(u8, eot)
		__field(u8, hw)
		__field(u16, seq)
		__field(u32, addr)
		__field(u32, op1)
		__field(u32, op2)
	),

	TP_fast_assign(
		IWM_ASSIGN;
		__entry->opcode = GET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_OPCODE);
		__entry->resp = GET_VAL32(hdr->cmd, UDMA_HDI_OUT_NW_CMD_RESP);
		__entry->eot = GET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_EOT);
		__entry->hw = GET_VAL32(hdr->cmd, UDMA_HDI_OUT_NW_CMD_HANDLE_BY_HW);
		__entry->seq = GET_VAL32(hdr->cmd, UDMA_HDI_OUT_CMD_NON_WIFI_HW_SEQ_NUM);
		__entry->addr = le32_to_cpu(hdr->addr);
		__entry->op1 = le32_to_cpu(hdr->op1_sz);
		__entry->op2 = le32_to_cpu(hdr->op2);
	),

	TP_printk(
		IWM_PR_FMT " Tx TARGET CMD: opcode 0x%x, resp %d, eot %d, "
		"hw %d, seq 0x%x, addr 0x%x, op1 0x%x, op2 0x%x",
		IWM_PR_ARG, __entry->opcode, __entry->resp, __entry->eot,
		__entry->hw, __entry->seq, __entry->addr, __entry->op1,
		__entry->op2
	)
);

TRACE_EVENT(iwm_tx_wifi_cmd,
	TP_PROTO(struct iwm_priv *iwm, struct iwm_umac_wifi_out_hdr *hdr),

	TP_ARGS(iwm, hdr),

	TP_STRUCT__entry(
		IWM_ENTRY
		__field(u8, opcode)
		__field(u8, lmac)
		__field(u8, resp)
		__field(u8, eot)
		__field(u8, ra_tid)
		__field(u8, credit_group)
		__field(u8, color)
		__field(u16, seq)
	),

	TP_fast_assign(
		IWM_ASSIGN;
		__entry->opcode = hdr->sw_hdr.cmd.cmd;
		__entry->lmac = 0;
		__entry->seq = __le16_to_cpu(hdr->sw_hdr.cmd.seq_num);
		__entry->resp = GET_VAL8(hdr->sw_hdr.cmd.flags, UMAC_DEV_CMD_FLAGS_RESP_REQ);
		__entry->color = GET_VAL32(hdr->sw_hdr.meta_data, UMAC_FW_CMD_TX_STA_COLOR);
		__entry->eot = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_OUT_CMD_EOT);
		__entry->ra_tid = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_RATID);
		__entry->credit_group = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_CREDIT_GRP);
		if (__entry->opcode == UMAC_CMD_OPCODE_WIFI_PASS_THROUGH ||
		    __entry->opcode == UMAC_CMD_OPCODE_WIFI_IF_WRAPPER) {
			__entry->lmac = 1;
			__entry->opcode = ((struct iwm_lmac_hdr *)(hdr + 1))->id;
		}
	),

	TP_printk(
		IWM_PR_FMT " Tx %cMAC CMD: opcode 0x%x, resp %d, eot %d, "
		"seq 0x%x, sta_color 0x%x, ra_tid 0x%x, credit_group 0x%x",
		IWM_PR_ARG, __entry->lmac ? 'L' : 'U', __entry->opcode,
		__entry->resp, __entry->eot, __entry->seq, __entry->color,
		__entry->ra_tid, __entry->credit_group
	)
);

TRACE_EVENT(iwm_tx_packets,
	TP_PROTO(struct iwm_priv *iwm, u8 *buf, int len),

	TP_ARGS(iwm, buf, len),

	TP_STRUCT__entry(
		IWM_ENTRY
		__field(u8, eot)
		__field(u8, ra_tid)
		__field(u8, credit_group)
		__field(u8, color)
		__field(u16, seq)
		__field(u8, npkt)
		__field(u32, bytes)
	),

	TP_fast_assign(
		struct iwm_umac_wifi_out_hdr *hdr =
			(struct iwm_umac_wifi_out_hdr *)buf;

		IWM_ASSIGN;
		__entry->eot = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_OUT_CMD_EOT);
		__entry->ra_tid = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_RATID);
		__entry->credit_group = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_CREDIT_GRP);
		__entry->color = GET_VAL32(hdr->sw_hdr.meta_data, UMAC_FW_CMD_TX_STA_COLOR);
		__entry->seq = __le16_to_cpu(hdr->sw_hdr.cmd.seq_num);
		__entry->npkt = 1;
		__entry->bytes = len;

		if (!__entry->eot) {
			int count;
			u8 *ptr = buf;

			__entry->npkt = 0;
			while (ptr < buf + len) {
				count = GET_VAL32(hdr->sw_hdr.meta_data,
						  UMAC_FW_CMD_BYTE_COUNT);
				ptr += ALIGN(sizeof(*hdr) + count, 16);
				hdr = (struct iwm_umac_wifi_out_hdr *)ptr;
				__entry->npkt++;
			}
		}
	),

	TP_printk(
		IWM_PR_FMT " Tx %spacket: eot %d, seq 0x%x, sta_color 0x%x, "
		"ra_tid 0x%x, credit_group 0x%x, embeded_packets %d, %d bytes",
		IWM_PR_ARG, !__entry->eot ? "concatenated " : "",
		__entry->eot, __entry->seq, __entry->color, __entry->ra_tid,
		__entry->credit_group, __entry->npkt, __entry->bytes
	)
);

TRACE_EVENT(iwm_rx_nonwifi_cmd,
	TP_PROTO(struct iwm_priv *iwm, void *buf, int len),

	TP_ARGS(iwm, buf, len),

	TP_STRUCT__entry(
		IWM_ENTRY
		__field(u8, opcode)
		__field(u16, seq)
		__field(u32, len)
	),

	TP_fast_assign(
		struct iwm_udma_in_hdr *hdr = buf;

		IWM_ASSIGN;
		__entry->opcode = GET_VAL32(hdr->cmd, UDMA_HDI_IN_NW_CMD_OPCODE);
		__entry->seq = GET_VAL32(hdr->cmd, UDMA_HDI_IN_CMD_NON_WIFI_HW_SEQ_NUM);
		__entry->len = len;
	),

	TP_printk(
		IWM_PR_FMT " Rx TARGET RESP: opcode 0x%x, seq 0x%x, len 0x%x",
		IWM_PR_ARG, __entry->opcode, __entry->seq, __entry->len
	)
);

TRACE_EVENT(iwm_rx_wifi_cmd,
	TP_PROTO(struct iwm_priv *iwm, struct iwm_umac_wifi_in_hdr *hdr),

	TP_ARGS(iwm, hdr),

	TP_STRUCT__entry(
		IWM_ENTRY
		__field(u8, cmd)
		__field(u8, source)
		__field(u16, seq)
		__field(u32, count)
	),

	TP_fast_assign(
		IWM_ASSIGN;
		__entry->cmd = hdr->sw_hdr.cmd.cmd;
		__entry->source = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE);
		__entry->count = GET_VAL32(hdr->sw_hdr.meta_data, UMAC_FW_CMD_BYTE_COUNT);
		__entry->seq = le16_to_cpu(hdr->sw_hdr.cmd.seq_num);
	),

	TP_printk(
		IWM_PR_FMT " Rx %s RESP: cmd 0x%x, seq 0x%x, count 0x%x",
		IWM_PR_ARG, __entry->source == UMAC_HDI_IN_SOURCE_FHRX ? "LMAC" :
		__entry->source == UMAC_HDI_IN_SOURCE_FW ? "UMAC" : "UDMA",
		__entry->cmd, __entry->seq, __entry->count
	)
);

#define iwm_ticket_action_symbol		\
	{ IWM_RX_TICKET_DROP, "DROP" },		\
	{ IWM_RX_TICKET_RELEASE, "RELEASE" },	\
	{ IWM_RX_TICKET_SNIFFER, "SNIFFER" },	\
	{ IWM_RX_TICKET_ENQUEUE, "ENQUEUE" }

TRACE_EVENT(iwm_rx_ticket,
	TP_PROTO(struct iwm_priv *iwm, void *buf, int len),

	TP_ARGS(iwm, buf, len),

	TP_STRUCT__entry(
		IWM_ENTRY
		__field(u8, action)
		__field(u8, reason)
		__field(u16, id)
		__field(u16, flags)
	),

	TP_fast_assign(
		struct iwm_rx_ticket *ticket =
			((struct iwm_umac_notif_rx_ticket *)buf)->tickets;

		IWM_ASSIGN;
		__entry->id = le16_to_cpu(ticket->id);
		__entry->action = le16_to_cpu(ticket->action);
		__entry->flags = le16_to_cpu(ticket->flags);
		__entry->reason = (__entry->flags & IWM_RX_TICKET_DROP_REASON_MSK) >> IWM_RX_TICKET_DROP_REASON_POS;
	),

	TP_printk(
		IWM_PR_FMT " Rx ticket: id 0x%x, action %s, %s 0x%x%s",
		IWM_PR_ARG, __entry->id,
		__print_symbolic(__entry->action, iwm_ticket_action_symbol),
		__entry->reason ? "reason" : "flags",
		__entry->reason ? __entry->reason : __entry->flags,
		__entry->flags & IWM_RX_TICKET_AMSDU_MSK ? ", AMSDU frame" : ""
	)
);

TRACE_EVENT(iwm_rx_packet,
	TP_PROTO(struct iwm_priv *iwm, void *buf, int len),

	TP_ARGS(iwm, buf, len),

	TP_STRUCT__entry(
		IWM_ENTRY
		__field(u8, source)
		__field(u16, id)
		__field(u32, len)
	),

	TP_fast_assign(
		struct iwm_umac_wifi_in_hdr *hdr = buf;

		IWM_ASSIGN;
		__entry->source = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE);
		__entry->id = le16_to_cpu(hdr->sw_hdr.cmd.seq_num);
		__entry->len = len - sizeof(*hdr);
	),

	TP_printk(
		IWM_PR_FMT " Rx %s packet: id 0x%x, %d bytes",
		IWM_PR_ARG, __entry->source == UMAC_HDI_IN_SOURCE_FHRX ?
		"LMAC" : "UMAC", __entry->id, __entry->len
	)
);
#endif

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace
#include <trace/define_trace.h>
OpenPOWER on IntegriCloud