325
wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
326
struct cfg80211_sched_scan_request *req,
327
struct conn_scan_ch_params *channels,
328
u32 band, bool radar, bool passive,
331
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
334
bool force_passive = !req->n_ssids;
336
for (i = 0, j = start;
337
i < req->n_channels && j < MAX_CHANNELS_ALL_BANDS;
339
flags = req->channels[i]->flags;
342
flags |= IEEE80211_CHAN_PASSIVE_SCAN;
344
if ((req->channels[i]->band == band) &&
345
!(flags & IEEE80211_CHAN_DISABLED) &&
346
(!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
347
/* if radar is set, we ignore the passive flag */
349
!!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
350
wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
351
req->channels[i]->band,
352
req->channels[i]->center_freq);
353
wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
354
req->channels[i]->hw_value,
355
req->channels[i]->flags);
356
wl1271_debug(DEBUG_SCAN, "max_power %d",
357
req->channels[i]->max_power);
359
if (flags & IEEE80211_CHAN_RADAR) {
360
channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS;
361
channels[j].passive_duration =
362
cpu_to_le16(c->dwell_time_dfs);
364
else if (flags & IEEE80211_CHAN_PASSIVE_SCAN) {
365
channels[j].passive_duration =
366
cpu_to_le16(c->dwell_time_passive);
368
channels[j].min_duration =
369
cpu_to_le16(c->min_dwell_time_active);
370
channels[j].max_duration =
371
cpu_to_le16(c->max_dwell_time_active);
373
channels[j].tx_power_att = req->channels[i]->max_power;
374
channels[j].channel = req->channels[i]->hw_value;
384
wl1271_scan_sched_scan_channels(struct wl1271 *wl,
385
struct cfg80211_sched_scan_request *req,
386
struct wl1271_cmd_sched_scan_config *cfg)
391
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
394
idx += cfg->passive[0];
397
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
401
* 5GHz channels always start at position 14, not immediately
402
* after the last 2.4GHz channel
407
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
410
idx += cfg->passive[1];
413
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
419
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
422
idx += cfg->active[1];
424
wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d",
425
cfg->active[0], cfg->passive[0]);
426
wl1271_debug(DEBUG_SCAN, " 5GHz: active %d passive %d",
427
cfg->active[1], cfg->passive[1]);
428
wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs);
433
int wl1271_scan_sched_scan_config(struct wl1271 *wl,
434
struct cfg80211_sched_scan_request *req,
435
struct ieee80211_sched_scan_ies *ies)
437
struct wl1271_cmd_sched_scan_config *cfg = NULL;
438
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
439
int i, total_channels, ret;
440
bool force_passive = !req->n_ssids;
442
wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config");
444
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
448
cfg->rssi_threshold = c->rssi_threshold;
449
cfg->snr_threshold = c->snr_threshold;
450
cfg->n_probe_reqs = c->num_probe_reqs;
451
/* cycles set to 0 it means infinite (until manually stopped) */
453
/* report APs when at least 1 is found */
454
cfg->report_after = 1;
455
/* don't stop scanning automatically when something is found */
457
cfg->tag = WL1271_SCAN_DEFAULT_TAG;
458
/* don't filter on BSS type */
459
cfg->bss_type = SCAN_BSS_TYPE_ANY;
460
/* currently NL80211 supports only a single interval */
461
for (i = 0; i < SCAN_MAX_CYCLE_INTERVALS; i++)
462
cfg->intervals[i] = cpu_to_le32(req->interval);
464
if (!force_passive && req->ssids[0].ssid_len && req->ssids[0].ssid) {
465
cfg->filter_type = SCAN_SSID_FILTER_SPECIFIC;
466
cfg->ssid_len = req->ssids[0].ssid_len;
467
memcpy(cfg->ssid, req->ssids[0].ssid,
468
req->ssids[0].ssid_len);
470
cfg->filter_type = SCAN_SSID_FILTER_ANY;
474
total_channels = wl1271_scan_sched_scan_channels(wl, req, cfg);
475
if (total_channels == 0) {
476
wl1271_error("scan channel list is empty");
481
if (!force_passive && cfg->active[0]) {
482
ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
483
req->ssids[0].ssid_len,
484
ies->ie[IEEE80211_BAND_2GHZ],
485
ies->len[IEEE80211_BAND_2GHZ],
486
IEEE80211_BAND_2GHZ);
488
wl1271_error("2.4GHz PROBE request template failed");
493
if (!force_passive && cfg->active[1]) {
494
ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
495
req->ssids[0].ssid_len,
496
ies->ie[IEEE80211_BAND_5GHZ],
497
ies->len[IEEE80211_BAND_5GHZ],
498
IEEE80211_BAND_5GHZ);
500
wl1271_error("5GHz PROBE request template failed");
505
wl1271_dump(DEBUG_SCAN, "SCAN_CFG: ", cfg, sizeof(*cfg));
507
ret = wl1271_cmd_send(wl, CMD_CONNECTION_SCAN_CFG, cfg,
510
wl1271_error("SCAN configuration failed");
518
int wl1271_scan_sched_scan_start(struct wl1271 *wl)
520
struct wl1271_cmd_sched_scan_start *start;
523
wl1271_debug(DEBUG_CMD, "cmd periodic scan start");
525
if (wl->bss_type != BSS_TYPE_STA_BSS)
528
if (!test_bit(WL1271_FLAG_IDLE, &wl->flags))
531
start = kzalloc(sizeof(*start), GFP_KERNEL);
535
start->tag = WL1271_SCAN_DEFAULT_TAG;
537
ret = wl1271_cmd_send(wl, CMD_START_PERIODIC_SCAN, start,
540
wl1271_error("failed to send scan start command");
549
void wl1271_scan_sched_scan_results(struct wl1271 *wl)
551
wl1271_debug(DEBUG_SCAN, "got periodic scan results");
553
ieee80211_sched_scan_results(wl->hw);
556
void wl1271_scan_sched_scan_stop(struct wl1271 *wl)
558
struct wl1271_cmd_sched_scan_stop *stop;
561
wl1271_debug(DEBUG_CMD, "cmd periodic scan stop");
563
/* FIXME: what to do if alloc'ing to stop fails? */
564
stop = kzalloc(sizeof(*stop), GFP_KERNEL);
566
wl1271_error("failed to alloc memory to send sched scan stop");
570
stop->tag = WL1271_SCAN_DEFAULT_TAG;
572
ret = wl1271_cmd_send(wl, CMD_STOP_PERIODIC_SCAN, stop,
575
wl1271_error("failed to send sched scan stop command");
578
wl->sched_scanning = false;