pm.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #include <net/mac80211.h>
  2. #include <net/rtnetlink.h>
  3. #include "ieee80211_i.h"
  4. #include "mesh.h"
  5. #include "driver-ops.h"
  6. #include "led.h"
  7. int __ieee80211_suspend(struct ieee80211_hw *hw)
  8. {
  9. struct ieee80211_local *local = hw_to_local(hw);
  10. struct ieee80211_sub_if_data *sdata;
  11. struct sta_info *sta;
  12. if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)))
  13. ieee80211_scan_cancel(local);
  14. ieee80211_stop_queues_by_reason(hw,
  15. IEEE80211_QUEUE_STOP_REASON_SUSPEND);
  16. /* flush out all packets */
  17. synchronize_net();
  18. local->quiescing = true;
  19. /* make quiescing visible to timers everywhere */
  20. mb();
  21. flush_workqueue(local->workqueue);
  22. /* Don't try to run timers while suspended. */
  23. del_timer_sync(&local->sta_cleanup);
  24. /*
  25. * Note that this particular timer doesn't need to be
  26. * restarted at resume.
  27. */
  28. cancel_work_sync(&local->dynamic_ps_enable_work);
  29. del_timer_sync(&local->dynamic_ps_timer);
  30. /* disable keys */
  31. list_for_each_entry(sdata, &local->interfaces, list)
  32. ieee80211_disable_keys(sdata);
  33. /* tear down aggregation sessions and remove STAs */
  34. mutex_lock(&local->sta_mtx);
  35. list_for_each_entry(sta, &local->sta_list, list) {
  36. if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
  37. set_sta_flags(sta, WLAN_STA_BLOCK_BA);
  38. ieee80211_sta_tear_down_BA_sessions(sta);
  39. }
  40. if (sta->uploaded) {
  41. sdata = sta->sdata;
  42. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  43. sdata = container_of(sdata->bss,
  44. struct ieee80211_sub_if_data,
  45. u.ap);
  46. drv_sta_remove(local, sdata, &sta->sta);
  47. }
  48. mesh_plink_quiesce(sta);
  49. }
  50. mutex_unlock(&local->sta_mtx);
  51. /* remove all interfaces */
  52. list_for_each_entry(sdata, &local->interfaces, list) {
  53. cancel_work_sync(&sdata->work);
  54. switch(sdata->vif.type) {
  55. case NL80211_IFTYPE_STATION:
  56. ieee80211_sta_quiesce(sdata);
  57. break;
  58. case NL80211_IFTYPE_ADHOC:
  59. ieee80211_ibss_quiesce(sdata);
  60. break;
  61. case NL80211_IFTYPE_MESH_POINT:
  62. ieee80211_mesh_quiesce(sdata);
  63. break;
  64. case NL80211_IFTYPE_AP_VLAN:
  65. case NL80211_IFTYPE_MONITOR:
  66. /* don't tell driver about this */
  67. continue;
  68. default:
  69. break;
  70. }
  71. if (!ieee80211_sdata_running(sdata))
  72. continue;
  73. /* disable beaconing */
  74. ieee80211_bss_info_change_notify(sdata,
  75. BSS_CHANGED_BEACON_ENABLED);
  76. drv_remove_interface(local, &sdata->vif);
  77. }
  78. /* stop hardware - this must stop RX */
  79. if (local->open_count)
  80. ieee80211_stop_device(local);
  81. local->suspended = true;
  82. /* need suspended to be visible before quiescing is false */
  83. barrier();
  84. local->quiescing = false;
  85. return 0;
  86. }
  87. /*
  88. * __ieee80211_resume() is a static inline which just calls
  89. * ieee80211_reconfig(), which is also needed for hardware
  90. * hang/firmware failure/etc. recovery.
  91. */