pm.c 2.6 KB

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