diff options
author | Luciano Coelho <luciano.coelho@intel.com> | 2015-03-27 03:28:26 -0400 |
---|---|---|
committer | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2015-04-29 06:13:15 -0400 |
commit | 999d2568ee0c2bbdf71a414e85fffe5d58fe766a (patch) | |
tree | ee0c7caf61ed62adeb605c3b7f2c806070f6b576 /drivers | |
parent | 83c415fd89486ab2992f728337c812b7264f7459 (diff) |
iwlwifi: mvm: combine scan size checks into a common function
Instead of repeating the same code in 4 different places, combine the
comparisons into a new function. Additionally, this change fixes UMAC
scans where the RRM IEs were not taken into consideration when
calculating the IE length.
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/mac80211.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/mvm.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/scan.c | 44 |
3 files changed, 21 insertions, 27 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c index 249d02079a48..8d9e5da1db3c 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c | |||
@@ -505,7 +505,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) | |||
505 | 505 | ||
506 | iwl_mvm_reset_phy_ctxts(mvm); | 506 | iwl_mvm_reset_phy_ctxts(mvm); |
507 | 507 | ||
508 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm, false); | 508 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); |
509 | 509 | ||
510 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; | 510 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
511 | 511 | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h index a8f51a824a75..7679ad680194 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h | |||
@@ -1168,7 +1168,7 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
1168 | struct ieee80211_scan_ies *ies); | 1168 | struct ieee80211_scan_ies *ies); |
1169 | int iwl_mvm_scan_size(struct iwl_mvm *mvm); | 1169 | int iwl_mvm_scan_size(struct iwl_mvm *mvm); |
1170 | int iwl_mvm_cancel_scan(struct iwl_mvm *mvm); | 1170 | int iwl_mvm_cancel_scan(struct iwl_mvm *mvm); |
1171 | int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan); | 1171 | int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm); |
1172 | void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm); | 1172 | void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm); |
1173 | 1173 | ||
1174 | /* Scheduled scan */ | 1174 | /* Scheduled scan */ |
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c index cbed9f31758c..95b986238e57 100644 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c | |||
@@ -296,8 +296,7 @@ static inline bool iwl_mvm_rrm_scan_needed(struct iwl_mvm *mvm) | |||
296 | IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT; | 296 | IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT; |
297 | } | 297 | } |
298 | 298 | ||
299 | static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm, | 299 | static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm) |
300 | bool is_sched_scan) | ||
301 | { | 300 | { |
302 | int max_probe_len; | 301 | int max_probe_len; |
303 | 302 | ||
@@ -313,9 +312,9 @@ static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm, | |||
313 | return max_probe_len; | 312 | return max_probe_len; |
314 | } | 313 | } |
315 | 314 | ||
316 | int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan) | 315 | int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm) |
317 | { | 316 | { |
318 | int max_ie_len = iwl_mvm_max_scan_ie_fw_cmd_room(mvm, is_sched_scan); | 317 | int max_ie_len = iwl_mvm_max_scan_ie_fw_cmd_room(mvm); |
319 | 318 | ||
320 | /* TODO: [BUG] This function should return the maximum allowed size of | 319 | /* TODO: [BUG] This function should return the maximum allowed size of |
321 | * scan IEs, however the LMAC scan api contains both 2GHZ and 5GHZ IEs | 320 | * scan IEs, however the LMAC scan api contains both 2GHZ and 5GHZ IEs |
@@ -802,6 +801,18 @@ iwl_mvm_build_generic_scan_cmd(struct iwl_mvm *mvm, | |||
802 | cpu_to_le32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED); | 801 | cpu_to_le32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED); |
803 | } | 802 | } |
804 | 803 | ||
804 | static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids, | ||
805 | struct ieee80211_scan_ies *ies, | ||
806 | int n_channels) | ||
807 | { | ||
808 | return ((n_ssids <= PROBE_OPTION_MAX) && | ||
809 | (n_channels <= mvm->fw->ucode_capa.n_scan_channels) & | ||
810 | (ies->common_ie_len + | ||
811 | ies->len[NL80211_BAND_2GHZ] + | ||
812 | ies->len[NL80211_BAND_5GHZ] <= | ||
813 | iwl_mvm_max_scan_ie_fw_cmd_room(mvm))); | ||
814 | } | ||
815 | |||
805 | static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | 816 | static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
806 | struct cfg80211_scan_request *req, | 817 | struct cfg80211_scan_request *req, |
807 | struct ieee80211_scan_ies *ies) | 818 | struct ieee80211_scan_ies *ies) |
@@ -825,11 +836,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
825 | if (WARN_ON(mvm->scan_cmd == NULL)) | 836 | if (WARN_ON(mvm->scan_cmd == NULL)) |
826 | return -ENOMEM; | 837 | return -ENOMEM; |
827 | 838 | ||
828 | if (req->n_ssids > PROBE_OPTION_MAX || | 839 | if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels)) |
829 | ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] + | ||
830 | ies->len[NL80211_BAND_5GHZ] > | ||
831 | iwl_mvm_max_scan_ie_fw_cmd_room(mvm, false) || | ||
832 | req->n_channels > mvm->fw->ucode_capa.n_scan_channels) | ||
833 | return -ENOBUFS; | 840 | return -ENOBUFS; |
834 | 841 | ||
835 | mvm->scan_status |= IWL_MVM_SCAN_REGULAR; | 842 | mvm->scan_status |= IWL_MVM_SCAN_REGULAR; |
@@ -938,11 +945,7 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, | |||
938 | if (WARN_ON(mvm->scan_cmd == NULL)) | 945 | if (WARN_ON(mvm->scan_cmd == NULL)) |
939 | return -ENOMEM; | 946 | return -ENOMEM; |
940 | 947 | ||
941 | if (req->n_ssids > PROBE_OPTION_MAX || | 948 | if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels)) |
942 | ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] + | ||
943 | ies->len[NL80211_BAND_5GHZ] > | ||
944 | iwl_mvm_max_scan_ie_fw_cmd_room(mvm, true) || | ||
945 | req->n_channels > mvm->fw->ucode_capa.n_scan_channels) | ||
946 | return -ENOBUFS; | 949 | return -ENOBUFS; |
947 | 950 | ||
948 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, 0, ¶ms); | 951 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, 0, ¶ms); |
@@ -1316,12 +1319,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
1316 | if (WARN_ON(mvm->scan_cmd == NULL)) | 1319 | if (WARN_ON(mvm->scan_cmd == NULL)) |
1317 | return -ENOMEM; | 1320 | return -ENOMEM; |
1318 | 1321 | ||
1319 | if (WARN_ON(req->n_ssids > PROBE_OPTION_MAX || | 1322 | if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels)) |
1320 | ies->common_ie_len + | ||
1321 | ies->len[NL80211_BAND_2GHZ] + | ||
1322 | ies->len[NL80211_BAND_5GHZ] + 24 + 2 > | ||
1323 | SCAN_OFFLOAD_PROBE_REQ_SIZE || req->n_channels > | ||
1324 | mvm->fw->ucode_capa.n_scan_channels)) | ||
1325 | return -ENOBUFS; | 1323 | return -ENOBUFS; |
1326 | 1324 | ||
1327 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, | 1325 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, |
@@ -1414,11 +1412,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, | |||
1414 | if (WARN_ON(mvm->scan_cmd == NULL)) | 1412 | if (WARN_ON(mvm->scan_cmd == NULL)) |
1415 | return -ENOMEM; | 1413 | return -ENOMEM; |
1416 | 1414 | ||
1417 | if (WARN_ON(req->n_ssids > PROBE_OPTION_MAX || | 1415 | if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels)) |
1418 | ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] + | ||
1419 | ies->len[NL80211_BAND_5GHZ] + 24 + 2 > | ||
1420 | SCAN_OFFLOAD_PROBE_REQ_SIZE || req->n_channels > | ||
1421 | mvm->fw->ucode_capa.n_scan_channels)) | ||
1422 | return -ENOBUFS; | 1416 | return -ENOBUFS; |
1423 | 1417 | ||
1424 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, | 1418 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, |