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