blob: eae036af880e0fbefa91a1e56d061f4e8eef365b [file] [log] [blame]
Gregory Greenmance792912015-06-02 18:06:16 +03001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2015 Intel Deutschland GmbH
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
26 *
27 * Contact Information:
Emmanuel Grumbachd01c5362015-11-17 15:39:56 +020028 * Intel Linux Wireless <linuxwifi@intel.com>
Gregory Greenmance792912015-06-02 18:06:16 +030029 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2015 Intel Deutschland GmbH
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63#ifndef __fw_api_tof_h__
64#define __fw_api_tof_h__
65
66#include "fw-api.h"
67
68/* ToF sub-group command IDs */
69enum iwl_mvm_tof_sub_grp_ids {
70 TOF_RANGE_REQ_CMD = 0x1,
71 TOF_CONFIG_CMD = 0x2,
72 TOF_RANGE_ABORT_CMD = 0x3,
73 TOF_RANGE_REQ_EXT_CMD = 0x4,
74 TOF_RESPONDER_CONFIG_CMD = 0x5,
75 TOF_NW_INITIATED_RES_SEND_CMD = 0x6,
76 TOF_NEIGHBOR_REPORT_REQ_CMD = 0x7,
77 TOF_NEIGHBOR_REPORT_RSP_NOTIF = 0xFC,
78 TOF_NW_INITIATED_REQ_RCVD_NOTIF = 0xFD,
79 TOF_RANGE_RESPONSE_NOTIF = 0xFE,
80 TOF_MCSI_DEBUG_NOTIF = 0xFB,
81};
82
83/**
84 * struct iwl_tof_config_cmd - ToF configuration
85 * @tof_disabled: 0 enabled, 1 - disabled
86 * @one_sided_disabled: 0 enabled, 1 - disabled
87 * @is_debug_mode: 1 debug mode, 0 - otherwise
88 * @is_buf_required: 1 channel estimation buffer required, 0 - otherwise
89 */
90struct iwl_tof_config_cmd {
Gregory Greenmance792912015-06-02 18:06:16 +030091 __le32 sub_grp_cmd_id;
92 u8 tof_disabled;
93 u8 one_sided_disabled;
94 u8 is_debug_mode;
95 u8 is_buf_required;
96} __packed;
97
98/**
99 * struct iwl_tof_responder_config_cmd - ToF AP mode (for debug)
100 * @burst_period: future use: (currently hard coded in the LMAC)
101 * The interval between two sequential bursts.
102 * @min_delta_ftm: future use: (currently hard coded in the LMAC)
103 * The minimum delay between two sequential FTM Responses
104 * in the same burst.
105 * @burst_duration: future use: (currently hard coded in the LMAC)
106 * The total time for all FTMs handshake in the same burst.
107 * Affect the time events duration in the LMAC.
108 * @num_of_burst_exp: future use: (currently hard coded in the LMAC)
109 * The number of bursts for the current ToF request. Affect
110 * the number of events allocations in the current iteration.
111 * @get_ch_est: for xVT only, NA for driver
112 * @abort_responder: when set to '1' - Responder will terminate its activity
113 * (all other fields in the command are ignored)
114 * @recv_sta_req_params: 1 - Responder will ignore the other Responder's
115 * params and use the recomended Initiator params.
116 * 0 - otherwise
117 * @channel_num: current AP Channel
118 * @bandwidth: current AP Bandwidth: 0 20MHz, 1 40MHz, 2 80MHz
119 * @rate: current AP rate
120 * @ctrl_ch_position: coding of the control channel position relative to
Johannes Berg3a07d362017-03-15 10:18:20 +0100121 * the center frequency:
122 *
123 * 40 MHz
124 * 0 below center, 1 above center
125 *
126 * 80 MHz
127 * bits [0..1]
128 * * 0 the near 20MHz to the center,
129 * * 1 the far 20MHz to the center
130 * bit[2]
131 * as above 40MHz
Gregory Greenmance792912015-06-02 18:06:16 +0300132 * @ftm_per_burst: FTMs per Burst
133 * @ftm_resp_ts_avail: '0' - we don't measure over the Initial FTM Response,
134 * '1' - we measure over the Initial FTM Response
135 * @asap_mode: ASAP / Non ASAP mode for the current WLS station
136 * @sta_id: index of the AP STA when in AP mode
137 * @tsf_timer_offset_msecs: The dictated time offset (mSec) from the AP's TSF
138 * @toa_offset: Artificial addition [0.1nsec] for the ToA - to be used for debug
139 * purposes, simulating station movement by adding various values
140 * to this field
141 * @bssid: Current AP BSSID
142 */
143struct iwl_tof_responder_config_cmd {
Gregory Greenmance792912015-06-02 18:06:16 +0300144 __le32 sub_grp_cmd_id;
145 __le16 burst_period;
146 u8 min_delta_ftm;
147 u8 burst_duration;
148 u8 num_of_burst_exp;
149 u8 get_ch_est;
150 u8 abort_responder;
151 u8 recv_sta_req_params;
152 u8 channel_num;
153 u8 bandwidth;
154 u8 rate;
155 u8 ctrl_ch_position;
156 u8 ftm_per_burst;
157 u8 ftm_resp_ts_avail;
158 u8 asap_mode;
159 u8 sta_id;
160 __le16 tsf_timer_offset_msecs;
161 __le16 toa_offset;
162 u8 bssid[ETH_ALEN];
163} __packed;
164
165/**
166 * struct iwl_tof_range_request_ext_cmd - extended range req for WLS
167 * @tsf_timer_offset_msec: the recommended time offset (mSec) from the AP's TSF
168 * @min_delta_ftm: Minimal time between two consecutive measurements,
169 * in units of 100us. 0 means no preference by station
170 * @ftm_format_and_bw20M: FTM Channel Spacing/Format for 20MHz: recommended
171 * value be sent to the AP
172 * @ftm_format_and_bw40M: FTM Channel Spacing/Format for 40MHz: recommended
173 * value to be sent to the AP
174 * @ftm_format_and_bw80M: FTM Channel Spacing/Format for 80MHz: recommended
175 * value to be sent to the AP
176 */
177struct iwl_tof_range_req_ext_cmd {
Gregory Greenmance792912015-06-02 18:06:16 +0300178 __le32 sub_grp_cmd_id;
179 __le16 tsf_timer_offset_msec;
180 __le16 reserved;
181 u8 min_delta_ftm;
182 u8 ftm_format_and_bw20M;
183 u8 ftm_format_and_bw40M;
184 u8 ftm_format_and_bw80M;
185} __packed;
186
187#define IWL_MVM_TOF_MAX_APS 21
188
189/**
190 * struct iwl_tof_range_req_ap_entry - AP configuration parameters
191 * @channel_num: Current AP Channel
192 * @bandwidth: Current AP Bandwidth: 0 20MHz, 1 40MHz, 2 80MHz
193 * @tsf_delta_direction: TSF relatively to the subject AP
194 * @ctrl_ch_position: Coding of the control channel position relative to the
195 * center frequency.
196 * 40MHz 0 below center, 1 above center
197 * 80MHz bits [0..1]: 0 the near 20MHz to the center,
198 * 1 the far 20MHz to the center
199 * bit[2] as above 40MHz
200 * @bssid: AP's bss id
201 * @measure_type: Measurement type: 0 - two sided, 1 - One sided
202 * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of the
203 * number of measurement iterations (min 2^0 = 1, max 2^14)
204 * @burst_period: Recommended value to be sent to the AP. Measurement
205 * periodicity In units of 100ms. ignored if num_of_bursts = 0
206 * @samples_per_burst: 2-sided: the number of FTMs pairs in single Burst (1-31)
207 * 1-sided: how many rts/cts pairs should be used per burst.
208 * @retries_per_sample: Max number of retries that the LMAC should send
209 * in case of no replies by the AP.
210 * @tsf_delta: TSF Delta in units of microseconds.
211 * The difference between the AP TSF and the device local clock.
212 * @location_req: Location Request Bit[0] LCI should be sent in the FTMR
213 * Bit[1] Civic should be sent in the FTMR
214 * @asap_mode: 0 - non asap mode, 1 - asap mode (not relevant for one sided)
215 * @enable_dyn_ack: Enable Dynamic ACK BW.
216 * 0 Initiator interact with regular AP
217 * 1 Initiator interact with Responder machine: need to send the
218 * Initiator Acks with HT 40MHz / 80MHz, since the Responder should
219 * use it for its ch est measurement (this flag will be set when we
220 * configure the opposite machine to be Responder).
221 * @rssi: Last received value
222 * leagal values: -128-0 (0x7f). above 0x0 indicating an invalid value.
223 */
224struct iwl_tof_range_req_ap_entry {
225 u8 channel_num;
226 u8 bandwidth;
227 u8 tsf_delta_direction;
228 u8 ctrl_ch_position;
229 u8 bssid[ETH_ALEN];
230 u8 measure_type;
231 u8 num_of_bursts;
232 __le16 burst_period;
233 u8 samples_per_burst;
234 u8 retries_per_sample;
235 __le32 tsf_delta;
236 u8 location_req;
237 u8 asap_mode;
238 u8 enable_dyn_ack;
239 s8 rssi;
240} __packed;
241
242/**
243 * enum iwl_tof_response_mode
244 * @IWL_MVM_TOF_RESPOSE_ASAP: report each AP measurement separately as soon as
245 * possible (not supported for this release)
246 * @IWL_MVM_TOF_RESPOSE_TIMEOUT: report all AP measurements as a batch upon
247 * timeout expiration
248 * @IWL_MVM_TOF_RESPOSE_COMPLETE: report all AP measurements as a batch at the
249 * earlier of: measurements completion / timeout
250 * expiration.
251 */
252enum iwl_tof_response_mode {
253 IWL_MVM_TOF_RESPOSE_ASAP = 1,
254 IWL_MVM_TOF_RESPOSE_TIMEOUT,
255 IWL_MVM_TOF_RESPOSE_COMPLETE,
256};
257
258/**
259 * struct iwl_tof_range_req_cmd - start measurement cmd
260 * @request_id: A Token incremented per request. The same Token will be
261 * sent back in the range response
262 * @initiator: 0- NW initiated, 1 - Client Initiated
263 * @one_sided_los_disable: '0'- run ML-Algo for both ToF/OneSided,
264 * '1' - run ML-Algo for ToF only
265 * @req_timeout: Requested timeout of the response in units of 100ms.
266 * This is equivalent to the session time configured to the
267 * LMAC in Initiator Request
268 * @report_policy: Supported partially for this release: For current release -
269 * the range report will be uploaded as a batch when ready or
270 * when the session is done (successfully / partially).
271 * one of iwl_tof_response_mode.
272 * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
273 * @macaddr_random: '0' Use default source MAC address (i.e. p2_p),
274 * '1' Use MAC Address randomization according to the below
275 * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
276 * Bits set to 1 shall be randomized by the UMAC
277 */
278struct iwl_tof_range_req_cmd {
Gregory Greenmance792912015-06-02 18:06:16 +0300279 __le32 sub_grp_cmd_id;
280 u8 request_id;
281 u8 initiator;
282 u8 one_sided_los_disable;
283 u8 req_timeout;
284 u8 report_policy;
285 u8 los_det_disable;
286 u8 num_of_ap;
287 u8 macaddr_random;
288 u8 macaddr_template[ETH_ALEN];
289 u8 macaddr_mask[ETH_ALEN];
290 struct iwl_tof_range_req_ap_entry ap[IWL_MVM_TOF_MAX_APS];
291} __packed;
292
293/**
294 * struct iwl_tof_gen_resp_cmd - generic ToF response
295 */
296struct iwl_tof_gen_resp_cmd {
297 __le32 sub_grp_cmd_id;
298 u8 data[];
299} __packed;
300
301/**
302 * struct iwl_tof_range_rsp_ap_entry_ntfy - AP parameters (response)
303 * @measure_status: current APs measurement status
304 * @measure_bw: Current AP Bandwidth: 0 20MHz, 1 40MHz, 2 80MHz
305 * @rtt: The Round Trip Time that took for the last measurement for
306 * current AP [nSec]
307 * @rtt_variance: The Variance of the RTT values measured for current AP
308 * @rtt_spread: The Difference between the maximum and the minimum RTT
309 * values measured for current AP in the current session [nsec]
310 * @rssi: RSSI as uploaded in the Channel Estimation notification
311 * @rssi_spread: The Difference between the maximum and the minimum RSSI values
312 * measured for current AP in the current session
313 * @range: Measured range [cm]
314 * @range_variance: Measured range variance [cm]
315 * @timestamp: The GP2 Clock [usec] where Channel Estimation notification was
316 * uploaded by the LMAC
317 */
318struct iwl_tof_range_rsp_ap_entry_ntfy {
319 u8 bssid[ETH_ALEN];
320 u8 measure_status;
321 u8 measure_bw;
322 __le32 rtt;
323 __le32 rtt_variance;
324 __le32 rtt_spread;
325 s8 rssi;
326 u8 rssi_spread;
327 __le16 reserved;
328 __le32 range;
329 __le32 range_variance;
330 __le32 timestamp;
331} __packed;
332
333/**
334 * struct iwl_tof_range_rsp_ntfy -
335 * @request_id: A Token ID of the corresponding Range request
336 * @request_status: status of current measurement session
337 * @last_in_batch: reprot policy (when not all responses are uploaded at once)
338 * @num_of_aps: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
339 */
340struct iwl_tof_range_rsp_ntfy {
341 u8 request_id;
342 u8 request_status;
343 u8 last_in_batch;
344 u8 num_of_aps;
345 struct iwl_tof_range_rsp_ap_entry_ntfy ap[IWL_MVM_TOF_MAX_APS];
346} __packed;
347
348#define IWL_MVM_TOF_MCSI_BUF_SIZE (245)
349/**
350 * struct iwl_tof_mcsi_notif - used for debug
351 * @token: token ID for the current session
352 * @role: '0' - initiator, '1' - responder
353 * @initiator_bssid: initiator machine
354 * @responder_bssid: responder machine
355 * @mcsi_buffer: debug data
356 */
357struct iwl_tof_mcsi_notif {
358 u8 token;
359 u8 role;
360 __le16 reserved;
361 u8 initiator_bssid[ETH_ALEN];
362 u8 responder_bssid[ETH_ALEN];
363 u8 mcsi_buffer[IWL_MVM_TOF_MCSI_BUF_SIZE * 4];
364} __packed;
365
366/**
367 * struct iwl_tof_neighbor_report_notif
368 * @bssid: BSSID of the AP which sent the report
369 * @request_token: same token as the corresponding request
370 * @status:
371 * @report_ie_len: the length of the response frame starting from the Element ID
372 * @data: the IEs
373 */
374struct iwl_tof_neighbor_report {
375 u8 bssid[ETH_ALEN];
376 u8 request_token;
377 u8 status;
378 __le16 report_ie_len;
379 u8 data[];
380} __packed;
381
382/**
383 * struct iwl_tof_range_abort_cmd
384 * @request_id: corresponds to a range request
385 */
386struct iwl_tof_range_abort_cmd {
Gregory Greenmance792912015-06-02 18:06:16 +0300387 __le32 sub_grp_cmd_id;
388 u8 request_id;
389 u8 reserved[3];
390} __packed;
391
392#endif