aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1251_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1251_cmd.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_cmd.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1251_cmd.c b/drivers/net/wireless/wl12xx/wl1251_cmd.c
index 770f260726bd..fcbfbd7585f8 100644
--- a/drivers/net/wireless/wl12xx/wl1251_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1251_cmd.c
@@ -410,3 +410,85 @@ out:
410 kfree(cmd); 410 kfree(cmd);
411 return ret; 411 return ret;
412} 412}
413
414int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len,
415 unsigned int n_channels, unsigned int n_probes)
416{
417 struct wl1251_cmd_scan *cmd;
418 int i, ret = 0;
419
420 wl1251_debug(DEBUG_CMD, "cmd scan");
421
422 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
423 if (!cmd)
424 return -ENOMEM;
425
426 cmd->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD);
427 cmd->params.rx_filter_options = cpu_to_le32(CFG_RX_PRSP_EN |
428 CFG_RX_MGMT_EN |
429 CFG_RX_BCN_EN);
430 cmd->params.scan_options = 0;
431 cmd->params.num_channels = n_channels;
432 cmd->params.num_probe_requests = n_probes;
433 cmd->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */
434 cmd->params.tid_trigger = 0;
435
436 for (i = 0; i < n_channels; i++) {
437 cmd->channels[i].min_duration =
438 cpu_to_le32(WL1251_SCAN_MIN_DURATION);
439 cmd->channels[i].max_duration =
440 cpu_to_le32(WL1251_SCAN_MAX_DURATION);
441 memset(&cmd->channels[i].bssid_lsb, 0xff, 4);
442 memset(&cmd->channels[i].bssid_msb, 0xff, 2);
443 cmd->channels[i].early_termination = 0;
444 cmd->channels[i].tx_power_att = 0;
445 cmd->channels[i].channel = i + 1;
446 }
447
448 cmd->params.ssid_len = ssid_len;
449 if (ssid)
450 memcpy(cmd->params.ssid, ssid, ssid_len);
451
452 ret = wl1251_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd));
453 if (ret < 0) {
454 wl1251_error("cmd scan failed: %d", ret);
455 goto out;
456 }
457
458 wl1251_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd));
459
460 if (cmd->header.status != CMD_STATUS_SUCCESS) {
461 wl1251_error("cmd scan status wasn't success: %d",
462 cmd->header.status);
463 ret = -EIO;
464 goto out;
465 }
466
467out:
468 kfree(cmd);
469 return ret;
470}
471
472int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout)
473{
474 struct wl1251_cmd_trigger_scan_to *cmd;
475 int ret;
476
477 wl1251_debug(DEBUG_CMD, "cmd trigger scan to");
478
479 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
480 if (!cmd)
481 return -ENOMEM;
482
483 cmd->timeout = timeout;
484
485 ret = wl1251_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd));
486 if (ret < 0) {
487 wl1251_error("cmd trigger scan to failed: %d", ret);
488 goto out;
489 }
490
491out:
492 kfree(cmd);
493 return ret;
494}