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 /** 184 * struct iwl_fw_error_dump_info - info on the device / firmware 185 * @device_family: the family of the device (7 / 8) 186 * @hw_step: the step of the device 187 * @fw_human_readable: human readable FW version 188 * @dev_human_readable: name of the device 189 * @bus_human_readable: name of the bus used 190 */ 191 struct iwl_fw_error_dump_info { 192 __le32 device_family; 193 __le32 hw_step; 194 u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ]; 195 u8 dev_human_readable[64]; 196 u8 bus_human_readable[8]; 197 } __packed; 198 199 /** 200 * struct iwl_fw_error_dump_fw_mon - FW monitor data 201 * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer 202 * @fw_mon_base_ptr: base pointer of the data 203 * @fw_mon_cycle_cnt: number of wraparounds 204 * @reserved: for future use 205 * @data: captured data 206 */ 207 struct iwl_fw_error_dump_fw_mon { 208 __le32 fw_mon_wr_ptr; 209 __le32 fw_mon_base_ptr; 210 __le32 fw_mon_cycle_cnt; 211 __le32 reserved[3]; 212 u8 data[]; 213 } __packed; 214 215 #define MAX_NUM_LMAC 2 216 #define TX_FIFO_INTERNAL_MAX_NUM 6 217 #define TX_FIFO_MAX_NUM 15 218 /** 219 * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration 220 * This must follow &struct iwl_fwrt_shared_mem_cfg. 221 * @num_lmacs: number of lmacs 222 * @num_txfifo_entries: number of tx fifos 223 * @lmac: sizes of lmacs txfifos and rxfifo1 224 * @rxfifo2_size: size of rxfifo2 225 * @internal_txfifo_addr: address of internal tx fifo 226 * @internal_txfifo_size: size of internal tx fifo 227 */ 228 struct iwl_fw_error_dump_smem_cfg { 229 __le32 num_lmacs; 230 __le32 num_txfifo_entries; 231 struct { 232 __le32 txfifo_size[TX_FIFO_MAX_NUM]; 233 __le32 rxfifo1_size; 234 } lmac[MAX_NUM_LMAC]; 235 __le32 rxfifo2_size; 236 __le32 internal_txfifo_addr; 237 __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM]; 238 } __packed; 239 /** 240 * struct iwl_fw_error_dump_prph - periphery registers data 241 * @prph_start: address of the first register in this chunk 242 * @data: the content of the registers 243 */ 244 struct iwl_fw_error_dump_prph { 245 __le32 prph_start; 246 __le32 data[]; 247 }; 248 249 enum iwl_fw_error_dump_mem_type { 250 IWL_FW_ERROR_DUMP_MEM_SRAM, 251 IWL_FW_ERROR_DUMP_MEM_SMEM, 252 }; 253 254 /** 255 * struct iwl_fw_error_dump_mem - chunk of memory 256 * @type: &enum iwl_fw_error_dump_mem_type 257 * @offset: the offset from which the memory was read 258 * @data: the content of the memory 259 */ 260 struct iwl_fw_error_dump_mem { 261 __le32 type; 262 __le32 offset; 263 u8 data[]; 264 }; 265 266 /** 267 * struct iwl_fw_error_dump_rb - content of an Receive Buffer 268 * @index: the index of the Receive Buffer in the Rx queue 269 * @rxq: the RB's Rx queue 270 * @reserved: 271 * @data: the content of the Receive Buffer 272 */ 273 struct iwl_fw_error_dump_rb { 274 __le32 index; 275 __le32 rxq; 276 __le32 reserved; 277 u8 data[]; 278 }; 279 280 /** 281 * struct iwl_fw_error_dump_paging - content of the UMAC's image page 282 * block on DRAM 283 * @index: the index of the page block 284 * @reserved: 285 * @data: the content of the page block 286 */ 287 struct iwl_fw_error_dump_paging { 288 __le32 index; 289 __le32 reserved; 290 u8 data[]; 291 }; 292 293 /** 294 * iwl_fw_error_next_data - advance fw error dump data pointer 295 * @data: previous data block 296 * Returns: next data block 297 */ 298 static inline struct iwl_fw_error_dump_data * 299 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data) 300 { 301 return (void *)(data->data + le32_to_cpu(data->len)); 302 } 303 304 /** 305 * enum iwl_fw_dbg_trigger - triggers available 306 * 307 * @FW_DBG_TRIGGER_USER: trigger log collection by user 308 * This should not be defined as a trigger to the driver, but a value the 309 * driver should set to indicate that the trigger was initiated by the 310 * user. 311 * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts 312 * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are 313 * missed. 314 * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch. 315 * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a 316 * command response or a notification. 317 * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event. 318 * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold. 319 * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon 320 * goes below a threshold. 321 * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang 322 * detection. 323 * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related 324 * events. 325 * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events. 326 * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a 327 * threshold. 328 * @FW_DBG_TDLS: trigger log collection upon TDLS related events. 329 * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when 330 * the firmware sends a tx reply. 331 * @FW_DBG_TRIGGER_NO_ALIVE: trigger log collection if alive flow fails 332 */ 333 enum iwl_fw_dbg_trigger { 334 FW_DBG_TRIGGER_INVALID = 0, 335 FW_DBG_TRIGGER_USER, 336 FW_DBG_TRIGGER_FW_ASSERT, 337 FW_DBG_TRIGGER_MISSED_BEACONS, 338 FW_DBG_TRIGGER_CHANNEL_SWITCH, 339 FW_DBG_TRIGGER_FW_NOTIF, 340 FW_DBG_TRIGGER_MLME, 341 FW_DBG_TRIGGER_STATS, 342 FW_DBG_TRIGGER_RSSI, 343 FW_DBG_TRIGGER_TXQ_TIMERS, 344 FW_DBG_TRIGGER_TIME_EVENT, 345 FW_DBG_TRIGGER_BA, 346 FW_DBG_TRIGGER_TX_LATENCY, 347 FW_DBG_TRIGGER_TDLS, 348 FW_DBG_TRIGGER_TX_STATUS, 349 FW_DBG_TRIGGER_NO_ALIVE, 350 351 /* must be last */ 352 FW_DBG_TRIGGER_MAX, 353 }; 354 355 /** 356 * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition 357 * @type: &enum iwl_fw_dbg_trigger 358 * @data: raw data about what happened 359 */ 360 struct iwl_fw_error_dump_trigger_desc { 361 __le32 type; 362 u8 data[]; 363 }; 364 365 #endif /* __fw_error_dump_h__ */ 366