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