wifi_pos_api.h 14 KB

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