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: defines driver functions interfacing with linux kernel 21 */ 22 23 #include <qdf_list.h> 24 #include <qdf_status.h> 25 #include <linux/wireless.h> 26 #include <linux/netdevice.h> 27 #include <net/cfg80211.h> 28 #include <wlan_scan_utils_api.h> 29 #include <wlan_cfg80211.h> 30 #include <wlan_cfg80211_scan.h> 31 #include <wlan_osif_priv.h> 32 #include <wlan_scan_public_structs.h> 33 #include <wlan_scan_ucfg_api.h> 34 #include <wlan_cfg80211_scan.h> 35 #include <qdf_mem.h> 36 #include <wlan_utility.h> 37 #ifdef WLAN_POLICY_MGR_ENABLE 38 #include <wlan_policy_mgr_api.h> 39 #endif 40 #include <wlan_reg_services_api.h> 41 42 static const 43 struct nla_policy scan_policy[QCA_WLAN_VENDOR_ATTR_SCAN_MAX + 1] = { 44 [QCA_WLAN_VENDOR_ATTR_SCAN_FLAGS] = {.type = NLA_U32}, 45 [QCA_WLAN_VENDOR_ATTR_SCAN_TX_NO_CCK_RATE] = {.type = NLA_FLAG}, 46 [QCA_WLAN_VENDOR_ATTR_SCAN_COOKIE] = {.type = NLA_U64}, 47 }; 48 49 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) 50 static uint32_t hdd_config_sched_scan_start_delay( 51 struct cfg80211_sched_scan_request *request) 52 { 53 return request->delay; 54 } 55 #else 56 static uint32_t hdd_config_sched_scan_start_delay( 57 struct cfg80211_sched_scan_request *request) 58 { 59 return 0; 60 } 61 #endif 62 63 #if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \ 64 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) 65 /** 66 * wlan_fill_scan_rand_attrs() - Populate the scan randomization attrs 67 * @vdev: pointer to objmgr vdev 68 * @flags: cfg80211 scan flags 69 * @mac_addr: random mac addr from cfg80211 70 * @mac_addr_mask: mac addr mask from cfg80211 71 * @randomize: output variable to check scan randomization status 72 * @addr: output variable to hold random addr 73 * @mask: output variable to hold mac mask 74 * 75 * Return: None 76 */ 77 static void wlan_fill_scan_rand_attrs(struct wlan_objmgr_vdev *vdev, 78 uint32_t flags, 79 uint8_t *mac_addr, 80 uint8_t *mac_addr_mask, 81 bool *randomize, 82 uint8_t *addr, 83 uint8_t *mask) 84 { 85 *randomize = false; 86 if (!(flags & NL80211_SCAN_FLAG_RANDOM_ADDR)) 87 return; 88 89 if (wlan_vdev_mlme_get_opmode(vdev) != QDF_STA_MODE) 90 return; 91 92 if (wlan_vdev_is_connected(vdev)) 93 return; 94 95 *randomize = true; 96 memcpy(addr, mac_addr, QDF_MAC_ADDR_SIZE); 97 memcpy(mask, mac_addr_mask, QDF_MAC_ADDR_SIZE); 98 cfg80211_debug("Random mac addr: %pM and Random mac mask: %pM", 99 addr, mask); 100 } 101 102 /** 103 * wlan_scan_rand_attrs() - Wrapper function to fill scan random attrs 104 * @vdev: pointer to objmgr vdev 105 * @request: pointer to cfg80211 scan request 106 * @req: pointer to cmn module scan request 107 * 108 * This is a wrapper function which invokes wlan_fill_scan_rand_attrs() 109 * to fill random attributes of internal scan request with cfg80211_scan_request 110 * 111 * Return: None 112 */ 113 static void wlan_scan_rand_attrs(struct wlan_objmgr_vdev *vdev, 114 struct cfg80211_scan_request *request, 115 struct scan_start_request *req) 116 { 117 bool *randomize = &req->scan_req.scan_random.randomize; 118 uint8_t *mac_addr = req->scan_req.scan_random.mac_addr; 119 uint8_t *mac_mask = req->scan_req.scan_random.mac_mask; 120 121 wlan_fill_scan_rand_attrs(vdev, request->flags, request->mac_addr, 122 request->mac_addr_mask, randomize, mac_addr, 123 mac_mask); 124 if (!*randomize) 125 return; 126 127 req->scan_req.scan_f_add_spoofed_mac_in_probe = true; 128 req->scan_req.scan_f_add_rand_seq_in_probe = true; 129 } 130 #else 131 /** 132 * wlan_scan_rand_attrs() - Wrapper function to fill scan random attrs 133 * @vdev: pointer to objmgr vdev 134 * @request: pointer to cfg80211 scan request 135 * @req: pointer to cmn module scan request 136 * 137 * This is a wrapper function which invokes wlan_fill_scan_rand_attrs() 138 * to fill random attributes of internal scan request with cfg80211_scan_request 139 * 140 * Return: None 141 */ 142 static void wlan_scan_rand_attrs(struct wlan_objmgr_vdev *vdev, 143 struct cfg80211_scan_request *request, 144 struct scan_start_request *req) 145 { 146 } 147 #endif 148 149 #ifdef FEATURE_WLAN_SCAN_PNO 150 #if ((LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) || \ 151 defined(CFG80211_MULTI_SCAN_PLAN_BACKPORT)) 152 153 /** 154 * wlan_config_sched_scan_plan() - configures the sched scan plans 155 * from the framework. 156 * @pno_req: pointer to PNO scan request 157 * @request: pointer to scan request from framework 158 * 159 * Return: None 160 */ 161 static void wlan_config_sched_scan_plan(struct pno_scan_req_params *pno_req, 162 struct cfg80211_sched_scan_request *request) 163 { 164 /* 165 * As of now max 2 scan plans were supported by firmware 166 * if number of scan plan supported by firmware increased below logic 167 * must change. 168 */ 169 if (request->n_scan_plans == SCAN_PNO_MAX_PLAN_REQUEST) { 170 pno_req->fast_scan_period = 171 request->scan_plans[0].interval * MSEC_PER_SEC; 172 pno_req->fast_scan_max_cycles = 173 request->scan_plans[0].iterations; 174 pno_req->slow_scan_period = 175 request->scan_plans[1].interval * MSEC_PER_SEC; 176 } else if (request->n_scan_plans == 1) { 177 pno_req->fast_scan_period = 178 request->scan_plans[0].interval * MSEC_PER_SEC; 179 /* 180 * if only one scan plan is configured from framework 181 * then both fast and slow scan should be configured with the 182 * same value that is why fast scan cycles are hardcoded to one 183 */ 184 pno_req->fast_scan_max_cycles = 1; 185 pno_req->slow_scan_period = 186 request->scan_plans[0].interval * MSEC_PER_SEC; 187 } else { 188 cfg80211_err("Invalid number of scan plans %d !!", 189 request->n_scan_plans); 190 } 191 } 192 #else 193 static void wlan_config_sched_scan_plan(struct pno_scan_req_params *pno_req, 194 struct cfg80211_sched_scan_request *request) 195 { 196 pno_req->fast_scan_period = request->interval; 197 pno_req->fast_scan_max_cycles = SCAN_PNO_DEF_SCAN_TIMER_REPEAT; 198 pno_req->slow_scan_period = 199 SCAN_PNO_DEF_SLOW_SCAN_MULTIPLIER * 200 pno_req->fast_scan_period; 201 } 202 #endif 203 204 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) 205 static inline void 206 wlan_cfg80211_sched_scan_results(struct wiphy *wiphy, uint64_t reqid) 207 { 208 cfg80211_sched_scan_results(wiphy); 209 } 210 #else 211 static inline void 212 wlan_cfg80211_sched_scan_results(struct wiphy *wiphy, uint64_t reqid) 213 { 214 cfg80211_sched_scan_results(wiphy, reqid); 215 } 216 #endif 217 218 /** 219 * wlan_cfg80211_pno_callback() - pno callback function to handle 220 * pno events. 221 * @vdev: vdev ptr 222 * @event: scan events 223 * @args: argument 224 * 225 * Return: void 226 */ 227 static void wlan_cfg80211_pno_callback(struct wlan_objmgr_vdev *vdev, 228 struct scan_event *event, 229 void *args) 230 { 231 struct wlan_objmgr_pdev *pdev; 232 struct pdev_osif_priv *pdev_ospriv; 233 234 if (event->type != SCAN_EVENT_TYPE_NLO_COMPLETE) 235 return; 236 237 cfg80211_debug("vdev id = %d", event->vdev_id); 238 239 pdev = wlan_vdev_get_pdev(vdev); 240 if (!pdev) { 241 cfg80211_err("pdev is NULL"); 242 return; 243 } 244 245 pdev_ospriv = wlan_pdev_get_ospriv(pdev); 246 if (!pdev_ospriv) { 247 cfg80211_err("pdev_ospriv is NULL"); 248 return; 249 } 250 wlan_cfg80211_sched_scan_results(pdev_ospriv->wiphy, 0); 251 } 252 253 #ifdef WLAN_POLICY_MGR_ENABLE 254 static bool wlan_cfg80211_is_ap_go_present(struct wlan_objmgr_psoc *psoc) 255 { 256 return policy_mgr_mode_specific_connection_count(psoc, 257 PM_SAP_MODE, 258 NULL) || 259 policy_mgr_mode_specific_connection_count(psoc, 260 PM_P2P_GO_MODE, 261 NULL); 262 } 263 264 static QDF_STATUS wlan_cfg80211_is_chan_ok_for_dnbs( 265 struct wlan_objmgr_psoc *psoc, 266 u8 channel, bool *ok) 267 { 268 QDF_STATUS status = policy_mgr_is_chan_ok_for_dnbs(psoc, channel, ok); 269 270 if (QDF_IS_STATUS_ERROR(status)) { 271 cfg80211_err("DNBS check failed"); 272 return status; 273 } 274 275 return QDF_STATUS_SUCCESS; 276 } 277 #else 278 static bool wlan_cfg80211_is_ap_go_present(struct wlan_objmgr_psoc *psoc) 279 { 280 return false; 281 } 282 283 static QDF_STATUS wlan_cfg80211_is_chan_ok_for_dnbs( 284 struct wlan_objmgr_psoc *psoc, 285 u8 channel, 286 bool *ok) 287 { 288 if (!ok) 289 return QDF_STATUS_E_INVAL; 290 291 *ok = true; 292 return QDF_STATUS_SUCCESS; 293 } 294 #endif 295 296 #if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \ 297 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) 298 /** 299 * wlan_pno_scan_rand_attr() - Wrapper function to fill sched scan random attrs 300 * @vdev: pointer to objmgr vdev 301 * @request: pointer to cfg80211 sched scan request 302 * @req: pointer to cmn module pno scan request 303 * 304 * This is a wrapper function which invokes wlan_fill_scan_rand_attrs() 305 * to fill random attributes of internal pno scan 306 * with cfg80211_sched_scan_request 307 * 308 * Return: None 309 */ 310 static void wlan_pno_scan_rand_attr(struct wlan_objmgr_vdev *vdev, 311 struct cfg80211_sched_scan_request *request, 312 struct pno_scan_req_params *req) 313 { 314 bool *randomize = &req->scan_random.randomize; 315 uint8_t *mac_addr = req->scan_random.mac_addr; 316 uint8_t *mac_mask = req->scan_random.mac_mask; 317 318 wlan_fill_scan_rand_attrs(vdev, request->flags, request->mac_addr, 319 request->mac_addr_mask, randomize, mac_addr, 320 mac_mask); 321 } 322 #else 323 /** 324 * wlan_pno_scan_rand_attr() - Wrapper function to fill sched scan random attrs 325 * @vdev: pointer to objmgr vdev 326 * @request: pointer to cfg80211 sched scan request 327 * @req: pointer to cmn module pno scan request 328 * 329 * This is a wrapper function which invokes wlan_fill_scan_rand_attrs() 330 * to fill random attributes of internal pno scan 331 * with cfg80211_sched_scan_request 332 * 333 * Return: None 334 */ 335 static void wlan_pno_scan_rand_attr(struct wlan_objmgr_vdev *vdev, 336 struct cfg80211_sched_scan_request *request, 337 struct pno_scan_req_params *req) 338 { 339 } 340 #endif 341 342 /** 343 * wlan_hdd_sched_scan_update_relative_rssi() - update CPNO params 344 * @pno_request: pointer to PNO scan request 345 * @request: Pointer to cfg80211 scheduled scan start request 346 * 347 * This function is used to update Connected PNO params sent by kernel 348 * 349 * Return: None 350 */ 351 #if defined(CFG80211_REPORT_BETTER_BSS_IN_SCHED_SCAN) || \ 352 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) 353 static inline void wlan_hdd_sched_scan_update_relative_rssi( 354 struct pno_scan_req_params *pno_request, 355 struct cfg80211_sched_scan_request *request) 356 { 357 pno_request->relative_rssi_set = request->relative_rssi_set; 358 pno_request->relative_rssi = request->relative_rssi; 359 if (NL80211_BAND_2GHZ == request->rssi_adjust.band) 360 pno_request->band_rssi_pref.band = WLAN_BAND_2_4_GHZ; 361 else if (NL80211_BAND_5GHZ == request->rssi_adjust.band) 362 pno_request->band_rssi_pref.band = WLAN_BAND_5_GHZ; 363 pno_request->band_rssi_pref.rssi = request->rssi_adjust.delta; 364 } 365 #else 366 static inline void wlan_hdd_sched_scan_update_relative_rssi( 367 struct pno_scan_req_params *pno_request, 368 struct cfg80211_sched_scan_request *request) 369 { 370 } 371 #endif 372 373 int wlan_cfg80211_sched_scan_start(struct wlan_objmgr_pdev *pdev, 374 struct net_device *dev, 375 struct cfg80211_sched_scan_request *request, 376 uint8_t scan_backoff_multiplier) 377 { 378 struct pno_scan_req_params *req; 379 int i, j, ret = 0; 380 QDF_STATUS status; 381 uint8_t num_chan = 0, channel; 382 struct wlan_objmgr_vdev *vdev; 383 struct wlan_objmgr_psoc *psoc; 384 uint32_t valid_ch[SCAN_PNO_MAX_NETW_CHANNELS_EX] = {0}; 385 386 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(pdev, dev->dev_addr, 387 WLAN_OSIF_ID); 388 if (!vdev) { 389 cfg80211_err("vdev object is NULL"); 390 return -EIO; 391 } 392 393 if (ucfg_scan_get_pno_in_progress(vdev)) { 394 cfg80211_debug("pno is already in progress"); 395 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 396 return -EBUSY; 397 } 398 399 if (ucfg_scan_get_pdev_status(pdev) != 400 SCAN_NOT_IN_PROGRESS) { 401 status = wlan_abort_scan(pdev, 402 wlan_objmgr_pdev_get_pdev_id(pdev), 403 INVAL_VDEV_ID, INVAL_SCAN_ID, true); 404 if (QDF_IS_STATUS_ERROR(status)) { 405 cfg80211_err("aborting the existing scan is unsuccessful"); 406 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 407 return -EBUSY; 408 } 409 } 410 411 req = qdf_mem_malloc(sizeof(*req)); 412 if (!req) { 413 cfg80211_err("req malloc failed"); 414 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 415 return -ENOMEM; 416 } 417 418 wlan_pdev_obj_lock(pdev); 419 psoc = wlan_pdev_get_psoc(pdev); 420 wlan_pdev_obj_unlock(pdev); 421 422 req->networks_cnt = request->n_match_sets; 423 req->vdev_id = wlan_vdev_get_id(vdev); 424 425 if ((!req->networks_cnt) || 426 (req->networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) { 427 cfg80211_err("Network input is not correct %d", 428 req->networks_cnt); 429 ret = -EINVAL; 430 goto error; 431 } 432 433 if (request->n_channels > SCAN_PNO_MAX_NETW_CHANNELS_EX) { 434 cfg80211_err("Incorrect number of channels %d", 435 request->n_channels); 436 ret = -EINVAL; 437 goto error; 438 } 439 440 if (request->n_channels) { 441 char chl[(request->n_channels * 5) + 1]; 442 int len = 0; 443 bool ap_or_go_present = wlan_cfg80211_is_ap_go_present(psoc); 444 445 for (i = 0; i < request->n_channels; i++) { 446 channel = request->channels[i]->hw_value; 447 if (wlan_reg_is_dsrc_chan(pdev, channel)) 448 continue; 449 450 if (ap_or_go_present) { 451 bool ok; 452 453 status = 454 wlan_cfg80211_is_chan_ok_for_dnbs(psoc, 455 channel, 456 &ok); 457 if (QDF_IS_STATUS_ERROR(status)) { 458 cfg80211_err("DNBS check failed"); 459 qdf_mem_free(req); 460 ret = -EINVAL; 461 goto error; 462 } 463 if (!ok) 464 continue; 465 } 466 len += snprintf(chl + len, 5, "%d ", channel); 467 valid_ch[num_chan++] = wlan_chan_to_freq(channel); 468 } 469 cfg80211_notice("No. of Scan Channels: %d", num_chan); 470 cfg80211_notice("Channel-List: %s", chl); 471 /* If all channels are DFS and dropped, 472 * then ignore the PNO request 473 */ 474 if (!num_chan) { 475 cfg80211_notice("Channel list empty due to filtering of DSRC"); 476 ret = -EINVAL; 477 goto error; 478 } 479 } 480 481 /* Filling per profile params */ 482 for (i = 0; i < req->networks_cnt; i++) { 483 req->networks_list[i].ssid.length = 484 request->match_sets[i].ssid.ssid_len; 485 486 if ((!req->networks_list[i].ssid.length) || 487 (req->networks_list[i].ssid.length > WLAN_SSID_MAX_LEN)) { 488 cfg80211_err(" SSID Len %d is not correct for network %d", 489 req->networks_list[i].ssid.length, i); 490 ret = -EINVAL; 491 goto error; 492 } 493 494 qdf_mem_copy(req->networks_list[i].ssid.ssid, 495 request->match_sets[i].ssid.ssid, 496 req->networks_list[i].ssid.length); 497 req->networks_list[i].authentication = 0; /*eAUTH_TYPE_ANY */ 498 req->networks_list[i].encryption = 0; /*eED_ANY */ 499 req->networks_list[i].bc_new_type = 0; /*eBCAST_UNKNOWN */ 500 501 cfg80211_notice("Received ssid:%.*s", 502 req->networks_list[i].ssid.length, 503 req->networks_list[i].ssid.ssid); 504 505 /*Copying list of valid channel into request */ 506 qdf_mem_copy(req->networks_list[i].channels, valid_ch, 507 num_chan * sizeof(uint32_t)); 508 req->networks_list[i].channel_cnt = num_chan; 509 req->networks_list[i].rssi_thresh = 510 request->match_sets[i].rssi_thold; 511 } 512 513 /* set scan to passive if no SSIDs are specified in the request */ 514 if (0 == request->n_ssids) 515 req->do_passive_scan = true; 516 else 517 req->do_passive_scan = false; 518 519 for (i = 0; i < request->n_ssids; i++) { 520 j = 0; 521 while (j < req->networks_cnt) { 522 if ((req->networks_list[j].ssid.length == 523 request->ssids[i].ssid_len) && 524 (!qdf_mem_cmp(req->networks_list[j].ssid.ssid, 525 request->ssids[i].ssid, 526 req->networks_list[j].ssid.length))) { 527 req->networks_list[j].bc_new_type = 528 SSID_BC_TYPE_HIDDEN; 529 break; 530 } 531 j++; 532 } 533 } 534 cfg80211_notice("Number of hidden networks being Configured = %d", 535 request->n_ssids); 536 537 /* 538 * Before Kernel 4.4 539 * Driver gets only one time interval which is hard coded in 540 * supplicant for 10000ms. 541 * 542 * After Kernel 4.4 543 * User can configure multiple scan_plans, each scan would have 544 * separate scan cycle and interval. (interval is in unit of second.) 545 * For our use case, we would only have supplicant set one scan_plan, 546 * and firmware also support only one as well, so pick up the first 547 * index. 548 * 549 * Taking power consumption into account 550 * firmware after gPNOScanTimerRepeatValue times fast_scan_period 551 * switches slow_scan_period. This is less frequent scans and firmware 552 * shall be in slow_scan_period mode until next PNO Start. 553 */ 554 wlan_config_sched_scan_plan(req, request); 555 req->delay_start_time = hdd_config_sched_scan_start_delay(request); 556 req->scan_backoff_multiplier = scan_backoff_multiplier; 557 cfg80211_notice("Base scan interval: %d sec, scan cycles: %d, slow scan interval %d", 558 req->fast_scan_period, req->fast_scan_max_cycles, 559 req->slow_scan_period); 560 wlan_hdd_sched_scan_update_relative_rssi(req, request); 561 562 psoc = wlan_pdev_get_psoc(pdev); 563 ucfg_scan_register_pno_cb(psoc, 564 wlan_cfg80211_pno_callback, NULL); 565 ucfg_scan_get_pno_def_params(vdev, req); 566 567 if (req->scan_random.randomize) 568 wlan_pno_scan_rand_attr(vdev, request, req); 569 570 if (ucfg_ie_whitelist_enabled(psoc, vdev)) 571 ucfg_copy_ie_whitelist_attrs(psoc, &req->ie_whitelist); 572 status = ucfg_scan_pno_start(vdev, req); 573 if (QDF_IS_STATUS_ERROR(status)) { 574 cfg80211_err("Failed to enable PNO"); 575 ret = -EINVAL; 576 goto error; 577 } 578 579 cfg80211_info("PNO scan request offloaded"); 580 581 error: 582 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 583 qdf_mem_free(req); 584 return ret; 585 } 586 587 int wlan_cfg80211_sched_scan_stop(struct wlan_objmgr_pdev *pdev, 588 struct net_device *dev) 589 { 590 int ret = 0; 591 QDF_STATUS status; 592 struct wlan_objmgr_vdev *vdev; 593 594 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(pdev, dev->dev_addr, 595 WLAN_OSIF_ID); 596 if (!vdev) { 597 cfg80211_err("vdev object is NULL"); 598 return -EIO; 599 } 600 601 status = ucfg_scan_pno_stop(vdev); 602 if (QDF_IS_STATUS_ERROR(status)) { 603 cfg80211_err("Failed to disabled PNO"); 604 ret = -EINVAL; 605 } else { 606 cfg80211_info("PNO scan disabled"); 607 } 608 609 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 610 return ret; 611 } 612 #endif /*FEATURE_WLAN_SCAN_PNO */ 613 614 /** 615 * wlan_copy_bssid_scan_request() - API to copy the bssid to Scan request 616 * @scan_req: Pointer to scan_start_request 617 * @request: scan request from Supplicant 618 * 619 * This API copies the BSSID in scan request from Supplicant and copies it to 620 * the scan_start_request 621 * 622 * Return: None 623 */ 624 #if defined(CFG80211_SCAN_BSSID) || \ 625 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) 626 static inline void 627 wlan_copy_bssid_scan_request(struct scan_start_request *scan_req, 628 struct cfg80211_scan_request *request) 629 { 630 qdf_mem_copy(scan_req->scan_req.bssid_list[0].bytes, 631 request->bssid, QDF_MAC_ADDR_SIZE); 632 } 633 #else 634 static inline void 635 wlan_copy_bssid_scan_request(struct scan_start_request *scan_req, 636 struct cfg80211_scan_request *request) 637 { 638 639 } 640 #endif 641 642 /** 643 * wlan_scan_request_enqueue() - enqueue Scan Request 644 * @pdev: pointer to pdev object 645 * @req: Pointer to the scan request 646 * @source: source of the scan request 647 * @scan_id: scan identifier 648 * 649 * Enqueue scan request in the global scan list.This list 650 * stores the active scan request information. 651 * 652 * Return: 0 on success, error number otherwise 653 */ 654 static int wlan_scan_request_enqueue(struct wlan_objmgr_pdev *pdev, 655 struct cfg80211_scan_request *req, 656 uint8_t source, uint32_t scan_id) 657 { 658 struct scan_req *scan_req; 659 QDF_STATUS status; 660 struct pdev_osif_priv *osif_ctx; 661 struct osif_scan_pdev *osif_scan; 662 663 scan_req = qdf_mem_malloc(sizeof(*scan_req)); 664 if (NULL == scan_req) { 665 cfg80211_alert("malloc failed for Scan req"); 666 return -ENOMEM; 667 } 668 669 /* Get NL global context from objmgr*/ 670 osif_ctx = wlan_pdev_get_ospriv(pdev); 671 osif_scan = osif_ctx->osif_scan; 672 scan_req->scan_request = req; 673 scan_req->source = source; 674 scan_req->scan_id = scan_id; 675 scan_req->dev = req->wdev->netdev; 676 677 qdf_mutex_acquire(&osif_scan->scan_req_q_lock); 678 status = qdf_list_insert_back(&osif_scan->scan_req_q, 679 &scan_req->node); 680 qdf_mutex_release(&osif_scan->scan_req_q_lock); 681 if (QDF_STATUS_SUCCESS != status) { 682 cfg80211_err("Failed to enqueue Scan Req"); 683 qdf_mem_free(scan_req); 684 return -EINVAL; 685 } 686 687 return 0; 688 } 689 690 /** 691 * wlan_scan_request_dequeue() - dequeue scan request 692 * @nl_ctx: Global HDD context 693 * @scan_id: scan id 694 * @req: scan request 695 * @dev: net device 696 * @source : returns source of the scan request 697 * 698 * Return: QDF_STATUS 699 */ 700 static QDF_STATUS wlan_scan_request_dequeue( 701 struct wlan_objmgr_pdev *pdev, 702 uint32_t scan_id, struct cfg80211_scan_request **req, 703 uint8_t *source, struct net_device **dev) 704 { 705 QDF_STATUS status = QDF_STATUS_E_FAILURE; 706 struct scan_req *scan_req; 707 qdf_list_node_t *node = NULL, *next_node = NULL; 708 struct pdev_osif_priv *osif_ctx; 709 struct osif_scan_pdev *scan_priv; 710 711 cfg80211_debug("Dequeue Scan id: %d", scan_id); 712 713 if ((source == NULL) || (req == NULL)) { 714 cfg80211_err("source or request is NULL"); 715 return QDF_STATUS_E_NULL_VALUE; 716 } 717 718 /* Get NL global context from objmgr*/ 719 osif_ctx = wlan_pdev_get_ospriv(pdev); 720 if (!osif_ctx) { 721 cfg80211_err("Failed to retrieve osif context"); 722 return status; 723 } 724 scan_priv = osif_ctx->osif_scan; 725 726 if (qdf_list_empty(&scan_priv->scan_req_q)) { 727 cfg80211_info("Scan List is empty"); 728 return QDF_STATUS_E_FAILURE; 729 } 730 731 qdf_mutex_acquire(&scan_priv->scan_req_q_lock); 732 if (QDF_STATUS_SUCCESS != 733 qdf_list_peek_front(&scan_priv->scan_req_q, &next_node)) { 734 qdf_mutex_release(&scan_priv->scan_req_q_lock); 735 cfg80211_err("Failed to remove Scan Req from queue"); 736 return QDF_STATUS_E_FAILURE; 737 } 738 739 do { 740 node = next_node; 741 scan_req = qdf_container_of(node, struct scan_req, 742 node); 743 if (scan_req->scan_id == scan_id) { 744 status = qdf_list_remove_node(&scan_priv->scan_req_q, 745 node); 746 if (status == QDF_STATUS_SUCCESS) { 747 *req = scan_req->scan_request; 748 *source = scan_req->source; 749 *dev = scan_req->dev; 750 qdf_mem_free(scan_req); 751 qdf_mutex_release(&scan_priv->scan_req_q_lock); 752 cfg80211_debug("removed Scan id: %d, req = %pK, pending scans %d", 753 scan_id, req, 754 qdf_list_size(&scan_priv-> 755 scan_req_q)); 756 return QDF_STATUS_SUCCESS; 757 } else { 758 qdf_mutex_release(&scan_priv->scan_req_q_lock); 759 cfg80211_err("Failed to remove node scan id %d, pending scans %d", 760 scan_id, 761 qdf_list_size(&scan_priv->scan_req_q)); 762 return status; 763 } 764 } 765 } while (QDF_STATUS_SUCCESS == 766 qdf_list_peek_next(&scan_priv->scan_req_q, node, &next_node)); 767 qdf_mutex_release(&scan_priv->scan_req_q_lock); 768 cfg80211_err("Failed to find scan id %d", scan_id); 769 770 return status; 771 } 772 773 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) 774 /** 775 * wlan_cfg80211_scan_done() - Scan completed callback to cfg80211 776 * @netdev: Net device 777 * @req : Scan request 778 * @aborted : true scan aborted false scan success 779 * 780 * This function notifies scan done to cfg80211 781 * 782 * Return: none 783 */ 784 static void wlan_cfg80211_scan_done(struct net_device *netdev, 785 struct cfg80211_scan_request *req, 786 bool aborted) 787 { 788 struct cfg80211_scan_info info = { 789 .aborted = aborted 790 }; 791 792 if (netdev->flags & IFF_UP) 793 cfg80211_scan_done(req, &info); 794 } 795 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) 796 /** 797 * wlan_cfg80211_scan_done() - Scan completed callback to cfg80211 798 * @netdev: Net device 799 * @req : Scan request 800 * @aborted : true scan aborted false scan success 801 * 802 * This function notifies scan done to cfg80211 803 * 804 * Return: none 805 */ 806 static void wlan_cfg80211_scan_done(struct net_device *netdev, 807 struct cfg80211_scan_request *req, 808 bool aborted) 809 { 810 if (netdev->flags & IFF_UP) 811 cfg80211_scan_done(req, aborted); 812 } 813 #endif 814 815 /** 816 * wlan_vendor_scan_callback() - Scan completed callback event 817 * 818 * @req : Scan request 819 * @aborted : true scan aborted false scan success 820 * 821 * This function sends scan completed callback event to NL. 822 * 823 * Return: none 824 */ 825 static void wlan_vendor_scan_callback(struct cfg80211_scan_request *req, 826 bool aborted) 827 { 828 struct sk_buff *skb; 829 struct nlattr *attr; 830 int i; 831 uint8_t scan_status; 832 uint64_t cookie; 833 834 skb = cfg80211_vendor_event_alloc(req->wdev->wiphy, req->wdev, 835 SCAN_DONE_EVENT_BUF_SIZE + 4 + NLMSG_HDRLEN, 836 QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE_INDEX, 837 GFP_ATOMIC); 838 839 if (!skb) { 840 cfg80211_err("skb alloc failed"); 841 qdf_mem_free(req); 842 return; 843 } 844 845 cookie = (uintptr_t)req; 846 847 attr = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_SCAN_SSIDS); 848 if (!attr) 849 goto nla_put_failure; 850 for (i = 0; i < req->n_ssids; i++) { 851 if (nla_put(skb, i, req->ssids[i].ssid_len, req->ssids[i].ssid)) 852 goto nla_put_failure; 853 } 854 nla_nest_end(skb, attr); 855 856 attr = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_SCAN_FREQUENCIES); 857 if (!attr) 858 goto nla_put_failure; 859 for (i = 0; i < req->n_channels; i++) { 860 if (nla_put_u32(skb, i, req->channels[i]->center_freq)) 861 goto nla_put_failure; 862 } 863 nla_nest_end(skb, attr); 864 865 if (req->ie && 866 nla_put(skb, QCA_WLAN_VENDOR_ATTR_SCAN_IE, req->ie_len, 867 req->ie)) 868 goto nla_put_failure; 869 870 if (req->flags && 871 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_SCAN_FLAGS, req->flags)) 872 goto nla_put_failure; 873 874 if (wlan_cfg80211_nla_put_u64(skb, QCA_WLAN_VENDOR_ATTR_SCAN_COOKIE, 875 cookie)) 876 goto nla_put_failure; 877 878 scan_status = (aborted == true) ? VENDOR_SCAN_STATUS_ABORTED : 879 VENDOR_SCAN_STATUS_NEW_RESULTS; 880 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_SCAN_STATUS, scan_status)) 881 goto nla_put_failure; 882 883 cfg80211_vendor_event(skb, GFP_ATOMIC); 884 qdf_mem_free(req); 885 886 return; 887 888 nla_put_failure: 889 kfree_skb(skb); 890 qdf_mem_free(req); 891 } 892 893 894 /** 895 * wlan_cfg80211_scan_done_callback() - scan done callback function called after 896 * scan is finished 897 * @vdev: vdev ptr 898 * @event: Scan event 899 * @args: Scan cb arg 900 * 901 * Return: void 902 */ 903 static void wlan_cfg80211_scan_done_callback( 904 struct wlan_objmgr_vdev *vdev, 905 struct scan_event *event, 906 void *args) 907 { 908 struct cfg80211_scan_request *req = NULL; 909 bool success = false; 910 uint32_t scan_id = event->scan_id; 911 uint8_t source = NL_SCAN; 912 struct wlan_objmgr_pdev *pdev; 913 struct pdev_osif_priv *osif_priv; 914 struct net_device *netdev = NULL; 915 QDF_STATUS status; 916 917 if (!util_is_scan_completed(event, &success)) 918 return; 919 920 cfg80211_debug("scan ID = %d vdev id = %d, event type %s(%d) reason = %s(%d)", 921 scan_id, event->vdev_id, 922 util_scan_get_ev_type_name(event->type), event->type, 923 util_scan_get_ev_reason_name(event->reason), 924 event->reason); 925 926 pdev = wlan_vdev_get_pdev(vdev); 927 status = wlan_scan_request_dequeue( 928 pdev, scan_id, &req, &source, &netdev); 929 if (QDF_IS_STATUS_ERROR(status)) { 930 cfg80211_err("Dequeue of scan request failed ID: %d", scan_id); 931 goto allow_suspend; 932 } 933 934 if (!netdev) { 935 cfg80211_err("net dev is NULL,Drop scan event Id: %d", 936 scan_id); 937 goto allow_suspend; 938 } 939 940 /* Make sure vdev is active */ 941 status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_OSIF_ID); 942 if (QDF_IS_STATUS_ERROR(status)) { 943 cfg80211_err("Failed to get vdev reference: scan Id: %d", 944 scan_id); 945 goto allow_suspend; 946 } 947 948 /* 949 * Scan can be triggred from NL or vendor scan 950 * - If scan is triggered from NL then cfg80211 scan done should be 951 * called to updated scan completion to NL. 952 * - If scan is triggred through vendor command then 953 * scan done event will be posted 954 */ 955 if (NL_SCAN == source) 956 wlan_cfg80211_scan_done(netdev, req, !success); 957 else 958 wlan_vendor_scan_callback(req, !success); 959 960 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 961 allow_suspend: 962 osif_priv = wlan_pdev_get_ospriv(pdev); 963 if (qdf_list_empty(&osif_priv->osif_scan->scan_req_q)) 964 qdf_runtime_pm_allow_suspend( 965 &osif_priv->osif_scan->runtime_pm_lock); 966 967 } 968 969 QDF_STATUS wlan_scan_runtime_pm_init(struct wlan_objmgr_pdev *pdev) 970 { 971 struct pdev_osif_priv *osif_priv; 972 struct osif_scan_pdev *scan_priv; 973 974 wlan_pdev_obj_lock(pdev); 975 osif_priv = wlan_pdev_get_ospriv(pdev); 976 wlan_pdev_obj_unlock(pdev); 977 978 scan_priv = osif_priv->osif_scan; 979 980 return qdf_runtime_lock_init(&scan_priv->runtime_pm_lock); 981 } 982 983 void wlan_scan_runtime_pm_deinit(struct wlan_objmgr_pdev *pdev) 984 { 985 struct pdev_osif_priv *osif_priv; 986 struct osif_scan_pdev *scan_priv; 987 988 wlan_pdev_obj_lock(pdev); 989 osif_priv = wlan_pdev_get_ospriv(pdev); 990 wlan_pdev_obj_unlock(pdev); 991 992 scan_priv = osif_priv->osif_scan; 993 qdf_runtime_lock_deinit(&scan_priv->runtime_pm_lock); 994 } 995 996 QDF_STATUS wlan_cfg80211_scan_priv_init(struct wlan_objmgr_pdev *pdev) 997 { 998 struct pdev_osif_priv *osif_priv; 999 struct osif_scan_pdev *scan_priv; 1000 struct wlan_objmgr_psoc *psoc; 1001 wlan_scan_requester req_id; 1002 1003 psoc = wlan_pdev_get_psoc(pdev); 1004 1005 req_id = ucfg_scan_register_requester(psoc, "CFG", 1006 wlan_cfg80211_scan_done_callback, NULL); 1007 1008 osif_priv = wlan_pdev_get_ospriv(pdev); 1009 scan_priv = qdf_mem_malloc(sizeof(*scan_priv)); 1010 if (!scan_priv) { 1011 cfg80211_err("failed to allocate memory"); 1012 return QDF_STATUS_E_NOMEM; 1013 } 1014 /* Initialize the scan request queue */ 1015 osif_priv->osif_scan = scan_priv; 1016 qdf_list_create(&scan_priv->scan_req_q, WLAN_MAX_SCAN_COUNT); 1017 qdf_mutex_create(&scan_priv->scan_req_q_lock); 1018 scan_priv->req_id = req_id; 1019 1020 return QDF_STATUS_SUCCESS; 1021 } 1022 1023 QDF_STATUS wlan_cfg80211_scan_priv_deinit(struct wlan_objmgr_pdev *pdev) 1024 { 1025 struct pdev_osif_priv *osif_priv; 1026 struct osif_scan_pdev *scan_priv; 1027 struct wlan_objmgr_psoc *psoc; 1028 1029 psoc = wlan_pdev_get_psoc(pdev); 1030 osif_priv = wlan_pdev_get_ospriv(pdev); 1031 1032 wlan_cfg80211_cleanup_scan_queue(pdev, NULL); 1033 scan_priv = osif_priv->osif_scan; 1034 ucfg_scan_unregister_requester(psoc, scan_priv->req_id); 1035 qdf_list_destroy(&scan_priv->scan_req_q); 1036 qdf_mutex_destroy(&scan_priv->scan_req_q_lock); 1037 qdf_mem_free(scan_priv); 1038 osif_priv->osif_scan = NULL; 1039 1040 return QDF_STATUS_SUCCESS; 1041 } 1042 1043 /** 1044 * wlan_cfg80211_enqueue_for_cleanup() - Function to populate scan cleanup queue 1045 * @scan_cleanup_q: Scan cleanup queue to be populated 1046 * @scan_priv: Pointer to scan related data used by cfg80211 scan 1047 * @dev: Netdevice pointer 1048 * 1049 * The function synchrounously iterates through the global scan queue to 1050 * identify entries that have to be cleaned up, copies identified entries 1051 * to another queue(to send scan complete event to NL later) and removes the 1052 * entry from the global scan queue. 1053 * 1054 * Return: None 1055 */ 1056 static void 1057 wlan_cfg80211_enqueue_for_cleanup(qdf_list_t *scan_cleanup_q, 1058 struct osif_scan_pdev *scan_priv, 1059 struct net_device *dev) 1060 { 1061 struct scan_req *scan_req, *scan_cleanup; 1062 qdf_list_node_t *node = NULL, *next_node = NULL; 1063 1064 qdf_mutex_acquire(&scan_priv->scan_req_q_lock); 1065 if (QDF_STATUS_SUCCESS != 1066 qdf_list_peek_front(&scan_priv->scan_req_q, 1067 &node)) { 1068 qdf_mutex_release(&scan_priv->scan_req_q_lock); 1069 return; 1070 } 1071 1072 while (node) { 1073 /* 1074 * Keep track of the next node, to traverse through the list 1075 * in the event of the current node being deleted. 1076 */ 1077 qdf_list_peek_next(&scan_priv->scan_req_q, 1078 node, &next_node); 1079 scan_req = qdf_container_of(node, struct scan_req, node); 1080 if (!dev || (dev == scan_req->dev)) { 1081 scan_cleanup = qdf_mem_malloc(sizeof(struct scan_req)); 1082 if (!scan_cleanup) { 1083 qdf_mutex_release(&scan_priv->scan_req_q_lock); 1084 cfg80211_err("Failed to allocate memory"); 1085 return; 1086 } 1087 scan_cleanup->scan_request = scan_req->scan_request; 1088 scan_cleanup->scan_id = scan_req->scan_id; 1089 scan_cleanup->source = scan_req->source; 1090 scan_cleanup->dev = scan_req->dev; 1091 qdf_list_insert_back(scan_cleanup_q, 1092 &scan_cleanup->node); 1093 if (QDF_STATUS_SUCCESS != 1094 qdf_list_remove_node(&scan_priv->scan_req_q, 1095 node)) { 1096 qdf_mutex_release(&scan_priv->scan_req_q_lock); 1097 cfg80211_err("Failed to remove scan request"); 1098 return; 1099 } 1100 qdf_mem_free(scan_req); 1101 } 1102 node = next_node; 1103 next_node = NULL; 1104 } 1105 qdf_mutex_release(&scan_priv->scan_req_q_lock); 1106 } 1107 1108 void wlan_cfg80211_cleanup_scan_queue(struct wlan_objmgr_pdev *pdev, 1109 struct net_device *dev) 1110 { 1111 struct scan_req *scan_req; 1112 struct cfg80211_scan_request *req; 1113 uint8_t source; 1114 bool aborted = true; 1115 struct pdev_osif_priv *osif_priv; 1116 qdf_list_t scan_cleanup_q; 1117 qdf_list_node_t *node = NULL; 1118 1119 if (!pdev) { 1120 cfg80211_err("pdev is Null"); 1121 return; 1122 } 1123 1124 osif_priv = wlan_pdev_get_ospriv(pdev); 1125 1126 /* 1127 * To avoid any race conditions, create a local list to copy all the 1128 * scan entries to be removed and then send scan complete for each of 1129 * the identified entries to NL. 1130 */ 1131 qdf_list_create(&scan_cleanup_q, WLAN_MAX_SCAN_COUNT); 1132 wlan_cfg80211_enqueue_for_cleanup(&scan_cleanup_q, 1133 osif_priv->osif_scan, dev); 1134 1135 while (!qdf_list_empty(&scan_cleanup_q)) { 1136 if (QDF_STATUS_SUCCESS != qdf_list_remove_front(&scan_cleanup_q, 1137 &node)) { 1138 cfg80211_err("Failed to remove scan request"); 1139 return; 1140 } 1141 scan_req = container_of(node, struct scan_req, node); 1142 req = scan_req->scan_request; 1143 source = scan_req->source; 1144 if (NL_SCAN == source) 1145 wlan_cfg80211_scan_done(scan_req->dev, req, 1146 aborted); 1147 else 1148 wlan_vendor_scan_callback(req, aborted); 1149 1150 qdf_mem_free(scan_req); 1151 } 1152 qdf_list_destroy(&scan_cleanup_q); 1153 1154 return; 1155 } 1156 1157 /** 1158 * wlan_cfg80211_update_scan_policy_type_flags() - Set scan flags according to 1159 * scan request 1160 * @scan_req: Pointer to csr scan req 1161 * 1162 * Return: None 1163 */ 1164 #if defined(CFG80211_SCAN_DBS_CONTROL_SUPPORT) || \ 1165 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)) 1166 static void wlan_cfg80211_update_scan_policy_type_flags( 1167 struct cfg80211_scan_request *req, 1168 struct scan_req_params *scan_req) 1169 { 1170 if (req->flags & NL80211_SCAN_FLAG_HIGH_ACCURACY) 1171 scan_req->scan_policy_high_accuracy = true; 1172 if (req->flags & NL80211_SCAN_FLAG_LOW_SPAN) 1173 scan_req->scan_policy_low_span = true; 1174 if (req->flags & NL80211_SCAN_FLAG_LOW_POWER) 1175 scan_req->scan_policy_low_power = true; 1176 } 1177 #else 1178 static inline void wlan_cfg80211_update_scan_policy_type_flags( 1179 struct cfg80211_scan_request *req, 1180 struct scan_req_params *scan_req) 1181 { 1182 } 1183 #endif 1184 1185 int wlan_cfg80211_scan(struct wlan_objmgr_pdev *pdev, 1186 struct cfg80211_scan_request *request, 1187 struct scan_params *params) 1188 { 1189 struct net_device *dev = request->wdev->netdev; 1190 struct scan_start_request *req; 1191 struct wlan_ssid *pssid; 1192 uint8_t i; 1193 int status; 1194 uint8_t num_chan = 0, channel; 1195 uint32_t c_freq; 1196 struct wlan_objmgr_vdev *vdev; 1197 wlan_scan_requester req_id; 1198 struct pdev_osif_priv *osif_priv; 1199 struct wlan_objmgr_psoc *psoc; 1200 wlan_scan_id scan_id; 1201 bool is_p2p_scan = false; 1202 enum wlan_band band; 1203 struct net_device *netdev = NULL; 1204 1205 /* Get the vdev object */ 1206 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(pdev, dev->dev_addr, 1207 WLAN_OSIF_ID); 1208 if (vdev == NULL) { 1209 cfg80211_err("vdev object is NULL"); 1210 return -EIO; 1211 } 1212 psoc = wlan_pdev_get_psoc(pdev); 1213 if (!psoc) { 1214 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 1215 cfg80211_err("Invalid psoc object"); 1216 return -EINVAL; 1217 } 1218 req = qdf_mem_malloc(sizeof(*req)); 1219 if (!req) { 1220 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 1221 cfg80211_err("Failed to allocate scan request memory"); 1222 return -EINVAL; 1223 } 1224 /* Initialize the scan global params */ 1225 ucfg_scan_init_default_params(vdev, req); 1226 1227 /* Get NL global context from objmgr*/ 1228 osif_priv = wlan_pdev_get_ospriv(pdev); 1229 req_id = osif_priv->osif_scan->req_id; 1230 scan_id = ucfg_scan_get_scan_id(psoc); 1231 if (!scan_id) { 1232 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 1233 cfg80211_err("Invalid scan id"); 1234 qdf_mem_free(req); 1235 return -EINVAL; 1236 } 1237 /* fill the scan request structure */ 1238 req->vdev = vdev; 1239 req->scan_req.vdev_id = wlan_vdev_get_id(vdev); 1240 req->scan_req.scan_id = scan_id; 1241 req->scan_req.scan_req_id = req_id; 1242 1243 /* Update scan policy type flags according to cfg scan request */ 1244 wlan_cfg80211_update_scan_policy_type_flags(request, 1245 &req->scan_req); 1246 /* 1247 * Even though supplicant doesn't provide any SSIDs, n_ssids is 1248 * set to 1. Because of this, driver is assuming that this is not 1249 * wildcard scan and so is not aging out the scan results. 1250 */ 1251 if ((request->ssids) && (request->n_ssids == 1) && 1252 ('\0' == request->ssids->ssid[0])) { 1253 request->n_ssids = 0; 1254 } 1255 1256 if ((request->ssids) && (0 < request->n_ssids)) { 1257 int j; 1258 req->scan_req.num_ssids = request->n_ssids; 1259 1260 /* copy all the ssid's and their length */ 1261 for (j = 0; j < request->n_ssids; j++) { 1262 pssid = &req->scan_req.ssid[j]; 1263 /* get the ssid length */ 1264 pssid->length = request->ssids[j].ssid_len; 1265 qdf_mem_copy(pssid->ssid, 1266 &request->ssids[j].ssid[0], 1267 pssid->length); 1268 pssid->ssid[pssid->length] = '\0'; 1269 cfg80211_notice("SSID number %d: %s", j, 1270 pssid->ssid); 1271 } 1272 } 1273 if (request->ssids || 1274 (wlan_vdev_mlme_get_opmode(vdev) == QDF_P2P_GO_MODE)) 1275 req->scan_req.scan_f_passive = false; 1276 1277 if (params->half_rate) 1278 req->scan_req.scan_f_half_rate = true; 1279 else if (params->quarter_rate) 1280 req->scan_req.scan_f_quarter_rate = true; 1281 1282 if (params->strict_pscan) 1283 req->scan_req.scan_f_strict_passive_pch = true; 1284 1285 if ((request->n_ssids == 1) && request->ssids && 1286 !qdf_mem_cmp(&request->ssids[0], "DIRECT-", 7)) 1287 is_p2p_scan = true; 1288 1289 if (is_p2p_scan && request->no_cck) 1290 req->scan_req.p2p_scan_type = SCAN_P2P_SEARCH; 1291 1292 /* Set dwell time mode according to scan policy type flags */ 1293 if (req->scan_req.scan_policy_high_accuracy) 1294 req->scan_req.adaptive_dwell_time_mode = 1295 SCAN_DWELL_MODE_STATIC; 1296 if ((req->scan_req.scan_policy_low_power) || 1297 (req->scan_req.scan_policy_low_span)) 1298 req->scan_req.adaptive_dwell_time_mode = 1299 SCAN_DWELL_MODE_AGGRESSIVE; 1300 1301 /* 1302 * FW require at least 1 MAC to send probe request. 1303 * If MAC is all 0 set it to BC addr as this is the address on 1304 * which fw will send probe req. 1305 */ 1306 req->scan_req.num_bssid = 1; 1307 wlan_copy_bssid_scan_request(req, request); 1308 if (qdf_is_macaddr_zero(&req->scan_req.bssid_list[0])) 1309 qdf_set_macaddr_broadcast(&req->scan_req.bssid_list[0]); 1310 1311 if (request->n_channels) { 1312 char chl[(request->n_channels * 5) + 1]; 1313 int len = 0; 1314 #ifdef WLAN_POLICY_MGR_ENABLE 1315 bool ap_or_go_present = 1316 policy_mgr_mode_specific_connection_count( 1317 psoc, PM_SAP_MODE, NULL) || 1318 policy_mgr_mode_specific_connection_count( 1319 psoc, PM_P2P_GO_MODE, NULL); 1320 #endif 1321 1322 for (i = 0; i < request->n_channels; i++) { 1323 channel = request->channels[i]->hw_value; 1324 c_freq = wlan_reg_chan_to_freq(pdev, channel); 1325 if (wlan_reg_is_dsrc_chan(pdev, channel)) 1326 continue; 1327 #ifdef WLAN_POLICY_MGR_ENABLE 1328 if (ap_or_go_present) { 1329 bool ok; 1330 int ret; 1331 1332 ret = policy_mgr_is_chan_ok_for_dnbs(psoc, 1333 channel, 1334 &ok); 1335 1336 if (QDF_IS_STATUS_ERROR(ret)) { 1337 cfg80211_err("DNBS check failed"); 1338 qdf_mem_free(req); 1339 status = -EINVAL; 1340 goto end; 1341 } 1342 if (!ok) 1343 continue; 1344 } 1345 #endif 1346 len += snprintf(chl + len, 5, "%d ", channel); 1347 req->scan_req.chan_list.chan[num_chan].freq = c_freq; 1348 band = util_scan_scm_freq_to_band(c_freq); 1349 if (band == WLAN_BAND_2_4_GHZ) 1350 req->scan_req.chan_list.chan[num_chan].phymode = 1351 SCAN_PHY_MODE_11G; 1352 else 1353 req->scan_req.chan_list.chan[num_chan].phymode = 1354 SCAN_PHY_MODE_11A; 1355 num_chan++; 1356 } 1357 cfg80211_notice("Channel-List: %s", chl); 1358 cfg80211_notice("No. of Scan Channels: %d", num_chan); 1359 } 1360 if (!num_chan) { 1361 cfg80211_err("Received zero non-dsrc channels"); 1362 qdf_mem_free(req); 1363 status = -EINVAL; 1364 goto end; 1365 } 1366 req->scan_req.chan_list.num_chan = num_chan; 1367 1368 /* P2P increase the scan priority */ 1369 if (is_p2p_scan) 1370 req->scan_req.scan_priority = SCAN_PRIORITY_HIGH; 1371 if (request->ie_len) { 1372 req->scan_req.extraie.ptr = qdf_mem_malloc(request->ie_len); 1373 if (!req->scan_req.extraie.ptr) { 1374 cfg80211_err("Failed to allocate memory"); 1375 status = -ENOMEM; 1376 qdf_mem_free(req); 1377 goto end; 1378 } 1379 req->scan_req.extraie.len = request->ie_len; 1380 qdf_mem_copy(req->scan_req.extraie.ptr, request->ie, 1381 request->ie_len); 1382 } else if (params->default_ie.ptr && params->default_ie.len) { 1383 req->scan_req.extraie.ptr = 1384 qdf_mem_malloc(params->default_ie.len); 1385 if (!req->scan_req.extraie.ptr) { 1386 cfg80211_err("Failed to allocate memory"); 1387 status = -ENOMEM; 1388 qdf_mem_free(req); 1389 goto end; 1390 } 1391 req->scan_req.extraie.len = params->default_ie.len; 1392 qdf_mem_copy(req->scan_req.extraie.ptr, params->default_ie.ptr, 1393 params->default_ie.len); 1394 } 1395 1396 if (!is_p2p_scan) { 1397 if (req->scan_req.scan_random.randomize) 1398 wlan_scan_rand_attrs(vdev, request, req); 1399 if (ucfg_ie_whitelist_enabled(psoc, vdev) && 1400 ucfg_copy_ie_whitelist_attrs(psoc, 1401 &req->scan_req.ie_whitelist)) 1402 req->scan_req.scan_f_en_ie_whitelist_in_probe = true; 1403 } 1404 1405 if (request->flags & NL80211_SCAN_FLAG_FLUSH) 1406 ucfg_scan_flush_results(pdev, NULL); 1407 1408 /* Enqueue the scan request */ 1409 wlan_scan_request_enqueue(pdev, request, params->source, 1410 req->scan_req.scan_id); 1411 1412 qdf_runtime_pm_prevent_suspend( 1413 &osif_priv->osif_scan->runtime_pm_lock); 1414 1415 status = ucfg_scan_start(req); 1416 if (QDF_STATUS_SUCCESS != status) { 1417 cfg80211_err("ucfg_scan_start returned error %d", status); 1418 if (QDF_STATUS_E_RESOURCES == status) { 1419 cfg80211_err("HO is in progress.So defer the scan by informing busy"); 1420 status = -EBUSY; 1421 } else { 1422 status = -EIO; 1423 } 1424 wlan_scan_request_dequeue(pdev, scan_id, &request, 1425 ¶ms->source, &netdev); 1426 if (qdf_list_empty(&osif_priv->osif_scan->scan_req_q)) 1427 qdf_runtime_pm_allow_suspend( 1428 &osif_priv->osif_scan->runtime_pm_lock); 1429 } 1430 1431 end: 1432 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 1433 return status; 1434 } 1435 1436 /** 1437 * wlan_get_scanid() - API to get the scan id 1438 * from the scan cookie attribute. 1439 * @pdev: Pointer to pdev object 1440 * @scan_id: Pointer to scan id 1441 * @cookie : Scan cookie attribute 1442 * 1443 * API to get the scan id from the scan cookie attribute 1444 * sent from supplicant by matching scan request. 1445 * 1446 * Return: 0 for success, non zero for failure 1447 */ 1448 static int wlan_get_scanid(struct wlan_objmgr_pdev *pdev, 1449 uint32_t *scan_id, uint64_t cookie) 1450 { 1451 struct scan_req *scan_req; 1452 qdf_list_node_t *node = NULL; 1453 qdf_list_node_t *ptr_node = NULL; 1454 int ret = -EINVAL; 1455 struct pdev_osif_priv *osif_ctx; 1456 struct osif_scan_pdev *scan_priv; 1457 1458 /* Get NL global context from objmgr*/ 1459 osif_ctx = wlan_pdev_get_ospriv(pdev); 1460 if (!osif_ctx) { 1461 cfg80211_err("Failed to retrieve osif context"); 1462 return ret; 1463 } 1464 scan_priv = osif_ctx->osif_scan; 1465 qdf_mutex_acquire(&scan_priv->scan_req_q_lock); 1466 if (qdf_list_empty(&scan_priv->scan_req_q)) { 1467 qdf_mutex_release(&scan_priv->scan_req_q_lock); 1468 cfg80211_err("Failed to retrieve scan id"); 1469 return ret; 1470 } 1471 1472 if (QDF_STATUS_SUCCESS != 1473 qdf_list_peek_front(&scan_priv->scan_req_q, 1474 &ptr_node)) { 1475 qdf_mutex_release(&scan_priv->scan_req_q_lock); 1476 return ret; 1477 } 1478 1479 do { 1480 node = ptr_node; 1481 scan_req = qdf_container_of(node, struct scan_req, node); 1482 if (cookie == 1483 (uintptr_t)(scan_req->scan_request)) { 1484 *scan_id = scan_req->scan_id; 1485 ret = 0; 1486 break; 1487 } 1488 } while (QDF_STATUS_SUCCESS == 1489 qdf_list_peek_next(&scan_priv->scan_req_q, 1490 node, &ptr_node)); 1491 1492 qdf_mutex_release(&scan_priv->scan_req_q_lock); 1493 1494 return ret; 1495 } 1496 1497 QDF_STATUS wlan_abort_scan(struct wlan_objmgr_pdev *pdev, 1498 uint32_t pdev_id, uint32_t vdev_id, 1499 wlan_scan_id scan_id, bool sync) 1500 { 1501 struct scan_cancel_request *req; 1502 struct pdev_osif_priv *osif_ctx; 1503 struct osif_scan_pdev *scan_priv; 1504 QDF_STATUS status; 1505 struct wlan_objmgr_vdev *vdev; 1506 1507 req = qdf_mem_malloc(sizeof(*req)); 1508 if (!req) { 1509 cfg80211_err("Failed to allocate memory"); 1510 return QDF_STATUS_E_NOMEM; 1511 } 1512 1513 /* Get NL global context from objmgr*/ 1514 osif_ctx = wlan_pdev_get_ospriv(pdev); 1515 if (!osif_ctx) { 1516 cfg80211_err("Failed to retrieve osif context"); 1517 qdf_mem_free(req); 1518 return QDF_STATUS_E_FAILURE; 1519 } 1520 if (vdev_id == INVAL_VDEV_ID) 1521 vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, 1522 0, WLAN_OSIF_ID); 1523 else 1524 vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, 1525 vdev_id, WLAN_OSIF_ID); 1526 1527 if (!vdev) { 1528 cfg80211_err("Failed get vdev"); 1529 qdf_mem_free(req); 1530 return QDF_STATUS_E_INVAL; 1531 } 1532 scan_priv = osif_ctx->osif_scan; 1533 req->cancel_req.requester = scan_priv->req_id; 1534 req->vdev = vdev; 1535 req->cancel_req.scan_id = scan_id; 1536 req->cancel_req.pdev_id = pdev_id; 1537 req->cancel_req.vdev_id = vdev_id; 1538 if (scan_id != INVAL_SCAN_ID) 1539 req->cancel_req.req_type = WLAN_SCAN_CANCEL_SINGLE; 1540 else if (vdev_id == INVAL_VDEV_ID) 1541 req->cancel_req.req_type = WLAN_SCAN_CANCEL_PDEV_ALL; 1542 else 1543 req->cancel_req.req_type = WLAN_SCAN_CANCEL_VDEV_ALL; 1544 1545 if (sync) 1546 status = ucfg_scan_cancel_sync(req); 1547 else 1548 status = ucfg_scan_cancel(req); 1549 if (QDF_IS_STATUS_ERROR(status)) 1550 cfg80211_err("Cancel scan request failed"); 1551 1552 wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_ID); 1553 1554 return status; 1555 } 1556 1557 int wlan_cfg80211_abort_scan(struct wlan_objmgr_pdev *pdev) 1558 { 1559 uint8_t pdev_id; 1560 1561 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 1562 1563 if (ucfg_scan_get_pdev_status(pdev) != 1564 SCAN_NOT_IN_PROGRESS) 1565 wlan_abort_scan(pdev, pdev_id, 1566 INVAL_VDEV_ID, INVAL_SCAN_ID, true); 1567 1568 return 0; 1569 } 1570 1571 int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev, 1572 const void *data, int data_len) 1573 { 1574 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SCAN_MAX + 1]; 1575 int ret = -EINVAL; 1576 wlan_scan_id scan_id; 1577 uint64_t cookie; 1578 uint8_t pdev_id; 1579 1580 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 1581 if (wlan_cfg80211_nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SCAN_MAX, data, 1582 data_len, scan_policy)) { 1583 cfg80211_err("Invalid ATTR"); 1584 return ret; 1585 } 1586 1587 if (tb[QCA_WLAN_VENDOR_ATTR_SCAN_COOKIE]) { 1588 cookie = nla_get_u64( 1589 tb[QCA_WLAN_VENDOR_ATTR_SCAN_COOKIE]); 1590 ret = wlan_get_scanid(pdev, &scan_id, cookie); 1591 if (ret != 0) 1592 return ret; 1593 if (ucfg_scan_get_pdev_status(pdev) != 1594 SCAN_NOT_IN_PROGRESS) 1595 wlan_abort_scan(pdev, INVAL_PDEV_ID, 1596 INVAL_VDEV_ID, scan_id, true); 1597 } 1598 return 0; 1599 } 1600 1601 static inline struct ieee80211_channel * 1602 wlan_get_ieee80211_channel(struct wiphy *wiphy, 1603 struct wlan_objmgr_pdev *pdev, 1604 int chan_no) 1605 { 1606 unsigned int freq; 1607 struct ieee80211_channel *chan; 1608 1609 freq = wlan_reg_chan_to_freq(pdev, chan_no); 1610 chan = ieee80211_get_channel(wiphy, freq); 1611 if (!chan) 1612 cfg80211_err("chan is NULL, chan_no: %d freq: %d", 1613 chan_no, freq); 1614 1615 return chan; 1616 } 1617 1618 #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS 1619 static inline int wlan_get_frame_len(struct scan_cache_entry *scan_params) 1620 { 1621 return util_scan_entry_frame_len(scan_params) + sizeof(qcom_ie_age); 1622 } 1623 1624 static inline void wlan_add_age_ie(uint8_t *mgmt_frame, 1625 struct scan_cache_entry *scan_params) 1626 { 1627 qcom_ie_age *qie_age = NULL; 1628 1629 /* GPS Requirement: need age ie per entry. Using vendor specific. */ 1630 /* Assuming this is the last IE, copy at the end */ 1631 qie_age = (qcom_ie_age *) (mgmt_frame + 1632 util_scan_entry_frame_len(scan_params)); 1633 qie_age->element_id = QCOM_VENDOR_IE_ID; 1634 qie_age->len = QCOM_VENDOR_IE_AGE_LEN; 1635 qie_age->oui_1 = QCOM_OUI1; 1636 qie_age->oui_2 = QCOM_OUI2; 1637 qie_age->oui_3 = QCOM_OUI3; 1638 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; 1639 /* 1640 * Lowi expects the timestamp of bss in units of 1/10 ms. In driver 1641 * all bss related timestamp is in units of ms. Due to this when scan 1642 * results are sent to lowi the scan age is high.To address this, 1643 * send age in units of 1/10 ms. 1644 */ 1645 qie_age->age = 1646 (uint32_t)(qdf_mc_timer_get_system_time() - 1647 scan_params->scan_entry_time)/10; 1648 qie_age->tsf_delta = scan_params->tsf_delta; 1649 memcpy(&qie_age->beacon_tsf, scan_params->tsf_info.data, 1650 sizeof(qie_age->beacon_tsf)); 1651 memcpy(&qie_age->seq_ctrl, &scan_params->seq_num, 1652 sizeof(qie_age->seq_ctrl)); 1653 } 1654 #else 1655 static inline int wlan_get_frame_len(struct scan_cache_entry *scan_params) 1656 { 1657 return util_scan_entry_frame_len(scan_params); 1658 } 1659 1660 static inline void wlan_add_age_ie(uint8_t *mgmt_frame, 1661 struct scan_cache_entry *scan_params) 1662 { 1663 } 1664 #endif /* WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS */ 1665 1666 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) || \ 1667 defined(CFG80211_INFORM_BSS_FRAME_DATA) 1668 /** 1669 * wlan_fill_per_chain_rssi() - fill per chain RSSI in inform bss 1670 * @data: bss data 1671 * @per_chain_snr: per chain RSSI 1672 * 1673 * Return: void 1674 */ 1675 #if defined(CFG80211_SCAN_PER_CHAIN_RSSI_SUPPORT) || \ 1676 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)) 1677 static void wlan_fill_per_chain_rssi(struct cfg80211_inform_bss *data, 1678 struct wlan_cfg80211_inform_bss *bss) 1679 { 1680 1681 uint32_t i; 1682 1683 if (!bss || !data) { 1684 cfg80211_err("Received bss is NULL"); 1685 return; 1686 } 1687 for (i = 0; i < WLAN_MGMT_TXRX_HOST_MAX_ANTENNA; i++) { 1688 if (!bss->per_chain_snr[i] || 1689 (bss->per_chain_snr[i] == WLAN_INVALID_PER_CHAIN_RSSI)) 1690 continue; 1691 /* Add noise margin to SNR to convert it to RSSI */ 1692 data->chain_signal[i] = bss->per_chain_snr[i] + 1693 WLAN_NOISE_FLOOR_DBM_DEFAULT; 1694 data->chains |= BIT(i); 1695 } 1696 } 1697 #else 1698 static inline void 1699 wlan_fill_per_chain_rssi(struct cfg80211_inform_bss *data, 1700 struct wlan_cfg80211_inform_bss *bss) 1701 { 1702 } 1703 #endif 1704 1705 struct cfg80211_bss * 1706 wlan_cfg80211_inform_bss_frame_data(struct wiphy *wiphy, 1707 struct wlan_cfg80211_inform_bss *bss) 1708 { 1709 struct cfg80211_inform_bss data = {0}; 1710 1711 if (!bss) { 1712 cfg80211_err("bss is null"); 1713 return NULL; 1714 } 1715 wlan_fill_per_chain_rssi(&data, bss); 1716 1717 data.chan = bss->chan; 1718 data.boottime_ns = bss->boottime_ns; 1719 data.signal = bss->rssi; 1720 return cfg80211_inform_bss_frame_data(wiphy, &data, bss->mgmt, 1721 bss->frame_len, GFP_ATOMIC); 1722 } 1723 #else 1724 struct cfg80211_bss * 1725 wlan_cfg80211_inform_bss_frame_data(struct wiphy *wiphy, 1726 struct wlan_cfg80211_inform_bss *bss) 1727 1728 { 1729 return cfg80211_inform_bss_frame(wiphy, bss->chan, bss->mgmt, 1730 bss->frame_len, 1731 bss->rssi, GFP_ATOMIC); 1732 } 1733 #endif 1734 1735 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) 1736 static inline void wlan_cfg80211_put_bss(struct wiphy *wiphy, 1737 struct cfg80211_bss *bss) 1738 { 1739 cfg80211_put_bss(wiphy, bss); 1740 } 1741 #else 1742 static inline void wlan_cfg80211_put_bss(struct wiphy *wiphy, 1743 struct cfg80211_bss *bss) 1744 { 1745 cfg80211_put_bss(bss); 1746 } 1747 #endif 1748 1749 void wlan_cfg80211_inform_bss_frame(struct wlan_objmgr_pdev *pdev, 1750 struct scan_cache_entry *scan_params) 1751 { 1752 struct pdev_osif_priv *pdev_ospriv = wlan_pdev_get_ospriv(pdev); 1753 struct wiphy *wiphy; 1754 struct cfg80211_bss *bss = NULL; 1755 struct wlan_cfg80211_inform_bss bss_data = {0}; 1756 1757 if (!pdev_ospriv) { 1758 cfg80211_err("os_priv is NULL"); 1759 return; 1760 } 1761 1762 wiphy = pdev_ospriv->wiphy; 1763 1764 bss_data.frame_len = wlan_get_frame_len(scan_params); 1765 bss_data.mgmt = qdf_mem_malloc_atomic(bss_data.frame_len); 1766 if (!bss_data.mgmt) { 1767 cfg80211_err("mem alloc failed"); 1768 return; 1769 } 1770 qdf_mem_copy(bss_data.mgmt, 1771 util_scan_entry_frame_ptr(scan_params), 1772 util_scan_entry_frame_len(scan_params)); 1773 /* 1774 * Android does not want the timestamp from the frame. 1775 * Instead it wants a monotonic increasing value 1776 */ 1777 bss_data.mgmt->u.probe_resp.timestamp = qdf_get_monotonic_boottime(); 1778 wlan_add_age_ie((uint8_t *)bss_data.mgmt, scan_params); 1779 /* 1780 * Based on .ini configuration, raw rssi can be reported for bss. 1781 * Raw rssi is typically used for estimating power. 1782 */ 1783 bss_data.rssi = scan_params->rssi_raw; 1784 1785 bss_data.chan = wlan_get_ieee80211_channel(wiphy, pdev, 1786 scan_params->channel.chan_idx); 1787 if (!bss_data.chan) { 1788 qdf_mem_free(bss_data.mgmt); 1789 return; 1790 } 1791 1792 /* 1793 * Supplicant takes the signal strength in terms of 1794 * mBm (1 dBm = 100 mBm). 1795 */ 1796 bss_data.rssi = QDF_MIN(bss_data.rssi, 0) * 100; 1797 1798 bss_data.boottime_ns = scan_params->boottime_ns; 1799 1800 qdf_mem_copy(bss_data.per_chain_snr, scan_params->per_chain_snr, 1801 WLAN_MGMT_TXRX_HOST_MAX_ANTENNA); 1802 1803 cfg80211_debug("BSSID: %pM Channel:%d RSSI:%d", bss_data.mgmt->bssid, 1804 bss_data.chan->center_freq, (int)(bss_data.rssi / 100)); 1805 1806 bss = wlan_cfg80211_inform_bss_frame_data(wiphy, &bss_data); 1807 if (!bss) 1808 cfg80211_err("failed to inform bss"); 1809 else 1810 wlan_cfg80211_put_bss(wiphy, bss); 1811 1812 qdf_mem_free(bss_data.mgmt); 1813 } 1814