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) 2018 Intel Corporation
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of version 2 of the GNU General Public License as
12  * published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * The full GNU General Public License is included in this distribution
20  * in the file called COPYING.
21  *
22  * Contact Information:
23  *  Intel Linux Wireless <linuxwifi@intel.com>
24  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25  *
26  * BSD LICENSE
27  *
28  * Copyright (C) 2018 Intel Corporation
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions
33  * are met:
34  *
35  *  * Redistributions of source code must retain the above copyright
36  *    notice, this list of conditions and the following disclaimer.
37  *  * Redistributions in binary form must reproduce the above copyright
38  *    notice, this list of conditions and the following disclaimer in
39  *    the documentation and/or other materials provided with the
40  *    distribution.
41  *  * Neither the name Intel Corporation nor the names of its
42  *    contributors may be used to endorse or promote products derived
43  *    from this software without specific prior written permission.
44  *
45  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56  *
57  *****************************************************************************/
58 #ifndef __iwl_fw_dbg_tlv_h__
59 #define __iwl_fw_dbg_tlv_h__
60 
61 #include <linux/bitops.h>
62 
63 /*
64  * struct iwl_fw_ini_header: Common Header for all debug group TLV's structures
65  * @tlv_version: version info
66  * @apply_point: &enum iwl_fw_ini_apply_point
67  * @data: TLV data followed
68  **/
69 struct iwl_fw_ini_header {
70 	__le32 tlv_version;
71 	__le32 apply_point;
72 	u8 data[];
73 } __packed; /* FW_INI_HEADER_TLV_S */
74 
75 /**
76  * struct iwl_fw_ini_allocation_tlv - (IWL_FW_INI_TLV_TYPE_BUFFER_ALLOCATION)
77  * buffer allocation TLV - for debug
78  *
79  * @iwl_fw_ini_header: header
80  * @allocation_id: &enum iwl_fw_ini_allocation_id - to bind allocation and hcmd
81  *	if needed (DBGC1/DBGC2/SDFX/...)
82  * @buffer_location: type of iwl_fw_ini_buffer_location
83  * @size: size in bytes
84  * @max_fragments: the maximum allowed fragmentation in the desired memory
85  *	allocation above
86  * @min_frag_size: the minimum allowed fragmentation size in bytes
87 */
88 struct iwl_fw_ini_allocation_tlv {
89 	struct iwl_fw_ini_header header;
90 	__le32 allocation_id;
91 	__le32 buffer_location;
92 	__le32 size;
93 	__le32 max_fragments;
94 	__le32 min_frag_size;
95 } __packed; /* FW_INI_BUFFER_ALLOCATION_TLV_S_VER_1 */
96 
97 /**
98  * struct iwl_fw_ini_hcmd (IWL_FW_INI_TLV_TYPE_HCMD)
99  * Generic Host command pass through TLV
100  *
101  * @id: the debug configuration command type for instance: 0xf6 / 0xf5 / DHC
102  * @group: the desired cmd group
103  * @padding: all zeros for dword alignment
104  * @data: all of the relevant command (0xf6/0xf5) to be sent
105 */
106 struct iwl_fw_ini_hcmd {
107 	u8 id;
108 	u8 group;
109 	__le16 padding;
110 	u8 data[0];
111 } __packed; /* FW_INI_HCMD_S */
112 
113 /**
114  * struct iwl_fw_ini_hcmd_tlv
115  * @header: header
116  * @hcmd: a variable length host-command to be sent to apply the configuration.
117  */
118 struct iwl_fw_ini_hcmd_tlv {
119 	struct iwl_fw_ini_header header;
120 	struct iwl_fw_ini_hcmd hcmd;
121 } __packed; /* FW_INI_HCMD_TLV_S_VER_1 */
122 
123 /*
124  * struct iwl_fw_ini_debug_flow_tlv (IWL_FW_INI_TLV_TYPE_DEBUG_FLOW)
125  *
126  * @header: header
127  * @debug_flow_cfg: &enum iwl_fw_ini_debug_flow
128  */
129 struct iwl_fw_ini_debug_flow_tlv {
130 	struct iwl_fw_ini_header header;
131 	__le32 debug_flow_cfg;
132 } __packed; /* FW_INI_DEBUG_FLOW_TLV_S_VER_1 */
133 
134 #define IWL_FW_INI_MAX_REGION_ID	20
135 #define IWL_FW_INI_MAX_NAME		32
136 /**
137  * struct iwl_fw_ini_region_cfg
138  * @region_id: ID of this dump configuration
139  * @region_type: &enum iwl_fw_ini_region_type
140  * @num_regions: amount of regions in the address array.
141  * @allocation_id: For DRAM type field substitutes for allocation_id.
142  * @name_len: name length
143  * @name: file name to use for this region
144  * @size: size of the data, in bytes.(unused for IWL_FW_INI_REGION_DRAM_BUFFER)
145  * @start_addr: array of addresses. (unused for IWL_FW_INI_REGION_DRAM_BUFFER)
146  */
147 struct iwl_fw_ini_region_cfg {
148 	__le32 region_id;
149 	__le32 region_type;
150 	__le32 name_len;
151 	u8 name[IWL_FW_INI_MAX_NAME];
152 	union {
153 		__le32 num_regions;
154 		__le32 allocation_id;
155 	};
156 	__le32 size;
157 	__le32 start_addr[];
158 } __packed; /* FW_INI_REGION_CONFIG_S */
159 
160 /**
161  * struct iwl_fw_ini_region_tlv - (IWL_FW_INI_TLV_TYPE_REGION_CFG)
162  * DUMP sections define IDs and triggers that use those IDs TLV
163  * @header: header
164  * @num_regions: how many different region section and IDs are coming next
165  * @iwl_fw_ini_dump dump_config: list of dump configurations
166  */
167 struct iwl_fw_ini_region_tlv {
168 	struct iwl_fw_ini_header header;
169 	__le32 num_regions;
170 	struct iwl_fw_ini_region_cfg region_config[];
171 } __packed; /* FW_INI_REGION_CFG_S */
172 
173 /**
174  * struct iwl_fw_ini_trigger - (IWL_FW_INI_TLV_TYPE_DUMP_CFG)
175  * Region sections define IDs and triggers that use those IDs TLV
176  *
177  * @trigger_id: enum &iwl_fw_ini_tigger_id
178  * @ignore_default: override FW TLV with binary TLV
179  * @dump_delay: delay from trigger fire to dump, in usec
180  * @occurrences: max amount of times to be fired
181  * @ignore_consec: ignore consecutive triggers, in usec
182  * @force_restart: force FW restart
183  * @multi_dut: initiate debug dump data on several DUTs
184  * @trigger_data: generic data to be utilized per trigger
185  * @num_regions: number of dump regions defined for this trigger
186  * @data: region IDs
187  */
188 struct iwl_fw_ini_trigger {
189 	__le32 trigger_id;
190 	__le32 ignore_default;
191 	__le32 dump_delay;
192 	__le32 occurrences;
193 	__le32 ignore_consec;
194 	__le32 force_restart;
195 	__le32 multi_dut;
196 	__le32 trigger_data;
197 	__le32 num_regions;
198 	__le32 data[];
199 } __packed; /* FW_INI_TRIGGER_CONFIG_S */
200 
201 /**
202  * struct iwl_fw_ini_trigger_tlv - (IWL_FW_INI_TLV_TYPE_TRIGGERS_CFG)
203  * DUMP sections define IDs and triggers that use those IDs TLV
204  *
205  * @header: header
206  * @num_triggers: how many different triggers section and IDs are coming next
207  * @trigger_config: list of trigger configurations
208  */
209 struct iwl_fw_ini_trigger_tlv {
210 	struct iwl_fw_ini_header header;
211 	__le32 num_triggers;
212 	struct iwl_fw_ini_trigger trigger_config[];
213 } __packed; /* FW_INI_TRIGGER_CFG_S */
214 
215 /**
216  * enum iwl_fw_ini_trigger_id
217  * @IWL_FW_TRIGGER_ID_FW_ASSERT: FW assert
218  * @IWL_FW_TRIGGER_ID_FW_TFD_Q_HANG: TFD queue hang
219  * @IWL_FW_TRIGGER_ID_FW_HW_ERROR: HW assert
220  * @IWL_FW_TRIGGER_ID_FW_TRIGGER_ERROR: FW error notification
221  * @IWL_FW_TRIGGER_ID_FW_TRIGGER_WARNING: FW warning notification
222  * @IWL_FW_TRIGGER_ID_FW_TRIGGER_INFO: FW info notification
223  * @IWL_FW_TRIGGER_ID_FW_TRIGGER_DEBUG: FW debug notification
224  * @IWL_FW_TRIGGER_ID_USER_TRIGGER: User trigger
225  * @IWL_FW_TRIGGER_ID_HOST_PEER_CLIENT_INACTIVITY: peer inactivity
226  * @FW_DEBUG_TLV_TRIGGER_ID_HOST_DID_INITIATED_EVENT: undefined
227  * @IWL_FW_TRIGGER_ID_HOST_TX_LATENCY_THRESHOLD_CROSSED: TX latency
228  *	threshold was crossed
229  * @IWL_FW_TRIGGER_ID_HOST_TX_RESPONSE_STATUS_FAILED: TX failed
230  * @IWL_FW_TRIGGER_ID_HOST_OS_REQ_DEAUTH_PEER: Deauth initiated by host
231  * @IWL_FW_TRIGGER_ID_HOST_STOP_GO_REQUEST: stop GO request
232  * @IWL_FW_TRIGGER_ID_HOST_START_GO_REQUEST: start GO request
233  * @IWL_FW_TRIGGER_ID_HOST_JOIN_GROUP_REQUEST: join P2P group request
234  * @IWL_FW_TRIGGER_ID_HOST_SCAN_START: scan started event
235  * @IWL_FW_TRIGGER_ID_HOST_SCAN_SUBMITTED: undefined
236  * @IWL_FW_TRIGGER_ID_HOST_SCAN_PARAMS: undefined
237  * @IWL_FW_TRIGGER_ID_HOST_CHECK_FOR_HANG: undefined
238  * @IWL_FW_TRIGGER_ID_HOST_BAR_RECEIVED: BAR frame was received
239  * @IWL_FW_TRIGGER_ID_HOST_AGG_TX_RESPONSE_STATUS_FAILED: agg TX failed
240  * @IWL_FW_TRIGGER_ID_HOST_EAPOL_TX_RESPONSE_FAILED: EAPOL TX failed
241  * @IWL_FW_TRIGGER_ID_HOST_FAKE_TX_RESPONSE_SUSPECTED: suspicious TX response
242  * @IWL_FW_TRIGGER_ID_HOST_AUTH_REQ_FROM_ASSOC_CLIENT: received suspicious auth
243  * @IWL_FW_TRIGGER_ID_HOST_ROAM_COMPLETE: roaming was completed
244  * @IWL_FW_TRIGGER_ID_HOST_AUTH_ASSOC_FAST_FAILED: fast assoc failed
245  * @IWL_FW_TRIGGER_ID_HOST_D3_START: D3 start
246  * @IWL_FW_TRIGGER_ID_HOST_D3_END: D3 end
247  * @IWL_FW_TRIGGER_ID_HOST_BSS_MISSED_BEACONS: missed beacon events
248  * @IWL_FW_TRIGGER_ID_HOST_P2P_CLIENT_MISSED_BEACONS: P2P missed beacon events
249  * @IWL_FW_TRIGGER_ID_HOST_PEER_CLIENT_TX_FAILURES:  undefined
250  * @IWL_FW_TRIGGER_ID_HOST_TX_WFD_ACTION_FRAME_FAILED: undefined
251  * @IWL_FW_TRIGGER_ID_HOST_AUTH_ASSOC_FAILED: authentication / association
252  *	failed
253  * @IWL_FW_TRIGGER_ID_HOST_SCAN_COMPLETE: scan complete event
254  * @IWL_FW_TRIGGER_ID_HOST_SCAN_ABORT: scan abort complete
255  * @IWL_FW_TRIGGER_ID_HOST_NIC_ALIVE: nic alive message was received
256  * @IWL_FW_TRIGGER_ID_HOST_CHANNEL_SWITCH_COMPLETE: CSA was completed
257  * @IWL_FW_TRIGGER_ID_NUM: number of trigger IDs
258  */
259 enum iwl_fw_ini_trigger_id {
260 	/* Errors triggers */
261 	IWL_FW_TRIGGER_ID_FW_ASSERT				= 1,
262 	IWL_FW_TRIGGER_ID_FW_TFD_Q_HANG				= 2,
263 	IWL_FW_TRIGGER_ID_FW_HW_ERROR				= 3,
264 	/* Generic triggers */
265 	IWL_FW_TRIGGER_ID_FW_TRIGGER_ERROR			= 4,
266 	IWL_FW_TRIGGER_ID_FW_TRIGGER_WARNING			= 5,
267 	IWL_FW_TRIGGER_ID_FW_TRIGGER_INFO			= 6,
268 	IWL_FW_TRIGGER_ID_FW_TRIGGER_DEBUG			= 7,
269 	/* User Trigger */
270 	IWL_FW_TRIGGER_ID_USER_TRIGGER				= 8,
271 	/* Host triggers */
272 	IWL_FW_TRIGGER_ID_HOST_PEER_CLIENT_INACTIVITY		= 9,
273 	IWL_FW_TRIGGER_ID_HOST_DID_INITIATED_EVENT		= 10,
274 	IWL_FW_TRIGGER_ID_HOST_TX_LATENCY_THRESHOLD_CROSSED	= 11,
275 	IWL_FW_TRIGGER_ID_HOST_TX_RESPONSE_STATUS_FAILED	= 12,
276 	IWL_FW_TRIGGER_ID_HOST_OS_REQ_DEAUTH_PEER		= 13,
277 	IWL_FW_TRIGGER_ID_HOST_STOP_GO_REQUEST			= 14,
278 	IWL_FW_TRIGGER_ID_HOST_START_GO_REQUEST			= 15,
279 	IWL_FW_TRIGGER_ID_HOST_JOIN_GROUP_REQUEST		= 16,
280 	IWL_FW_TRIGGER_ID_HOST_SCAN_START			= 17,
281 	IWL_FW_TRIGGER_ID_HOST_SCAN_SUBITTED			= 18,
282 	IWL_FW_TRIGGER_ID_HOST_SCAN_PARAMS			= 19,
283 	IWL_FW_TRIGGER_ID_HOST_CHECK_FOR_HANG			= 20,
284 	IWL_FW_TRIGGER_ID_HOST_BAR_RECEIVED			= 21,
285 	IWL_FW_TRIGGER_ID_HOST_AGG_TX_RESPONSE_STATUS_FAILED	= 22,
286 	IWL_FW_TRIGGER_ID_HOST_EAPOL_TX_RESPONSE_FAILED		= 23,
287 	IWL_FW_TRIGGER_ID_HOST_FAKE_TX_RESPONSE_SUSPECTED	= 24,
288 	IWL_FW_TRIGGER_ID_HOST_AUTH_REQ_FROM_ASSOC_CLIENT	= 25,
289 	IWL_FW_TRIGGER_ID_HOST_ROAM_COMPLETE			= 26,
290 	IWL_FW_TRIGGER_ID_HOST_AUTH_ASSOC_FAST_FAILED		= 27,
291 	IWL_FW_TRIGGER_ID_HOST_D3_START				= 28,
292 	IWL_FW_TRIGGER_ID_HOST_D3_END				= 29,
293 	IWL_FW_TRIGGER_ID_HOST_BSS_MISSED_BEACONS		= 30,
294 	IWL_FW_TRIGGER_ID_HOST_P2P_CLIENT_MISSED_BEACONS	= 31,
295 	IWL_FW_TRIGGER_ID_HOST_PEER_CLIENT_TX_FAILURES		= 32,
296 	IWL_FW_TRIGGER_ID_HOST_TX_WFD_ACTION_FRAME_FAILED	= 33,
297 	IWL_FW_TRIGGER_ID_HOST_AUTH_ASSOC_FAILED		= 34,
298 	IWL_FW_TRIGGER_ID_HOST_SCAN_COMPLETE			= 35,
299 	IWL_FW_TRIGGER_ID_HOST_SCAN_ABORT			= 36,
300 	IWL_FW_TRIGGER_ID_HOST_NIC_ALIVE			= 37,
301 	IWL_FW_TRIGGER_ID_HOST_CHANNEL_SWITCH_COMPLETE          = 38,
302 	IWL_FW_TRIGGER_ID_NUM,
303 }; /* FW_INI_TRIGGER_ID_E_VER_1 */
304 
305 /**
306  * enum iwl_fw_ini_apply_point
307  * @IWL_FW_INI_APPLY_INVALID: invalid
308  * @IWL_FW_INI_APPLY_EARLY: pre loading FW
309  * @IWL_FW_INI_APPLY_AFTER_ALIVE: first cmd from host after alive
310  * @IWL_FW_INI_APPLY_POST_INIT: last cmd in initialization sequence
311  * @IWL_FW_INI_APPLY_MISSED_BEACONS: missed beacons notification
312  * @IWL_FW_INI_APPLY_SCAN_COMPLETE: scan completed
313  * @IWL_FW_INI_APPLY_NUM: number of apply points
314 */
315 enum iwl_fw_ini_apply_point {
316 	IWL_FW_INI_APPLY_INVALID,
317 	IWL_FW_INI_APPLY_EARLY,
318 	IWL_FW_INI_APPLY_AFTER_ALIVE,
319 	IWL_FW_INI_APPLY_POST_INIT,
320 	IWL_FW_INI_APPLY_MISSED_BEACONS,
321 	IWL_FW_INI_APPLY_SCAN_COMPLETE,
322 	IWL_FW_INI_APPLY_NUM,
323 }; /* FW_INI_APPLY_POINT_E_VER_1 */
324 
325 /**
326  * enum iwl_fw_ini_allocation_id
327  * @IWL_FW_INI_ALLOCATION_INVALID: invalid
328  * @IWL_FW_INI_ALLOCATION_ID_DBGC1: allocation meant for DBGC1 configuration
329  * @IWL_FW_INI_ALLOCATION_ID_DBGC2: allocation meant for DBGC2 configuration
330  * @IWL_FW_INI_ALLOCATION_ID_DBGC3: allocation meant for DBGC3 configuration
331  * @IWL_FW_INI_ALLOCATION_ID_SDFX: for SDFX module
332  * @IWL_FW_INI_ALLOCATION_ID_FW_DUMP: used for crash and runtime dumps
333  * @IWL_FW_INI_ALLOCATION_ID_USER_DEFINED: for future user scenarios
334 */
335 enum iwl_fw_ini_allocation_id {
336 	IWL_FW_INI_ALLOCATION_INVALID,
337 	IWL_FW_INI_ALLOCATION_ID_DBGC1,
338 	IWL_FW_INI_ALLOCATION_ID_DBGC2,
339 	IWL_FW_INI_ALLOCATION_ID_DBGC3,
340 	IWL_FW_INI_ALLOCATION_ID_SDFX,
341 	IWL_FW_INI_ALLOCATION_ID_FW_DUMP,
342 	IWL_FW_INI_ALLOCATION_ID_USER_DEFINED,
343 }; /* FW_INI_ALLOCATION_ID_E_VER_1 */
344 
345 /**
346  * enum iwl_fw_ini_buffer_location
347  * @IWL_FW_INI_LOCATION_INVALID: invalid
348  * @IWL_FW_INI_LOCATION_SRAM_PATH: SRAM location
349  * @IWL_FW_INI_LOCATION_DRAM_PATH: DRAM location
350  */
351 enum iwl_fw_ini_buffer_location {
352 	IWL_FW_INI_LOCATION_SRAM_INVALID,
353 	IWL_FW_INI_LOCATION_SRAM_PATH,
354 	IWL_FW_INI_LOCATION_DRAM_PATH,
355 }; /* FW_INI_BUFFER_LOCATION_E_VER_1 */
356 
357 /**
358  * enum iwl_fw_ini_debug_flow
359  * @IWL_FW_INI_DEBUG_INVALID: invalid
360  * @IWL_FW_INI_DEBUG_DBTR_FLOW: undefined
361  * @IWL_FW_INI_DEBUG_TB2DTF_FLOW: undefined
362  */
363 enum iwl_fw_ini_debug_flow {
364 	IWL_FW_INI_DEBUG_INVALID,
365 	IWL_FW_INI_DEBUG_DBTR_FLOW,
366 	IWL_FW_INI_DEBUG_TB2DTF_FLOW,
367 }; /* FW_INI_DEBUG_FLOW_E_VER_1 */
368 
369 /**
370  * enum iwl_fw_ini_region_type
371  * @IWL_FW_INI_REGION_INVALID: invalid
372  * @IWL_FW_INI_REGION_DEVICE_MEMORY: device internal memory
373  * @IWL_FW_INI_REGION_PERIPHERY_MAC: periphery registers of MAC
374  * @IWL_FW_INI_REGION_PERIPHERY_PHY: periphery registers of PHY
375  * @IWL_FW_INI_REGION_PERIPHERY_AUX: periphery registers of AUX
376  * @IWL_FW_INI_REGION_DRAM_BUFFER: DRAM buffer
377  * @IWL_FW_INI_REGION_DRAM_IMR: IMR memory
378  * @IWL_FW_INI_REGION_INTERNAL_BUFFER: undefined
379  * @IWL_FW_INI_REGION_TXF: TX fifos
380  * @IWL_FW_INI_REGION_RXF: RX fifo
381  * @IWL_FW_INI_REGION_PAGING: paging memory
382  * @IWL_FW_INI_REGION_CSR: CSR registers
383  * @IWL_FW_INI_REGION_NUM: number of region types
384  */
385 enum iwl_fw_ini_region_type {
386 	IWL_FW_INI_REGION_INVALID,
387 	IWL_FW_INI_REGION_DEVICE_MEMORY,
388 	IWL_FW_INI_REGION_PERIPHERY_MAC,
389 	IWL_FW_INI_REGION_PERIPHERY_PHY,
390 	IWL_FW_INI_REGION_PERIPHERY_AUX,
391 	IWL_FW_INI_REGION_DRAM_BUFFER,
392 	IWL_FW_INI_REGION_DRAM_IMR,
393 	IWL_FW_INI_REGION_INTERNAL_BUFFER,
394 	IWL_FW_INI_REGION_TXF,
395 	IWL_FW_INI_REGION_RXF,
396 	IWL_FW_INI_REGION_PAGING,
397 	IWL_FW_INI_REGION_CSR,
398 	IWL_FW_INI_REGION_NUM
399 }; /* FW_INI_REGION_TYPE_E_VER_1*/
400 
401 #endif
402