mac80211: config hw when going back on-channel
[linux-2.6.git] / net / mac80211 / debugfs.c
index a694c59..186e02f 100644 (file)
@@ -21,23 +21,43 @@ int mac80211_open_file_generic(struct inode *inode, struct file *file)
        return 0;
 }
 
-#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...)             \
+#define DEBUGFS_FORMAT_BUFFER_SIZE 100
+
+int mac80211_format_buffer(char __user *userbuf, size_t count,
+                                 loff_t *ppos, char *fmt, ...)
+{
+       va_list args;
+       char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
+       int res;
+
+       va_start(args, fmt);
+       res = vscnprintf(buf, sizeof(buf), fmt, args);
+       va_end(args);
+
+       return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+
+#define DEBUGFS_READONLY_FILE_FN(name, fmt, value...)                  \
 static ssize_t name## _read(struct file *file, char __user *userbuf,   \
                            size_t count, loff_t *ppos)                 \
 {                                                                      \
        struct ieee80211_local *local = file->private_data;             \
-       char buf[buflen];                                               \
-       int res;                                                        \
-                                                                       \
-       res = scnprintf(buf, buflen, fmt "\n", ##value);                \
-       return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
-}                                                                      \
                                                                        \
+       return mac80211_format_buffer(userbuf, count, ppos,             \
+                                     fmt "\n", ##value);               \
+}
+
+#define DEBUGFS_READONLY_FILE_OPS(name)                        \
 static const struct file_operations name## _ops = {                    \
        .read = name## _read,                                           \
        .open = mac80211_open_file_generic,                             \
+       .llseek = generic_file_llseek,                                  \
 };
 
