pm.c 2.0 KB

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