28 #include <linux/slab.h>
29 #include <linux/types.h>
39 #define IWL_ACTIVE_DWELL_TIME_24 (30)
40 #define IWL_ACTIVE_DWELL_TIME_52 (20)
42 #define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3)
43 #define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2)
48 #define IWL_PASSIVE_DWELL_TIME_24 (20)
49 #define IWL_PASSIVE_DWELL_TIME_52 (10)
50 #define IWL_PASSIVE_DWELL_BASE (100)
51 #define IWL_CHANNEL_TUNE_TIME 5
52 #define MAX_SCAN_CHANNEL 50
55 #define IWL_RADIO_RESET_DWELL_TIME 5
111 static void iwl_process_scan_complete(
struct iwl_priv *priv)
148 "failed to initiate pending scan: %d\n", err);
157 iwl_complete_scan(priv, aborted);
161 if (!iwl_is_ready_rf(priv))
181 iwl_complete_scan(priv,
true);
184 static void iwl_do_scan_abort(
struct iwl_priv *priv)
200 ret = iwl_send_scan_abort(priv);
231 iwl_do_scan_abort(priv);
252 iwl_process_scan_complete(priv);
256 static int iwl_rx_reply_scan(
struct iwl_priv *priv,
260 #ifdef CONFIG_IWLWIFI_DEBUG
270 static int iwl_rx_scan_start_notif(
struct iwl_priv *priv,
280 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n",
282 notif->
band ?
"bg" :
"a",
297 static int iwl_rx_scan_results_notif(
struct iwl_priv *priv,
301 #ifdef CONFIG_IWLWIFI_DEBUG
307 "probe status: %u:%u "
308 "(TSF: 0x%08X:%08X) - %d "
309 "elapsed=%lu usec\n",
311 notif->
band ?
"bg" :
"a",
322 static int iwl_rx_scan_complete_notif(
struct iwl_priv *priv,
329 IWL_DEBUG_SCAN(priv,
"Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
351 iwl_advanced_bt_coexist(priv) &&
380 iwl_rx_scan_results_notif;
382 iwl_rx_scan_complete_notif;
385 static u16 iwl_get_active_dwell_time(
struct iwl_priv *priv,
414 switch (ctx->
staging.dev_type) {
421 if (!iwl_is_associated_ctx(ctx))
442 dwell_time =
min(limit, dwell_time);
447 return min(limit, dwell_time);
454 static u16 iwl_get_passive_dwell_time(
struct iwl_priv *priv,
461 return iwl_limit_dwell(priv, passive);
465 static u8 iwl_get_single_channel_number(
struct iwl_priv *priv,
492 static int iwl_get_channel_for_reset_scan(
struct iwl_priv *priv,
500 sband = iwl_get_hw_mode(priv, band);
502 IWL_ERR(priv,
"invalid band\n");
506 channel = iwl_get_single_channel_number(priv, band);
517 scan_ch->
tx_gain = ((1 << 5) | (3 << 3)) | 3;
519 scan_ch->
tx_gain = ((1 << 5) | (5 << 3));
523 IWL_ERR(priv,
"no valid channel found\n");
527 static int iwl_get_channels_for_scan(
struct iwl_priv *priv,
535 u16 passive_dwell = 0;
536 u16 active_dwell = 0;
540 sband = iwl_get_hw_mode(priv, band);
544 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
545 passive_dwell = iwl_get_passive_dwell_time(priv, band);
547 if (passive_dwell <= active_dwell)
548 passive_dwell = active_dwell + 1;
550 for (i = 0, added = 0; i < priv->
scan_request->n_channels; i++) {
553 if (chan->
band != band)
578 scan_ch->
tx_gain = ((1 << 5) | (3 << 3)) | 3;
580 scan_ch->
tx_gain = ((1 << 5) | (5 << 3));
585 "ACTIVE" :
"PASSIVE",
587 active_dwell : passive_dwell);
615 eth_broadcast_addr(frame->
da);
617 eth_broadcast_addr(frame->
bssid);
623 pos = &frame->
u.probe_req.variable[0];
626 left -= ssid_len + 2;
631 if (ssid && ssid_len) {
632 memcpy(pos, ssid, ssid_len);
665 bool is_active =
false;
672 priv->
fw->ucode_capa.max_probe_length;
683 ctx = iwl_rxon_ctx_from_vif(vif);
689 "fail to allocate memory for scan\n");
694 memset(scan, 0, scan_cmd_size);
700 iwl_is_any_associated(priv)) {
703 u32 suspend_time = 100;
704 u32 scan_suspend_time = 100;
715 interval = vif->
bss_conf.beacon_int;
722 interval = suspend_time;
724 extra = (suspend_time /
interval) << 22;
725 scan_suspend_time = (extra |
726 ((suspend_time %
interval) * 1024));
729 scan_suspend_time, interval);
762 for (i = priv->
scan_request->n_ssids - 1; i >= 1; i--) {
803 if (priv->
cfg->bt_params &&
804 priv->
cfg->bt_params->advanced_bt_coexist)
811 IWL_WARN(priv,
"Invalid scan band\n");
846 priv->
cfg->bt_params &&
847 priv->
cfg->bt_params->advanced_bt_coexist) {
849 scan_tx_antennas = first_antenna(scan_tx_antennas);
855 rate_flags |= iwl_ant_idx_to_flags(priv->
scan_tx_ant[band]);
856 scan->
tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
865 active_chains = rx_ant &
868 active_chains = rx_ant;
873 rx_ant = first_antenna(active_chains);
875 if (priv->
cfg->bt_params &&
876 priv->
cfg->bt_params->advanced_bt_coexist &&
879 rx_ant = first_antenna(rx_ant);
891 cmd_len = iwl_fill_probe_req(
897 scan_cmd_size -
sizeof(*scan));
902 cmd_len = iwl_fill_probe_req(
906 scan_cmd_size -
sizeof(*scan));
919 iwl_get_channel_for_reset_scan(priv, vif, band,
920 (
void *)&scan->
data[cmd_len]);
924 iwl_get_channels_for_scan(priv, vif, band,
926 (
void *)&scan->
data[cmd_len]);
938 scan_ch = (
void *)&scan->
data[cmd_len];
940 for (i = 0; i < n_chan; i++) {
959 scan_ch->
tx_gain = ((1 << 5) | (3 << 3)) | 3;
961 scan_ch->
tx_gain = ((1 << 5) | (5 << 3));
1019 if (!iwl_is_ready_rf(priv)) {
1020 IWL_WARN(priv,
"Request scan called when driver not ready.\n");
1026 "Multiple concurrent scan requests in parallel.\n");
1045 ret = iwlagn_request_scan(priv, vif);
1108 static void iwl_bg_abort_scan(
struct work_struct *work)
1121 static void iwl_bg_scan_completed(
struct work_struct *work)
1127 iwl_process_scan_complete(priv);