xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h (revision bd628c1bed7902ec1f24ba0fe70758949146abbe)
1 /******************************************************************************
2  *
3  * This file is provided under a dual BSD/GPLv2 license.  When using or
4  * redistributing this file, you may do so under either license.
5  *
6  * GPL LICENSE SUMMARY
7  *
8  * Copyright(c) 2014 Intel Corporation. All rights reserved.
9  * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
10  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11  * Copyright (C) 2018 Intel Corporation
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of version 2 of the GNU General Public License as
15  * published by the Free Software Foundation.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * The full GNU General Public License is included in this distribution
23  * in the file called COPYING.
24  *
25  * Contact Information:
26  *  Intel Linux Wireless <linuxwifi@intel.com>
27  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28  *
29  * BSD LICENSE
30  *
31  * Copyright(c) 2014 Intel Corporation. All rights reserved.
32  * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
33  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34  * Copyright (C) 2018 Intel Corporation
35  * All rights reserved.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  *
41  *  * Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  *  * Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in
45  *    the documentation and/or other materials provided with the
46  *    distribution.
47  *  * Neither the name Intel Corporation nor the names of its
48  *    contributors may be used to endorse or promote products derived
49  *    from this software without specific prior written permission.
50  *
51  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62  *****************************************************************************/
63 
64 #ifndef __fw_error_dump_h__
65 #define __fw_error_dump_h__
66 
67 #include <linux/types.h>
68 
69 #define IWL_FW_ERROR_DUMP_BARKER	0x14789632
70 
71 /**
72  * enum iwl_fw_error_dump_type - types of data in the dump file
73  * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
74  * @IWL_FW_ERROR_DUMP_RXF:
75  * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
76  *	&struct iwl_fw_error_dump_txcmd packets
77  * @IWL_FW_ERROR_DUMP_DEV_FW_INFO:  struct %iwl_fw_error_dump_info
78  *	info on the device / firmware.
79  * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
80  * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
81  *	sections like this in a single file.
82  * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
83  * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
84  * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump.
85  *	Structured as &struct iwl_fw_error_dump_trigger_desc.
86  * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as
87  *	&struct iwl_fw_error_dump_rb
88  * @IWL_FW_ERROR_PAGING: UMAC's image memory segments which were
89  *	paged to the DRAM.
90  * @IWL_FW_ERROR_DUMP_RADIO_REG: Dump the radio registers.
91  * @IWL_FW_ERROR_DUMP_EXTERNAL: used only by external code utilities, and
92  *	for that reason is not in use in any other place in the Linux Wi-Fi
93  *	stack.
94  * @IWL_FW_ERROR_DUMP_MEM_CFG: the addresses and sizes of fifos in the smem,
95  *	which we get from the fw after ALIVE. The content is structured as
96  *	&struct iwl_fw_error_dump_smem_cfg.
97  */
98 enum iwl_fw_error_dump_type {
99 	/* 0 is deprecated */
100 	IWL_FW_ERROR_DUMP_CSR = 1,
101 	IWL_FW_ERROR_DUMP_RXF = 2,
102 	IWL_FW_ERROR_DUMP_TXCMD = 3,
103 	IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
104 	IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
105 	IWL_FW_ERROR_DUMP_PRPH = 6,
106 	IWL_FW_ERROR_DUMP_TXF = 7,
107 	IWL_FW_ERROR_DUMP_FH_REGS = 8,
108 	IWL_FW_ERROR_DUMP_MEM = 9,
109 	IWL_FW_ERROR_DUMP_ERROR_INFO = 10,
110 	IWL_FW_ERROR_DUMP_RB = 11,
111 	IWL_FW_ERROR_DUMP_PAGING = 12,
112 	IWL_FW_ERROR_DUMP_RADIO_REG = 13,
113 	IWL_FW_ERROR_DUMP_INTERNAL_TXF = 14,
114 	IWL_FW_ERROR_DUMP_EXTERNAL = 15, /* Do not move */
115 	IWL_FW_ERROR_DUMP_MEM_CFG = 16,
116 	IWL_FW_ERROR_DUMP_D3_DEBUG_DATA = 17,
117 
118 	IWL_FW_ERROR_DUMP_MAX,
119 };
120 
121 /**
122  * struct iwl_fw_error_dump_data - data for one type
123  * @type: &enum iwl_fw_error_dump_type
124  * @len: the length starting from %data
125  * @data: the data itself
126  */
127 struct iwl_fw_error_dump_data {
128 	__le32 type;
129 	__le32 len;
130 	__u8 data[];
131 } __packed;
132 
133 /**
134  * struct iwl_fw_error_dump_file - the layout of the header of the file
135  * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
136  * @file_len: the length of all the file starting from %barker
137  * @data: array of &struct iwl_fw_error_dump_data
138  */
139 struct iwl_fw_error_dump_file {
140 	__le32 barker;
141 	__le32 file_len;
142 	u8 data[0];
143 } __packed;
144 
145 /**
146  * struct iwl_fw_error_dump_txcmd - TX command data
147  * @cmdlen: original length of command
148  * @caplen: captured length of command (may be less)
149  * @data: captured command data, @caplen bytes
150  */
151 struct iwl_fw_error_dump_txcmd {
152 	__le32 cmdlen;
153 	__le32 caplen;
154 	u8 data[];
155 } __packed;
156 
157 /**
158  * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
159  * @fifo_num: number of FIFO (starting from 0)
160  * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
161  * @wr_ptr: position of write pointer
162  * @rd_ptr: position of read pointer
163  * @fence_ptr: position of fence pointer
164  * @fence_mode: the current mode of the fence (before locking) -
165  *	0=follow RD pointer ; 1 = freeze
166  * @data: all of the FIFO's data
167  */
168 struct iwl_fw_error_dump_fifo {
169 	__le32 fifo_num;
170 	__le32 available_bytes;
171 	__le32 wr_ptr;
172 	__le32 rd_ptr;
173 	__le32 fence_ptr;
174 	__le32 fence_mode;
175 	u8 data[];
176 } __packed;
177 
178 enum iwl_fw_error_dump_family {
179 	IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
180 	IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
181 };
182 
183 /**
184  * struct iwl_fw_error_dump_info - info on the device / firmware
185  * @device_family: the family of the device (7 / 8)
186  * @hw_step: the step of the device
187  * @fw_human_readable: human readable FW version
188  * @dev_human_readable: name of the device
189  * @bus_human_readable: name of the bus used
190  * @rt_status: the error_id/rt_status that that triggered the latest dump
191  *	if the dump collection was not initiated by an assert, the value is 0
192  */
193 struct iwl_fw_error_dump_info {
194 	__le32 device_family;
195 	__le32 hw_step;
196 	u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
197 	u8 dev_human_readable[64];
198 	u8 bus_human_readable[8];
199 	__le32 rt_status;
200 } __packed;
201 
202 /**
203  * struct iwl_fw_error_dump_fw_mon - FW monitor data
204  * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
205  * @fw_mon_base_ptr: base pointer of the data
206  * @fw_mon_cycle_cnt: number of wraparounds
207  * @reserved: for future use
208  * @data: captured data
209  */
210 struct iwl_fw_error_dump_fw_mon {
211 	__le32 fw_mon_wr_ptr;
212 	__le32 fw_mon_base_ptr;
213 	__le32 fw_mon_cycle_cnt;
214 	__le32 reserved[3];
215 	u8 data[];
216 } __packed;
217 
218 #define MAX_NUM_LMAC 2
219 #define TX_FIFO_INTERNAL_MAX_NUM	6
220 #define TX_FIFO_MAX_NUM			15
221 /**
222  * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration
223  *	This must follow &struct iwl_fwrt_shared_mem_cfg.
224  * @num_lmacs: number of lmacs
225  * @num_txfifo_entries: number of tx fifos
226  * @lmac: sizes of lmacs txfifos and rxfifo1
227  * @rxfifo2_size: size of rxfifo2
228  * @internal_txfifo_addr: address of internal tx fifo
229  * @internal_txfifo_size: size of internal tx fifo
230  */
231 struct iwl_fw_error_dump_smem_cfg {
232 	__le32 num_lmacs;
233 	__le32 num_txfifo_entries;
234 	struct {
235 		__le32 txfifo_size[TX_FIFO_MAX_NUM];
236 		__le32 rxfifo1_size;
237 	} lmac[MAX_NUM_LMAC];
238 	__le32 rxfifo2_size;
239 	__le32 internal_txfifo_addr;
240 	__le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
241 } __packed;
242 /**
243  * struct iwl_fw_error_dump_prph - periphery registers data
244  * @prph_start: address of the first register in this chunk
245  * @data: the content of the registers
246  */
247 struct iwl_fw_error_dump_prph {
248 	__le32 prph_start;
249 	__le32 data[];
250 };
251 
252 enum iwl_fw_error_dump_mem_type {
253 	IWL_FW_ERROR_DUMP_MEM_SRAM,
254 	IWL_FW_ERROR_DUMP_MEM_SMEM,
255 	IWL_FW_ERROR_DUMP_MEM_NAMED_MEM = 10,
256 };
257 
258 /**
259  * struct iwl_fw_error_dump_mem - chunk of memory
260  * @type: &enum iwl_fw_error_dump_mem_type
261  * @offset: the offset from which the memory was read
262  * @data: the content of the memory
263  */
264 struct iwl_fw_error_dump_mem {
265 	__le32 type;
266 	__le32 offset;
267 	u8 data[];
268 };
269 
270 /**
271  * struct iwl_fw_error_dump_named_mem - chunk of memory
272  * @type: &enum iwl_fw_error_dump_mem_type
273  * @offset: the offset from which the memory was read
274  * @name_len: name length
275  * @name: file name
276  * @data: the content of the memory
277  */
278 struct iwl_fw_error_dump_named_mem {
279 	__le32 type;
280 	__le32 offset;
281 	u8 name_len;
282 	u8 name[32];
283 	u8 data[];
284 };
285 
286 /**
287  * struct iwl_fw_error_dump_rb - content of an Receive Buffer
288  * @index: the index of the Receive Buffer in the Rx queue
289  * @rxq: the RB's Rx queue
290  * @reserved:
291  * @data: the content of the Receive Buffer
292  */
293 struct iwl_fw_error_dump_rb {
294 	__le32 index;
295 	__le32 rxq;
296 	__le32 reserved;
297 	u8 data[];
298 };
299 
300 /**
301  * struct iwl_fw_error_dump_paging - content of the UMAC's image page
302  *	block on DRAM
303  * @index: the index of the page block
304  * @reserved:
305  * @data: the content of the page block
306  */
307 struct iwl_fw_error_dump_paging {
308 	__le32 index;
309 	__le32 reserved;
310 	u8 data[];
311 };
312 
313 /**
314  * iwl_fw_error_next_data - advance fw error dump data pointer
315  * @data: previous data block
316  * Returns: next data block
317  */
318 static inline struct iwl_fw_error_dump_data *
319 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
320 {
321 	return (void *)(data->data + le32_to_cpu(data->len));
322 }
323 
324 /**
325  * enum iwl_fw_dbg_trigger - triggers available
326  *
327  * @FW_DBG_TRIGGER_USER: trigger log collection by user
328  *	This should not be defined as a trigger to the driver, but a value the
329  *	driver should set to indicate that the trigger was initiated by the
330  *	user.
331  * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
332  * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
333  *	missed.
334  * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
335  * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
336  *	command response or a notification.
337  * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
338  * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
339  * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
340  *	goes below a threshold.
341  * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
342  *	detection.
343  * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
344  *	events.
345  * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
346  * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a
347  *	threshold.
348  * @FW_DBG_TDLS: trigger log collection upon TDLS related events.
349  * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when
350  *  the firmware sends a tx reply.
351  * @FW_DBG_TRIGGER_NO_ALIVE: trigger log collection if alive flow fails
352  */
353 enum iwl_fw_dbg_trigger {
354 	FW_DBG_TRIGGER_INVALID = 0,
355 	FW_DBG_TRIGGER_USER,
356 	FW_DBG_TRIGGER_FW_ASSERT,
357 	FW_DBG_TRIGGER_MISSED_BEACONS,
358 	FW_DBG_TRIGGER_CHANNEL_SWITCH,
359 	FW_DBG_TRIGGER_FW_NOTIF,
360 	FW_DBG_TRIGGER_MLME,
361 	FW_DBG_TRIGGER_STATS,
362 	FW_DBG_TRIGGER_RSSI,
363 	FW_DBG_TRIGGER_TXQ_TIMERS,
364 	FW_DBG_TRIGGER_TIME_EVENT,
365 	FW_DBG_TRIGGER_BA,
366 	FW_DBG_TRIGGER_TX_LATENCY,
367 	FW_DBG_TRIGGER_TDLS,
368 	FW_DBG_TRIGGER_TX_STATUS,
369 	FW_DBG_TRIGGER_NO_ALIVE,
370 
371 	/* must be last */
372 	FW_DBG_TRIGGER_MAX,
373 };
374 
375 /**
376  * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
377  * @type: &enum iwl_fw_dbg_trigger
378  * @data: raw data about what happened
379  */
380 struct iwl_fw_error_dump_trigger_desc {
381 	__le32 type;
382 	u8 data[];
383 };
384 
385 #endif /* __fw_error_dump_h__ */
386