]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/iwlwifi/iwl-debugfs.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
[karo-tx-linux.git] / drivers / net / wireless / iwlwifi / iwl-debugfs.c
index d0c63cfee15c144946e7f6517e88e51427cb1534..a1670e3f8bfaa48bc0f2bb1328e9ba6b59acfe92 100644 (file)
                goto err;                                               \
 } while (0)
 
+#define DEBUGFS_ADD_U32(name, parent, ptr, mode) do {                  \
+       struct dentry *__tmp;                                           \
+       __tmp = debugfs_create_u32(#name, mode,                         \
+                                  parent, ptr);                        \
+       if (IS_ERR(__tmp) || !__tmp)                                    \
+               goto err;                                               \
+} while (0)
+
 /* file operation */
 #define DEBUGFS_READ_FUNC(name)                                         \
 static ssize_t iwl_dbgfs_##name##_read(struct file *file,               \
@@ -341,7 +349,6 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
        struct iwl_priv *priv = file->private_data;
        struct iwl_station_entry *station;
        struct iwl_tid_data *tid_data;
-       int max_sta = hw_params(priv).max_stations;
        char *buf;
        int i, j, pos = 0;
        ssize_t ret;
@@ -355,7 +362,7 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
        pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
                        priv->num_stations);
 
-       for (i = 0; i < max_sta; i++) {
+       for (i = 0; i < IWLAGN_STATION_COUNT; i++) {
                station = &priv->stations[i];
                if (!station->used)
                        continue;
@@ -707,6 +714,20 @@ static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
        return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
 }
 
+static ssize_t iwl_dbgfs_temperature_read(struct file *file,
+                                        char __user *user_buf,
+                                        size_t count, loff_t *ppos)
+{
+       struct iwl_priv *priv = file->private_data;
+       char buf[8];
+       int pos = 0;
+       const size_t bufsz = sizeof(buf);
+
+       pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature);
+       return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+}
+
+
 static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
                                                    const char __user *user_buf,
                                                    size_t count, loff_t *ppos)
@@ -801,6 +822,7 @@ DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers);
 DEBUGFS_READ_FILE_OPS(qos);
 DEBUGFS_READ_FILE_OPS(thermal_throttling);
 DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
+DEBUGFS_READ_FILE_OPS(temperature);
 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
 DEBUGFS_READ_FILE_OPS(current_sleep_command);
 
@@ -2229,8 +2251,8 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
 
 static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
                                        char __user *user_buf,
-                                       size_t count, loff_t *ppos) {
-
+                                       size_t count, loff_t *ppos)
+{
        struct iwl_priv *priv = file->private_data;
        int i, pos = 0;
        char buf[300];
@@ -2309,8 +2331,8 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
 
 static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file,
                                        const char __user *user_buf,
-                                       size_t count, loff_t *ppos) {
-
+                                       size_t count, loff_t *ppos)
+{
        struct iwl_priv *priv = file->private_data;
        char buf[8];
        int buf_size;
@@ -2421,6 +2443,23 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
        return count;
 }
 
+static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
+                                       const char __user *user_buf,
+                                       size_t count, loff_t *ppos)
+{
+       struct iwl_priv *priv = file->private_data;
+       char buf[8];
+       int buf_size;
+
+       memset(buf, 0, sizeof(buf));
+       buf_size = min(count, sizeof(buf) -  1);
+       if (copy_from_user(buf, user_buf, buf_size))
+               return -EFAULT;
+
+       iwl_cmd_echo_test(priv);
+       return count;
+}
+
 DEBUGFS_READ_FILE_OPS(rx_statistics);
 DEBUGFS_READ_FILE_OPS(tx_statistics);
 DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
@@ -2444,6 +2483,53 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout);
 DEBUGFS_READ_FILE_OPS(bt_traffic);
 DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
 DEBUGFS_READ_FILE_OPS(reply_tx_error);
+DEBUGFS_WRITE_FILE_OPS(echo_test);
+
+#ifdef CONFIG_IWLWIFI_DEBUG
+static ssize_t iwl_dbgfs_debug_level_read(struct file *file,
+                                         char __user *user_buf,
+                                         size_t count, loff_t *ppos)
+{
+       struct iwl_priv *priv = file->private_data;
+       struct iwl_shared *shrd = priv->shrd;
+       char buf[11];
+       int len;
+
+       len = scnprintf(buf, sizeof(buf), "0x%.8x",
+                       iwl_get_debug_level(shrd));
+
+       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t iwl_dbgfs_debug_level_write(struct file *file,
+                                          const char __user *user_buf,
+                                          size_t count, loff_t *ppos)
+{
+       struct iwl_priv *priv = file->private_data;
+       struct iwl_shared *shrd = priv->shrd;
+       char buf[11];
+       unsigned long val;
+       int ret;
+
+       if (count > sizeof(buf))
+               return -EINVAL;
+
+       memset(buf, 0, sizeof(buf));
+       if (copy_from_user(buf, user_buf, count))
+               return -EFAULT;
+
+       ret = strict_strtoul(buf, 0, &val);
+       if (ret)
+               return ret;
+
+       shrd->dbg_level_dev = val;
+       if (iwl_alloc_traffic_mem(priv))
+               IWL_ERR(priv, "Not enough memory to generate traffic log\n");
+
+       return count;
+}
+DEBUGFS_READ_WRITE_FILE_OPS(debug_level);
+#endif /* CONFIG_IWLWIFI_DEBUG */
 
 /*
  * Create the debugfs files and directories
@@ -2482,6 +2568,8 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
        DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
        DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
        DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
+       DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR);
+
        DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
        DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
        DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
@@ -2496,7 +2584,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
        DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
        DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
        DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
-
        DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
        DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
        DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
@@ -2505,8 +2592,13 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
        DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
        DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
        DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR);
+       DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR);
        if (iwl_advanced_bt_coexist(priv))
                DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
+#ifdef CONFIG_IWLWIFI_DEBUG
+       DEBUGFS_ADD_FILE(debug_level, dir_debug, S_IRUSR | S_IWUSR);
+#endif
+
        DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
                         &priv->disable_sens_cal);
        DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
@@ -2534,6 +2626,3 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
        debugfs_remove_recursive(priv->debugfs_dir);
        priv->debugfs_dir = NULL;
 }
-
-
-