pm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. unsigned long flags;
  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 */
  34. rcu_read_lock();
  35. if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
  36. list_for_each_entry_rcu(sta, &local->sta_list, list) {
  37. set_sta_flags(sta, WLAN_STA_SUSPEND);
  38. ieee80211_sta_tear_down_BA_sessions(sta);
  39. }
  40. }
  41. rcu_read_unlock();
  42. /* remove STAs */
  43. spin_lock_irqsave(&local->sta_lock, flags);
  44. list_for_each_entry(sta, &local->sta_list, list) {
  45. if (local->ops->sta_notify) {
  46. sdata = sta->sdata;
  47. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  48. sdata = container_of(sdata->bss,
  49. struct ieee80211_sub_if_data,
  50. u.ap);
  51. drv_sta_notify(local, sdata, STA_NOTIFY_REMOVE,
  52. &sta->sta);
  53. }
  54. mesh_plink_quiesce(sta);
  55. }
  56. spin_unlock_irqrestore(&local->sta_lock, flags);
  57. /* remove all interfaces */
  58. list_for_each_entry(sdata, &local->interfaces, list) {
  59. switch(sdata->vif.type) {
  60. case NL80211_IFTYPE_STATION:
  61. ieee80211_sta_quiesce(sdata);
  62. break;
  63. case NL80211_IFTYPE_ADHOC:
  64. ieee80211_ibss_quiesce(sdata);
  65. break;
  66. case NL80211_IFTYPE_MESH_POINT:
  67. ieee80211_mesh_quiesce(sdata);
  68. break;
  69. case NL80211_IFTYPE_AP_VLAN:
  70. case NL80211_IFTYPE_MONITOR:
  71. /* don't tell driver about this */
  72. continue;
  73. default:
  74. break;
  75. }
  76. if (!ieee80211_sdata_running(sdata))
  77. continue;
  78. /* disable beaconing */
  79. ieee80211_bss_info_change_notify(sdata,
  80. BSS_CHANGED_BEACON_ENABLED);
  81. drv_remove_interface(local, &sdata->vif);
  82. }
  83. /* stop hardware - this must stop RX */
  84. if (local->open_count)
  85. ieee80211_stop_device(local);
  86. local->suspended = true;
  87. /* need suspended to be visible before quiescing is false */
  88. barrier();
  89. local->quiescing = false;
  90. return 0;
  91. }
  92. /*
  93. * __ieee80211_resume() is a static inline which just calls
  94. * ieee80211_reconfig(), which is also needed for hardware
  95. * hang/firmware failure/etc. recovery.
  96. */