Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
0002 /*
0003  * Copyright (C) 2014, 2018-2021 Intel Corporation
0004  * Copyright (C) 2014-2015 Intel Mobile Communications GmbH
0005  * Copyright (C) 2016-2017 Intel Deutschland GmbH
0006  */
0007 #ifndef __fw_error_dump_h__
0008 #define __fw_error_dump_h__
0009 
0010 #include <linux/types.h>
0011 #include "fw/api/cmdhdr.h"
0012 
0013 #define IWL_FW_ERROR_DUMP_BARKER    0x14789632
0014 #define IWL_FW_INI_ERROR_DUMP_BARKER    0x14789633
0015 
0016 /**
0017  * enum iwl_fw_error_dump_type - types of data in the dump file
0018  * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
0019  * @IWL_FW_ERROR_DUMP_RXF:
0020  * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
0021  *  &struct iwl_fw_error_dump_txcmd packets
0022  * @IWL_FW_ERROR_DUMP_DEV_FW_INFO:  struct %iwl_fw_error_dump_info
0023  *  info on the device / firmware.
0024  * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
0025  * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
0026  *  sections like this in a single file.
0027  * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
0028  * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
0029  * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump.
0030  *  Structured as &struct iwl_fw_error_dump_trigger_desc.
0031  * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as
0032  *  &struct iwl_fw_error_dump_rb
0033  * @IWL_FW_ERROR_PAGING: UMAC's image memory segments which were
0034  *  paged to the DRAM.
0035  * @IWL_FW_ERROR_DUMP_RADIO_REG: Dump the radio registers.
0036  * @IWL_FW_ERROR_DUMP_EXTERNAL: used only by external code utilities, and
0037  *  for that reason is not in use in any other place in the Linux Wi-Fi
0038  *  stack.
0039  * @IWL_FW_ERROR_DUMP_MEM_CFG: the addresses and sizes of fifos in the smem,
0040  *  which we get from the fw after ALIVE. The content is structured as
0041  *  &struct iwl_fw_error_dump_smem_cfg.
0042  */
0043 enum iwl_fw_error_dump_type {
0044     /* 0 is deprecated */
0045     IWL_FW_ERROR_DUMP_CSR = 1,
0046     IWL_FW_ERROR_DUMP_RXF = 2,
0047     IWL_FW_ERROR_DUMP_TXCMD = 3,
0048     IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
0049     IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
0050     IWL_FW_ERROR_DUMP_PRPH = 6,
0051     IWL_FW_ERROR_DUMP_TXF = 7,
0052     IWL_FW_ERROR_DUMP_FH_REGS = 8,
0053     IWL_FW_ERROR_DUMP_MEM = 9,
0054     IWL_FW_ERROR_DUMP_ERROR_INFO = 10,
0055     IWL_FW_ERROR_DUMP_RB = 11,
0056     IWL_FW_ERROR_DUMP_PAGING = 12,
0057     IWL_FW_ERROR_DUMP_RADIO_REG = 13,
0058     IWL_FW_ERROR_DUMP_INTERNAL_TXF = 14,
0059     IWL_FW_ERROR_DUMP_EXTERNAL = 15, /* Do not move */
0060     IWL_FW_ERROR_DUMP_MEM_CFG = 16,
0061     IWL_FW_ERROR_DUMP_D3_DEBUG_DATA = 17,
0062 
0063     IWL_FW_ERROR_DUMP_MAX,
0064 };
0065 
0066 /**
0067  * struct iwl_fw_error_dump_data - data for one type
0068  * @type: &enum iwl_fw_error_dump_type
0069  * @len: the length starting from %data
0070  * @data: the data itself
0071  */
0072 struct iwl_fw_error_dump_data {
0073     __le32 type;
0074     __le32 len;
0075     __u8 data[];
0076 } __packed;
0077 
0078 /**
0079  * struct iwl_fw_error_dump_file - the layout of the header of the file
0080  * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
0081  * @file_len: the length of all the file starting from %barker
0082  * @data: array of &struct iwl_fw_error_dump_data
0083  */
0084 struct iwl_fw_error_dump_file {
0085     __le32 barker;
0086     __le32 file_len;
0087     u8 data[];
0088 } __packed;
0089 
0090 /**
0091  * struct iwl_fw_error_dump_txcmd - TX command data
0092  * @cmdlen: original length of command
0093  * @caplen: captured length of command (may be less)
0094  * @data: captured command data, @caplen bytes
0095  */
0096 struct iwl_fw_error_dump_txcmd {
0097     __le32 cmdlen;
0098     __le32 caplen;
0099     u8 data[];
0100 } __packed;
0101 
0102 /**
0103  * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
0104  * @fifo_num: number of FIFO (starting from 0)
0105  * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
0106  * @wr_ptr: position of write pointer
0107  * @rd_ptr: position of read pointer
0108  * @fence_ptr: position of fence pointer
0109  * @fence_mode: the current mode of the fence (before locking) -
0110  *  0=follow RD pointer ; 1 = freeze
0111  * @data: all of the FIFO's data
0112  */
0113 struct iwl_fw_error_dump_fifo {
0114     __le32 fifo_num;
0115     __le32 available_bytes;
0116     __le32 wr_ptr;
0117     __le32 rd_ptr;
0118     __le32 fence_ptr;
0119     __le32 fence_mode;
0120     u8 data[];
0121 } __packed;
0122 
0123 enum iwl_fw_error_dump_family {
0124     IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
0125     IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
0126 };
0127 
0128 #define MAX_NUM_LMAC 2
0129 
0130 /**
0131  * struct iwl_fw_error_dump_info - info on the device / firmware
0132  * @hw_type: the type of the device
0133  * @hw_step: the step of the device
0134  * @fw_human_readable: human readable FW version
0135  * @dev_human_readable: name of the device
0136  * @bus_human_readable: name of the bus used
0137  * @num_of_lmacs: the number of lmacs
0138  * @lmac_err_id: the lmac 0/1 error_id/rt_status that triggered the latest dump
0139  *  if the dump collection was not initiated by an assert, the value is 0
0140  * @umac_err_id: the umac error_id/rt_status that triggered the latest dump
0141  *  if the dump collection was not initiated by an assert, the value is 0
0142  */
0143 struct iwl_fw_error_dump_info {
0144     __le32 hw_type;
0145     __le32 hw_step;
0146     u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
0147     u8 dev_human_readable[64];
0148     u8 bus_human_readable[8];
0149     u8 num_of_lmacs;
0150     __le32 umac_err_id;
0151     __le32 lmac_err_id[MAX_NUM_LMAC];
0152 } __packed;
0153 
0154 /**
0155  * struct iwl_fw_error_dump_fw_mon - FW monitor data
0156  * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
0157  * @fw_mon_base_ptr: base pointer of the data
0158  * @fw_mon_cycle_cnt: number of wraparounds
0159  * @fw_mon_base_high_ptr: used in AX210 devices, the base adderss is 64 bit
0160  *  so fw_mon_base_ptr holds LSB 32 bits and fw_mon_base_high_ptr hold
0161  *  MSB 32 bits
0162  * @reserved: for future use
0163  * @data: captured data
0164  */
0165 struct iwl_fw_error_dump_fw_mon {
0166     __le32 fw_mon_wr_ptr;
0167     __le32 fw_mon_base_ptr;
0168     __le32 fw_mon_cycle_cnt;
0169     __le32 fw_mon_base_high_ptr;
0170     __le32 reserved[2];
0171     u8 data[];
0172 } __packed;
0173 
0174 #define MAX_NUM_LMAC 2
0175 #define TX_FIFO_INTERNAL_MAX_NUM    6
0176 #define TX_FIFO_MAX_NUM         15
0177 /**
0178  * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration
0179  *  This must follow &struct iwl_fwrt_shared_mem_cfg.
0180  * @num_lmacs: number of lmacs
0181  * @num_txfifo_entries: number of tx fifos
0182  * @lmac: sizes of lmacs txfifos and rxfifo1
0183  * @rxfifo2_size: size of rxfifo2
0184  * @internal_txfifo_addr: address of internal tx fifo
0185  * @internal_txfifo_size: size of internal tx fifo
0186  */
0187 struct iwl_fw_error_dump_smem_cfg {
0188     __le32 num_lmacs;
0189     __le32 num_txfifo_entries;
0190     struct {
0191         __le32 txfifo_size[TX_FIFO_MAX_NUM];
0192         __le32 rxfifo1_size;
0193     } lmac[MAX_NUM_LMAC];
0194     __le32 rxfifo2_size;
0195     __le32 internal_txfifo_addr;
0196     __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
0197 } __packed;
0198 /**
0199  * struct iwl_fw_error_dump_prph - periphery registers data
0200  * @prph_start: address of the first register in this chunk
0201  * @data: the content of the registers
0202  */
0203 struct iwl_fw_error_dump_prph {
0204     __le32 prph_start;
0205     __le32 data[];
0206 };
0207 
0208 enum iwl_fw_error_dump_mem_type {
0209     IWL_FW_ERROR_DUMP_MEM_SRAM,
0210     IWL_FW_ERROR_DUMP_MEM_SMEM,
0211     IWL_FW_ERROR_DUMP_MEM_NAMED_MEM = 10,
0212 };
0213 
0214 /**
0215  * struct iwl_fw_error_dump_mem - chunk of memory
0216  * @type: &enum iwl_fw_error_dump_mem_type
0217  * @offset: the offset from which the memory was read
0218  * @data: the content of the memory
0219  */
0220 struct iwl_fw_error_dump_mem {
0221     __le32 type;
0222     __le32 offset;
0223     u8 data[];
0224 };
0225 
0226 /* Dump version, used by the dump parser to differentiate between
0227  * different dump formats
0228  */
0229 #define IWL_INI_DUMP_VER 1
0230 
0231 /* Use bit 31 as dump info type to avoid colliding with region types */
0232 #define IWL_INI_DUMP_INFO_TYPE BIT(31)
0233 
0234 /**
0235  * struct iwl_fw_error_dump_data - data for one type
0236  * @type: &enum iwl_fw_ini_region_type
0237  * @sub_type: sub type id
0238  * @sub_type_ver: sub type version
0239  * @reserved: not in use
0240  * @len: the length starting from %data
0241  * @data: the data itself
0242  */
0243 struct iwl_fw_ini_error_dump_data {
0244     u8 type;
0245     u8 sub_type;
0246     u8 sub_type_ver;
0247     u8 reserved;
0248     __le32 len;
0249     __u8 data[];
0250 } __packed;
0251 
0252 /**
0253  * struct iwl_fw_ini_dump_entry
0254  * @list: list of dump entries
0255  * @size: size of the data
0256  * @data: entry data
0257  */
0258 struct iwl_fw_ini_dump_entry {
0259     struct list_head list;
0260     u32 size;
0261     u8 data[];
0262 } __packed;
0263 
0264 /**
0265  * struct iwl_fw_error_dump_file - header of dump file
0266  * @barker: must be %IWL_FW_INI_ERROR_DUMP_BARKER
0267  * @file_len: the length of all the file including the header
0268  */
0269 struct iwl_fw_ini_dump_file_hdr {
0270     __le32 barker;
0271     __le32 file_len;
0272 } __packed;
0273 
0274 /**
0275  * struct iwl_fw_ini_fifo_hdr - fifo range header
0276  * @fifo_num: the fifo number. In case of umac rx fifo, set BIT(31) to
0277  *  distinguish between lmac and umac rx fifos
0278  * @num_of_registers: num of registers to dump, dword size each
0279  */
0280 struct iwl_fw_ini_fifo_hdr {
0281     __le32 fifo_num;
0282     __le32 num_of_registers;
0283 } __packed;
0284 
0285 /**
0286  * struct iwl_fw_ini_error_dump_range - range of memory
0287  * @range_data_size: the size of this range, in bytes
0288  * @internal_base_addr: base address of internal memory range
0289  * @dram_base_addr: base address of dram monitor range
0290  * @page_num: page number of memory range
0291  * @fifo_hdr: fifo header of memory range
0292  * @fw_pkt: FW packet header of memory range
0293  * @data: the actual memory
0294  */
0295 struct iwl_fw_ini_error_dump_range {
0296     __le32 range_data_size;
0297     union {
0298         __le32 internal_base_addr;
0299         __le64 dram_base_addr;
0300         __le32 page_num;
0301         struct iwl_fw_ini_fifo_hdr fifo_hdr;
0302         struct iwl_cmd_header fw_pkt_hdr;
0303     };
0304     __le32 data[];
0305 } __packed;
0306 
0307 /**
0308  * struct iwl_fw_ini_error_dump_header - ini region dump header
0309  * @version: dump version
0310  * @region_id: id of the region
0311  * @num_of_ranges: number of ranges in this region
0312  * @name_len: number of bytes allocated to the name string of this region
0313  * @name: name of the region
0314  */
0315 struct iwl_fw_ini_error_dump_header {
0316     __le32 version;
0317     __le32 region_id;
0318     __le32 num_of_ranges;
0319     __le32 name_len;
0320     u8 name[IWL_FW_INI_MAX_NAME];
0321 };
0322 
0323 /**
0324  * struct iwl_fw_ini_error_dump - ini region dump
0325  * @header: the header of this region
0326  * @data: data of memory ranges in this region,
0327  *  see &struct iwl_fw_ini_error_dump_range
0328  */
0329 struct iwl_fw_ini_error_dump {
0330     struct iwl_fw_ini_error_dump_header header;
0331     u8 data[];
0332 } __packed;
0333 
0334 /* This bit is used to differentiate between lmac and umac rxf */
0335 #define IWL_RXF_UMAC_BIT BIT(31)
0336 
0337 /**
0338  * struct iwl_fw_ini_error_dump_register - ini register dump
0339  * @addr: address of the register
0340  * @data: data of the register
0341  */
0342 struct iwl_fw_ini_error_dump_register {
0343     __le32 addr;
0344     __le32 data;
0345 } __packed;
0346 
0347 /**
0348  * struct iwl_fw_ini_dump_cfg_name - configuration name
0349  * @image_type: image type the configuration is related to
0350  * @cfg_name_len: length of the configuration name
0351  * @cfg_name: name of the configuraiton
0352  */
0353 struct iwl_fw_ini_dump_cfg_name {
0354     __le32 image_type;
0355     __le32 cfg_name_len;
0356     u8 cfg_name[IWL_FW_INI_MAX_CFG_NAME];
0357 } __packed;
0358 
0359 /* AX210's HW type */
0360 #define IWL_AX210_HW_TYPE 0x42
0361 /* How many bits to roll when adding to the HW type of AX210 HW */
0362 #define IWL_AX210_HW_TYPE_ADDITION_SHIFT 12
0363 
0364 /* struct iwl_fw_ini_dump_info - ini dump information
0365  * @version: dump version
0366  * @time_point: time point that caused the dump collection
0367  * @trigger_reason: reason of the trigger
0368  * @external_cfg_state: &enum iwl_ini_cfg_state
0369  * @ver_type: FW version type
0370  * @ver_subtype: FW version subype
0371  * @hw_step: HW step
0372  * @hw_type: HW type
0373  * @rf_id_flavor: HW RF id flavor
0374  * @rf_id_dash: HW RF id dash
0375  * @rf_id_step: HW RF id step
0376  * @rf_id_type: HW RF id type
0377  * @lmac_major: lmac major version
0378  * @lmac_minor: lmac minor version
0379  * @umac_major: umac major version
0380  * @umac_minor: umac minor version
0381  * @fw_mon_mode: FW monitor mode &enum iwl_fw_ini_buffer_location
0382  * @regions_mask: bitmap mask of regions ids in the dump
0383  * @build_tag_len: length of the build tag
0384  * @build_tag: build tag string
0385  * @num_of_cfg_names: number of configuration name structs
0386  * @cfg_names: configuration names
0387  */
0388 struct iwl_fw_ini_dump_info {
0389     __le32 version;
0390     __le32 time_point;
0391     __le32 trigger_reason;
0392     __le32 external_cfg_state;
0393     __le32 ver_type;
0394     __le32 ver_subtype;
0395     __le32 hw_step;
0396     __le32 hw_type;
0397     __le32 rf_id_flavor;
0398     __le32 rf_id_dash;
0399     __le32 rf_id_step;
0400     __le32 rf_id_type;
0401     __le32 lmac_major;
0402     __le32 lmac_minor;
0403     __le32 umac_major;
0404     __le32 umac_minor;
0405     __le32 fw_mon_mode;
0406     __le64 regions_mask;
0407     __le32 build_tag_len;
0408     u8 build_tag[FW_VER_HUMAN_READABLE_SZ];
0409     __le32 num_of_cfg_names;
0410     struct iwl_fw_ini_dump_cfg_name cfg_names[];
0411 } __packed;
0412 
0413 /**
0414  * struct iwl_fw_ini_err_table_dump - ini error table dump
0415  * @header: header of the region
0416  * @version: error table version
0417  * @data: data of memory ranges in this region,
0418  *  see &struct iwl_fw_ini_error_dump_range
0419  */
0420 struct iwl_fw_ini_err_table_dump {
0421     struct iwl_fw_ini_error_dump_header header;
0422     __le32 version;
0423     u8 data[];
0424 } __packed;
0425 
0426 /**
0427  * struct iwl_fw_error_dump_rb - content of an Receive Buffer
0428  * @index: the index of the Receive Buffer in the Rx queue
0429  * @rxq: the RB's Rx queue
0430  * @reserved:
0431  * @data: the content of the Receive Buffer
0432  */
0433 struct iwl_fw_error_dump_rb {
0434     __le32 index;
0435     __le32 rxq;
0436     __le32 reserved;
0437     u8 data[];
0438 };
0439 
0440 /**
0441  * struct iwl_fw_ini_monitor_dump - ini monitor dump
0442  * @header: header of the region
0443  * @write_ptr: write pointer position in the buffer
0444  * @cycle_cnt: cycles count
0445  * @cur_frag: current fragment in use
0446  * @data: data of memory ranges in this region,
0447  *  see &struct iwl_fw_ini_error_dump_range
0448  */
0449 struct iwl_fw_ini_monitor_dump {
0450     struct iwl_fw_ini_error_dump_header header;
0451     __le32 write_ptr;
0452     __le32 cycle_cnt;
0453     __le32 cur_frag;
0454     u8 data[];
0455 } __packed;
0456 
0457 /**
0458  * struct iwl_fw_ini_special_device_memory - special device memory
0459  * @header: header of the region
0460  * @type: type of special memory
0461  * @version: struct special memory version
0462  * @data: data of memory ranges in this region,
0463  *  see &struct iwl_fw_ini_error_dump_range
0464  */
0465 struct iwl_fw_ini_special_device_memory {
0466     struct iwl_fw_ini_error_dump_header header;
0467     __le16 type;
0468     __le16 version;
0469     u8 data[];
0470 } __packed;
0471 
0472 /**
0473  * struct iwl_fw_error_dump_paging - content of the UMAC's image page
0474  *  block on DRAM
0475  * @index: the index of the page block
0476  * @reserved:
0477  * @data: the content of the page block
0478  */
0479 struct iwl_fw_error_dump_paging {
0480     __le32 index;
0481     __le32 reserved;
0482     u8 data[];
0483 };
0484 
0485 /**
0486  * iwl_fw_error_next_data - advance fw error dump data pointer
0487  * @data: previous data block
0488  * Returns: next data block
0489  */
0490 static inline struct iwl_fw_error_dump_data *
0491 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
0492 {
0493     return (void *)(data->data + le32_to_cpu(data->len));
0494 }
0495 
0496 /**
0497  * enum iwl_fw_dbg_trigger - triggers available
0498  *
0499  * @FW_DBG_TRIGGER_USER: trigger log collection by user
0500  *  This should not be defined as a trigger to the driver, but a value the
0501  *  driver should set to indicate that the trigger was initiated by the
0502  *  user.
0503  * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
0504  * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
0505  *  missed.
0506  * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
0507  * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
0508  *  command response or a notification.
0509  * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
0510  * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
0511  * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
0512  *  goes below a threshold.
0513  * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
0514  *  detection.
0515  * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
0516  *  events.
0517  * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
0518  * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a
0519  *  threshold.
0520  * @FW_DBG_TDLS: trigger log collection upon TDLS related events.
0521  * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when
0522  *  the firmware sends a tx reply.
0523  * @FW_DBG_TRIGGER_ALIVE_TIMEOUT: trigger log collection if alive flow timeouts
0524  * @FW_DBG_TRIGGER_DRIVER: trigger log collection upon a flow failure
0525  *  in the driver.
0526  */
0527 enum iwl_fw_dbg_trigger {
0528     FW_DBG_TRIGGER_INVALID = 0,
0529     FW_DBG_TRIGGER_USER,
0530     FW_DBG_TRIGGER_FW_ASSERT,
0531     FW_DBG_TRIGGER_MISSED_BEACONS,
0532     FW_DBG_TRIGGER_CHANNEL_SWITCH,
0533     FW_DBG_TRIGGER_FW_NOTIF,
0534     FW_DBG_TRIGGER_MLME,
0535     FW_DBG_TRIGGER_STATS,
0536     FW_DBG_TRIGGER_RSSI,
0537     FW_DBG_TRIGGER_TXQ_TIMERS,
0538     FW_DBG_TRIGGER_TIME_EVENT,
0539     FW_DBG_TRIGGER_BA,
0540     FW_DBG_TRIGGER_TX_LATENCY,
0541     FW_DBG_TRIGGER_TDLS,
0542     FW_DBG_TRIGGER_TX_STATUS,
0543     FW_DBG_TRIGGER_ALIVE_TIMEOUT,
0544     FW_DBG_TRIGGER_DRIVER,
0545 
0546     /* must be last */
0547     FW_DBG_TRIGGER_MAX,
0548 };
0549 
0550 /**
0551  * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
0552  * @type: &enum iwl_fw_dbg_trigger
0553  * @data: raw data about what happened
0554  */
0555 struct iwl_fw_error_dump_trigger_desc {
0556     __le32 type;
0557     u8 data[];
0558 };
0559 
0560 #endif /* __fw_error_dump_h__ */