1 /* 2 * Copyright (c) 2017-2018 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: declares driver functions interfacing with linux kernel 21 */ 22 23 24 #ifndef _WLAN_CFG80211_SCAN_H_ 25 #define _WLAN_CFG80211_SCAN_H_ 26 27 #include <linux/version.h> 28 #include <linux/netdevice.h> 29 #include <net/cfg80211.h> 30 #include <qca_vendor.h> 31 #include <wlan_scan_public_structs.h> 32 #include <qdf_list.h> 33 #include <qdf_types.h> 34 #include <wlan_scan_ucfg_api.h> 35 #include <wlan_mgmt_txrx_utils_api.h> 36 37 /* Max number of scans allowed from userspace */ 38 #define WLAN_MAX_SCAN_COUNT 8 39 40 /* GPS application requirement */ 41 #define QCOM_VENDOR_IE_ID 221 42 #define QCOM_OUI1 0x00 43 #define QCOM_OUI2 0xA0 44 #define QCOM_OUI3 0xC6 45 #define QCOM_VENDOR_IE_AGE_TYPE 0x100 46 #define QCOM_VENDOR_IE_AGE_LEN (sizeof(qcom_ie_age) - 2) 47 #define SCAN_DONE_EVENT_BUF_SIZE 4096 48 49 /** 50 * typedef struct qcom_ie_age - age ie 51 * 52 * @element_id: Element id 53 * @len: Length 54 * @oui_1: OUI 1 55 * @oui_2: OUI 2 56 * @oui_3: OUI 3 57 * @type: Type 58 * @age: Age 59 * @tsf_delta: tsf delta from FW 60 * @beacon_tsf: original beacon TSF 61 * @seq_ctrl: sequence control field 62 */ 63 typedef struct { 64 u8 element_id; 65 u8 len; 66 u8 oui_1; 67 u8 oui_2; 68 u8 oui_3; 69 u32 type; 70 u32 age; 71 u32 tsf_delta; 72 u64 beacon_tsf; 73 u16 seq_ctrl; 74 } __attribute__ ((packed)) qcom_ie_age; 75 76 /** 77 * struct osif_scan_pdev - OS scan private strcutre 78 * scan_req_q: Scan request queue 79 * scan_req_q_lock: Protect scan request queue 80 * req_id: Scan request Id 81 * runtime_pm_lock: Runtime suspend lock 82 */ 83 struct osif_scan_pdev{ 84 qdf_list_t scan_req_q; 85 qdf_mutex_t scan_req_q_lock; 86 wlan_scan_requester req_id; 87 qdf_runtime_lock_t runtime_pm_lock; 88 }; 89 90 /* 91 * enum scan_source - scan request source 92 * @NL_SCAN: Scan initiated from NL 93 * @VENDOR_SCAN: Scan intiated from vendor command 94 */ 95 enum scan_source { 96 NL_SCAN, 97 VENDOR_SCAN, 98 }; 99 100 /** 101 * struct scan_req - Scan Request entry 102 * @node : List entry element 103 * @scan_request: scan request holder 104 * @scan_id: scan identifier used across host layers which is generated at WMI 105 * @source: scan request originator (NL/Vendor scan) 106 * @dev: net device (same as what is in scan_request) 107 * 108 * Scan request linked list element 109 */ 110 struct scan_req { 111 qdf_list_node_t node; 112 struct cfg80211_scan_request *scan_request; 113 uint32_t scan_id; 114 uint8_t source; 115 struct net_device *dev; 116 }; 117 118 /** 119 * struct scan_params - Scan params 120 * @source: scan request source 121 * @default_ie: default scan ie 122 * 123 */ 124 struct scan_params { 125 uint8_t source; 126 struct element_info default_ie; 127 }; 128 129 /** 130 * struct wlan_cfg80211_inform_bss - BSS inform data 131 * @chan: channel the frame was received on 132 * @mgmt: beacon/probe resp frame 133 * @frame_len: frame length 134 * @rssi: signal strength in mBm (100*dBm) 135 * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was received. 136 * @per_chain_snr: per chain snr received 137 */ 138 struct wlan_cfg80211_inform_bss { 139 struct ieee80211_channel *chan; 140 struct ieee80211_mgmt *mgmt; 141 size_t frame_len; 142 int rssi; 143 uint64_t boottime_ns; 144 uint8_t per_chain_snr[WLAN_MGMT_TXRX_HOST_MAX_ANTENNA]; 145 }; 146 147 148 #ifdef FEATURE_WLAN_SCAN_PNO 149 /** 150 * wlan_cfg80211_sched_scan_start() - cfg80211 scheduled scan(pno) start 151 * @pdev: pdev pointer 152 * @dev: Pointer network device 153 * @request: Pointer to cfg80211 scheduled scan start request 154 * @scan_backoff_multiplier: multiply scan period by this after max cycles 155 * 156 * Return: 0 for success, non zero for failure 157 */ 158 int wlan_cfg80211_sched_scan_start(struct wlan_objmgr_pdev *pdev, 159 struct net_device *dev, 160 struct cfg80211_sched_scan_request *request, 161 uint8_t scan_backoff_multiplier); 162 163 /** 164 * wlan_cfg80211_sched_scan_stop() - cfg80211 scheduled scan(pno) stop 165 * @pdev: pdev pointer 166 * @dev: Pointer network device 167 * 168 * Return: 0 for success, non zero for failure 169 */ 170 int wlan_cfg80211_sched_scan_stop(struct wlan_objmgr_pdev *pdev, 171 struct net_device *dev); 172 #endif 173 174 /** 175 * wlan_scan_runtime_pm_init() - API to initialize runtime pm context for scan 176 * @pdev: Pointer to pdev 177 * 178 * This will help to initialize scan runtime pm context separately. 179 * 180 * Return: QDF_STATUS 181 */ 182 QDF_STATUS wlan_scan_runtime_pm_init(struct wlan_objmgr_pdev *pdev); 183 184 /** 185 * wlan_scan_runtime_pm_deinit() - API to deinitialize runtime pm 186 * for scan. 187 * @pdev: Pointer to pdev 188 * 189 * This will help to deinitialize scan runtime pm before deinitialize 190 * HIF 191 * 192 * Return: void 193 */ 194 void wlan_scan_runtime_pm_deinit(struct wlan_objmgr_pdev *pdev); 195 196 /** 197 * wlan_cfg80211_scan_priv_init() - API to initialize cfg80211 scan 198 * @pdev: Pointer to net device 199 * 200 * API to initialize cfg80211 scan module. 201 * 202 * Return: QDF_STATUS 203 */ 204 QDF_STATUS wlan_cfg80211_scan_priv_init(struct wlan_objmgr_pdev *pdev); 205 206 /** 207 * wlan_cfg80211_scan_priv_deinit() - API to deinitialize cfg80211 scan 208 * @pdev: Pointer to net device 209 * 210 * API to deinitialize cfg80211 scan module. 211 * 212 * Return: QDF_STATUS 213 */ 214 QDF_STATUS wlan_cfg80211_scan_priv_deinit( 215 struct wlan_objmgr_pdev *pdev); 216 217 /** 218 * wlan_cfg80211_scan() - API to process cfg80211 scan request 219 * @pdev: Pointer to pdev 220 * @request: Pointer to scan request 221 * @params: scan params 222 * 223 * API to trigger scan and update cfg80211 scan database. 224 * scan dump command can be used to fetch scan results 225 * on receipt of scan complete event. 226 * 227 * Return: 0 for success, non zero for failure 228 */ 229 int wlan_cfg80211_scan(struct wlan_objmgr_pdev *pdev, 230 struct cfg80211_scan_request *request, 231 struct scan_params *params); 232 233 /** 234 * wlan_cfg80211_inform_bss_frame_data() - API to inform beacon to cfg80211 235 * @wiphy: wiphy 236 * @bss_data: bss data 237 * 238 * API to inform beacon to cfg80211 239 * 240 * Return: pointer to bss entry 241 */ 242 struct cfg80211_bss * 243 wlan_cfg80211_inform_bss_frame_data(struct wiphy *wiphy, 244 struct wlan_cfg80211_inform_bss *bss); 245 246 /** 247 * wlan_cfg80211_inform_bss_frame() - API to inform beacon to cfg80211 248 * @pdev: Pointer to pdev 249 * @scan_params: scan entry 250 * @request: Pointer to scan request 251 * 252 * API to inform beacon to cfg80211 253 * 254 * Return: void 255 */ 256 void wlan_cfg80211_inform_bss_frame(struct wlan_objmgr_pdev *pdev, 257 struct scan_cache_entry *scan_params); 258 259 /** 260 * wlan_vendor_abort_scan() - API to vendor abort scan 261 * @pdev: Pointer to pdev 262 * @data: pointer to data 263 * @data_len: Data length 264 * 265 * API to abort scan through vendor command 266 * 267 * Return: 0 for success, non zero for failure 268 */ 269 int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev, 270 const void *data, int data_len); 271 272 /** 273 * wlan_cfg80211_abort_scan() - API to abort scan through cfg80211 274 * @pdev: Pointer to pdev 275 * 276 * API to abort scan through cfg80211 request 277 * 278 * Return: 0 for success, non zero for failure 279 */ 280 int wlan_cfg80211_abort_scan(struct wlan_objmgr_pdev *pdev); 281 282 /** 283 * wlan_abort_scan() - Generic API to abort scan request 284 * @pdev: Pointer to pdev 285 * @pdev_id: pdev id 286 * @vdev_id: vdev id 287 * @scan_id: scan id 288 * @sync: if wait for scan complete is required 289 * 290 * Generic API to abort scans 291 * 292 * Return: 0 for success, non zero for failure 293 */ 294 QDF_STATUS wlan_abort_scan(struct wlan_objmgr_pdev *pdev, 295 uint32_t pdev_id, 296 uint32_t vdev_id, 297 wlan_scan_id scan_id, 298 bool sync); 299 300 /** 301 * wlan_cfg80211_cleanup_scan_queue() - remove entries in scan queue 302 * @pdev: pdev pointer 303 * @dev: net device pointer 304 * 305 * Removes entries in scan queue depending on dev provided and sends scan 306 * complete event to NL. 307 * Removes all entries in scan queue, if dev provided is NULL 308 * 309 * Return: None 310 */ 311 void wlan_cfg80211_cleanup_scan_queue(struct wlan_objmgr_pdev *pdev, 312 struct net_device *dev); 313 314 315 #endif 316