tof.h 14 KB

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