1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright (C) 2014, 2018-2022 Intel Corporation
4 * Copyright (C) 2014-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
7 #ifndef __fw_error_dump_h__
8 #define __fw_error_dump_h__
10 #include <linux/types.h>
11 #include "fw/api/cmdhdr.h"
13 #define IWL_FW_ERROR_DUMP_BARKER 0x14789632
14 #define IWL_FW_INI_ERROR_DUMP_BARKER 0x14789633
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
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
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.
43 enum iwl_fw_error_dump_type {
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,
63 IWL_FW_ERROR_DUMP_MAX,
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
72 struct iwl_fw_error_dump_data {
79 * struct iwl_dump_file_name_info - data for dump file name addition
80 * @type: region type with reserved bits
81 * @len: the length of file name string to be added to dump file
82 * @data: the string need to be added to dump file
84 struct iwl_dump_file_name_info {
91 * struct iwl_fw_error_dump_file - the layout of the header of the file
92 * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
93 * @file_len: the length of all the file starting from %barker
94 * @data: array of &struct iwl_fw_error_dump_data
96 struct iwl_fw_error_dump_file {
103 * struct iwl_fw_error_dump_txcmd - TX command data
104 * @cmdlen: original length of command
105 * @caplen: captured length of command (may be less)
106 * @data: captured command data, @caplen bytes
108 struct iwl_fw_error_dump_txcmd {
115 * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
116 * @fifo_num: number of FIFO (starting from 0)
117 * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
118 * @wr_ptr: position of write pointer
119 * @rd_ptr: position of read pointer
120 * @fence_ptr: position of fence pointer
121 * @fence_mode: the current mode of the fence (before locking) -
122 * 0=follow RD pointer ; 1 = freeze
123 * @data: all of the FIFO's data
125 struct iwl_fw_error_dump_fifo {
127 __le32 available_bytes;
135 enum iwl_fw_error_dump_family {
136 IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
137 IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
140 #define MAX_NUM_LMAC 2
143 * struct iwl_fw_error_dump_info - info on the device / firmware
144 * @hw_type: the type of the device
145 * @hw_step: the step of the device
146 * @fw_human_readable: human readable FW version
147 * @dev_human_readable: name of the device
148 * @bus_human_readable: name of the bus used
149 * @num_of_lmacs: the number of lmacs
150 * @lmac_err_id: the lmac 0/1 error_id/rt_status that triggered the latest dump
151 * if the dump collection was not initiated by an assert, the value is 0
152 * @umac_err_id: the umac error_id/rt_status that triggered the latest dump
153 * if the dump collection was not initiated by an assert, the value is 0
155 struct iwl_fw_error_dump_info {
158 u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
159 u8 dev_human_readable[64];
160 u8 bus_human_readable[8];
163 __le32 lmac_err_id[MAX_NUM_LMAC];
167 * struct iwl_fw_error_dump_fw_mon - FW monitor data
168 * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
169 * @fw_mon_base_ptr: base pointer of the data
170 * @fw_mon_cycle_cnt: number of wraparounds
171 * @fw_mon_base_high_ptr: used in AX210 devices, the base adderss is 64 bit
172 * so fw_mon_base_ptr holds LSB 32 bits and fw_mon_base_high_ptr hold
174 * @reserved: for future use
175 * @data: captured data
177 struct iwl_fw_error_dump_fw_mon {
178 __le32 fw_mon_wr_ptr;
179 __le32 fw_mon_base_ptr;
180 __le32 fw_mon_cycle_cnt;
181 __le32 fw_mon_base_high_ptr;
186 #define MAX_NUM_LMAC 2
187 #define TX_FIFO_INTERNAL_MAX_NUM 6
188 #define TX_FIFO_MAX_NUM 15
190 * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration
191 * This must follow &struct iwl_fwrt_shared_mem_cfg.
192 * @num_lmacs: number of lmacs
193 * @num_txfifo_entries: number of tx fifos
194 * @lmac: sizes of lmacs txfifos and rxfifo1
195 * @rxfifo2_size: size of rxfifo2
196 * @internal_txfifo_addr: address of internal tx fifo
197 * @internal_txfifo_size: size of internal tx fifo
199 struct iwl_fw_error_dump_smem_cfg {
201 __le32 num_txfifo_entries;
203 __le32 txfifo_size[TX_FIFO_MAX_NUM];
205 } lmac[MAX_NUM_LMAC];
207 __le32 internal_txfifo_addr;
208 __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
211 * struct iwl_fw_error_dump_prph - periphery registers data
212 * @prph_start: address of the first register in this chunk
213 * @data: the content of the registers
215 struct iwl_fw_error_dump_prph {
220 enum iwl_fw_error_dump_mem_type {
221 IWL_FW_ERROR_DUMP_MEM_SRAM,
222 IWL_FW_ERROR_DUMP_MEM_SMEM,
223 IWL_FW_ERROR_DUMP_MEM_NAMED_MEM = 10,
227 * struct iwl_fw_error_dump_mem - chunk of memory
228 * @type: &enum iwl_fw_error_dump_mem_type
229 * @offset: the offset from which the memory was read
230 * @data: the content of the memory
232 struct iwl_fw_error_dump_mem {
238 /* Dump version, used by the dump parser to differentiate between
239 * different dump formats
241 #define IWL_INI_DUMP_VER 1
243 /* Use bit 31 as dump info type to avoid colliding with region types */
244 #define IWL_INI_DUMP_INFO_TYPE BIT(31)
246 /* Use bit 31 and bit 24 as dump name type to avoid colliding with region types */
247 #define IWL_INI_DUMP_NAME_TYPE (BIT(31) | BIT(24))
250 * struct iwl_fw_error_dump_data - data for one type
251 * @type: &enum iwl_fw_ini_region_type
252 * @sub_type: sub type id
253 * @sub_type_ver: sub type version
254 * @reserved: not in use
255 * @len: the length starting from %data
256 * @data: the data itself
258 struct iwl_fw_ini_error_dump_data {
268 * struct iwl_fw_ini_dump_entry
269 * @list: list of dump entries
270 * @size: size of the data
273 struct iwl_fw_ini_dump_entry {
274 struct list_head list;
280 * struct iwl_fw_error_dump_file - header of dump file
281 * @barker: must be %IWL_FW_INI_ERROR_DUMP_BARKER
282 * @file_len: the length of all the file including the header
284 struct iwl_fw_ini_dump_file_hdr {
290 * struct iwl_fw_ini_fifo_hdr - fifo range header
291 * @fifo_num: the fifo number. In case of umac rx fifo, set BIT(31) to
292 * distinguish between lmac and umac rx fifos
293 * @num_of_registers: num of registers to dump, dword size each
295 struct iwl_fw_ini_fifo_hdr {
297 __le32 num_of_registers;
301 * struct iwl_fw_ini_error_dump_range - range of memory
302 * @range_data_size: the size of this range, in bytes
303 * @internal_base_addr: base address of internal memory range
304 * @dram_base_addr: base address of dram monitor range
305 * @page_num: page number of memory range
306 * @fifo_hdr: fifo header of memory range
307 * @fw_pkt: FW packet header of memory range
308 * @data: the actual memory
310 struct iwl_fw_ini_error_dump_range {
311 __le32 range_data_size;
313 __le32 internal_base_addr __packed;
314 __le64 dram_base_addr __packed;
315 __le32 page_num __packed;
316 struct iwl_fw_ini_fifo_hdr fifo_hdr;
317 struct iwl_cmd_header fw_pkt_hdr;
323 * struct iwl_fw_ini_error_dump_header - ini region dump header
324 * @version: dump version
325 * @region_id: id of the region
326 * @num_of_ranges: number of ranges in this region
327 * @name_len: number of bytes allocated to the name string of this region
328 * @name: name of the region
330 struct iwl_fw_ini_error_dump_header {
333 __le32 num_of_ranges;
335 u8 name[IWL_FW_INI_MAX_NAME];
339 * struct iwl_fw_ini_error_dump - ini region dump
340 * @header: the header of this region
341 * @data: data of memory ranges in this region,
342 * see &struct iwl_fw_ini_error_dump_range
344 struct iwl_fw_ini_error_dump {
345 struct iwl_fw_ini_error_dump_header header;
349 /* This bit is used to differentiate between lmac and umac rxf */
350 #define IWL_RXF_UMAC_BIT BIT(31)
353 * struct iwl_fw_ini_error_dump_register - ini register dump
354 * @addr: address of the register
355 * @data: data of the register
357 struct iwl_fw_ini_error_dump_register {
363 * struct iwl_fw_ini_dump_cfg_name - configuration name
364 * @image_type: image type the configuration is related to
365 * @cfg_name_len: length of the configuration name
366 * @cfg_name: name of the configuraiton
368 struct iwl_fw_ini_dump_cfg_name {
371 u8 cfg_name[IWL_FW_INI_MAX_CFG_NAME];
374 /* AX210's HW type */
375 #define IWL_AX210_HW_TYPE 0x42
376 /* How many bits to roll when adding to the HW type of AX210 HW */
377 #define IWL_AX210_HW_TYPE_ADDITION_SHIFT 12
379 /* struct iwl_fw_ini_dump_info - ini dump information
380 * @version: dump version
381 * @time_point: time point that caused the dump collection
382 * @trigger_reason: reason of the trigger
383 * @external_cfg_state: &enum iwl_ini_cfg_state
384 * @ver_type: FW version type
385 * @ver_subtype: FW version subype
388 * @rf_id_flavor: HW RF id flavor
389 * @rf_id_dash: HW RF id dash
390 * @rf_id_step: HW RF id step
391 * @rf_id_type: HW RF id type
392 * @lmac_major: lmac major version
393 * @lmac_minor: lmac minor version
394 * @umac_major: umac major version
395 * @umac_minor: umac minor version
396 * @fw_mon_mode: FW monitor mode &enum iwl_fw_ini_buffer_location
397 * @regions_mask: bitmap mask of regions ids in the dump
398 * @build_tag_len: length of the build tag
399 * @build_tag: build tag string
400 * @num_of_cfg_names: number of configuration name structs
401 * @cfg_names: configuration names
403 struct iwl_fw_ini_dump_info {
406 __le32 trigger_reason;
407 __le32 external_cfg_state;
422 __le32 build_tag_len;
423 u8 build_tag[FW_VER_HUMAN_READABLE_SZ];
424 __le32 num_of_cfg_names;
425 struct iwl_fw_ini_dump_cfg_name cfg_names[];
429 * struct iwl_fw_ini_err_table_dump - ini error table dump
430 * @header: header of the region
431 * @version: error table version
432 * @data: data of memory ranges in this region,
433 * see &struct iwl_fw_ini_error_dump_range
435 struct iwl_fw_ini_err_table_dump {
436 struct iwl_fw_ini_error_dump_header header;
442 * struct iwl_fw_error_dump_rb - content of an Receive Buffer
443 * @index: the index of the Receive Buffer in the Rx queue
444 * @rxq: the RB's Rx queue
446 * @data: the content of the Receive Buffer
448 struct iwl_fw_error_dump_rb {
456 * struct iwl_fw_ini_monitor_dump - ini monitor dump
457 * @header: header of the region
458 * @write_ptr: write pointer position in the buffer
459 * @cycle_cnt: cycles count
460 * @cur_frag: current fragment in use
461 * @data: data of memory ranges in this region,
462 * see &struct iwl_fw_ini_error_dump_range
464 struct iwl_fw_ini_monitor_dump {
465 struct iwl_fw_ini_error_dump_header header;
473 * struct iwl_fw_ini_special_device_memory - special device memory
474 * @header: header of the region
475 * @type: type of special memory
476 * @version: struct special memory version
477 * @data: data of memory ranges in this region,
478 * see &struct iwl_fw_ini_error_dump_range
480 struct iwl_fw_ini_special_device_memory {
481 struct iwl_fw_ini_error_dump_header header;
488 * struct iwl_fw_error_dump_paging - content of the UMAC's image page
490 * @index: the index of the page block
492 * @data: the content of the page block
494 struct iwl_fw_error_dump_paging {
501 * iwl_fw_error_next_data - advance fw error dump data pointer
502 * @data: previous data block
503 * Returns: next data block
505 static inline struct iwl_fw_error_dump_data *
506 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
508 return (void *)(data->data + le32_to_cpu(data->len));
512 * enum iwl_fw_dbg_trigger - triggers available
514 * @FW_DBG_TRIGGER_USER: trigger log collection by user
515 * This should not be defined as a trigger to the driver, but a value the
516 * driver should set to indicate that the trigger was initiated by the
518 * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
519 * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
521 * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
522 * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
523 * command response or a notification.
524 * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
525 * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
526 * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
527 * goes below a threshold.
528 * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
530 * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
532 * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
533 * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a
535 * @FW_DBG_TDLS: trigger log collection upon TDLS related events.
536 * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when
537 * the firmware sends a tx reply.
538 * @FW_DBG_TRIGGER_ALIVE_TIMEOUT: trigger log collection if alive flow timeouts
539 * @FW_DBG_TRIGGER_DRIVER: trigger log collection upon a flow failure
542 enum iwl_fw_dbg_trigger {
543 FW_DBG_TRIGGER_INVALID = 0,
545 FW_DBG_TRIGGER_FW_ASSERT,
546 FW_DBG_TRIGGER_MISSED_BEACONS,
547 FW_DBG_TRIGGER_CHANNEL_SWITCH,
548 FW_DBG_TRIGGER_FW_NOTIF,
550 FW_DBG_TRIGGER_STATS,
552 FW_DBG_TRIGGER_TXQ_TIMERS,
553 FW_DBG_TRIGGER_TIME_EVENT,
555 FW_DBG_TRIGGER_TX_LATENCY,
557 FW_DBG_TRIGGER_TX_STATUS,
558 FW_DBG_TRIGGER_ALIVE_TIMEOUT,
559 FW_DBG_TRIGGER_DRIVER,
566 * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
567 * @type: &enum iwl_fw_dbg_trigger
568 * @data: raw data about what happened
570 struct iwl_fw_error_dump_trigger_desc {
575 #endif /* __fw_error_dump_h__ */