gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / net / wireless / intel / iwlwifi / fw / error-dump.h
blobf008e1bbfdf479787dc9c6dcca73a328e4ec3eee
1 /******************************************************************************
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.
6 * GPL LICENSE SUMMARY
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
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.
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.
22 * The full GNU General Public License is included in this distribution
23 * in the file called COPYING.
25 * Contact Information:
26 * Intel Linux Wireless <linuxwifi@intel.com>
27 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
29 * BSD LICENSE
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.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
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.
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 *****************************************************************************/
64 #ifndef __fw_error_dump_h__
65 #define __fw_error_dump_h__
67 #include <linux/types.h>
68 #include "fw/api/cmdhdr.h"
70 #define IWL_FW_ERROR_DUMP_BARKER 0x14789632
71 #define IWL_FW_INI_ERROR_DUMP_BARKER 0x14789633
73 /**
74 * enum iwl_fw_error_dump_type - types of data in the dump file
75 * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
76 * @IWL_FW_ERROR_DUMP_RXF:
77 * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
78 * &struct iwl_fw_error_dump_txcmd packets
79 * @IWL_FW_ERROR_DUMP_DEV_FW_INFO: struct %iwl_fw_error_dump_info
80 * info on the device / firmware.
81 * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
82 * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
83 * sections like this in a single file.
84 * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
85 * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
86 * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump.
87 * Structured as &struct iwl_fw_error_dump_trigger_desc.
88 * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as
89 * &struct iwl_fw_error_dump_rb
90 * @IWL_FW_ERROR_PAGING: UMAC's image memory segments which were
91 * paged to the DRAM.
92 * @IWL_FW_ERROR_DUMP_RADIO_REG: Dump the radio registers.
93 * @IWL_FW_ERROR_DUMP_EXTERNAL: used only by external code utilities, and
94 * for that reason is not in use in any other place in the Linux Wi-Fi
95 * stack.
96 * @IWL_FW_ERROR_DUMP_MEM_CFG: the addresses and sizes of fifos in the smem,
97 * which we get from the fw after ALIVE. The content is structured as
98 * &struct iwl_fw_error_dump_smem_cfg.
100 enum iwl_fw_error_dump_type {
101 /* 0 is deprecated */
102 IWL_FW_ERROR_DUMP_CSR = 1,
103 IWL_FW_ERROR_DUMP_RXF = 2,
104 IWL_FW_ERROR_DUMP_TXCMD = 3,
105 IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
106 IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
107 IWL_FW_ERROR_DUMP_PRPH = 6,
108 IWL_FW_ERROR_DUMP_TXF = 7,
109 IWL_FW_ERROR_DUMP_FH_REGS = 8,
110 IWL_FW_ERROR_DUMP_MEM = 9,
111 IWL_FW_ERROR_DUMP_ERROR_INFO = 10,
112 IWL_FW_ERROR_DUMP_RB = 11,
113 IWL_FW_ERROR_DUMP_PAGING = 12,
114 IWL_FW_ERROR_DUMP_RADIO_REG = 13,
115 IWL_FW_ERROR_DUMP_INTERNAL_TXF = 14,
116 IWL_FW_ERROR_DUMP_EXTERNAL = 15, /* Do not move */
117 IWL_FW_ERROR_DUMP_MEM_CFG = 16,
118 IWL_FW_ERROR_DUMP_D3_DEBUG_DATA = 17,
120 IWL_FW_ERROR_DUMP_MAX,
124 * struct iwl_fw_error_dump_data - data for one type
125 * @type: &enum iwl_fw_error_dump_type
126 * @len: the length starting from %data
127 * @data: the data itself
129 struct iwl_fw_error_dump_data {
130 __le32 type;
131 __le32 len;
132 __u8 data[];
133 } __packed;
136 * struct iwl_fw_error_dump_file - the layout of the header of the file
137 * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
138 * @file_len: the length of all the file starting from %barker
139 * @data: array of &struct iwl_fw_error_dump_data
141 struct iwl_fw_error_dump_file {
142 __le32 barker;
143 __le32 file_len;
144 u8 data[0];
145 } __packed;
148 * struct iwl_fw_error_dump_txcmd - TX command data
149 * @cmdlen: original length of command
150 * @caplen: captured length of command (may be less)
151 * @data: captured command data, @caplen bytes
153 struct iwl_fw_error_dump_txcmd {
154 __le32 cmdlen;
155 __le32 caplen;
156 u8 data[];
157 } __packed;
160 * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
161 * @fifo_num: number of FIFO (starting from 0)
162 * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
163 * @wr_ptr: position of write pointer
164 * @rd_ptr: position of read pointer
165 * @fence_ptr: position of fence pointer
166 * @fence_mode: the current mode of the fence (before locking) -
167 * 0=follow RD pointer ; 1 = freeze
168 * @data: all of the FIFO's data
170 struct iwl_fw_error_dump_fifo {
171 __le32 fifo_num;
172 __le32 available_bytes;
173 __le32 wr_ptr;
174 __le32 rd_ptr;
175 __le32 fence_ptr;
176 __le32 fence_mode;
177 u8 data[];
178 } __packed;
180 enum iwl_fw_error_dump_family {
181 IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
182 IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
185 #define MAX_NUM_LMAC 2
188 * struct iwl_fw_error_dump_info - info on the device / firmware
189 * @hw_type: the type of the device
190 * @hw_step: the step of the device
191 * @fw_human_readable: human readable FW version
192 * @dev_human_readable: name of the device
193 * @bus_human_readable: name of the bus used
194 * @num_of_lmacs: the number of lmacs
195 * @lmac_err_id: the lmac 0/1 error_id/rt_status that triggered the latest dump
196 * if the dump collection was not initiated by an assert, the value is 0
197 * @umac_err_id: the umac error_id/rt_status that triggered the latest dump
198 * if the dump collection was not initiated by an assert, the value is 0
200 struct iwl_fw_error_dump_info {
201 __le32 hw_type;
202 __le32 hw_step;
203 u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
204 u8 dev_human_readable[64];
205 u8 bus_human_readable[8];
206 u8 num_of_lmacs;
207 __le32 umac_err_id;
208 __le32 lmac_err_id[MAX_NUM_LMAC];
209 } __packed;
212 * struct iwl_fw_error_dump_fw_mon - FW monitor data
213 * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
214 * @fw_mon_base_ptr: base pointer of the data
215 * @fw_mon_cycle_cnt: number of wraparounds
216 * @fw_mon_base_high_ptr: used in AX210 devices, the base adderss is 64 bit
217 * so fw_mon_base_ptr holds LSB 32 bits and fw_mon_base_high_ptr hold
218 * MSB 32 bits
219 * @reserved: for future use
220 * @data: captured data
222 struct iwl_fw_error_dump_fw_mon {
223 __le32 fw_mon_wr_ptr;
224 __le32 fw_mon_base_ptr;
225 __le32 fw_mon_cycle_cnt;
226 __le32 fw_mon_base_high_ptr;
227 __le32 reserved[2];
228 u8 data[];
229 } __packed;
231 #define MAX_NUM_LMAC 2
232 #define TX_FIFO_INTERNAL_MAX_NUM 6
233 #define TX_FIFO_MAX_NUM 15
235 * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration
236 * This must follow &struct iwl_fwrt_shared_mem_cfg.
237 * @num_lmacs: number of lmacs
238 * @num_txfifo_entries: number of tx fifos
239 * @lmac: sizes of lmacs txfifos and rxfifo1
240 * @rxfifo2_size: size of rxfifo2
241 * @internal_txfifo_addr: address of internal tx fifo
242 * @internal_txfifo_size: size of internal tx fifo
244 struct iwl_fw_error_dump_smem_cfg {
245 __le32 num_lmacs;
246 __le32 num_txfifo_entries;
247 struct {
248 __le32 txfifo_size[TX_FIFO_MAX_NUM];
249 __le32 rxfifo1_size;
250 } lmac[MAX_NUM_LMAC];
251 __le32 rxfifo2_size;
252 __le32 internal_txfifo_addr;
253 __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
254 } __packed;
256 * struct iwl_fw_error_dump_prph - periphery registers data
257 * @prph_start: address of the first register in this chunk
258 * @data: the content of the registers
260 struct iwl_fw_error_dump_prph {
261 __le32 prph_start;
262 __le32 data[];
265 enum iwl_fw_error_dump_mem_type {
266 IWL_FW_ERROR_DUMP_MEM_SRAM,
267 IWL_FW_ERROR_DUMP_MEM_SMEM,
268 IWL_FW_ERROR_DUMP_MEM_NAMED_MEM = 10,
272 * struct iwl_fw_error_dump_mem - chunk of memory
273 * @type: &enum iwl_fw_error_dump_mem_type
274 * @offset: the offset from which the memory was read
275 * @data: the content of the memory
277 struct iwl_fw_error_dump_mem {
278 __le32 type;
279 __le32 offset;
280 u8 data[];
283 /* Dump version, used by the dump parser to differentiate between
284 * different dump formats
286 #define IWL_INI_DUMP_VER 1
288 /* Use bit 31 as dump info type to avoid colliding with region types */
289 #define IWL_INI_DUMP_INFO_TYPE BIT(31)
292 * struct iwl_fw_ini_dump_entry
293 * @list: list of dump entries
294 * @size: size of the data
295 * @data: entry data
297 struct iwl_fw_ini_dump_entry {
298 struct list_head list;
299 u32 size;
300 u8 data[];
301 } __packed;
304 * struct iwl_fw_error_dump_file - header of dump file
305 * @barker: must be %IWL_FW_INI_ERROR_DUMP_BARKER
306 * @file_len: the length of all the file including the header
308 struct iwl_fw_ini_dump_file_hdr {
309 __le32 barker;
310 __le32 file_len;
311 } __packed;
314 * struct iwl_fw_ini_fifo_hdr - fifo range header
315 * @fifo_num: the fifo number. In case of umac rx fifo, set BIT(31) to
316 * distinguish between lmac and umac rx fifos
317 * @num_of_registers: num of registers to dump, dword size each
319 struct iwl_fw_ini_fifo_hdr {
320 __le32 fifo_num;
321 __le32 num_of_registers;
322 } __packed;
325 * struct iwl_fw_ini_error_dump_range - range of memory
326 * @range_data_size: the size of this range, in bytes
327 * @internal_base_addr: base address of internal memory range
328 * @dram_base_addr: base address of dram monitor range
329 * @page_num: page number of memory range
330 * @fifo_hdr: fifo header of memory range
331 * @fw_pkt: FW packet header of memory range
332 * @data: the actual memory
334 struct iwl_fw_ini_error_dump_range {
335 __le32 range_data_size;
336 union {
337 __le32 internal_base_addr;
338 __le64 dram_base_addr;
339 __le32 page_num;
340 struct iwl_fw_ini_fifo_hdr fifo_hdr;
341 struct iwl_cmd_header fw_pkt_hdr;
343 __le32 data[];
344 } __packed;
347 * struct iwl_fw_ini_error_dump_header - ini region dump header
348 * @version: dump version
349 * @region_id: id of the region
350 * @num_of_ranges: number of ranges in this region
351 * @name_len: number of bytes allocated to the name string of this region
352 * @name: name of the region
354 struct iwl_fw_ini_error_dump_header {
355 __le32 version;
356 __le32 region_id;
357 __le32 num_of_ranges;
358 __le32 name_len;
359 u8 name[IWL_FW_INI_MAX_NAME];
363 * struct iwl_fw_ini_error_dump - ini region dump
364 * @header: the header of this region
365 * @ranges: the memory ranges of this region
367 struct iwl_fw_ini_error_dump {
368 struct iwl_fw_ini_error_dump_header header;
369 struct iwl_fw_ini_error_dump_range ranges[];
370 } __packed;
372 /* This bit is used to differentiate between lmac and umac rxf */
373 #define IWL_RXF_UMAC_BIT BIT(31)
376 * struct iwl_fw_ini_error_dump_register - ini register dump
377 * @addr: address of the register
378 * @data: data of the register
380 struct iwl_fw_ini_error_dump_register {
381 __le32 addr;
382 __le32 data;
383 } __packed;
386 * struct iwl_fw_ini_dump_cfg_name - configuration name
387 * @image_type: image type the configuration is related to
388 * @cfg_name_len: length of the configuration name
389 * @cfg_name: name of the configuraiton
391 struct iwl_fw_ini_dump_cfg_name {
392 __le32 image_type;
393 __le32 cfg_name_len;
394 u8 cfg_name[IWL_FW_INI_MAX_CFG_NAME];
395 } __packed;
397 /* struct iwl_fw_ini_dump_info - ini dump information
398 * @version: dump version
399 * @time_point: time point that caused the dump collection
400 * @trigger_reason: reason of the trigger
401 * @external_cfg_state: &enum iwl_ini_cfg_state
402 * @ver_type: FW version type
403 * @ver_subtype: FW version subype
404 * @hw_step: HW step
405 * @hw_type: HW type
406 * @rf_id_flavor: HW RF id flavor
407 * @rf_id_dash: HW RF id dash
408 * @rf_id_step: HW RF id step
409 * @rf_id_type: HW RF id type
410 * @lmac_major: lmac major version
411 * @lmac_minor: lmac minor version
412 * @umac_major: umac major version
413 * @umac_minor: umac minor version
414 * @fw_mon_mode: FW monitor mode &enum iwl_fw_ini_buffer_location
415 * @regions_mask: bitmap mask of regions ids in the dump
416 * @build_tag_len: length of the build tag
417 * @build_tag: build tag string
418 * @num_of_cfg_names: number of configuration name structs
419 * @cfg_names: configuration names
421 struct iwl_fw_ini_dump_info {
422 __le32 version;
423 __le32 time_point;
424 __le32 trigger_reason;
425 __le32 external_cfg_state;
426 __le32 ver_type;
427 __le32 ver_subtype;
428 __le32 hw_step;
429 __le32 hw_type;
430 __le32 rf_id_flavor;
431 __le32 rf_id_dash;
432 __le32 rf_id_step;
433 __le32 rf_id_type;
434 __le32 lmac_major;
435 __le32 lmac_minor;
436 __le32 umac_major;
437 __le32 umac_minor;
438 __le32 fw_mon_mode;
439 __le64 regions_mask;
440 __le32 build_tag_len;
441 u8 build_tag[FW_VER_HUMAN_READABLE_SZ];
442 __le32 num_of_cfg_names;
443 struct iwl_fw_ini_dump_cfg_name cfg_names[];
444 } __packed;
447 * struct iwl_fw_ini_err_table_dump - ini error table dump
448 * @header: header of the region
449 * @version: error table version
450 * @ranges: the memory ranges of this this region
452 struct iwl_fw_ini_err_table_dump {
453 struct iwl_fw_ini_error_dump_header header;
454 __le32 version;
455 struct iwl_fw_ini_error_dump_range ranges[];
456 } __packed;
459 * struct iwl_fw_error_dump_rb - content of an Receive Buffer
460 * @index: the index of the Receive Buffer in the Rx queue
461 * @rxq: the RB's Rx queue
462 * @reserved:
463 * @data: the content of the Receive Buffer
465 struct iwl_fw_error_dump_rb {
466 __le32 index;
467 __le32 rxq;
468 __le32 reserved;
469 u8 data[];
473 * struct iwl_fw_ini_monitor_dump - ini monitor dump
474 * @header: header of the region
475 * @write_ptr: write pointer position in the buffer
476 * @cycle_cnt: cycles count
477 * @cur_frag: current fragment in use
478 * @ranges: the memory ranges of this this region
480 struct iwl_fw_ini_monitor_dump {
481 struct iwl_fw_ini_error_dump_header header;
482 __le32 write_ptr;
483 __le32 cycle_cnt;
484 __le32 cur_frag;
485 struct iwl_fw_ini_error_dump_range ranges[];
486 } __packed;
489 * struct iwl_fw_error_dump_paging - content of the UMAC's image page
490 * block on DRAM
491 * @index: the index of the page block
492 * @reserved:
493 * @data: the content of the page block
495 struct iwl_fw_error_dump_paging {
496 __le32 index;
497 __le32 reserved;
498 u8 data[];
502 * iwl_fw_error_next_data - advance fw error dump data pointer
503 * @data: previous data block
504 * Returns: next data block
506 static inline struct iwl_fw_error_dump_data *
507 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
509 return (void *)(data->data + le32_to_cpu(data->len));
513 * enum iwl_fw_dbg_trigger - triggers available
515 * @FW_DBG_TRIGGER_USER: trigger log collection by user
516 * This should not be defined as a trigger to the driver, but a value the
517 * driver should set to indicate that the trigger was initiated by the
518 * user.
519 * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
520 * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
521 * missed.
522 * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
523 * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
524 * command response or a notification.
525 * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
526 * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
527 * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
528 * goes below a threshold.
529 * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
530 * detection.
531 * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
532 * events.
533 * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
534 * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a
535 * threshold.
536 * @FW_DBG_TDLS: trigger log collection upon TDLS related events.
537 * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when
538 * the firmware sends a tx reply.
539 * @FW_DBG_TRIGGER_ALIVE_TIMEOUT: trigger log collection if alive flow timeouts
540 * @FW_DBG_TRIGGER_DRIVER: trigger log collection upon a flow failure
541 * in the driver.
543 enum iwl_fw_dbg_trigger {
544 FW_DBG_TRIGGER_INVALID = 0,
545 FW_DBG_TRIGGER_USER,
546 FW_DBG_TRIGGER_FW_ASSERT,
547 FW_DBG_TRIGGER_MISSED_BEACONS,
548 FW_DBG_TRIGGER_CHANNEL_SWITCH,
549 FW_DBG_TRIGGER_FW_NOTIF,
550 FW_DBG_TRIGGER_MLME,
551 FW_DBG_TRIGGER_STATS,
552 FW_DBG_TRIGGER_RSSI,
553 FW_DBG_TRIGGER_TXQ_TIMERS,
554 FW_DBG_TRIGGER_TIME_EVENT,
555 FW_DBG_TRIGGER_BA,
556 FW_DBG_TRIGGER_TX_LATENCY,
557 FW_DBG_TRIGGER_TDLS,
558 FW_DBG_TRIGGER_TX_STATUS,
559 FW_DBG_TRIGGER_ALIVE_TIMEOUT,
560 FW_DBG_TRIGGER_DRIVER,
562 /* must be last */
563 FW_DBG_TRIGGER_MAX,
567 * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
568 * @type: &enum iwl_fw_dbg_trigger
569 * @data: raw data about what happened
571 struct iwl_fw_error_dump_trigger_desc {
572 __le32 type;
573 u8 data[];
576 #endif /* __fw_error_dump_h__ */