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