iwlwifi: mvm: generalize the other-scan stopping code
Instead of hardcoding the differences between UMAC scans and LMAC
scans (which in this case is the number of simultaneous scans that can
run), introduce a max_scans variable and stop scans of the other type
(i.e. stop sched scan if regular scan is being attempted and
vice-versa) if the number of running scans reached the maximum.
Add a function that checks if the maximum number of scans was reached
and stops the appropriate scan to make room for the new scan.
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 833d078..3721b16 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -1200,7 +1200,7 @@
{
int i;
- for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++)
+ for (i = 0; i < mvm->max_scans; i++)
if (mvm->scan_uid[i] == uid)
return i;
@@ -1217,7 +1217,7 @@
{
int i;
- for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++)
+ for (i = 0; i < mvm->max_scans; i++)
if (mvm->scan_uid[i] & type)
return true;
@@ -1229,7 +1229,7 @@
{
int i;
- for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++)
+ for (i = 0; i < mvm->max_scans; i++)
if (mvm->scan_uid[i] & type)
return i;
@@ -1253,8 +1253,7 @@
uid = type | (mvm->scan_seq_num <<
IWL_UMAC_SCAN_UID_SEQ_OFFSET);
mvm->scan_seq_num++;
- } while (iwl_mvm_find_scan_uid(mvm, uid) <
- IWL_MVM_MAX_SIMULTANEOUS_SCANS);
+ } while (iwl_mvm_find_scan_uid(mvm, uid) < mvm->max_scans);
IWL_DEBUG_SCAN(mvm, "Generated scan UID %u\n", uid);
@@ -1338,7 +1337,7 @@
lockdep_assert_held(&mvm->mutex);
uid_idx = iwl_mvm_find_free_scan_uid(mvm);
- if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+ if (uid_idx >= mvm->max_scans)
return -EBUSY;
/* we should have failed registration if scan_cmd was NULL */
@@ -1435,7 +1434,7 @@
lockdep_assert_held(&mvm->mutex);
uid_idx = iwl_mvm_find_free_scan_uid(mvm);
- if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+ if (uid_idx >= mvm->max_scans)
return -EBUSY;
/* we should have failed registration if scan_cmd was NULL */
@@ -1536,7 +1535,7 @@
/*
* Scan uid may be set to zero in case of scan abort request from above.
*/
- if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+ if (uid_idx >= mvm->max_scans)
return 0;
IWL_DEBUG_SCAN(mvm,
@@ -1577,7 +1576,7 @@
if (WARN_ON(pkt->hdr.cmd != SCAN_COMPLETE_UMAC))
return false;
- if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+ if (uid_idx >= scan_done->mvm->max_scans)
return false;
/*
@@ -1626,7 +1625,7 @@
IWL_DEBUG_SCAN(mvm, "Preparing to stop scan, type %x\n", type);
- for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) {
+ for (i = 0; i < mvm->max_scans; i++) {
if (mvm->scan_uid[i] & type) {
int err;
@@ -1689,13 +1688,13 @@
u32 uid, i;
uid = iwl_mvm_find_first_scan(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
- if (uid < IWL_MVM_MAX_SIMULTANEOUS_SCANS) {
+ if (uid < mvm->max_scans) {
ieee80211_scan_completed(mvm->hw, true);
mvm->scan_uid[uid] = 0;
}
uid = iwl_mvm_find_first_scan(mvm,
IWL_UMAC_SCAN_UID_SCHED_SCAN);
- if (uid < IWL_MVM_MAX_SIMULTANEOUS_SCANS && !mvm->restart_fw) {
+ if (uid < mvm->max_scans && !mvm->restart_fw) {
ieee80211_sched_scan_stopped(mvm->hw);
mvm->scan_uid[uid] = 0;
}
@@ -1704,7 +1703,7 @@
* UIDs to make sure there's nothing left there and warn if
* any is found.
*/
- for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) {
+ for (i = 0; i < mvm->max_scans; i++) {
if (WARN_ONCE(mvm->scan_uid[i],
"UMAC scan UID %d was not cleaned\n",
mvm->scan_uid[i]))