wifi_pos_api.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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 "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. /**
  32. * struct wifi_pos_field - wifi positioning field element
  33. * @id: RTT field id
  34. * @offset: data offset in field info buffer
  35. * @length: length of related data in field info buffer
  36. */
  37. struct wifi_pos_field {
  38. uint32_t id;
  39. uint32_t offset;
  40. uint32_t length;
  41. };
  42. /**
  43. * struct wifi_pos_field_info - wifi positioning field info buffer
  44. * @count: number of @wifi_pos_field elements
  45. * @fields: buffer to hold @wifi_pos_field elements
  46. */
  47. struct wifi_pos_field_info {
  48. uint32_t count;
  49. struct wifi_pos_field fields[1];
  50. };
  51. #ifdef WIFI_POS_CONVERGED
  52. /**
  53. * enum oem_err_msg - err msg returned to user space
  54. * @OEM_ERR_NULL_CONTEXT: NULL context
  55. * @OEM_ERR_APP_NOT_REGISTERED: OEM App is not registered
  56. * @OEM_ERR_INVALID_SIGNATURE: Invalid signature
  57. * @OEM_ERR_NULL_MESSAGE_HEADER: Invalid message header
  58. * @OEM_ERR_INVALID_MESSAGE_TYPE: Invalid message type
  59. * @OEM_ERR_INVALID_MESSAGE_LENGTH: Invalid length in message body
  60. */
  61. enum oem_err_msg {
  62. OEM_ERR_NULL_CONTEXT = 1,
  63. OEM_ERR_APP_NOT_REGISTERED,
  64. OEM_ERR_INVALID_SIGNATURE,
  65. OEM_ERR_NULL_MESSAGE_HEADER,
  66. OEM_ERR_INVALID_MESSAGE_TYPE,
  67. OEM_ERR_INVALID_MESSAGE_LENGTH
  68. };
  69. /* this struct is needed since MLME is not converged yet */
  70. struct wifi_pos_ch_info {
  71. uint8_t chan_id;
  72. uint32_t mhz;
  73. uint32_t band_center_freq1;
  74. uint32_t band_center_freq2;
  75. uint32_t info;
  76. uint32_t reg_info_1;
  77. uint32_t reg_info_2;
  78. uint8_t nss;
  79. uint32_t rate_flags;
  80. uint8_t sec_ch_offset;
  81. uint32_t ch_width;
  82. };
  83. /**
  84. * typedef wifi_pos_ch_info_rsp - Channel information
  85. * @chan_id: channel id
  86. * @reserved0: reserved for padding and future use
  87. * @mhz: primary 20 MHz channel frequency in mhz
  88. * @band_center_freq1: Center frequency 1 in MHz
  89. * @band_center_freq2: Center frequency 2 in MHz, valid only for 11ac
  90. * VHT 80+80 mode
  91. * @info: channel info
  92. * @reg_info_1: regulatory information field 1 which contains min power,
  93. * max power, reg power and reg class id
  94. * @reg_info_2: regulatory information field 2 which contains antennamax
  95. */
  96. struct qdf_packed wifi_pos_ch_info_rsp {
  97. uint32_t chan_id;
  98. uint32_t reserved0;
  99. uint32_t mhz;
  100. uint32_t band_center_freq1;
  101. uint32_t band_center_freq2;
  102. uint32_t info;
  103. uint32_t reg_info_1;
  104. uint32_t reg_info_2;
  105. };
  106. /**
  107. * struct wmi_pos_peer_status_info - Status information for a given peer
  108. * @peer_mac_addr: peer mac address
  109. * @peer_status: peer status: 1: CONNECTED, 2: DISCONNECTED
  110. * @vdev_id: vdev_id for the peer mac
  111. * @peer_capability: peer capability: 0: RTT/RTT2, 1: RTT3. Default is 0
  112. * @reserved0: reserved0
  113. * @peer_chan_info: channel info on which peer is connected
  114. */
  115. struct qdf_packed wmi_pos_peer_status_info {
  116. uint8_t peer_mac_addr[ETH_ALEN];
  117. uint8_t peer_status;
  118. uint8_t vdev_id;
  119. uint32_t peer_capability;
  120. uint32_t reserved0;
  121. struct wifi_pos_ch_info_rsp peer_chan_info;
  122. };
  123. /**
  124. * struct wifi_pos_req_msg - wifi pos request struct
  125. * @msg_type: message type
  126. * @pid: process id
  127. * @buf: request buffer
  128. * @buf_len: request buffer length
  129. * @field_info_buf: buffer containing field info
  130. * @field_info_buf_len: length of field info buffer
  131. *
  132. */
  133. struct wifi_pos_req_msg {
  134. uint32_t 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. };
  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. * wifi_pos_get_app_pid: returns oem app pid.
  314. * @psoc: pointer to psoc object
  315. *
  316. * Return: oem app pid
  317. */
  318. uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc);
  319. /**
  320. * wifi_pos_is_app_registered: indicates if oem app is registered.
  321. * @psoc: pointer to psoc object
  322. *
  323. * Return: true if app is registered, false otherwise
  324. */
  325. bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc);
  326. /**
  327. * wifi_pos_get_psoc: API to get global PSOC object
  328. *
  329. * Since request from userspace is not associated with any vdev/pdev/psoc, this
  330. * API is used to get global psoc object.
  331. * Return: global psoc object.
  332. */
  333. struct wlan_objmgr_psoc *wifi_pos_get_psoc(void);
  334. #else
  335. static inline QDF_STATUS wifi_pos_init(void)
  336. {
  337. return QDF_STATUS_SUCCESS;
  338. }
  339. static inline QDF_STATUS wifi_pos_deinit(void)
  340. {
  341. return QDF_STATUS_SUCCESS;
  342. }
  343. static inline QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
  344. {
  345. return QDF_STATUS_SUCCESS;
  346. }
  347. static inline QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
  348. {
  349. return QDF_STATUS_SUCCESS;
  350. }
  351. #endif
  352. #if defined(WLAN_FEATURE_CIF_CFR) && defined(WIFI_POS_CONVERGED)
  353. /**
  354. * wifi_pos_init_cir_cfr_rings: API to set DMA ring cap in wifi pos psoc private
  355. * object
  356. * @psoc: pointer to psoc object
  357. * @hal_soc: hal soc pointer
  358. * @num_mac: number of macs
  359. * @buf: buffer containing dma ring cap
  360. *
  361. * Return: status of operation.
  362. */
  363. QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc,
  364. void *hal_soc, uint8_t num_mac, void *buf);
  365. #else
  366. static inline QDF_STATUS wifi_pos_init_cir_cfr_rings(
  367. struct wlan_objmgr_psoc *psoc,
  368. void *hal_soc, uint8_t num_mac, void *buf)
  369. {
  370. return QDF_STATUS_SUCCESS;
  371. }
  372. #endif
  373. /**
  374. * wifi_pos_register_get_fw_phy_mode_for_freq_cb: API to register callback
  375. * to get current PHY mode
  376. * @psoc: pointer to psoc object
  377. * @handler: callback to be registered
  378. *
  379. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  380. * case of failure
  381. */
  382. QDF_STATUS wifi_pos_register_get_fw_phy_mode_for_freq_cb(
  383. struct wlan_objmgr_psoc *psoc,
  384. void (*handler)(uint32_t, uint32_t, uint32_t *));
  385. /**
  386. * wifi_pos_register_get_phy_mode_cb: API to register callback to get
  387. * current PHY mode
  388. * @psoc: pointer to psoc object
  389. * @handler: callback to be registered
  390. *
  391. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  392. * case of failure
  393. */
  394. QDF_STATUS wifi_pos_register_get_phy_mode_cb(
  395. struct wlan_objmgr_psoc *psoc,
  396. void (*handler)(uint8_t, uint32_t, uint32_t *));
  397. /**
  398. * wifi_pos_register_send_action: API to register callback to send
  399. * action frames
  400. * @psoc: pointer to psoc object
  401. * @handler: callback to be registered
  402. *
  403. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  404. * case of failure
  405. */
  406. QDF_STATUS wifi_pos_register_send_action(
  407. struct wlan_objmgr_psoc *psoc,
  408. void (*handler)(struct wlan_objmgr_psoc *psoc,
  409. uint32_t sub_type,
  410. uint8_t *buf,
  411. uint32_t buf_len));
  412. /**
  413. * wifi_pos_send_report_resp: Send report to osif
  414. * @psoc: pointer to psoc object
  415. * @req_id: Request id
  416. * @dest_mac: destination mac address
  417. * @err_code: Error code to be sent
  418. *
  419. * Return: QDF_STATUS_SUCCESS in case of success, error codes in
  420. * case of failure
  421. */
  422. QDF_STATUS wifi_pos_send_report_resp(struct wlan_objmgr_psoc *psoc,
  423. int req_id, uint8_t *dest_mac,
  424. int err_code);
  425. #endif