提交 fbe9c429 编写于 作者: H Helmut Schaa 提交者: John W. Linville

mac80211: Replace {sw, hw}_scanning variables with a bitfield

Use a bitfield to store the current scan mode instead of two boolean
variables {sw,hw}_scanning. This patch does not introduce functional
changes but allows us to enhance the scan flags later (for example
for background scanning).
Signed-off-by: NHelmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 2fb3f028
...@@ -742,7 +742,7 @@ static void ieee80211_ibss_work(struct work_struct *work) ...@@ -742,7 +742,7 @@ static void ieee80211_ibss_work(struct work_struct *work)
if (!netif_running(sdata->dev)) if (!netif_running(sdata->dev))
return; return;
if (local->sw_scanning || local->hw_scanning) if (local->scanning)
return; return;
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC)) if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC))
......
...@@ -570,6 +570,11 @@ enum queue_stop_reason { ...@@ -570,6 +570,11 @@ enum queue_stop_reason {
IEEE80211_QUEUE_STOP_REASON_SKB_ADD, IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
}; };
enum {
SCAN_SW_SCANNING,
SCAN_HW_SCANNING
};
struct ieee80211_local { struct ieee80211_local {
/* embed the driver visible part. /* embed the driver visible part.
* don't cast (use the static inlines below), but we keep * don't cast (use the static inlines below), but we keep
...@@ -668,7 +673,7 @@ struct ieee80211_local { ...@@ -668,7 +673,7 @@ struct ieee80211_local {
/* Scanning and BSS list */ /* Scanning and BSS list */
struct mutex scan_mtx; struct mutex scan_mtx;
bool sw_scanning, hw_scanning; unsigned long scanning;
struct cfg80211_ssid scan_ssid; struct cfg80211_ssid scan_ssid;
struct cfg80211_scan_request int_scan_req; struct cfg80211_scan_request int_scan_req;
struct cfg80211_scan_request *scan_req; struct cfg80211_scan_request *scan_req;
......
...@@ -518,7 +518,7 @@ static int ieee80211_stop(struct net_device *dev) ...@@ -518,7 +518,7 @@ static int ieee80211_stop(struct net_device *dev)
* the scan_sdata is NULL already don't send out a * the scan_sdata is NULL already don't send out a
* scan event to userspace -- the scan is incomplete. * scan event to userspace -- the scan is incomplete.
*/ */
if (local->sw_scanning) if (test_bit(SCAN_SW_SCANNING, &local->scanning))
ieee80211_scan_completed(&local->hw, true); ieee80211_scan_completed(&local->hw, true);
} }
...@@ -920,7 +920,7 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local) ...@@ -920,7 +920,7 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local)
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
int count = 0; int count = 0;
if (local->hw_scanning || local->sw_scanning) if (local->scanning)
return ieee80211_idle_off(local, "scanning"); return ieee80211_idle_off(local, "scanning");
list_for_each_entry(sdata, &local->interfaces, list) { list_for_each_entry(sdata, &local->interfaces, list) {
......
...@@ -198,7 +198,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, ...@@ -198,7 +198,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
} }
if (changed & BSS_CHANGED_BEACON_ENABLED) { if (changed & BSS_CHANGED_BEACON_ENABLED) {
if (local->sw_scanning) { if (test_bit(SCAN_SW_SCANNING, &local->scanning)) {
sdata->vif.bss_conf.enable_beacon = false; sdata->vif.bss_conf.enable_beacon = false;
} else { } else {
/* /*
......
...@@ -597,7 +597,7 @@ static void ieee80211_mesh_work(struct work_struct *work) ...@@ -597,7 +597,7 @@ static void ieee80211_mesh_work(struct work_struct *work)
if (!netif_running(sdata->dev)) if (!netif_running(sdata->dev))
return; return;
if (local->sw_scanning || local->hw_scanning) if (local->scanning)
return; return;
while ((skb = skb_dequeue(&ifmsh->skb_queue))) while ((skb = skb_dequeue(&ifmsh->skb_queue)))
......
...@@ -581,7 +581,7 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, ...@@ -581,7 +581,7 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
if (!ifmgd->associated) if (!ifmgd->associated)
return; return;
if (sdata->local->sw_scanning || sdata->local->hw_scanning) if (sdata->local->scanning)
return; return;
/* Disregard subsequent beacons if we are already running a timer /* Disregard subsequent beacons if we are already running a timer
...@@ -639,7 +639,7 @@ static void ieee80211_enable_ps(struct ieee80211_local *local, ...@@ -639,7 +639,7 @@ static void ieee80211_enable_ps(struct ieee80211_local *local,
* If we are scanning right now then the parameters will * If we are scanning right now then the parameters will
* take effect when scan finishes. * take effect when scan finishes.
*/ */
if (local->hw_scanning || local->sw_scanning) if (local->scanning)
return; return;
if (conf->dynamic_ps_timeout > 0 && if (conf->dynamic_ps_timeout > 0 &&
...@@ -2038,7 +2038,7 @@ static void ieee80211_sta_work(struct work_struct *work) ...@@ -2038,7 +2038,7 @@ static void ieee80211_sta_work(struct work_struct *work)
if (!netif_running(sdata->dev)) if (!netif_running(sdata->dev))
return; return;
if (local->sw_scanning || local->hw_scanning) if (local->scanning)
return; return;
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
...@@ -2213,7 +2213,7 @@ static void ieee80211_sta_monitor_work(struct work_struct *work) ...@@ -2213,7 +2213,7 @@ static void ieee80211_sta_monitor_work(struct work_struct *work)
container_of(work, struct ieee80211_sub_if_data, container_of(work, struct ieee80211_sub_if_data,
u.mgd.monitor_work); u.mgd.monitor_work);
if (sdata->local->sw_scanning || sdata->local->hw_scanning) if (sdata->local->scanning)
return; return;
ieee80211_mgd_probe_ap(sdata, false); ieee80211_mgd_probe_ap(sdata, false);
......
...@@ -418,10 +418,10 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx) ...@@ -418,10 +418,10 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
struct ieee80211_local *local = rx->local; struct ieee80211_local *local = rx->local;
struct sk_buff *skb = rx->skb; struct sk_buff *skb = rx->skb;
if (unlikely(local->hw_scanning)) if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning)))
return ieee80211_scan_rx(rx->sdata, skb); return ieee80211_scan_rx(rx->sdata, skb);
if (unlikely(local->sw_scanning)) { if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning))) {
/* drop all the other packets during a software scan anyway */ /* drop all the other packets during a software scan anyway */
if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED) if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED)
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -2136,7 +2136,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, ...@@ -2136,7 +2136,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
return; return;
} }
if (unlikely(local->sw_scanning || local->hw_scanning)) if (unlikely(local->scanning))
rx.flags |= IEEE80211_RX_IN_SCAN; rx.flags |= IEEE80211_RX_IN_SCAN;
ieee80211_parse_qos(&rx); ieee80211_parse_qos(&rx);
......
...@@ -265,7 +265,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) ...@@ -265,7 +265,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
mutex_lock(&local->scan_mtx); mutex_lock(&local->scan_mtx);
if (WARN_ON(!local->hw_scanning && !local->sw_scanning)) { if (WARN_ON(!local->scanning)) {
mutex_unlock(&local->scan_mtx); mutex_unlock(&local->scan_mtx);
return; return;
} }
...@@ -275,16 +275,15 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) ...@@ -275,16 +275,15 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
return; return;
} }
if (local->hw_scanning) if (test_bit(SCAN_HW_SCANNING, &local->scanning))
ieee80211_restore_scan_ies(local); ieee80211_restore_scan_ies(local);
if (local->scan_req != &local->int_scan_req) if (local->scan_req != &local->int_scan_req)
cfg80211_scan_done(local->scan_req, aborted); cfg80211_scan_done(local->scan_req, aborted);
local->scan_req = NULL; local->scan_req = NULL;
was_hw_scan = local->hw_scanning; was_hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
local->hw_scanning = false; local->scanning = 0;
local->sw_scanning = false;
local->scan_channel = NULL; local->scan_channel = NULL;
/* we only have to protect scan_req and hw/sw scan */ /* we only have to protect scan_req and hw/sw scan */
...@@ -434,9 +433,9 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, ...@@ -434,9 +433,9 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
} }
if (local->ops->hw_scan) if (local->ops->hw_scan)
local->hw_scanning = true; __set_bit(SCAN_HW_SCANNING, &local->scanning);
else else
local->sw_scanning = true; __set_bit(SCAN_SW_SCANNING, &local->scanning);
/* /*
* Kicking off the scan need not be protected, * Kicking off the scan need not be protected,
* only the scan variable stuff, since now * only the scan variable stuff, since now
...@@ -459,11 +458,9 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, ...@@ -459,11 +458,9 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
mutex_lock(&local->scan_mtx); mutex_lock(&local->scan_mtx);
if (rc) { if (rc) {
if (local->ops->hw_scan) { if (local->ops->hw_scan)
local->hw_scanning = false;
ieee80211_restore_scan_ies(local); ieee80211_restore_scan_ies(local);
} else local->scanning = 0;
local->sw_scanning = false;
ieee80211_recalc_idle(local); ieee80211_recalc_idle(local);
...@@ -572,7 +569,7 @@ void ieee80211_scan_work(struct work_struct *work) ...@@ -572,7 +569,7 @@ void ieee80211_scan_work(struct work_struct *work)
return; return;
} }
if (local->scan_req && !(local->sw_scanning || local->hw_scanning)) { if (local->scan_req && !local->scanning) {
struct cfg80211_scan_request *req = local->scan_req; struct cfg80211_scan_request *req = local->scan_req;
int rc; int rc;
...@@ -663,7 +660,7 @@ void ieee80211_scan_cancel(struct ieee80211_local *local) ...@@ -663,7 +660,7 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
* queued -- mostly at suspend under RTNL. * queued -- mostly at suspend under RTNL.
*/ */
mutex_lock(&local->scan_mtx); mutex_lock(&local->scan_mtx);
swscan = local->sw_scanning; swscan = test_bit(SCAN_SW_SCANNING, &local->scanning);
mutex_unlock(&local->scan_mtx); mutex_unlock(&local->scan_mtx);
if (swscan) if (swscan)
......
...@@ -192,7 +192,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) ...@@ -192,7 +192,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED))
return TX_CONTINUE; return TX_CONTINUE;
if (unlikely(tx->local->sw_scanning) && if (unlikely(test_bit(SCAN_SW_SCANNING, &tx->local->scanning)) &&
!ieee80211_is_probe_req(hdr->frame_control) && !ieee80211_is_probe_req(hdr->frame_control) &&
!ieee80211_is_nullfunc(hdr->frame_control)) !ieee80211_is_nullfunc(hdr->frame_control))
/* /*
...@@ -552,7 +552,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) ...@@ -552,7 +552,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
* Lets not bother rate control if we're associated and cannot * Lets not bother rate control if we're associated and cannot
* talk to the sta. This should not happen. * talk to the sta. This should not happen.
*/ */
if (WARN((tx->local->sw_scanning) && if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) &&
(sta_flags & WLAN_STA_ASSOC) && (sta_flags & WLAN_STA_ASSOC) &&
!rate_usable_index_exists(sband, &tx->sta->sta), !rate_usable_index_exists(sband, &tx->sta->sta),
"%s: Dropped data frame as no usable bitrate found while " "%s: Dropped data frame as no usable bitrate found while "
...@@ -1411,7 +1411,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, ...@@ -1411,7 +1411,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
local->hw.conf.dynamic_ps_timeout > 0 && local->hw.conf.dynamic_ps_timeout > 0 &&
!local->sw_scanning && !local->hw_scanning && local->ps_sdata) { !(local->scanning) && local->ps_sdata) {
if (local->hw.conf.flags & IEEE80211_CONF_PS) { if (local->hw.conf.flags & IEEE80211_CONF_PS) {
ieee80211_stop_queues_by_reason(&local->hw, ieee80211_stop_queues_by_reason(&local->hw,
IEEE80211_QUEUE_STOP_REASON_PS); IEEE80211_QUEUE_STOP_REASON_PS);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册