xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h (revision b8d312aa075f33282565467662c4628dae0a2aff)
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 - 2019 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 - 2019 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 #define IWL_FW_INI_ERROR_DUMP_BARKER	0x14789633
71 
72 /**
73  * enum iwl_fw_error_dump_type - types of data in the dump file
74  * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
75  * @IWL_FW_ERROR_DUMP_RXF:
76  * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
77  *	&struct iwl_fw_error_dump_txcmd packets
78  * @IWL_FW_ERROR_DUMP_DEV_FW_INFO:  struct %iwl_fw_error_dump_info
79  *	info on the device / firmware.
80  * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
81  * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
82  *	sections like this in a single file.
83  * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
84  * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
85  * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump.
86  *	Structured as &struct iwl_fw_error_dump_trigger_desc.
87  * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as
88  *	&struct iwl_fw_error_dump_rb
89  * @IWL_FW_ERROR_PAGING: UMAC's image memory segments which were
90  *	paged to the DRAM.
91  * @IWL_FW_ERROR_DUMP_RADIO_REG: Dump the radio registers.
92  * @IWL_FW_ERROR_DUMP_EXTERNAL: used only by external code utilities, and
93  *	for that reason is not in use in any other place in the Linux Wi-Fi
94  *	stack.
95  * @IWL_FW_ERROR_DUMP_MEM_CFG: the addresses and sizes of fifos in the smem,
96  *	which we get from the fw after ALIVE. The content is structured as
97  *	&struct iwl_fw_error_dump_smem_cfg.
98  */
99 enum iwl_fw_error_dump_type {
100 	/* 0 is deprecated */
101 	IWL_FW_ERROR_DUMP_CSR = 1,
102 	IWL_FW_ERROR_DUMP_RXF = 2,
103 	IWL_FW_ERROR_DUMP_TXCMD = 3,
104 	IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
105 	IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
106 	IWL_FW_ERROR_DUMP_PRPH = 6,
107 	IWL_FW_ERROR_DUMP_TXF = 7,
108 	IWL_FW_ERROR_DUMP_FH_REGS = 8,
109 	IWL_FW_ERROR_DUMP_MEM = 9,
110 	IWL_FW_ERROR_DUMP_ERROR_INFO = 10,
111 	IWL_FW_ERROR_DUMP_RB = 11,
112 	IWL_FW_ERROR_DUMP_PAGING = 12,
113 	IWL_FW_ERROR_DUMP_RADIO_REG = 13,
114 	IWL_FW_ERROR_DUMP_INTERNAL_TXF = 14,
115 	IWL_FW_ERROR_DUMP_EXTERNAL = 15, /* Do not move */
116 	IWL_FW_ERROR_DUMP_MEM_CFG = 16,
117 	IWL_FW_ERROR_DUMP_D3_DEBUG_DATA = 17,
118 
119 	IWL_FW_ERROR_DUMP_MAX,
120 };
121 
122 /**
123  * struct iwl_fw_error_dump_data - data for one type
124  * @type: &enum iwl_fw_error_dump_type
125  * @len: the length starting from %data
126  * @data: the data itself
127  */
128 struct iwl_fw_error_dump_data {
129 	__le32 type;
130 	__le32 len;
131 	__u8 data[];
132 } __packed;
133 
134 /**
135  * struct iwl_fw_error_dump_file - the layout of the header of the file
136  * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
137  * @file_len: the length of all the file starting from %barker
138  * @data: array of &struct iwl_fw_error_dump_data
139  */
140 struct iwl_fw_error_dump_file {
141 	__le32 barker;
142 	__le32 file_len;
143 	u8 data[0];
144 } __packed;
145 
146 /**
147  * struct iwl_fw_error_dump_txcmd - TX command data
148  * @cmdlen: original length of command
149  * @caplen: captured length of command (may be less)
150  * @data: captured command data, @caplen bytes
151  */
152 struct iwl_fw_error_dump_txcmd {
153 	__le32 cmdlen;
154 	__le32 caplen;
155 	u8 data[];
156 } __packed;
157 
158 /**
159  * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
160  * @fifo_num: number of FIFO (starting from 0)
161  * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
162  * @wr_ptr: position of write pointer
163  * @rd_ptr: position of read pointer
164  * @fence_ptr: position of fence pointer
165  * @fence_mode: the current mode of the fence (before locking) -
166  *	0=follow RD pointer ; 1 = freeze
167  * @data: all of the FIFO's data
168  */
169 struct iwl_fw_error_dump_fifo {
170 	__le32 fifo_num;
171 	__le32 available_bytes;
172 	__le32 wr_ptr;
173 	__le32 rd_ptr;
174 	__le32 fence_ptr;
175 	__le32 fence_mode;
176 	u8 data[];
177 } __packed;
178 
179 enum iwl_fw_error_dump_family {
180 	IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
181 	IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
182 };
183 
184 #define MAX_NUM_LMAC 2
185 
186 /**
187  * struct iwl_fw_error_dump_info - info on the device / firmware
188  * @hw_type: the type of the device
189  * @hw_step: the step of the device
190  * @fw_human_readable: human readable FW version
191  * @dev_human_readable: name of the device
192  * @bus_human_readable: name of the bus used
193  * @num_of_lmacs: the number of lmacs
194  * @lmac_err_id: the lmac 0/1 error_id/rt_status that triggered the latest dump
195  *	if the dump collection was not initiated by an assert, the value is 0
196  * @umac_err_id: the umac error_id/rt_status that triggered the latest dump
197  *	if the dump collection was not initiated by an assert, the value is 0
198  */
199 struct iwl_fw_error_dump_info {
200 	__le32 hw_type;
201 	__le32 hw_step;
202 	u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
203 	u8 dev_human_readable[64];
204 	u8 bus_human_readable[8];
205 	u8 num_of_lmacs;
206 	__le32 umac_err_id;
207 	__le32 lmac_err_id[MAX_NUM_LMAC];
208 } __packed;
209 
210 /**
211  * struct iwl_fw_error_dump_fw_mon - FW monitor data
212  * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
213  * @fw_mon_base_ptr: base pointer of the data
214  * @fw_mon_cycle_cnt: number of wraparounds
215  * @fw_mon_base_high_ptr: used in AX210 devices, the base adderss is 64 bit
216  *	so fw_mon_base_ptr holds LSB 32 bits and fw_mon_base_high_ptr hold
217  *	MSB 32 bits
218  * @reserved: for future use
219  * @data: captured data
220  */
221 struct iwl_fw_error_dump_fw_mon {
222 	__le32 fw_mon_wr_ptr;
223 	__le32 fw_mon_base_ptr;
224 	__le32 fw_mon_cycle_cnt;
225 	__le32 fw_mon_base_high_ptr;
226 	__le32 reserved[2];
227 	u8 data[];
228 } __packed;
229 
230 #define MAX_NUM_LMAC 2
231 #define TX_FIFO_INTERNAL_MAX_NUM	6
232 #define TX_FIFO_MAX_NUM			15
233 /**
234  * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration
235  *	This must follow &struct iwl_fwrt_shared_mem_cfg.
236  * @num_lmacs: number of lmacs
237  * @num_txfifo_entries: number of tx fifos
238  * @lmac: sizes of lmacs txfifos and rxfifo1
239  * @rxfifo2_size: size of rxfifo2
240  * @internal_txfifo_addr: address of internal tx fifo
241  * @internal_txfifo_size: size of internal tx fifo
242  */
243 struct iwl_fw_error_dump_smem_cfg {
244 	__le32 num_lmacs;
245 	__le32 num_txfifo_entries;
246 	struct {
247 		__le32 txfifo_size[TX_FIFO_MAX_NUM];
248 		__le32 rxfifo1_size;
249 	} lmac[MAX_NUM_LMAC];
250 	__le32 rxfifo2_size;
251 	__le32 internal_txfifo_addr;
252 	__le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
253 } __packed;
254 /**
255  * struct iwl_fw_error_dump_prph - periphery registers data
256  * @prph_start: address of the first register in this chunk
257  * @data: the content of the registers
258  */
259 struct iwl_fw_error_dump_prph {
260 	__le32 prph_start;
261 	__le32 data[];
262 };
263 
264 enum iwl_fw_error_dump_mem_type {
265 	IWL_FW_ERROR_DUMP_MEM_SRAM,
266 	IWL_FW_ERROR_DUMP_MEM_SMEM,
267 	IWL_FW_ERROR_DUMP_MEM_NAMED_MEM = 10,
268 };
269 
270 /**
271  * struct iwl_fw_error_dump_mem - chunk of memory
272  * @type: &enum iwl_fw_error_dump_mem_type
273  * @offset: the offset from which the memory was read
274  * @data: the content of the memory
275  */
276 struct iwl_fw_error_dump_mem {
277 	__le32 type;
278 	__le32 offset;
279 	u8 data[];
280 };
281 
282 /* Dump version, used by the dump parser to differentiate between
283  * different dump formats
284  */
285 #define IWL_INI_DUMP_VER 1
286 
287 /* Use bit 31 as dump info type to avoid colliding with region types */
288 #define IWL_INI_DUMP_INFO_TYPE BIT(31)
289 
290 /**
291  * struct iwl_fw_ini_fifo_hdr - fifo range header
292  * @fifo_num: the fifo number. In case of umac rx fifo, set BIT(31) to
293  *	distinguish between lmac and umac rx fifos
294  * @num_of_registers: num of registers to dump, dword size each
295  */
296 struct iwl_fw_ini_fifo_hdr {
297 	__le32 fifo_num;
298 	__le32 num_of_registers;
299 } __packed;
300 
301 /**
302  * struct iwl_fw_ini_error_dump_range - range of memory
303  * @range_data_size: the size of this range, in bytes
304  * @internal_base_addr - base address of internal memory range
305  * @dram_base_addr - base address of dram monitor range
306  * @page_num - page number of memory range
307  * @fifo_hdr - fifo header of memory range
308  * @data: the actual memory
309  */
310 struct iwl_fw_ini_error_dump_range {
311 	__le32 range_data_size;
312 	union {
313 		__le32 internal_base_addr;
314 		__le64 dram_base_addr;
315 		__le32 page_num;
316 		struct iwl_fw_ini_fifo_hdr fifo_hdr;
317 	};
318 	__le32 data[];
319 } __packed;
320 
321 /**
322  * struct iwl_fw_ini_error_dump_header - ini region dump header
323  * @version: dump version
324  * @region_id: id of the region
325  * @num_of_ranges: number of ranges in this region
326  * @name_len: number of bytes allocated to the name string of this region
327  * @name: name of the region
328  */
329 struct iwl_fw_ini_error_dump_header {
330 	__le32 version;
331 	__le32 region_id;
332 	__le32 num_of_ranges;
333 	__le32 name_len;
334 	u8 name[IWL_FW_INI_MAX_NAME];
335 };
336 
337 /**
338  * struct iwl_fw_ini_error_dump - ini region dump
339  * @header: the header of this region
340  * @ranges: the memory ranges of this region
341  */
342 struct iwl_fw_ini_error_dump {
343 	struct iwl_fw_ini_error_dump_header header;
344 	struct iwl_fw_ini_error_dump_range ranges[];
345 } __packed;
346 
347 /* This bit is used to differentiate between lmac and umac rxf */
348 #define IWL_RXF_UMAC_BIT BIT(31)
349 
350 /**
351  * struct iwl_fw_ini_error_dump_register - ini register dump
352  * @addr: address of the register
353  * @data: data of the register
354  */
355 struct iwl_fw_ini_error_dump_register {
356 	__le32 addr;
357 	__le32 data;
358 } __packed;
359 
360 /* struct iwl_fw_ini_dump_info - ini dump information
361  * @version: dump version
362  * @trigger_id: trigger id that caused the dump collection
363  * @trigger_reason: not supported yet
364  * @is_external_cfg: 1 if an external debug configuration was loaded
365  *	and 0 otherwise
366  * @ver_type: FW version type
367  * @ver_subtype: FW version subype
368  * @hw_step: HW step
369  * @hw_type: HW type
370  * @rf_id_flavor: HW RF id flavor
371  * @rf_id_dash: HW RF id dash
372  * @rf_id_step: HW RF id step
373  * @rf_id_type: HW RF id type
374  * @lmac_major: lmac major version
375  * @lmac_minor: lmac minor version
376  * @umac_major: umac major version
377  * @umac_minor: umac minor version
378  * @build_tag_len: length of the build tag
379  * @build_tag: build tag string
380  * @img_name_len: length of the FW image name
381  * @img_name: FW image name
382  * @internal_dbg_cfg_name_len: length of the internal debug configuration name
383  * @internal_dbg_cfg_name: internal debug configuration name
384  * @external_dbg_cfg_name_len: length of the external debug configuration name
385  * @external_dbg_cfg_name: external debug configuration name
386  * @regions_num: number of region ids
387  * @region_ids: region ids the trigger configured to collect
388  */
389 struct iwl_fw_ini_dump_info {
390 	__le32 version;
391 	__le32 trigger_id;
392 	__le32 trigger_reason;
393 	__le32 is_external_cfg;
394 	__le32 ver_type;
395 	__le32 ver_subtype;
396 	__le32 hw_step;
397 	__le32 hw_type;
398 	__le32 rf_id_flavor;
399 	__le32 rf_id_dash;
400 	__le32 rf_id_step;
401 	__le32 rf_id_type;
402 	__le32 lmac_major;
403 	__le32 lmac_minor;
404 	__le32 umac_major;
405 	__le32 umac_minor;
406 	__le32 build_tag_len;
407 	u8 build_tag[FW_VER_HUMAN_READABLE_SZ];
408 	__le32 img_name_len;
409 	u8 img_name[IWL_FW_INI_MAX_IMG_NAME_LEN];
410 	__le32 internal_dbg_cfg_name_len;
411 	u8 internal_dbg_cfg_name[IWL_FW_INI_MAX_DBG_CFG_NAME_LEN];
412 	__le32 external_dbg_cfg_name_len;
413 	u8 external_dbg_cfg_name[IWL_FW_INI_MAX_DBG_CFG_NAME_LEN];
414 	__le32 regions_num;
415 	__le32 region_ids[];
416 
417 } __packed;
418 
419 /**
420  * struct iwl_fw_error_dump_rb - content of an Receive Buffer
421  * @index: the index of the Receive Buffer in the Rx queue
422  * @rxq: the RB's Rx queue
423  * @reserved:
424  * @data: the content of the Receive Buffer
425  */
426 struct iwl_fw_error_dump_rb {
427 	__le32 index;
428 	__le32 rxq;
429 	__le32 reserved;
430 	u8 data[];
431 };
432 
433 /**
434  * struct iwl_fw_ini_monitor_dump - ini monitor dump
435  * @header - header of the region
436  * @write_ptr - write pointer position in the buffer
437  * @cycle_cnt - cycles count
438  * @ranges - the memory ranges of this this region
439  */
440 struct iwl_fw_ini_monitor_dump {
441 	struct iwl_fw_ini_error_dump_header header;
442 	__le32 write_ptr;
443 	__le32 cycle_cnt;
444 	struct iwl_fw_ini_error_dump_range ranges[];
445 } __packed;
446 
447 /**
448  * struct iwl_fw_error_dump_paging - content of the UMAC's image page
449  *	block on DRAM
450  * @index: the index of the page block
451  * @reserved:
452  * @data: the content of the page block
453  */
454 struct iwl_fw_error_dump_paging {
455 	__le32 index;
456 	__le32 reserved;
457 	u8 data[];
458 };
459 
460 /**
461  * iwl_fw_error_next_data - advance fw error dump data pointer
462  * @data: previous data block
463  * Returns: next data block
464  */
465 static inline struct iwl_fw_error_dump_data *
466 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
467 {
468 	return (void *)(data->data + le32_to_cpu(data->len));
469 }
470 
471 /**
472  * enum iwl_fw_dbg_trigger - triggers available
473  *
474  * @FW_DBG_TRIGGER_USER: trigger log collection by user
475  *	This should not be defined as a trigger to the driver, but a value the
476  *	driver should set to indicate that the trigger was initiated by the
477  *	user.
478  * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
479  * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
480  *	missed.
481  * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
482  * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
483  *	command response or a notification.
484  * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
485  * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
486  * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
487  *	goes below a threshold.
488  * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
489  *	detection.
490  * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
491  *	events.
492  * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
493  * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a
494  *	threshold.
495  * @FW_DBG_TDLS: trigger log collection upon TDLS related events.
496  * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when
497  *  the firmware sends a tx reply.
498  * @FW_DBG_TRIGGER_ALIVE_TIMEOUT: trigger log collection if alive flow timeouts
499  * @FW_DBG_TRIGGER_DRIVER: trigger log collection upon a flow failure
500  *	in the driver.
501  */
502 enum iwl_fw_dbg_trigger {
503 	FW_DBG_TRIGGER_INVALID = 0,
504 	FW_DBG_TRIGGER_USER,
505 	FW_DBG_TRIGGER_FW_ASSERT,
506 	FW_DBG_TRIGGER_MISSED_BEACONS,
507 	FW_DBG_TRIGGER_CHANNEL_SWITCH,
508 	FW_DBG_TRIGGER_FW_NOTIF,
509 	FW_DBG_TRIGGER_MLME,
510 	FW_DBG_TRIGGER_STATS,
511 	FW_DBG_TRIGGER_RSSI,
512 	FW_DBG_TRIGGER_TXQ_TIMERS,
513 	FW_DBG_TRIGGER_TIME_EVENT,
514 	FW_DBG_TRIGGER_BA,
515 	FW_DBG_TRIGGER_TX_LATENCY,
516 	FW_DBG_TRIGGER_TDLS,
517 	FW_DBG_TRIGGER_TX_STATUS,
518 	FW_DBG_TRIGGER_ALIVE_TIMEOUT,
519 	FW_DBG_TRIGGER_DRIVER,
520 
521 	/* must be last */
522 	FW_DBG_TRIGGER_MAX,
523 };
524 
525 /**
526  * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
527  * @type: &enum iwl_fw_dbg_trigger
528  * @data: raw data about what happened
529  */
530 struct iwl_fw_error_dump_trigger_desc {
531 	__le32 type;
532 	u8 data[];
533 };
534 
535 #endif /* __fw_error_dump_h__ */
536