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 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 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_error_dump_named_mem - chunk of memory 279 * @type: &enum iwl_fw_error_dump_mem_type 280 * @offset: the offset from which the memory was read 281 * @name_len: name length 282 * @name: file name 283 * @data: the content of the memory 284 */ 285 struct iwl_fw_error_dump_named_mem { 286 __le32 type; 287 __le32 offset; 288 u8 name_len; 289 u8 name[32]; 290 u8 data[]; 291 }; 292 293 /** 294 * struct iwl_fw_error_dump_rb - content of an Receive Buffer 295 * @index: the index of the Receive Buffer in the Rx queue 296 * @rxq: the RB's Rx queue 297 * @reserved: 298 * @data: the content of the Receive Buffer 299 */ 300 struct iwl_fw_error_dump_rb { 301 __le32 index; 302 __le32 rxq; 303 __le32 reserved; 304 u8 data[]; 305 }; 306 307 /** 308 * struct iwl_fw_error_dump_paging - content of the UMAC's image page 309 * block on DRAM 310 * @index: the index of the page block 311 * @reserved: 312 * @data: the content of the page block 313 */ 314 struct iwl_fw_error_dump_paging { 315 __le32 index; 316 __le32 reserved; 317 u8 data[]; 318 }; 319 320 /** 321 * iwl_fw_error_next_data - advance fw error dump data pointer 322 * @data: previous data block 323 * Returns: next data block 324 */ 325 static inline struct iwl_fw_error_dump_data * 326 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data) 327 { 328 return (void *)(data->data + le32_to_cpu(data->len)); 329 } 330 331 /** 332 * enum iwl_fw_dbg_trigger - triggers available 333 * 334 * @FW_DBG_TRIGGER_USER: trigger log collection by user 335 * This should not be defined as a trigger to the driver, but a value the 336 * driver should set to indicate that the trigger was initiated by the 337 * user. 338 * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts 339 * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are 340 * missed. 341 * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch. 342 * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a 343 * command response or a notification. 344 * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event. 345 * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold. 346 * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon 347 * goes below a threshold. 348 * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang 349 * detection. 350 * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related 351 * events. 352 * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events. 353 * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a 354 * threshold. 355 * @FW_DBG_TDLS: trigger log collection upon TDLS related events. 356 * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when 357 * the firmware sends a tx reply. 358 * @FW_DBG_TRIGGER_NO_ALIVE: trigger log collection if alive flow fails 359 */ 360 enum iwl_fw_dbg_trigger { 361 FW_DBG_TRIGGER_INVALID = 0, 362 FW_DBG_TRIGGER_USER, 363 FW_DBG_TRIGGER_FW_ASSERT, 364 FW_DBG_TRIGGER_MISSED_BEACONS, 365 FW_DBG_TRIGGER_CHANNEL_SWITCH, 366 FW_DBG_TRIGGER_FW_NOTIF, 367 FW_DBG_TRIGGER_MLME, 368 FW_DBG_TRIGGER_STATS, 369 FW_DBG_TRIGGER_RSSI, 370 FW_DBG_TRIGGER_TXQ_TIMERS, 371 FW_DBG_TRIGGER_TIME_EVENT, 372 FW_DBG_TRIGGER_BA, 373 FW_DBG_TRIGGER_TX_LATENCY, 374 FW_DBG_TRIGGER_TDLS, 375 FW_DBG_TRIGGER_TX_STATUS, 376 FW_DBG_TRIGGER_NO_ALIVE, 377 378 /* must be last */ 379 FW_DBG_TRIGGER_MAX, 380 }; 381 382 /** 383 * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition 384 * @type: &enum iwl_fw_dbg_trigger 385 * @data: raw data about what happened 386 */ 387 struct iwl_fw_error_dump_trigger_desc { 388 __le32 type; 389 u8 data[]; 390 }; 391 392 #endif /* __fw_error_dump_h__ */ 393