xref: /freebsd/sys/contrib/dev/iwlwifi/fw/api/location.h (revision 4f8f43b06ed07e96a250855488cc531799d5b78f)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2015-2017 Intel Deutschland GmbH
4  * Copyright (C) 2018-2022 Intel Corporation
5  */
6 #ifndef __iwl_fw_api_location_h__
7 #define __iwl_fw_api_location_h__
8 
9 /**
10  * enum iwl_location_subcmd_ids - location group command IDs
11  */
12 enum iwl_location_subcmd_ids {
13 	/**
14 	 * @TOF_RANGE_REQ_CMD: TOF ranging request,
15 	 *	uses one of &struct iwl_tof_range_req_cmd_v5,
16 	 *	&struct iwl_tof_range_req_cmd_v7,
17 	 *	&struct iwl_tof_range_req_cmd_v8,
18 	 *	&struct iwl_tof_range_req_cmd_v9,
19 	 *	&struct iwl_tof_range_req_cmd_v11,
20 	 *	&struct iwl_tof_range_req_cmd_v7
21 	 */
22 	TOF_RANGE_REQ_CMD = 0x0,
23 	/**
24 	 * @TOF_CONFIG_CMD: TOF configuration, uses &struct iwl_tof_config_cmd
25 	 */
26 	TOF_CONFIG_CMD = 0x1,
27 	/**
28 	 * @TOF_RANGE_ABORT_CMD: abort ongoing ranging, uses
29 	 *	&struct iwl_tof_range_abort_cmd
30 	 */
31 	TOF_RANGE_ABORT_CMD = 0x2,
32 	/**
33 	 * @TOF_RANGE_REQ_EXT_CMD: TOF extended ranging config,
34 	 *	uses &struct iwl_tof_range_req_ext_cmd
35 	 */
36 	TOF_RANGE_REQ_EXT_CMD = 0x3,
37 	/**
38 	 * @TOF_RESPONDER_CONFIG_CMD: FTM responder configuration, one of
39 	 *	&struct iwl_tof_responder_config_cmd_v6,
40 	 *	&struct iwl_tof_responder_config_cmd_v7,
41 	 *	&struct iwl_tof_responder_config_cmd_v8 or
42 	 *	&struct iwl_tof_responder_config_cmd_v9
43 	 */
44 	TOF_RESPONDER_CONFIG_CMD = 0x4,
45 	/**
46 	 * @TOF_RESPONDER_DYN_CONFIG_CMD: FTM dynamic configuration,
47 	 *	uses &struct iwl_tof_responder_dyn_config_cmd
48 	 */
49 	TOF_RESPONDER_DYN_CONFIG_CMD = 0x5,
50 	/**
51 	 * @CSI_HEADER_NOTIFICATION: CSI header
52 	 */
53 	CSI_HEADER_NOTIFICATION = 0xFA,
54 	/**
55 	 * @CSI_CHUNKS_NOTIFICATION: CSI chunk,
56 	 *	uses &struct iwl_csi_chunk_notification
57 	 */
58 	CSI_CHUNKS_NOTIFICATION = 0xFB,
59 	/**
60 	 * @TOF_LC_NOTIF: used for LCI/civic location, contains just
61 	 *	the action frame
62 	 */
63 	TOF_LC_NOTIF = 0xFC,
64 	/**
65 	 * @TOF_RESPONDER_STATS: FTM responder statistics notification,
66 	 *	uses &struct iwl_ftm_responder_stats
67 	 */
68 	TOF_RESPONDER_STATS = 0xFD,
69 	/**
70 	 * @TOF_MCSI_DEBUG_NOTIF: MCSI debug notification, uses
71 	 *	&struct iwl_tof_mcsi_notif
72 	 */
73 	TOF_MCSI_DEBUG_NOTIF = 0xFE,
74 	/**
75 	 * @TOF_RANGE_RESPONSE_NOTIF: ranging response, using one of
76 	 *	&struct iwl_tof_range_rsp_ntfy_v5,
77 	 *	&struct iwl_tof_range_rsp_ntfy_v6,
78 	 *	&struct iwl_tof_range_rsp_ntfy_v7 or
79 	 *	&struct iwl_tof_range_rsp_ntfy_v8
80 	 */
81 	TOF_RANGE_RESPONSE_NOTIF = 0xFF,
82 };
83 
84 /**
85  * struct iwl_tof_config_cmd - ToF configuration
86  * @tof_disabled: indicates if ToF is disabled (or not)
87  * @one_sided_disabled: indicates if one-sided is disabled (or not)
88  * @is_debug_mode: indiciates if debug mode is active
89  * @is_buf_required: indicates if channel estimation buffer is required
90  */
91 struct iwl_tof_config_cmd {
92 	u8 tof_disabled;
93 	u8 one_sided_disabled;
94 	u8 is_debug_mode;
95 	u8 is_buf_required;
96 } __packed;
97 
98 /**
99  * enum iwl_tof_bandwidth - values for iwl_tof_range_req_ap_entry.bandwidth
100  * @IWL_TOF_BW_20_LEGACY: 20 MHz non-HT
101  * @IWL_TOF_BW_20_HT: 20 MHz HT
102  * @IWL_TOF_BW_40: 40 MHz
103  * @IWL_TOF_BW_80: 80 MHz
104  * @IWL_TOF_BW_160: 160 MHz
105  * @IWL_TOF_BW_NUM: number of tof bandwidths
106  */
107 enum iwl_tof_bandwidth {
108 	IWL_TOF_BW_20_LEGACY,
109 	IWL_TOF_BW_20_HT,
110 	IWL_TOF_BW_40,
111 	IWL_TOF_BW_80,
112 	IWL_TOF_BW_160,
113 	IWL_TOF_BW_NUM,
114 }; /* LOCAT_BW_TYPE_E */
115 
116 /*
117  * enum iwl_tof_algo_type - Algorithym type for range measurement request
118  */
119 enum iwl_tof_algo_type {
120 	IWL_TOF_ALGO_TYPE_MAX_LIKE	= 0,
121 	IWL_TOF_ALGO_TYPE_LINEAR_REG	= 1,
122 	IWL_TOF_ALGO_TYPE_FFT		= 2,
123 
124 	/* Keep last */
125 	IWL_TOF_ALGO_TYPE_INVALID,
126 }; /* ALGO_TYPE_E */
127 
128 /*
129  * enum iwl_tof_mcsi_ntfy - Enable/Disable MCSI notifications
130  */
131 enum iwl_tof_mcsi_enable {
132 	IWL_TOF_MCSI_DISABLED = 0,
133 	IWL_TOF_MCSI_ENABLED = 1,
134 }; /* MCSI_ENABLE_E */
135 
136 /**
137  * enum iwl_tof_responder_cmd_valid_field - valid fields in the responder cfg
138  * @IWL_TOF_RESPONDER_CMD_VALID_CHAN_INFO: channel info is valid
139  * @IWL_TOF_RESPONDER_CMD_VALID_TOA_OFFSET: ToA offset is valid
140  * @IWL_TOF_RESPONDER_CMD_VALID_COMMON_CALIB: common calibration mode is valid
141  * @IWL_TOF_RESPONDER_CMD_VALID_SPECIFIC_CALIB: spefici calibration mode is
142  *	valid
143  * @IWL_TOF_RESPONDER_CMD_VALID_BSSID: BSSID is valid
144  * @IWL_TOF_RESPONDER_CMD_VALID_TX_ANT: TX antenna is valid
145  * @IWL_TOF_RESPONDER_CMD_VALID_ALGO_TYPE: algorithm type is valid
146  * @IWL_TOF_RESPONDER_CMD_VALID_NON_ASAP_SUPPORT: non-ASAP support is valid
147  * @IWL_TOF_RESPONDER_CMD_VALID_STATISTICS_REPORT_SUPPORT: statistics report
148  *	support is valid
149  * @IWL_TOF_RESPONDER_CMD_VALID_MCSI_NOTIF_SUPPORT: MCSI notification support
150  *	is valid
151  * @IWL_TOF_RESPONDER_CMD_VALID_FAST_ALGO_SUPPORT: fast algorithm support
152  *	is valid
153  * @IWL_TOF_RESPONDER_CMD_VALID_RETRY_ON_ALGO_FAIL: retry on algorithm failure
154  *	is valid
155  * @IWL_TOF_RESPONDER_CMD_VALID_STA_ID: station ID is valid
156  * @IWL_TOF_RESPONDER_CMD_VALID_NDP_SUPPORT: enable/disable NDP ranging support
157  *	is valid
158  * @IWL_TOF_RESPONDER_CMD_VALID_NDP_PARAMS: NDP parameters are valid
159  * @IWL_TOF_RESPONDER_CMD_VALID_LMR_FEEDBACK: LMR feedback support is valid
160  * @IWL_TOF_RESPONDER_CMD_VALID_SESSION_ID: session id flag is valid
161  * @IWL_TOF_RESPONDER_CMD_VALID_BSS_COLOR: the bss_color field is valid
162  * @IWL_TOF_RESPONDER_CMD_VALID_MIN_MAX_TIME_BETWEEN_MSR: the
163  *	min_time_between_msr and max_time_between_msr fields are valid
164  */
165 enum iwl_tof_responder_cmd_valid_field {
166 	IWL_TOF_RESPONDER_CMD_VALID_CHAN_INFO = BIT(0),
167 	IWL_TOF_RESPONDER_CMD_VALID_TOA_OFFSET = BIT(1),
168 	IWL_TOF_RESPONDER_CMD_VALID_COMMON_CALIB = BIT(2),
169 	IWL_TOF_RESPONDER_CMD_VALID_SPECIFIC_CALIB = BIT(3),
170 	IWL_TOF_RESPONDER_CMD_VALID_BSSID = BIT(4),
171 	IWL_TOF_RESPONDER_CMD_VALID_TX_ANT = BIT(5),
172 	IWL_TOF_RESPONDER_CMD_VALID_ALGO_TYPE = BIT(6),
173 	IWL_TOF_RESPONDER_CMD_VALID_NON_ASAP_SUPPORT = BIT(7),
174 	IWL_TOF_RESPONDER_CMD_VALID_STATISTICS_REPORT_SUPPORT = BIT(8),
175 	IWL_TOF_RESPONDER_CMD_VALID_MCSI_NOTIF_SUPPORT = BIT(9),
176 	IWL_TOF_RESPONDER_CMD_VALID_FAST_ALGO_SUPPORT = BIT(10),
177 	IWL_TOF_RESPONDER_CMD_VALID_RETRY_ON_ALGO_FAIL = BIT(11),
178 	IWL_TOF_RESPONDER_CMD_VALID_STA_ID = BIT(12),
179 	IWL_TOF_RESPONDER_CMD_VALID_NDP_SUPPORT = BIT(22),
180 	IWL_TOF_RESPONDER_CMD_VALID_NDP_PARAMS = BIT(23),
181 	IWL_TOF_RESPONDER_CMD_VALID_LMR_FEEDBACK = BIT(24),
182 	IWL_TOF_RESPONDER_CMD_VALID_SESSION_ID = BIT(25),
183 	IWL_TOF_RESPONDER_CMD_VALID_BSS_COLOR = BIT(26),
184 	IWL_TOF_RESPONDER_CMD_VALID_MIN_MAX_TIME_BETWEEN_MSR = BIT(27),
185 };
186 
187 /**
188  * enum iwl_tof_responder_cfg_flags - responder configuration flags
189  * @IWL_TOF_RESPONDER_FLAGS_NON_ASAP_SUPPORT: non-ASAP support
190  * @IWL_TOF_RESPONDER_FLAGS_REPORT_STATISTICS: report statistics
191  * @IWL_TOF_RESPONDER_FLAGS_REPORT_MCSI: report MCSI
192  * @IWL_TOF_RESPONDER_FLAGS_ALGO_TYPE: algorithm type
193  * @IWL_TOF_RESPONDER_FLAGS_TOA_OFFSET_MODE: ToA offset mode
194  * @IWL_TOF_RESPONDER_FLAGS_COMMON_CALIB_MODE: common calibration mode
195  * @IWL_TOF_RESPONDER_FLAGS_SPECIFIC_CALIB_MODE: specific calibration mode
196  * @IWL_TOF_RESPONDER_FLAGS_FAST_ALGO_SUPPORT: fast algorithm support
197  * @IWL_TOF_RESPONDER_FLAGS_RETRY_ON_ALGO_FAIL: retry on algorithm fail
198  * @IWL_TOF_RESPONDER_FLAGS_FTM_TX_ANT: TX antenna mask
199  * @IWL_TOF_RESPONDER_FLAGS_NDP_SUPPORT: support NDP ranging
200  * @IWL_TOF_RESPONDER_FLAGS_LMR_FEEDBACK: request for LMR feedback if the
201  *	initiator supports it
202  * @IWL_TOF_RESPONDER_FLAGS_SESSION_ID: send the session id in the initial FTM
203  *	frame.
204  */
205 enum iwl_tof_responder_cfg_flags {
206 	IWL_TOF_RESPONDER_FLAGS_NON_ASAP_SUPPORT = BIT(0),
207 	IWL_TOF_RESPONDER_FLAGS_REPORT_STATISTICS = BIT(1),
208 	IWL_TOF_RESPONDER_FLAGS_REPORT_MCSI = BIT(2),
209 	IWL_TOF_RESPONDER_FLAGS_ALGO_TYPE = BIT(3) | BIT(4) | BIT(5),
210 	IWL_TOF_RESPONDER_FLAGS_TOA_OFFSET_MODE = BIT(6),
211 	IWL_TOF_RESPONDER_FLAGS_COMMON_CALIB_MODE = BIT(7),
212 	IWL_TOF_RESPONDER_FLAGS_SPECIFIC_CALIB_MODE = BIT(8),
213 	IWL_TOF_RESPONDER_FLAGS_FAST_ALGO_SUPPORT = BIT(9),
214 	IWL_TOF_RESPONDER_FLAGS_RETRY_ON_ALGO_FAIL = BIT(10),
215 	IWL_TOF_RESPONDER_FLAGS_FTM_TX_ANT = RATE_MCS_ANT_AB_MSK,
216 	IWL_TOF_RESPONDER_FLAGS_NDP_SUPPORT = BIT(24),
217 	IWL_TOF_RESPONDER_FLAGS_LMR_FEEDBACK = BIT(25),
218 	IWL_TOF_RESPONDER_FLAGS_SESSION_ID = BIT(27),
219 };
220 
221 /**
222  * struct iwl_tof_responder_config_cmd_v6 - ToF AP mode (for debug)
223  * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
224  * @responder_cfg_flags: &iwl_tof_responder_cfg_flags
225  * @bandwidth: current AP Bandwidth: &enum iwl_tof_bandwidth
226  * @rate: current AP rate
227  * @channel_num: current AP Channel
228  * @ctrl_ch_position: coding of the control channel position relative to
229  *	the center frequency, see iwl_mvm_get_ctrl_pos()
230  * @sta_id: index of the AP STA when in AP mode
231  * @reserved1: reserved
232  * @toa_offset: Artificial addition [pSec] for the ToA - to be used for debug
233  *	purposes, simulating station movement by adding various values
234  *	to this field
235  * @common_calib: XVT: common calibration value
236  * @specific_calib: XVT: specific calibration value
237  * @bssid: Current AP BSSID
238  * @reserved2: reserved
239  */
240 struct iwl_tof_responder_config_cmd_v6 {
241 	__le32 cmd_valid_fields;
242 	__le32 responder_cfg_flags;
243 	u8 bandwidth;
244 	u8 rate;
245 	u8 channel_num;
246 	u8 ctrl_ch_position;
247 	u8 sta_id;
248 	u8 reserved1;
249 	__le16 toa_offset;
250 	__le16 common_calib;
251 	__le16 specific_calib;
252 	u8 bssid[ETH_ALEN];
253 	__le16 reserved2;
254 } __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_6 */
255 
256 /**
257  * struct iwl_tof_responder_config_cmd_v7 - ToF AP mode (for debug)
258  * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
259  * @responder_cfg_flags: &iwl_tof_responder_cfg_flags
260  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
261  *             bits 4 - 7: &enum iwl_location_bw.
262  * @rate: current AP rate
263  * @channel_num: current AP Channel
264  * @ctrl_ch_position: coding of the control channel position relative to
265  *	the center frequency, see iwl_mvm_get_ctrl_pos()
266  * @sta_id: index of the AP STA when in AP mode
267  * @reserved1: reserved
268  * @toa_offset: Artificial addition [pSec] for the ToA - to be used for debug
269  *	purposes, simulating station movement by adding various values
270  *	to this field
271  * @common_calib: XVT: common calibration value
272  * @specific_calib: XVT: specific calibration value
273  * @bssid: Current AP BSSID
274  * @reserved2: reserved
275  */
276 struct iwl_tof_responder_config_cmd_v7 {
277 	__le32 cmd_valid_fields;
278 	__le32 responder_cfg_flags;
279 	u8 format_bw;
280 	u8 rate;
281 	u8 channel_num;
282 	u8 ctrl_ch_position;
283 	u8 sta_id;
284 	u8 reserved1;
285 	__le16 toa_offset;
286 	__le16 common_calib;
287 	__le16 specific_calib;
288 	u8 bssid[ETH_ALEN];
289 	__le16 reserved2;
290 } __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_7 */
291 
292 #define IWL_RESPONDER_STS_POS	3
293 #define IWL_RESPONDER_TOTAL_LTF_POS	6
294 
295 /**
296  * struct iwl_tof_responder_config_cmd_v8 - ToF AP mode (for debug)
297  * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
298  * @responder_cfg_flags: &iwl_tof_responder_cfg_flags
299  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
300  *             bits 4 - 7: &enum iwl_location_bw.
301  * @rate: current AP rate
302  * @channel_num: current AP Channel
303  * @ctrl_ch_position: coding of the control channel position relative to
304  *	the center frequency, see iwl_mvm_get_ctrl_pos()
305  * @sta_id: index of the AP STA when in AP mode
306  * @reserved1: reserved
307  * @toa_offset: Artificial addition [pSec] for the ToA - to be used for debug
308  *	purposes, simulating station movement by adding various values
309  *	to this field
310  * @common_calib: XVT: common calibration value
311  * @specific_calib: XVT: specific calibration value
312  * @bssid: Current AP BSSID
313  * @r2i_ndp_params: parameters for R2I NDP.
314  *	bits 0 - 2: max number of LTF repetitions
315  *	bits 3 - 5: max number of spatial streams (supported values are < 2)
316  *	bits 6 - 7: max number of total LTFs see
317  *	&enum ieee80211_range_params_max_total_ltf
318  * @i2r_ndp_params: parameters for I2R NDP.
319  *	bits 0 - 2: max number of LTF repetitions
320  *	bits 3 - 5: max number of spatial streams
321  *	bits 6 - 7: max number of total LTFs see
322  *	&enum ieee80211_range_params_max_total_ltf
323  */
324 struct iwl_tof_responder_config_cmd_v8 {
325 	__le32 cmd_valid_fields;
326 	__le32 responder_cfg_flags;
327 	u8 format_bw;
328 	u8 rate;
329 	u8 channel_num;
330 	u8 ctrl_ch_position;
331 	u8 sta_id;
332 	u8 reserved1;
333 	__le16 toa_offset;
334 	__le16 common_calib;
335 	__le16 specific_calib;
336 	u8 bssid[ETH_ALEN];
337 	u8 r2i_ndp_params;
338 	u8 i2r_ndp_params;
339 } __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_8 */
340 
341 /**
342  * struct iwl_tof_responder_config_cmd_v9 - ToF AP mode (for debug)
343  * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
344  * @responder_cfg_flags: &iwl_tof_responder_cfg_flags
345  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
346  *             bits 4 - 7: &enum iwl_location_bw.
347  * @bss_color: current AP bss_color
348  * @channel_num: current AP Channel
349  * @ctrl_ch_position: coding of the control channel position relative to
350  *	the center frequency, see iwl_mvm_get_ctrl_pos()
351  * @sta_id: index of the AP STA when in AP mode
352  * @reserved1: reserved
353  * @toa_offset: Artificial addition [pSec] for the ToA - to be used for debug
354  *	purposes, simulating station movement by adding various values
355  *	to this field
356  * @common_calib: XVT: common calibration value
357  * @specific_calib: XVT: specific calibration value
358  * @bssid: Current AP BSSID
359  * @r2i_ndp_params: parameters for R2I NDP.
360  *	bits 0 - 2: max number of LTF repetitions
361  *	bits 3 - 5: max number of spatial streams (supported values are < 2)
362  *	bits 6 - 7: max number of total LTFs see
363  *	&enum ieee80211_range_params_max_total_ltf
364  * @i2r_ndp_params: parameters for I2R NDP.
365  *	bits 0 - 2: max number of LTF repetitions
366  *	bits 3 - 5: max number of spatial streams
367  *	bits 6 - 7: max number of total LTFs see
368  *	&enum ieee80211_range_params_max_total_ltf
369  * @min_time_between_msr: for non trigger based NDP ranging, minimum time
370  *	between measurements in milliseconds.
371  * @max_time_between_msr: for non trigger based NDP ranging, maximum time
372  *	between measurements in milliseconds.
373  */
374 struct iwl_tof_responder_config_cmd_v9 {
375 	__le32 cmd_valid_fields;
376 	__le32 responder_cfg_flags;
377 	u8 format_bw;
378 	u8 bss_color;
379 	u8 channel_num;
380 	u8 ctrl_ch_position;
381 	u8 sta_id;
382 	u8 reserved1;
383 	__le16 toa_offset;
384 	__le16 common_calib;
385 	__le16 specific_calib;
386 	u8 bssid[ETH_ALEN];
387 	u8 r2i_ndp_params;
388 	u8 i2r_ndp_params;
389 	__le16 min_time_between_msr;
390 	__le16 max_time_between_msr;
391 } __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_8 */
392 
393 #define IWL_LCI_CIVIC_IE_MAX_SIZE	400
394 
395 /**
396  * struct iwl_tof_responder_dyn_config_cmd - Dynamic responder settings
397  * @lci_len: The length of the 1st (LCI) part in the @lci_civic buffer
398  * @civic_len: The length of the 2nd (CIVIC) part in the @lci_civic buffer
399  * @lci_civic: The LCI/CIVIC buffer. LCI data (if exists) comes first, then, if
400  *	needed, 0-padding such that the next part is dword-aligned, then CIVIC
401  *	data (if exists) follows, and then 0-padding again to complete a
402  *	4-multiple long buffer.
403  */
404 struct iwl_tof_responder_dyn_config_cmd_v2 {
405 	__le32 lci_len;
406 	__le32 civic_len;
407 	u8 lci_civic[];
408 } __packed; /* TOF_RESPONDER_DYN_CONFIG_CMD_API_S_VER_2 */
409 
410 #define IWL_LCI_MAX_SIZE	160
411 #define IWL_CIVIC_MAX_SIZE	160
412 #define HLTK_11AZ_LEN	32
413 
414 /**
415  * enum iwl_responder_dyn_cfg_valid_flags - valid flags for dyn_config_cmd
416  * @IWL_RESPONDER_DYN_CFG_VALID_LCI: LCI data is valid
417  * @IWL_RESPONDER_DYN_CFG_VALID_CIVIC: Civic data is valid
418  * @IWL_RESPONDER_DYN_CFG_VALID_PASN_STA: the pasn_addr, HLTK and cipher fields
419  *	are valid.
420  */
421 enum iwl_responder_dyn_cfg_valid_flags {
422 	IWL_RESPONDER_DYN_CFG_VALID_LCI = BIT(0),
423 	IWL_RESPONDER_DYN_CFG_VALID_CIVIC = BIT(1),
424 	IWL_RESPONDER_DYN_CFG_VALID_PASN_STA = BIT(2),
425 };
426 
427 /**
428  * struct iwl_tof_responder_dyn_config_cmd - Dynamic responder settings
429  * @cipher: The negotiated cipher. see &enum iwl_location_cipher.
430  * @valid_flags: flags indicating which fields in the command are valid. see
431  *	&enum iwl_responder_dyn_cfg_valid_flags.
432  * @lci_len: length of the LCI data in bytes
433  * @civic_len: length of the Civic data in bytes
434  * @lci_buf: the LCI buffer
435  * @civic_buf: the Civic buffer
436  * @hltk_buf: HLTK for secure LTF bits generation for the specified station
437  * @addr: mac address of the station for which to use the HLTK
438  * @reserved: for alignment
439  */
440 struct iwl_tof_responder_dyn_config_cmd {
441 	u8 cipher;
442 	u8 valid_flags;
443 	u8 lci_len;
444 	u8 civic_len;
445 	u8 lci_buf[IWL_LCI_MAX_SIZE];
446 	u8 civic_buf[IWL_LCI_MAX_SIZE];
447 	u8 hltk_buf[HLTK_11AZ_LEN];
448 	u8 addr[ETH_ALEN];
449 	u8 reserved[2];
450 } __packed; /* TOF_RESPONDER_DYN_CONFIG_CMD_API_S_VER_3 */
451 
452 /**
453  * struct iwl_tof_range_req_ext_cmd - extended range req for WLS
454  * @tsf_timer_offset_msec: the recommended time offset (mSec) from the AP's TSF
455  * @reserved: reserved
456  * @min_delta_ftm: Minimal time between two consecutive measurements,
457  *		   in units of 100us. 0 means no preference by station
458  * @ftm_format_and_bw20M: FTM Channel Spacing/Format for 20MHz: recommended
459  *			value be sent to the AP
460  * @ftm_format_and_bw40M: FTM Channel Spacing/Format for 40MHz: recommended
461  *			value to be sent to the AP
462  * @ftm_format_and_bw80M: FTM Channel Spacing/Format for 80MHz: recommended
463  *			value to be sent to the AP
464  */
465 struct iwl_tof_range_req_ext_cmd {
466 	__le16 tsf_timer_offset_msec;
467 	__le16 reserved;
468 	u8 min_delta_ftm;
469 	u8 ftm_format_and_bw20M;
470 	u8 ftm_format_and_bw40M;
471 	u8 ftm_format_and_bw80M;
472 } __packed;
473 
474 /**
475  * enum iwl_tof_location_query - values for query bitmap
476  * @IWL_TOF_LOC_LCI: query LCI
477  * @IWL_TOF_LOC_CIVIC: query civic
478  */
479 enum iwl_tof_location_query {
480 	IWL_TOF_LOC_LCI = 0x01,
481 	IWL_TOF_LOC_CIVIC = 0x02,
482 };
483 
484  /**
485  * struct iwl_tof_range_req_ap_entry_v2 - AP configuration parameters
486  * @channel_num: Current AP Channel
487  * @bandwidth: Current AP Bandwidth. One of iwl_tof_bandwidth.
488  * @tsf_delta_direction: TSF relatively to the subject AP
489  * @ctrl_ch_position: Coding of the control channel position relative to the
490  *	center frequency, see iwl_mvm_get_ctrl_pos().
491  * @bssid: AP's BSSID
492  * @measure_type: Measurement type: 0 - two sided, 1 - One sided
493  * @num_of_bursts: Recommended value to be sent to the AP.  2s Exponent of the
494  *	number of measurement iterations (min 2^0 = 1, max 2^14)
495  * @burst_period: Recommended value to be sent to the AP. Measurement
496  *	periodicity In units of 100ms. ignored if num_of_bursts = 0
497  * @samples_per_burst: 2-sided: the number of FTMs pairs in single Burst (1-31);
498  *	1-sided: how many rts/cts pairs should be used per burst.
499  * @retries_per_sample: Max number of retries that the LMAC should send
500  *	in case of no replies by the AP.
501  * @tsf_delta: TSF Delta in units of microseconds.
502  *	The difference between the AP TSF and the device local clock.
503  * @location_req: Location Request Bit[0] LCI should be sent in the FTMR;
504  *	Bit[1] Civic should be sent in the FTMR
505  * @asap_mode: 0 - non asap mode, 1 - asap mode (not relevant for one sided)
506  * @enable_dyn_ack: Enable Dynamic ACK BW.
507  *	0: Initiator interact with regular AP;
508  *	1: Initiator interact with Responder machine: need to send the
509  *	Initiator Acks with HT 40MHz / 80MHz, since the Responder should
510  *	use it for its ch est measurement (this flag will be set when we
511  *	configure the opposite machine to be Responder).
512  * @rssi: Last received value
513  *	legal values: -128-0 (0x7f). above 0x0 indicating an invalid value.
514  * @algo_type: &enum iwl_tof_algo_type
515  * @notify_mcsi: &enum iwl_tof_mcsi_ntfy.
516  * @reserved: For alignment and future use
517  */
518 struct iwl_tof_range_req_ap_entry_v2 {
519 	u8 channel_num;
520 	u8 bandwidth;
521 	u8 tsf_delta_direction;
522 	u8 ctrl_ch_position;
523 	u8 bssid[ETH_ALEN];
524 	u8 measure_type;
525 	u8 num_of_bursts;
526 	__le16 burst_period;
527 	u8 samples_per_burst;
528 	u8 retries_per_sample;
529 	__le32 tsf_delta;
530 	u8 location_req;
531 	u8 asap_mode;
532 	u8 enable_dyn_ack;
533 	s8 rssi;
534 	u8 algo_type;
535 	u8 notify_mcsi;
536 	__le16 reserved;
537 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_2 */
538 
539 /**
540  * enum iwl_initiator_ap_flags - per responder FTM configuration flags
541  * @IWL_INITIATOR_AP_FLAGS_ASAP: Request for ASAP measurement.
542  * @IWL_INITIATOR_AP_FLAGS_LCI_REQUEST: Request for LCI information
543  * @IWL_INITIATOR_AP_FLAGS_CIVIC_REQUEST: Request for CIVIC information
544  * @IWL_INITIATOR_AP_FLAGS_DYN_ACK: Send HT/VHT ack for FTM frames. If not set,
545  *	20Mhz dup acks will be sent.
546  * @IWL_INITIATOR_AP_FLAGS_ALGO_LR: Use LR algo type for rtt calculation.
547  *	Default algo type is ML.
548  * @IWL_INITIATOR_AP_FLAGS_ALGO_FFT: Use FFT algo type for rtt calculation.
549  *	Default algo type is ML.
550  * @IWL_INITIATOR_AP_FLAGS_MCSI_REPORT: Send the MCSI for each FTM frame to the
551  *	driver.
552  * @IWL_INITIATOR_AP_FLAGS_NON_TB: Use non trigger based flow
553  * @IWL_INITIATOR_AP_FLAGS_TB: Use trigger based flow
554  * @IWL_INITIATOR_AP_FLAGS_SECURED: request secure LTF measurement
555  * @IWL_INITIATOR_AP_FLAGS_LMR_FEEDBACK: Send LMR feedback
556  * @IWL_INITIATOR_AP_FLAGS_USE_CALIB: Use calibration values from the request
557  *      instead of fw internal values.
558  * @IWL_INITIATOR_AP_FLAGS_PMF: request to protect the negotiation and LMR
559  *      frames with protected management frames.
560  * @IWL_INITIATOR_AP_FLAGS_TERMINATE_ON_LMR_FEEDBACK: terminate the session if
561  *	the responder asked for LMR feedback although the initiator did not set
562  *	the LMR feedback bit in the FTM request. If not set, the initiator will
563  *	continue with the session and will provide the LMR feedback.
564  */
565 enum iwl_initiator_ap_flags {
566 	IWL_INITIATOR_AP_FLAGS_ASAP = BIT(1),
567 	IWL_INITIATOR_AP_FLAGS_LCI_REQUEST = BIT(2),
568 	IWL_INITIATOR_AP_FLAGS_CIVIC_REQUEST = BIT(3),
569 	IWL_INITIATOR_AP_FLAGS_DYN_ACK = BIT(4),
570 	IWL_INITIATOR_AP_FLAGS_ALGO_LR = BIT(5),
571 	IWL_INITIATOR_AP_FLAGS_ALGO_FFT = BIT(6),
572 	IWL_INITIATOR_AP_FLAGS_MCSI_REPORT = BIT(8),
573 	IWL_INITIATOR_AP_FLAGS_NON_TB = BIT(9),
574 	IWL_INITIATOR_AP_FLAGS_TB = BIT(10),
575 	IWL_INITIATOR_AP_FLAGS_SECURED = BIT(11),
576 	IWL_INITIATOR_AP_FLAGS_LMR_FEEDBACK = BIT(12),
577 	IWL_INITIATOR_AP_FLAGS_USE_CALIB = BIT(13),
578 	IWL_INITIATOR_AP_FLAGS_PMF = BIT(14),
579 	IWL_INITIATOR_AP_FLAGS_TERMINATE_ON_LMR_FEEDBACK = BIT(15),
580 };
581 
582 /**
583  * struct iwl_tof_range_req_ap_entry_v3 - AP configuration parameters
584  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
585  * @channel_num: AP Channel number
586  * @bandwidth: AP bandwidth. One of iwl_tof_bandwidth.
587  * @ctrl_ch_position: Coding of the control channel position relative to the
588  *	center frequency, see iwl_mvm_get_ctrl_pos().
589  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
590  *	reply from the AP.
591  * @bssid: AP's BSSID
592  * @burst_period: Recommended value to be sent to the AP. Measurement
593  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
594  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
595  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
596  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
597  * @reserved: For alignment and future use
598  * @tsf_delta: not in use
599  */
600 struct iwl_tof_range_req_ap_entry_v3 {
601 	__le32 initiator_ap_flags;
602 	u8 channel_num;
603 	u8 bandwidth;
604 	u8 ctrl_ch_position;
605 	u8 ftmr_max_retries;
606 	u8 bssid[ETH_ALEN];
607 	__le16 burst_period;
608 	u8 samples_per_burst;
609 	u8 num_of_bursts;
610 	__le16 reserved;
611 	__le32 tsf_delta;
612 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_3 */
613 
614 /**
615  * enum iwl_location_frame_format - location frame formats
616  * @IWL_LOCATION_FRAME_FORMAT_LEGACY: legacy
617  * @IWL_LOCATION_FRAME_FORMAT_HT: HT
618  * @IWL_LOCATION_FRAME_FORMAT_VHT: VHT
619  * @IWL_LOCATION_FRAME_FORMAT_HE: HE
620  */
621 enum iwl_location_frame_format {
622 	IWL_LOCATION_FRAME_FORMAT_LEGACY,
623 	IWL_LOCATION_FRAME_FORMAT_HT,
624 	IWL_LOCATION_FRAME_FORMAT_VHT,
625 	IWL_LOCATION_FRAME_FORMAT_HE,
626 };
627 
628 /**
629  * enum iwl_location_bw - location bandwidth selection
630  * @IWL_LOCATION_BW_20MHZ: 20MHz
631  * @IWL_LOCATION_BW_40MHZ: 40MHz
632  * @IWL_LOCATION_BW_80MHZ: 80MHz
633  */
634 enum iwl_location_bw {
635 	IWL_LOCATION_BW_20MHZ,
636 	IWL_LOCATION_BW_40MHZ,
637 	IWL_LOCATION_BW_80MHZ,
638 	IWL_LOCATION_BW_160MHZ,
639 };
640 
641 #define TK_11AZ_LEN	32
642 
643 #define LOCATION_BW_POS	4
644 
645 /**
646  * struct iwl_tof_range_req_ap_entry_v4 - AP configuration parameters
647  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
648  * @channel_num: AP Channel number
649  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
650  *             bits 4 - 7: &enum iwl_location_bw.
651  * @ctrl_ch_position: Coding of the control channel position relative to the
652  *	center frequency, see iwl_mvm_get_ctrl_pos().
653  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
654  *	reply from the AP.
655  * @bssid: AP's BSSID
656  * @burst_period: Recommended value to be sent to the AP. Measurement
657  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
658  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
659  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
660  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
661  * @reserved: For alignment and future use
662  * @hltk: HLTK to be used for secured 11az measurement
663  * @tk: TK to be used for secured 11az measurement
664  */
665 struct iwl_tof_range_req_ap_entry_v4 {
666 	__le32 initiator_ap_flags;
667 	u8 channel_num;
668 	u8 format_bw;
669 	u8 ctrl_ch_position;
670 	u8 ftmr_max_retries;
671 	u8 bssid[ETH_ALEN];
672 	__le16 burst_period;
673 	u8 samples_per_burst;
674 	u8 num_of_bursts;
675 	__le16 reserved;
676 	u8 hltk[HLTK_11AZ_LEN];
677 	u8 tk[TK_11AZ_LEN];
678 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_4 */
679 
680 /**
681  * enum iwl_location_cipher - location cipher selection
682  * @IWL_LOCATION_CIPHER_CCMP_128: CCMP 128
683  * @IWL_LOCATION_CIPHER_GCMP_128: GCMP 128
684  * @IWL_LOCATION_CIPHER_GCMP_256: GCMP 256
685  * @IWL_LOCATION_CIPHER_INVALID: security is not used.
686  * @IWL_LOCATION_CIPHER_MAX: maximum value for this enum.
687  */
688 enum iwl_location_cipher {
689 	IWL_LOCATION_CIPHER_CCMP_128,
690 	IWL_LOCATION_CIPHER_GCMP_128,
691 	IWL_LOCATION_CIPHER_GCMP_256,
692 	IWL_LOCATION_CIPHER_INVALID,
693 	IWL_LOCATION_CIPHER_MAX,
694 };
695 
696 /**
697  * struct iwl_tof_range_req_ap_entry_v6 - AP configuration parameters
698  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
699  * @channel_num: AP Channel number
700  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
701  *             bits 4 - 7: &enum iwl_location_bw.
702  * @ctrl_ch_position: Coding of the control channel position relative to the
703  *	center frequency, see iwl_mvm_get_ctrl_pos().
704  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
705  *	reply from the AP.
706  * @bssid: AP's BSSID
707  * @burst_period: Recommended value to be sent to the AP. Measurement
708  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
709  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
710  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
711  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
712  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
713  *	otherwise should be set to &IWL_MVM_INVALID_STA.
714  * @cipher: pairwise cipher suite for secured measurement.
715  *          &enum iwl_location_cipher.
716  * @hltk: HLTK to be used for secured 11az measurement
717  * @tk: TK to be used for secured 11az measurement
718  * @calib: An array of calibration values per FTM rx bandwidth.
719  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
720  *         calibration value that corresponds to the rx bandwidth of the FTM
721  *         frame.
722  * @beacon_interval: beacon interval of the AP in TUs. Only required if
723  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
724  */
725 struct iwl_tof_range_req_ap_entry_v6 {
726 	__le32 initiator_ap_flags;
727 	u8 channel_num;
728 	u8 format_bw;
729 	u8 ctrl_ch_position;
730 	u8 ftmr_max_retries;
731 	u8 bssid[ETH_ALEN];
732 	__le16 burst_period;
733 	u8 samples_per_burst;
734 	u8 num_of_bursts;
735 	u8 sta_id;
736 	u8 cipher;
737 	u8 hltk[HLTK_11AZ_LEN];
738 	u8 tk[TK_11AZ_LEN];
739 	__le16 calib[IWL_TOF_BW_NUM];
740 	__le16 beacon_interval;
741 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_6 */
742 
743 /**
744  * struct iwl_tof_range_req_ap_entry_v7 - AP configuration parameters
745  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
746  * @channel_num: AP Channel number
747  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
748  *             bits 4 - 7: &enum iwl_location_bw.
749  * @ctrl_ch_position: Coding of the control channel position relative to the
750  *	center frequency, see iwl_mvm_get_ctrl_pos().
751  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
752  *	reply from the AP.
753  * @bssid: AP's BSSID
754  * @burst_period: Recommended value to be sent to the AP. Measurement
755  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
756  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
757  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
758  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
759  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
760  *	otherwise should be set to &IWL_MVM_INVALID_STA.
761  * @cipher: pairwise cipher suite for secured measurement.
762  *          &enum iwl_location_cipher.
763  * @hltk: HLTK to be used for secured 11az measurement
764  * @tk: TK to be used for secured 11az measurement
765  * @calib: An array of calibration values per FTM rx bandwidth.
766  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
767  *         calibration value that corresponds to the rx bandwidth of the FTM
768  *         frame.
769  * @beacon_interval: beacon interval of the AP in TUs. Only required if
770  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
771  * @rx_pn: the next expected PN for protected management frames Rx. LE byte
772  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
773  *	is set to &IWL_MVM_INVALID_STA.
774  * @tx_pn: the next PN to use for protected management frames Tx. LE byte
775  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
776  *	is set to &IWL_MVM_INVALID_STA.
777  */
778 struct iwl_tof_range_req_ap_entry_v7 {
779 	__le32 initiator_ap_flags;
780 	u8 channel_num;
781 	u8 format_bw;
782 	u8 ctrl_ch_position;
783 	u8 ftmr_max_retries;
784 	u8 bssid[ETH_ALEN];
785 	__le16 burst_period;
786 	u8 samples_per_burst;
787 	u8 num_of_bursts;
788 	u8 sta_id;
789 	u8 cipher;
790 	u8 hltk[HLTK_11AZ_LEN];
791 	u8 tk[TK_11AZ_LEN];
792 	__le16 calib[IWL_TOF_BW_NUM];
793 	__le16 beacon_interval;
794 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
795 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
796 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_7 */
797 
798 #define IWL_LOCATION_MAX_STS_POS	3
799 
800 /**
801  * struct iwl_tof_range_req_ap_entry_v8 - AP configuration parameters
802  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
803  * @channel_num: AP Channel number
804  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
805  *             bits 4 - 7: &enum iwl_location_bw.
806  * @ctrl_ch_position: Coding of the control channel position relative to the
807  *	center frequency, see iwl_mvm_get_ctrl_pos().
808  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
809  *	reply from the AP.
810  * @bssid: AP's BSSID
811  * @burst_period: Recommended value to be sent to the AP. Measurement
812  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
813  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
814  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
815  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
816  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
817  *	otherwise should be set to &IWL_MVM_INVALID_STA.
818  * @cipher: pairwise cipher suite for secured measurement.
819  *          &enum iwl_location_cipher.
820  * @hltk: HLTK to be used for secured 11az measurement
821  * @tk: TK to be used for secured 11az measurement
822  * @calib: An array of calibration values per FTM rx bandwidth.
823  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
824  *         calibration value that corresponds to the rx bandwidth of the FTM
825  *         frame.
826  * @beacon_interval: beacon interval of the AP in TUs. Only required if
827  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
828  * @rx_pn: the next expected PN for protected management frames Rx. LE byte
829  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
830  *	is set to &IWL_MVM_INVALID_STA.
831  * @tx_pn: the next PN to use for protected management frames Tx. LE byte
832  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
833  *	is set to &IWL_MVM_INVALID_STA.
834  * @r2i_ndp_params: parameters for R2I NDP ranging negotiation.
835  *      bits 0 - 2: max LTF repetitions
836  *      bits 3 - 5: max number of spatial streams
837  *      bits 6 - 7: reserved
838  * @i2r_ndp_params: parameters for I2R NDP ranging negotiation.
839  *      bits 0 - 2: max LTF repetitions
840  *      bits 3 - 5: max number of spatial streams (supported values are < 2)
841  *      bits 6 - 7: reserved
842  * @r2i_max_total_ltf: R2I Max Total LTFs for NDP ranging negotiation.
843  *      One of &enum ieee80211_range_params_max_total_ltf.
844  * @i2r_max_total_ltf: I2R Max Total LTFs for NDP ranging negotiation.
845  *      One of &enum ieee80211_range_params_max_total_ltf.
846  */
847 struct iwl_tof_range_req_ap_entry_v8 {
848 	__le32 initiator_ap_flags;
849 	u8 channel_num;
850 	u8 format_bw;
851 	u8 ctrl_ch_position;
852 	u8 ftmr_max_retries;
853 	u8 bssid[ETH_ALEN];
854 	__le16 burst_period;
855 	u8 samples_per_burst;
856 	u8 num_of_bursts;
857 	u8 sta_id;
858 	u8 cipher;
859 	u8 hltk[HLTK_11AZ_LEN];
860 	u8 tk[TK_11AZ_LEN];
861 	__le16 calib[IWL_TOF_BW_NUM];
862 	__le16 beacon_interval;
863 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
864 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
865 	u8 r2i_ndp_params;
866 	u8 i2r_ndp_params;
867 	u8 r2i_max_total_ltf;
868 	u8 i2r_max_total_ltf;
869 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_8 */
870 
871 /**
872  * struct iwl_tof_range_req_ap_entry_v9 - AP configuration parameters
873  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
874  * @channel_num: AP Channel number
875  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
876  *             bits 4 - 7: &enum iwl_location_bw.
877  * @ctrl_ch_position: Coding of the control channel position relative to the
878  *	center frequency, see iwl_mvm_get_ctrl_pos().
879  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
880  *	reply from the AP.
881  * @bssid: AP's BSSID
882  * @burst_period: For EDCA based ranging: Recommended value to be sent to the
883  *	AP. Measurement periodicity In units of 100ms. ignored if
884  *	num_of_bursts_exp = 0.
885  *	For non trigger based NDP ranging, the maximum time between
886  *	measurements in units of milliseconds.
887  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
888  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
889  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
890  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
891  *	otherwise should be set to &IWL_MVM_INVALID_STA.
892  * @cipher: pairwise cipher suite for secured measurement.
893  *          &enum iwl_location_cipher.
894  * @hltk: HLTK to be used for secured 11az measurement
895  * @tk: TK to be used for secured 11az measurement
896  * @calib: An array of calibration values per FTM rx bandwidth.
897  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
898  *         calibration value that corresponds to the rx bandwidth of the FTM
899  *         frame.
900  * @beacon_interval: beacon interval of the AP in TUs. Only required if
901  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
902  * @bss_color: the BSS color of the responder. Only valid if
903  *	&IWL_INITIATOR_AP_FLAGS_TB or &IWL_INITIATOR_AP_FLAGS_NON_TB is set.
904  * @rx_pn: the next expected PN for protected management frames Rx. LE byte
905  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
906  *	is set to &IWL_MVM_INVALID_STA.
907  * @tx_pn: the next PN to use for protected management frames Tx. LE byte
908  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
909  *	is set to &IWL_MVM_INVALID_STA.
910  * @r2i_ndp_params: parameters for R2I NDP ranging negotiation.
911  *      bits 0 - 2: max LTF repetitions
912  *      bits 3 - 5: max number of spatial streams
913  *      bits 6 - 7: reserved
914  * @i2r_ndp_params: parameters for I2R NDP ranging negotiation.
915  *      bits 0 - 2: max LTF repetitions
916  *      bits 3 - 5: max number of spatial streams (supported values are < 2)
917  *      bits 6 - 7: reserved
918  * @r2i_max_total_ltf: R2I Max Total LTFs for NDP ranging negotiation.
919  *      One of &enum ieee80211_range_params_max_total_ltf.
920  * @i2r_max_total_ltf: I2R Max Total LTFs for NDP ranging negotiation.
921  *      One of &enum ieee80211_range_params_max_total_ltf.
922  * @bss_color: the BSS color of the responder. Only valid if
923  *	&IWL_INITIATOR_AP_FLAGS_NON_TB or &IWL_INITIATOR_AP_FLAGS_TB is set.
924  * @band: 0 for 5.2 GHz, 1 for 2.4 GHz, 2 for 6GHz
925  * @min_time_between_msr: For non trigger based NDP ranging, the minimum time
926  *	between measurements in units of milliseconds
927  */
928 struct iwl_tof_range_req_ap_entry_v9 {
929 	__le32 initiator_ap_flags;
930 	u8 channel_num;
931 	u8 format_bw;
932 	u8 ctrl_ch_position;
933 	u8 ftmr_max_retries;
934 	u8 bssid[ETH_ALEN];
935 	__le16 burst_period;
936 	u8 samples_per_burst;
937 	u8 num_of_bursts;
938 	u8 sta_id;
939 	u8 cipher;
940 	u8 hltk[HLTK_11AZ_LEN];
941 	u8 tk[TK_11AZ_LEN];
942 	__le16 calib[IWL_TOF_BW_NUM];
943 	u16 beacon_interval;
944 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
945 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
946 	u8 r2i_ndp_params;
947 	u8 i2r_ndp_params;
948 	u8 r2i_max_total_ltf;
949 	u8 i2r_max_total_ltf;
950 	u8 bss_color;
951 	u8 band;
952 	__le16 min_time_between_msr;
953 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_9 */
954 
955 /**
956  * enum iwl_tof_response_mode
957  * @IWL_MVM_TOF_RESPONSE_ASAP: report each AP measurement separately as soon as
958  *			       possible (not supported for this release)
959  * @IWL_MVM_TOF_RESPONSE_TIMEOUT: report all AP measurements as a batch upon
960  *				  timeout expiration
961  * @IWL_MVM_TOF_RESPONSE_COMPLETE: report all AP measurements as a batch at the
962  *				   earlier of: measurements completion / timeout
963  *				   expiration.
964  */
965 enum iwl_tof_response_mode {
966 	IWL_MVM_TOF_RESPONSE_ASAP,
967 	IWL_MVM_TOF_RESPONSE_TIMEOUT,
968 	IWL_MVM_TOF_RESPONSE_COMPLETE,
969 };
970 
971 /**
972  * enum iwl_tof_initiator_flags
973  *
974  * @IWL_TOF_INITIATOR_FLAGS_FAST_ALGO_DISABLED: disable fast algo, meaning run
975  *	the algo on ant A+B, instead of only one of them.
976  * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_A: open RX antenna A for FTMs RX
977  * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_B: open RX antenna B for FTMs RX
978  * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_C: open RX antenna C for FTMs RX
979  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A: use antenna A fo TX ACKs during FTM
980  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B: use antenna B fo TX ACKs during FTM
981  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C: use antenna C fo TX ACKs during FTM
982  * @IWL_TOF_INITIATOR_FLAGS_MACADDR_RANDOM: use random mac address for FTM
983  * @IWL_TOF_INITIATOR_FLAGS_SPECIFIC_CALIB: use the specific calib value from
984  *	the range request command
985  * @IWL_TOF_INITIATOR_FLAGS_COMMON_CALIB: use the common calib value from the
986  *	ragne request command
987  * @IWL_TOF_INITIATOR_FLAGS_NON_ASAP_SUPPORT: support non-asap measurements
988  */
989 enum iwl_tof_initiator_flags {
990 	IWL_TOF_INITIATOR_FLAGS_FAST_ALGO_DISABLED = BIT(0),
991 	IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_A = BIT(1),
992 	IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_B = BIT(2),
993 	IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_C = BIT(3),
994 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A = BIT(4),
995 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B = BIT(5),
996 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C = BIT(6),
997 	IWL_TOF_INITIATOR_FLAGS_MACADDR_RANDOM = BIT(7),
998 	IWL_TOF_INITIATOR_FLAGS_SPECIFIC_CALIB = BIT(15),
999 	IWL_TOF_INITIATOR_FLAGS_COMMON_CALIB   = BIT(16),
1000 	IWL_TOF_INITIATOR_FLAGS_NON_ASAP_SUPPORT = BIT(20),
1001 }; /* LOCATION_RANGE_REQ_CMD_API_S_VER_5 */
1002 
1003 #define IWL_MVM_TOF_MAX_APS 5
1004 #define IWL_MVM_TOF_MAX_TWO_SIDED_APS 5
1005 
1006 /**
1007  * struct iwl_tof_range_req_cmd_v5 - start measurement cmd
1008  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1009  * @request_id: A Token incremented per request. The same Token will be
1010  *		sent back in the range response
1011  * @initiator: 0- NW initiated,  1 - Client Initiated
1012  * @one_sided_los_disable: '0'- run ML-Algo for both ToF/OneSided,
1013  *			   '1' - run ML-Algo for ToF only
1014  * @req_timeout: Requested timeout of the response in units of 100ms.
1015  *	     This is equivalent to the session time configured to the
1016  *	     LMAC in Initiator Request
1017  * @report_policy: Supported partially for this release: For current release -
1018  *		   the range report will be uploaded as a batch when ready or
1019  *		   when the session is done (successfully / partially).
1020  *		   one of iwl_tof_response_mode.
1021  * @reserved0: reserved
1022  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1023  * @macaddr_random: '0' Use default source MAC address (i.e. p2_p),
1024  *	            '1' Use MAC Address randomization according to the below
1025  * @range_req_bssid: ranging request BSSID
1026  * @macaddr_template: MAC address template to use for non-randomized bits
1027  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1028  *		  Bits set to 1 shall be randomized by the UMAC
1029  * @ftm_rx_chains: Rx chain to open to receive Responder's FTMs (XVT)
1030  * @ftm_tx_chains: Tx chain to send the ack to the Responder FTM (XVT)
1031  * @common_calib: The common calib value to inject to this measurement calc
1032  * @specific_calib: The specific calib value to inject to this measurement calc
1033  * @ap: per-AP request data
1034  */
1035 struct iwl_tof_range_req_cmd_v5 {
1036 	__le32 initiator_flags;
1037 	u8 request_id;
1038 	u8 initiator;
1039 	u8 one_sided_los_disable;
1040 	u8 req_timeout;
1041 	u8 report_policy;
1042 	u8 reserved0;
1043 	u8 num_of_ap;
1044 	u8 macaddr_random;
1045 	u8 range_req_bssid[ETH_ALEN];
1046 	u8 macaddr_template[ETH_ALEN];
1047 	u8 macaddr_mask[ETH_ALEN];
1048 	u8 ftm_rx_chains;
1049 	u8 ftm_tx_chains;
1050 	__le16 common_calib;
1051 	__le16 specific_calib;
1052 	struct iwl_tof_range_req_ap_entry_v2 ap[IWL_MVM_TOF_MAX_APS];
1053 } __packed;
1054 /* LOCATION_RANGE_REQ_CMD_API_S_VER_5 */
1055 
1056 /**
1057  * struct iwl_tof_range_req_cmd_v7 - start measurement cmd
1058  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1059  * @request_id: A Token incremented per request. The same Token will be
1060  *		sent back in the range response
1061  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1062  * @range_req_bssid: ranging request BSSID
1063  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1064  *		  Bits set to 1 shall be randomized by the UMAC
1065  * @macaddr_template: MAC address template to use for non-randomized bits
1066  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1067  *	This is the session time for completing the measurement.
1068  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1069  *	TSF of this mac id. 0xff to disable TSF reporting.
1070  * @common_calib: The common calib value to inject to this measurement calc
1071  * @specific_calib: The specific calib value to inject to this measurement calc
1072  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1073  */
1074 struct iwl_tof_range_req_cmd_v7 {
1075 	__le32 initiator_flags;
1076 	u8 request_id;
1077 	u8 num_of_ap;
1078 	u8 range_req_bssid[ETH_ALEN];
1079 	u8 macaddr_mask[ETH_ALEN];
1080 	u8 macaddr_template[ETH_ALEN];
1081 	__le32 req_timeout_ms;
1082 	__le32 tsf_mac_id;
1083 	__le16 common_calib;
1084 	__le16 specific_calib;
1085 	struct iwl_tof_range_req_ap_entry_v3 ap[IWL_MVM_TOF_MAX_APS];
1086 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_7 */
1087 
1088 /**
1089  * struct iwl_tof_range_req_cmd_v8 - start measurement cmd
1090  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1091  * @request_id: A Token incremented per request. The same Token will be
1092  *		sent back in the range response
1093  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1094  * @range_req_bssid: ranging request BSSID
1095  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1096  *		  Bits set to 1 shall be randomized by the UMAC
1097  * @macaddr_template: MAC address template to use for non-randomized bits
1098  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1099  *	This is the session time for completing the measurement.
1100  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1101  *	TSF of this mac id. 0xff to disable TSF reporting.
1102  * @common_calib: The common calib value to inject to this measurement calc
1103  * @specific_calib: The specific calib value to inject to this measurement calc
1104  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1105  */
1106 struct iwl_tof_range_req_cmd_v8 {
1107 	__le32 initiator_flags;
1108 	u8 request_id;
1109 	u8 num_of_ap;
1110 	u8 range_req_bssid[ETH_ALEN];
1111 	u8 macaddr_mask[ETH_ALEN];
1112 	u8 macaddr_template[ETH_ALEN];
1113 	__le32 req_timeout_ms;
1114 	__le32 tsf_mac_id;
1115 	__le16 common_calib;
1116 	__le16 specific_calib;
1117 	struct iwl_tof_range_req_ap_entry_v4 ap[IWL_MVM_TOF_MAX_APS];
1118 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_8 */
1119 
1120 /**
1121  * struct iwl_tof_range_req_cmd_v9 - start measurement cmd
1122  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1123  * @request_id: A Token incremented per request. The same Token will be
1124  *		sent back in the range response
1125  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1126  * @range_req_bssid: ranging request BSSID
1127  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1128  *		  Bits set to 1 shall be randomized by the UMAC
1129  * @macaddr_template: MAC address template to use for non-randomized bits
1130  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1131  *	This is the session time for completing the measurement.
1132  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1133  *	TSF of this mac id. 0xff to disable TSF reporting.
1134  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1135  */
1136 struct iwl_tof_range_req_cmd_v9 {
1137 	__le32 initiator_flags;
1138 	u8 request_id;
1139 	u8 num_of_ap;
1140 	u8 range_req_bssid[ETH_ALEN];
1141 	u8 macaddr_mask[ETH_ALEN];
1142 	u8 macaddr_template[ETH_ALEN];
1143 	__le32 req_timeout_ms;
1144 	__le32 tsf_mac_id;
1145 	struct iwl_tof_range_req_ap_entry_v6 ap[IWL_MVM_TOF_MAX_APS];
1146 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_9 */
1147 
1148 /**
1149  * struct iwl_tof_range_req_cmd_v11 - start measurement cmd
1150  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1151  * @request_id: A Token incremented per request. The same Token will be
1152  *		sent back in the range response
1153  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1154  * @range_req_bssid: ranging request BSSID
1155  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1156  *		  Bits set to 1 shall be randomized by the UMAC
1157  * @macaddr_template: MAC address template to use for non-randomized bits
1158  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1159  *	This is the session time for completing the measurement.
1160  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1161  *	TSF of this mac id. 0xff to disable TSF reporting.
1162  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1163  */
1164 struct iwl_tof_range_req_cmd_v11 {
1165 	__le32 initiator_flags;
1166 	u8 request_id;
1167 	u8 num_of_ap;
1168 	u8 range_req_bssid[ETH_ALEN];
1169 	u8 macaddr_mask[ETH_ALEN];
1170 	u8 macaddr_template[ETH_ALEN];
1171 	__le32 req_timeout_ms;
1172 	__le32 tsf_mac_id;
1173 	struct iwl_tof_range_req_ap_entry_v7 ap[IWL_MVM_TOF_MAX_APS];
1174 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_11 */
1175 
1176 /**
1177  * struct iwl_tof_range_req_cmd_v12 - start measurement cmd
1178  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1179  * @request_id: A Token incremented per request. The same Token will be
1180  *		sent back in the range response
1181  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1182  * @range_req_bssid: ranging request BSSID
1183  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1184  *		  Bits set to 1 shall be randomized by the UMAC
1185  * @macaddr_template: MAC address template to use for non-randomized bits
1186  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1187  *	This is the session time for completing the measurement.
1188  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1189  *	TSF of this mac id. 0xff to disable TSF reporting.
1190  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1191  */
1192 struct iwl_tof_range_req_cmd_v12 {
1193 	__le32 initiator_flags;
1194 	u8 request_id;
1195 	u8 num_of_ap;
1196 	u8 range_req_bssid[ETH_ALEN];
1197 	u8 macaddr_mask[ETH_ALEN];
1198 	u8 macaddr_template[ETH_ALEN];
1199 	__le32 req_timeout_ms;
1200 	__le32 tsf_mac_id;
1201 	struct iwl_tof_range_req_ap_entry_v8 ap[IWL_MVM_TOF_MAX_APS];
1202 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_12 */
1203 
1204 /**
1205  * struct iwl_tof_range_req_cmd_v13 - start measurement cmd
1206  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1207  * @request_id: A Token incremented per request. The same Token will be
1208  *		sent back in the range response
1209  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1210  * @range_req_bssid: ranging request BSSID
1211  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1212  *		  Bits set to 1 shall be randomized by the UMAC
1213  * @macaddr_template: MAC address template to use for non-randomized bits
1214  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1215  *	This is the session time for completing the measurement.
1216  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1217  *	TSF of this mac id. 0xff to disable TSF reporting.
1218  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v9.
1219  */
1220 struct iwl_tof_range_req_cmd_v13 {
1221 	__le32 initiator_flags;
1222 	u8 request_id;
1223 	u8 num_of_ap;
1224 	u8 range_req_bssid[ETH_ALEN];
1225 	u8 macaddr_mask[ETH_ALEN];
1226 	u8 macaddr_template[ETH_ALEN];
1227 	__le32 req_timeout_ms;
1228 	__le32 tsf_mac_id;
1229 	struct iwl_tof_range_req_ap_entry_v9 ap[IWL_MVM_TOF_MAX_APS];
1230 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_13 */
1231 
1232 /*
1233  * enum iwl_tof_range_request_status - status of the sent request
1234  * @IWL_TOF_RANGE_REQUEST_STATUS_SUCCESSFUL - FW successfully received the
1235  *	request
1236  * @IWL_TOF_RANGE_REQUEST_STATUS_BUSY - FW is busy with a previous request, the
1237  *	sent request will not be handled
1238  */
1239 enum iwl_tof_range_request_status {
1240 	IWL_TOF_RANGE_REQUEST_STATUS_SUCCESS,
1241 	IWL_TOF_RANGE_REQUEST_STATUS_BUSY,
1242 };
1243 
1244 /**
1245  * enum iwl_tof_entry_status
1246  *
1247  * @IWL_TOF_ENTRY_SUCCESS: successful measurement.
1248  * @IWL_TOF_ENTRY_GENERAL_FAILURE: General failure.
1249  * @IWL_TOF_ENTRY_NO_RESPONSE: Responder didn't reply to the request.
1250  * @IWL_TOF_ENTRY_REQUEST_REJECTED: Responder rejected the request.
1251  * @IWL_TOF_ENTRY_NOT_SCHEDULED: Time event was scheduled but not called yet.
1252  * @IWL_TOF_ENTRY_TIMING_MEASURE_TIMEOUT: Time event triggered but no
1253  *	measurement was completed.
1254  * @IWL_TOF_ENTRY_TARGET_DIFF_CH_CANNOT_CHANGE: No range due inability to switch
1255  *	from the primary channel.
1256  * @IWL_TOF_ENTRY_RANGE_NOT_SUPPORTED: Device doesn't support FTM.
1257  * @IWL_TOF_ENTRY_REQUEST_ABORT_UNKNOWN_REASON: Request aborted due to unknown
1258  *	reason.
1259  * @IWL_TOF_ENTRY_LOCATION_INVALID_T1_T4_TIME_STAMP: Failure due to invalid
1260  *	T1/T4.
1261  * @IWL_TOF_ENTRY_11MC_PROTOCOL_FAILURE: Failure due to invalid FTM frame
1262  *	structure.
1263  * @IWL_TOF_ENTRY_REQUEST_CANNOT_SCHED: Request cannot be scheduled.
1264  * @IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE: Responder cannot serve the
1265  *	initiator for some period, period supplied in @refusal_period.
1266  * @IWL_TOF_ENTRY_BAD_REQUEST_ARGS: Bad request arguments.
1267  * @IWL_TOF_ENTRY_WIFI_NOT_ENABLED: Wifi not enabled.
1268  * @IWL_TOF_ENTRY_RESPONDER_OVERRIDE_PARAMS: Responder override the original
1269  *	parameters within the current session.
1270  */
1271 enum iwl_tof_entry_status {
1272 	IWL_TOF_ENTRY_SUCCESS = 0,
1273 	IWL_TOF_ENTRY_GENERAL_FAILURE = 1,
1274 	IWL_TOF_ENTRY_NO_RESPONSE = 2,
1275 	IWL_TOF_ENTRY_REQUEST_REJECTED = 3,
1276 	IWL_TOF_ENTRY_NOT_SCHEDULED = 4,
1277 	IWL_TOF_ENTRY_TIMING_MEASURE_TIMEOUT = 5,
1278 	IWL_TOF_ENTRY_TARGET_DIFF_CH_CANNOT_CHANGE = 6,
1279 	IWL_TOF_ENTRY_RANGE_NOT_SUPPORTED = 7,
1280 	IWL_TOF_ENTRY_REQUEST_ABORT_UNKNOWN_REASON = 8,
1281 	IWL_TOF_ENTRY_LOCATION_INVALID_T1_T4_TIME_STAMP = 9,
1282 	IWL_TOF_ENTRY_11MC_PROTOCOL_FAILURE = 10,
1283 	IWL_TOF_ENTRY_REQUEST_CANNOT_SCHED = 11,
1284 	IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE = 12,
1285 	IWL_TOF_ENTRY_BAD_REQUEST_ARGS = 13,
1286 	IWL_TOF_ENTRY_WIFI_NOT_ENABLED = 14,
1287 	IWL_TOF_ENTRY_RESPONDER_OVERRIDE_PARAMS = 15,
1288 }; /* LOCATION_RANGE_RSP_AP_ENTRY_NTFY_API_S_VER_2 */
1289 
1290 /**
1291  * struct iwl_tof_range_rsp_ap_entry_ntfy_v3 - AP parameters (response)
1292  * @bssid: BSSID of the AP
1293  * @measure_status: current APs measurement status, one of
1294  *	&enum iwl_tof_entry_status.
1295  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1296  * @rtt: The Round Trip Time that took for the last measurement for
1297  *	current AP [pSec]
1298  * @rtt_variance: The Variance of the RTT values measured for current AP
1299  * @rtt_spread: The Difference between the maximum and the minimum RTT
1300  *	values measured for current AP in the current session [pSec]
1301  * @rssi: RSSI as uploaded in the Channel Estimation notification
1302  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1303  *	measured for current AP in the current session
1304  * @reserved: reserved
1305  * @refusal_period: refusal period in case of
1306  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1307  * @range: Measured range [cm]
1308  * @range_variance: Measured range variance [cm]
1309  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1310  *	uploaded by the LMAC
1311  * @t2t3_initiator: as calculated from the algo in the initiator
1312  * @t1t4_responder: as calculated from the algo in the responder
1313  * @common_calib: Calib val that was used in for this AP measurement
1314  * @specific_calib: val that was used in for this AP measurement
1315  * @papd_calib_output: The result of the tof papd calibration that was injected
1316  *	into the algorithm.
1317  */
1318 struct iwl_tof_range_rsp_ap_entry_ntfy_v3 {
1319 	u8 bssid[ETH_ALEN];
1320 	u8 measure_status;
1321 	u8 measure_bw;
1322 	__le32 rtt;
1323 	__le32 rtt_variance;
1324 	__le32 rtt_spread;
1325 	s8 rssi;
1326 	u8 rssi_spread;
1327 	u8 reserved;
1328 	u8 refusal_period;
1329 	__le32 range;
1330 	__le32 range_variance;
1331 	__le32 timestamp;
1332 	__le32 t2t3_initiator;
1333 	__le32 t1t4_responder;
1334 	__le16 common_calib;
1335 	__le16 specific_calib;
1336 	__le32 papd_calib_output;
1337 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_3 */
1338 
1339 /**
1340  * struct iwl_tof_range_rsp_ap_entry_ntfy_v4 - AP parameters (response)
1341  * @bssid: BSSID of the AP
1342  * @measure_status: current APs measurement status, one of
1343  *	&enum iwl_tof_entry_status.
1344  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1345  * @rtt: The Round Trip Time that took for the last measurement for
1346  *	current AP [pSec]
1347  * @rtt_variance: The Variance of the RTT values measured for current AP
1348  * @rtt_spread: The Difference between the maximum and the minimum RTT
1349  *	values measured for current AP in the current session [pSec]
1350  * @rssi: RSSI as uploaded in the Channel Estimation notification
1351  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1352  *	measured for current AP in the current session
1353  * @last_burst: 1 if no more FTM sessions are scheduled for this responder
1354  * @refusal_period: refusal period in case of
1355  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1356  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1357  *	uploaded by the LMAC
1358  * @start_tsf: measurement start time in TSF of the mac specified in the range
1359  *	request
1360  * @rx_rate_n_flags: rate and flags of the last FTM frame received from this
1361  *	responder
1362  * @tx_rate_n_flags: rate and flags of the last ack sent to this responder
1363  * @t2t3_initiator: as calculated from the algo in the initiator
1364  * @t1t4_responder: as calculated from the algo in the responder
1365  * @common_calib: Calib val that was used in for this AP measurement
1366  * @specific_calib: val that was used in for this AP measurement
1367  * @papd_calib_output: The result of the tof papd calibration that was injected
1368  *	into the algorithm.
1369  */
1370 struct iwl_tof_range_rsp_ap_entry_ntfy_v4 {
1371 	u8 bssid[ETH_ALEN];
1372 	u8 measure_status;
1373 	u8 measure_bw;
1374 	__le32 rtt;
1375 	__le32 rtt_variance;
1376 	__le32 rtt_spread;
1377 	s8 rssi;
1378 	u8 rssi_spread;
1379 	u8 last_burst;
1380 	u8 refusal_period;
1381 	__le32 timestamp;
1382 	__le32 start_tsf;
1383 	__le32 rx_rate_n_flags;
1384 	__le32 tx_rate_n_flags;
1385 	__le32 t2t3_initiator;
1386 	__le32 t1t4_responder;
1387 	__le16 common_calib;
1388 	__le16 specific_calib;
1389 	__le32 papd_calib_output;
1390 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_4 */
1391 
1392 /**
1393  * struct iwl_tof_range_rsp_ap_entry_ntfy_v5 - AP parameters (response)
1394  * @bssid: BSSID of the AP
1395  * @measure_status: current APs measurement status, one of
1396  *	&enum iwl_tof_entry_status.
1397  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1398  * @rtt: The Round Trip Time that took for the last measurement for
1399  *	current AP [pSec]
1400  * @rtt_variance: The Variance of the RTT values measured for current AP
1401  * @rtt_spread: The Difference between the maximum and the minimum RTT
1402  *	values measured for current AP in the current session [pSec]
1403  * @rssi: RSSI as uploaded in the Channel Estimation notification
1404  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1405  *	measured for current AP in the current session
1406  * @last_burst: 1 if no more FTM sessions are scheduled for this responder
1407  * @refusal_period: refusal period in case of
1408  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1409  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1410  *	uploaded by the LMAC
1411  * @start_tsf: measurement start time in TSF of the mac specified in the range
1412  *	request
1413  * @rx_rate_n_flags: rate and flags of the last FTM frame received from this
1414  *	responder
1415  * @tx_rate_n_flags: rate and flags of the last ack sent to this responder
1416  * @t2t3_initiator: as calculated from the algo in the initiator
1417  * @t1t4_responder: as calculated from the algo in the responder
1418  * @common_calib: Calib val that was used in for this AP measurement
1419  * @specific_calib: val that was used in for this AP measurement
1420  * @papd_calib_output: The result of the tof papd calibration that was injected
1421  *	into the algorithm.
1422  * @rttConfidence: a value between 0 - 31 that represents the rtt accuracy.
1423  * @reserved: for alignment
1424  */
1425 struct iwl_tof_range_rsp_ap_entry_ntfy_v5 {
1426 	u8 bssid[ETH_ALEN];
1427 	u8 measure_status;
1428 	u8 measure_bw;
1429 	__le32 rtt;
1430 	__le32 rtt_variance;
1431 	__le32 rtt_spread;
1432 	s8 rssi;
1433 	u8 rssi_spread;
1434 	u8 last_burst;
1435 	u8 refusal_period;
1436 	__le32 timestamp;
1437 	__le32 start_tsf;
1438 	__le32 rx_rate_n_flags;
1439 	__le32 tx_rate_n_flags;
1440 	__le32 t2t3_initiator;
1441 	__le32 t1t4_responder;
1442 	__le16 common_calib;
1443 	__le16 specific_calib;
1444 	__le32 papd_calib_output;
1445 	u8 rttConfidence;
1446 	u8 reserved[3];
1447 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_5 */
1448 
1449 /**
1450  * struct iwl_tof_range_rsp_ap_entry_ntfy_v6 - AP parameters (response)
1451  * @bssid: BSSID of the AP
1452  * @measure_status: current APs measurement status, one of
1453  *	&enum iwl_tof_entry_status.
1454  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1455  * @rtt: The Round Trip Time that took for the last measurement for
1456  *	current AP [pSec]
1457  * @rtt_variance: The Variance of the RTT values measured for current AP
1458  * @rtt_spread: The Difference between the maximum and the minimum RTT
1459  *	values measured for current AP in the current session [pSec]
1460  * @rssi: RSSI as uploaded in the Channel Estimation notification
1461  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1462  *	measured for current AP in the current session
1463  * @last_burst: 1 if no more FTM sessions are scheduled for this responder
1464  * @refusal_period: refusal period in case of
1465  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1466  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1467  *	uploaded by the LMAC
1468  * @start_tsf: measurement start time in TSF of the mac specified in the range
1469  *	request
1470  * @rx_rate_n_flags: rate and flags of the last FTM frame received from this
1471  *	responder
1472  * @tx_rate_n_flags: rate and flags of the last ack sent to this responder
1473  * @t2t3_initiator: as calculated from the algo in the initiator
1474  * @t1t4_responder: as calculated from the algo in the responder
1475  * @common_calib: Calib val that was used in for this AP measurement
1476  * @specific_calib: val that was used in for this AP measurement
1477  * @papd_calib_output: The result of the tof papd calibration that was injected
1478  *	into the algorithm.
1479  * @rttConfidence: a value between 0 - 31 that represents the rtt accuracy.
1480  * @reserved: for alignment
1481  * @rx_pn: the last PN used for this responder Rx in case PMF is configured in
1482  *	LE byte order.
1483  * @tx_pn: the last PN used for this responder Tx in case PMF is configured in
1484  *	LE byte order.
1485  */
1486 struct iwl_tof_range_rsp_ap_entry_ntfy_v6 {
1487 	u8 bssid[ETH_ALEN];
1488 	u8 measure_status;
1489 	u8 measure_bw;
1490 	__le32 rtt;
1491 	__le32 rtt_variance;
1492 	__le32 rtt_spread;
1493 	s8 rssi;
1494 	u8 rssi_spread;
1495 	u8 last_burst;
1496 	u8 refusal_period;
1497 	__le32 timestamp;
1498 	__le32 start_tsf;
1499 	__le32 rx_rate_n_flags;
1500 	__le32 tx_rate_n_flags;
1501 	__le32 t2t3_initiator;
1502 	__le32 t1t4_responder;
1503 	__le16 common_calib;
1504 	__le16 specific_calib;
1505 	__le32 papd_calib_output;
1506 	u8 rttConfidence;
1507 	u8 reserved[3];
1508 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
1509 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
1510 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_6,
1511 	       LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_7 */
1512 
1513 
1514 /**
1515  * enum iwl_tof_response_status - tof response status
1516  *
1517  * @IWL_TOF_RESPONSE_SUCCESS: successful range.
1518  * @IWL_TOF_RESPONSE_TIMEOUT: request aborted due to timeout expiration.
1519  *	partial result of ranges done so far is included in the response.
1520  * @IWL_TOF_RESPONSE_ABORTED: Measurement aborted by command.
1521  * @IWL_TOF_RESPONSE_FAILED: Measurement request command failed.
1522  */
1523 enum iwl_tof_response_status {
1524 	IWL_TOF_RESPONSE_SUCCESS = 0,
1525 	IWL_TOF_RESPONSE_TIMEOUT = 1,
1526 	IWL_TOF_RESPONSE_ABORTED = 4,
1527 	IWL_TOF_RESPONSE_FAILED  = 5,
1528 }; /* LOCATION_RNG_RSP_STATUS */
1529 
1530 /**
1531  * struct iwl_tof_range_rsp_ntfy_v5 - ranging response notification
1532  * @request_id: A Token ID of the corresponding Range request
1533  * @request_status: status of current measurement session, one of
1534  *	&enum iwl_tof_response_status.
1535  * @last_in_batch: reprot policy (when not all responses are uploaded at once)
1536  * @num_of_aps: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1537  * @ap: per-AP data
1538  */
1539 struct iwl_tof_range_rsp_ntfy_v5 {
1540 	u8 request_id;
1541 	u8 request_status;
1542 	u8 last_in_batch;
1543 	u8 num_of_aps;
1544 	struct iwl_tof_range_rsp_ap_entry_ntfy_v3 ap[IWL_MVM_TOF_MAX_APS];
1545 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_5 */
1546 
1547 /**
1548  * struct iwl_tof_range_rsp_ntfy_v6 - ranging response notification
1549  * @request_id: A Token ID of the corresponding Range request
1550  * @num_of_aps: Number of APs results
1551  * @last_report: 1 if no more FTM sessions are scheduled, 0 otherwise.
1552  * @reserved: reserved
1553  * @ap: per-AP data
1554  */
1555 struct iwl_tof_range_rsp_ntfy_v6 {
1556 	u8 request_id;
1557 	u8 num_of_aps;
1558 	u8 last_report;
1559 	u8 reserved;
1560 	struct iwl_tof_range_rsp_ap_entry_ntfy_v4 ap[IWL_MVM_TOF_MAX_APS];
1561 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_6 */
1562 
1563 /**
1564  * struct iwl_tof_range_rsp_ntfy_v7 - ranging response notification
1565  * @request_id: A Token ID of the corresponding Range request
1566  * @num_of_aps: Number of APs results
1567  * @last_report: 1 if no more FTM sessions are scheduled, 0 otherwise.
1568  * @reserved: reserved
1569  * @ap: per-AP data
1570  */
1571 struct iwl_tof_range_rsp_ntfy_v7 {
1572 	u8 request_id;
1573 	u8 num_of_aps;
1574 	u8 last_report;
1575 	u8 reserved;
1576 	struct iwl_tof_range_rsp_ap_entry_ntfy_v5 ap[IWL_MVM_TOF_MAX_APS];
1577 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_7 */
1578 
1579 /**
1580  * struct iwl_tof_range_rsp_ntfy_v8 - ranging response notification
1581  * @request_id: A Token ID of the corresponding Range request
1582  * @num_of_aps: Number of APs results
1583  * @last_report: 1 if no more FTM sessions are scheduled, 0 otherwise.
1584  * @reserved: reserved
1585  * @ap: per-AP data
1586  */
1587 struct iwl_tof_range_rsp_ntfy_v8 {
1588 	u8 request_id;
1589 	u8 num_of_aps;
1590 	u8 last_report;
1591 	u8 reserved;
1592 	struct iwl_tof_range_rsp_ap_entry_ntfy_v6 ap[IWL_MVM_TOF_MAX_APS];
1593 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_8,
1594 	       LOCATION_RANGE_RSP_NTFY_API_S_VER_9 */
1595 
1596 #define IWL_MVM_TOF_MCSI_BUF_SIZE  (245)
1597 /**
1598  * struct iwl_tof_mcsi_notif - used for debug
1599  * @token: token ID for the current session
1600  * @role: '0' - initiator, '1' - responder
1601  * @reserved: reserved
1602  * @initiator_bssid: initiator machine
1603  * @responder_bssid: responder machine
1604  * @mcsi_buffer: debug data
1605  */
1606 struct iwl_tof_mcsi_notif {
1607 	u8 token;
1608 	u8 role;
1609 	__le16 reserved;
1610 	u8 initiator_bssid[ETH_ALEN];
1611 	u8 responder_bssid[ETH_ALEN];
1612 	u8 mcsi_buffer[IWL_MVM_TOF_MCSI_BUF_SIZE * 4];
1613 } __packed;
1614 
1615 /**
1616  * struct iwl_tof_range_abort_cmd
1617  * @request_id: corresponds to a range request
1618  * @reserved: reserved
1619  */
1620 struct iwl_tof_range_abort_cmd {
1621 	u8 request_id;
1622 	u8 reserved[3];
1623 } __packed;
1624 
1625 enum ftm_responder_stats_flags {
1626 	FTM_RESP_STAT_NON_ASAP_STARTED = BIT(0),
1627 	FTM_RESP_STAT_NON_ASAP_IN_WIN = BIT(1),
1628 	FTM_RESP_STAT_NON_ASAP_OUT_WIN = BIT(2),
1629 	FTM_RESP_STAT_TRIGGER_DUP = BIT(3),
1630 	FTM_RESP_STAT_DUP = BIT(4),
1631 	FTM_RESP_STAT_DUP_IN_WIN = BIT(5),
1632 	FTM_RESP_STAT_DUP_OUT_WIN = BIT(6),
1633 	FTM_RESP_STAT_SCHED_SUCCESS = BIT(7),
1634 	FTM_RESP_STAT_ASAP_REQ = BIT(8),
1635 	FTM_RESP_STAT_NON_ASAP_REQ = BIT(9),
1636 	FTM_RESP_STAT_ASAP_RESP = BIT(10),
1637 	FTM_RESP_STAT_NON_ASAP_RESP = BIT(11),
1638 	FTM_RESP_STAT_FAIL_INITIATOR_INACTIVE = BIT(12),
1639 	FTM_RESP_STAT_FAIL_INITIATOR_OUT_WIN = BIT(13),
1640 	FTM_RESP_STAT_FAIL_INITIATOR_RETRY_LIM = BIT(14),
1641 	FTM_RESP_STAT_FAIL_NEXT_SERVED = BIT(15),
1642 	FTM_RESP_STAT_FAIL_TRIGGER_ERR = BIT(16),
1643 	FTM_RESP_STAT_FAIL_GC = BIT(17),
1644 	FTM_RESP_STAT_SUCCESS = BIT(18),
1645 	FTM_RESP_STAT_INTEL_IE = BIT(19),
1646 	FTM_RESP_STAT_INITIATOR_ACTIVE = BIT(20),
1647 	FTM_RESP_STAT_MEASUREMENTS_AVAILABLE = BIT(21),
1648 	FTM_RESP_STAT_TRIGGER_UNKNOWN = BIT(22),
1649 	FTM_RESP_STAT_PROCESS_FAIL = BIT(23),
1650 	FTM_RESP_STAT_ACK = BIT(24),
1651 	FTM_RESP_STAT_NACK = BIT(25),
1652 	FTM_RESP_STAT_INVALID_INITIATOR_ID = BIT(26),
1653 	FTM_RESP_STAT_TIMER_MIN_DELTA = BIT(27),
1654 	FTM_RESP_STAT_INITIATOR_REMOVED = BIT(28),
1655 	FTM_RESP_STAT_INITIATOR_ADDED = BIT(29),
1656 	FTM_RESP_STAT_ERR_LIST_FULL = BIT(30),
1657 	FTM_RESP_STAT_INITIATOR_SCHED_NOW = BIT(31),
1658 }; /* RESP_IND_E */
1659 
1660 /**
1661  * struct iwl_ftm_responder_stats - FTM responder statistics
1662  * @addr: initiator address
1663  * @success_ftm: number of successful ftm frames
1664  * @ftm_per_burst: num of FTM frames that were received
1665  * @flags: &enum ftm_responder_stats_flags
1666  * @duration: actual duration of FTM
1667  * @allocated_duration: time that was allocated for this FTM session
1668  * @bw: FTM request bandwidth
1669  * @rate: FTM request rate
1670  * @reserved: for alingment and future use
1671  */
1672 struct iwl_ftm_responder_stats {
1673 	u8 addr[ETH_ALEN];
1674 	u8 success_ftm;
1675 	u8 ftm_per_burst;
1676 	__le32 flags;
1677 	__le32 duration;
1678 	__le32 allocated_duration;
1679 	u8 bw;
1680 	u8 rate;
1681 	__le16 reserved;
1682 } __packed; /* TOF_RESPONDER_STATISTICS_NTFY_S_VER_2 */
1683 
1684 #define IWL_CSI_MAX_EXPECTED_CHUNKS		16
1685 
1686 #define IWL_CSI_CHUNK_CTL_NUM_MASK_VER_1	0x0003
1687 #define IWL_CSI_CHUNK_CTL_IDX_MASK_VER_1	0x000c
1688 
1689 #define IWL_CSI_CHUNK_CTL_NUM_MASK_VER_2	0x00ff
1690 #define IWL_CSI_CHUNK_CTL_IDX_MASK_VER_2	0xff00
1691 
1692 struct iwl_csi_chunk_notification {
1693 	__le32 token;
1694 	__le16 seq;
1695 	__le16 ctl;
1696 	__le32 size;
1697 	u8 data[];
1698 } __packed; /* CSI_CHUNKS_HDR_NTFY_API_S_VER_1/VER_2 */
1699 
1700 #endif /* __iwl_fw_api_location_h__ */
1701