diff options
author | Alexander Bondar <alexander.bondar@intel.com> | 2014-03-12 11:31:19 -0400 |
---|---|---|
committer | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2014-03-18 15:15:38 -0400 |
commit | 8a110d9be1c14a95f502343b8b4783eb3228e1e3 (patch) | |
tree | 74b642f80d269687bc2a68e36f10023ab9e8179a | |
parent | 65d66628500a40e2acbf1546af536801d65e0d14 (diff) |
iwlwifi: mvm: restructure scan parameters calculation
Some scan parameters should be dependent on traffic conditions.
Centralize conditions verification in one function and obtain
scan max out-of-channel and suspend time in that new function.
Rely on bound interfaces indication instead of association state
to calculate scan parameters. If no bound interfaces use default
values for out-of-channel and suspend time parameters.
Additionally, get rid of NL80211_SCAN_FLAG_LOW_PRIORITY checks
since no use case for this exists so far.
Signed-off-by: Alexander Bondar <alexander.bondar@intel.com>
[reword commit log a bit]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/mac80211.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/scan.c | 82 |
2 files changed, 41 insertions, 44 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c index 8414c031e274..dbe6ff8e67b3 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c | |||
@@ -375,8 +375,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) | |||
375 | } | 375 | } |
376 | 376 | ||
377 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | | 377 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
378 | NL80211_FEATURE_P2P_GO_OPPPS | | 378 | NL80211_FEATURE_P2P_GO_OPPPS; |
379 | NL80211_FEATURE_LOW_PRIORITY_SCAN; | ||
380 | 379 | ||
381 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | 380 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
382 | 381 | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c index 945398ba39b4..ee3f67f5e42b 100644 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c | |||
@@ -70,9 +70,11 @@ | |||
70 | 70 | ||
71 | #define IWL_PLCP_QUIET_THRESH 1 | 71 | #define IWL_PLCP_QUIET_THRESH 1 |
72 | #define IWL_ACTIVE_QUIET_TIME 10 | 72 | #define IWL_ACTIVE_QUIET_TIME 10 |
73 | #define LONG_OUT_TIME_PERIOD 600 | 73 | |
74 | #define SHORT_OUT_TIME_PERIOD 200 | 74 | struct iwl_mvm_scan_params { |
75 | #define SUSPEND_TIME_PERIOD 100 | 75 | u32 max_out_time; |
76 | u32 suspend_time; | ||
77 | }; | ||
76 | 78 | ||
77 | static inline __le16 iwl_mvm_scan_rx_chain(struct iwl_mvm *mvm) | 79 | static inline __le16 iwl_mvm_scan_rx_chain(struct iwl_mvm *mvm) |
78 | { | 80 | { |
@@ -90,24 +92,6 @@ static inline __le16 iwl_mvm_scan_rx_chain(struct iwl_mvm *mvm) | |||
90 | return cpu_to_le16(rx_chain); | 92 | return cpu_to_le16(rx_chain); |
91 | } | 93 | } |
92 | 94 | ||
93 | static inline __le32 iwl_mvm_scan_max_out_time(struct ieee80211_vif *vif, | ||
94 | u32 flags, bool is_assoc) | ||
95 | { | ||
96 | if (!is_assoc) | ||
97 | return 0; | ||
98 | if (flags & NL80211_SCAN_FLAG_LOW_PRIORITY) | ||
99 | return cpu_to_le32(ieee80211_tu_to_usec(SHORT_OUT_TIME_PERIOD)); | ||
100 | return cpu_to_le32(ieee80211_tu_to_usec(LONG_OUT_TIME_PERIOD)); | ||
101 | } | ||
102 | |||
103 | static inline __le32 iwl_mvm_scan_suspend_time(struct ieee80211_vif *vif, | ||
104 | bool is_assoc) | ||
105 | { | ||
106 | if (!is_assoc) | ||
107 | return 0; | ||
108 | return cpu_to_le32(ieee80211_tu_to_usec(SUSPEND_TIME_PERIOD)); | ||
109 | } | ||
110 | |||
111 | static inline __le32 | 95 | static inline __le32 |
112 | iwl_mvm_scan_rxon_flags(struct cfg80211_scan_request *req) | 96 | iwl_mvm_scan_rxon_flags(struct cfg80211_scan_request *req) |
113 | { | 97 | { |
@@ -267,13 +251,30 @@ static u16 iwl_mvm_fill_probe_req(struct ieee80211_mgmt *frame, const u8 *ta, | |||
267 | return (u16)len; | 251 | return (u16)len; |
268 | } | 252 | } |
269 | 253 | ||
270 | static void iwl_mvm_vif_assoc_iterator(void *data, u8 *mac, | 254 | static void iwl_mvm_scan_condition_iterator(void *data, u8 *mac, |
271 | struct ieee80211_vif *vif) | 255 | struct ieee80211_vif *vif) |
272 | { | 256 | { |
273 | bool *is_assoc = data; | 257 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
258 | bool *global_bound = data; | ||
274 | 259 | ||
275 | if (vif->bss_conf.assoc) | 260 | if (mvmvif->phy_ctxt && mvmvif->phy_ctxt->id < MAX_PHYS) |
276 | *is_assoc = true; | 261 | *global_bound = true; |
262 | } | ||
263 | |||
264 | static void iwl_mvm_scan_calc_params(struct iwl_mvm *mvm, | ||
265 | struct iwl_mvm_scan_params *params) | ||
266 | { | ||
267 | bool global_bound = false; | ||
268 | |||
269 | ieee80211_iterate_active_interfaces_atomic(mvm->hw, | ||
270 | IEEE80211_IFACE_ITER_NORMAL, | ||
271 | iwl_mvm_scan_condition_iterator, | ||
272 | &global_bound); | ||
273 | if (!global_bound) | ||
274 | return; | ||
275 | |||
276 | params->suspend_time = ieee80211_tu_to_usec(100); | ||
277 | params->max_out_time = ieee80211_tu_to_usec(600); | ||
277 | } | 278 | } |
278 | 279 | ||
279 | int iwl_mvm_scan_request(struct iwl_mvm *mvm, | 280 | int iwl_mvm_scan_request(struct iwl_mvm *mvm, |
@@ -288,13 +289,13 @@ int iwl_mvm_scan_request(struct iwl_mvm *mvm, | |||
288 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, | 289 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, |
289 | }; | 290 | }; |
290 | struct iwl_scan_cmd *cmd = mvm->scan_cmd; | 291 | struct iwl_scan_cmd *cmd = mvm->scan_cmd; |
291 | bool is_assoc = false; | ||
292 | int ret; | 292 | int ret; |
293 | u32 status; | 293 | u32 status; |
294 | int ssid_len = 0; | 294 | int ssid_len = 0; |
295 | u8 *ssid = NULL; | 295 | u8 *ssid = NULL; |
296 | bool basic_ssid = !(mvm->fw->ucode_capa.flags & | 296 | bool basic_ssid = !(mvm->fw->ucode_capa.flags & |
297 | IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID); | 297 | IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID); |
298 | struct iwl_mvm_scan_params params = {}; | ||
298 | 299 | ||
299 | lockdep_assert_held(&mvm->mutex); | 300 | lockdep_assert_held(&mvm->mutex); |
300 | BUG_ON(mvm->scan_cmd == NULL); | 301 | BUG_ON(mvm->scan_cmd == NULL); |
@@ -304,17 +305,16 @@ int iwl_mvm_scan_request(struct iwl_mvm *mvm, | |||
304 | memset(cmd, 0, sizeof(struct iwl_scan_cmd) + | 305 | memset(cmd, 0, sizeof(struct iwl_scan_cmd) + |
305 | mvm->fw->ucode_capa.max_probe_length + | 306 | mvm->fw->ucode_capa.max_probe_length + |
306 | (MAX_NUM_SCAN_CHANNELS * sizeof(struct iwl_scan_channel))); | 307 | (MAX_NUM_SCAN_CHANNELS * sizeof(struct iwl_scan_channel))); |
307 | ieee80211_iterate_active_interfaces_atomic(mvm->hw, | 308 | |
308 | IEEE80211_IFACE_ITER_NORMAL, | ||
309 | iwl_mvm_vif_assoc_iterator, | ||
310 | &is_assoc); | ||
311 | cmd->channel_count = (u8)req->n_channels; | 309 | cmd->channel_count = (u8)req->n_channels; |
312 | cmd->quiet_time = cpu_to_le16(IWL_ACTIVE_QUIET_TIME); | 310 | cmd->quiet_time = cpu_to_le16(IWL_ACTIVE_QUIET_TIME); |
313 | cmd->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH); | 311 | cmd->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH); |
314 | cmd->rxchain_sel_flags = iwl_mvm_scan_rx_chain(mvm); | 312 | cmd->rxchain_sel_flags = iwl_mvm_scan_rx_chain(mvm); |
315 | cmd->max_out_time = iwl_mvm_scan_max_out_time(vif, req->flags, | 313 | |
316 | is_assoc); | 314 | iwl_mvm_scan_calc_params(mvm, ¶ms); |
317 | cmd->suspend_time = iwl_mvm_scan_suspend_time(vif, is_assoc); | 315 | cmd->max_out_time = cpu_to_le32(params.max_out_time); |
316 | cmd->suspend_time = cpu_to_le32(params.suspend_time); | ||
317 | |||
318 | cmd->rxon_flags = iwl_mvm_scan_rxon_flags(req); | 318 | cmd->rxon_flags = iwl_mvm_scan_rxon_flags(req); |
319 | cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP | | 319 | cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP | |
320 | MAC_FILTER_IN_BEACON); | 320 | MAC_FILTER_IN_BEACON); |
@@ -556,12 +556,8 @@ static void iwl_build_scan_cmd(struct iwl_mvm *mvm, | |||
556 | struct cfg80211_sched_scan_request *req, | 556 | struct cfg80211_sched_scan_request *req, |
557 | struct iwl_scan_offload_cmd *scan) | 557 | struct iwl_scan_offload_cmd *scan) |
558 | { | 558 | { |
559 | bool is_assoc = false; | 559 | struct iwl_mvm_scan_params params = {}; |
560 | 560 | ||
561 | ieee80211_iterate_active_interfaces_atomic(mvm->hw, | ||
562 | IEEE80211_IFACE_ITER_NORMAL, | ||
563 | iwl_mvm_vif_assoc_iterator, | ||
564 | &is_assoc); | ||
565 | scan->channel_count = | 561 | scan->channel_count = |
566 | mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels + | 562 | mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels + |
567 | mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; | 563 | mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; |
@@ -569,9 +565,11 @@ static void iwl_build_scan_cmd(struct iwl_mvm *mvm, | |||
569 | scan->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH); | 565 | scan->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH); |
570 | scan->good_CRC_th = IWL_GOOD_CRC_TH_DEFAULT; | 566 | scan->good_CRC_th = IWL_GOOD_CRC_TH_DEFAULT; |
571 | scan->rx_chain = iwl_mvm_scan_rx_chain(mvm); | 567 | scan->rx_chain = iwl_mvm_scan_rx_chain(mvm); |
572 | scan->max_out_time = iwl_mvm_scan_max_out_time(vif, req->flags, | 568 | |
573 | is_assoc); | 569 | iwl_mvm_scan_calc_params(mvm, ¶ms); |
574 | scan->suspend_time = iwl_mvm_scan_suspend_time(vif, is_assoc); | 570 | scan->max_out_time = cpu_to_le32(params.max_out_time); |
571 | scan->suspend_time = cpu_to_le32(params.suspend_time); | ||
572 | |||
575 | scan->filter_flags |= cpu_to_le32(MAC_FILTER_ACCEPT_GRP | | 573 | scan->filter_flags |= cpu_to_le32(MAC_FILTER_ACCEPT_GRP | |
576 | MAC_FILTER_IN_BEACON); | 574 | MAC_FILTER_IN_BEACON); |
577 | scan->scan_type = cpu_to_le32(SCAN_TYPE_BACKGROUND); | 575 | scan->scan_type = cpu_to_le32(SCAN_TYPE_BACKGROUND); |