]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/iwlwifi/iwl-debugfs.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / iwlwifi / iwl-debugfs.c
index 20db0eb636a82b64a85f403ef5c096ab37827aaf..36cfeccfafbcde17933cba2a1e6261a7c6023d04 100644 (file)
@@ -2,7 +2,7 @@
  *
  * GPL LICENSE SUMMARY
  *
- * Copyright(c) 2008 Intel Corporation. All rights reserved.
+ * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -22,7 +22,7 @@
  * in the file called LICENSE.GPL.
  *
  * Contact Information:
- * Tomas Winkler <tomas.winkler@intel.com>
+ *  Intel Linux Wireless <ilw@linux.intel.com>
  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  *****************************************************************************/
 
 #define DEBUGFS_ADD_BOOL(name, parent, ptr) do {                        \
        dbgfs->dbgfs_##parent##_files.file_##name =                     \
        debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr);     \
-       if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name))          \
+       if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name)           \
+                       || !dbgfs->dbgfs_##parent##_files.file_##name)  \
+               goto err;                                               \
+} while (0)
+
+#define DEBUGFS_ADD_X32(name, parent, ptr) do {                        \
+       dbgfs->dbgfs_##parent##_files.file_##name =                     \
+       debugfs_create_x32(#name, 0444, dbgfs->dir_##parent, ptr);     \
+       if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name)           \
+                       || !dbgfs->dbgfs_##parent##_files.file_##name)  \
                goto err;                                               \
 } while (0)
 
@@ -163,9 +172,6 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
        struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
        const size_t bufsz = sizeof(buf);
 
-       printk(KERN_DEBUG "offset is: 0x%x\tlen is: 0x%x\n",
-       priv->dbgfs->sram_offset, priv->dbgfs->sram_len);
-
        iwl_grab_nic_access(priv);
        for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
                val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \
@@ -228,7 +234,6 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
        ssize_t ret;
        /* Add 30 for initial string */
        const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
-       DECLARE_MAC_BUF(mac);
 
        buf = kmalloc(bufsz, GFP_KERNEL);
        if (!buf)
@@ -242,7 +247,6 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
                if (station->used) {
                        pos += scnprintf(buf + pos, bufsz - pos,
                                        "station %d:\ngeneral data:\n", i+1);
-                       print_mac(mac, station->sta.sta.addr);
                        pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
                                        station->sta.sta.sta_id);
                        pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
@@ -302,14 +306,14 @@ static ssize_t iwl_dbgfs_eeprom_read(struct file *file,
        buf_size = 4 * eeprom_len + 256;
 
        if (eeprom_len % 16) {
-               IWL_ERROR("EEPROM size is not multiple of 16.\n");
+               IWL_ERR(priv, "EEPROM size is not multiple of 16.\n");
                return -ENODATA;
        }
 
        /* 4 characters for byte 0xYY */
        buf = kzalloc(buf_size, GFP_KERNEL);
        if (!buf) {
-               IWL_ERROR("Can not allocate Buffer\n");
+               IWL_ERR(priv, "Can not allocate Buffer\n");
                return -ENOMEM;
        }
 
@@ -349,12 +353,85 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
        return count;
 }
 
+
+
+static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
+                                      size_t count, loff_t *ppos)
+{
+       struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+       struct ieee80211_channel *channels = NULL;
+       const struct ieee80211_supported_band *supp_band = NULL;
+       int pos = 0, i, bufsz = PAGE_SIZE;
+       char *buf;
+       ssize_t ret;
+
+       if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
+               return -EAGAIN;
+
+       buf = kzalloc(bufsz, GFP_KERNEL);
+       if (!buf) {
+               IWL_ERR(priv, "Can not allocate Buffer\n");
+               return -ENOMEM;
+       }
+
+       supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
+       channels = supp_band->channels;
+
+       pos += scnprintf(buf + pos, bufsz - pos,
+                       "Displaying %d channels in 2.4GHz band 802.11bg):\n",
+                        supp_band->n_channels);
+
+       for (i = 0; i < supp_band->n_channels; i++)
+               pos += scnprintf(buf + pos, bufsz - pos,
+                               "%d: %ddBm: BSS%s%s, %s.\n",
+                               ieee80211_frequency_to_channel(
+                               channels[i].center_freq),
+                               channels[i].max_power,
+                               channels[i].flags & IEEE80211_CHAN_RADAR ?
+                               " (IEEE 802.11h required)" : "",
+                               (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
+                               || (channels[i].flags &
+                               IEEE80211_CHAN_RADAR)) ? "" :
+                               ", IBSS",
+                               channels[i].flags &
+                               IEEE80211_CHAN_PASSIVE_SCAN ?
+                               "passive only" : "active/passive");
+
+       supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
+       channels = supp_band->channels;
+
+       pos += scnprintf(buf + pos, bufsz - pos,
+                       "Displaying %d channels in 5.2GHz band (802.11a)\n",
+                       supp_band->n_channels);
+
+       for (i = 0; i < supp_band->n_channels; i++)
+               pos += scnprintf(buf + pos, bufsz - pos,
+                               "%d: %ddBm: BSS%s%s, %s.\n",
+                               ieee80211_frequency_to_channel(
+                               channels[i].center_freq),
+                               channels[i].max_power,
+                               channels[i].flags & IEEE80211_CHAN_RADAR ?
+                               " (IEEE 802.11h required)" : "",
+                               ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
+                               || (channels[i].flags &
+                               IEEE80211_CHAN_RADAR)) ? "" :
+                               ", IBSS",
+                               channels[i].flags &
+                               IEEE80211_CHAN_PASSIVE_SCAN ?
+                               "passive only" : "active/passive");
+
+       ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+       kfree(buf);
+       return ret;
+}
+
 DEBUGFS_READ_WRITE_FILE_OPS(sram);
 DEBUGFS_WRITE_FILE_OPS(log_event);
 DEBUGFS_READ_FILE_OPS(eeprom);
 DEBUGFS_READ_FILE_OPS(stations);
 DEBUGFS_READ_FILE_OPS(rx_statistics);
 DEBUGFS_READ_FILE_OPS(tx_statistics);
+DEBUGFS_READ_FILE_OPS(channels);
 
 /*
  * Create the debugfs files and directories
@@ -388,6 +465,8 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
        DEBUGFS_ADD_FILE(stations, data);
        DEBUGFS_ADD_FILE(rx_statistics, data);
        DEBUGFS_ADD_FILE(tx_statistics, data);
+       DEBUGFS_ADD_FILE(channels, data);
+       DEBUGFS_ADD_X32(status, data, (u32 *)&priv->status);
        DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
        DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
                         &priv->disable_chain_noise_cal);
@@ -395,7 +474,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
        return 0;
 
 err:
-       IWL_ERROR("Can't open the debugfs directory\n");
+       IWL_ERR(priv, "Can't open the debugfs directory\n");
        iwl_dbgfs_unregister(priv);
        return ret;
 }
@@ -416,6 +495,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
+       DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
        DEBUGFS_REMOVE(priv->dbgfs->dir_data);
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);