1 /* 2 * Copyright (c) 2012-2017 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 "qdf_types.h" 28 #include "qdf_status.h" 29 #include "qdf_trace.h" 30 31 /* forward reference */ 32 struct wlan_objmgr_psoc; 33 struct wifi_pos_driver_caps; 34 35 #ifdef WIFI_POS_CONVERGED 36 /** 37 * enum oem_err_msg - err msg returned to user space 38 * @OEM_ERR_NULL_CONTEXT: NULL context 39 * @OEM_ERR_APP_NOT_REGISTERED: OEM App is not registered 40 * @OEM_ERR_INVALID_SIGNATURE: Invalid signature 41 * @OEM_ERR_NULL_MESSAGE_HEADER: Invalid message header 42 * @OEM_ERR_INVALID_MESSAGE_TYPE: Invalid message type 43 * @OEM_ERR_INVALID_MESSAGE_LENGTH: Invalid length in message body 44 */ 45 enum oem_err_msg { 46 OEM_ERR_NULL_CONTEXT = 1, 47 OEM_ERR_APP_NOT_REGISTERED, 48 OEM_ERR_INVALID_SIGNATURE, 49 OEM_ERR_NULL_MESSAGE_HEADER, 50 OEM_ERR_INVALID_MESSAGE_TYPE, 51 OEM_ERR_INVALID_MESSAGE_LENGTH 52 }; 53 54 /* this struct is needed since MLME is not converged yet */ 55 struct wifi_pos_ch_info { 56 uint8_t chan_id; 57 uint32_t mhz; 58 uint32_t band_center_freq1; 59 uint32_t band_center_freq2; 60 uint32_t info; 61 uint32_t reg_info_1; 62 uint32_t reg_info_2; 63 uint8_t nss; 64 uint32_t rate_flags; 65 uint8_t sec_ch_offset; 66 uint32_t ch_width; 67 }; 68 69 /** 70 * typedef wifi_pos_ch_info_rsp - Channel information 71 * @chan_id: channel id 72 * @reserved0: reserved for padding and future use 73 * @mhz: primary 20 MHz channel frequency in mhz 74 * @band_center_freq1: Center frequency 1 in MHz 75 * @band_center_freq2: Center frequency 2 in MHz, valid only for 11ac 76 * VHT 80+80 mode 77 * @info: channel info 78 * @reg_info_1: regulatory information field 1 which contains min power, 79 * max power, reg power and reg class id 80 * @reg_info_2: regulatory information field 2 which contains antennamax 81 */ 82 struct qdf_packed wifi_pos_ch_info_rsp { 83 uint32_t chan_id; 84 uint32_t reserved0; 85 uint32_t mhz; 86 uint32_t band_center_freq1; 87 uint32_t band_center_freq2; 88 uint32_t info; 89 uint32_t reg_info_1; 90 uint32_t reg_info_2; 91 }; 92 93 /** 94 * struct wmi_pos_peer_status_info - Status information for a given peer 95 * @peer_mac_addr: peer mac address 96 * @peer_status: peer status: 1: CONNECTED, 2: DISCONNECTED 97 * @vdev_id: vdev_id for the peer mac 98 * @peer_capability: peer capability: 0: RTT/RTT2, 1: RTT3. Default is 0 99 * @reserved0: reserved0 100 * @peer_chan_info: channel info on which peer is connected 101 */ 102 struct qdf_packed wmi_pos_peer_status_info { 103 uint8_t peer_mac_addr[ETH_ALEN]; 104 uint8_t peer_status; 105 uint8_t vdev_id; 106 uint32_t peer_capability; 107 uint32_t reserved0; 108 struct wifi_pos_ch_info_rsp peer_chan_info; 109 }; 110 111 /** 112 * struct wifi_pos_req_msg - wifi pos request struct 113 * @msg_type: message type 114 * @pid: process id 115 * @buf: request buffer 116 * @buf_len: request buffer length 117 * @field_info_buf: buffer containing field info 118 * @field_info_buf_len: length of field info buffer 119 * 120 */ 121 struct wifi_pos_req_msg { 122 uint32_t msg_type; 123 uint32_t pid; 124 uint8_t *buf; 125 uint32_t buf_len; 126 struct wifi_pos_field_info *field_info_buf; 127 uint32_t field_info_buf_len; 128 }; 129 130 /** 131 * ucfg_wifi_pos_process_req: ucfg API to be called from HDD/OS_IF to process a 132 * wifi_pos request from userspace 133 * @psoc: pointer to psoc object 134 * @req: wifi_pos request msg 135 * @send_rsp_cb: callback pointer required to send msg to userspace 136 * 137 * Return: status of operation 138 */ 139 QDF_STATUS ucfg_wifi_pos_process_req(struct wlan_objmgr_psoc *psoc, 140 struct wifi_pos_req_msg *req, 141 void (*send_rsp_cb)(uint32_t, uint32_t, uint32_t, uint8_t *)); 142 143 /** 144 * wifi_pos_init: initializes WIFI POS component, called by dispatcher init 145 * 146 * Return: status of operation 147 */ 148 QDF_STATUS wifi_pos_init(void); 149 150 /** 151 * wifi_pos_deinit: de-initializes WIFI POS component, called by dispatcher init 152 * 153 * Return: status of operation 154 */ 155 QDF_STATUS wifi_pos_deinit(void); 156 157 /** 158 * wifi_pos_psoc_enable: psoc enable API for wifi positioning component 159 * @psoc: pointer to PSOC 160 * 161 * Return: status of operation 162 */ 163 QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc); 164 165 /** 166 * wifi_pos_psoc_disable: psoc disable API for wifi positioning component 167 * @psoc: pointer to PSOC 168 * 169 * Return: status of operation 170 */ 171 QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc); 172 173 /** 174 * wifi_pos_set_oem_target_type: public API to set param in wifi_pos private 175 * object 176 * @psoc: pointer to PSOC 177 * @val: value to set 178 * 179 * Return: None 180 */ 181 void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val); 182 183 /** 184 * wifi_pos_set_oem_fw_version: public API to set param in wifi_pos private 185 * object 186 * @psoc: pointer to PSOC 187 * @val: value to set 188 * 189 * Return: None 190 */ 191 void wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc *psoc, uint32_t val); 192 193 /** 194 * wifi_pos_set_drv_ver_major: public API to set param in wifi_pos private 195 * object 196 * @psoc: pointer to PSOC 197 * @val: value to set 198 * 199 * Return: None 200 */ 201 void wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc *psoc, uint8_t val); 202 203 /** 204 * wifi_pos_set_drv_ver_minor: 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_drv_ver_minor(struct wlan_objmgr_psoc *psoc, uint8_t val); 212 213 /** 214 * wifi_pos_set_drv_ver_patch: public API to set param in wifi_pos private 215 * object 216 * @psoc: pointer to PSOC 217 * @val: value to set 218 * 219 * Return: None 220 */ 221 void wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc *psoc, uint8_t val); 222 223 /** 224 * wifi_pos_set_drv_ver_build: public API to set param in wifi_pos private 225 * object 226 * @psoc: pointer to PSOC 227 * @val: value to set 228 * 229 * Return: None 230 */ 231 void wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc *psoc, uint8_t val); 232 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 /** 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 /** 254 * wifi_pos_set_current_dwell_time_min: public API to set param in wifi_pos 255 * private object 256 * @psoc: pointer to PSOC 257 * @val: value to set 258 * 259 * Return: None 260 */ 261 void wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc *psoc, 262 uint16_t val); 263 264 /** 265 * wifi_pos_set_current_dwell_time_max: public API to set param in wifi_pos 266 * private object 267 * @psoc: pointer to PSOC 268 * @val: value to set 269 * 270 * Return: None 271 */ 272 void wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc *psoc, 273 uint16_t val); 274 275 /** 276 * wifi_pos_populate_caps() - populate oem capabilities 277 * @psoc: psoc object 278 * @caps: pointer to populate the capabilities 279 * 280 * Return: error code 281 */ 282 QDF_STATUS wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc, 283 struct wifi_pos_driver_caps *caps); 284 285 /** 286 * ucfg_wifi_pos_get_ftm_cap: API to get fine timing measurement caps 287 * @psoc: psoc object 288 * 289 * Return: FTM value 290 */ 291 uint32_t ucfg_wifi_pos_get_ftm_cap(struct wlan_objmgr_psoc *psoc); 292 293 /** 294 * ucfg_wifi_pos_set_ftm_cap: API to set fine timing measurement caps 295 * @psoc: psoc object 296 * @val: value to set 297 * 298 * Return: None 299 */ 300 void ucfg_wifi_pos_set_ftm_cap(struct wlan_objmgr_psoc *psoc, uint32_t val); 301 302 /** 303 * wifi_pos_get_app_pid: returns oem app pid. 304 * @psoc: pointer to psoc object 305 * 306 * Return: oem app pid 307 */ 308 uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc); 309 310 /** 311 * wifi_pos_is_app_registered: indicates if oem app is registered. 312 * @psoc: pointer to psoc object 313 * 314 * Return: true if app is registered, false otherwise 315 */ 316 bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc); 317 318 /** 319 * wifi_pos_get_psoc: API to get global PSOC object 320 * 321 * Since request from userspace is not associated with any vdev/pdev/psoc, this 322 * API is used to get global psoc object. 323 * Return: global psoc object. 324 */ 325 struct wlan_objmgr_psoc *wifi_pos_get_psoc(void); 326 327 #else 328 static inline QDF_STATUS wifi_pos_init(void) 329 { 330 return QDF_STATUS_SUCCESS; 331 } 332 333 static inline QDF_STATUS wifi_pos_deinit(void) 334 { 335 return QDF_STATUS_SUCCESS; 336 } 337 338 static inline QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc) 339 { 340 return QDF_STATUS_SUCCESS; 341 } 342 343 static inline QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc) 344 { 345 return QDF_STATUS_SUCCESS; 346 } 347 #endif 348 349 #if defined(WLAN_FEATURE_CIF_CFR) && defined(WIFI_POS_CONVERGED) 350 /** 351 * wifi_pos_init_cir_cfr_rings: API to set DMA ring cap in wifi pos psoc private 352 * object 353 * @psoc: pointer to psoc object 354 * @hal_soc: hal soc pointer 355 * @num_mac: number of macs 356 * @buf: buffer containing dma ring cap 357 * 358 * Return: status of operation. 359 */ 360 QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc, 361 void *hal_soc, uint8_t num_mac, void *buf); 362 #else 363 static inline QDF_STATUS wifi_pos_init_cir_cfr_rings( 364 struct wlan_objmgr_psoc *psoc, 365 void *hal_soc, uint8_t num_mac, void *buf) 366 { 367 return QDF_STATUS_SUCCESS; 368 } 369 #endif 370 371 #endif 372