pm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. flush_workqueue(local->hw.workqueue);
  12. /* disable keys */
  13. list_for_each_entry(sdata, &local->interfaces, list)
  14. ieee80211_disable_keys(sdata);
  15. /* remove STAs */
  16. list_for_each_entry(sta, &local->sta_list, list) {
  17. if (local->ops->sta_notify) {
  18. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  19. sdata = container_of(sdata->bss,
  20. struct ieee80211_sub_if_data,
  21. u.ap);
  22. local->ops->sta_notify(hw, &sdata->vif,
  23. STA_NOTIFY_REMOVE, &sta->sta);
  24. }
  25. }
  26. /* remove all interfaces */
  27. list_for_each_entry(sdata, &local->interfaces, list) {
  28. if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  29. sdata->vif.type != NL80211_IFTYPE_MONITOR &&
  30. netif_running(sdata->dev)) {
  31. conf.vif = &sdata->vif;
  32. conf.type = sdata->vif.type;
  33. conf.mac_addr = sdata->dev->dev_addr;
  34. local->ops->remove_interface(hw, &conf);
  35. }
  36. }
  37. /* flush again, in case driver queued work */
  38. flush_workqueue(local->hw.workqueue);
  39. /* stop hardware */
  40. if (local->open_count) {
  41. ieee80211_led_radio(local, false);
  42. local->ops->stop(hw);
  43. }
  44. return 0;
  45. }
  46. int __ieee80211_resume(struct ieee80211_hw *hw)
  47. {
  48. struct ieee80211_local *local = hw_to_local(hw);
  49. struct ieee80211_sub_if_data *sdata;
  50. struct ieee80211_if_init_conf conf;
  51. struct sta_info *sta;
  52. int res;
  53. /* restart hardware */
  54. if (local->open_count) {
  55. res = local->ops->start(hw);
  56. ieee80211_led_radio(local, hw->conf.radio_enabled);
  57. }
  58. /* add interfaces */
  59. list_for_each_entry(sdata, &local->interfaces, list) {
  60. if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  61. sdata->vif.type != NL80211_IFTYPE_MONITOR &&
  62. netif_running(sdata->dev)) {
  63. conf.vif = &sdata->vif;
  64. conf.type = sdata->vif.type;
  65. conf.mac_addr = sdata->dev->dev_addr;
  66. res = local->ops->add_interface(hw, &conf);
  67. }
  68. }
  69. /* add STAs back */
  70. list_for_each_entry(sta, &local->sta_list, list) {
  71. if (local->ops->sta_notify) {
  72. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  73. sdata = container_of(sdata->bss,
  74. struct ieee80211_sub_if_data,
  75. u.ap);
  76. local->ops->sta_notify(hw, &sdata->vif,
  77. STA_NOTIFY_ADD, &sta->sta);
  78. }
  79. }
  80. /* add back keys */
  81. list_for_each_entry(sdata, &local->interfaces, list)
  82. if (netif_running(sdata->dev))
  83. ieee80211_enable_keys(sdata);
  84. /* setup RTS threshold */
  85. if (local->ops->set_rts_threshold)
  86. local->ops->set_rts_threshold(hw, local->rts_threshold);
  87. /* reconfigure hardware */
  88. ieee80211_hw_config(local, ~0);
  89. netif_addr_lock_bh(local->mdev);
  90. ieee80211_configure_filter(local);
  91. netif_addr_unlock_bh(local->mdev);
  92. return 0;
  93. }