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