xref: /openbmc/linux/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h (revision f291209eca5eba0b4704fa0832af57b12dbc1a02)
18e99ea8dSJohannes Berg /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
28e99ea8dSJohannes Berg /*
351fa8c02SMukesh Sisodiya  * Copyright (C) 2014, 2018-2022 Intel Corporation
48e99ea8dSJohannes Berg  * Copyright (C) 2014-2015 Intel Mobile Communications GmbH
58e99ea8dSJohannes Berg  * Copyright (C) 2016-2017 Intel Deutschland GmbH
68e99ea8dSJohannes Berg  */
7d962f9b1SJohannes Berg #ifndef __fw_error_dump_h__
8d962f9b1SJohannes Berg #define __fw_error_dump_h__
9d962f9b1SJohannes Berg 
10d962f9b1SJohannes Berg #include <linux/types.h>
113ed34fbfSShahar S Matityahu #include "fw/api/cmdhdr.h"
12d962f9b1SJohannes Berg 
13d962f9b1SJohannes Berg #define IWL_FW_ERROR_DUMP_BARKER	0x14789632
14dc14b800SShahar S Matityahu #define IWL_FW_INI_ERROR_DUMP_BARKER	0x14789633
15d962f9b1SJohannes Berg 
16d962f9b1SJohannes Berg /**
17d962f9b1SJohannes Berg  * enum iwl_fw_error_dump_type - types of data in the dump file
18d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
19d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_RXF:
20d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
21d962f9b1SJohannes Berg  *	&struct iwl_fw_error_dump_txcmd packets
22d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_DEV_FW_INFO:  struct %iwl_fw_error_dump_info
23d962f9b1SJohannes Berg  *	info on the device / firmware.
24d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
25d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
26d962f9b1SJohannes Berg  *	sections like this in a single file.
27d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
28d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
29d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump.
30d962f9b1SJohannes Berg  *	Structured as &struct iwl_fw_error_dump_trigger_desc.
31d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as
32d962f9b1SJohannes Berg  *	&struct iwl_fw_error_dump_rb
33d962f9b1SJohannes Berg  * @IWL_FW_ERROR_PAGING: UMAC's image memory segments which were
34d962f9b1SJohannes Berg  *	paged to the DRAM.
35d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_RADIO_REG: Dump the radio registers.
36d962f9b1SJohannes Berg  * @IWL_FW_ERROR_DUMP_EXTERNAL: used only by external code utilities, and
37d962f9b1SJohannes Berg  *	for that reason is not in use in any other place in the Linux Wi-Fi
38d962f9b1SJohannes Berg  *	stack.
39ce27f005SGolan Ben-Ami  * @IWL_FW_ERROR_DUMP_MEM_CFG: the addresses and sizes of fifos in the smem,
40ce27f005SGolan Ben-Ami  *	which we get from the fw after ALIVE. The content is structured as
41ce27f005SGolan Ben-Ami  *	&struct iwl_fw_error_dump_smem_cfg.
42d962f9b1SJohannes Berg  */
43d962f9b1SJohannes Berg enum iwl_fw_error_dump_type {
44d962f9b1SJohannes Berg 	/* 0 is deprecated */
45d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_CSR = 1,
46d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_RXF = 2,
47d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_TXCMD = 3,
48d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
49d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
50d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_PRPH = 6,
51d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_TXF = 7,
52d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_FH_REGS = 8,
53d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_MEM = 9,
54d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_ERROR_INFO = 10,
55d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_RB = 11,
56d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_PAGING = 12,
57d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_RADIO_REG = 13,
58d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_INTERNAL_TXF = 14,
59d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_EXTERNAL = 15, /* Do not move */
60ce27f005SGolan Ben-Ami 	IWL_FW_ERROR_DUMP_MEM_CFG = 16,
612d8c2615SShahar S Matityahu 	IWL_FW_ERROR_DUMP_D3_DEBUG_DATA = 17,
62d962f9b1SJohannes Berg 
63d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_MAX,
64d962f9b1SJohannes Berg };
65d962f9b1SJohannes Berg 
66d962f9b1SJohannes Berg /**
67d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_data - data for one type
68d962f9b1SJohannes Berg  * @type: &enum iwl_fw_error_dump_type
69d962f9b1SJohannes Berg  * @len: the length starting from %data
70d962f9b1SJohannes Berg  * @data: the data itself
71d962f9b1SJohannes Berg  */
72d962f9b1SJohannes Berg struct iwl_fw_error_dump_data {
73d962f9b1SJohannes Berg 	__le32 type;
74d962f9b1SJohannes Berg 	__le32 len;
75d962f9b1SJohannes Berg 	__u8 data[];
76d962f9b1SJohannes Berg } __packed;
77d962f9b1SJohannes Berg 
78d962f9b1SJohannes Berg /**
7951fa8c02SMukesh Sisodiya  * struct iwl_dump_file_name_info - data for dump file name addition
8051fa8c02SMukesh Sisodiya  * @type: region type with reserved bits
8151fa8c02SMukesh Sisodiya  * @len: the length of file name string to be added to dump file
8251fa8c02SMukesh Sisodiya  * @data: the string need to be added to dump file
8351fa8c02SMukesh Sisodiya  */
8451fa8c02SMukesh Sisodiya struct iwl_dump_file_name_info {
8551fa8c02SMukesh Sisodiya 	__le32 type;
8651fa8c02SMukesh Sisodiya 	__le32 len;
8751fa8c02SMukesh Sisodiya 	__u8 data[];
8851fa8c02SMukesh Sisodiya } __packed;
8951fa8c02SMukesh Sisodiya 
9051fa8c02SMukesh Sisodiya /**
91d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_file - the layout of the header of the file
92d962f9b1SJohannes Berg  * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
93d962f9b1SJohannes Berg  * @file_len: the length of all the file starting from %barker
94d962f9b1SJohannes Berg  * @data: array of &struct iwl_fw_error_dump_data
95d962f9b1SJohannes Berg  */
96d962f9b1SJohannes Berg struct iwl_fw_error_dump_file {
97d962f9b1SJohannes Berg 	__le32 barker;
98d962f9b1SJohannes Berg 	__le32 file_len;
9934e63cd5SGustavo A. R. Silva 	u8 data[];
100d962f9b1SJohannes Berg } __packed;
101d962f9b1SJohannes Berg 
102d962f9b1SJohannes Berg /**
103d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_txcmd - TX command data
104d962f9b1SJohannes Berg  * @cmdlen: original length of command
105d962f9b1SJohannes Berg  * @caplen: captured length of command (may be less)
106d962f9b1SJohannes Berg  * @data: captured command data, @caplen bytes
107d962f9b1SJohannes Berg  */
108d962f9b1SJohannes Berg struct iwl_fw_error_dump_txcmd {
109d962f9b1SJohannes Berg 	__le32 cmdlen;
110d962f9b1SJohannes Berg 	__le32 caplen;
111d962f9b1SJohannes Berg 	u8 data[];
112d962f9b1SJohannes Berg } __packed;
113d962f9b1SJohannes Berg 
114d962f9b1SJohannes Berg /**
115d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
116d962f9b1SJohannes Berg  * @fifo_num: number of FIFO (starting from 0)
117d962f9b1SJohannes Berg  * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
118d962f9b1SJohannes Berg  * @wr_ptr: position of write pointer
119d962f9b1SJohannes Berg  * @rd_ptr: position of read pointer
120d962f9b1SJohannes Berg  * @fence_ptr: position of fence pointer
121d962f9b1SJohannes Berg  * @fence_mode: the current mode of the fence (before locking) -
122d962f9b1SJohannes Berg  *	0=follow RD pointer ; 1 = freeze
123d962f9b1SJohannes Berg  * @data: all of the FIFO's data
124d962f9b1SJohannes Berg  */
125d962f9b1SJohannes Berg struct iwl_fw_error_dump_fifo {
126d962f9b1SJohannes Berg 	__le32 fifo_num;
127d962f9b1SJohannes Berg 	__le32 available_bytes;
128d962f9b1SJohannes Berg 	__le32 wr_ptr;
129d962f9b1SJohannes Berg 	__le32 rd_ptr;
130d962f9b1SJohannes Berg 	__le32 fence_ptr;
131d962f9b1SJohannes Berg 	__le32 fence_mode;
132d962f9b1SJohannes Berg 	u8 data[];
133d962f9b1SJohannes Berg } __packed;
134d962f9b1SJohannes Berg 
135d962f9b1SJohannes Berg enum iwl_fw_error_dump_family {
136d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
137d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
138d962f9b1SJohannes Berg };
139d962f9b1SJohannes Berg 
140d3561e0eSShahar S Matityahu #define MAX_NUM_LMAC 2
141d3561e0eSShahar S Matityahu 
142d962f9b1SJohannes Berg /**
143d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_info - info on the device / firmware
144391481adSShahar S Matityahu  * @hw_type: the type of the device
145d962f9b1SJohannes Berg  * @hw_step: the step of the device
146d962f9b1SJohannes Berg  * @fw_human_readable: human readable FW version
147d962f9b1SJohannes Berg  * @dev_human_readable: name of the device
148d962f9b1SJohannes Berg  * @bus_human_readable: name of the bus used
149d3561e0eSShahar S Matityahu  * @num_of_lmacs: the number of lmacs
150d3561e0eSShahar S Matityahu  * @lmac_err_id: the lmac 0/1 error_id/rt_status that triggered the latest dump
151d3561e0eSShahar S Matityahu  *	if the dump collection was not initiated by an assert, the value is 0
152d3561e0eSShahar S Matityahu  * @umac_err_id: the umac error_id/rt_status that triggered the latest dump
153a06875a7SShahar S Matityahu  *	if the dump collection was not initiated by an assert, the value is 0
154d962f9b1SJohannes Berg  */
155d962f9b1SJohannes Berg struct iwl_fw_error_dump_info {
156391481adSShahar S Matityahu 	__le32 hw_type;
157d962f9b1SJohannes Berg 	__le32 hw_step;
158d962f9b1SJohannes Berg 	u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
159d962f9b1SJohannes Berg 	u8 dev_human_readable[64];
160d962f9b1SJohannes Berg 	u8 bus_human_readable[8];
161d3561e0eSShahar S Matityahu 	u8 num_of_lmacs;
162d3561e0eSShahar S Matityahu 	__le32 umac_err_id;
163d3561e0eSShahar S Matityahu 	__le32 lmac_err_id[MAX_NUM_LMAC];
164d962f9b1SJohannes Berg } __packed;
165d962f9b1SJohannes Berg 
166d962f9b1SJohannes Berg /**
167d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_fw_mon - FW monitor data
168d962f9b1SJohannes Berg  * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
169d962f9b1SJohannes Berg  * @fw_mon_base_ptr: base pointer of the data
170d962f9b1SJohannes Berg  * @fw_mon_cycle_cnt: number of wraparounds
171c88580e1SShahar S Matityahu  * @fw_mon_base_high_ptr: used in AX210 devices, the base adderss is 64 bit
172c88580e1SShahar S Matityahu  *	so fw_mon_base_ptr holds LSB 32 bits and fw_mon_base_high_ptr hold
173c88580e1SShahar S Matityahu  *	MSB 32 bits
174d962f9b1SJohannes Berg  * @reserved: for future use
175d962f9b1SJohannes Berg  * @data: captured data
176d962f9b1SJohannes Berg  */
177d962f9b1SJohannes Berg struct iwl_fw_error_dump_fw_mon {
178d962f9b1SJohannes Berg 	__le32 fw_mon_wr_ptr;
179d962f9b1SJohannes Berg 	__le32 fw_mon_base_ptr;
180d962f9b1SJohannes Berg 	__le32 fw_mon_cycle_cnt;
181c88580e1SShahar S Matityahu 	__le32 fw_mon_base_high_ptr;
182c88580e1SShahar S Matityahu 	__le32 reserved[2];
183d962f9b1SJohannes Berg 	u8 data[];
184d962f9b1SJohannes Berg } __packed;
185d962f9b1SJohannes Berg 
186ce27f005SGolan Ben-Ami #define MAX_NUM_LMAC 2
187ce27f005SGolan Ben-Ami #define TX_FIFO_INTERNAL_MAX_NUM	6
188ce27f005SGolan Ben-Ami #define TX_FIFO_MAX_NUM			15
189ce27f005SGolan Ben-Ami /**
190ce27f005SGolan Ben-Ami  * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration
191ce27f005SGolan Ben-Ami  *	This must follow &struct iwl_fwrt_shared_mem_cfg.
192ce27f005SGolan Ben-Ami  * @num_lmacs: number of lmacs
193ce27f005SGolan Ben-Ami  * @num_txfifo_entries: number of tx fifos
194ce27f005SGolan Ben-Ami  * @lmac: sizes of lmacs txfifos and rxfifo1
195ce27f005SGolan Ben-Ami  * @rxfifo2_size: size of rxfifo2
196ce27f005SGolan Ben-Ami  * @internal_txfifo_addr: address of internal tx fifo
197ce27f005SGolan Ben-Ami  * @internal_txfifo_size: size of internal tx fifo
198ce27f005SGolan Ben-Ami  */
199ce27f005SGolan Ben-Ami struct iwl_fw_error_dump_smem_cfg {
200ce27f005SGolan Ben-Ami 	__le32 num_lmacs;
201ce27f005SGolan Ben-Ami 	__le32 num_txfifo_entries;
202ce27f005SGolan Ben-Ami 	struct {
203ce27f005SGolan Ben-Ami 		__le32 txfifo_size[TX_FIFO_MAX_NUM];
204ce27f005SGolan Ben-Ami 		__le32 rxfifo1_size;
205ce27f005SGolan Ben-Ami 	} lmac[MAX_NUM_LMAC];
206ce27f005SGolan Ben-Ami 	__le32 rxfifo2_size;
207ce27f005SGolan Ben-Ami 	__le32 internal_txfifo_addr;
208ce27f005SGolan Ben-Ami 	__le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
209ce27f005SGolan Ben-Ami } __packed;
210d962f9b1SJohannes Berg /**
211d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_prph - periphery registers data
212d962f9b1SJohannes Berg  * @prph_start: address of the first register in this chunk
213d962f9b1SJohannes Berg  * @data: the content of the registers
214d962f9b1SJohannes Berg  */
215d962f9b1SJohannes Berg struct iwl_fw_error_dump_prph {
216d962f9b1SJohannes Berg 	__le32 prph_start;
217d962f9b1SJohannes Berg 	__le32 data[];
218d962f9b1SJohannes Berg };
219d962f9b1SJohannes Berg 
220d962f9b1SJohannes Berg enum iwl_fw_error_dump_mem_type {
221d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_MEM_SRAM,
222d962f9b1SJohannes Berg 	IWL_FW_ERROR_DUMP_MEM_SMEM,
2237a14c23dSSara Sharon 	IWL_FW_ERROR_DUMP_MEM_NAMED_MEM = 10,
224d962f9b1SJohannes Berg };
225d962f9b1SJohannes Berg 
226d962f9b1SJohannes Berg /**
227d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_mem - chunk of memory
228d962f9b1SJohannes Berg  * @type: &enum iwl_fw_error_dump_mem_type
229d962f9b1SJohannes Berg  * @offset: the offset from which the memory was read
230d962f9b1SJohannes Berg  * @data: the content of the memory
231d962f9b1SJohannes Berg  */
232d962f9b1SJohannes Berg struct iwl_fw_error_dump_mem {
233d962f9b1SJohannes Berg 	__le32 type;
234d962f9b1SJohannes Berg 	__le32 offset;
235d962f9b1SJohannes Berg 	u8 data[];
236d962f9b1SJohannes Berg };
237d962f9b1SJohannes Berg 
23897319355SShahar S Matityahu /* Dump version, used by the dump parser to differentiate between
23997319355SShahar S Matityahu  * different dump formats
24097319355SShahar S Matityahu  */
24197319355SShahar S Matityahu #define IWL_INI_DUMP_VER 1
24297319355SShahar S Matityahu 
2430a3a3e9eSShahar S Matityahu /* Use bit 31 as dump info type to avoid colliding with region types */
2440a3a3e9eSShahar S Matityahu #define IWL_INI_DUMP_INFO_TYPE BIT(31)
2450a3a3e9eSShahar S Matityahu 
24651fa8c02SMukesh Sisodiya /* Use bit 31 and bit 24 as dump name type to avoid colliding with region types */
24751fa8c02SMukesh Sisodiya #define IWL_INI_DUMP_NAME_TYPE (BIT(31) | BIT(24))
24851fa8c02SMukesh Sisodiya 
24997319355SShahar S Matityahu /**
25062ed5d90SMordechay Goodstein  * struct iwl_fw_error_dump_data - data for one type
25162ed5d90SMordechay Goodstein  * @type: &enum iwl_fw_ini_region_type
25262ed5d90SMordechay Goodstein  * @sub_type: sub type id
25362ed5d90SMordechay Goodstein  * @sub_type_ver: sub type version
25462ed5d90SMordechay Goodstein  * @reserved: not in use
25562ed5d90SMordechay Goodstein  * @len: the length starting from %data
25662ed5d90SMordechay Goodstein  * @data: the data itself
25762ed5d90SMordechay Goodstein  */
25862ed5d90SMordechay Goodstein struct iwl_fw_ini_error_dump_data {
25962ed5d90SMordechay Goodstein 	u8 type;
26062ed5d90SMordechay Goodstein 	u8 sub_type;
26162ed5d90SMordechay Goodstein 	u8 sub_type_ver;
26262ed5d90SMordechay Goodstein 	u8 reserved;
26362ed5d90SMordechay Goodstein 	__le32 len;
26462ed5d90SMordechay Goodstein 	__u8 data[];
26562ed5d90SMordechay Goodstein } __packed;
26662ed5d90SMordechay Goodstein 
26762ed5d90SMordechay Goodstein /**
2680fc296f8SShahar S Matityahu  * struct iwl_fw_ini_dump_entry
2690fc296f8SShahar S Matityahu  * @list: list of dump entries
2700fc296f8SShahar S Matityahu  * @size: size of the data
2710fc296f8SShahar S Matityahu  * @data: entry data
2720fc296f8SShahar S Matityahu  */
2730fc296f8SShahar S Matityahu struct iwl_fw_ini_dump_entry {
2740fc296f8SShahar S Matityahu 	struct list_head list;
2750fc296f8SShahar S Matityahu 	u32 size;
2760fc296f8SShahar S Matityahu 	u8 data[];
2770fc296f8SShahar S Matityahu } __packed;
2780fc296f8SShahar S Matityahu 
2790fc296f8SShahar S Matityahu /**
2800fc296f8SShahar S Matityahu  * struct iwl_fw_error_dump_file - header of dump file
2810fc296f8SShahar S Matityahu  * @barker: must be %IWL_FW_INI_ERROR_DUMP_BARKER
2820fc296f8SShahar S Matityahu  * @file_len: the length of all the file including the header
2830fc296f8SShahar S Matityahu  */
2840fc296f8SShahar S Matityahu struct iwl_fw_ini_dump_file_hdr {
2850fc296f8SShahar S Matityahu 	__le32 barker;
2860fc296f8SShahar S Matityahu 	__le32 file_len;
2870fc296f8SShahar S Matityahu } __packed;
2880fc296f8SShahar S Matityahu 
2890fc296f8SShahar S Matityahu /**
29097319355SShahar S Matityahu  * struct iwl_fw_ini_fifo_hdr - fifo range header
29197319355SShahar S Matityahu  * @fifo_num: the fifo number. In case of umac rx fifo, set BIT(31) to
29297319355SShahar S Matityahu  *	distinguish between lmac and umac rx fifos
29397319355SShahar S Matityahu  * @num_of_registers: num of registers to dump, dword size each
29497319355SShahar S Matityahu  */
29597319355SShahar S Matityahu struct iwl_fw_ini_fifo_hdr {
29697319355SShahar S Matityahu 	__le32 fifo_num;
29797319355SShahar S Matityahu 	__le32 num_of_registers;
29897319355SShahar S Matityahu } __packed;
299990ffe3eSShahar S Matityahu 
300d962f9b1SJohannes Berg /**
3018d534e96SShahar S Matityahu  * struct iwl_fw_ini_error_dump_range - range of memory
3028d534e96SShahar S Matityahu  * @range_data_size: the size of this range, in bytes
3034828f462SShahar S Matityahu  * @internal_base_addr: base address of internal memory range
3044828f462SShahar S Matityahu  * @dram_base_addr: base address of dram monitor range
3054828f462SShahar S Matityahu  * @page_num: page number of memory range
3064828f462SShahar S Matityahu  * @fifo_hdr: fifo header of memory range
3073ed34fbfSShahar S Matityahu  * @fw_pkt: FW packet header of memory range
3088d534e96SShahar S Matityahu  * @data: the actual memory
3098d534e96SShahar S Matityahu  */
3108d534e96SShahar S Matityahu struct iwl_fw_ini_error_dump_range {
3118d534e96SShahar S Matityahu 	__le32 range_data_size;
31297319355SShahar S Matityahu 	union {
313*424c82e8SArnd Bergmann 		__le32 internal_base_addr __packed;
314*424c82e8SArnd Bergmann 		__le64 dram_base_addr __packed;
315*424c82e8SArnd Bergmann 		__le32 page_num __packed;
31697319355SShahar S Matityahu 		struct iwl_fw_ini_fifo_hdr fifo_hdr;
3173ed34fbfSShahar S Matityahu 		struct iwl_cmd_header fw_pkt_hdr;
31897319355SShahar S Matityahu 	};
3198d534e96SShahar S Matityahu 	__le32 data[];
3208d534e96SShahar S Matityahu } __packed;
3218d534e96SShahar S Matityahu 
3228d534e96SShahar S Matityahu /**
3238d534e96SShahar S Matityahu  * struct iwl_fw_ini_error_dump_header - ini region dump header
324990ffe3eSShahar S Matityahu  * @version: dump version
3251cdb4d8fSShahar S Matityahu  * @region_id: id of the region
3268d534e96SShahar S Matityahu  * @num_of_ranges: number of ranges in this region
3278d534e96SShahar S Matityahu  * @name_len: number of bytes allocated to the name string of this region
3288d534e96SShahar S Matityahu  * @name: name of the region
3298d534e96SShahar S Matityahu  */
3308d534e96SShahar S Matityahu struct iwl_fw_ini_error_dump_header {
331990ffe3eSShahar S Matityahu 	__le32 version;
3321cdb4d8fSShahar S Matityahu 	__le32 region_id;
3338d534e96SShahar S Matityahu 	__le32 num_of_ranges;
3348d534e96SShahar S Matityahu 	__le32 name_len;
3358d534e96SShahar S Matityahu 	u8 name[IWL_FW_INI_MAX_NAME];
3368d534e96SShahar S Matityahu };
3378d534e96SShahar S Matityahu 
3388d534e96SShahar S Matityahu /**
3398d534e96SShahar S Matityahu  * struct iwl_fw_ini_error_dump - ini region dump
3408d534e96SShahar S Matityahu  * @header: the header of this region
3418a433cb6SJohannes Berg  * @data: data of memory ranges in this region,
3428a433cb6SJohannes Berg  *	see &struct iwl_fw_ini_error_dump_range
3438d534e96SShahar S Matityahu  */
3448d534e96SShahar S Matityahu struct iwl_fw_ini_error_dump {
3458d534e96SShahar S Matityahu 	struct iwl_fw_ini_error_dump_header header;
3468a433cb6SJohannes Berg 	u8 data[];
3478d534e96SShahar S Matityahu } __packed;
3488d534e96SShahar S Matityahu 
3498d7dea25SShahar S Matityahu /* This bit is used to differentiate between lmac and umac rxf */
3508d7dea25SShahar S Matityahu #define IWL_RXF_UMAC_BIT BIT(31)
3518d7dea25SShahar S Matityahu 
3528d534e96SShahar S Matityahu /**
35360eeaf57SShahar S Matityahu  * struct iwl_fw_ini_error_dump_register - ini register dump
35460eeaf57SShahar S Matityahu  * @addr: address of the register
35560eeaf57SShahar S Matityahu  * @data: data of the register
35660eeaf57SShahar S Matityahu  */
35760eeaf57SShahar S Matityahu struct iwl_fw_ini_error_dump_register {
35860eeaf57SShahar S Matityahu 	__le32 addr;
35960eeaf57SShahar S Matityahu 	__le32 data;
36060eeaf57SShahar S Matityahu } __packed;
36160eeaf57SShahar S Matityahu 
362677d25b2SShahar S Matityahu /**
363677d25b2SShahar S Matityahu  * struct iwl_fw_ini_dump_cfg_name - configuration name
364677d25b2SShahar S Matityahu  * @image_type: image type the configuration is related to
365677d25b2SShahar S Matityahu  * @cfg_name_len: length of the configuration name
366677d25b2SShahar S Matityahu  * @cfg_name: name of the configuraiton
367677d25b2SShahar S Matityahu  */
368677d25b2SShahar S Matityahu struct iwl_fw_ini_dump_cfg_name {
369677d25b2SShahar S Matityahu 	__le32 image_type;
370677d25b2SShahar S Matityahu 	__le32 cfg_name_len;
371677d25b2SShahar S Matityahu 	u8 cfg_name[IWL_FW_INI_MAX_CFG_NAME];
372677d25b2SShahar S Matityahu } __packed;
373677d25b2SShahar S Matityahu 
374d3d2674cSLiad Kaufman /* AX210's HW type */
375d3d2674cSLiad Kaufman #define IWL_AX210_HW_TYPE 0x42
376d3d2674cSLiad Kaufman /* How many bits to roll when adding to the HW type of AX210 HW */
377d3d2674cSLiad Kaufman #define IWL_AX210_HW_TYPE_ADDITION_SHIFT 12
378d3d2674cSLiad Kaufman 
3790a3a3e9eSShahar S Matityahu /* struct iwl_fw_ini_dump_info - ini dump information
3800a3a3e9eSShahar S Matityahu  * @version: dump version
3813b589d56SShahar S Matityahu  * @time_point: time point that caused the dump collection
3823b589d56SShahar S Matityahu  * @trigger_reason: reason of the trigger
3833b589d56SShahar S Matityahu  * @external_cfg_state: &enum iwl_ini_cfg_state
3840a3a3e9eSShahar S Matityahu  * @ver_type: FW version type
3850a3a3e9eSShahar S Matityahu  * @ver_subtype: FW version subype
3860a3a3e9eSShahar S Matityahu  * @hw_step: HW step
3870a3a3e9eSShahar S Matityahu  * @hw_type: HW type
3880a3a3e9eSShahar S Matityahu  * @rf_id_flavor: HW RF id flavor
3890a3a3e9eSShahar S Matityahu  * @rf_id_dash: HW RF id dash
3900a3a3e9eSShahar S Matityahu  * @rf_id_step: HW RF id step
3910a3a3e9eSShahar S Matityahu  * @rf_id_type: HW RF id type
3920a3a3e9eSShahar S Matityahu  * @lmac_major: lmac major version
3930a3a3e9eSShahar S Matityahu  * @lmac_minor: lmac minor version
3940a3a3e9eSShahar S Matityahu  * @umac_major: umac major version
3950a3a3e9eSShahar S Matityahu  * @umac_minor: umac minor version
396677d25b2SShahar S Matityahu  * @fw_mon_mode: FW monitor mode &enum iwl_fw_ini_buffer_location
397677d25b2SShahar S Matityahu  * @regions_mask: bitmap mask of regions ids in the dump
3980a3a3e9eSShahar S Matityahu  * @build_tag_len: length of the build tag
3990a3a3e9eSShahar S Matityahu  * @build_tag: build tag string
400677d25b2SShahar S Matityahu  * @num_of_cfg_names: number of configuration name structs
401677d25b2SShahar S Matityahu  * @cfg_names: configuration names
4020a3a3e9eSShahar S Matityahu  */
4030a3a3e9eSShahar S Matityahu struct iwl_fw_ini_dump_info {
4040a3a3e9eSShahar S Matityahu 	__le32 version;
4053b589d56SShahar S Matityahu 	__le32 time_point;
4060a3a3e9eSShahar S Matityahu 	__le32 trigger_reason;
4073b589d56SShahar S Matityahu 	__le32 external_cfg_state;
4080a3a3e9eSShahar S Matityahu 	__le32 ver_type;
4090a3a3e9eSShahar S Matityahu 	__le32 ver_subtype;
4100a3a3e9eSShahar S Matityahu 	__le32 hw_step;
4110a3a3e9eSShahar S Matityahu 	__le32 hw_type;
4120a3a3e9eSShahar S Matityahu 	__le32 rf_id_flavor;
4130a3a3e9eSShahar S Matityahu 	__le32 rf_id_dash;
4140a3a3e9eSShahar S Matityahu 	__le32 rf_id_step;
4150a3a3e9eSShahar S Matityahu 	__le32 rf_id_type;
4160a3a3e9eSShahar S Matityahu 	__le32 lmac_major;
4170a3a3e9eSShahar S Matityahu 	__le32 lmac_minor;
4180a3a3e9eSShahar S Matityahu 	__le32 umac_major;
4190a3a3e9eSShahar S Matityahu 	__le32 umac_minor;
420677d25b2SShahar S Matityahu 	__le32 fw_mon_mode;
421677d25b2SShahar S Matityahu 	__le64 regions_mask;
4220a3a3e9eSShahar S Matityahu 	__le32 build_tag_len;
4230a3a3e9eSShahar S Matityahu 	u8 build_tag[FW_VER_HUMAN_READABLE_SZ];
424677d25b2SShahar S Matityahu 	__le32 num_of_cfg_names;
425677d25b2SShahar S Matityahu 	struct iwl_fw_ini_dump_cfg_name cfg_names[];
426a77e3d28SShahar S Matityahu } __packed;
4270a3a3e9eSShahar S Matityahu 
428a77e3d28SShahar S Matityahu /**
429a77e3d28SShahar S Matityahu  * struct iwl_fw_ini_err_table_dump - ini error table dump
430a77e3d28SShahar S Matityahu  * @header: header of the region
431a77e3d28SShahar S Matityahu  * @version: error table version
4328a433cb6SJohannes Berg  * @data: data of memory ranges in this region,
4338a433cb6SJohannes Berg  *	see &struct iwl_fw_ini_error_dump_range
434a77e3d28SShahar S Matityahu  */
435a77e3d28SShahar S Matityahu struct iwl_fw_ini_err_table_dump {
436a77e3d28SShahar S Matityahu 	struct iwl_fw_ini_error_dump_header header;
437a77e3d28SShahar S Matityahu 	__le32 version;
4388a433cb6SJohannes Berg 	u8 data[];
4390a3a3e9eSShahar S Matityahu } __packed;
4400a3a3e9eSShahar S Matityahu 
44160eeaf57SShahar S Matityahu /**
442d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_rb - content of an Receive Buffer
443d962f9b1SJohannes Berg  * @index: the index of the Receive Buffer in the Rx queue
444d962f9b1SJohannes Berg  * @rxq: the RB's Rx queue
445d962f9b1SJohannes Berg  * @reserved:
446d962f9b1SJohannes Berg  * @data: the content of the Receive Buffer
447d962f9b1SJohannes Berg  */
448d962f9b1SJohannes Berg struct iwl_fw_error_dump_rb {
449d962f9b1SJohannes Berg 	__le32 index;
450d962f9b1SJohannes Berg 	__le32 rxq;
451d962f9b1SJohannes Berg 	__le32 reserved;
452d962f9b1SJohannes Berg 	u8 data[];
453d962f9b1SJohannes Berg };
454d962f9b1SJohannes Berg 
455d962f9b1SJohannes Berg /**
4564c704534SShahar S Matityahu  * struct iwl_fw_ini_monitor_dump - ini monitor dump
4574828f462SShahar S Matityahu  * @header: header of the region
4584828f462SShahar S Matityahu  * @write_ptr: write pointer position in the buffer
4594828f462SShahar S Matityahu  * @cycle_cnt: cycles count
460593fae3eSShahar S Matityahu  * @cur_frag: current fragment in use
4618a433cb6SJohannes Berg  * @data: data of memory ranges in this region,
4628a433cb6SJohannes Berg  *	see &struct iwl_fw_ini_error_dump_range
463106b791aSShahar S Matityahu  */
4644c704534SShahar S Matityahu struct iwl_fw_ini_monitor_dump {
465106b791aSShahar S Matityahu 	struct iwl_fw_ini_error_dump_header header;
466106b791aSShahar S Matityahu 	__le32 write_ptr;
467106b791aSShahar S Matityahu 	__le32 cycle_cnt;
468593fae3eSShahar S Matityahu 	__le32 cur_frag;
4698a433cb6SJohannes Berg 	u8 data[];
470106b791aSShahar S Matityahu } __packed;
471106b791aSShahar S Matityahu 
472106b791aSShahar S Matityahu /**
473ba8f6f4aSMordechay Goodstein  * struct iwl_fw_ini_special_device_memory - special device memory
474ba8f6f4aSMordechay Goodstein  * @header: header of the region
475ba8f6f4aSMordechay Goodstein  * @type: type of special memory
476ba8f6f4aSMordechay Goodstein  * @version: struct special memory version
4778a433cb6SJohannes Berg  * @data: data of memory ranges in this region,
4788a433cb6SJohannes Berg  *	see &struct iwl_fw_ini_error_dump_range
479ba8f6f4aSMordechay Goodstein  */
480ba8f6f4aSMordechay Goodstein struct iwl_fw_ini_special_device_memory {
481ba8f6f4aSMordechay Goodstein 	struct iwl_fw_ini_error_dump_header header;
482ba8f6f4aSMordechay Goodstein 	__le16 type;
483ba8f6f4aSMordechay Goodstein 	__le16 version;
4848a433cb6SJohannes Berg 	u8 data[];
485ba8f6f4aSMordechay Goodstein } __packed;
486ba8f6f4aSMordechay Goodstein 
487ba8f6f4aSMordechay Goodstein /**
488d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_paging - content of the UMAC's image page
489d962f9b1SJohannes Berg  *	block on DRAM
490d962f9b1SJohannes Berg  * @index: the index of the page block
491d962f9b1SJohannes Berg  * @reserved:
492d962f9b1SJohannes Berg  * @data: the content of the page block
493d962f9b1SJohannes Berg  */
494d962f9b1SJohannes Berg struct iwl_fw_error_dump_paging {
495d962f9b1SJohannes Berg 	__le32 index;
496d962f9b1SJohannes Berg 	__le32 reserved;
497d962f9b1SJohannes Berg 	u8 data[];
498d962f9b1SJohannes Berg };
499d962f9b1SJohannes Berg 
500d962f9b1SJohannes Berg /**
501d962f9b1SJohannes Berg  * iwl_fw_error_next_data - advance fw error dump data pointer
502d962f9b1SJohannes Berg  * @data: previous data block
503d962f9b1SJohannes Berg  * Returns: next data block
504d962f9b1SJohannes Berg  */
505d962f9b1SJohannes Berg static inline struct iwl_fw_error_dump_data *
iwl_fw_error_next_data(struct iwl_fw_error_dump_data * data)506d962f9b1SJohannes Berg iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
507d962f9b1SJohannes Berg {
508d962f9b1SJohannes Berg 	return (void *)(data->data + le32_to_cpu(data->len));
509d962f9b1SJohannes Berg }
510d962f9b1SJohannes Berg 
511d962f9b1SJohannes Berg /**
512d962f9b1SJohannes Berg  * enum iwl_fw_dbg_trigger - triggers available
513d962f9b1SJohannes Berg  *
514d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_USER: trigger log collection by user
515d962f9b1SJohannes Berg  *	This should not be defined as a trigger to the driver, but a value the
516d962f9b1SJohannes Berg  *	driver should set to indicate that the trigger was initiated by the
517d962f9b1SJohannes Berg  *	user.
518d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
519d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
520d962f9b1SJohannes Berg  *	missed.
521d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
522d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
523d962f9b1SJohannes Berg  *	command response or a notification.
524d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
525d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
526d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
527d962f9b1SJohannes Berg  *	goes below a threshold.
528d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
529d962f9b1SJohannes Berg  *	detection.
530d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
531d962f9b1SJohannes Berg  *	events.
532d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
533d962f9b1SJohannes Berg  * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a
534d962f9b1SJohannes Berg  *	threshold.
535d962f9b1SJohannes Berg  * @FW_DBG_TDLS: trigger log collection upon TDLS related events.
536d962f9b1SJohannes Berg  * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when
537d962f9b1SJohannes Berg  *  the firmware sends a tx reply.
53867b8261cSShahar S Matityahu  * @FW_DBG_TRIGGER_ALIVE_TIMEOUT: trigger log collection if alive flow timeouts
539700b3799SShahar S Matityahu  * @FW_DBG_TRIGGER_DRIVER: trigger log collection upon a flow failure
540700b3799SShahar S Matityahu  *	in the driver.
541d962f9b1SJohannes Berg  */
542d962f9b1SJohannes Berg enum iwl_fw_dbg_trigger {
543d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_INVALID = 0,
544d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_USER,
545d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_FW_ASSERT,
546d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_MISSED_BEACONS,
547d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_CHANNEL_SWITCH,
548d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_FW_NOTIF,
549d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_MLME,
550d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_STATS,
551d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_RSSI,
552d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_TXQ_TIMERS,
553d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_TIME_EVENT,
554d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_BA,
555d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_TX_LATENCY,
556d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_TDLS,
557d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_TX_STATUS,
55867b8261cSShahar S Matityahu 	FW_DBG_TRIGGER_ALIVE_TIMEOUT,
559700b3799SShahar S Matityahu 	FW_DBG_TRIGGER_DRIVER,
560d962f9b1SJohannes Berg 
561d962f9b1SJohannes Berg 	/* must be last */
562d962f9b1SJohannes Berg 	FW_DBG_TRIGGER_MAX,
563d962f9b1SJohannes Berg };
564d962f9b1SJohannes Berg 
565d962f9b1SJohannes Berg /**
566d962f9b1SJohannes Berg  * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
567d962f9b1SJohannes Berg  * @type: &enum iwl_fw_dbg_trigger
568d962f9b1SJohannes Berg  * @data: raw data about what happened
569d962f9b1SJohannes Berg  */
570d962f9b1SJohannes Berg struct iwl_fw_error_dump_trigger_desc {
571d962f9b1SJohannes Berg 	__le32 type;
572d962f9b1SJohannes Berg 	u8 data[];
573d962f9b1SJohannes Berg };
574d962f9b1SJohannes Berg 
575d962f9b1SJohannes Berg #endif /* __fw_error_dump_h__ */
576