Lines Matching +full:scan +full:- +full:interval
1 // SPDX-License-Identifier: ISC
38 #define ifp_to_pno(_ifp) ((_ifp)->drvr->config->pno)
43 if (WARN(pi->n_reqs == BRCMF_PNO_MAX_BUCKETS, in brcmf_pno_store_request()
45 return -ENOSPC; in brcmf_pno_store_request()
47 brcmf_dbg(SCAN, "reqid=%llu\n", req->reqid); in brcmf_pno_store_request()
48 mutex_lock(&pi->req_lock); in brcmf_pno_store_request()
49 pi->reqs[pi->n_reqs++] = req; in brcmf_pno_store_request()
50 mutex_unlock(&pi->req_lock); in brcmf_pno_store_request()
58 mutex_lock(&pi->req_lock); in brcmf_pno_remove_request()
61 if (pi->n_reqs == 0) in brcmf_pno_remove_request()
65 for (i = 0; i < pi->n_reqs; i++) { in brcmf_pno_remove_request()
66 if (pi->reqs[i]->reqid == reqid) in brcmf_pno_remove_request()
70 if (WARN(i == pi->n_reqs, "reqid not found\n")) { in brcmf_pno_remove_request()
71 err = -ENOENT; in brcmf_pno_remove_request()
75 brcmf_dbg(SCAN, "reqid=%llu\n", reqid); in brcmf_pno_remove_request()
76 pi->n_reqs--; in brcmf_pno_remove_request()
79 if (!pi->n_reqs || i == pi->n_reqs) in brcmf_pno_remove_request()
83 while (i <= pi->n_reqs - 1) { in brcmf_pno_remove_request()
84 pi->reqs[i] = pi->reqs[i + 1]; in brcmf_pno_remove_request()
89 mutex_unlock(&pi->req_lock); in brcmf_pno_remove_request()
96 cfg->reporttype = 0; in brcmf_pno_channel_config()
97 cfg->flags = 0; in brcmf_pno_channel_config()
105 struct brcmf_pub *drvr = ifp->drvr; in brcmf_pno_config()
120 /* set up pno scan fr */ in brcmf_pno_config()
157 struct brcmf_pub *drvr = ifp->drvr; in brcmf_pno_set_random()
163 for (ri = 0; ri < pi->n_reqs; ri++) in brcmf_pno_set_random()
164 if (pi->reqs[ri]->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { in brcmf_pno_set_random()
165 mac_addr = pi->reqs[ri]->mac_addr; in brcmf_pno_set_random()
166 mac_mask = pi->reqs[ri]->mac_addr_mask; in brcmf_pno_set_random()
187 brcmf_dbg(SCAN, "enabling random mac: reqid=%llu mac=%pM\n", in brcmf_pno_set_random()
188 pi->reqs[ri]->reqid, pfn_mac.mac); in brcmf_pno_set_random()
200 struct brcmf_pub *drvr = ifp->drvr; in brcmf_pno_add_ssid()
211 pfn.ssid.SSID_len = cpu_to_le32(ssid->ssid_len); in brcmf_pno_add_ssid()
212 memcpy(pfn.ssid.SSID, ssid->ssid, ssid->ssid_len); in brcmf_pno_add_ssid()
214 brcmf_dbg(SCAN, "adding ssid=%.32s (active=%d)\n", ssid->ssid, active); in brcmf_pno_add_ssid()
223 struct brcmf_pub *drvr = ifp->drvr; in brcmf_pno_add_bssid()
230 brcmf_dbg(SCAN, "adding bssid=%pM\n", bssid); in brcmf_pno_add_bssid()
243 if (!ssid || !req->ssids || !req->n_ssids) in brcmf_is_ssid_active()
246 for (i = 0; i < req->n_ssids; i++) { in brcmf_is_ssid_active()
247 if (ssid->ssid_len == req->ssids[i].ssid_len) { in brcmf_is_ssid_active()
248 if (!strncmp(ssid->ssid, req->ssids[i].ssid, in brcmf_is_ssid_active()
249 ssid->ssid_len)) in brcmf_is_ssid_active()
258 struct brcmf_pub *drvr = ifp->drvr; in brcmf_pno_clean()
276 u32 n_chan = le32_to_cpu(pno_cfg->channel_num); in brcmf_pno_get_bucket_channels()
280 for (i = 0; i < r->n_channels; i++) { in brcmf_pno_get_bucket_channels()
282 err = -ENOSPC; in brcmf_pno_get_bucket_channels()
285 chan = r->channels[i]->hw_value; in brcmf_pno_get_bucket_channels()
286 brcmf_dbg(SCAN, "[%d] Chan : %u\n", n_chan, chan); in brcmf_pno_get_bucket_channels()
287 pno_cfg->channel_list[n_chan++] = cpu_to_le16(chan); in brcmf_pno_get_bucket_channels()
292 pno_cfg->channel_num = cpu_to_le32(n_chan); in brcmf_pno_get_bucket_channels()
305 brcmf_dbg(SCAN, "n_reqs=%d\n", pi->n_reqs); in brcmf_pno_prep_fwconfig()
306 if (WARN_ON(!pi->n_reqs)) in brcmf_pno_prep_fwconfig()
307 return -ENODATA; in brcmf_pno_prep_fwconfig()
310 * actual scan period is determined using gcd() for each in brcmf_pno_prep_fwconfig()
311 * scheduled scan period. in brcmf_pno_prep_fwconfig()
313 *scan_freq = pi->reqs[0]->scan_plans[0].interval; in brcmf_pno_prep_fwconfig()
314 for (i = 1; i < pi->n_reqs; i++) { in brcmf_pno_prep_fwconfig()
315 sr = pi->reqs[i]; in brcmf_pno_prep_fwconfig()
316 *scan_freq = gcd(sr->scan_plans[0].interval, *scan_freq); in brcmf_pno_prep_fwconfig()
319 brcmf_dbg(SCAN, "scan period too small, using minimum\n"); in brcmf_pno_prep_fwconfig()
324 fw_buckets = kcalloc(pi->n_reqs, sizeof(*fw_buckets), GFP_KERNEL); in brcmf_pno_prep_fwconfig()
326 return -ENOMEM; in brcmf_pno_prep_fwconfig()
329 for (i = 0; i < pi->n_reqs; i++) { in brcmf_pno_prep_fwconfig()
330 sr = pi->reqs[i]; in brcmf_pno_prep_fwconfig()
336 fw_buckets[i].bucket_end_index = chidx - 1; in brcmf_pno_prep_fwconfig()
338 sr->scan_plans[0].interval / *scan_freq; in brcmf_pno_prep_fwconfig()
339 /* assure period is non-zero */ in brcmf_pno_prep_fwconfig()
347 for (i = 0; i < pi->n_reqs; i++) { in brcmf_pno_prep_fwconfig()
356 return pi->n_reqs; in brcmf_pno_prep_fwconfig()
371 for (i = 0; i < pi->n_reqs; i++) { in brcmf_pno_config_networks()
372 r = pi->reqs[i]; in brcmf_pno_config_networks()
374 for (j = 0; j < r->n_match_sets; j++) { in brcmf_pno_config_networks()
375 ms = &r->match_sets[j]; in brcmf_pno_config_networks()
376 if (ms->ssid.ssid_len) { in brcmf_pno_config_networks()
377 active = brcmf_is_ssid_active(&ms->ssid, r); in brcmf_pno_config_networks()
378 err = brcmf_pno_add_ssid(ifp, &ms->ssid, in brcmf_pno_config_networks()
381 if (!err && is_valid_ether_addr(ms->bssid)) in brcmf_pno_config_networks()
382 err = brcmf_pno_add_bssid(ifp, ms->bssid); in brcmf_pno_config_networks()
393 struct brcmf_pub *drvr = ifp->drvr; in brcmf_pno_config_sched_scans()
411 err = -ENOMEM; in brcmf_pno_config_sched_scans()
431 gscan_cfg->version = cpu_to_le16(BRCMF_GSCAN_CFG_VERSION); in brcmf_pno_config_sched_scans()
432 gscan_cfg->retry_threshold = GSCAN_RETRY_THRESHOLD; in brcmf_pno_config_sched_scans()
433 gscan_cfg->buffer_threshold = GSCAN_BATCH_NO_THR_SET; in brcmf_pno_config_sched_scans()
434 gscan_cfg->flags = BRCMF_GSCAN_CFG_ALL_BUCKETS_IN_1ST_SCAN; in brcmf_pno_config_sched_scans()
436 gscan_cfg->count_of_channel_buckets = n_buckets; in brcmf_pno_config_sched_scans()
437 memcpy(gscan_cfg->bucket, buckets, in brcmf_pno_config_sched_scans()
473 brcmf_dbg(TRACE, "reqid=%llu\n", req->reqid); in brcmf_pno_start_sched_scan()
482 brcmf_pno_remove_request(pi, req->reqid); in brcmf_pno_start_sched_scan()
483 if (pi->n_reqs) in brcmf_pno_start_sched_scan()
500 if (!pi->n_reqs) in brcmf_pno_stop_sched_scan()
509 if (pi->n_reqs) in brcmf_pno_stop_sched_scan()
522 return -ENOMEM; in brcmf_pno_attach()
524 cfg->pno = pi; in brcmf_pno_attach()
525 mutex_init(&pi->req_lock); in brcmf_pno_attach()
534 pi = cfg->pno; in brcmf_pno_detach()
535 cfg->pno = NULL; in brcmf_pno_detach()
537 WARN_ON(pi->n_reqs); in brcmf_pno_detach()
538 mutex_destroy(&pi->req_lock); in brcmf_pno_detach()
544 /* scheduled scan settings */ in brcmf_pno_wiphy_params()
545 wiphy->max_sched_scan_reqs = gscan ? BRCMF_PNO_MAX_BUCKETS : 1; in brcmf_pno_wiphy_params()
546 wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT; in brcmf_pno_wiphy_params()
547 wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT; in brcmf_pno_wiphy_params()
548 wiphy->max_sched_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX; in brcmf_pno_wiphy_params()
549 wiphy->max_sched_scan_plan_interval = BRCMF_PNO_SCHED_SCAN_MAX_PERIOD; in brcmf_pno_wiphy_params()
556 mutex_lock(&pi->req_lock); in brcmf_pno_find_reqid_by_bucket()
558 if (bucket < pi->n_reqs) in brcmf_pno_find_reqid_by_bucket()
559 reqid = pi->reqs[bucket]->reqid; in brcmf_pno_find_reqid_by_bucket()
561 mutex_unlock(&pi->req_lock); in brcmf_pno_find_reqid_by_bucket()
573 mutex_lock(&pi->req_lock); in brcmf_pno_get_bucket_map()
574 for (i = 0; i < pi->n_reqs; i++) { in brcmf_pno_get_bucket_map()
575 req = pi->reqs[i]; in brcmf_pno_get_bucket_map()
577 if (!req->n_match_sets) in brcmf_pno_get_bucket_map()
579 for (j = 0; j < req->n_match_sets; j++) { in brcmf_pno_get_bucket_map()
580 ms = &req->match_sets[j]; in brcmf_pno_get_bucket_map()
581 if (ms->ssid.ssid_len == ni->SSID_len && in brcmf_pno_get_bucket_map()
582 !memcmp(ms->ssid.ssid, ni->SSID, ni->SSID_len)) { in brcmf_pno_get_bucket_map()
586 if (is_valid_ether_addr(ms->bssid) && in brcmf_pno_get_bucket_map()
587 !memcmp(ms->bssid, ni->bssid, ETH_ALEN)) { in brcmf_pno_get_bucket_map()
593 mutex_unlock(&pi->req_lock); in brcmf_pno_get_bucket_map()