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) 2008 - 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  * Copyright(c) 2019 Intel Corporation
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of version 2 of the GNU General Public License as
16  * published by the Free Software Foundation.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * General Public License for more details.
22  *
23  * The full GNU General Public License is included in this distribution
24  * in the file called COPYING.
25  *
26  * Contact Information:
27  *  Intel Linux Wireless <linuxwifi@intel.com>
28  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
29  *
30  * BSD LICENSE
31  *
32  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
33  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
34  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
35  * Copyright(c) 2018 Intel Corporation
36  * Copyright(c) 2019 Intel Corporation
37  * All rights reserved.
38  *
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  *
43  *  * Redistributions of source code must retain the above copyright
44  *    notice, this list of conditions and the following disclaimer.
45  *  * Redistributions in binary form must reproduce the above copyright
46  *    notice, this list of conditions and the following disclaimer in
47  *    the documentation and/or other materials provided with the
48  *    distribution.
49  *  * Neither the name Intel Corporation nor the names of its
50  *    contributors may be used to endorse or promote products derived
51  *    from this software without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64  *****************************************************************************/
65 
66 #ifndef __iwl_fw_file_h__
67 #define __iwl_fw_file_h__
68 
69 #include <linux/netdevice.h>
70 #include <linux/nl80211.h>
71 
72 /* v1/v2 uCode file layout */
73 struct iwl_ucode_header {
74 	__le32 ver;	/* major/minor/API/serial */
75 	union {
76 		struct {
77 			__le32 inst_size;	/* bytes of runtime code */
78 			__le32 data_size;	/* bytes of runtime data */
79 			__le32 init_size;	/* bytes of init code */
80 			__le32 init_data_size;	/* bytes of init data */
81 			__le32 boot_size;	/* bytes of bootstrap code */
82 			u8 data[0];		/* in same order as sizes */
83 		} v1;
84 		struct {
85 			__le32 build;		/* build number */
86 			__le32 inst_size;	/* bytes of runtime code */
87 			__le32 data_size;	/* bytes of runtime data */
88 			__le32 init_size;	/* bytes of init code */
89 			__le32 init_data_size;	/* bytes of init data */
90 			__le32 boot_size;	/* bytes of bootstrap code */
91 			u8 data[0];		/* in same order as sizes */
92 		} v2;
93 	} u;
94 };
95 
96 #define IWL_UCODE_INI_TLV_GROUP	0x1000000
97 
98 /*
99  * new TLV uCode file layout
100  *
101  * The new TLV file format contains TLVs, that each specify
102  * some piece of data.
103  */
104 
105 enum iwl_ucode_tlv_type {
106 	IWL_UCODE_TLV_INVALID		= 0, /* unused */
107 	IWL_UCODE_TLV_INST		= 1,
108 	IWL_UCODE_TLV_DATA		= 2,
109 	IWL_UCODE_TLV_INIT		= 3,
110 	IWL_UCODE_TLV_INIT_DATA		= 4,
111 	IWL_UCODE_TLV_BOOT		= 5,
112 	IWL_UCODE_TLV_PROBE_MAX_LEN	= 6, /* a u32 value */
113 	IWL_UCODE_TLV_PAN		= 7,
114 	IWL_UCODE_TLV_RUNT_EVTLOG_PTR	= 8,
115 	IWL_UCODE_TLV_RUNT_EVTLOG_SIZE	= 9,
116 	IWL_UCODE_TLV_RUNT_ERRLOG_PTR	= 10,
117 	IWL_UCODE_TLV_INIT_EVTLOG_PTR	= 11,
118 	IWL_UCODE_TLV_INIT_EVTLOG_SIZE	= 12,
119 	IWL_UCODE_TLV_INIT_ERRLOG_PTR	= 13,
120 	IWL_UCODE_TLV_ENHANCE_SENS_TBL	= 14,
121 	IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
122 	IWL_UCODE_TLV_WOWLAN_INST	= 16,
123 	IWL_UCODE_TLV_WOWLAN_DATA	= 17,
124 	IWL_UCODE_TLV_FLAGS		= 18,
125 	IWL_UCODE_TLV_SEC_RT		= 19,
126 	IWL_UCODE_TLV_SEC_INIT		= 20,
127 	IWL_UCODE_TLV_SEC_WOWLAN	= 21,
128 	IWL_UCODE_TLV_DEF_CALIB		= 22,
129 	IWL_UCODE_TLV_PHY_SKU		= 23,
130 	IWL_UCODE_TLV_SECURE_SEC_RT	= 24,
131 	IWL_UCODE_TLV_SECURE_SEC_INIT	= 25,
132 	IWL_UCODE_TLV_SECURE_SEC_WOWLAN	= 26,
133 	IWL_UCODE_TLV_NUM_OF_CPU	= 27,
134 	IWL_UCODE_TLV_CSCHEME		= 28,
135 	IWL_UCODE_TLV_API_CHANGES_SET	= 29,
136 	IWL_UCODE_TLV_ENABLED_CAPABILITIES	= 30,
137 	IWL_UCODE_TLV_N_SCAN_CHANNELS		= 31,
138 	IWL_UCODE_TLV_PAGING		= 32,
139 	IWL_UCODE_TLV_SEC_RT_USNIFFER	= 34,
140 	/* 35 is unused */
141 	IWL_UCODE_TLV_FW_VERSION	= 36,
142 	IWL_UCODE_TLV_FW_DBG_DEST	= 38,
143 	IWL_UCODE_TLV_FW_DBG_CONF	= 39,
144 	IWL_UCODE_TLV_FW_DBG_TRIGGER	= 40,
145 	IWL_UCODE_TLV_CMD_VERSIONS	= 48,
146 	IWL_UCODE_TLV_FW_GSCAN_CAPA	= 50,
147 	IWL_UCODE_TLV_FW_MEM_SEG	= 51,
148 	IWL_UCODE_TLV_IML		= 52,
149 	IWL_UCODE_TLV_UMAC_DEBUG_ADDRS	= 54,
150 	IWL_UCODE_TLV_LMAC_DEBUG_ADDRS	= 55,
151 	IWL_UCODE_TLV_FW_RECOVERY_INFO	= 57,
152 	IWL_UCODE_TLV_FW_FSEQ_VERSION	= 60,
153 
154 	IWL_UCODE_TLV_DEBUG_BASE		= IWL_UCODE_INI_TLV_GROUP,
155 	IWL_UCODE_TLV_TYPE_DEBUG_INFO		= IWL_UCODE_TLV_DEBUG_BASE + 0,
156 	IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION	= IWL_UCODE_TLV_DEBUG_BASE + 1,
157 	IWL_UCODE_TLV_TYPE_HCMD			= IWL_UCODE_TLV_DEBUG_BASE + 2,
158 	IWL_UCODE_TLV_TYPE_REGIONS		= IWL_UCODE_TLV_DEBUG_BASE + 3,
159 	IWL_UCODE_TLV_TYPE_TRIGGERS		= IWL_UCODE_TLV_DEBUG_BASE + 4,
160 	IWL_UCODE_TLV_DEBUG_MAX = IWL_UCODE_TLV_TYPE_TRIGGERS,
161 
162 	/* TLVs 0x1000-0x2000 are for internal driver usage */
163 	IWL_UCODE_TLV_FW_DBG_DUMP_LST	= 0x1000,
164 };
165 
166 struct iwl_ucode_tlv {
167 	__le32 type;		/* see above */
168 	__le32 length;		/* not including type/length fields */
169 	u8 data[0];
170 };
171 
172 #define IWL_TLV_UCODE_MAGIC		0x0a4c5749
173 #define FW_VER_HUMAN_READABLE_SZ	64
174 
175 struct iwl_tlv_ucode_header {
176 	/*
177 	 * The TLV style ucode header is distinguished from
178 	 * the v1/v2 style header by first four bytes being
179 	 * zero, as such is an invalid combination of
180 	 * major/minor/API/serial versions.
181 	 */
182 	__le32 zero;
183 	__le32 magic;
184 	u8 human_readable[FW_VER_HUMAN_READABLE_SZ];
185 	/* major/minor/API/serial or major in new format */
186 	__le32 ver;
187 	__le32 build;
188 	__le64 ignore;
189 	/*
190 	 * The data contained herein has a TLV layout,
191 	 * see above for the TLV header and types.
192 	 * Note that each TLV is padded to a length
193 	 * that is a multiple of 4 for alignment.
194 	 */
195 	u8 data[0];
196 };
197 
198 /*
199  * ucode TLVs
200  *
201  * ability to get extension for: flags & capabilities from ucode binaries files
202  */
203 struct iwl_ucode_api {
204 	__le32 api_index;
205 	__le32 api_flags;
206 } __packed;
207 
208 struct iwl_ucode_capa {
209 	__le32 api_index;
210 	__le32 api_capa;
211 } __packed;
212 
213 /**
214  * enum iwl_ucode_tlv_flag - ucode API flags
215  * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
216  *	was a separate TLV but moved here to save space.
217  * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behavior on hidden SSID,
218  *	treats good CRC threshold as a boolean
219  * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
220  * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: This uCode image supports uAPSD
221  * @IWL_UCODE_TLV_FLAGS_SHORT_BL: 16 entries of black list instead of 64 in scan
222  *	offload profile config command.
223  * @IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS: D3 image supports up to six
224  *	(rather than two) IPv6 addresses
225  * @IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID: not sending a probe with the SSID element
226  *	from the probe request template.
227  * @IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL: new NS offload (small version)
228  * @IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE: new NS offload (large version)
229  * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD
230  * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save
231  * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering.
232  * @IWL_UCODE_TLV_FLAGS_EBS_SUPPORT: this uCode image supports EBS.
233  */
234 enum iwl_ucode_tlv_flag {
235 	IWL_UCODE_TLV_FLAGS_PAN			= BIT(0),
236 	IWL_UCODE_TLV_FLAGS_NEWSCAN		= BIT(1),
237 	IWL_UCODE_TLV_FLAGS_MFP			= BIT(2),
238 	IWL_UCODE_TLV_FLAGS_SHORT_BL		= BIT(7),
239 	IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS	= BIT(10),
240 	IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID	= BIT(12),
241 	IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL	= BIT(15),
242 	IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE	= BIT(16),
243 	IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT	= BIT(24),
244 	IWL_UCODE_TLV_FLAGS_EBS_SUPPORT		= BIT(25),
245 	IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD	= BIT(26),
246 	IWL_UCODE_TLV_FLAGS_BCAST_FILTERING	= BIT(29),
247 };
248 
249 typedef unsigned int __bitwise iwl_ucode_tlv_api_t;
250 
251 /**
252  * enum iwl_ucode_tlv_api - ucode api
253  * @IWL_UCODE_TLV_API_FRAGMENTED_SCAN: This ucode supports active dwell time
254  *	longer than the passive one, which is essential for fragmented scan.
255  * @IWL_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source.
256  * @IWL_UCODE_TLV_API_LQ_SS_PARAMS: Configure STBC/BFER via LQ CMD ss_params
257  * @IWL_UCODE_TLV_API_NEW_VERSION: new versioning format
258  * @IWL_UCODE_TLV_API_SCAN_TSF_REPORT: Scan start time reported in scan
259  *	iteration complete notification, and the timestamp reported for RX
260  *	received during scan, are reported in TSF of the mac specified in the
261  *	scan request.
262  * @IWL_UCODE_TLV_API_TKIP_MIC_KEYS: This ucode supports version 2 of
263  *	ADD_MODIFY_STA_KEY_API_S_VER_2.
264  * @IWL_UCODE_TLV_API_STA_TYPE: This ucode supports station type assignement.
265  * @IWL_UCODE_TLV_API_NAN2_VER2: This ucode supports NAN API version 2
266  * @IWL_UCODE_TLV_API_NEW_RX_STATS: should new RX STATISTICS API be used
267  * @IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY: Quota command includes a field
268  *	indicating low latency direction.
269  * @IWL_UCODE_TLV_API_DEPRECATE_TTAK: RX status flag TTAK ok (bit 7) is
270  *	deprecated.
271  * @IWL_UCODE_TLV_API_ADAPTIVE_DWELL_V2: This ucode supports version 8
272  *	of scan request: SCAN_REQUEST_CMD_UMAC_API_S_VER_8
273  * @IWL_UCODE_TLV_API_FRAG_EBS: This ucode supports fragmented EBS
274  * @IWL_UCODE_TLV_API_REDUCE_TX_POWER: This ucode supports v5 of
275  *	the REDUCE_TX_POWER_CMD.
276  * @IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF: This ucode supports the short
277  *	version of the beacon notification.
278  * @IWL_UCODE_TLV_API_BEACON_FILTER_V4: This ucode supports v4 of
279  *	BEACON_FILTER_CONFIG_API_S_VER_4.
280  * @IWL_UCODE_TLV_API_REGULATORY_NVM_INFO: This ucode supports v4 of
281  *	REGULATORY_NVM_GET_INFO_RSP_API_S.
282  * @IWL_UCODE_TLV_API_FTM_NEW_RANGE_REQ: This ucode supports v7 of
283  *	LOCATION_RANGE_REQ_CMD_API_S and v6 of LOCATION_RANGE_RESP_NTFY_API_S.
284  * @IWL_UCODE_TLV_API_SCAN_OFFLOAD_CHANS: This ucode supports v2 of
285  *	SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S and v3 of
286  *	SCAN_OFFLOAD_PROFILES_QUERY_RSP_S.
287  * @IWL_UCODE_TLV_API_MBSSID_HE: This ucode supports v2 of
288  *	STA_CONTEXT_DOT11AX_API_S
289  * @IWL_UCODE_TLV_CAPA_SAR_TABLE_VER: This ucode supports different sar
290  *	version tables.
291  * @IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG: This ucode supports v3 of
292  *  SCAN_CONFIG_DB_CMD_API_S.
293  *
294  * @NUM_IWL_UCODE_TLV_API: number of bits used
295  */
296 enum iwl_ucode_tlv_api {
297 	/* API Set 0 */
298 	IWL_UCODE_TLV_API_FRAGMENTED_SCAN	= (__force iwl_ucode_tlv_api_t)8,
299 	IWL_UCODE_TLV_API_WIFI_MCC_UPDATE	= (__force iwl_ucode_tlv_api_t)9,
300 	IWL_UCODE_TLV_API_LQ_SS_PARAMS		= (__force iwl_ucode_tlv_api_t)18,
301 	IWL_UCODE_TLV_API_NEW_VERSION		= (__force iwl_ucode_tlv_api_t)20,
302 	IWL_UCODE_TLV_API_SCAN_TSF_REPORT	= (__force iwl_ucode_tlv_api_t)28,
303 	IWL_UCODE_TLV_API_TKIP_MIC_KEYS		= (__force iwl_ucode_tlv_api_t)29,
304 	IWL_UCODE_TLV_API_STA_TYPE		= (__force iwl_ucode_tlv_api_t)30,
305 	IWL_UCODE_TLV_API_NAN2_VER2		= (__force iwl_ucode_tlv_api_t)31,
306 	/* API Set 1 */
307 	IWL_UCODE_TLV_API_ADAPTIVE_DWELL	= (__force iwl_ucode_tlv_api_t)32,
308 	IWL_UCODE_TLV_API_OCE			= (__force iwl_ucode_tlv_api_t)33,
309 	IWL_UCODE_TLV_API_NEW_BEACON_TEMPLATE	= (__force iwl_ucode_tlv_api_t)34,
310 	IWL_UCODE_TLV_API_NEW_RX_STATS		= (__force iwl_ucode_tlv_api_t)35,
311 	IWL_UCODE_TLV_API_WOWLAN_KEY_MATERIAL	= (__force iwl_ucode_tlv_api_t)36,
312 	IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY	= (__force iwl_ucode_tlv_api_t)38,
313 	IWL_UCODE_TLV_API_DEPRECATE_TTAK	= (__force iwl_ucode_tlv_api_t)41,
314 	IWL_UCODE_TLV_API_ADAPTIVE_DWELL_V2	= (__force iwl_ucode_tlv_api_t)42,
315 	IWL_UCODE_TLV_API_FRAG_EBS		= (__force iwl_ucode_tlv_api_t)44,
316 	IWL_UCODE_TLV_API_REDUCE_TX_POWER	= (__force iwl_ucode_tlv_api_t)45,
317 	IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF	= (__force iwl_ucode_tlv_api_t)46,
318 	IWL_UCODE_TLV_API_BEACON_FILTER_V4      = (__force iwl_ucode_tlv_api_t)47,
319 	IWL_UCODE_TLV_API_REGULATORY_NVM_INFO   = (__force iwl_ucode_tlv_api_t)48,
320 	IWL_UCODE_TLV_API_FTM_NEW_RANGE_REQ     = (__force iwl_ucode_tlv_api_t)49,
321 	IWL_UCODE_TLV_API_SCAN_OFFLOAD_CHANS    = (__force iwl_ucode_tlv_api_t)50,
322 	IWL_UCODE_TLV_API_MBSSID_HE		= (__force iwl_ucode_tlv_api_t)52,
323 	IWL_UCODE_TLV_API_WOWLAN_TCP_SYN_WAKE	= (__force iwl_ucode_tlv_api_t)53,
324 	IWL_UCODE_TLV_API_FTM_RTT_ACCURACY      = (__force iwl_ucode_tlv_api_t)54,
325 	IWL_UCODE_TLV_API_SAR_TABLE_VER         = (__force iwl_ucode_tlv_api_t)55,
326 	IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG   = (__force iwl_ucode_tlv_api_t)56,
327 	IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP	= (__force iwl_ucode_tlv_api_t)57,
328 	IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER	= (__force iwl_ucode_tlv_api_t)58,
329 
330 	NUM_IWL_UCODE_TLV_API
331 #ifdef __CHECKER__
332 		/* sparse says it cannot increment the previous enum member */
333 		= 128
334 #endif
335 };
336 
337 typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
338 
339 /**
340  * enum iwl_ucode_tlv_capa - ucode capabilities
341  * @IWL_UCODE_TLV_CAPA_D0I3_SUPPORT: supports D0i3
342  * @IWL_UCODE_TLV_CAPA_LAR_SUPPORT: supports Location Aware Regulatory
343  * @IWL_UCODE_TLV_CAPA_UMAC_SCAN: supports UMAC scan.
344  * @IWL_UCODE_TLV_CAPA_BEAMFORMER: supports Beamformer
345  * @IWL_UCODE_TLV_CAPA_TDLS_SUPPORT: support basic TDLS functionality
346  * @IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT: supports insertion of current
347  *	tx power value into TPC Report action frame and Link Measurement Report
348  *	action frame
349  * @IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT: supports updating current
350  *	channel in DS parameter set element in probe requests.
351  * @IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT: supports adding TPC Report IE in
352  *	probe requests.
353  * @IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT: supports Quiet Period requests
354  * @IWL_UCODE_TLV_CAPA_DQA_SUPPORT: supports dynamic queue allocation (DQA),
355  *	which also implies support for the scheduler configuration command
356  * @IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH: supports TDLS channel switching
357  * @IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG: Consolidated D3-D0 image
358  * @IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT: supports Hot Spot Command
359  * @IWL_UCODE_TLV_CAPA_DC2DC_SUPPORT: supports DC2DC Command
360  * @IWL_UCODE_TLV_CAPA_CSUM_SUPPORT: supports TCP Checksum Offload
361  * @IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS: support radio and beacon statistics
362  * @IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD: supports U-APSD on p2p interface when it
363  *	is standalone or with a BSS station interface in the same binding.
364  * @IWL_UCODE_TLV_CAPA_BT_COEX_PLCR: enabled BT Coex packet level co-running
365  * @IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC: ucode supports LAR updates with different
366  *	sources for the MCC. This TLV bit is a future replacement to
367  *	IWL_UCODE_TLV_API_WIFI_MCC_UPDATE. When either is set, multi-source LAR
368  *	is supported.
369  * @IWL_UCODE_TLV_CAPA_BT_COEX_RRC: supports BT Coex RRC
370  * @IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT: supports gscan (no longer used)
371  * @IWL_UCODE_TLV_CAPA_STA_PM_NOTIF: firmware will send STA PM notification
372  * @IWL_UCODE_TLV_CAPA_TLC_OFFLOAD: firmware implements rate scaling algorithm
373  * @IWL_UCODE_TLV_CAPA_DYNAMIC_QUOTA: firmware implements quota related
374  * @IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2: firmware implements Coex Schema 2
375  * IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD: firmware supports CSA command
376  * @IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS: firmware supports ultra high band
377  *	(6 GHz).
378  * @IWL_UCODE_TLV_CAPA_CS_MODIFY: firmware supports modify action CSA command
379  * @IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE: extended DTS measurement
380  * @IWL_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS: supports short PM timeouts
381  * @IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT: supports bt-coex Multi-priority LUT
382  * @IWL_UCODE_TLV_CAPA_CSA_AND_TBTT_OFFLOAD: the firmware supports CSA
383  *	countdown offloading. Beacon notifications are not sent to the host.
384  *	The fw also offloads TBTT alignment.
385  * @IWL_UCODE_TLV_CAPA_BEACON_ANT_SELECTION: firmware will decide on what
386  *	antenna the beacon should be transmitted
387  * @IWL_UCODE_TLV_CAPA_BEACON_STORING: firmware will store the latest beacon
388  *	from AP and will send it upon d0i3 exit.
389  * @IWL_UCODE_TLV_CAPA_LAR_SUPPORT_V3: support LAR API V3
390  * @IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW: firmware responsible for CT-kill
391  * @IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT: supports temperature
392  *	thresholds reporting
393  * @IWL_UCODE_TLV_CAPA_CTDP_SUPPORT: supports cTDP command
394  * @IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED: supports usniffer enabled in
395  *	regular image.
396  * @IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG: support getting more shared
397  *	memory addresses from the firmware.
398  * @IWL_UCODE_TLV_CAPA_LQM_SUPPORT: supports Link Quality Measurement
399  * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger
400  *	command size (command version 4) that supports toggling ACK TX
401  *	power reduction.
402  * @IWL_UCODE_TLV_CAPA_D3_DEBUG: supports debug recording during D3
403  * @IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT: MCC response support 11ax
404  *	capability.
405  * @IWL_UCODE_TLV_CAPA_CSI_REPORTING: firmware is capable of being configured
406  *	to report the CSI information with (certain) RX frames
407  * @IWL_UCODE_TLV_CAPA_FTM_CALIBRATED: has FTM calibrated and thus supports both
408  *	initiator and responder
409  *
410  * @IWL_UCODE_TLV_CAPA_MLME_OFFLOAD: supports MLME offload
411  *
412  * @NUM_IWL_UCODE_TLV_CAPA: number of bits used
413  */
414 enum iwl_ucode_tlv_capa {
415 	/* set 0 */
416 	IWL_UCODE_TLV_CAPA_D0I3_SUPPORT			= (__force iwl_ucode_tlv_capa_t)0,
417 	IWL_UCODE_TLV_CAPA_LAR_SUPPORT			= (__force iwl_ucode_tlv_capa_t)1,
418 	IWL_UCODE_TLV_CAPA_UMAC_SCAN			= (__force iwl_ucode_tlv_capa_t)2,
419 	IWL_UCODE_TLV_CAPA_BEAMFORMER			= (__force iwl_ucode_tlv_capa_t)3,
420 	IWL_UCODE_TLV_CAPA_TDLS_SUPPORT			= (__force iwl_ucode_tlv_capa_t)6,
421 	IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT	= (__force iwl_ucode_tlv_capa_t)8,
422 	IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT	= (__force iwl_ucode_tlv_capa_t)9,
423 	IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT	= (__force iwl_ucode_tlv_capa_t)10,
424 	IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT		= (__force iwl_ucode_tlv_capa_t)11,
425 	IWL_UCODE_TLV_CAPA_DQA_SUPPORT			= (__force iwl_ucode_tlv_capa_t)12,
426 	IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH		= (__force iwl_ucode_tlv_capa_t)13,
427 	IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG		= (__force iwl_ucode_tlv_capa_t)17,
428 	IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT		= (__force iwl_ucode_tlv_capa_t)18,
429 	IWL_UCODE_TLV_CAPA_DC2DC_CONFIG_SUPPORT		= (__force iwl_ucode_tlv_capa_t)19,
430 	IWL_UCODE_TLV_CAPA_CSUM_SUPPORT			= (__force iwl_ucode_tlv_capa_t)21,
431 	IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS		= (__force iwl_ucode_tlv_capa_t)22,
432 	IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD		= (__force iwl_ucode_tlv_capa_t)26,
433 	IWL_UCODE_TLV_CAPA_BT_COEX_PLCR			= (__force iwl_ucode_tlv_capa_t)28,
434 	IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC		= (__force iwl_ucode_tlv_capa_t)29,
435 	IWL_UCODE_TLV_CAPA_BT_COEX_RRC			= (__force iwl_ucode_tlv_capa_t)30,
436 	IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT		= (__force iwl_ucode_tlv_capa_t)31,
437 
438 	/* set 1 */
439 	IWL_UCODE_TLV_CAPA_STA_PM_NOTIF			= (__force iwl_ucode_tlv_capa_t)38,
440 	IWL_UCODE_TLV_CAPA_BINDING_CDB_SUPPORT		= (__force iwl_ucode_tlv_capa_t)39,
441 	IWL_UCODE_TLV_CAPA_CDB_SUPPORT			= (__force iwl_ucode_tlv_capa_t)40,
442 	IWL_UCODE_TLV_CAPA_D0I3_END_FIRST		= (__force iwl_ucode_tlv_capa_t)41,
443 	IWL_UCODE_TLV_CAPA_TLC_OFFLOAD                  = (__force iwl_ucode_tlv_capa_t)43,
444 	IWL_UCODE_TLV_CAPA_DYNAMIC_QUOTA                = (__force iwl_ucode_tlv_capa_t)44,
445 	IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2		= (__force iwl_ucode_tlv_capa_t)45,
446 	IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD		= (__force iwl_ucode_tlv_capa_t)46,
447 	IWL_UCODE_TLV_CAPA_FTM_CALIBRATED		= (__force iwl_ucode_tlv_capa_t)47,
448 	IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS		= (__force iwl_ucode_tlv_capa_t)48,
449 	IWL_UCODE_TLV_CAPA_CS_MODIFY			= (__force iwl_ucode_tlv_capa_t)49,
450 	IWL_UCODE_TLV_CAPA_SET_LTR_GEN2			= (__force iwl_ucode_tlv_capa_t)50,
451 	IWL_UCODE_TLV_CAPA_SET_PPAG			= (__force iwl_ucode_tlv_capa_t)52,
452 
453 	/* set 2 */
454 	IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE		= (__force iwl_ucode_tlv_capa_t)64,
455 	IWL_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS		= (__force iwl_ucode_tlv_capa_t)65,
456 	IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT		= (__force iwl_ucode_tlv_capa_t)67,
457 	IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT	= (__force iwl_ucode_tlv_capa_t)68,
458 	IWL_UCODE_TLV_CAPA_CSA_AND_TBTT_OFFLOAD		= (__force iwl_ucode_tlv_capa_t)70,
459 	IWL_UCODE_TLV_CAPA_BEACON_ANT_SELECTION		= (__force iwl_ucode_tlv_capa_t)71,
460 	IWL_UCODE_TLV_CAPA_BEACON_STORING		= (__force iwl_ucode_tlv_capa_t)72,
461 	IWL_UCODE_TLV_CAPA_LAR_SUPPORT_V3		= (__force iwl_ucode_tlv_capa_t)73,
462 	IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW		= (__force iwl_ucode_tlv_capa_t)74,
463 	IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT	= (__force iwl_ucode_tlv_capa_t)75,
464 	IWL_UCODE_TLV_CAPA_CTDP_SUPPORT			= (__force iwl_ucode_tlv_capa_t)76,
465 	IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED		= (__force iwl_ucode_tlv_capa_t)77,
466 	IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG	= (__force iwl_ucode_tlv_capa_t)80,
467 	IWL_UCODE_TLV_CAPA_LQM_SUPPORT			= (__force iwl_ucode_tlv_capa_t)81,
468 	IWL_UCODE_TLV_CAPA_TX_POWER_ACK			= (__force iwl_ucode_tlv_capa_t)84,
469 	IWL_UCODE_TLV_CAPA_D3_DEBUG			= (__force iwl_ucode_tlv_capa_t)87,
470 	IWL_UCODE_TLV_CAPA_LED_CMD_SUPPORT		= (__force iwl_ucode_tlv_capa_t)88,
471 	IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT	= (__force iwl_ucode_tlv_capa_t)89,
472 	IWL_UCODE_TLV_CAPA_CSI_REPORTING		= (__force iwl_ucode_tlv_capa_t)90,
473 	IWL_UCODE_TLV_CAPA_DBG_SUSPEND_RESUME_CMD_SUPP	= (__force iwl_ucode_tlv_capa_t)92,
474 	IWL_UCODE_TLV_CAPA_DBG_BUF_ALLOC_CMD_SUPP	= (__force iwl_ucode_tlv_capa_t)93,
475 
476 	/* set 3 */
477 	IWL_UCODE_TLV_CAPA_MLME_OFFLOAD			= (__force iwl_ucode_tlv_capa_t)96,
478 
479 	NUM_IWL_UCODE_TLV_CAPA
480 #ifdef __CHECKER__
481 		/* sparse says it cannot increment the previous enum member */
482 		= 128
483 #endif
484 };
485 
486 /* The default calibrate table size if not specified by firmware file */
487 #define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE	18
488 #define IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE		19
489 #define IWL_MAX_PHY_CALIBRATE_TBL_SIZE			253
490 
491 /* The default max probe length if not specified by the firmware file */
492 #define IWL_DEFAULT_MAX_PROBE_LENGTH	200
493 
494 /*
495  * For 16.0 uCode and above, there is no differentiation between sections,
496  * just an offset to the HW address.
497  */
498 #define CPU1_CPU2_SEPARATOR_SECTION	0xFFFFCCCC
499 #define PAGING_SEPARATOR_SECTION	0xAAAABBBB
500 
501 /* uCode version contains 4 values: Major/Minor/API/Serial */
502 #define IWL_UCODE_MAJOR(ver)	(((ver) & 0xFF000000) >> 24)
503 #define IWL_UCODE_MINOR(ver)	(((ver) & 0x00FF0000) >> 16)
504 #define IWL_UCODE_API(ver)	(((ver) & 0x0000FF00) >> 8)
505 #define IWL_UCODE_SERIAL(ver)	((ver) & 0x000000FF)
506 
507 /**
508  * struct iwl_tlv_calib_ctrl - Calibration control struct.
509  * Sent as part of the phy configuration command.
510  * @flow_trigger: bitmap for which calibrations to perform according to
511  *		flow triggers.
512  * @event_trigger: bitmap for which calibrations to perform according to
513  *		event triggers.
514  */
515 struct iwl_tlv_calib_ctrl {
516 	__le32 flow_trigger;
517 	__le32 event_trigger;
518 } __packed;
519 
520 enum iwl_fw_phy_cfg {
521 	FW_PHY_CFG_RADIO_TYPE_POS = 0,
522 	FW_PHY_CFG_RADIO_TYPE = 0x3 << FW_PHY_CFG_RADIO_TYPE_POS,
523 	FW_PHY_CFG_RADIO_STEP_POS = 2,
524 	FW_PHY_CFG_RADIO_STEP = 0x3 << FW_PHY_CFG_RADIO_STEP_POS,
525 	FW_PHY_CFG_RADIO_DASH_POS = 4,
526 	FW_PHY_CFG_RADIO_DASH = 0x3 << FW_PHY_CFG_RADIO_DASH_POS,
527 	FW_PHY_CFG_TX_CHAIN_POS = 16,
528 	FW_PHY_CFG_TX_CHAIN = 0xf << FW_PHY_CFG_TX_CHAIN_POS,
529 	FW_PHY_CFG_RX_CHAIN_POS = 20,
530 	FW_PHY_CFG_RX_CHAIN = 0xf << FW_PHY_CFG_RX_CHAIN_POS,
531 	FW_PHY_CFG_CHAIN_SAD_POS = 23,
532 	FW_PHY_CFG_CHAIN_SAD_ENABLED = 0x1 << FW_PHY_CFG_CHAIN_SAD_POS,
533 	FW_PHY_CFG_CHAIN_SAD_ANT_A = 0x2 << FW_PHY_CFG_CHAIN_SAD_POS,
534 	FW_PHY_CFG_CHAIN_SAD_ANT_B = 0x4 << FW_PHY_CFG_CHAIN_SAD_POS,
535 	FW_PHY_CFG_SHARED_CLK = BIT(31),
536 };
537 
538 #define IWL_UCODE_MAX_CS		1
539 
540 /**
541  * struct iwl_fw_cipher_scheme - a cipher scheme supported by FW.
542  * @cipher: a cipher suite selector
543  * @flags: cipher scheme flags (currently reserved for a future use)
544  * @hdr_len: a size of MPDU security header
545  * @pn_len: a size of PN
546  * @pn_off: an offset of pn from the beginning of the security header
547  * @key_idx_off: an offset of key index byte in the security header
548  * @key_idx_mask: a bit mask of key_idx bits
549  * @key_idx_shift: bit shift needed to get key_idx
550  * @mic_len: mic length in bytes
551  * @hw_cipher: a HW cipher index used in host commands
552  */
553 struct iwl_fw_cipher_scheme {
554 	__le32 cipher;
555 	u8 flags;
556 	u8 hdr_len;
557 	u8 pn_len;
558 	u8 pn_off;
559 	u8 key_idx_off;
560 	u8 key_idx_mask;
561 	u8 key_idx_shift;
562 	u8 mic_len;
563 	u8 hw_cipher;
564 } __packed;
565 
566 enum iwl_fw_dbg_reg_operator {
567 	CSR_ASSIGN,
568 	CSR_SETBIT,
569 	CSR_CLEARBIT,
570 
571 	PRPH_ASSIGN,
572 	PRPH_SETBIT,
573 	PRPH_CLEARBIT,
574 
575 	INDIRECT_ASSIGN,
576 	INDIRECT_SETBIT,
577 	INDIRECT_CLEARBIT,
578 
579 	PRPH_BLOCKBIT,
580 };
581 
582 /**
583  * struct iwl_fw_dbg_reg_op - an operation on a register
584  *
585  * @op: &enum iwl_fw_dbg_reg_operator
586  * @addr: offset of the register
587  * @val: value
588  */
589 struct iwl_fw_dbg_reg_op {
590 	u8 op;
591 	u8 reserved[3];
592 	__le32 addr;
593 	__le32 val;
594 } __packed;
595 
596 /**
597  * enum iwl_fw_dbg_monitor_mode - available monitor recording modes
598  *
599  * @SMEM_MODE: monitor stores the data in SMEM
600  * @EXTERNAL_MODE: monitor stores the data in allocated DRAM
601  * @MARBH_MODE: monitor stores the data in MARBH buffer
602  * @MIPI_MODE: monitor outputs the data through the MIPI interface
603  */
604 enum iwl_fw_dbg_monitor_mode {
605 	SMEM_MODE = 0,
606 	EXTERNAL_MODE = 1,
607 	MARBH_MODE = 2,
608 	MIPI_MODE = 3,
609 };
610 
611 /**
612  * struct iwl_fw_dbg_mem_seg_tlv - configures the debug data memory segments
613  *
614  * @data_type: the memory segment type to record
615  * @ofs: the memory segment offset
616  * @len: the memory segment length, in bytes
617  *
618  * This parses IWL_UCODE_TLV_FW_MEM_SEG
619  */
620 struct iwl_fw_dbg_mem_seg_tlv {
621 	__le32 data_type;
622 	__le32 ofs;
623 	__le32 len;
624 } __packed;
625 
626 /**
627  * struct iwl_fw_dbg_dest_tlv_v1 - configures the destination of the debug data
628  *
629  * @version: version of the TLV - currently 0
630  * @monitor_mode: &enum iwl_fw_dbg_monitor_mode
631  * @size_power: buffer size will be 2^(size_power + 11)
632  * @base_reg: addr of the base addr register (PRPH)
633  * @end_reg:  addr of the end addr register (PRPH)
634  * @write_ptr_reg: the addr of the reg of the write pointer
635  * @wrap_count: the addr of the reg of the wrap_count
636  * @base_shift: shift right of the base addr reg
637  * @end_shift: shift right of the end addr reg
638  * @reg_ops: array of registers operations
639  *
640  * This parses IWL_UCODE_TLV_FW_DBG_DEST
641  */
642 struct iwl_fw_dbg_dest_tlv_v1 {
643 	u8 version;
644 	u8 monitor_mode;
645 	u8 size_power;
646 	u8 reserved;
647 	__le32 base_reg;
648 	__le32 end_reg;
649 	__le32 write_ptr_reg;
650 	__le32 wrap_count;
651 	u8 base_shift;
652 	u8 end_shift;
653 	struct iwl_fw_dbg_reg_op reg_ops[0];
654 } __packed;
655 
656 /* Mask of the register for defining the LDBG MAC2SMEM buffer SMEM size */
657 #define IWL_LDBG_M2S_BUF_SIZE_MSK	0x0fff0000
658 /* Mask of the register for defining the LDBG MAC2SMEM SMEM base address */
659 #define IWL_LDBG_M2S_BUF_BA_MSK		0x00000fff
660 /* The smem buffer chunks are in units of 256 bits */
661 #define IWL_M2S_UNIT_SIZE			0x100
662 
663 struct iwl_fw_dbg_dest_tlv {
664 	u8 version;
665 	u8 monitor_mode;
666 	u8 size_power;
667 	u8 reserved;
668 	__le32 cfg_reg;
669 	__le32 write_ptr_reg;
670 	__le32 wrap_count;
671 	u8 base_shift;
672 	u8 size_shift;
673 	struct iwl_fw_dbg_reg_op reg_ops[0];
674 } __packed;
675 
676 struct iwl_fw_dbg_conf_hcmd {
677 	u8 id;
678 	u8 reserved;
679 	__le16 len;
680 	u8 data[0];
681 } __packed;
682 
683 /**
684  * enum iwl_fw_dbg_trigger_mode - triggers functionalities
685  *
686  * @IWL_FW_DBG_TRIGGER_START: when trigger occurs re-conf the dbg mechanism
687  * @IWL_FW_DBG_TRIGGER_STOP: when trigger occurs pull the dbg data
688  * @IWL_FW_DBG_TRIGGER_MONITOR_ONLY: when trigger occurs trigger is set to
689  *	collect only monitor data
690  */
691 enum iwl_fw_dbg_trigger_mode {
692 	IWL_FW_DBG_TRIGGER_START = BIT(0),
693 	IWL_FW_DBG_TRIGGER_STOP = BIT(1),
694 	IWL_FW_DBG_TRIGGER_MONITOR_ONLY = BIT(2),
695 };
696 
697 /**
698  * enum iwl_fw_dbg_trigger_flags - the flags supported by wrt triggers
699  * @IWL_FW_DBG_FORCE_RESTART: force a firmware restart
700  */
701 enum iwl_fw_dbg_trigger_flags {
702 	IWL_FW_DBG_FORCE_RESTART = BIT(0),
703 };
704 
705 /**
706  * enum iwl_fw_dbg_trigger_vif_type - define the VIF type for a trigger
707  * @IWL_FW_DBG_CONF_VIF_ANY: any vif type
708  * @IWL_FW_DBG_CONF_VIF_IBSS: IBSS mode
709  * @IWL_FW_DBG_CONF_VIF_STATION: BSS mode
710  * @IWL_FW_DBG_CONF_VIF_AP: AP mode
711  * @IWL_FW_DBG_CONF_VIF_P2P_CLIENT: P2P Client mode
712  * @IWL_FW_DBG_CONF_VIF_P2P_GO: P2P GO mode
713  * @IWL_FW_DBG_CONF_VIF_P2P_DEVICE: P2P device
714  */
715 enum iwl_fw_dbg_trigger_vif_type {
716 	IWL_FW_DBG_CONF_VIF_ANY = NL80211_IFTYPE_UNSPECIFIED,
717 	IWL_FW_DBG_CONF_VIF_IBSS = NL80211_IFTYPE_ADHOC,
718 	IWL_FW_DBG_CONF_VIF_STATION = NL80211_IFTYPE_STATION,
719 	IWL_FW_DBG_CONF_VIF_AP = NL80211_IFTYPE_AP,
720 	IWL_FW_DBG_CONF_VIF_P2P_CLIENT = NL80211_IFTYPE_P2P_CLIENT,
721 	IWL_FW_DBG_CONF_VIF_P2P_GO = NL80211_IFTYPE_P2P_GO,
722 	IWL_FW_DBG_CONF_VIF_P2P_DEVICE = NL80211_IFTYPE_P2P_DEVICE,
723 };
724 
725 /**
726  * struct iwl_fw_dbg_trigger_tlv - a TLV that describes the trigger
727  * @id: &enum iwl_fw_dbg_trigger
728  * @vif_type: &enum iwl_fw_dbg_trigger_vif_type
729  * @stop_conf_ids: bitmap of configurations this trigger relates to.
730  *	if the mode is %IWL_FW_DBG_TRIGGER_STOP, then if the bit corresponding
731  *	to the currently running configuration is set, the data should be
732  *	collected.
733  * @stop_delay: how many milliseconds to wait before collecting the data
734  *	after the STOP trigger fires.
735  * @mode: &enum iwl_fw_dbg_trigger_mode - can be stop / start of both
736  * @start_conf_id: if mode is %IWL_FW_DBG_TRIGGER_START, this defines what
737  *	configuration should be applied when the triggers kicks in.
738  * @occurrences: number of occurrences. 0 means the trigger will never fire.
739  * @trig_dis_ms: the time, in milliseconds, after an occurrence of this
740  *	trigger in which another occurrence should be ignored.
741  * @flags: &enum iwl_fw_dbg_trigger_flags
742  */
743 struct iwl_fw_dbg_trigger_tlv {
744 	__le32 id;
745 	__le32 vif_type;
746 	__le32 stop_conf_ids;
747 	__le32 stop_delay;
748 	u8 mode;
749 	u8 start_conf_id;
750 	__le16 occurrences;
751 	__le16 trig_dis_ms;
752 	u8 flags;
753 	u8 reserved[5];
754 
755 	u8 data[0];
756 } __packed;
757 
758 #define FW_DBG_START_FROM_ALIVE	0
759 #define FW_DBG_CONF_MAX		32
760 #define FW_DBG_INVALID		0xff
761 
762 /**
763  * struct iwl_fw_dbg_trigger_missed_bcon - configures trigger for missed beacons
764  * @stop_consec_missed_bcon: stop recording if threshold is crossed.
765  * @stop_consec_missed_bcon_since_rx: stop recording if threshold is crossed.
766  * @start_consec_missed_bcon: start recording if threshold is crossed.
767  * @start_consec_missed_bcon_since_rx: start recording if threshold is crossed.
768  * @reserved1: reserved
769  * @reserved2: reserved
770  */
771 struct iwl_fw_dbg_trigger_missed_bcon {
772 	__le32 stop_consec_missed_bcon;
773 	__le32 stop_consec_missed_bcon_since_rx;
774 	__le32 reserved2[2];
775 	__le32 start_consec_missed_bcon;
776 	__le32 start_consec_missed_bcon_since_rx;
777 	__le32 reserved1[2];
778 } __packed;
779 
780 /**
781  * struct iwl_fw_dbg_trigger_cmd - configures trigger for messages from FW.
782  * cmds: the list of commands to trigger the collection on
783  */
784 struct iwl_fw_dbg_trigger_cmd {
785 	struct cmd {
786 		u8 cmd_id;
787 		u8 group_id;
788 	} __packed cmds[16];
789 } __packed;
790 
791 /**
792  * iwl_fw_dbg_trigger_stats - configures trigger for statistics
793  * @stop_offset: the offset of the value to be monitored
794  * @stop_threshold: the threshold above which to collect
795  * @start_offset: the offset of the value to be monitored
796  * @start_threshold: the threshold above which to start recording
797  */
798 struct iwl_fw_dbg_trigger_stats {
799 	__le32 stop_offset;
800 	__le32 stop_threshold;
801 	__le32 start_offset;
802 	__le32 start_threshold;
803 } __packed;
804 
805 /**
806  * struct iwl_fw_dbg_trigger_low_rssi - trigger for low beacon RSSI
807  * @rssi: RSSI value to trigger at
808  */
809 struct iwl_fw_dbg_trigger_low_rssi {
810 	__le32 rssi;
811 } __packed;
812 
813 /**
814  * struct iwl_fw_dbg_trigger_mlme - configures trigger for mlme events
815  * @stop_auth_denied: number of denied authentication to collect
816  * @stop_auth_timeout: number of authentication timeout to collect
817  * @stop_rx_deauth: number of Rx deauth before to collect
818  * @stop_tx_deauth: number of Tx deauth before to collect
819  * @stop_assoc_denied: number of denied association to collect
820  * @stop_assoc_timeout: number of association timeout to collect
821  * @stop_connection_loss: number of connection loss to collect
822  * @start_auth_denied: number of denied authentication to start recording
823  * @start_auth_timeout: number of authentication timeout to start recording
824  * @start_rx_deauth: number of Rx deauth to start recording
825  * @start_tx_deauth: number of Tx deauth to start recording
826  * @start_assoc_denied: number of denied association to start recording
827  * @start_assoc_timeout: number of association timeout to start recording
828  * @start_connection_loss: number of connection loss to start recording
829  */
830 struct iwl_fw_dbg_trigger_mlme {
831 	u8 stop_auth_denied;
832 	u8 stop_auth_timeout;
833 	u8 stop_rx_deauth;
834 	u8 stop_tx_deauth;
835 
836 	u8 stop_assoc_denied;
837 	u8 stop_assoc_timeout;
838 	u8 stop_connection_loss;
839 	u8 reserved;
840 
841 	u8 start_auth_denied;
842 	u8 start_auth_timeout;
843 	u8 start_rx_deauth;
844 	u8 start_tx_deauth;
845 
846 	u8 start_assoc_denied;
847 	u8 start_assoc_timeout;
848 	u8 start_connection_loss;
849 	u8 reserved2;
850 } __packed;
851 
852 /**
853  * struct iwl_fw_dbg_trigger_txq_timer - configures the Tx queue's timer
854  * @command_queue: timeout for the command queue in ms
855  * @bss: timeout for the queues of a BSS (except for TDLS queues) in ms
856  * @softap: timeout for the queues of a softAP in ms
857  * @p2p_go: timeout for the queues of a P2P GO in ms
858  * @p2p_client: timeout for the queues of a P2P client in ms
859  * @p2p_device: timeout for the queues of a P2P device in ms
860  * @ibss: timeout for the queues of an IBSS in ms
861  * @tdls: timeout for the queues of a TDLS station in ms
862  */
863 struct iwl_fw_dbg_trigger_txq_timer {
864 	__le32 command_queue;
865 	__le32 bss;
866 	__le32 softap;
867 	__le32 p2p_go;
868 	__le32 p2p_client;
869 	__le32 p2p_device;
870 	__le32 ibss;
871 	__le32 tdls;
872 	__le32 reserved[4];
873 } __packed;
874 
875 /**
876  * struct iwl_fw_dbg_trigger_time_event - configures a time event trigger
877  * time_Events: a list of tuples <id, action_bitmap>. The driver will issue a
878  *	trigger each time a time event notification that relates to time event
879  *	id with one of the actions in the bitmap is received and
880  *	BIT(notif->status) is set in status_bitmap.
881  *
882  */
883 struct iwl_fw_dbg_trigger_time_event {
884 	struct {
885 		__le32 id;
886 		__le32 action_bitmap;
887 		__le32 status_bitmap;
888 	} __packed time_events[16];
889 } __packed;
890 
891 /**
892  * struct iwl_fw_dbg_trigger_ba - configures BlockAck related trigger
893  * rx_ba_start: tid bitmap to configure on what tid the trigger should occur
894  *	when an Rx BlockAck session is started.
895  * rx_ba_stop: tid bitmap to configure on what tid the trigger should occur
896  *	when an Rx BlockAck session is stopped.
897  * tx_ba_start: tid bitmap to configure on what tid the trigger should occur
898  *	when a Tx BlockAck session is started.
899  * tx_ba_stop: tid bitmap to configure on what tid the trigger should occur
900  *	when a Tx BlockAck session is stopped.
901  * rx_bar: tid bitmap to configure on what tid the trigger should occur
902  *	when a BAR is received (for a Tx BlockAck session).
903  * tx_bar: tid bitmap to configure on what tid the trigger should occur
904  *	when a BAR is send (for an Rx BlocAck session).
905  * frame_timeout: tid bitmap to configure on what tid the trigger should occur
906  *	when a frame times out in the reodering buffer.
907  */
908 struct iwl_fw_dbg_trigger_ba {
909 	__le16 rx_ba_start;
910 	__le16 rx_ba_stop;
911 	__le16 tx_ba_start;
912 	__le16 tx_ba_stop;
913 	__le16 rx_bar;
914 	__le16 tx_bar;
915 	__le16 frame_timeout;
916 } __packed;
917 
918 /**
919  * struct iwl_fw_dbg_trigger_tdls - configures trigger for TDLS events.
920  * @action_bitmap: the TDLS action to trigger the collection upon
921  * @peer_mode: trigger on specific peer or all
922  * @peer: the TDLS peer to trigger the collection on
923  */
924 struct iwl_fw_dbg_trigger_tdls {
925 	u8 action_bitmap;
926 	u8 peer_mode;
927 	u8 peer[ETH_ALEN];
928 	u8 reserved[4];
929 } __packed;
930 
931 /**
932  * struct iwl_fw_dbg_trigger_tx_status - configures trigger for tx response
933  *  status.
934  * @statuses: the list of statuses to trigger the collection on
935  */
936 struct iwl_fw_dbg_trigger_tx_status {
937 	struct tx_status {
938 		u8 status;
939 		u8 reserved[3];
940 	} __packed statuses[16];
941 	__le32 reserved[2];
942 } __packed;
943 
944 /**
945  * struct iwl_fw_dbg_conf_tlv - a TLV that describes a debug configuration.
946  * @id: conf id
947  * @usniffer: should the uSniffer image be used
948  * @num_of_hcmds: how many HCMDs to send are present here
949  * @hcmd: a variable length host command to be sent to apply the configuration.
950  *	If there is more than one HCMD to send, they will appear one after the
951  *	other and be sent in the order that they appear in.
952  * This parses IWL_UCODE_TLV_FW_DBG_CONF. The user can add up-to
953  * %FW_DBG_CONF_MAX configuration per run.
954  */
955 struct iwl_fw_dbg_conf_tlv {
956 	u8 id;
957 	u8 usniffer;
958 	u8 reserved;
959 	u8 num_of_hcmds;
960 	struct iwl_fw_dbg_conf_hcmd hcmd;
961 } __packed;
962 
963 #define IWL_FW_CMD_VER_UNKNOWN 99
964 
965 /**
966  * struct iwl_fw_cmd_version - firmware command version entry
967  * @cmd: command ID
968  * @group: group ID
969  * @cmd_ver: command version
970  * @notif_ver: notification version
971  */
972 struct iwl_fw_cmd_version {
973 	u8 cmd;
974 	u8 group;
975 	u8 cmd_ver;
976 	u8 notif_ver;
977 } __packed;
978 
_iwl_tlv_array_len(const struct iwl_ucode_tlv * tlv,size_t fixed_size,size_t var_size)979 static inline size_t _iwl_tlv_array_len(const struct iwl_ucode_tlv *tlv,
980 					size_t fixed_size, size_t var_size)
981 {
982 	size_t var_len = le32_to_cpu(tlv->length) - fixed_size;
983 
984 	if (WARN_ON(var_len % var_size))
985 		return 0;
986 
987 	return var_len / var_size;
988 }
989 
990 #define iwl_tlv_array_len(_tlv_ptr, _struct_ptr, _memb)			\
991 	_iwl_tlv_array_len((_tlv_ptr), sizeof(*(_struct_ptr)),		\
992 			   sizeof(_struct_ptr->_memb[0]))
993 
994 #endif  /* __iwl_fw_file_h__ */
995