wifi_pos_api.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. /*
  2. * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: wifi_pos_api.h
  20. * This file declares public APIs of wifi positioning component
  21. */
  22. #ifndef _WIFI_POS_API_H_
  23. #define _WIFI_POS_API_H_
  24. /* Include files */
  25. #include "qdf_types.h"
  26. #include "qdf_status.h"
  27. #include "qdf_trace.h"
  28. /* forward reference */
  29. struct wlan_objmgr_psoc;
  30. struct wifi_pos_driver_caps;
  31. #ifdef WIFI_POS_CONVERGED
  32. /**
  33. * enum oem_err_msg - err msg returned to user space
  34. * @OEM_ERR_NULL_CONTEXT: NULL context
  35. * @OEM_ERR_APP_NOT_REGISTERED: OEM App is not registered
  36. * @OEM_ERR_INVALID_SIGNATURE: Invalid signature
  37. * @OEM_ERR_NULL_MESSAGE_HEADER: Invalid message header
  38. * @OEM_ERR_INVALID_MESSAGE_TYPE: Invalid message type
  39. * @OEM_ERR_INVALID_MESSAGE_LENGTH: Invalid length in message body
  40. */
  41. enum oem_err_msg {
  42. OEM_ERR_NULL_CONTEXT = 1,
  43. OEM_ERR_APP_NOT_REGISTERED,
  44. OEM_ERR_INVALID_SIGNATURE,
  45. OEM_ERR_NULL_MESSAGE_HEADER,
  46. OEM_ERR_INVALID_MESSAGE_TYPE,
  47. OEM_ERR_INVALID_MESSAGE_LENGTH
  48. };
  49. /* this struct is needed since MLME is not converged yet */
  50. struct wifi_pos_ch_info {
  51. uint8_t chan_id;
  52. uint32_t mhz;
  53. uint32_t band_center_freq1;
  54. uint32_t band_center_freq2;
  55. uint32_t info;
  56. uint32_t reg_info_1;
  57. uint32_t reg_info_2;
  58. uint8_t nss;
  59. uint32_t rate_flags;
  60. uint8_t sec_ch_offset;
  61. uint32_t ch_width;
  62. };
  63. /**
  64. * typedef wifi_pos_ch_info_rsp - Channel information
  65. * @chan_id: channel id
  66. * @reserved0: reserved for padding and future use
  67. * @mhz: primary 20 MHz channel frequency in mhz
  68. * @band_center_freq1: Center frequency 1 in MHz
  69. * @band_center_freq2: Center frequency 2 in MHz, valid only for 11ac
  70. * VHT 80+80 mode
  71. * @info: channel info
  72. * @reg_info_1: regulatory information field 1 which contains min power,
  73. * max power, reg power and reg class id
  74. * @reg_info_2: regulatory information field 2 which contains antennamax
  75. */
  76. struct qdf_packed wifi_pos_ch_info_rsp {
  77. uint32_t chan_id;
  78. uint32_t reserved0;
  79. uint32_t mhz;
  80. uint32_t band_center_freq1;
  81. uint32_t band_center_freq2;
  82. uint32_t info;
  83. uint32_t reg_info_1;
  84. uint32_t reg_info_2;
  85. };
  86. /**
  87. * struct wmi_pos_peer_status_info - Status information for a given peer
  88. * @peer_mac_addr: peer mac address
  89. * @peer_status: peer status: 1: CONNECTED, 2: DISCONNECTED
  90. * @vdev_id: vdev_id for the peer mac
  91. * @peer_capability: peer capability: 0: RTT/RTT2, 1: RTT3. Default is 0
  92. * @reserved0: reserved0
  93. * @peer_chan_info: channel info on which peer is connected
  94. */
  95. struct qdf_packed wmi_pos_peer_status_info {
  96. uint8_t peer_mac_addr[ETH_ALEN];
  97. uint8_t peer_status;
  98. uint8_t vdev_id;
  99. uint32_t peer_capability;
  100. uint32_t reserved0;
  101. struct wifi_pos_ch_info_rsp peer_chan_info;
  102. };
  103. /**
  104. * struct wifi_pos_req_msg - wifi pos request struct
  105. * @msg_type: message type
  106. * @pid: process id
  107. * @buf: request buffer
  108. * @buf_len: request buffer length
  109. * @field_info_buf: buffer containing field info
  110. * @field_info_buf_len: length of field info buffer
  111. *
  112. */
  113. struct wifi_pos_req_msg {
  114. uint32_t msg_type;
  115. uint32_t pid;
  116. uint8_t *buf;
  117. uint32_t buf_len;
  118. struct wifi_pos_field_info *field_info_buf;
  119. uint32_t field_info_buf_len;
  120. };
  121. /**
  122. * ucfg_wifi_pos_process_req: ucfg API to be called from HDD/OS_IF to process a
  123. * wifi_pos request from userspace
  124. * @psoc: pointer to psoc object
  125. * @req: wifi_pos request msg
  126. * @send_rsp_cb: callback pointer required to send msg to userspace
  127. *
  128. * Return: status of operation
  129. */
  130. QDF_STATUS ucfg_wifi_pos_process_req(struct wlan_objmgr_psoc *psoc,
  131. struct wifi_pos_req_msg *req,
  132. void (*send_rsp_cb)(uint32_t, uint32_t, uint32_t, uint8_t *));
  133. /**
  134. * wifi_pos_init: initializes WIFI POS component, called by dispatcher init
  135. *
  136. * Return: status of operation
  137. */
  138. QDF_STATUS wifi_pos_init(void);
  139. /**
  140. * wifi_pos_deinit: de-initializes WIFI POS component, called by dispatcher init
  141. *
  142. * Return: status of operation
  143. */
  144. QDF_STATUS wifi_pos_deinit(void);
  145. /**
  146. * wifi_pos_psoc_enable: psoc enable API for wifi positioning component
  147. * @psoc: pointer to PSOC
  148. *
  149. * Return: status of operation
  150. */
  151. QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc);
  152. /**
  153. * wifi_pos_psoc_disable: psoc disable API for wifi positioning component
  154. * @psoc: pointer to PSOC
  155. *
  156. * Return: status of operation
  157. */
  158. QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc);
  159. /**
  160. * wifi_pos_set_oem_target_type: public API to set param in wifi_pos private
  161. * object
  162. * @psoc: pointer to PSOC
  163. * @val: value to set
  164. *
  165. * Return: None
  166. */
  167. void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val);
  168. /**
  169. * wifi_pos_set_oem_fw_version: public API to set param in wifi_pos private
  170. * object
  171. * @psoc: pointer to PSOC
  172. * @val: value to set
  173. *
  174. * Return: None
  175. */
  176. void wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc *psoc, uint32_t val);
  177. /**
  178. * wifi_pos_set_drv_ver_major: public API to set param in wifi_pos private
  179. * object
  180. * @psoc: pointer to PSOC
  181. * @val: value to set
  182. *
  183. * Return: None
  184. */
  185. void wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc *psoc, uint8_t val);
  186. /**
  187. * wifi_pos_set_drv_ver_minor: public API to set param in wifi_pos private
  188. * object
  189. * @psoc: pointer to PSOC
  190. * @val: value to set
  191. *
  192. * Return: None
  193. */
  194. void wifi_pos_set_drv_ver_minor(struct wlan_objmgr_psoc *psoc, uint8_t val);
  195. /**
  196. * wifi_pos_set_drv_ver_patch: public API to set param in wifi_pos private
  197. * object
  198. * @psoc: pointer to PSOC
  199. * @val: value to set
  200. *
  201. * Return: None
  202. */
  203. void wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc *psoc, uint8_t val);
  204. /**
  205. * wifi_pos_set_drv_ver_build: public API to set param in wifi_pos private
  206. * object
  207. * @psoc: pointer to PSOC
  208. * @val: value to set
  209. *
  210. * Return: None
  211. */
  212. void wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc *psoc, uint8_t val);
  213. /**
  214. * wifi_pos_set_dwell_time_min: public API to set param in wifi_pos private
  215. * object
  216. * @psoc: pointer to PSOC
  217. * @val: value to set
  218. *
  219. * Return: None
  220. */
  221. void wifi_pos_set_dwell_time_min(struct wlan_objmgr_psoc *psoc, uint16_t val);
  222. /**
  223. * wifi_pos_set_dwell_time_max: public API to set param in wifi_pos private
  224. * object
  225. * @psoc: pointer to PSOC
  226. * @val: value to set
  227. *
  228. * Return: None
  229. */
  230. void wifi_pos_set_dwell_time_max(struct wlan_objmgr_psoc *psoc, uint16_t val);
  231. /**
  232. * wifi_pos_set_current_dwell_time_min: public API to set param in wifi_pos
  233. * private object
  234. * @psoc: pointer to PSOC
  235. * @val: value to set
  236. *
  237. * Return: None
  238. */
  239. void wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc *psoc,
  240. uint16_t val);
  241. /**
  242. * wifi_pos_set_current_dwell_time_max: public API to set param in wifi_pos
  243. * private object
  244. * @psoc: pointer to PSOC
  245. * @val: value to set
  246. *
  247. * Return: None
  248. */
  249. void wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc *psoc,
  250. uint16_t val);
  251. /**
  252. * wifi_pos_populate_caps() - populate oem capabilities
  253. * @psoc: psoc object
  254. * @caps: pointer to populate the capabilities
  255. *
  256. * Return: error code
  257. */
  258. QDF_STATUS wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc,
  259. struct wifi_pos_driver_caps *caps);
  260. /**
  261. * ucfg_wifi_pos_get_ftm_cap: API to get fine timing measurement caps
  262. * @psoc: psoc object
  263. *
  264. * Return: FTM value
  265. */
  266. uint32_t ucfg_wifi_pos_get_ftm_cap(struct wlan_objmgr_psoc *psoc);
  267. /**
  268. * ucfg_wifi_pos_set_ftm_cap: API to set fine timing measurement caps
  269. * @psoc: psoc object
  270. * @val: value to set
  271. *
  272. * Return: None
  273. */
  274. void ucfg_wifi_pos_set_ftm_cap(struct wlan_objmgr_psoc *psoc, uint32_t val);
  275. /**
  276. * wifi_pos_get_app_pid: returns oem app pid.
  277. * @psoc: pointer to psoc object
  278. *
  279. * Return: oem app pid
  280. */
  281. uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc);
  282. /**
  283. * wifi_pos_is_app_registered: indicates if oem app is registered.
  284. * @psoc: pointer to psoc object
  285. *
  286. * Return: true if app is registered, false otherwise
  287. */
  288. bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc);
  289. /**
  290. * wifi_pos_get_psoc: API to get global PSOC object
  291. *
  292. * Since request from userspace is not associated with any vdev/pdev/psoc, this
  293. * API is used to get global psoc object.
  294. * Return: global psoc object.
  295. */
  296. struct wlan_objmgr_psoc *wifi_pos_get_psoc(void);
  297. #else
  298. static inline QDF_STATUS wifi_pos_init(void)
  299. {
  300. return QDF_STATUS_SUCCESS;
  301. }
  302. static inline QDF_STATUS wifi_pos_deinit(void)
  303. {
  304. return QDF_STATUS_SUCCESS;
  305. }
  306. static inline QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
  307. {
  308. return QDF_STATUS_SUCCESS;
  309. }
  310. static inline QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
  311. {
  312. return QDF_STATUS_SUCCESS;
  313. }
  314. #endif
  315. #if defined(WLAN_FEATURE_CIF_CFR) && defined(WIFI_POS_CONVERGED)
  316. /**
  317. * wifi_pos_init_cir_cfr_rings: API to set DMA ring cap in wifi pos psoc private
  318. * object
  319. * @psoc: pointer to psoc object
  320. * @hal_soc: hal soc pointer
  321. * @num_mac: number of macs
  322. * @buf: buffer containing dma ring cap
  323. *
  324. * Return: status of operation.
  325. */
  326. QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc,
  327. void *hal_soc, uint8_t num_mac, void *buf);
  328. #else
  329. static inline QDF_STATUS wifi_pos_init_cir_cfr_rings(
  330. struct wlan_objmgr_psoc *psoc,
  331. void *hal_soc, uint8_t num_mac, void *buf)
  332. {
  333. return QDF_STATUS_SUCCESS;
  334. }
  335. #endif
  336. /**
  337. * wifi_pos_register_get_phy_mode_cb: API to register callback to get
  338. * current PHY mode
  339. * @psoc: pointer to psoc object
  340. * @handler: callback to be registered
  341. *
  342. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  343. * case of failure
  344. */
  345. QDF_STATUS wifi_pos_register_get_phy_mode_cb(
  346. struct wlan_objmgr_psoc *psoc,
  347. void (*handler)(uint8_t, uint32_t, uint32_t *));
  348. #endif