aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelmut Schaa <helmut.schaa@googlemail.com>2009-07-23 06:14:04 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-27 15:24:16 -0400
commitfbe9c429f195111bbf7f1630efa19aee295fd8e7 (patch)
tree80556ac48bfa0e7d60db63e6c71b0bbf58143263
parent2fb3f028a9a46bd344329766257699b4acb36525 (diff)
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: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/mac80211/ibss.c2
-rw-r--r--net/mac80211/ieee80211_i.h7
-rw-r--r--net/mac80211/iface.c4
-rw-r--r--net/mac80211/main.c2
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mlme.c8
-rw-r--r--net/mac80211/rx.c6
-rw-r--r--net/mac80211/scan.c23
-rw-r--r--net/mac80211/tx.c6
9 files changed, 31 insertions, 29 deletions
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 8e2220000e5c..6e3cca65c460 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -742,7 +742,7 @@ static void ieee80211_ibss_work(struct work_struct *work)
742 if (!netif_running(sdata->dev)) 742 if (!netif_running(sdata->dev))
743 return; 743 return;
744 744
745 if (local->sw_scanning || local->hw_scanning) 745 if (local->scanning)
746 return; 746 return;
747 747
748 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC)) 748 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC))
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 4166418b4aa7..783a125402b0 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -570,6 +570,11 @@ enum queue_stop_reason {
570 IEEE80211_QUEUE_STOP_REASON_SKB_ADD, 570 IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
571}; 571};
572 572
573enum {
574 SCAN_SW_SCANNING,
575 SCAN_HW_SCANNING
576};
577
573struct ieee80211_local { 578struct ieee80211_local {
574 /* embed the driver visible part. 579 /* embed the driver visible part.
575 * don't cast (use the static inlines below), but we keep 580 * don't cast (use the static inlines below), but we keep
@@ -668,7 +673,7 @@ struct ieee80211_local {
668 673
669 /* Scanning and BSS list */ 674 /* Scanning and BSS list */
670 struct mutex scan_mtx; 675 struct mutex scan_mtx;
671 bool sw_scanning, hw_scanning; 676 unsigned long scanning;
672 struct cfg80211_ssid scan_ssid; 677 struct cfg80211_ssid scan_ssid;
673 struct cfg80211_scan_request int_scan_req; 678 struct cfg80211_scan_request int_scan_req;
674 struct cfg80211_scan_request *scan_req; 679 struct cfg80211_scan_request *scan_req;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 0cb29df09e35..d79a21105042 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -518,7 +518,7 @@ static int ieee80211_stop(struct net_device *dev)
518 * the scan_sdata is NULL already don't send out a 518 * the scan_sdata is NULL already don't send out a
519 * scan event to userspace -- the scan is incomplete. 519 * scan event to userspace -- the scan is incomplete.
520 */ 520 */
521 if (local->sw_scanning) 521 if (test_bit(SCAN_SW_SCANNING, &local->scanning))
522 ieee80211_scan_completed(&local->hw, true); 522 ieee80211_scan_completed(&local->hw, true);
523 } 523 }
524 524
@@ -920,7 +920,7 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local)
920 struct ieee80211_sub_if_data *sdata; 920 struct ieee80211_sub_if_data *sdata;
921 int count = 0; 921 int count = 0;
922 922
923 if (local->hw_scanning || local->sw_scanning) 923 if (local->scanning)
924 return ieee80211_idle_off(local, "scanning"); 924 return ieee80211_idle_off(local, "scanning");
925 925
926 list_for_each_entry(sdata, &local->interfaces, list) { 926 list_for_each_entry(sdata, &local->interfaces, list) {
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 02cabbffc19a..c1a799194fff 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -198,7 +198,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
198 } 198 }
199 199
200 if (changed & BSS_CHANGED_BEACON_ENABLED) { 200 if (changed & BSS_CHANGED_BEACON_ENABLED) {
201 if (local->sw_scanning) { 201 if (test_bit(SCAN_SW_SCANNING, &local->scanning)) {
202 sdata->vif.bss_conf.enable_beacon = false; 202 sdata->vif.bss_conf.enable_beacon = false;
203 } else { 203 } else {
204 /* 204 /*
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 8a97b1423088..9a3826978b1c 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -597,7 +597,7 @@ static void ieee80211_mesh_work(struct work_struct *work)
597 if (!netif_running(sdata->dev)) 597 if (!netif_running(sdata->dev))
598 return; 598 return;
599 599
600 if (local->sw_scanning || local->hw_scanning) 600 if (local->scanning)
601 return; 601 return;
602 602
603 while ((skb = skb_dequeue(&ifmsh->skb_queue))) 603 while ((skb = skb_dequeue(&ifmsh->skb_queue)))
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 523c0d994d15..52b6f8327a5b 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -581,7 +581,7 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
581 if (!ifmgd->associated) 581 if (!ifmgd->associated)
582 return; 582 return;
583 583
584 if (sdata->local->sw_scanning || sdata->local->hw_scanning) 584 if (sdata->local->scanning)
585 return; 585 return;
586 586
587 /* Disregard subsequent beacons if we are already running a timer 587 /* Disregard subsequent beacons if we are already running a timer
@@ -639,7 +639,7 @@ static void ieee80211_enable_ps(struct ieee80211_local *local,
639 * If we are scanning right now then the parameters will 639 * If we are scanning right now then the parameters will
640 * take effect when scan finishes. 640 * take effect when scan finishes.
641 */ 641 */
642 if (local->hw_scanning || local->sw_scanning) 642 if (local->scanning)
643 return; 643 return;
644 644
645 if (conf->dynamic_ps_timeout > 0 && 645 if (conf->dynamic_ps_timeout > 0 &&
@@ -2038,7 +2038,7 @@ static void ieee80211_sta_work(struct work_struct *work)
2038 if (!netif_running(sdata->dev)) 2038 if (!netif_running(sdata->dev))
2039 return; 2039 return;
2040 2040
2041 if (local->sw_scanning || local->hw_scanning) 2041 if (local->scanning)
2042 return; 2042 return;
2043 2043
2044 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) 2044 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
@@ -2213,7 +2213,7 @@ static void ieee80211_sta_monitor_work(struct work_struct *work)
2213 container_of(work, struct ieee80211_sub_if_data, 2213 container_of(work, struct ieee80211_sub_if_data,
2214 u.mgd.monitor_work); 2214 u.mgd.monitor_work);
2215 2215
2216 if (sdata->local->sw_scanning || sdata->local->hw_scanning) 2216 if (sdata->local->scanning)
2217 return; 2217 return;
2218 2218
2219 ieee80211_mgd_probe_ap(sdata, false); 2219 ieee80211_mgd_probe_ap(sdata, false);
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index d9df819eef3b..9c1679d124ba 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -418,10 +418,10 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
418 struct ieee80211_local *local = rx->local; 418 struct ieee80211_local *local = rx->local;
419 struct sk_buff *skb = rx->skb; 419 struct sk_buff *skb = rx->skb;
420 420
421 if (unlikely(local->hw_scanning)) 421 if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning)))
422 return ieee80211_scan_rx(rx->sdata, skb); 422 return ieee80211_scan_rx(rx->sdata, skb);
423 423
424 if (unlikely(local->sw_scanning)) { 424 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning))) {
425 /* drop all the other packets during a software scan anyway */ 425 /* drop all the other packets during a software scan anyway */
426 if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED) 426 if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED)
427 dev_kfree_skb(skb); 427 dev_kfree_skb(skb);
@@ -2136,7 +2136,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2136 return; 2136 return;
2137 } 2137 }
2138 2138
2139 if (unlikely(local->sw_scanning || local->hw_scanning)) 2139 if (unlikely(local->scanning))
2140 rx.flags |= IEEE80211_RX_IN_SCAN; 2140 rx.flags |= IEEE80211_RX_IN_SCAN;
2141 2141
2142 ieee80211_parse_qos(&rx); 2142 ieee80211_parse_qos(&rx);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 48f910ae95c0..4233c3d700ce 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -265,7 +265,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
265 265
266 mutex_lock(&local->scan_mtx); 266 mutex_lock(&local->scan_mtx);
267 267
268 if (WARN_ON(!local->hw_scanning && !local->sw_scanning)) { 268 if (WARN_ON(!local->scanning)) {
269 mutex_unlock(&local->scan_mtx); 269 mutex_unlock(&local->scan_mtx);
270 return; 270 return;
271 } 271 }
@@ -275,16 +275,15 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
275 return; 275 return;
276 } 276 }
277 277
278 if (local->hw_scanning) 278 if (test_bit(SCAN_HW_SCANNING, &local->scanning))
279 ieee80211_restore_scan_ies(local); 279 ieee80211_restore_scan_ies(local);
280 280
281 if (local->scan_req != &local->int_scan_req) 281 if (local->scan_req != &local->int_scan_req)
282 cfg80211_scan_done(local->scan_req, aborted); 282 cfg80211_scan_done(local->scan_req, aborted);
283 local->scan_req = NULL; 283 local->scan_req = NULL;
284 284
285 was_hw_scan = local->hw_scanning; 285 was_hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
286 local->hw_scanning = false; 286 local->scanning = 0;
287 local->sw_scanning = false;
288 local->scan_channel = NULL; 287 local->scan_channel = NULL;
289 288
290 /* we only have to protect scan_req and hw/sw scan */ 289 /* 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 } 433 }
435 434
436 if (local->ops->hw_scan) 435 if (local->ops->hw_scan)
437 local->hw_scanning = true; 436 __set_bit(SCAN_HW_SCANNING, &local->scanning);
438 else 437 else
439 local->sw_scanning = true; 438 __set_bit(SCAN_SW_SCANNING, &local->scanning);
440 /* 439 /*
441 * Kicking off the scan need not be protected, 440 * Kicking off the scan need not be protected,
442 * only the scan variable stuff, since now 441 * only the scan variable stuff, since now
@@ -459,11 +458,9 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
459 mutex_lock(&local->scan_mtx); 458 mutex_lock(&local->scan_mtx);
460 459
461 if (rc) { 460 if (rc) {
462 if (local->ops->hw_scan) { 461 if (local->ops->hw_scan)
463 local->hw_scanning = false;
464 ieee80211_restore_scan_ies(local); 462 ieee80211_restore_scan_ies(local);
465 } else 463 local->scanning = 0;
466 local->sw_scanning = false;
467 464
468 ieee80211_recalc_idle(local); 465 ieee80211_recalc_idle(local);
469 466
@@ -572,7 +569,7 @@ void ieee80211_scan_work(struct work_struct *work)
572 return; 569 return;
573 } 570 }
574 571
575 if (local->scan_req && !(local->sw_scanning || local->hw_scanning)) { 572 if (local->scan_req && !local->scanning) {
576 struct cfg80211_scan_request *req = local->scan_req; 573 struct cfg80211_scan_request *req = local->scan_req;
577 int rc; 574 int rc;
578 575
@@ -663,7 +660,7 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
663 * queued -- mostly at suspend under RTNL. 660 * queued -- mostly at suspend under RTNL.
664 */ 661 */
665 mutex_lock(&local->scan_mtx); 662 mutex_lock(&local->scan_mtx);
666 swscan = local->sw_scanning; 663 swscan = test_bit(SCAN_SW_SCANNING, &local->scanning);
667 mutex_unlock(&local->scan_mtx); 664 mutex_unlock(&local->scan_mtx);
668 665
669 if (swscan) 666 if (swscan)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index ffd3b10f2696..d7491dc2a65c 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -192,7 +192,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
192 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) 192 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED))
193 return TX_CONTINUE; 193 return TX_CONTINUE;
194 194
195 if (unlikely(tx->local->sw_scanning) && 195 if (unlikely(test_bit(SCAN_SW_SCANNING, &tx->local->scanning)) &&
196 !ieee80211_is_probe_req(hdr->frame_control) && 196 !ieee80211_is_probe_req(hdr->frame_control) &&
197 !ieee80211_is_nullfunc(hdr->frame_control)) 197 !ieee80211_is_nullfunc(hdr->frame_control))
198 /* 198 /*
@@ -552,7 +552,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
552 * Lets not bother rate control if we're associated and cannot 552 * Lets not bother rate control if we're associated and cannot
553 * talk to the sta. This should not happen. 553 * talk to the sta. This should not happen.
554 */ 554 */
555 if (WARN((tx->local->sw_scanning) && 555 if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) &&
556 (sta_flags & WLAN_STA_ASSOC) && 556 (sta_flags & WLAN_STA_ASSOC) &&
557 !rate_usable_index_exists(sband, &tx->sta->sta), 557 !rate_usable_index_exists(sband, &tx->sta->sta),
558 "%s: Dropped data frame as no usable bitrate found while " 558 "%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 1411
1412 if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && 1412 if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
1413 local->hw.conf.dynamic_ps_timeout > 0 && 1413 local->hw.conf.dynamic_ps_timeout > 0 &&
1414 !local->sw_scanning && !local->hw_scanning && local->ps_sdata) { 1414 !(local->scanning) && local->ps_sdata) {
1415 if (local->hw.conf.flags & IEEE80211_CONF_PS) { 1415 if (local->hw.conf.flags & IEEE80211_CONF_PS) {
1416 ieee80211_stop_queues_by_reason(&local->hw, 1416 ieee80211_stop_queues_by_reason(&local->hw,
1417 IEEE80211_QUEUE_STOP_REASON_PS); 1417 IEEE80211_QUEUE_STOP_REASON_PS);