aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/mvm/scan.c')
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/scan.c423
1 files changed, 331 insertions, 92 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
index 875281cf7fc0..97d2de8f1582 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
@@ -1,69 +1,12 @@
-/******************************************************************************
- *
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018 - 2019 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * The full GNU General Public License is included in this distribution
- * in the file called COPYING.
- *
- * Contact Information:
- * Intel Linux Wireless <linuxwifi@intel.com>
- * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
- *
- * BSD LICENSE
- *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018 - 2019 Intel Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/*
+ * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
+ * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
+ * Copyright (C) 2016-2017 Intel Deutschland GmbH
+ */
#include <linux/etherdevice.h>
#include <net/mac80211.h>
+#include <linux/crc32.h>
#include "mvm.h"
#include "fw/api/scan.h"
@@ -148,6 +91,9 @@ struct iwl_mvm_scan_params {
int n_scan_plans;
struct cfg80211_sched_scan_plan *scan_plans;
bool iter_notif;
+ struct cfg80211_scan_6ghz_params *scan_6ghz_params;
+ u32 n_6ghz_params;
+ bool scan_6ghz;
};
static inline void *iwl_mvm_get_scan_req_umac_data(struct iwl_mvm *mvm)
@@ -568,7 +514,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
{
struct iwl_scan_offload_profile *profile;
struct iwl_scan_offload_profile_cfg_v1 *profile_cfg_v1;
- struct iwl_scan_offload_blacklist *blacklist;
+ struct iwl_scan_offload_blocklist *blocklist;
struct iwl_scan_offload_profile_cfg_data *data;
int max_profiles = iwl_umac_scan_get_max_profiles(mvm->fw);
int profile_cfg_size = sizeof(*data) +
@@ -579,7 +525,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
.dataflags[1] = IWL_HCMD_DFL_NOCOPY,
};
- int blacklist_len;
+ int blocklist_len;
int i;
int ret;
@@ -587,22 +533,22 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
return -EIO;
if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SHORT_BL)
- blacklist_len = IWL_SCAN_SHORT_BLACKLIST_LEN;
+ blocklist_len = IWL_SCAN_SHORT_BLACKLIST_LEN;
else
- blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN;
+ blocklist_len = IWL_SCAN_MAX_BLACKLIST_LEN;
- blacklist = kcalloc(blacklist_len, sizeof(*blacklist), GFP_KERNEL);
- if (!blacklist)
+ blocklist = kcalloc(blocklist_len, sizeof(*blocklist), GFP_KERNEL);
+ if (!blocklist)
return -ENOMEM;
profile_cfg_v1 = kzalloc(profile_cfg_size, GFP_KERNEL);
if (!profile_cfg_v1) {
ret = -ENOMEM;
- goto free_blacklist;
+ goto free_blocklist;
}
- cmd.data[0] = blacklist;
- cmd.len[0] = sizeof(*blacklist) * blacklist_len;
+ cmd.data[0] = blocklist;
+ cmd.len[0] = sizeof(*blocklist) * blocklist_len;
cmd.data[1] = profile_cfg_v1;
/* if max_profile is MAX_PROFILES_V2, we have the new API */
@@ -615,7 +561,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
data = &profile_cfg_v1->data;
}
- /* No blacklist configuration */
+ /* No blocklist configuration */
data->num_profiles = req->n_match_sets;
data->active_clients = SCAN_CLIENT_SCHED_SCAN;
data->pass_match = SCAN_CLIENT_SCHED_SCAN;
@@ -639,8 +585,8 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
ret = iwl_mvm_send_cmd(mvm, &cmd);
kfree(profile_cfg_v1);
-free_blacklist:
- kfree(blacklist);
+free_blocklist:
+ kfree(blocklist);
return ret;
}
@@ -844,6 +790,12 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
cpu_to_le16(ies->len[NL80211_BAND_5GHZ]);
pos += ies->len[NL80211_BAND_5GHZ];
+ memcpy(pos, ies->ies[NL80211_BAND_6GHZ],
+ ies->len[NL80211_BAND_6GHZ]);
+ params->preq.band_data[2].offset = cpu_to_le16(pos - params->preq.buf);
+ params->preq.band_data[2].len =
+ cpu_to_le16(ies->len[NL80211_BAND_6GHZ]);
+ pos += ies->len[NL80211_BAND_6GHZ];
memcpy(pos, ies->common_ies, ies->common_ie_len);
params->preq.common_data.offset = cpu_to_le16(pos - params->preq.buf);
@@ -1516,6 +1468,14 @@ static const struct iwl_mvm_scan_channel_segment scan_channel_segments[] = {
.channel_spacing_shift = 2,
.band = PHY_BAND_5
},
+ {
+ .start_idx = 51,
+ .end_idx = 111,
+ .first_channel_id = 1,
+ .last_channel_id = 241,
+ .channel_spacing_shift = 2,
+ .band = PHY_BAND_6
+ },
};
static int iwl_mvm_scan_ch_and_band_to_idx(u8 channel_id, u8 band)
@@ -1687,11 +1647,210 @@ iwl_mvm_umac_scan_cfg_channels_v6(struct iwl_mvm *mvm,
cfg->flags = cpu_to_le32(flags | n_aps_flag);
cfg->v2.channel_num = channels[i]->hw_value;
cfg->v2.band = iwl_mvm_phy_band_from_nl80211(band);
+ if (cfg80211_channel_is_psc(channels[i]))
+ cfg->flags = 0;
cfg->v2.iter_count = 1;
cfg->v2.iter_interval = 0;
}
}
+static int
+iwl_mvm_umac_scan_fill_6g_chan_list(struct iwl_mvm_scan_params *params,
+ __le32 *cmd_short_ssid, u8 *cmd_bssid,
+ u8 *scan_ssid_num, u8 *bssid_num)
+{
+ int j, idex_s = 0, idex_b = 0;
+ struct cfg80211_scan_6ghz_params *scan_6ghz_params =
+ params->scan_6ghz_params;
+
+ if (!params->n_6ghz_params) {
+ for (j = 0; j < params->n_ssids; j++) {
+ cmd_short_ssid[idex_s++] =
+ cpu_to_le32(~crc32_le(~0, params->ssids[j].ssid,
+ params->ssids[j].ssid_len));
+ (*scan_ssid_num)++;
+ }
+ return 0;
+ }
+
+ /*
+ * Populate the arrays of the short SSIDs and the BSSIDs using the 6GHz
+ * collocated parameters. This might not be optimal, as this processing
+ * does not (yet) correspond to the actual channels, so it is possible
+ * that some entries would be left out.
+ *
+ * TODO: improve this logic.
+ */
+ for (j = 0; j < params->n_6ghz_params; j++) {
+ int k;
+
+ /* First, try to place the short SSID */
+ if (scan_6ghz_params[j].short_ssid_valid) {
+ for (k = 0; k < idex_s; k++) {
+ if (cmd_short_ssid[k] ==
+ cpu_to_le32(scan_6ghz_params[j].short_ssid))
+ break;
+ }
+
+ if (k == idex_s && idex_s < SCAN_SHORT_SSID_MAX_SIZE) {
+ cmd_short_ssid[idex_s++] =
+ cpu_to_le32(scan_6ghz_params[j].short_ssid);
+ (*scan_ssid_num)++;
+ }
+ }
+
+ /* try to place BSSID for the same entry */
+ for (k = 0; k < idex_b; k++) {
+ if (!memcmp(&cmd_bssid[ETH_ALEN * k],
+ scan_6ghz_params[j].bssid, ETH_ALEN))
+ break;
+ }
+
+ if (k == idex_b && idex_b < SCAN_BSSID_MAX_SIZE) {
+ memcpy(&cmd_bssid[ETH_ALEN * idex_b++],
+ scan_6ghz_params[j].bssid, ETH_ALEN);
+ (*bssid_num)++;
+ }
+ }
+ return 0;
+}
+
+/* TODO: this function can be merged with iwl_mvm_scan_umac_fill_ch_p_v6 */
+static void
+iwl_mvm_umac_scan_cfg_channels_v6_6g(struct iwl_mvm_scan_params *params,
+ u32 n_channels, __le32 *cmd_short_ssid,
+ u8 *cmd_bssid, u8 scan_ssid_num,
+ u8 bssid_num,
+ struct iwl_scan_channel_params_v6 *cp,
+ enum nl80211_iftype vif_type)
+{
+ struct iwl_scan_channel_cfg_umac *channel_cfg = cp->channel_config;
+ int i;
+ struct cfg80211_scan_6ghz_params *scan_6ghz_params =
+ params->scan_6ghz_params;
+
+ for (i = 0; i < params->n_channels; i++) {
+ struct iwl_scan_channel_cfg_umac *cfg =
+ &cp->channel_config[i];
+
+ u32 s_ssid_bitmap = 0, bssid_bitmap = 0, flags = 0;
+ u8 j, k, s_max = 0, b_max = 0, n_used_bssid_entries;
+ bool force_passive, found = false,
+ unsolicited_probe_on_chan = false, psc_no_listen = false;
+
+ cfg->v1.channel_num = params->channels[i]->hw_value;
+ cfg->v2.band = 2;
+ cfg->v2.iter_count = 1;
+ cfg->v2.iter_interval = 0;
+
+ /*
+ * The optimize the scan time, i.e., reduce the scan dwell time
+ * on each channel, the below logic tries to set 3 direct BSSID
+ * probe requests for each broadcast probe request with a short
+ * SSID.
+ * TODO: improve this logic
+ */
+ n_used_bssid_entries = 3;
+ for (j = 0; j < params->n_6ghz_params; j++) {
+ if (!(scan_6ghz_params[j].channel_idx == i))
+ continue;
+
+ found = false;
+ unsolicited_probe_on_chan |=
+ scan_6ghz_params[j].unsolicited_probe;
+ psc_no_listen |= scan_6ghz_params[j].psc_no_listen;
+
+ for (k = 0; k < scan_ssid_num; k++) {
+ if (!scan_6ghz_params[j].unsolicited_probe &&
+ le32_to_cpu(cmd_short_ssid[k]) ==
+ scan_6ghz_params[j].short_ssid) {
+ /* Relevant short SSID bit set */
+ if (s_ssid_bitmap & BIT(k)) {
+ found = true;
+ break;
+ }
+
+ /*
+ * Use short SSID only to create a new
+ * iteration during channel dwell.
+ */
+ if (n_used_bssid_entries >= 3) {
+ s_ssid_bitmap |= BIT(k);
+ s_max++;
+ n_used_bssid_entries -= 3;
+ found = true;
+ break;
+ }
+ }
+ }
+
+ if (found)
+ continue;
+
+ for (k = 0; k < bssid_num; k++) {
+ if (!memcmp(&cmd_bssid[ETH_ALEN * k],
+ scan_6ghz_params[j].bssid,
+ ETH_ALEN)) {
+ if (!(bssid_bitmap & BIT(k))) {
+ bssid_bitmap |= BIT(k);
+ b_max++;
+ n_used_bssid_entries++;
+ }
+ break;
+ }
+ }
+ }
+
+ flags = bssid_bitmap | (s_ssid_bitmap << 16);
+
+ if (cfg80211_channel_is_psc(params->channels[i]) &&
+ psc_no_listen)
+ flags |= IWL_UHB_CHAN_CFG_FLAG_PSC_CHAN_NO_LISTEN;
+
+ if (unsolicited_probe_on_chan)
+ flags |= IWL_UHB_CHAN_CFG_FLAG_UNSOLICITED_PROBE_RES;
+
+ /*
+ * In the following cases apply passive scan:
+ * 1. Non fragmented scan:
+ * - PSC channel with NO_LISTEN_FLAG on should be treated
+ * like non PSC channel
+ * - Non PSC channel with more than 3 short SSIDs or more
+ * than 9 BSSIDs.
+ * - Non PSC Channel with unsolicited probe response and
+ * more than 2 short SSIDs or more than 6 BSSIDs.
+ * - PSC channel with more than 2 short SSIDs or more than
+ * 6 BSSIDs.
+ * 3. Fragmented scan:
+ * - PSC channel with more than 1 SSID or 3 BSSIDs.
+ * - Non PSC channel with more than 2 SSIDs or 6 BSSIDs.
+ * - Non PSC channel with unsolicited probe response and
+ * more than 1 SSID or more than 3 BSSIDs.
+ */
+ if (!iwl_mvm_is_scan_fragmented(params->type)) {
+ if (!cfg80211_channel_is_psc(params->channels[i]) ||
+ flags & IWL_UHB_CHAN_CFG_FLAG_PSC_CHAN_NO_LISTEN) {
+ force_passive = (s_max > 3 || b_max > 9);
+ force_passive |= (unsolicited_probe_on_chan &&
+ (s_max > 2 || b_max > 6));
+ } else {
+ force_passive = (s_max > 2 || b_max > 6);
+ }
+ } else if (cfg80211_channel_is_psc(params->channels[i])) {
+ force_passive = (s_max > 1 || b_max > 3);
+ } else {
+ force_passive = (s_max > 2 || b_max > 6);
+ force_passive |= (unsolicited_probe_on_chan &&
+ (s_max > 1 || b_max > 3));
+ }
+ if (force_passive ||
+ (!flags && !cfg80211_channel_is_psc(params->channels[i])))
+ flags |= IWL_UHB_CHAN_CFG_FLAG_FORCE_PASSIVE;
+
+ channel_cfg[i].flags |= cpu_to_le32(flags);
+ }
+}
+
static u8 iwl_mvm_scan_umac_chan_flags_v2(struct iwl_mvm *mvm,
struct iwl_mvm_scan_params *params,
struct ieee80211_vif *vif)
@@ -1746,6 +1905,10 @@ static u16 iwl_mvm_scan_umac_flags_v2(struct iwl_mvm *mvm,
if (type == IWL_MVM_SCAN_SCHED || type == IWL_MVM_SCAN_NETDETECT)
flags |= IWL_UMAC_SCAN_GEN_FLAGS_V2_PREEMPTIVE;
+ if ((type == IWL_MVM_SCAN_SCHED || type == IWL_MVM_SCAN_NETDETECT) &&
+ params->flags & NL80211_SCAN_FLAG_COLOCATED_6GHZ)
+ flags |= IWL_UMAC_SCAN_GEN_FLAGS_V2_TRIGGER_UHB_SCAN;
+
return flags;
}
@@ -1925,8 +2088,10 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
ret = iwl_mvm_fill_scan_sched_params(params, tail_v2->schedule,
&tail_v2->delay);
- if (ret)
+ if (ret) {
+ mvm->scan_uid_status[uid] = 0;
return ret;
+ }
if (iwl_mvm_is_scan_ext_chan_supported(mvm)) {
tail_v2->preq = params->preq;
@@ -2056,6 +2221,8 @@ static int iwl_mvm_scan_umac_v14(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
{
struct iwl_scan_req_umac_v14 *cmd = mvm->scan_cmd;
struct iwl_scan_req_params_v14 *scan_p = &cmd->scan_params;
+ struct iwl_scan_channel_params_v6 *cp = &scan_p->channel_params;
+ struct iwl_scan_probe_params_v4 *pb = &scan_p->probe_params;
int ret;
u16 gen_flags;
u32 bitmap_ssid = 0;
@@ -2078,8 +2245,34 @@ static int iwl_mvm_scan_umac_v14(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
iwl_mvm_scan_umac_fill_probe_p_v4(params, &scan_p->probe_params,
&bitmap_ssid);
- iwl_mvm_scan_umac_fill_ch_p_v6(mvm, params, vif,
- &scan_p->channel_params, bitmap_ssid);
+ if (!params->scan_6ghz) {
+ iwl_mvm_scan_umac_fill_ch_p_v6(mvm, params, vif,
+ &scan_p->channel_params, bitmap_ssid);
+
+ return 0;
+ }
+ cp->flags = iwl_mvm_scan_umac_chan_flags_v2(mvm, params, vif);
+ cp->n_aps_override[0] = IWL_SCAN_ADWELL_N_APS_GO_FRIENDLY;
+ cp->n_aps_override[1] = IWL_SCAN_ADWELL_N_APS_SOCIAL_CHS;
+
+ ret = iwl_mvm_umac_scan_fill_6g_chan_list(params, pb->short_ssid,
+ pb->bssid_array[0],
+ &pb->short_ssid_num,
+ &pb->bssid_num);
+ if (ret)
+ return ret;
+
+ iwl_mvm_umac_scan_cfg_channels_v6_6g(params,
+ params->n_channels,
+ pb->short_ssid,
+ pb->bssid_array[0],
+ pb->short_ssid_num,
+ pb->bssid_num, cp,
+ vif->type);
+ cp->count = params->n_channels;
+ if (!params->n_ssids ||
+ (params->n_ssids == 1 && !params->ssids[0].ssid_len))
+ cp->flags |= IWL_SCAN_CHANNEL_FLAG_6G_PSC_NO_FILTER;
return 0;
}
@@ -2148,7 +2341,7 @@ static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type)
/* Something is wrong if no scan was running but we
* ran out of scans.
*/
- /* fall through */
+ fallthrough;
default:
WARN_ON(1);
break;
@@ -2209,7 +2402,7 @@ static int iwl_mvm_build_scan_cmd(struct iwl_mvm *mvm,
struct iwl_mvm_scan_params *params,
int type)
{
- int uid, i;
+ int uid, i, err;
u8 scan_ver;
lockdep_assert_held(&mvm->mutex);
@@ -2241,7 +2434,11 @@ static int iwl_mvm_build_scan_cmd(struct iwl_mvm *mvm,
return ver_handler->handler(mvm, vif, params, type, uid);
}
- return iwl_mvm_scan_umac(mvm, vif, params, type, uid);
+ err = iwl_mvm_scan_umac(mvm, vif, params, type, uid);
+ if (err)
+ return err;
+
+ return uid;
}
int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
@@ -2254,7 +2451,7 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
.dataflags = { IWL_HCMD_DFL_NOCOPY, },
};
struct iwl_mvm_scan_params params = {};
- int ret;
+ int ret, uid;
struct cfg80211_sched_scan_plan scan_plan = { .iterations = 1 };
lockdep_assert_held(&mvm->mutex);
@@ -2291,6 +2488,9 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
params.scan_plans = &scan_plan;
params.n_scan_plans = 1;
+ params.n_6ghz_params = req->n_6ghz_params;
+ params.scan_6ghz_params = req->scan_6ghz_params;
+ params.scan_6ghz = req->scan_6ghz;
iwl_mvm_fill_scan_type(mvm, &params, vif);
if (req->duration)
@@ -2298,11 +2498,11 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
- ret = iwl_mvm_build_scan_cmd(mvm, vif, &hcmd, &params,
+ uid = iwl_mvm_build_scan_cmd(mvm, vif, &hcmd, &params,
IWL_MVM_SCAN_REGULAR);
- if (ret)
- return ret;
+ if (uid < 0)
+ return uid;
iwl_mvm_pause_tcm(mvm, false);
@@ -2314,6 +2514,7 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
*/
IWL_ERR(mvm, "Scan failed! ret %d\n", ret);
iwl_mvm_resume_tcm(mvm);
+ mvm->scan_uid_status[uid] = 0;
return ret;
}
@@ -2339,7 +2540,9 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
.dataflags = { IWL_HCMD_DFL_NOCOPY, },
};
struct iwl_mvm_scan_params params = {};
- int ret;
+ int ret, uid;
+ int i, j;
+ bool non_psc_included = false;
lockdep_assert_held(&mvm->mutex);
@@ -2356,8 +2559,6 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
if (WARN_ON(!mvm->scan_cmd))
return -ENOMEM;
- if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
- return -ENOBUFS;
params.n_ssids = req->n_ssids;
params.flags = req->flags;
@@ -2397,10 +2598,46 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
- ret = iwl_mvm_build_scan_cmd(mvm, vif, &hcmd, &params, type);
+ /* for 6 GHZ band only PSC channels need to be added */
+ for (i = 0; i < params.n_channels; i++) {
+ struct ieee80211_channel *channel = params.channels[i];
- if (ret)
- return ret;
+ if (channel->band == NL80211_BAND_6GHZ &&
+ !cfg80211_channel_is_psc(channel)) {
+ non_psc_included = true;
+ break;
+ }
+ }
+
+ if (non_psc_included) {
+ params.channels = kmemdup(params.channels,
+ sizeof(params.channels[0]) *
+ params.n_channels,
+ GFP_KERNEL);
+ if (!params.channels)
+ return -ENOMEM;
+
+ for (i = j = 0; i < params.n_channels; i++) {
+ if (params.channels[i]->band == NL80211_BAND_6GHZ &&
+ !cfg80211_channel_is_psc(params.channels[i]))
+ continue;
+ params.channels[j++] = params.channels[i];
+ }
+ params.n_channels = j;
+ }
+
+ if (non_psc_included &&
+ !iwl_mvm_scan_fits(mvm, req->n_ssids, ies, params.n_channels)) {
+ kfree(params.channels);
+ return -ENOBUFS;
+ }
+
+ uid = iwl_mvm_build_scan_cmd(mvm, vif, &hcmd, &params, type);
+
+ if (non_psc_included)
+ kfree(params.channels);
+ if (uid < 0)
+ return uid;
ret = iwl_mvm_send_cmd(mvm, &hcmd);
if (!ret) {
@@ -2413,6 +2650,8 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
* should try to send the command again with different params.
*/
IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
+ mvm->scan_uid_status[uid] = 0;
+ mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_DISABLED;
}
return ret;