+#define DEBUGFS_READONLY_FILE(name, fmt, value...)             \
+       DEBUGFS_READONLY_FILE_FN(name, fmt, value)              \
+       DEBUGFS_READONLY_FILE_OPS(name)
+
 #define DEBUGFS_ADD(name)                                              \
        debugfs_create_file(#name, 0400, phyd, local, &name## _ops);
 
@@ -45,13 +65,17 @@ static const struct file_operations name## _ops = {                 \
        debugfs_create_file(#name, mode, phyd, local, &name## _ops);
 
 
-DEBUGFS_READONLY_FILE(frequency, 20, "%d",
+DEBUGFS_READONLY_FILE(user_power, "%d",
+                     local->user_power_level);
+DEBUGFS_READONLY_FILE(power, "%d",
+                     local->hw.conf.power_level);
+DEBUGFS_READONLY_FILE(frequency, "%d",
                      local->hw.conf.channel->center_freq);
-DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d",
+DEBUGFS_READONLY_FILE(total_ps_buffered, "%d",
                      local->total_ps_buffered);
-DEBUGFS_READONLY_FILE(wep_iv, 20, "%#08x",
+DEBUGFS_READONLY_FILE(wep_iv, "%#08x",
                      local->wep_iv & 0xffffff);
-DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s",
+DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s",
        local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver");
 
 static ssize_t tsf_read(struct file *file, char __user *user_buf,
@@ -59,13 +83,11 @@ static ssize_t tsf_read(struct file *file, char __user *user_buf,
 {
        struct ieee80211_local *local = file->private_data;
        u64 tsf;
-       char buf[100];
 
        tsf = drv_get_tsf(local);
 
-       snprintf(buf, sizeof(buf), "0x%016llx\n", (unsigned long long) tsf);
-
-       return simple_read_from_buffer(user_buf, count, ppos, buf, 19);
+       return mac80211_format_buffer(user_buf, count, ppos, "0x%016llx\n",
+                                     (unsigned long long) tsf);
 }
 
 static ssize_t tsf_write(struct file *file,
@@ -85,13 +107,15 @@ static ssize_t tsf_write(struct file *file,
        if (strncmp(buf, "reset", 5) == 0) {
                if (local->ops->reset_tsf) {
                        drv_reset_tsf(local);
-                       printk(KERN_INFO "%s: debugfs reset TSF\n", wiphy_name(local->hw.wiphy));
+                       wiphy_info(local->hw.wiphy, "debugfs reset TSF\n");
                }
        } else {
                tsf = simple_strtoul(buf, NULL, 0);
                if (local->ops->set_tsf) {
                        drv_set_tsf(local, tsf);
-                       printk(KERN_INFO "%s: debugfs set TSF to %#018llx\n", wiphy_name(local->hw.wiphy), tsf);
+                       wiphy_info(local->hw.wiphy,
+                                  "debugfs set TSF to %#018llx\n", tsf);
+
                }
        }
 
@@ -101,7 +125,8 @@ static ssize_t tsf_write(struct file *file,
 static const struct file_operations tsf_ops = {
        .read = tsf_read,
        .write = tsf_write,
-       .open = mac80211_open_file_generic
+       .open = mac80211_open_file_generic,
+       .llseek = default_llseek,
 };
 
 static ssize_t reset_write(struct file *file, const char __user *user_buf,
@@ -110,7 +135,7 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf,
        struct ieee80211_local *local = file->private_data;
 
        rtnl_lock();
-       __ieee80211_suspend(&local->hw);
+       __ieee80211_suspend(&local->hw, NULL);
        __ieee80211_resume(&local->hw);
        rtnl_unlock();
 
@@ -120,18 +145,16 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf,
 static const struct file_operations reset_ops = {
        .write = reset_write,
        .open = mac80211_open_file_generic,
+       .llseek = noop_llseek,
 };
 
 static ssize_t noack_read(struct file *file, char __user *user_buf,
                          size_t count, loff_t *ppos)
 {
        struct ieee80211_local *local = file->private_data;
-       int res;
-       char buf[10];
 
-       res = scnprintf(buf, sizeof(buf), "%d\n", local->wifi_wme_noack_test);
-
-       return simple_read_from_buffer(user_buf, count, ppos, buf, res);
+       return mac80211_format_buffer(user_buf, count, ppos, "%d\n",
+                                     local->wifi_wme_noack_test);
 }
 
 static ssize_t noack_write(struct file *file,
@@ -155,19 +178,16 @@ static ssize_t noack_write(struct file *file,
 static const struct file_operations noack_ops = {
        .read = noack_read,
        .write = noack_write,
-       .open = mac80211_open_file_generic
+       .open = mac80211_open_file_generic,
+       .llseek = default_llseek,
 };
 
 static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf,
                                 size_t count, loff_t *ppos)
 {
        struct ieee80211_local *local = file->private_data;
-       int res;
-       char buf[10];
-
-       res = scnprintf(buf, sizeof(buf), "0x%x\n", local->uapsd_queues);
-
-       return simple_read_from_buffer(user_buf, count, ppos, buf, res);
+       return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n",
+                                     local->uapsd_queues);
 }
 
 static ssize_t uapsd_queues_write(struct file *file,
@@ -201,19 +221,17 @@ static ssize_t uapsd_queues_write(struct file *file,
 static const struct file_operations uapsd_queues_ops = {
        .read = uapsd_queues_read,
        .write = uapsd_queues_write,
-       .open = mac80211_open_file_generic
+       .open = mac80211_open_file_generic,
+       .llseek = default_llseek,
 };
 
 static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf,
                                     size_t count, loff_t *ppos)
 {
        struct ieee80211_local *local = file->private_data;
-       int res;
-       char buf[10];
-
-       res = scnprintf(buf, sizeof(buf), "0x%x\n", local->uapsd_max_sp_len);
 
-       return simple_read_from_buffer(user_buf, count, ppos, buf, res);
+       return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n",
+                                     local->uapsd_max_sp_len);
 }
 
 static ssize_t uapsd_max_sp_len_write(struct file *file,
@@ -247,7 +265,8 @@ static ssize_t uapsd_max_sp_len_write(struct file *file,
 static const struct file_operations uapsd_max_sp_len_ops = {
        .read = uapsd_max_sp_len_read,
        .write = uapsd_max_sp_len_write,
-       .open = mac80211_open_file_generic
+       .open = mac80211_open_file_generic,
+       .llseek = default_llseek,
 };
 
 static ssize_t channel_type_read(struct file *file, char __user *user_buf,
@@ -277,10 +296,70 @@ static ssize_t channel_type_read(struct file *file, char __user *user_buf,
        return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
 }
 
-static const struct file_operations channel_type_ops = {
-       .read = channel_type_read,
-       .open = mac80211_open_file_generic
-};
+static ssize_t hwflags_read(struct file *file, char __user *user_buf,
+                           size_t count, loff_t *ppos)
+{
+       struct ieee80211_local *local = file->private_data;
+       int mxln = 500;
+       ssize_t rv;
+       char *buf = kzalloc(mxln, GFP_KERNEL);
+       int sf = 0; /* how many written so far */
+
+       sf += snprintf(buf, mxln - sf, "0x%x\n", local->hw.flags);
+       if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL)
+               sf += snprintf(buf + sf, mxln - sf, "HAS_RATE_CONTROL\n");
+       if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
+               sf += snprintf(buf + sf, mxln - sf, "RX_INCLUDES_FCS\n");
+       if (local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING)
+               sf += snprintf(buf + sf, mxln - sf,
+                              "HOST_BCAST_PS_BUFFERING\n");
+       if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)
+               sf += snprintf(buf + sf, mxln - sf,
+                              "2GHZ_SHORT_SLOT_INCAPABLE\n");
+       if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)
+               sf += snprintf(buf + sf, mxln - sf,
+                              "2GHZ_SHORT_PREAMBLE_INCAPABLE\n");
+       if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)
+               sf += snprintf(buf + sf, mxln - sf, "SIGNAL_UNSPEC\n");
+       if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
+               sf += snprintf(buf + sf, mxln - sf, "SIGNAL_DBM\n");
+       if (local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD)
+               sf += snprintf(buf + sf, mxln - sf, "NEED_DTIM_PERIOD\n");
+       if (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)
+               sf += snprintf(buf + sf, mxln - sf, "SPECTRUM_MGMT\n");
+       if (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION)
+               sf += snprintf(buf + sf, mxln - sf, "AMPDU_AGGREGATION\n");
+       if (local->hw.flags & IEEE80211_HW_SUPPORTS_PS)
+               sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PS\n");
+       if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
+               sf += snprintf(buf + sf, mxln - sf, "PS_NULLFUNC_STACK\n");
+       if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
+               sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n");
+       if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE)
+               sf += snprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n");
+       if (local->hw.flags & IEEE80211_HW_BEACON_FILTER)
+               sf += snprintf(buf + sf, mxln - sf, "BEACON_FILTER\n");
+       if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS)
+               sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n");
+       if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS)
+               sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_SMPS\n");
+       if (local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)
+               sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_UAPSD\n");
+       if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
+               sf += snprintf(buf + sf, mxln - sf, "REPORTS_TX_ACK_STATUS\n");
+       if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
+               sf += snprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n");
+       if (local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)
+               sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_CQM_RSSI\n");
+       if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK)
+               sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n");
+       if (local->hw.flags & IEEE80211_HW_AP_LINK_PS)
+               sf += snprintf(buf + sf, mxln - sf, "AP_LINK_PS\n");
+
+       rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+       kfree(buf);
+       return rv;
+}
 
 static ssize_t queues_read(struct file *file, char __user *user_buf,
                           size_t count, loff_t *ppos)
@@ -300,10 +379,9 @@ static ssize_t queues_read(struct file *file, char __user *user_buf,
        return simple_read_from_buffer(user_buf, count, ppos, buf, res);
 }
 
-static const struct file_operations queues_ops = {
-       .read = queues_read,
-       .open = mac80211_open_file_generic
-};
+DEBUGFS_READONLY_FILE_OPS(hwflags);
+DEBUGFS_READONLY_FILE_OPS(channel_type);
+DEBUGFS_READONLY_FILE_OPS(queues);
 
 /* statistics stuff */
 
@@ -346,6 +424,7 @@ static ssize_t stats_ ##name## _read(struct file *file,                     \
 static const struct file_operations stats_ ##name## _ops = {           \
        .read = stats_ ##name## _read,                                  \
        .open = mac80211_open_file_generic,                             \
+       .llseek = generic_file_llseek,                                  \
 };
 
 #define DEBUGFS_STATS_ADD(name, field)                                 \
@@ -366,7 +445,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
        if (!phyd)
                return;
 
-       local->debugfs.stations = debugfs_create_dir("stations", phyd);
        local->debugfs.keys = debugfs_create_dir("keys", phyd);
 
        DEBUGFS_ADD(frequency);
@@ -379,6 +457,9 @@ void debugfs_hw_add(struct ieee80211_local *local)
        DEBUGFS_ADD(uapsd_queues);
        DEBUGFS_ADD(uapsd_max_sp_len);
        DEBUGFS_ADD(channel_type);
+       DEBUGFS_ADD(hwflags);
+       DEBUGFS_ADD(user_power);
+       DEBUGFS_ADD(power);
 
        statsd = debugfs_create_dir("statistics", phyd);