]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
mac80211: resume properly, add suspend/resume test
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 13 Mar 2009 10:44:18 +0000 (11:44 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Sat, 28 Mar 2009 00:13:03 +0000 (20:13 -0400)
When mac80211 resumes, it currently doesn't reconfigure the interfaces
entirely and also doesn't reconfigure BSS information -- fix this.

Also, to be able to test this, add a debugfs file that just calls
the suspend/resume code to see what happens when we go through that,
without needing the time-consuming suspend/resume cycle.

(Original version broke the build for CONFIG_PM=n.  Define alternative
functions for that situation. -- JWL)

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/debugfs.c
net/mac80211/ieee80211_i.h
net/mac80211/pm.c

index e37f557de3f33e5178ccaeb9fdc0f01689b8fc29..210b9b6fecd2a3676c8fe23393c22d87700228b4 100644 (file)
@@ -40,6 +40,10 @@ static const struct file_operations name## _ops = {                  \
        local->debugfs.name = debugfs_create_file(#name, 0400, phyd,    \
                                                  local, &name## _ops);
 
+#define DEBUGFS_ADD_MODE(name, mode)                                   \
+       local->debugfs.name = debugfs_create_file(#name, mode, phyd,    \
+                                                 local, &name## _ops);
+
 #define DEBUGFS_DEL(name)                                              \
        debugfs_remove(local->debugfs.name);                            \
        local->debugfs.name = NULL;
@@ -113,6 +117,24 @@ static const struct file_operations tsf_ops = {
        .open = mac80211_open_file_generic
 };
 
+static ssize_t reset_write(struct file *file, const char __user *user_buf,
+                          size_t count, loff_t *ppos)
+{
+       struct ieee80211_local *local = file->private_data;
+
+       rtnl_lock();
+       __ieee80211_suspend(&local->hw);
+       __ieee80211_resume(&local->hw);
+       rtnl_unlock();
+
+       return count;
+}
+
+static const struct file_operations reset_ops = {
+       .write = reset_write,
+       .open = mac80211_open_file_generic,
+};
+
 /* statistics stuff */
 
 #define DEBUGFS_STATS_FILE(name, buflen, fmt, value...)                        \
@@ -254,6 +276,7 @@ void debugfs_hw_add(struct ieee80211_local *local)
        DEBUGFS_ADD(total_ps_buffered);
        DEBUGFS_ADD(wep_iv);
        DEBUGFS_ADD(tsf);
+       DEBUGFS_ADD_MODE(reset, 0200);
 
        statsd = debugfs_create_dir("statistics", phyd);
        local->debugfs.statistics = statsd;
@@ -308,6 +331,7 @@ void debugfs_hw_del(struct ieee80211_local *local)
        DEBUGFS_DEL(total_ps_buffered);
        DEBUGFS_DEL(wep_iv);
        DEBUGFS_DEL(tsf);
+       DEBUGFS_DEL(reset);
 
        DEBUGFS_STATS_DEL(transmitted_fragment_count);
        DEBUGFS_STATS_DEL(multicast_transmitted_frame_count);
index 7b96d95f48b1b3658063eb0229fe9ab4cdf7ddb7..547cfac218eebbf3a99f485b8f422748b6edd345 100644 (file)
@@ -780,6 +780,7 @@ struct ieee80211_local {
                struct dentry *total_ps_buffered;
                struct dentry *wep_iv;
                struct dentry *tsf;
+               struct dentry *reset;
                struct dentry *statistics;
                struct local_debugfsdentries_statsdentries {
                        struct dentry *transmitted_fragment_count;
@@ -1059,8 +1060,19 @@ void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
                                 u8 pwr_constr_elem_len);
 
 /* Suspend/resume */
+#ifdef CONFIG_PM
 int __ieee80211_suspend(struct ieee80211_hw *hw);
 int __ieee80211_resume(struct ieee80211_hw *hw);
+#else
+static inline int __ieee80211_suspend(struct ieee80211_hw *hw)
+{
+       return 0;
+}
+static inline int __ieee80211_resume(struct ieee80211_hw *hw)
+{
+       return 0;
+}
+#endif
 
 /* utility functions/constants */
 extern void *mac80211_wiphy_privid; /* for wiphy privid */
index 1e6152ac6778d7c900cd2600225774bba9b63a2c..027302326498a681645e981db118077ecff3707e 100644 (file)
@@ -143,6 +143,35 @@ int __ieee80211_resume(struct ieee80211_hw *hw)
        ieee80211_configure_filter(local);
        netif_addr_unlock_bh(local->mdev);
 
+       /* Finally also reconfigure all the BSS information */
+       list_for_each_entry(sdata, &local->interfaces, list) {
+               u32 changed = ~0;
+               if (!netif_running(sdata->dev))
+                       continue;
+               switch (sdata->vif.type) {
+               case NL80211_IFTYPE_STATION:
+                       /* disable beacon change bits */
+                       changed &= ~IEEE80211_IFCC_BEACON;
+                       /* fall through */
+               case NL80211_IFTYPE_ADHOC:
+               case NL80211_IFTYPE_AP:
+               case NL80211_IFTYPE_MESH_POINT:
+                       WARN_ON(ieee80211_if_config(sdata, changed));
+                       ieee80211_bss_info_change_notify(sdata, ~0);
+                       break;
+               case NL80211_IFTYPE_WDS:
+                       break;
+               case NL80211_IFTYPE_AP_VLAN:
+               case NL80211_IFTYPE_MONITOR:
+                       /* ignore virtual */
+                       break;
+               case NL80211_IFTYPE_UNSPECIFIED:
+               case __NL80211_IFTYPE_AFTER_LAST:
+                       WARN_ON(1);
+                       break;
+               }
+       }
+
        ieee80211_wake_queues_by_reason(hw,
                        IEEE80211_QUEUE_STOP_REASON_SUSPEND);