error-dump.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of version 2 of the GNU General Public License as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  24. * USA
  25. *
  26. * The full GNU General Public License is included in this distribution
  27. * in the file called COPYING.
  28. *
  29. * Contact Information:
  30. * Intel Linux Wireless <linuxwifi@intel.com>
  31. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  32. *
  33. * BSD LICENSE
  34. *
  35. * Copyright(c) 2014 Intel Corporation. All rights reserved.
  36. * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
  37. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  38. * All rights reserved.
  39. *
  40. * Redistribution and use in source and binary forms, with or without
  41. * modification, are permitted provided that the following conditions
  42. * are met:
  43. *
  44. * * Redistributions of source code must retain the above copyright
  45. * notice, this list of conditions and the following disclaimer.
  46. * * Redistributions in binary form must reproduce the above copyright
  47. * notice, this list of conditions and the following disclaimer in
  48. * the documentation and/or other materials provided with the
  49. * distribution.
  50. * * Neither the name Intel Corporation nor the names of its
  51. * contributors may be used to endorse or promote products derived
  52. * from this software without specific prior written permission.
  53. *
  54. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  55. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  56. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  57. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  58. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  59. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  60. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  61. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  62. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  63. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  64. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  65. *****************************************************************************/
  66. #ifndef __fw_error_dump_h__
  67. #define __fw_error_dump_h__
  68. #include <linux/types.h>
  69. #define IWL_FW_ERROR_DUMP_BARKER 0x14789632
  70. /**
  71. * enum iwl_fw_error_dump_type - types of data in the dump file
  72. * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
  73. * @IWL_FW_ERROR_DUMP_RXF:
  74. * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
  75. * &struct iwl_fw_error_dump_txcmd packets
  76. * @IWL_FW_ERROR_DUMP_DEV_FW_INFO: struct %iwl_fw_error_dump_info
  77. * info on the device / firmware.
  78. * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
  79. * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
  80. * sections like this in a single file.
  81. * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
  82. * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
  83. * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump.
  84. * Structured as &struct iwl_fw_error_dump_trigger_desc.
  85. * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as
  86. * &struct iwl_fw_error_dump_rb
  87. * @IWL_FW_ERROR_PAGING: UMAC's image memory segments which were
  88. * paged to the DRAM.
  89. * @IWL_FW_ERROR_DUMP_RADIO_REG: Dump the radio registers.
  90. * @IWL_FW_ERROR_DUMP_EXTERNAL: used only by external code utilities, and
  91. * for that reason is not in use in any other place in the Linux Wi-Fi
  92. * stack.
  93. * @IWL_FW_ERROR_DUMP_MEM_CFG: the addresses and sizes of fifos in the smem,
  94. * which we get from the fw after ALIVE. The content is structured as
  95. * &struct iwl_fw_error_dump_smem_cfg.
  96. */
  97. enum iwl_fw_error_dump_type {
  98. /* 0 is deprecated */
  99. IWL_FW_ERROR_DUMP_CSR = 1,
  100. IWL_FW_ERROR_DUMP_RXF = 2,
  101. IWL_FW_ERROR_DUMP_TXCMD = 3,
  102. IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
  103. IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
  104. IWL_FW_ERROR_DUMP_PRPH = 6,
  105. IWL_FW_ERROR_DUMP_TXF = 7,
  106. IWL_FW_ERROR_DUMP_FH_REGS = 8,
  107. IWL_FW_ERROR_DUMP_MEM = 9,
  108. IWL_FW_ERROR_DUMP_ERROR_INFO = 10,
  109. IWL_FW_ERROR_DUMP_RB = 11,
  110. IWL_FW_ERROR_DUMP_PAGING = 12,
  111. IWL_FW_ERROR_DUMP_RADIO_REG = 13,
  112. IWL_FW_ERROR_DUMP_INTERNAL_TXF = 14,
  113. IWL_FW_ERROR_DUMP_EXTERNAL = 15, /* Do not move */
  114. IWL_FW_ERROR_DUMP_MEM_CFG = 16,
  115. IWL_FW_ERROR_DUMP_MAX,
  116. };
  117. /**
  118. * struct iwl_fw_error_dump_data - data for one type
  119. * @type: &enum iwl_fw_error_dump_type
  120. * @len: the length starting from %data
  121. * @data: the data itself
  122. */
  123. struct iwl_fw_error_dump_data {
  124. __le32 type;
  125. __le32 len;
  126. __u8 data[];
  127. } __packed;
  128. /**
  129. * struct iwl_fw_error_dump_file - the layout of the header of the file
  130. * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
  131. * @file_len: the length of all the file starting from %barker
  132. * @data: array of &struct iwl_fw_error_dump_data
  133. */
  134. struct iwl_fw_error_dump_file {
  135. __le32 barker;
  136. __le32 file_len;
  137. u8 data[0];
  138. } __packed;
  139. /**
  140. * struct iwl_fw_error_dump_txcmd - TX command data
  141. * @cmdlen: original length of command
  142. * @caplen: captured length of command (may be less)
  143. * @data: captured command data, @caplen bytes
  144. */
  145. struct iwl_fw_error_dump_txcmd {
  146. __le32 cmdlen;
  147. __le32 caplen;
  148. u8 data[];
  149. } __packed;
  150. /**
  151. * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
  152. * @fifo_num: number of FIFO (starting from 0)
  153. * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
  154. * @wr_ptr: position of write pointer
  155. * @rd_ptr: position of read pointer
  156. * @fence_ptr: position of fence pointer
  157. * @fence_mode: the current mode of the fence (before locking) -
  158. * 0=follow RD pointer ; 1 = freeze
  159. * @data: all of the FIFO's data
  160. */
  161. struct iwl_fw_error_dump_fifo {
  162. __le32 fifo_num;
  163. __le32 available_bytes;
  164. __le32 wr_ptr;
  165. __le32 rd_ptr;
  166. __le32 fence_ptr;
  167. __le32 fence_mode;
  168. u8 data[];
  169. } __packed;
  170. enum iwl_fw_error_dump_family {
  171. IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
  172. IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
  173. };
  174. /**
  175. * struct iwl_fw_error_dump_info - info on the device / firmware
  176. * @device_family: the family of the device (7 / 8)
  177. * @hw_step: the step of the device
  178. * @fw_human_readable: human readable FW version
  179. * @dev_human_readable: name of the device
  180. * @bus_human_readable: name of the bus used
  181. */
  182. struct iwl_fw_error_dump_info {
  183. __le32 device_family;
  184. __le32 hw_step;
  185. u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
  186. u8 dev_human_readable[64];
  187. u8 bus_human_readable[8];
  188. } __packed;
  189. /**
  190. * struct iwl_fw_error_dump_fw_mon - FW monitor data
  191. * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
  192. * @fw_mon_base_ptr: base pointer of the data
  193. * @fw_mon_cycle_cnt: number of wraparounds
  194. * @reserved: for future use
  195. * @data: captured data
  196. */
  197. struct iwl_fw_error_dump_fw_mon {
  198. __le32 fw_mon_wr_ptr;
  199. __le32 fw_mon_base_ptr;
  200. __le32 fw_mon_cycle_cnt;
  201. __le32 reserved[3];
  202. u8 data[];
  203. } __packed;
  204. #define MAX_NUM_LMAC 2
  205. #define TX_FIFO_INTERNAL_MAX_NUM 6
  206. #define TX_FIFO_MAX_NUM 15
  207. /**
  208. * struct iwl_fw_error_dump_smem_cfg - Dump SMEM configuration
  209. * This must follow &struct iwl_fwrt_shared_mem_cfg.
  210. * @num_lmacs: number of lmacs
  211. * @num_txfifo_entries: number of tx fifos
  212. * @lmac: sizes of lmacs txfifos and rxfifo1
  213. * @rxfifo2_size: size of rxfifo2
  214. * @internal_txfifo_addr: address of internal tx fifo
  215. * @internal_txfifo_size: size of internal tx fifo
  216. */
  217. struct iwl_fw_error_dump_smem_cfg {
  218. __le32 num_lmacs;
  219. __le32 num_txfifo_entries;
  220. struct {
  221. __le32 txfifo_size[TX_FIFO_MAX_NUM];
  222. __le32 rxfifo1_size;
  223. } lmac[MAX_NUM_LMAC];
  224. __le32 rxfifo2_size;
  225. __le32 internal_txfifo_addr;
  226. __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
  227. } __packed;
  228. /**
  229. * struct iwl_fw_error_dump_prph - periphery registers data
  230. * @prph_start: address of the first register in this chunk
  231. * @data: the content of the registers
  232. */
  233. struct iwl_fw_error_dump_prph {
  234. __le32 prph_start;
  235. __le32 data[];
  236. };
  237. enum iwl_fw_error_dump_mem_type {
  238. IWL_FW_ERROR_DUMP_MEM_SRAM,
  239. IWL_FW_ERROR_DUMP_MEM_SMEM,
  240. };
  241. /**
  242. * struct iwl_fw_error_dump_mem - chunk of memory
  243. * @type: &enum iwl_fw_error_dump_mem_type
  244. * @offset: the offset from which the memory was read
  245. * @data: the content of the memory
  246. */
  247. struct iwl_fw_error_dump_mem {
  248. __le32 type;
  249. __le32 offset;
  250. u8 data[];
  251. };
  252. /**
  253. * struct iwl_fw_error_dump_rb - content of an Receive Buffer
  254. * @index: the index of the Receive Buffer in the Rx queue
  255. * @rxq: the RB's Rx queue
  256. * @reserved:
  257. * @data: the content of the Receive Buffer
  258. */
  259. struct iwl_fw_error_dump_rb {
  260. __le32 index;
  261. __le32 rxq;
  262. __le32 reserved;
  263. u8 data[];
  264. };
  265. /**
  266. * struct iwl_fw_error_dump_paging - content of the UMAC's image page
  267. * block on DRAM
  268. * @index: the index of the page block
  269. * @reserved:
  270. * @data: the content of the page block
  271. */
  272. struct iwl_fw_error_dump_paging {
  273. __le32 index;
  274. __le32 reserved;
  275. u8 data[];
  276. };
  277. /**
  278. * iwl_fw_error_next_data - advance fw error dump data pointer
  279. * @data: previous data block
  280. * Returns: next data block
  281. */
  282. static inline struct iwl_fw_error_dump_data *
  283. iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
  284. {
  285. return (void *)(data->data + le32_to_cpu(data->len));
  286. }
  287. /**
  288. * enum iwl_fw_dbg_trigger - triggers available
  289. *
  290. * @FW_DBG_TRIGGER_USER: trigger log collection by user
  291. * This should not be defined as a trigger to the driver, but a value the
  292. * driver should set to indicate that the trigger was initiated by the
  293. * user.
  294. * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
  295. * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
  296. * missed.
  297. * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
  298. * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
  299. * command response or a notification.
  300. * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
  301. * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
  302. * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
  303. * goes below a threshold.
  304. * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
  305. * detection.
  306. * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
  307. * events.
  308. * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
  309. * @FW_DBG_TX_LATENCY: trigger log collection when the tx latency goes above a
  310. * threshold.
  311. * @FW_DBG_TDLS: trigger log collection upon TDLS related events.
  312. * @FW_DBG_TRIGGER_TX_STATUS: trigger log collection upon tx status when
  313. * the firmware sends a tx reply.
  314. */
  315. enum iwl_fw_dbg_trigger {
  316. FW_DBG_TRIGGER_INVALID = 0,
  317. FW_DBG_TRIGGER_USER,
  318. FW_DBG_TRIGGER_FW_ASSERT,
  319. FW_DBG_TRIGGER_MISSED_BEACONS,
  320. FW_DBG_TRIGGER_CHANNEL_SWITCH,
  321. FW_DBG_TRIGGER_FW_NOTIF,
  322. FW_DBG_TRIGGER_MLME,
  323. FW_DBG_TRIGGER_STATS,
  324. FW_DBG_TRIGGER_RSSI,
  325. FW_DBG_TRIGGER_TXQ_TIMERS,
  326. FW_DBG_TRIGGER_TIME_EVENT,
  327. FW_DBG_TRIGGER_BA,
  328. FW_DBG_TRIGGER_TX_LATENCY,
  329. FW_DBG_TRIGGER_TDLS,
  330. FW_DBG_TRIGGER_TX_STATUS,
  331. /* must be last */
  332. FW_DBG_TRIGGER_MAX,
  333. };
  334. /**
  335. * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
  336. * @type: &enum iwl_fw_dbg_trigger
  337. * @data: raw data about what happened
  338. */
  339. struct iwl_fw_error_dump_trigger_desc {
  340. __le32 type;
  341. u8 data[];
  342. };
  343. #endif /* __fw_error_dump_h__ */