1 /****************************************************************************** 2 * 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. 5 * 6 * GPL LICENSE SUMMARY 7 * 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 12 * 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. 16 * 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. 21 * 22 * The full GNU General Public License is included in this distribution 23 * in the file called COPYING. 24 * 25 * Contact Information: 26 * Intel Linux Wireless <linuxwifi@intel.com> 27 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 28 * 29 * BSD LICENSE 30 * 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. 36 * 37 * Redistribution and use in source and binary forms, with or without 38 * modification, are permitted provided that the following conditions 39 * are met: 40 * 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. 50 * 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 *****************************************************************************/ 63 64 #ifndef __fw_error_dump_h__ 65 #define __fw_error_dump_h__ 66 67 #include <linux/types.h> 68 69 #define IWL_FW_ERROR_DUMP_BARKER 0x14789632 70 71 /** 72 * enum iwl_fw_error_dump_type - types of data in the dump file 73 * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0 74 * @IWL_FW_ERROR_DUMP_RXF: 75 * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as 76 * &struct iwl_fw_error_dump_txcmd packets 77 * @IWL_FW_ERROR_DUMP_DEV_FW_INFO: struct %iwl_fw_error_dump_info 78 * info on the device / firmware. 79 * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor 80 * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several 81 * sections like this in a single file. 82 * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers 83 * @IWL_FW_ERROR_DUMP_MEM: chunk of memory 84 * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump. 85 * Structured as &struct iwl_fw_error_dump_trigger_desc. 86 * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as 87 * &struct iwl_fw_error_dump_rb 88 * @IWL_FW_ERROR_PAGING: UMAC's image memory segments which were 89 * paged to the DRAM. 90 * @IWL_FW_ERROR_DUMP_RADIO_REG: Dump the radio registers. 91 * @IWL_FW_ERROR_DUMP_EXTERNAL: used only by external code utilities, and 92 * for that reason is not in use in any other place in the Linux Wi-Fi 93 * stack. 94 * @IWL_FW_ERROR_DUMP_MEM_CFG: the addresses and sizes of fifos in the smem, 95 * which we get from the fw after ALIVE. The content is structured as 96 * &struct iwl_fw_error_dump_smem_cfg. 97 */ 98 enum iwl_fw_error_dump_type { 99 /* 0 is deprecated */ 100 IWL_FW_ERROR_DUMP_CSR = 1, 101 IWL_FW_ERROR_DUMP_RXF = 2, 102 IWL_FW_ERROR_DUMP_TXCMD = 3, 103 IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4, 104 IWL_FW_ERROR_DUMP_FW_MONITOR = 5, 105 IWL_FW_ERROR_DUMP_PRPH = 6, 106 IWL_FW_ERROR_DUMP_TXF = 7, 107 IWL_FW_ERROR_DUMP_FH_REGS = 8, 108 IWL_FW_ERROR_DUMP_MEM = 9, 109 IWL_FW_ERROR_DUMP_ERROR_INFO = 10, 110 IWL_FW_ERROR_DUMP_RB = 11, 111 IWL_FW_ERROR_DUMP_PAGING = 12, 112 IWL_FW_ERROR_DUMP_RADIO_REG = 13, 113 IWL_FW_ERROR_DUMP_INTERNAL_TXF = 14, 114 IWL_FW_ERROR_DUMP_EXTERNAL = 15, /* Do not move */ 115 IWL_FW_ERROR_DUMP_MEM_CFG = 16, 116 IWL_FW_ERROR_DUMP_D3_DEBUG_DATA = 17, 117 118 IWL_FW_ERROR_DUMP_MAX, 119 }; 120 121 /** 122 * struct iwl_fw_error_dump_data - data for one type 123 * @type: &enum iwl_fw_error_dump_type 124 * @len: the length starting from %data 125 * @data: the data itself 126 */ 127 struct iwl_fw_error_dump_data { 128 __le32 type; 129 __le32 len; 130 __u8 data[]; 131 } __packed; 132 133 /** 134 * struct iwl_fw_error_dump_file - the layout of the header of the file 135 * @barker: must be %IWL_FW_ERROR_DUMP_BARKER 136 * @file_len: the length of all the file starting from %barker 137 * @data: array of &struct iwl_fw_error_dump_data 138 */ 139 struct iwl_fw_error_dump_file { 140 __le32 barker; 141 __le32 file_len; 142 u8 data[0]; 143 } __packed; 144 145 /** 146 * struct iwl_fw_error_dump_txcmd - TX command data 147 * @cmdlen: original length of command 148 * @caplen: captured length of command (may be less) 149 * @data: captured command data, @caplen bytes 150 */ 151 struct iwl_fw_error_dump_txcmd { 152 __le32 cmdlen; 153 __le32 caplen; 154 u8 data[]; 155 } __packed; 156 157 /** 158 * struct iwl_fw_error_dump_fifo - RX/TX FIFO data 159 * @fifo_num: number of FIFO (starting from 0) 160 * @available_bytes: num of bytes available in FIFO (may be less than FIFO size) 161 * @wr_ptr: position of write pointer 162 * @rd_ptr: position of read pointer 163 * @fence_ptr: position of fence pointer 164 * @fence_mode: the current mode of the fence (before locking) - 165 * 0=follow RD pointer ; 1 = freeze 166 * @data: all of the FIFO's data 167 */ 168 struct iwl_fw_error_dump_fifo { 169 __le32 fifo_num; 170 __le32 available_bytes; 171 __le32 wr_ptr; 172 __le32 rd_ptr; 173 __le32 fence_ptr; 174 __le32 fence_mode; 175 u8 data[]; 176 } __packed; 177 178 enum iwl_fw_error_dump_family { 179 IWL_FW_ERROR_DUMP_FAMILY_7 = 7, 180 IWL_FW_ERROR_DUMP_FAMILY_8 = 8, 181 }; 182 183 #define MAX_NUM_LMAC 2 184 185 /** 186 * struct iwl_fw_error_dump_info - info on the device / firmware 187 * @device_family: the family of the device (7 / 8) 188 * @hw_step: the step of the device 189 * @fw_human_readable: human readable FW version 190 * @dev_human_readable: name of the device 191 * @bus_human_readable: name of the bus used 192 * @num_of_lmacs: the number of lmacs 193 * @lmac_err_id: the lmac 0/1 error_id/rt_status that triggered the latest dump 194 * if the dump collection was not initiated by an assert, the value is 0 195 * @umac_err_id: the umac 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 */ 198 struct iwl_fw_error_dump_info { 199 __le32 device_family; 200 __le32 hw_step; 201 u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ]; 202 u8 dev_human_readable[64]; 203 u8 bus_human_readable[8]; 204 u8 num_of_lmacs; 205 __le32 umac_err_id; 206 __le32 lmac_err_id[MAX_NUM_LMAC]; 207 } __packed; 208 209 /** 210 * struct iwl_fw_error_dump_fw_mon - FW monitor data 211 * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer 212 * @fw_mon_base_ptr: base pointer of the data 213 * @fw_mon_cycle_cnt: number of wraparounds 214 * @reserved: for future use 215 * @data: captured data 216 */ 217 struct iwl_fw_error_dump_fw_mon { 218 __le32 fw_mon_wr_ptr; 219 __le32 fw_mon_base_ptr; 220 __le32 fw_mon_cycle_cnt; 221 __le32 reserved[3]; 222 u8 data[]; 223 } __packed; 224 225 #define MAX_NUM_LMAC 2 226 #define TX_FIFO_INTERNAL_MAX_NUM 6 227 #define TX_FIFO_MAX_NUM 15 228 /** 229 * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration 230 * This must follow &struct iwl_fwrt_shared_mem_cfg. 231 * @num_lmacs: number of lmacs 232 * @num_txfifo_entries: number of tx fifos 233 * @lmac: sizes of lmacs txfifos and rxfifo1 234 * @rxfifo2_size: size of rxfifo2 235 * @internal_txfifo_addr: address of internal tx fifo 236 * @internal_txfifo_size: size of internal tx fifo 237 */ 238 struct iwl_fw_error_dump_smem_cfg { 239 __le32 num_lmacs; 240 __le32 num_txfifo_entries; 241 struct { 242 __le32 txfifo_size[TX_FIFO_MAX_NUM]; 243 __le32 rxfifo1_size; 244 } lmac[MAX_NUM_LMAC]; 245 __le32 rxfifo2_size; 246 __le32 internal_txfifo_addr; 247 __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM]; 248 } __packed; 249 /** 250 * struct iwl_fw_error_dump_prph - periphery registers data 251 * @prph_start: address of the first register in this chunk 252 * @data: the content of the registers 253 */ 254 struct iwl_fw_error_dump_prph { 255 __le32 prph_start; 256 __le32 data[]; 257 }; 258 259 enum iwl_fw_error_dump_mem_type { 260 IWL_FW_ERROR_DUMP_MEM_SRAM, 261 IWL_FW_ERROR_DUMP_MEM_SMEM, 262 IWL_FW_ERROR_DUMP_MEM_NAMED_MEM = 10, 263 }; 264 265 /** 266 * struct iwl_fw_error_dump_mem - chunk of memory 267 * @type: &enum iwl_fw_error_dump_mem_type 268 * @offset: the offset from which the memory was read 269 * @data: the content of the memory 270 */ 271 struct iwl_fw_error_dump_mem { 272 __le32 type; 273 __le32 offset; 274 u8 data[]; 275 }; 276 277 /** 278 * struct iwl_fw_ini_error_dump_range - range of memory 279 * @start_addr: the start address of this range 280 * @range_data_size: the size of this range, in bytes 281 * @data: the actual memory 282 */ 283 struct iwl_fw_ini_error_dump_range { 284 __le32 start_addr; 285 __le32 range_data_size; 286 __le32 data[]; 287 } __packed; 288 289 /** 290 * struct iwl_fw_ini_error_dump_header - ini region dump header 291 * @num_of_ranges: number of ranges in this region 292 * @name_len: number of bytes allocated to the name string of this region 293 * @name: name of the region 294 */ 295 struct iwl_fw_ini_error_dump_header { 296 __le32 num_of_ranges; 297 __le32 name_len; 298 u8 name[IWL_FW_INI_MAX_NAME]; 299 }; 300 301 /** 302 * struct iwl_fw_ini_error_dump - ini region dump 303 * @header: the header of this region 304 * @ranges: the memory ranges of this region 305 */ 306 struct iwl_fw_ini_error_dump { 307 struct iwl_fw_ini_error_dump_header header; 308 struct iwl_fw_ini_error_dump_range ranges[]; 309 } __packed; 310 311 /* This bit is used to differentiate between lmac and umac rxf */ 312 #define IWL_RXF_UMAC_BIT BIT(31) 313 314 /** 315 * struct iwl_fw_ini_fifo_error_dump_range - ini fifo range dump 316 * @fifo_num: the fifo num. In case of rxf and umac rxf, set BIT(31) to 317 * distinguish between lmac and umac 318 * @num_of_registers: num of registers to dump, dword size each 319 * @range_data_size: the size of the registers and fifo data 320 * @data: fifo data 321 */ 322 struct iwl_fw_ini_fifo_error_dump_range { 323 __le32 fifo_num; 324 __le32 num_of_registers; 325 __le32 range_data_size; 326 __le32 data[]; 327 } __packed; 328 329 /** 330 * struct iwl_fw_ini_fifo_error_dump - ini fifo region dump 331 * @header: the header of this region 332 * @ranges: the memory ranges of this region 333 */ 334 struct iwl_fw_ini_fifo_error_dump { 335 struct iwl_fw_ini_error_dump_header header; 336 struct iwl_fw_ini_fifo_error_dump_range ranges[]; 337 } __packed; 338 339 /** 340 * struct iwl_fw_error_dump_rb - content of an Receive Buffer 341 * @index: the index of the Receive Buffer in the Rx queue 342 * @rxq: the RB's Rx queue 343 * @reserved: 344 * @data: the content of the Receive Buffer 345 */ 346 struct iwl_fw_error_dump_rb { 347 __le32 index; 348 __le32 rxq; 349 __le32 reserved; 350 u8 data[]; 351 }; 352 353 /** 354 * struct iwl_fw_ini_monitor_dram_dump - ini dram monitor dump 355 * @header - header of the region 356 * @write_ptr - write pointer position in the dram 357 * @cycle_cnt - cycles count 358 * @ranges - the memory ranges of this this region 359 */ 360 struct iwl_fw_ini_monitor_dram_dump { 361 struct iwl_fw_ini_error_dump_header header; 362 __le32 write_ptr; 363 __le32 cycle_cnt; 364 struct iwl_fw_ini_error_dump_range ranges[]; 365 } __packed; 366 367 /** 368 * struct iwl_fw_error_dump_paging - content of the UMAC's image page 369 * block on DRAM 370 * @index: the index of the page block 371 * @reserved: 372 * @data: the content of the page block 373 */ 374 struct iwl_fw_error_dump_paging { 375 __le32 index; 376 __le32 reserved; 377 u8 data[]; 378 }; 379 380 /** 381 * iwl_fw_error_next_data - advance fw error dump data pointer 382 * @data: previous data block 383 * Returns: next data block 384 */ 385 static inline struct iwl_fw_error_dump_data * 386 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data) 387 { 388 return (void *)(data->data + le32_to_cpu(data->len)); 389 } 390 391 /** 392 * enum iwl_fw_dbg_trigger - triggers available 393 * 394 * @FW_DBG_TRIGGER_USER: trigger log collection by user 395 * This should not be defined as a trigger to the driver, but a value the 396 * driver should set to indicate that the trigger was initiated by the 397 * user. 398 * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts 399 * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are 400 * missed. 401 * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch. 402 * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a 403 * command response or a notification. 404 * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event. 405 * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold. 406 * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon 407 * goes below a threshold. 408 * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang 409 * detection. 410 * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related 411 * events. 412 * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events. 413 * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a 414 * threshold. 415 * @FW_DBG_TDLS: trigger log collection upon TDLS related events. 416 * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when 417 * the firmware sends a tx reply. 418 * @FW_DBG_TRIGGER_ALIVE_TIMEOUT: trigger log collection if alive flow timeouts 419 * @FW_DBG_TRIGGER_DRIVER: trigger log collection upon a flow failure 420 * in the driver. 421 */ 422 enum iwl_fw_dbg_trigger { 423 FW_DBG_TRIGGER_INVALID = 0, 424 FW_DBG_TRIGGER_USER, 425 FW_DBG_TRIGGER_FW_ASSERT, 426 FW_DBG_TRIGGER_MISSED_BEACONS, 427 FW_DBG_TRIGGER_CHANNEL_SWITCH, 428 FW_DBG_TRIGGER_FW_NOTIF, 429 FW_DBG_TRIGGER_MLME, 430 FW_DBG_TRIGGER_STATS, 431 FW_DBG_TRIGGER_RSSI, 432 FW_DBG_TRIGGER_TXQ_TIMERS, 433 FW_DBG_TRIGGER_TIME_EVENT, 434 FW_DBG_TRIGGER_BA, 435 FW_DBG_TRIGGER_TX_LATENCY, 436 FW_DBG_TRIGGER_TDLS, 437 FW_DBG_TRIGGER_TX_STATUS, 438 FW_DBG_TRIGGER_ALIVE_TIMEOUT, 439 FW_DBG_TRIGGER_DRIVER, 440 441 /* must be last */ 442 FW_DBG_TRIGGER_MAX, 443 }; 444 445 /** 446 * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition 447 * @type: &enum iwl_fw_dbg_trigger 448 * @data: raw data about what happened 449 */ 450 struct iwl_fw_error_dump_trigger_desc { 451 __le32 type; 452 u8 data[]; 453 }; 454 455 #endif /* __fw_error_dump_h__ */ 456