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  * @IWL_LOCATION_BW_160MHZ: 160MHz
634  */
635 enum iwl_location_bw {
636 	IWL_LOCATION_BW_20MHZ,
637 	IWL_LOCATION_BW_40MHZ,
638 	IWL_LOCATION_BW_80MHZ,
639 	IWL_LOCATION_BW_160MHZ,
640 };
641 
642 #define TK_11AZ_LEN	32
643 
644 #define LOCATION_BW_POS	4
645 
646 /**
647  * struct iwl_tof_range_req_ap_entry_v4 - AP configuration parameters
648  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
649  * @channel_num: AP Channel number
650  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
651  *             bits 4 - 7: &enum iwl_location_bw.
652  * @ctrl_ch_position: Coding of the control channel position relative to the
653  *	center frequency, see iwl_mvm_get_ctrl_pos().
654  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
655  *	reply from the AP.
656  * @bssid: AP's BSSID
657  * @burst_period: Recommended value to be sent to the AP. Measurement
658  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
659  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
660  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
661  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
662  * @reserved: For alignment and future use
663  * @hltk: HLTK to be used for secured 11az measurement
664  * @tk: TK to be used for secured 11az measurement
665  */
666 struct iwl_tof_range_req_ap_entry_v4 {
667 	__le32 initiator_ap_flags;
668 	u8 channel_num;
669 	u8 format_bw;
670 	u8 ctrl_ch_position;
671 	u8 ftmr_max_retries;
672 	u8 bssid[ETH_ALEN];
673 	__le16 burst_period;
674 	u8 samples_per_burst;
675 	u8 num_of_bursts;
676 	__le16 reserved;
677 	u8 hltk[HLTK_11AZ_LEN];
678 	u8 tk[TK_11AZ_LEN];
679 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_4 */
680 
681 /**
682  * enum iwl_location_cipher - location cipher selection
683  * @IWL_LOCATION_CIPHER_CCMP_128: CCMP 128
684  * @IWL_LOCATION_CIPHER_GCMP_128: GCMP 128
685  * @IWL_LOCATION_CIPHER_GCMP_256: GCMP 256
686  * @IWL_LOCATION_CIPHER_INVALID: security is not used.
687  * @IWL_LOCATION_CIPHER_MAX: maximum value for this enum.
688  */
689 enum iwl_location_cipher {
690 	IWL_LOCATION_CIPHER_CCMP_128,
691 	IWL_LOCATION_CIPHER_GCMP_128,
692 	IWL_LOCATION_CIPHER_GCMP_256,
693 	IWL_LOCATION_CIPHER_INVALID,
694 	IWL_LOCATION_CIPHER_MAX,
695 };
696 
697 /**
698  * struct iwl_tof_range_req_ap_entry_v6 - AP configuration parameters
699  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
700  * @channel_num: AP Channel number
701  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
702  *             bits 4 - 7: &enum iwl_location_bw.
703  * @ctrl_ch_position: Coding of the control channel position relative to the
704  *	center frequency, see iwl_mvm_get_ctrl_pos().
705  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
706  *	reply from the AP.
707  * @bssid: AP's BSSID
708  * @burst_period: Recommended value to be sent to the AP. Measurement
709  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
710  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
711  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
712  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
713  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
714  *	otherwise should be set to &IWL_MVM_INVALID_STA.
715  * @cipher: pairwise cipher suite for secured measurement.
716  *          &enum iwl_location_cipher.
717  * @hltk: HLTK to be used for secured 11az measurement
718  * @tk: TK to be used for secured 11az measurement
719  * @calib: An array of calibration values per FTM rx bandwidth.
720  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
721  *         calibration value that corresponds to the rx bandwidth of the FTM
722  *         frame.
723  * @beacon_interval: beacon interval of the AP in TUs. Only required if
724  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
725  */
726 struct iwl_tof_range_req_ap_entry_v6 {
727 	__le32 initiator_ap_flags;
728 	u8 channel_num;
729 	u8 format_bw;
730 	u8 ctrl_ch_position;
731 	u8 ftmr_max_retries;
732 	u8 bssid[ETH_ALEN];
733 	__le16 burst_period;
734 	u8 samples_per_burst;
735 	u8 num_of_bursts;
736 	u8 sta_id;
737 	u8 cipher;
738 	u8 hltk[HLTK_11AZ_LEN];
739 	u8 tk[TK_11AZ_LEN];
740 	__le16 calib[IWL_TOF_BW_NUM];
741 	__le16 beacon_interval;
742 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_6 */
743 
744 /**
745  * struct iwl_tof_range_req_ap_entry_v7 - AP configuration parameters
746  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
747  * @channel_num: AP Channel number
748  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
749  *             bits 4 - 7: &enum iwl_location_bw.
750  * @ctrl_ch_position: Coding of the control channel position relative to the
751  *	center frequency, see iwl_mvm_get_ctrl_pos().
752  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
753  *	reply from the AP.
754  * @bssid: AP's BSSID
755  * @burst_period: Recommended value to be sent to the AP. Measurement
756  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
757  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
758  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
759  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
760  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
761  *	otherwise should be set to &IWL_MVM_INVALID_STA.
762  * @cipher: pairwise cipher suite for secured measurement.
763  *          &enum iwl_location_cipher.
764  * @hltk: HLTK to be used for secured 11az measurement
765  * @tk: TK to be used for secured 11az measurement
766  * @calib: An array of calibration values per FTM rx bandwidth.
767  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
768  *         calibration value that corresponds to the rx bandwidth of the FTM
769  *         frame.
770  * @beacon_interval: beacon interval of the AP in TUs. Only required if
771  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
772  * @rx_pn: the next expected PN for protected management frames Rx. LE byte
773  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
774  *	is set to &IWL_MVM_INVALID_STA.
775  * @tx_pn: the next PN to use for protected management frames Tx. LE byte
776  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
777  *	is set to &IWL_MVM_INVALID_STA.
778  */
779 struct iwl_tof_range_req_ap_entry_v7 {
780 	__le32 initiator_ap_flags;
781 	u8 channel_num;
782 	u8 format_bw;
783 	u8 ctrl_ch_position;
784 	u8 ftmr_max_retries;
785 	u8 bssid[ETH_ALEN];
786 	__le16 burst_period;
787 	u8 samples_per_burst;
788 	u8 num_of_bursts;
789 	u8 sta_id;
790 	u8 cipher;
791 	u8 hltk[HLTK_11AZ_LEN];
792 	u8 tk[TK_11AZ_LEN];
793 	__le16 calib[IWL_TOF_BW_NUM];
794 	__le16 beacon_interval;
795 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
796 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
797 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_7 */
798 
799 #define IWL_LOCATION_MAX_STS_POS	3
800 
801 /**
802  * struct iwl_tof_range_req_ap_entry_v8 - AP configuration parameters
803  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
804  * @channel_num: AP Channel number
805  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
806  *             bits 4 - 7: &enum iwl_location_bw.
807  * @ctrl_ch_position: Coding of the control channel position relative to the
808  *	center frequency, see iwl_mvm_get_ctrl_pos().
809  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
810  *	reply from the AP.
811  * @bssid: AP's BSSID
812  * @burst_period: Recommended value to be sent to the AP. Measurement
813  *	periodicity In units of 100ms. ignored if num_of_bursts_exp = 0
814  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
815  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
816  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
817  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
818  *	otherwise should be set to &IWL_MVM_INVALID_STA.
819  * @cipher: pairwise cipher suite for secured measurement.
820  *          &enum iwl_location_cipher.
821  * @hltk: HLTK to be used for secured 11az measurement
822  * @tk: TK to be used for secured 11az measurement
823  * @calib: An array of calibration values per FTM rx bandwidth.
824  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
825  *         calibration value that corresponds to the rx bandwidth of the FTM
826  *         frame.
827  * @beacon_interval: beacon interval of the AP in TUs. Only required if
828  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
829  * @rx_pn: the next expected PN for protected management frames Rx. LE byte
830  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
831  *	is set to &IWL_MVM_INVALID_STA.
832  * @tx_pn: the next PN to use for protected management frames Tx. LE byte
833  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
834  *	is set to &IWL_MVM_INVALID_STA.
835  * @r2i_ndp_params: parameters for R2I NDP ranging negotiation.
836  *      bits 0 - 2: max LTF repetitions
837  *      bits 3 - 5: max number of spatial streams
838  *      bits 6 - 7: reserved
839  * @i2r_ndp_params: parameters for I2R NDP ranging negotiation.
840  *      bits 0 - 2: max LTF repetitions
841  *      bits 3 - 5: max number of spatial streams (supported values are < 2)
842  *      bits 6 - 7: reserved
843  * @r2i_max_total_ltf: R2I Max Total LTFs for NDP ranging negotiation.
844  *      One of &enum ieee80211_range_params_max_total_ltf.
845  * @i2r_max_total_ltf: I2R Max Total LTFs for NDP ranging negotiation.
846  *      One of &enum ieee80211_range_params_max_total_ltf.
847  */
848 struct iwl_tof_range_req_ap_entry_v8 {
849 	__le32 initiator_ap_flags;
850 	u8 channel_num;
851 	u8 format_bw;
852 	u8 ctrl_ch_position;
853 	u8 ftmr_max_retries;
854 	u8 bssid[ETH_ALEN];
855 	__le16 burst_period;
856 	u8 samples_per_burst;
857 	u8 num_of_bursts;
858 	u8 sta_id;
859 	u8 cipher;
860 	u8 hltk[HLTK_11AZ_LEN];
861 	u8 tk[TK_11AZ_LEN];
862 	__le16 calib[IWL_TOF_BW_NUM];
863 	__le16 beacon_interval;
864 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
865 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
866 	u8 r2i_ndp_params;
867 	u8 i2r_ndp_params;
868 	u8 r2i_max_total_ltf;
869 	u8 i2r_max_total_ltf;
870 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_8 */
871 
872 /**
873  * struct iwl_tof_range_req_ap_entry_v9 - AP configuration parameters
874  * @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
875  * @channel_num: AP Channel number
876  * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
877  *             bits 4 - 7: &enum iwl_location_bw.
878  * @ctrl_ch_position: Coding of the control channel position relative to the
879  *	center frequency, see iwl_mvm_get_ctrl_pos().
880  * @ftmr_max_retries: Max number of retries to send the FTMR in case of no
881  *	reply from the AP.
882  * @bssid: AP's BSSID
883  * @burst_period: For EDCA based ranging: Recommended value to be sent to the
884  *	AP. Measurement periodicity In units of 100ms. ignored if
885  *	num_of_bursts_exp = 0.
886  *	For non trigger based NDP ranging, the maximum time between
887  *	measurements in units of milliseconds.
888  * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
889  * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
890  *	the number of measurement iterations (min 2^0 = 1, max 2^14)
891  * @sta_id: the station id of the AP. Only relevant when associated to the AP,
892  *	otherwise should be set to &IWL_MVM_INVALID_STA.
893  * @cipher: pairwise cipher suite for secured measurement.
894  *          &enum iwl_location_cipher.
895  * @hltk: HLTK to be used for secured 11az measurement
896  * @tk: TK to be used for secured 11az measurement
897  * @calib: An array of calibration values per FTM rx bandwidth.
898  *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
899  *         calibration value that corresponds to the rx bandwidth of the FTM
900  *         frame.
901  * @beacon_interval: beacon interval of the AP in TUs. Only required if
902  *	&IWL_INITIATOR_AP_FLAGS_TB is set.
903  * @bss_color: the BSS color of the responder. Only valid if
904  *	&IWL_INITIATOR_AP_FLAGS_TB or &IWL_INITIATOR_AP_FLAGS_NON_TB is set.
905  * @rx_pn: the next expected PN for protected management frames Rx. LE byte
906  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
907  *	is set to &IWL_MVM_INVALID_STA.
908  * @tx_pn: the next PN to use for protected management frames Tx. LE byte
909  *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
910  *	is set to &IWL_MVM_INVALID_STA.
911  * @r2i_ndp_params: parameters for R2I NDP ranging negotiation.
912  *      bits 0 - 2: max LTF repetitions
913  *      bits 3 - 5: max number of spatial streams
914  *      bits 6 - 7: reserved
915  * @i2r_ndp_params: parameters for I2R NDP ranging negotiation.
916  *      bits 0 - 2: max LTF repetitions
917  *      bits 3 - 5: max number of spatial streams (supported values are < 2)
918  *      bits 6 - 7: reserved
919  * @r2i_max_total_ltf: R2I Max Total LTFs for NDP ranging negotiation.
920  *      One of &enum ieee80211_range_params_max_total_ltf.
921  * @i2r_max_total_ltf: I2R Max Total LTFs for NDP ranging negotiation.
922  *      One of &enum ieee80211_range_params_max_total_ltf.
923  * @bss_color: the BSS color of the responder. Only valid if
924  *	&IWL_INITIATOR_AP_FLAGS_NON_TB or &IWL_INITIATOR_AP_FLAGS_TB is set.
925  * @band: 0 for 5.2 GHz, 1 for 2.4 GHz, 2 for 6GHz
926  * @min_time_between_msr: For non trigger based NDP ranging, the minimum time
927  *	between measurements in units of milliseconds
928  */
929 struct iwl_tof_range_req_ap_entry_v9 {
930 	__le32 initiator_ap_flags;
931 	u8 channel_num;
932 	u8 format_bw;
933 	u8 ctrl_ch_position;
934 	u8 ftmr_max_retries;
935 	u8 bssid[ETH_ALEN];
936 	__le16 burst_period;
937 	u8 samples_per_burst;
938 	u8 num_of_bursts;
939 	u8 sta_id;
940 	u8 cipher;
941 	u8 hltk[HLTK_11AZ_LEN];
942 	u8 tk[TK_11AZ_LEN];
943 	__le16 calib[IWL_TOF_BW_NUM];
944 	u16 beacon_interval;
945 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
946 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
947 	u8 r2i_ndp_params;
948 	u8 i2r_ndp_params;
949 	u8 r2i_max_total_ltf;
950 	u8 i2r_max_total_ltf;
951 	u8 bss_color;
952 	u8 band;
953 	__le16 min_time_between_msr;
954 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_9 */
955 
956 /**
957  * enum iwl_tof_response_mode
958  * @IWL_MVM_TOF_RESPONSE_ASAP: report each AP measurement separately as soon as
959  *			       possible (not supported for this release)
960  * @IWL_MVM_TOF_RESPONSE_TIMEOUT: report all AP measurements as a batch upon
961  *				  timeout expiration
962  * @IWL_MVM_TOF_RESPONSE_COMPLETE: report all AP measurements as a batch at the
963  *				   earlier of: measurements completion / timeout
964  *				   expiration.
965  */
966 enum iwl_tof_response_mode {
967 	IWL_MVM_TOF_RESPONSE_ASAP,
968 	IWL_MVM_TOF_RESPONSE_TIMEOUT,
969 	IWL_MVM_TOF_RESPONSE_COMPLETE,
970 };
971 
972 /**
973  * enum iwl_tof_initiator_flags
974  *
975  * @IWL_TOF_INITIATOR_FLAGS_FAST_ALGO_DISABLED: disable fast algo, meaning run
976  *	the algo on ant A+B, instead of only one of them.
977  * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_A: open RX antenna A for FTMs RX
978  * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_B: open RX antenna B for FTMs RX
979  * @IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_C: open RX antenna C for FTMs RX
980  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A: use antenna A fo TX ACKs during FTM
981  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B: use antenna B fo TX ACKs during FTM
982  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C: use antenna C fo TX ACKs during FTM
983  * @IWL_TOF_INITIATOR_FLAGS_MACADDR_RANDOM: use random mac address for FTM
984  * @IWL_TOF_INITIATOR_FLAGS_SPECIFIC_CALIB: use the specific calib value from
985  *	the range request command
986  * @IWL_TOF_INITIATOR_FLAGS_COMMON_CALIB: use the common calib value from the
987  *	ragne request command
988  * @IWL_TOF_INITIATOR_FLAGS_NON_ASAP_SUPPORT: support non-asap measurements
989  */
990 enum iwl_tof_initiator_flags {
991 	IWL_TOF_INITIATOR_FLAGS_FAST_ALGO_DISABLED = BIT(0),
992 	IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_A = BIT(1),
993 	IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_B = BIT(2),
994 	IWL_TOF_INITIATOR_FLAGS_RX_CHAIN_SEL_C = BIT(3),
995 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A = BIT(4),
996 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B = BIT(5),
997 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C = BIT(6),
998 	IWL_TOF_INITIATOR_FLAGS_MACADDR_RANDOM = BIT(7),
999 	IWL_TOF_INITIATOR_FLAGS_SPECIFIC_CALIB = BIT(15),
1000 	IWL_TOF_INITIATOR_FLAGS_COMMON_CALIB   = BIT(16),
1001 	IWL_TOF_INITIATOR_FLAGS_NON_ASAP_SUPPORT = BIT(20),
1002 }; /* LOCATION_RANGE_REQ_CMD_API_S_VER_5 */
1003 
1004 #define IWL_MVM_TOF_MAX_APS 5
1005 #define IWL_MVM_TOF_MAX_TWO_SIDED_APS 5
1006 
1007 /**
1008  * struct iwl_tof_range_req_cmd_v5 - start measurement cmd
1009  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1010  * @request_id: A Token incremented per request. The same Token will be
1011  *		sent back in the range response
1012  * @initiator: 0- NW initiated,  1 - Client Initiated
1013  * @one_sided_los_disable: '0'- run ML-Algo for both ToF/OneSided,
1014  *			   '1' - run ML-Algo for ToF only
1015  * @req_timeout: Requested timeout of the response in units of 100ms.
1016  *	     This is equivalent to the session time configured to the
1017  *	     LMAC in Initiator Request
1018  * @report_policy: Supported partially for this release: For current release -
1019  *		   the range report will be uploaded as a batch when ready or
1020  *		   when the session is done (successfully / partially).
1021  *		   one of iwl_tof_response_mode.
1022  * @reserved0: reserved
1023  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1024  * @macaddr_random: '0' Use default source MAC address (i.e. p2_p),
1025  *	            '1' Use MAC Address randomization according to the below
1026  * @range_req_bssid: ranging request BSSID
1027  * @macaddr_template: MAC address template to use for non-randomized bits
1028  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1029  *		  Bits set to 1 shall be randomized by the UMAC
1030  * @ftm_rx_chains: Rx chain to open to receive Responder's FTMs (XVT)
1031  * @ftm_tx_chains: Tx chain to send the ack to the Responder FTM (XVT)
1032  * @common_calib: The common calib value to inject to this measurement calc
1033  * @specific_calib: The specific calib value to inject to this measurement calc
1034  * @ap: per-AP request data
1035  */
1036 struct iwl_tof_range_req_cmd_v5 {
1037 	__le32 initiator_flags;
1038 	u8 request_id;
1039 	u8 initiator;
1040 	u8 one_sided_los_disable;
1041 	u8 req_timeout;
1042 	u8 report_policy;
1043 	u8 reserved0;
1044 	u8 num_of_ap;
1045 	u8 macaddr_random;
1046 	u8 range_req_bssid[ETH_ALEN];
1047 	u8 macaddr_template[ETH_ALEN];
1048 	u8 macaddr_mask[ETH_ALEN];
1049 	u8 ftm_rx_chains;
1050 	u8 ftm_tx_chains;
1051 	__le16 common_calib;
1052 	__le16 specific_calib;
1053 	struct iwl_tof_range_req_ap_entry_v2 ap[IWL_MVM_TOF_MAX_APS];
1054 } __packed;
1055 /* LOCATION_RANGE_REQ_CMD_API_S_VER_5 */
1056 
1057 /**
1058  * struct iwl_tof_range_req_cmd_v7 - start measurement cmd
1059  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1060  * @request_id: A Token incremented per request. The same Token will be
1061  *		sent back in the range response
1062  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1063  * @range_req_bssid: ranging request BSSID
1064  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1065  *		  Bits set to 1 shall be randomized by the UMAC
1066  * @macaddr_template: MAC address template to use for non-randomized bits
1067  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1068  *	This is the session time for completing the measurement.
1069  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1070  *	TSF of this mac id. 0xff to disable TSF reporting.
1071  * @common_calib: The common calib value to inject to this measurement calc
1072  * @specific_calib: The specific calib value to inject to this measurement calc
1073  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1074  */
1075 struct iwl_tof_range_req_cmd_v7 {
1076 	__le32 initiator_flags;
1077 	u8 request_id;
1078 	u8 num_of_ap;
1079 	u8 range_req_bssid[ETH_ALEN];
1080 	u8 macaddr_mask[ETH_ALEN];
1081 	u8 macaddr_template[ETH_ALEN];
1082 	__le32 req_timeout_ms;
1083 	__le32 tsf_mac_id;
1084 	__le16 common_calib;
1085 	__le16 specific_calib;
1086 	struct iwl_tof_range_req_ap_entry_v3 ap[IWL_MVM_TOF_MAX_APS];
1087 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_7 */
1088 
1089 /**
1090  * struct iwl_tof_range_req_cmd_v8 - start measurement cmd
1091  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1092  * @request_id: A Token incremented per request. The same Token will be
1093  *		sent back in the range response
1094  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1095  * @range_req_bssid: ranging request BSSID
1096  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1097  *		  Bits set to 1 shall be randomized by the UMAC
1098  * @macaddr_template: MAC address template to use for non-randomized bits
1099  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1100  *	This is the session time for completing the measurement.
1101  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1102  *	TSF of this mac id. 0xff to disable TSF reporting.
1103  * @common_calib: The common calib value to inject to this measurement calc
1104  * @specific_calib: The specific calib value to inject to this measurement calc
1105  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1106  */
1107 struct iwl_tof_range_req_cmd_v8 {
1108 	__le32 initiator_flags;
1109 	u8 request_id;
1110 	u8 num_of_ap;
1111 	u8 range_req_bssid[ETH_ALEN];
1112 	u8 macaddr_mask[ETH_ALEN];
1113 	u8 macaddr_template[ETH_ALEN];
1114 	__le32 req_timeout_ms;
1115 	__le32 tsf_mac_id;
1116 	__le16 common_calib;
1117 	__le16 specific_calib;
1118 	struct iwl_tof_range_req_ap_entry_v4 ap[IWL_MVM_TOF_MAX_APS];
1119 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_8 */
1120 
1121 /**
1122  * struct iwl_tof_range_req_cmd_v9 - start measurement cmd
1123  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1124  * @request_id: A Token incremented per request. The same Token will be
1125  *		sent back in the range response
1126  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1127  * @range_req_bssid: ranging request BSSID
1128  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1129  *		  Bits set to 1 shall be randomized by the UMAC
1130  * @macaddr_template: MAC address template to use for non-randomized bits
1131  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1132  *	This is the session time for completing the measurement.
1133  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1134  *	TSF of this mac id. 0xff to disable TSF reporting.
1135  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1136  */
1137 struct iwl_tof_range_req_cmd_v9 {
1138 	__le32 initiator_flags;
1139 	u8 request_id;
1140 	u8 num_of_ap;
1141 	u8 range_req_bssid[ETH_ALEN];
1142 	u8 macaddr_mask[ETH_ALEN];
1143 	u8 macaddr_template[ETH_ALEN];
1144 	__le32 req_timeout_ms;
1145 	__le32 tsf_mac_id;
1146 	struct iwl_tof_range_req_ap_entry_v6 ap[IWL_MVM_TOF_MAX_APS];
1147 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_9 */
1148 
1149 /**
1150  * struct iwl_tof_range_req_cmd_v11 - start measurement cmd
1151  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1152  * @request_id: A Token incremented per request. The same Token will be
1153  *		sent back in the range response
1154  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1155  * @range_req_bssid: ranging request BSSID
1156  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1157  *		  Bits set to 1 shall be randomized by the UMAC
1158  * @macaddr_template: MAC address template to use for non-randomized bits
1159  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1160  *	This is the session time for completing the measurement.
1161  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1162  *	TSF of this mac id. 0xff to disable TSF reporting.
1163  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1164  */
1165 struct iwl_tof_range_req_cmd_v11 {
1166 	__le32 initiator_flags;
1167 	u8 request_id;
1168 	u8 num_of_ap;
1169 	u8 range_req_bssid[ETH_ALEN];
1170 	u8 macaddr_mask[ETH_ALEN];
1171 	u8 macaddr_template[ETH_ALEN];
1172 	__le32 req_timeout_ms;
1173 	__le32 tsf_mac_id;
1174 	struct iwl_tof_range_req_ap_entry_v7 ap[IWL_MVM_TOF_MAX_APS];
1175 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_11 */
1176 
1177 /**
1178  * struct iwl_tof_range_req_cmd_v12 - start measurement cmd
1179  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1180  * @request_id: A Token incremented per request. The same Token will be
1181  *		sent back in the range response
1182  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1183  * @range_req_bssid: ranging request BSSID
1184  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1185  *		  Bits set to 1 shall be randomized by the UMAC
1186  * @macaddr_template: MAC address template to use for non-randomized bits
1187  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1188  *	This is the session time for completing the measurement.
1189  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1190  *	TSF of this mac id. 0xff to disable TSF reporting.
1191  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v2.
1192  */
1193 struct iwl_tof_range_req_cmd_v12 {
1194 	__le32 initiator_flags;
1195 	u8 request_id;
1196 	u8 num_of_ap;
1197 	u8 range_req_bssid[ETH_ALEN];
1198 	u8 macaddr_mask[ETH_ALEN];
1199 	u8 macaddr_template[ETH_ALEN];
1200 	__le32 req_timeout_ms;
1201 	__le32 tsf_mac_id;
1202 	struct iwl_tof_range_req_ap_entry_v8 ap[IWL_MVM_TOF_MAX_APS];
1203 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_12 */
1204 
1205 /**
1206  * struct iwl_tof_range_req_cmd_v13 - start measurement cmd
1207  * @initiator_flags: see flags @ iwl_tof_initiator_flags
1208  * @request_id: A Token incremented per request. The same Token will be
1209  *		sent back in the range response
1210  * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1211  * @range_req_bssid: ranging request BSSID
1212  * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
1213  *		  Bits set to 1 shall be randomized by the UMAC
1214  * @macaddr_template: MAC address template to use for non-randomized bits
1215  * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
1216  *	This is the session time for completing the measurement.
1217  * @tsf_mac_id: report the measurement start time for each ap in terms of the
1218  *	TSF of this mac id. 0xff to disable TSF reporting.
1219  * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v9.
1220  */
1221 struct iwl_tof_range_req_cmd_v13 {
1222 	__le32 initiator_flags;
1223 	u8 request_id;
1224 	u8 num_of_ap;
1225 	u8 range_req_bssid[ETH_ALEN];
1226 	u8 macaddr_mask[ETH_ALEN];
1227 	u8 macaddr_template[ETH_ALEN];
1228 	__le32 req_timeout_ms;
1229 	__le32 tsf_mac_id;
1230 	struct iwl_tof_range_req_ap_entry_v9 ap[IWL_MVM_TOF_MAX_APS];
1231 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_13 */
1232 
1233 /*
1234  * enum iwl_tof_range_request_status - status of the sent request
1235  * @IWL_TOF_RANGE_REQUEST_STATUS_SUCCESSFUL - FW successfully received the
1236  *	request
1237  * @IWL_TOF_RANGE_REQUEST_STATUS_BUSY - FW is busy with a previous request, the
1238  *	sent request will not be handled
1239  */
1240 enum iwl_tof_range_request_status {
1241 	IWL_TOF_RANGE_REQUEST_STATUS_SUCCESS,
1242 	IWL_TOF_RANGE_REQUEST_STATUS_BUSY,
1243 };
1244 
1245 /**
1246  * enum iwl_tof_entry_status
1247  *
1248  * @IWL_TOF_ENTRY_SUCCESS: successful measurement.
1249  * @IWL_TOF_ENTRY_GENERAL_FAILURE: General failure.
1250  * @IWL_TOF_ENTRY_NO_RESPONSE: Responder didn't reply to the request.
1251  * @IWL_TOF_ENTRY_REQUEST_REJECTED: Responder rejected the request.
1252  * @IWL_TOF_ENTRY_NOT_SCHEDULED: Time event was scheduled but not called yet.
1253  * @IWL_TOF_ENTRY_TIMING_MEASURE_TIMEOUT: Time event triggered but no
1254  *	measurement was completed.
1255  * @IWL_TOF_ENTRY_TARGET_DIFF_CH_CANNOT_CHANGE: No range due inability to switch
1256  *	from the primary channel.
1257  * @IWL_TOF_ENTRY_RANGE_NOT_SUPPORTED: Device doesn't support FTM.
1258  * @IWL_TOF_ENTRY_REQUEST_ABORT_UNKNOWN_REASON: Request aborted due to unknown
1259  *	reason.
1260  * @IWL_TOF_ENTRY_LOCATION_INVALID_T1_T4_TIME_STAMP: Failure due to invalid
1261  *	T1/T4.
1262  * @IWL_TOF_ENTRY_11MC_PROTOCOL_FAILURE: Failure due to invalid FTM frame
1263  *	structure.
1264  * @IWL_TOF_ENTRY_REQUEST_CANNOT_SCHED: Request cannot be scheduled.
1265  * @IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE: Responder cannot serve the
1266  *	initiator for some period, period supplied in @refusal_period.
1267  * @IWL_TOF_ENTRY_BAD_REQUEST_ARGS: Bad request arguments.
1268  * @IWL_TOF_ENTRY_WIFI_NOT_ENABLED: Wifi not enabled.
1269  * @IWL_TOF_ENTRY_RESPONDER_OVERRIDE_PARAMS: Responder override the original
1270  *	parameters within the current session.
1271  */
1272 enum iwl_tof_entry_status {
1273 	IWL_TOF_ENTRY_SUCCESS = 0,
1274 	IWL_TOF_ENTRY_GENERAL_FAILURE = 1,
1275 	IWL_TOF_ENTRY_NO_RESPONSE = 2,
1276 	IWL_TOF_ENTRY_REQUEST_REJECTED = 3,
1277 	IWL_TOF_ENTRY_NOT_SCHEDULED = 4,
1278 	IWL_TOF_ENTRY_TIMING_MEASURE_TIMEOUT = 5,
1279 	IWL_TOF_ENTRY_TARGET_DIFF_CH_CANNOT_CHANGE = 6,
1280 	IWL_TOF_ENTRY_RANGE_NOT_SUPPORTED = 7,
1281 	IWL_TOF_ENTRY_REQUEST_ABORT_UNKNOWN_REASON = 8,
1282 	IWL_TOF_ENTRY_LOCATION_INVALID_T1_T4_TIME_STAMP = 9,
1283 	IWL_TOF_ENTRY_11MC_PROTOCOL_FAILURE = 10,
1284 	IWL_TOF_ENTRY_REQUEST_CANNOT_SCHED = 11,
1285 	IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE = 12,
1286 	IWL_TOF_ENTRY_BAD_REQUEST_ARGS = 13,
1287 	IWL_TOF_ENTRY_WIFI_NOT_ENABLED = 14,
1288 	IWL_TOF_ENTRY_RESPONDER_OVERRIDE_PARAMS = 15,
1289 }; /* LOCATION_RANGE_RSP_AP_ENTRY_NTFY_API_S_VER_2 */
1290 
1291 /**
1292  * struct iwl_tof_range_rsp_ap_entry_ntfy_v3 - AP parameters (response)
1293  * @bssid: BSSID of the AP
1294  * @measure_status: current APs measurement status, one of
1295  *	&enum iwl_tof_entry_status.
1296  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1297  * @rtt: The Round Trip Time that took for the last measurement for
1298  *	current AP [pSec]
1299  * @rtt_variance: The Variance of the RTT values measured for current AP
1300  * @rtt_spread: The Difference between the maximum and the minimum RTT
1301  *	values measured for current AP in the current session [pSec]
1302  * @rssi: RSSI as uploaded in the Channel Estimation notification
1303  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1304  *	measured for current AP in the current session
1305  * @reserved: reserved
1306  * @refusal_period: refusal period in case of
1307  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1308  * @range: Measured range [cm]
1309  * @range_variance: Measured range variance [cm]
1310  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1311  *	uploaded by the LMAC
1312  * @t2t3_initiator: as calculated from the algo in the initiator
1313  * @t1t4_responder: as calculated from the algo in the responder
1314  * @common_calib: Calib val that was used in for this AP measurement
1315  * @specific_calib: val that was used in for this AP measurement
1316  * @papd_calib_output: The result of the tof papd calibration that was injected
1317  *	into the algorithm.
1318  */
1319 struct iwl_tof_range_rsp_ap_entry_ntfy_v3 {
1320 	u8 bssid[ETH_ALEN];
1321 	u8 measure_status;
1322 	u8 measure_bw;
1323 	__le32 rtt;
1324 	__le32 rtt_variance;
1325 	__le32 rtt_spread;
1326 	s8 rssi;
1327 	u8 rssi_spread;
1328 	u8 reserved;
1329 	u8 refusal_period;
1330 	__le32 range;
1331 	__le32 range_variance;
1332 	__le32 timestamp;
1333 	__le32 t2t3_initiator;
1334 	__le32 t1t4_responder;
1335 	__le16 common_calib;
1336 	__le16 specific_calib;
1337 	__le32 papd_calib_output;
1338 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_3 */
1339 
1340 /**
1341  * struct iwl_tof_range_rsp_ap_entry_ntfy_v4 - AP parameters (response)
1342  * @bssid: BSSID of the AP
1343  * @measure_status: current APs measurement status, one of
1344  *	&enum iwl_tof_entry_status.
1345  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1346  * @rtt: The Round Trip Time that took for the last measurement for
1347  *	current AP [pSec]
1348  * @rtt_variance: The Variance of the RTT values measured for current AP
1349  * @rtt_spread: The Difference between the maximum and the minimum RTT
1350  *	values measured for current AP in the current session [pSec]
1351  * @rssi: RSSI as uploaded in the Channel Estimation notification
1352  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1353  *	measured for current AP in the current session
1354  * @last_burst: 1 if no more FTM sessions are scheduled for this responder
1355  * @refusal_period: refusal period in case of
1356  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1357  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1358  *	uploaded by the LMAC
1359  * @start_tsf: measurement start time in TSF of the mac specified in the range
1360  *	request
1361  * @rx_rate_n_flags: rate and flags of the last FTM frame received from this
1362  *	responder
1363  * @tx_rate_n_flags: rate and flags of the last ack sent to this responder
1364  * @t2t3_initiator: as calculated from the algo in the initiator
1365  * @t1t4_responder: as calculated from the algo in the responder
1366  * @common_calib: Calib val that was used in for this AP measurement
1367  * @specific_calib: val that was used in for this AP measurement
1368  * @papd_calib_output: The result of the tof papd calibration that was injected
1369  *	into the algorithm.
1370  */
1371 struct iwl_tof_range_rsp_ap_entry_ntfy_v4 {
1372 	u8 bssid[ETH_ALEN];
1373 	u8 measure_status;
1374 	u8 measure_bw;
1375 	__le32 rtt;
1376 	__le32 rtt_variance;
1377 	__le32 rtt_spread;
1378 	s8 rssi;
1379 	u8 rssi_spread;
1380 	u8 last_burst;
1381 	u8 refusal_period;
1382 	__le32 timestamp;
1383 	__le32 start_tsf;
1384 	__le32 rx_rate_n_flags;
1385 	__le32 tx_rate_n_flags;
1386 	__le32 t2t3_initiator;
1387 	__le32 t1t4_responder;
1388 	__le16 common_calib;
1389 	__le16 specific_calib;
1390 	__le32 papd_calib_output;
1391 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_4 */
1392 
1393 /**
1394  * struct iwl_tof_range_rsp_ap_entry_ntfy_v5 - AP parameters (response)
1395  * @bssid: BSSID of the AP
1396  * @measure_status: current APs measurement status, one of
1397  *	&enum iwl_tof_entry_status.
1398  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1399  * @rtt: The Round Trip Time that took for the last measurement for
1400  *	current AP [pSec]
1401  * @rtt_variance: The Variance of the RTT values measured for current AP
1402  * @rtt_spread: The Difference between the maximum and the minimum RTT
1403  *	values measured for current AP in the current session [pSec]
1404  * @rssi: RSSI as uploaded in the Channel Estimation notification
1405  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1406  *	measured for current AP in the current session
1407  * @last_burst: 1 if no more FTM sessions are scheduled for this responder
1408  * @refusal_period: refusal period in case of
1409  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1410  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1411  *	uploaded by the LMAC
1412  * @start_tsf: measurement start time in TSF of the mac specified in the range
1413  *	request
1414  * @rx_rate_n_flags: rate and flags of the last FTM frame received from this
1415  *	responder
1416  * @tx_rate_n_flags: rate and flags of the last ack sent to this responder
1417  * @t2t3_initiator: as calculated from the algo in the initiator
1418  * @t1t4_responder: as calculated from the algo in the responder
1419  * @common_calib: Calib val that was used in for this AP measurement
1420  * @specific_calib: val that was used in for this AP measurement
1421  * @papd_calib_output: The result of the tof papd calibration that was injected
1422  *	into the algorithm.
1423  * @rttConfidence: a value between 0 - 31 that represents the rtt accuracy.
1424  * @reserved: for alignment
1425  */
1426 struct iwl_tof_range_rsp_ap_entry_ntfy_v5 {
1427 	u8 bssid[ETH_ALEN];
1428 	u8 measure_status;
1429 	u8 measure_bw;
1430 	__le32 rtt;
1431 	__le32 rtt_variance;
1432 	__le32 rtt_spread;
1433 	s8 rssi;
1434 	u8 rssi_spread;
1435 	u8 last_burst;
1436 	u8 refusal_period;
1437 	__le32 timestamp;
1438 	__le32 start_tsf;
1439 	__le32 rx_rate_n_flags;
1440 	__le32 tx_rate_n_flags;
1441 	__le32 t2t3_initiator;
1442 	__le32 t1t4_responder;
1443 	__le16 common_calib;
1444 	__le16 specific_calib;
1445 	__le32 papd_calib_output;
1446 	u8 rttConfidence;
1447 	u8 reserved[3];
1448 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_5 */
1449 
1450 /**
1451  * struct iwl_tof_range_rsp_ap_entry_ntfy_v6 - AP parameters (response)
1452  * @bssid: BSSID of the AP
1453  * @measure_status: current APs measurement status, one of
1454  *	&enum iwl_tof_entry_status.
1455  * @measure_bw: Current AP Bandwidth: 0  20MHz, 1  40MHz, 2  80MHz
1456  * @rtt: The Round Trip Time that took for the last measurement for
1457  *	current AP [pSec]
1458  * @rtt_variance: The Variance of the RTT values measured for current AP
1459  * @rtt_spread: The Difference between the maximum and the minimum RTT
1460  *	values measured for current AP in the current session [pSec]
1461  * @rssi: RSSI as uploaded in the Channel Estimation notification
1462  * @rssi_spread: The Difference between the maximum and the minimum RSSI values
1463  *	measured for current AP in the current session
1464  * @last_burst: 1 if no more FTM sessions are scheduled for this responder
1465  * @refusal_period: refusal period in case of
1466  *	@IWL_TOF_ENTRY_RESPONDER_CANNOT_COLABORATE [sec]
1467  * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
1468  *	uploaded by the LMAC
1469  * @start_tsf: measurement start time in TSF of the mac specified in the range
1470  *	request
1471  * @rx_rate_n_flags: rate and flags of the last FTM frame received from this
1472  *	responder
1473  * @tx_rate_n_flags: rate and flags of the last ack sent to this responder
1474  * @t2t3_initiator: as calculated from the algo in the initiator
1475  * @t1t4_responder: as calculated from the algo in the responder
1476  * @common_calib: Calib val that was used in for this AP measurement
1477  * @specific_calib: val that was used in for this AP measurement
1478  * @papd_calib_output: The result of the tof papd calibration that was injected
1479  *	into the algorithm.
1480  * @rttConfidence: a value between 0 - 31 that represents the rtt accuracy.
1481  * @reserved: for alignment
1482  * @rx_pn: the last PN used for this responder Rx in case PMF is configured in
1483  *	LE byte order.
1484  * @tx_pn: the last PN used for this responder Tx in case PMF is configured in
1485  *	LE byte order.
1486  */
1487 struct iwl_tof_range_rsp_ap_entry_ntfy_v6 {
1488 	u8 bssid[ETH_ALEN];
1489 	u8 measure_status;
1490 	u8 measure_bw;
1491 	__le32 rtt;
1492 	__le32 rtt_variance;
1493 	__le32 rtt_spread;
1494 	s8 rssi;
1495 	u8 rssi_spread;
1496 	u8 last_burst;
1497 	u8 refusal_period;
1498 	__le32 timestamp;
1499 	__le32 start_tsf;
1500 	__le32 rx_rate_n_flags;
1501 	__le32 tx_rate_n_flags;
1502 	__le32 t2t3_initiator;
1503 	__le32 t1t4_responder;
1504 	__le16 common_calib;
1505 	__le16 specific_calib;
1506 	__le32 papd_calib_output;
1507 	u8 rttConfidence;
1508 	u8 reserved[3];
1509 	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
1510 	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
1511 } __packed; /* LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_6,
1512 	       LOCATION_RANGE_RSP_AP_ETRY_NTFY_API_S_VER_7 */
1513 
1514 
1515 /**
1516  * enum iwl_tof_response_status - tof response status
1517  *
1518  * @IWL_TOF_RESPONSE_SUCCESS: successful range.
1519  * @IWL_TOF_RESPONSE_TIMEOUT: request aborted due to timeout expiration.
1520  *	partial result of ranges done so far is included in the response.
1521  * @IWL_TOF_RESPONSE_ABORTED: Measurement aborted by command.
1522  * @IWL_TOF_RESPONSE_FAILED: Measurement request command failed.
1523  */
1524 enum iwl_tof_response_status {
1525 	IWL_TOF_RESPONSE_SUCCESS = 0,
1526 	IWL_TOF_RESPONSE_TIMEOUT = 1,
1527 	IWL_TOF_RESPONSE_ABORTED = 4,
1528 	IWL_TOF_RESPONSE_FAILED  = 5,
1529 }; /* LOCATION_RNG_RSP_STATUS */
1530 
1531 /**
1532  * struct iwl_tof_range_rsp_ntfy_v5 - ranging response notification
1533  * @request_id: A Token ID of the corresponding Range request
1534  * @request_status: status of current measurement session, one of
1535  *	&enum iwl_tof_response_status.
1536  * @last_in_batch: reprot policy (when not all responses are uploaded at once)
1537  * @num_of_aps: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
1538  * @ap: per-AP data
1539  */
1540 struct iwl_tof_range_rsp_ntfy_v5 {
1541 	u8 request_id;
1542 	u8 request_status;
1543 	u8 last_in_batch;
1544 	u8 num_of_aps;
1545 	struct iwl_tof_range_rsp_ap_entry_ntfy_v3 ap[IWL_MVM_TOF_MAX_APS];
1546 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_5 */
1547 
1548 /**
1549  * struct iwl_tof_range_rsp_ntfy_v6 - ranging response notification
1550  * @request_id: A Token ID of the corresponding Range request
1551  * @num_of_aps: Number of APs results
1552  * @last_report: 1 if no more FTM sessions are scheduled, 0 otherwise.
1553  * @reserved: reserved
1554  * @ap: per-AP data
1555  */
1556 struct iwl_tof_range_rsp_ntfy_v6 {
1557 	u8 request_id;
1558 	u8 num_of_aps;
1559 	u8 last_report;
1560 	u8 reserved;
1561 	struct iwl_tof_range_rsp_ap_entry_ntfy_v4 ap[IWL_MVM_TOF_MAX_APS];
1562 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_6 */
1563 
1564 /**
1565  * struct iwl_tof_range_rsp_ntfy_v7 - ranging response notification
1566  * @request_id: A Token ID of the corresponding Range request
1567  * @num_of_aps: Number of APs results
1568  * @last_report: 1 if no more FTM sessions are scheduled, 0 otherwise.
1569  * @reserved: reserved
1570  * @ap: per-AP data
1571  */
1572 struct iwl_tof_range_rsp_ntfy_v7 {
1573 	u8 request_id;
1574 	u8 num_of_aps;
1575 	u8 last_report;
1576 	u8 reserved;
1577 	struct iwl_tof_range_rsp_ap_entry_ntfy_v5 ap[IWL_MVM_TOF_MAX_APS];
1578 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_7 */
1579 
1580 /**
1581  * struct iwl_tof_range_rsp_ntfy_v8 - ranging response notification
1582  * @request_id: A Token ID of the corresponding Range request
1583  * @num_of_aps: Number of APs results
1584  * @last_report: 1 if no more FTM sessions are scheduled, 0 otherwise.
1585  * @reserved: reserved
1586  * @ap: per-AP data
1587  */
1588 struct iwl_tof_range_rsp_ntfy_v8 {
1589 	u8 request_id;
1590 	u8 num_of_aps;
1591 	u8 last_report;
1592 	u8 reserved;
1593 	struct iwl_tof_range_rsp_ap_entry_ntfy_v6 ap[IWL_MVM_TOF_MAX_APS];
1594 } __packed; /* LOCATION_RANGE_RSP_NTFY_API_S_VER_8,
1595 	       LOCATION_RANGE_RSP_NTFY_API_S_VER_9 */
1596 
1597 #define IWL_MVM_TOF_MCSI_BUF_SIZE  (245)
1598 /**
1599  * struct iwl_tof_mcsi_notif - used for debug
1600  * @token: token ID for the current session
1601  * @role: '0' - initiator, '1' - responder
1602  * @reserved: reserved
1603  * @initiator_bssid: initiator machine
1604  * @responder_bssid: responder machine
1605  * @mcsi_buffer: debug data
1606  */
1607 struct iwl_tof_mcsi_notif {
1608 	u8 token;
1609 	u8 role;
1610 	__le16 reserved;
1611 	u8 initiator_bssid[ETH_ALEN];
1612 	u8 responder_bssid[ETH_ALEN];
1613 	u8 mcsi_buffer[IWL_MVM_TOF_MCSI_BUF_SIZE * 4];
1614 } __packed;
1615 
1616 /**
1617  * struct iwl_tof_range_abort_cmd
1618  * @request_id: corresponds to a range request
1619  * @reserved: reserved
1620  */
1621 struct iwl_tof_range_abort_cmd {
1622 	u8 request_id;
1623 	u8 reserved[3];
1624 } __packed;
1625 
1626 enum ftm_responder_stats_flags {
1627 	FTM_RESP_STAT_NON_ASAP_STARTED = BIT(0),
1628 	FTM_RESP_STAT_NON_ASAP_IN_WIN = BIT(1),
1629 	FTM_RESP_STAT_NON_ASAP_OUT_WIN = BIT(2),
1630 	FTM_RESP_STAT_TRIGGER_DUP = BIT(3),
1631 	FTM_RESP_STAT_DUP = BIT(4),
1632 	FTM_RESP_STAT_DUP_IN_WIN = BIT(5),
1633 	FTM_RESP_STAT_DUP_OUT_WIN = BIT(6),
1634 	FTM_RESP_STAT_SCHED_SUCCESS = BIT(7),
1635 	FTM_RESP_STAT_ASAP_REQ = BIT(8),
1636 	FTM_RESP_STAT_NON_ASAP_REQ = BIT(9),
1637 	FTM_RESP_STAT_ASAP_RESP = BIT(10),
1638 	FTM_RESP_STAT_NON_ASAP_RESP = BIT(11),
1639 	FTM_RESP_STAT_FAIL_INITIATOR_INACTIVE = BIT(12),
1640 	FTM_RESP_STAT_FAIL_INITIATOR_OUT_WIN = BIT(13),
1641 	FTM_RESP_STAT_FAIL_INITIATOR_RETRY_LIM = BIT(14),
1642 	FTM_RESP_STAT_FAIL_NEXT_SERVED = BIT(15),
1643 	FTM_RESP_STAT_FAIL_TRIGGER_ERR = BIT(16),
1644 	FTM_RESP_STAT_FAIL_GC = BIT(17),
1645 	FTM_RESP_STAT_SUCCESS = BIT(18),
1646 	FTM_RESP_STAT_INTEL_IE = BIT(19),
1647 	FTM_RESP_STAT_INITIATOR_ACTIVE = BIT(20),
1648 	FTM_RESP_STAT_MEASUREMENTS_AVAILABLE = BIT(21),
1649 	FTM_RESP_STAT_TRIGGER_UNKNOWN = BIT(22),
1650 	FTM_RESP_STAT_PROCESS_FAIL = BIT(23),
1651 	FTM_RESP_STAT_ACK = BIT(24),
1652 	FTM_RESP_STAT_NACK = BIT(25),
1653 	FTM_RESP_STAT_INVALID_INITIATOR_ID = BIT(26),
1654 	FTM_RESP_STAT_TIMER_MIN_DELTA = BIT(27),
1655 	FTM_RESP_STAT_INITIATOR_REMOVED = BIT(28),
1656 	FTM_RESP_STAT_INITIATOR_ADDED = BIT(29),
1657 	FTM_RESP_STAT_ERR_LIST_FULL = BIT(30),
1658 	FTM_RESP_STAT_INITIATOR_SCHED_NOW = BIT(31),
1659 }; /* RESP_IND_E */
1660 
1661 /**
1662  * struct iwl_ftm_responder_stats - FTM responder statistics
1663  * @addr: initiator address
1664  * @success_ftm: number of successful ftm frames
1665  * @ftm_per_burst: num of FTM frames that were received
1666  * @flags: &enum ftm_responder_stats_flags
1667  * @duration: actual duration of FTM
1668  * @allocated_duration: time that was allocated for this FTM session
1669  * @bw: FTM request bandwidth
1670  * @rate: FTM request rate
1671  * @reserved: for alingment and future use
1672  */
1673 struct iwl_ftm_responder_stats {
1674 	u8 addr[ETH_ALEN];
1675 	u8 success_ftm;
1676 	u8 ftm_per_burst;
1677 	__le32 flags;
1678 	__le32 duration;
1679 	__le32 allocated_duration;
1680 	u8 bw;
1681 	u8 rate;
1682 	__le16 reserved;
1683 } __packed; /* TOF_RESPONDER_STATISTICS_NTFY_S_VER_2 */
1684 
1685 #define IWL_CSI_MAX_EXPECTED_CHUNKS		16
1686 
1687 #define IWL_CSI_CHUNK_CTL_NUM_MASK_VER_1	0x0003
1688 #define IWL_CSI_CHUNK_CTL_IDX_MASK_VER_1	0x000c
1689 
1690 #define IWL_CSI_CHUNK_CTL_NUM_MASK_VER_2	0x00ff
1691 #define IWL_CSI_CHUNK_CTL_IDX_MASK_VER_2	0xff00
1692 
1693 struct iwl_csi_chunk_notification {
1694 	__le32 token;
1695 	__le16 seq;
1696 	__le16 ctl;
1697 	__le32 size;
1698 	u8 data[];
1699 } __packed; /* CSI_CHUNKS_HDR_NTFY_API_S_VER_1/VER_2 */
1700 
1701 #endif /* __iwl_fw_api_location_h__ */
1702