wifi_pos_api.h 12 KB

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