aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_cmd.c
diff options
context:
space:
mode:
authorLuciano Coelho <luciano.coelho@nokia.com>2010-07-08 10:50:06 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-07-08 16:41:58 -0400
commit34dd2aaac4a4b908c093980a9894fd878aeb6deb (patch)
tree62bd3f0ee0d56888d0b722648271c3463a6bab19 /drivers/net/wireless/wl12xx/wl1271_cmd.c
parentf532be6d48a12cd1b27c4efa38d22e0cbfa512d1 (diff)
wl1271: moved scan operations to a separate file
The scanning code is going to get a bit more complex, with proper support for active/passive scans together with 2.4GHz and 5GHz. In the future, also a new type of scan (periodic scan) will be added. When all this is implemented, the code is going to be much more complex, so we'd better separate it into a separate file. This patch doesn't have any impact on functionality. Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com> Reviewed-by: Saravanan Dhanabal <ext-saravanan.dhanabal@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_cmd.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.c136
1 files changed, 0 insertions, 136 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c
index 23c75988f082..ce503ddd5a41 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c
@@ -463,142 +463,6 @@ out:
463 return ret; 463 return ret;
464} 464}
465 465
466int wl1271_cmd_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
467 struct cfg80211_scan_request *req, u8 active_scan,
468 u8 high_prio, u8 band, u8 probe_requests)
469{
470
471 struct wl1271_cmd_trigger_scan_to *trigger = NULL;
472 struct wl1271_cmd_scan *params = NULL;
473 struct ieee80211_channel *channels;
474 u32 rate;
475 int i, j, n_ch, ret;
476 u16 scan_options = 0;
477 u8 ieee_band;
478
479 if (band == WL1271_SCAN_BAND_2_4_GHZ) {
480 ieee_band = IEEE80211_BAND_2GHZ;
481 rate = wl->conf.tx.basic_rate;
482 } else if (band == WL1271_SCAN_BAND_DUAL && wl1271_11a_enabled()) {
483 ieee_band = IEEE80211_BAND_2GHZ;
484 rate = wl->conf.tx.basic_rate;
485 } else if (band == WL1271_SCAN_BAND_5_GHZ && wl1271_11a_enabled()) {
486 ieee_band = IEEE80211_BAND_5GHZ;
487 rate = wl->conf.tx.basic_rate_5;
488 } else
489 return -EINVAL;
490
491 if (wl->hw->wiphy->bands[ieee_band]->channels == NULL)
492 return -EINVAL;
493
494 channels = wl->hw->wiphy->bands[ieee_band]->channels;
495 n_ch = wl->hw->wiphy->bands[ieee_band]->n_channels;
496
497 if (test_bit(WL1271_FLAG_SCANNING, &wl->flags))
498 return -EINVAL;
499
500 params = kzalloc(sizeof(*params), GFP_KERNEL);
501 if (!params)
502 return -ENOMEM;
503
504 params->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD);
505 params->params.rx_filter_options =
506 cpu_to_le32(CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN);
507
508 if (!active_scan)
509 scan_options |= WL1271_SCAN_OPT_PASSIVE;
510 if (high_prio)
511 scan_options |= WL1271_SCAN_OPT_PRIORITY_HIGH;
512 params->params.scan_options = cpu_to_le16(scan_options);
513
514 params->params.num_probe_requests = probe_requests;
515 params->params.tx_rate = cpu_to_le32(rate);
516 params->params.tid_trigger = 0;
517 params->params.scan_tag = WL1271_SCAN_DEFAULT_TAG;
518
519 if (band == WL1271_SCAN_BAND_DUAL)
520 params->params.band = WL1271_SCAN_BAND_2_4_GHZ;
521 else
522 params->params.band = band;
523
524 for (i = 0, j = 0; i < n_ch && i < WL1271_SCAN_MAX_CHANNELS; i++) {
525 if (!(channels[i].flags & IEEE80211_CHAN_DISABLED)) {
526 params->channels[j].min_duration =
527 cpu_to_le32(WL1271_SCAN_CHAN_MIN_DURATION);
528 params->channels[j].max_duration =
529 cpu_to_le32(WL1271_SCAN_CHAN_MAX_DURATION);
530 memset(&params->channels[j].bssid_lsb, 0xff, 4);
531 memset(&params->channels[j].bssid_msb, 0xff, 2);
532 params->channels[j].early_termination = 0;
533 params->channels[j].tx_power_att =
534 WL1271_SCAN_CURRENT_TX_PWR;
535 params->channels[j].channel = channels[i].hw_value;
536 j++;
537 }
538 }
539
540 params->params.num_channels = j;
541
542 if (ssid_len && ssid) {
543 params->params.ssid_len = ssid_len;
544 memcpy(params->params.ssid, ssid, ssid_len);
545 }
546
547 ret = wl1271_cmd_build_probe_req(wl, ssid, ssid_len,
548 req->ie, req->ie_len, ieee_band);
549 if (ret < 0) {
550 wl1271_error("PROBE request template failed");
551 goto out;
552 }
553
554 trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
555 if (!trigger) {
556 ret = -ENOMEM;
557 goto out;
558 }
559
560 /* disable the timeout */
561 trigger->timeout = 0;
562
563 ret = wl1271_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
564 sizeof(*trigger), 0);
565 if (ret < 0) {
566 wl1271_error("trigger scan to failed for hw scan");
567 goto out;
568 }
569
570 wl1271_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params));
571
572 set_bit(WL1271_FLAG_SCANNING, &wl->flags);
573 if (wl1271_11a_enabled()) {
574 wl->scan.state = band;
575 if (band == WL1271_SCAN_BAND_DUAL) {
576 wl->scan.active = active_scan;
577 wl->scan.high_prio = high_prio;
578 wl->scan.probe_requests = probe_requests;
579 if (ssid_len && ssid) {
580 wl->scan.ssid_len = ssid_len;
581 memcpy(wl->scan.ssid, ssid, ssid_len);
582 } else
583 wl->scan.ssid_len = 0;
584 wl->scan.req = req;
585 } else
586 wl->scan.req = NULL;
587 }
588
589 ret = wl1271_cmd_send(wl, CMD_SCAN, params, sizeof(*params), 0);
590 if (ret < 0) {
591 wl1271_error("SCAN failed");
592 clear_bit(WL1271_FLAG_SCANNING, &wl->flags);
593 goto out;
594 }
595
596out:
597 kfree(params);
598 kfree(trigger);
599 return ret;
600}
601
602int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, 466int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
603 void *buf, size_t buf_len, int index, u32 rates) 467 void *buf, size_t buf_len, int index, u32 rates)
604{ 468{