pm.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include <net/mac80211.h>
  2. #include <net/rtnetlink.h>
  3. #include "ieee80211_i.h"
  4. #include "driver-ops.h"
  5. #include "led.h"
  6. int __ieee80211_suspend(struct ieee80211_hw *hw)
  7. {
  8. struct ieee80211_local *local = hw_to_local(hw);
  9. struct ieee80211_sub_if_data *sdata;
  10. struct ieee80211_if_init_conf conf;
  11. struct sta_info *sta;
  12. unsigned long flags;
  13. ieee80211_stop_queues_by_reason(hw,
  14. IEEE80211_QUEUE_STOP_REASON_SUSPEND);
  15. flush_workqueue(local->hw.workqueue);
  16. /* disable keys */
  17. list_for_each_entry(sdata, &local->interfaces, list)
  18. ieee80211_disable_keys(sdata);
  19. /* Tear down aggregation sessions */
  20. rcu_read_lock();
  21. if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
  22. list_for_each_entry_rcu(sta, &local->sta_list, list) {
  23. set_sta_flags(sta, WLAN_STA_SUSPEND);
  24. ieee80211_sta_tear_down_BA_sessions(sta);
  25. }
  26. }
  27. rcu_read_unlock();
  28. /* remove STAs */
  29. if (local->ops->sta_notify) {
  30. spin_lock_irqsave(&local->sta_lock, flags);
  31. list_for_each_entry(sta, &local->sta_list, list) {
  32. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  33. sdata = container_of(sdata->bss,
  34. struct ieee80211_sub_if_data,
  35. u.ap);
  36. drv_sta_notify(local, &sdata->vif, STA_NOTIFY_REMOVE,
  37. &sta->sta);
  38. }
  39. spin_unlock_irqrestore(&local->sta_lock, flags);
  40. }
  41. /* remove all interfaces */
  42. list_for_each_entry(sdata, &local->interfaces, list) {
  43. if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  44. sdata->vif.type != NL80211_IFTYPE_MONITOR &&
  45. netif_running(sdata->dev)) {
  46. conf.vif = &sdata->vif;
  47. conf.type = sdata->vif.type;
  48. conf.mac_addr = sdata->dev->dev_addr;
  49. drv_remove_interface(local, &conf);
  50. }
  51. }
  52. /* flush again, in case driver queued work */
  53. flush_workqueue(local->hw.workqueue);
  54. /* stop hardware */
  55. if (local->open_count) {
  56. ieee80211_led_radio(local, false);
  57. drv_stop(local);
  58. }
  59. return 0;
  60. }
  61. /*
  62. * __ieee80211_resume() is a static inline which just calls
  63. * ieee80211_reconfig(), which is also needed for hardware
  64. * hang/firmware failure/etc. recovery.
  65. */