debug.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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) 2007 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2013 - 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) 2005 - 2014 Intel Corporation. All rights reserved.
  32. * Copyright(c) 2013 - 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 __iwl_fw_api_debug_h__
  65. #define __iwl_fw_api_debug_h__
  66. /**
  67. * enum iwl_debug_cmds - debug commands
  68. */
  69. enum iwl_debug_cmds {
  70. /**
  71. * @LMAC_RD_WR:
  72. * LMAC memory read/write, using &struct iwl_dbg_mem_access_cmd and
  73. * &struct iwl_dbg_mem_access_rsp
  74. */
  75. LMAC_RD_WR = 0x0,
  76. /**
  77. * @UMAC_RD_WR:
  78. * UMAC memory read/write, using &struct iwl_dbg_mem_access_cmd and
  79. * &struct iwl_dbg_mem_access_rsp
  80. */
  81. UMAC_RD_WR = 0x1,
  82. /**
  83. * @MFU_ASSERT_DUMP_NTF:
  84. * &struct iwl_mfu_assert_dump_notif
  85. */
  86. MFU_ASSERT_DUMP_NTF = 0xFE,
  87. };
  88. /* Error response/notification */
  89. enum {
  90. FW_ERR_UNKNOWN_CMD = 0x0,
  91. FW_ERR_INVALID_CMD_PARAM = 0x1,
  92. FW_ERR_SERVICE = 0x2,
  93. FW_ERR_ARC_MEMORY = 0x3,
  94. FW_ERR_ARC_CODE = 0x4,
  95. FW_ERR_WATCH_DOG = 0x5,
  96. FW_ERR_WEP_GRP_KEY_INDX = 0x10,
  97. FW_ERR_WEP_KEY_SIZE = 0x11,
  98. FW_ERR_OBSOLETE_FUNC = 0x12,
  99. FW_ERR_UNEXPECTED = 0xFE,
  100. FW_ERR_FATAL = 0xFF
  101. };
  102. /**
  103. * struct iwl_error_resp - FW error indication
  104. * ( REPLY_ERROR = 0x2 )
  105. * @error_type: one of FW_ERR_*
  106. * @cmd_id: the command ID for which the error occurred
  107. * @reserved1: reserved
  108. * @bad_cmd_seq_num: sequence number of the erroneous command
  109. * @error_service: which service created the error, applicable only if
  110. * error_type = 2, otherwise 0
  111. * @timestamp: TSF in usecs.
  112. */
  113. struct iwl_error_resp {
  114. __le32 error_type;
  115. u8 cmd_id;
  116. u8 reserved1;
  117. __le16 bad_cmd_seq_num;
  118. __le32 error_service;
  119. __le64 timestamp;
  120. } __packed;
  121. #define TX_FIFO_MAX_NUM_9000 8
  122. #define TX_FIFO_MAX_NUM 15
  123. #define RX_FIFO_MAX_NUM 2
  124. #define TX_FIFO_INTERNAL_MAX_NUM 6
  125. /**
  126. * struct iwl_shared_mem_cfg_v2 - Shared memory configuration information
  127. *
  128. * @shared_mem_addr: shared memory addr (pre 8000 HW set to 0x0 as MARBH is not
  129. * accessible)
  130. * @shared_mem_size: shared memory size
  131. * @sample_buff_addr: internal sample (mon/adc) buff addr (pre 8000 HW set to
  132. * 0x0 as accessible only via DBGM RDAT)
  133. * @sample_buff_size: internal sample buff size
  134. * @txfifo_addr: start addr of TXF0 (excluding the context table 0.5KB), (pre
  135. * 8000 HW set to 0x0 as not accessible)
  136. * @txfifo_size: size of TXF0 ... TXF7
  137. * @rxfifo_size: RXF1, RXF2 sizes. If there is no RXF2, it'll have a value of 0
  138. * @page_buff_addr: used by UMAC and performance debug (page miss analysis),
  139. * when paging is not supported this should be 0
  140. * @page_buff_size: size of %page_buff_addr
  141. * @rxfifo_addr: Start address of rxFifo
  142. * @internal_txfifo_addr: start address of internalFifo
  143. * @internal_txfifo_size: internal fifos' size
  144. *
  145. * NOTE: on firmware that don't have IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG
  146. * set, the last 3 members don't exist.
  147. */
  148. struct iwl_shared_mem_cfg_v2 {
  149. __le32 shared_mem_addr;
  150. __le32 shared_mem_size;
  151. __le32 sample_buff_addr;
  152. __le32 sample_buff_size;
  153. __le32 txfifo_addr;
  154. __le32 txfifo_size[TX_FIFO_MAX_NUM_9000];
  155. __le32 rxfifo_size[RX_FIFO_MAX_NUM];
  156. __le32 page_buff_addr;
  157. __le32 page_buff_size;
  158. __le32 rxfifo_addr;
  159. __le32 internal_txfifo_addr;
  160. __le32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
  161. } __packed; /* SHARED_MEM_ALLOC_API_S_VER_2 */
  162. /**
  163. * struct iwl_shared_mem_lmac_cfg - LMAC shared memory configuration
  164. *
  165. * @txfifo_addr: start addr of TXF0 (excluding the context table 0.5KB)
  166. * @txfifo_size: size of TX FIFOs
  167. * @rxfifo1_addr: RXF1 addr
  168. * @rxfifo1_size: RXF1 size
  169. */
  170. struct iwl_shared_mem_lmac_cfg {
  171. __le32 txfifo_addr;
  172. __le32 txfifo_size[TX_FIFO_MAX_NUM];
  173. __le32 rxfifo1_addr;
  174. __le32 rxfifo1_size;
  175. } __packed; /* SHARED_MEM_ALLOC_LMAC_API_S_VER_1 */
  176. /**
  177. * struct iwl_shared_mem_cfg - Shared memory configuration information
  178. *
  179. * @shared_mem_addr: shared memory address
  180. * @shared_mem_size: shared memory size
  181. * @sample_buff_addr: internal sample (mon/adc) buff addr
  182. * @sample_buff_size: internal sample buff size
  183. * @rxfifo2_addr: start addr of RXF2
  184. * @rxfifo2_size: size of RXF2
  185. * @page_buff_addr: used by UMAC and performance debug (page miss analysis),
  186. * when paging is not supported this should be 0
  187. * @page_buff_size: size of %page_buff_addr
  188. * @lmac_num: number of LMACs (1 or 2)
  189. * @lmac_smem: per - LMAC smem data
  190. */
  191. struct iwl_shared_mem_cfg {
  192. __le32 shared_mem_addr;
  193. __le32 shared_mem_size;
  194. __le32 sample_buff_addr;
  195. __le32 sample_buff_size;
  196. __le32 rxfifo2_addr;
  197. __le32 rxfifo2_size;
  198. __le32 page_buff_addr;
  199. __le32 page_buff_size;
  200. __le32 lmac_num;
  201. struct iwl_shared_mem_lmac_cfg lmac_smem[2];
  202. } __packed; /* SHARED_MEM_ALLOC_API_S_VER_3 */
  203. /**
  204. * struct iwl_mfuart_load_notif - mfuart image version & status
  205. * ( MFUART_LOAD_NOTIFICATION = 0xb1 )
  206. * @installed_ver: installed image version
  207. * @external_ver: external image version
  208. * @status: MFUART loading status
  209. * @duration: MFUART loading time
  210. * @image_size: MFUART image size in bytes
  211. */
  212. struct iwl_mfuart_load_notif {
  213. __le32 installed_ver;
  214. __le32 external_ver;
  215. __le32 status;
  216. __le32 duration;
  217. /* image size valid only in v2 of the command */
  218. __le32 image_size;
  219. } __packed; /* MFU_LOADER_NTFY_API_S_VER_2 */
  220. /**
  221. * struct iwl_mfu_assert_dump_notif - mfuart dump logs
  222. * ( MFU_ASSERT_DUMP_NTF = 0xfe )
  223. * @assert_id: mfuart assert id that cause the notif
  224. * @curr_reset_num: number of asserts since uptime
  225. * @index_num: current chunk id
  226. * @parts_num: total number of chunks
  227. * @data_size: number of data bytes sent
  228. * @data: data buffer
  229. */
  230. struct iwl_mfu_assert_dump_notif {
  231. __le32 assert_id;
  232. __le32 curr_reset_num;
  233. __le16 index_num;
  234. __le16 parts_num;
  235. __le32 data_size;
  236. __le32 data[0];
  237. } __packed; /* MFU_DUMP_ASSERT_API_S_VER_1 */
  238. /**
  239. * enum iwl_mvm_marker_id - marker ids
  240. *
  241. * The ids for different type of markers to insert into the usniffer logs
  242. *
  243. * @MARKER_ID_TX_FRAME_LATENCY: TX latency marker
  244. * @MARKER_ID_SYNC_CLOCK: sync FW time and systime
  245. */
  246. enum iwl_mvm_marker_id {
  247. MARKER_ID_TX_FRAME_LATENCY = 1,
  248. MARKER_ID_SYNC_CLOCK = 2,
  249. }; /* MARKER_ID_API_E_VER_2 */
  250. /**
  251. * struct iwl_mvm_marker - mark info into the usniffer logs
  252. *
  253. * (MARKER_CMD = 0xcb)
  254. *
  255. * Mark the UTC time stamp into the usniffer logs together with additional
  256. * metadata, so the usniffer output can be parsed.
  257. * In the command response the ucode will return the GP2 time.
  258. *
  259. * @dw_len: The amount of dwords following this byte including this byte.
  260. * @marker_id: A unique marker id (iwl_mvm_marker_id).
  261. * @reserved: reserved.
  262. * @timestamp: in milliseconds since 1970-01-01 00:00:00 UTC
  263. * @metadata: additional meta data that will be written to the unsiffer log
  264. */
  265. struct iwl_mvm_marker {
  266. u8 dw_len;
  267. u8 marker_id;
  268. __le16 reserved;
  269. __le64 timestamp;
  270. __le32 metadata[0];
  271. } __packed; /* MARKER_API_S_VER_1 */
  272. /**
  273. * struct iwl_mvm_marker_rsp - Response to marker cmd
  274. *
  275. * @gp2: The gp2 clock value in the FW
  276. */
  277. struct iwl_mvm_marker_rsp {
  278. __le32 gp2;
  279. } __packed;
  280. /* Operation types for the debug mem access */
  281. enum {
  282. DEBUG_MEM_OP_READ = 0,
  283. DEBUG_MEM_OP_WRITE = 1,
  284. DEBUG_MEM_OP_WRITE_BYTES = 2,
  285. };
  286. #define DEBUG_MEM_MAX_SIZE_DWORDS 32
  287. /**
  288. * struct iwl_dbg_mem_access_cmd - Request the device to read/write memory
  289. * @op: DEBUG_MEM_OP_*
  290. * @addr: address to read/write from/to
  291. * @len: in dwords, to read/write
  292. * @data: for write opeations, contains the source buffer
  293. */
  294. struct iwl_dbg_mem_access_cmd {
  295. __le32 op;
  296. __le32 addr;
  297. __le32 len;
  298. __le32 data[];
  299. } __packed; /* DEBUG_(U|L)MAC_RD_WR_CMD_API_S_VER_1 */
  300. /* Status responses for the debug mem access */
  301. enum {
  302. DEBUG_MEM_STATUS_SUCCESS = 0x0,
  303. DEBUG_MEM_STATUS_FAILED = 0x1,
  304. DEBUG_MEM_STATUS_LOCKED = 0x2,
  305. DEBUG_MEM_STATUS_HIDDEN = 0x3,
  306. DEBUG_MEM_STATUS_LENGTH = 0x4,
  307. };
  308. /**
  309. * struct iwl_dbg_mem_access_rsp - Response to debug mem commands
  310. * @status: DEBUG_MEM_STATUS_*
  311. * @len: read dwords (0 for write operations)
  312. * @data: contains the read DWs
  313. */
  314. struct iwl_dbg_mem_access_rsp {
  315. __le32 status;
  316. __le32 len;
  317. __le32 data[];
  318. } __packed; /* DEBUG_(U|L)MAC_RD_WR_RSP_API_S_VER_1 */
  319. #define CONT_REC_COMMAND_SIZE 80
  320. #define ENABLE_CONT_RECORDING 0x15
  321. #define DISABLE_CONT_RECORDING 0x16
  322. #define BUFFER_ALLOCATION 0x27
  323. #define START_DEBUG_RECORDING 0x29
  324. #define STOP_DEBUG_RECORDING 0x2A
  325. /*
  326. * struct iwl_continuous_record_mode - recording mode
  327. */
  328. struct iwl_continuous_record_mode {
  329. __le16 enable_recording;
  330. } __packed;
  331. /*
  332. * struct iwl_continuous_record_cmd - enable/disable continuous recording
  333. */
  334. struct iwl_continuous_record_cmd {
  335. struct iwl_continuous_record_mode record_mode;
  336. u8 pad[CONT_REC_COMMAND_SIZE -
  337. sizeof(struct iwl_continuous_record_mode)];
  338. } __packed;
  339. /* maximum fragments to be allocated per target of allocationId */
  340. #define IWL_BUFFER_LOCATION_MAX_FRAGS 2
  341. /**
  342. * struct iwl_fragment_data single fragment structure
  343. * @address: 64bit start address
  344. * @size: size in bytes
  345. */
  346. struct iwl_fragment_data {
  347. __le64 address;
  348. __le32 size;
  349. } __packed; /* FRAGMENT_STRUCTURE_API_S_VER_1 */
  350. /**
  351. * struct iwl_buffer_allocation_cmd - buffer allocation command structure
  352. * @allocation_id: id of the allocation
  353. * @buffer_location: location of the buffer
  354. * @num_frags: number of fragments
  355. * @fragments: memory fragments
  356. */
  357. struct iwl_buffer_allocation_cmd {
  358. __le32 allocation_id;
  359. __le32 buffer_location;
  360. __le32 num_frags;
  361. struct iwl_fragment_data fragments[IWL_BUFFER_LOCATION_MAX_FRAGS];
  362. } __packed; /* BUFFER_ALLOCATION_CMD_API_S_VER_1 */
  363. #endif /* __iwl_fw_api_debug_h__ */