iwl-fw-error-dump.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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 Intel Mobile Communications GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  23. * USA
  24. *
  25. * The full GNU General Public License is included in this distribution
  26. * in the file called COPYING.
  27. *
  28. * Contact Information:
  29. * Intel Linux Wireless <ilw@linux.intel.com>
  30. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  31. *
  32. * BSD LICENSE
  33. *
  34. * Copyright(c) 2014 Intel Corporation. All rights reserved.
  35. * Copyright(c) 2014 Intel Mobile Communications GmbH
  36. * All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. *
  42. * * Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * * Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in
  46. * the documentation and/or other materials provided with the
  47. * distribution.
  48. * * Neither the name Intel Corporation nor the names of its
  49. * contributors may be used to endorse or promote products derived
  50. * from this software without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  53. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  54. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  55. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  56. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  57. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  58. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  59. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  60. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  61. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  62. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63. *****************************************************************************/
  64. #ifndef __fw_error_dump_h__
  65. #define __fw_error_dump_h__
  66. #include <linux/types.h>
  67. #define IWL_FW_ERROR_DUMP_BARKER 0x14789632
  68. /**
  69. * enum iwl_fw_error_dump_type - types of data in the dump file
  70. * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
  71. * @IWL_FW_ERROR_DUMP_RXF:
  72. * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
  73. * &struct iwl_fw_error_dump_txcmd packets
  74. * @IWL_FW_ERROR_DUMP_DEV_FW_INFO: struct %iwl_fw_error_dump_info
  75. * info on the device / firmware.
  76. * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
  77. * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
  78. * sections like this in a single file.
  79. * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
  80. * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
  81. */
  82. enum iwl_fw_error_dump_type {
  83. /* 0 is deprecated */
  84. IWL_FW_ERROR_DUMP_CSR = 1,
  85. IWL_FW_ERROR_DUMP_RXF = 2,
  86. IWL_FW_ERROR_DUMP_TXCMD = 3,
  87. IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
  88. IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
  89. IWL_FW_ERROR_DUMP_PRPH = 6,
  90. IWL_FW_ERROR_DUMP_TXF = 7,
  91. IWL_FW_ERROR_DUMP_FH_REGS = 8,
  92. IWL_FW_ERROR_DUMP_MEM = 9,
  93. IWL_FW_ERROR_DUMP_MAX,
  94. };
  95. /**
  96. * struct iwl_fw_error_dump_data - data for one type
  97. * @type: %enum iwl_fw_error_dump_type
  98. * @len: the length starting from %data
  99. * @data: the data itself
  100. */
  101. struct iwl_fw_error_dump_data {
  102. __le32 type;
  103. __le32 len;
  104. __u8 data[];
  105. } __packed;
  106. /**
  107. * struct iwl_fw_error_dump_file - the layout of the header of the file
  108. * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
  109. * @file_len: the length of all the file starting from %barker
  110. * @data: array of %struct iwl_fw_error_dump_data
  111. */
  112. struct iwl_fw_error_dump_file {
  113. __le32 barker;
  114. __le32 file_len;
  115. u8 data[0];
  116. } __packed;
  117. /**
  118. * struct iwl_fw_error_dump_txcmd - TX command data
  119. * @cmdlen: original length of command
  120. * @caplen: captured length of command (may be less)
  121. * @data: captured command data, @caplen bytes
  122. */
  123. struct iwl_fw_error_dump_txcmd {
  124. __le32 cmdlen;
  125. __le32 caplen;
  126. u8 data[];
  127. } __packed;
  128. /**
  129. * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
  130. * @fifo_num: number of FIFO (starting from 0)
  131. * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
  132. * @wr_ptr: position of write pointer
  133. * @rd_ptr: position of read pointer
  134. * @fence_ptr: position of fence pointer
  135. * @fence_mode: the current mode of the fence (before locking) -
  136. * 0=follow RD pointer ; 1 = freeze
  137. * @data: all of the FIFO's data
  138. */
  139. struct iwl_fw_error_dump_fifo {
  140. __le32 fifo_num;
  141. __le32 available_bytes;
  142. __le32 wr_ptr;
  143. __le32 rd_ptr;
  144. __le32 fence_ptr;
  145. __le32 fence_mode;
  146. u8 data[];
  147. } __packed;
  148. enum iwl_fw_error_dump_family {
  149. IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
  150. IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
  151. };
  152. /**
  153. * struct iwl_fw_error_dump_info - info on the device / firmware
  154. * @device_family: the family of the device (7 / 8)
  155. * @hw_step: the step of the device
  156. * @fw_human_readable: human readable FW version
  157. * @dev_human_readable: name of the device
  158. * @bus_human_readable: name of the bus used
  159. */
  160. struct iwl_fw_error_dump_info {
  161. __le32 device_family;
  162. __le32 hw_step;
  163. u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
  164. u8 dev_human_readable[64];
  165. u8 bus_human_readable[8];
  166. } __packed;
  167. /**
  168. * struct iwl_fw_error_dump_fw_mon - FW monitor data
  169. * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
  170. * @fw_mon_base_ptr: base pointer of the data
  171. * @fw_mon_cycle_cnt: number of wrap arounds
  172. * @reserved: for future use
  173. * @data: captured data
  174. */
  175. struct iwl_fw_error_dump_fw_mon {
  176. __le32 fw_mon_wr_ptr;
  177. __le32 fw_mon_base_ptr;
  178. __le32 fw_mon_cycle_cnt;
  179. __le32 reserved[3];
  180. u8 data[];
  181. } __packed;
  182. /**
  183. * struct iwl_fw_error_dump_prph - periphery registers data
  184. * @prph_start: address of the first register in this chunk
  185. * @data: the content of the registers
  186. */
  187. struct iwl_fw_error_dump_prph {
  188. __le32 prph_start;
  189. __le32 data[];
  190. };
  191. enum iwl_fw_error_dump_mem_type {
  192. IWL_FW_ERROR_DUMP_MEM_SRAM,
  193. IWL_FW_ERROR_DUMP_MEM_SMEM,
  194. };
  195. /**
  196. * struct iwl_fw_error_dump_mem - chunk of memory
  197. * @type: %enum iwl_fw_error_dump_mem_type
  198. * @offset: the offset from which the memory was read
  199. * @data: the content of the memory
  200. */
  201. struct iwl_fw_error_dump_mem {
  202. __le32 type;
  203. __le32 offset;
  204. u8 data[];
  205. };
  206. /**
  207. * iwl_fw_error_next_data - advance fw error dump data pointer
  208. * @data: previous data block
  209. * Returns: next data block
  210. */
  211. static inline struct iwl_fw_error_dump_data *
  212. iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
  213. {
  214. return (void *)(data->data + le32_to_cpu(data->len));
  215. }
  216. #endif /* __fw_error_dump_h__ */