wifi_pos_api.h 9.9 KB

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