wifi_pos_api.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. /*
  2. * Copyright (c) 2012-2020 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 "wifi_pos_utils_pub.h"
  26. #include "../src/wifi_pos_utils_i.h"
  27. /* forward reference */
  28. struct wlan_objmgr_psoc;
  29. struct wifi_pos_driver_caps;
  30. /**
  31. * struct wifi_pos_field - wifi positioning field element
  32. * @id: RTT field id
  33. * @offset: data offset in field info buffer
  34. * @length: length of related data in field info buffer
  35. */
  36. struct wifi_pos_field {
  37. uint32_t id;
  38. uint32_t offset;
  39. uint32_t length;
  40. };
  41. /**
  42. * struct wifi_pos_field_info - wifi positioning field info buffer
  43. * @count: number of @wifi_pos_field elements
  44. * @fields: buffer to hold @wifi_pos_field elements
  45. */
  46. struct wifi_pos_field_info {
  47. uint32_t count;
  48. struct wifi_pos_field fields[1];
  49. };
  50. #ifdef WIFI_POS_CONVERGED
  51. /**
  52. * enum oem_err_msg - err msg returned to user space
  53. * @OEM_ERR_NULL_CONTEXT: NULL context
  54. * @OEM_ERR_APP_NOT_REGISTERED: OEM App is not registered
  55. * @OEM_ERR_INVALID_SIGNATURE: Invalid signature
  56. * @OEM_ERR_NULL_MESSAGE_HEADER: Invalid message header
  57. * @OEM_ERR_INVALID_MESSAGE_TYPE: Invalid message type
  58. * @OEM_ERR_INVALID_MESSAGE_LENGTH: Invalid length in message body
  59. */
  60. enum oem_err_msg {
  61. OEM_ERR_NULL_CONTEXT = 1,
  62. OEM_ERR_APP_NOT_REGISTERED,
  63. OEM_ERR_INVALID_SIGNATURE,
  64. OEM_ERR_NULL_MESSAGE_HEADER,
  65. OEM_ERR_INVALID_MESSAGE_TYPE,
  66. OEM_ERR_INVALID_MESSAGE_LENGTH
  67. };
  68. /* this struct is needed since MLME is not converged yet */
  69. struct wifi_pos_ch_info {
  70. uint8_t chan_id;
  71. uint32_t mhz;
  72. uint32_t band_center_freq1;
  73. uint32_t band_center_freq2;
  74. uint32_t info;
  75. uint32_t reg_info_1;
  76. uint32_t reg_info_2;
  77. uint8_t nss;
  78. uint32_t rate_flags;
  79. uint8_t sec_ch_offset;
  80. uint32_t ch_width;
  81. };
  82. /**
  83. * typedef wifi_pos_ch_info_rsp - Channel information
  84. * @chan_id: channel id
  85. * @reserved0: reserved for padding and future use
  86. * @mhz: primary 20 MHz channel frequency in mhz
  87. * @band_center_freq1: Center frequency 1 in MHz
  88. * @band_center_freq2: Center frequency 2 in MHz, valid only for 11ac
  89. * VHT 80+80 mode
  90. * @info: channel info
  91. * @reg_info_1: regulatory information field 1 which contains min power,
  92. * max power, reg power and reg class id
  93. * @reg_info_2: regulatory information field 2 which contains antennamax
  94. */
  95. struct qdf_packed wifi_pos_ch_info_rsp {
  96. uint32_t chan_id;
  97. uint32_t reserved0;
  98. uint32_t mhz;
  99. uint32_t band_center_freq1;
  100. uint32_t band_center_freq2;
  101. uint32_t info;
  102. uint32_t reg_info_1;
  103. uint32_t reg_info_2;
  104. };
  105. /**
  106. * struct wifi_pos_peer_status_info - Status information for a given peer
  107. * @peer_mac_addr: peer mac address
  108. * @peer_status: peer status: 1: CONNECTED, 2: DISCONNECTED
  109. * @vdev_id: vdev_id for the peer mac
  110. * @peer_capability: peer capability: 0: RTT/RTT2, 1: RTT3. Default is 0
  111. * @reserved0: reserved0
  112. * @peer_chan_info: channel info on which peer is connected
  113. */
  114. struct qdf_packed wifi_pos_peer_status_info {
  115. uint8_t peer_mac_addr[ETH_ALEN];
  116. uint8_t peer_status;
  117. uint8_t vdev_id;
  118. uint32_t peer_capability;
  119. uint32_t reserved0;
  120. struct wifi_pos_ch_info_rsp peer_chan_info;
  121. };
  122. /**
  123. * struct wifi_pos_req_msg - wifi pos request struct
  124. * @msg_type: message type
  125. * @pid: process id
  126. * @buf: request buffer
  127. * @buf_len: request buffer length
  128. * @field_info_buf: buffer containing field info
  129. * @field_info_buf_len: length of field info buffer
  130. * @rsp_version: nl type or ani type
  131. *
  132. */
  133. struct wifi_pos_req_msg {
  134. enum wifi_pos_cmd_ids msg_type;
  135. uint32_t pid;
  136. uint8_t *buf;
  137. uint32_t buf_len;
  138. struct wifi_pos_field_info *field_info_buf;
  139. uint32_t field_info_buf_len;
  140. uint32_t rsp_version;
  141. };
  142. /**
  143. * ucfg_wifi_pos_process_req: ucfg API to be called from HDD/OS_IF to process a
  144. * wifi_pos request from userspace
  145. * @psoc: pointer to psoc object
  146. * @req: wifi_pos request msg
  147. * @send_rsp_cb: callback pointer required to send msg to userspace
  148. *
  149. * Return: status of operation
  150. */
  151. QDF_STATUS ucfg_wifi_pos_process_req(struct wlan_objmgr_psoc *psoc,
  152. struct wifi_pos_req_msg *req,
  153. wifi_pos_send_rsp_handler send_rsp_cb);
  154. /**
  155. * wifi_pos_init: initializes WIFI POS component, called by dispatcher init
  156. *
  157. * Return: status of operation
  158. */
  159. QDF_STATUS wifi_pos_init(void);
  160. /**
  161. * wifi_pos_deinit: de-initializes WIFI POS component, called by dispatcher init
  162. *
  163. * Return: status of operation
  164. */
  165. QDF_STATUS wifi_pos_deinit(void);
  166. /**
  167. * wifi_pos_psoc_enable: psoc enable API for wifi positioning component
  168. * @psoc: pointer to PSOC
  169. *
  170. * Return: status of operation
  171. */
  172. QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc);
  173. /**
  174. * wifi_pos_psoc_disable: psoc disable API for wifi positioning component
  175. * @psoc: pointer to PSOC
  176. *
  177. * Return: status of operation
  178. */
  179. QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc);
  180. /**
  181. * wifi_pos_set_oem_target_type: public API to set param in wifi_pos private
  182. * object
  183. * @psoc: pointer to PSOC
  184. * @val: value to set
  185. *
  186. * Return: None
  187. */
  188. void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val);
  189. /**
  190. * wifi_pos_set_oem_fw_version: public API to set param in wifi_pos private
  191. * object
  192. * @psoc: pointer to PSOC
  193. * @val: value to set
  194. *
  195. * Return: None
  196. */
  197. void wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc *psoc, uint32_t val);
  198. /**
  199. * wifi_pos_set_drv_ver_major: public API to set param in wifi_pos private
  200. * object
  201. * @psoc: pointer to PSOC
  202. * @val: value to set
  203. *
  204. * Return: None
  205. */
  206. void wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc *psoc, uint8_t val);
  207. /**
  208. * wifi_pos_set_drv_ver_minor: public API to set param in wifi_pos private
  209. * object
  210. * @psoc: pointer to PSOC
  211. * @val: value to set
  212. *
  213. * Return: None
  214. */
  215. void wifi_pos_set_drv_ver_minor(struct wlan_objmgr_psoc *psoc, uint8_t val);
  216. /**
  217. * wifi_pos_set_drv_ver_patch: public API to set param in wifi_pos private
  218. * object
  219. * @psoc: pointer to PSOC
  220. * @val: value to set
  221. *
  222. * Return: None
  223. */
  224. void wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc *psoc, uint8_t val);
  225. /**
  226. * wifi_pos_set_drv_ver_build: public API to set param in wifi_pos private
  227. * object
  228. * @psoc: pointer to PSOC
  229. * @val: value to set
  230. *
  231. * Return: None
  232. */
  233. void wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc *psoc, uint8_t val);
  234. /**
  235. * wifi_pos_set_dwell_time_min: public API to set param in wifi_pos private
  236. * object
  237. * @psoc: pointer to PSOC
  238. * @val: value to set
  239. *
  240. * Return: None
  241. */
  242. void wifi_pos_set_dwell_time_min(struct wlan_objmgr_psoc *psoc, uint16_t val);
  243. /**
  244. * wifi_pos_set_dwell_time_max: public API to set param in wifi_pos private
  245. * object
  246. * @psoc: pointer to PSOC
  247. * @val: value to set
  248. *
  249. * Return: None
  250. */
  251. void wifi_pos_set_dwell_time_max(struct wlan_objmgr_psoc *psoc, uint16_t val);
  252. /**
  253. * wifi_pos_set_current_dwell_time_min: public API to set param in wifi_pos
  254. * private object
  255. * @psoc: pointer to PSOC
  256. * @val: value to set
  257. *
  258. * Return: None
  259. */
  260. void wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc *psoc,
  261. uint16_t val);
  262. /**
  263. * wifi_pos_set_current_dwell_time_max: public API to set param in wifi_pos
  264. * private object
  265. * @psoc: pointer to PSOC
  266. * @val: value to set
  267. *
  268. * Return: None
  269. */
  270. void wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc *psoc,
  271. uint16_t val);
  272. /**
  273. * wifi_pos_populate_caps() - populate oem capabilities
  274. * @psoc: psoc object
  275. * @caps: pointer to populate the capabilities
  276. *
  277. * Return: error code
  278. */
  279. QDF_STATUS wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc,
  280. struct wifi_pos_driver_caps *caps);
  281. struct wlan_lmac_if_rx_ops;
  282. /**
  283. * wifi_pos_register_rx_ops: function to register with lmac rx ops
  284. * @rx_ops: lmac rx ops struct object
  285. *
  286. * Return: None
  287. */
  288. void wifi_pos_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops);
  289. /**
  290. * ucfg_wifi_pos_get_ftm_cap: API to get fine timing measurement caps
  291. * @psoc: psoc object
  292. *
  293. * Return: FTM value
  294. */
  295. uint32_t ucfg_wifi_pos_get_ftm_cap(struct wlan_objmgr_psoc *psoc);
  296. /**
  297. * ucfg_wifi_pos_set_ftm_cap: API to set fine timing measurement caps
  298. * @psoc: psoc object
  299. * @val: value to set
  300. *
  301. * Return: None
  302. */
  303. void ucfg_wifi_pos_set_ftm_cap(struct wlan_objmgr_psoc *psoc, uint32_t val);
  304. /**
  305. * ucfg_wifi_pos_set_oem_6g_supported: API to set oem target 6g enabled/disabled
  306. * @psoc: psoc object
  307. * @val: value to set
  308. *
  309. * Return: None
  310. */
  311. void ucfg_wifi_pos_set_oem_6g_supported(struct wlan_objmgr_psoc *psoc,
  312. bool val);
  313. /**
  314. * ucfg_wifi_pos_is_nl_rsp: API to check if response is nl or ani type
  315. * @psoc: psoc object
  316. *
  317. * Return: true if response is nl type
  318. */
  319. bool ucfg_wifi_pos_is_nl_rsp(struct wlan_objmgr_psoc *psoc);
  320. /**
  321. * wifi_pos_get_app_pid: returns oem app pid.
  322. * @psoc: pointer to psoc object
  323. *
  324. * Return: oem app pid
  325. */
  326. uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc);
  327. /**
  328. * wifi_pos_is_app_registered: indicates if oem app is registered.
  329. * @psoc: pointer to psoc object
  330. *
  331. * Return: true if app is registered, false otherwise
  332. */
  333. bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc);
  334. /**
  335. * wifi_pos_get_psoc: API to get global PSOC object
  336. *
  337. * Since request from userspace is not associated with any vdev/pdev/psoc, this
  338. * API is used to get global psoc object.
  339. * Return: global psoc object.
  340. */
  341. struct wlan_objmgr_psoc *wifi_pos_get_psoc(void);
  342. #else
  343. static inline QDF_STATUS wifi_pos_init(void)
  344. {
  345. return QDF_STATUS_SUCCESS;
  346. }
  347. static inline QDF_STATUS wifi_pos_deinit(void)
  348. {
  349. return QDF_STATUS_SUCCESS;
  350. }
  351. static inline QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
  352. {
  353. return QDF_STATUS_SUCCESS;
  354. }
  355. static inline QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
  356. {
  357. return QDF_STATUS_SUCCESS;
  358. }
  359. #endif
  360. #if defined(WLAN_FEATURE_CIF_CFR) && defined(WIFI_POS_CONVERGED)
  361. /**
  362. * wifi_pos_init_cir_cfr_rings: API to set DMA ring cap in wifi pos psoc private
  363. * object
  364. * @psoc: pointer to psoc object
  365. * @hal_soc: hal soc pointer
  366. * @num_mac: number of macs
  367. * @buf: buffer containing dma ring cap
  368. *
  369. * Return: status of operation.
  370. */
  371. QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc,
  372. void *hal_soc, uint8_t num_mac, void *buf);
  373. #else
  374. static inline QDF_STATUS wifi_pos_init_cir_cfr_rings(
  375. struct wlan_objmgr_psoc *psoc,
  376. void *hal_soc, uint8_t num_mac, void *buf)
  377. {
  378. return QDF_STATUS_SUCCESS;
  379. }
  380. #endif
  381. /**
  382. * wifi_pos_register_get_fw_phy_mode_for_freq_cb: API to register callback
  383. * to get current PHY mode
  384. * @psoc: pointer to psoc object
  385. * @handler: callback to be registered
  386. *
  387. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  388. * case of failure
  389. */
  390. QDF_STATUS wifi_pos_register_get_fw_phy_mode_for_freq_cb(
  391. struct wlan_objmgr_psoc *psoc,
  392. void (*handler)(uint32_t, uint32_t, uint32_t *));
  393. /**
  394. * wifi_pos_register_get_phy_mode_cb: API to register callback to get
  395. * current PHY mode
  396. * @psoc: pointer to psoc object
  397. * @handler: callback to be registered
  398. *
  399. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  400. * case of failure
  401. */
  402. QDF_STATUS wifi_pos_register_get_phy_mode_cb(
  403. struct wlan_objmgr_psoc *psoc,
  404. void (*handler)(uint8_t, uint32_t, uint32_t *));
  405. /**
  406. * wifi_pos_register_send_action: API to register callback to send
  407. * action frames
  408. * @psoc: pointer to psoc object
  409. * @handler: callback to be registered
  410. *
  411. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  412. * case of failure
  413. */
  414. QDF_STATUS wifi_pos_register_send_action(
  415. struct wlan_objmgr_psoc *psoc,
  416. void (*handler)(struct wlan_objmgr_psoc *psoc,
  417. uint32_t sub_type,
  418. uint8_t *buf,
  419. uint32_t buf_len));
  420. /**
  421. * wifi_pos_send_report_resp: Send report to osif
  422. * @psoc: pointer to psoc object
  423. * @req_id: Request id
  424. * @dest_mac: destination mac address
  425. * @err_code: Error code to be sent
  426. *
  427. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  428. * case of failure
  429. */
  430. QDF_STATUS wifi_pos_send_report_resp(struct wlan_objmgr_psoc *psoc,
  431. int req_id, uint8_t *dest_mac,
  432. int err_code);
  433. #endif