Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
Reinette Chatre | 01f8162 | 2009-01-08 10:20:02 -0800 | [diff] [blame] | 5 | * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved. |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of version 2 of the GNU General Public License as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 19 | * USA |
| 20 | * |
| 21 | * The full GNU General Public License is included in this distribution |
| 22 | * in the file called LICENSE.GPL. |
| 23 | * |
| 24 | * Contact Information: |
Winkler, Tomas | 759ef89 | 2008-12-09 11:28:58 -0800 | [diff] [blame] | 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | *****************************************************************************/ |
| 28 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/module.h> |
| 31 | #include <linux/debugfs.h> |
| 32 | |
| 33 | #include <linux/ieee80211.h> |
| 34 | #include <net/mac80211.h> |
| 35 | |
| 36 | |
Tomas Winkler | 3e0d4cb | 2008-04-24 11:55:38 -0700 | [diff] [blame] | 37 | #include "iwl-dev.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 38 | #include "iwl-debug.h" |
Tomas Winkler | fee1247 | 2008-04-03 16:05:21 -0700 | [diff] [blame] | 39 | #include "iwl-core.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 40 | #include "iwl-io.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 41 | |
| 42 | |
| 43 | /* create and remove of files */ |
| 44 | #define DEBUGFS_ADD_DIR(name, parent) do { \ |
| 45 | dbgfs->dir_##name = debugfs_create_dir(#name, parent); \ |
| 46 | if (!(dbgfs->dir_##name)) \ |
| 47 | goto err; \ |
| 48 | } while (0) |
| 49 | |
| 50 | #define DEBUGFS_ADD_FILE(name, parent) do { \ |
| 51 | dbgfs->dbgfs_##parent##_files.file_##name = \ |
Reinette Chatre | fcf89d0 | 2009-07-09 10:33:38 -0700 | [diff] [blame] | 52 | debugfs_create_file(#name, S_IWUSR | S_IRUSR, \ |
| 53 | dbgfs->dir_##parent, priv, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 54 | &iwl_dbgfs_##name##_ops); \ |
| 55 | if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \ |
| 56 | goto err; \ |
| 57 | } while (0) |
| 58 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 59 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 60 | dbgfs->dbgfs_##parent##_files.file_##name = \ |
Reinette Chatre | fcf89d0 | 2009-07-09 10:33:38 -0700 | [diff] [blame] | 61 | debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ |
| 62 | dbgfs->dir_##parent, ptr); \ |
Zhaolei | 9b24001 | 2008-10-22 17:06:12 +0800 | [diff] [blame] | 63 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \ |
| 64 | || !dbgfs->dbgfs_##parent##_files.file_##name) \ |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 65 | goto err; \ |
| 66 | } while (0) |
| 67 | |
Winkler, Tomas | 2ddfa12 | 2008-12-22 11:31:20 +0800 | [diff] [blame] | 68 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
| 69 | dbgfs->dbgfs_##parent##_files.file_##name = \ |
Reinette Chatre | fcf89d0 | 2009-07-09 10:33:38 -0700 | [diff] [blame] | 70 | debugfs_create_x32(#name, S_IRUSR, dbgfs->dir_##parent, ptr); \ |
Winkler, Tomas | 2ddfa12 | 2008-12-22 11:31:20 +0800 | [diff] [blame] | 71 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \ |
| 72 | || !dbgfs->dbgfs_##parent##_files.file_##name) \ |
| 73 | goto err; \ |
| 74 | } while (0) |
| 75 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 76 | #define DEBUGFS_REMOVE(name) do { \ |
| 77 | debugfs_remove(name); \ |
| 78 | name = NULL; \ |
| 79 | } while (0); |
| 80 | |
| 81 | /* file operation */ |
| 82 | #define DEBUGFS_READ_FUNC(name) \ |
| 83 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ |
| 84 | char __user *user_buf, \ |
| 85 | size_t count, loff_t *ppos); |
| 86 | |
| 87 | #define DEBUGFS_WRITE_FUNC(name) \ |
| 88 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ |
| 89 | const char __user *user_buf, \ |
| 90 | size_t count, loff_t *ppos); |
| 91 | |
| 92 | |
| 93 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
| 94 | { |
| 95 | file->private_data = inode->i_private; |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 100 | DEBUGFS_READ_FUNC(name); \ |
| 101 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 102 | .read = iwl_dbgfs_##name##_read, \ |
| 103 | .open = iwl_dbgfs_open_file_generic, \ |
| 104 | }; |
| 105 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 106 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 107 | DEBUGFS_WRITE_FUNC(name); \ |
| 108 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 109 | .write = iwl_dbgfs_##name##_write, \ |
| 110 | .open = iwl_dbgfs_open_file_generic, \ |
| 111 | }; |
| 112 | |
| 113 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 114 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 115 | DEBUGFS_READ_FUNC(name); \ |
| 116 | DEBUGFS_WRITE_FUNC(name); \ |
| 117 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 118 | .write = iwl_dbgfs_##name##_write, \ |
| 119 | .read = iwl_dbgfs_##name##_read, \ |
| 120 | .open = iwl_dbgfs_open_file_generic, \ |
| 121 | }; |
| 122 | |
| 123 | |
| 124 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
| 125 | char __user *user_buf, |
| 126 | size_t count, loff_t *ppos) { |
| 127 | |
| 128 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 129 | char buf[256]; |
| 130 | int pos = 0; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 131 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 132 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 133 | pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n", |
| 134 | priv->tx_stats[0].cnt); |
| 135 | pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n", |
| 136 | priv->tx_stats[1].cnt); |
| 137 | pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n", |
| 138 | priv->tx_stats[2].cnt); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 139 | |
| 140 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 141 | } |
| 142 | |
| 143 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, |
| 144 | char __user *user_buf, |
| 145 | size_t count, loff_t *ppos) { |
| 146 | |
| 147 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 148 | char buf[256]; |
| 149 | int pos = 0; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 150 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 151 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 152 | pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n", |
| 153 | priv->rx_stats[0].cnt); |
| 154 | pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n", |
| 155 | priv->rx_stats[1].cnt); |
| 156 | pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n", |
| 157 | priv->rx_stats[2].cnt); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 158 | |
| 159 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 160 | } |
| 161 | |
| 162 | #define BYTE1_MASK 0x000000ff; |
| 163 | #define BYTE2_MASK 0x0000ffff; |
| 164 | #define BYTE3_MASK 0x00ffffff; |
| 165 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 166 | char __user *user_buf, |
| 167 | size_t count, loff_t *ppos) |
| 168 | { |
| 169 | u32 val; |
| 170 | char buf[1024]; |
| 171 | ssize_t ret; |
| 172 | int i; |
| 173 | int pos = 0; |
| 174 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 175 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 176 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 177 | for (i = priv->dbgfs->sram_len; i > 0; i -= 4) { |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 178 | val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 179 | priv->dbgfs->sram_len - i); |
| 180 | if (i < 4) { |
| 181 | switch (i) { |
| 182 | case 1: |
| 183 | val &= BYTE1_MASK; |
| 184 | break; |
| 185 | case 2: |
| 186 | val &= BYTE2_MASK; |
| 187 | break; |
| 188 | case 3: |
| 189 | val &= BYTE3_MASK; |
| 190 | break; |
| 191 | } |
| 192 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 193 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 194 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 195 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 196 | |
| 197 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 198 | return ret; |
| 199 | } |
| 200 | |
| 201 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 202 | const char __user *user_buf, |
| 203 | size_t count, loff_t *ppos) |
| 204 | { |
| 205 | struct iwl_priv *priv = file->private_data; |
| 206 | char buf[64]; |
| 207 | int buf_size; |
| 208 | u32 offset, len; |
| 209 | |
| 210 | memset(buf, 0, sizeof(buf)); |
| 211 | buf_size = min(count, sizeof(buf) - 1); |
| 212 | if (copy_from_user(buf, user_buf, buf_size)) |
| 213 | return -EFAULT; |
| 214 | |
| 215 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
| 216 | priv->dbgfs->sram_offset = offset; |
| 217 | priv->dbgfs->sram_len = len; |
| 218 | } else { |
| 219 | priv->dbgfs->sram_offset = 0; |
| 220 | priv->dbgfs->sram_len = 0; |
| 221 | } |
| 222 | |
| 223 | return count; |
| 224 | } |
| 225 | |
| 226 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 227 | size_t count, loff_t *ppos) |
| 228 | { |
| 229 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 230 | struct iwl_station_entry *station; |
Tomas Winkler | 5425e49 | 2008-04-15 16:01:38 -0700 | [diff] [blame] | 231 | int max_sta = priv->hw_params.max_stations; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 232 | char *buf; |
| 233 | int i, j, pos = 0; |
| 234 | ssize_t ret; |
| 235 | /* Add 30 for initial string */ |
| 236 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 237 | |
| 238 | buf = kmalloc(bufsz, GFP_KERNEL); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 239 | if (!buf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 240 | return -ENOMEM; |
| 241 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 242 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 243 | priv->num_stations); |
| 244 | |
| 245 | for (i = 0; i < max_sta; i++) { |
| 246 | station = &priv->stations[i]; |
| 247 | if (station->used) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 248 | pos += scnprintf(buf + pos, bufsz - pos, |
| 249 | "station %d:\ngeneral data:\n", i+1); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 250 | pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 251 | station->sta.sta.sta_id); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 252 | pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 253 | station->sta.mode); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 254 | pos += scnprintf(buf + pos, bufsz - pos, |
| 255 | "flags: 0x%x\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 256 | station->sta.station_flags_msk); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 257 | pos += scnprintf(buf + pos, bufsz - pos, |
| 258 | "ps_status: %u\n", station->ps_status); |
| 259 | pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); |
| 260 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 261 | "seq_num\t\ttxq_id"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 262 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 263 | "\tframe_count\twait_for_ba\t"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 264 | pos += scnprintf(buf + pos, bufsz - pos, |
| 265 | "start_idx\tbitmap0\t"); |
| 266 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 267 | "bitmap1\trate_n_flags"); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 268 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 269 | |
| 270 | for (j = 0; j < MAX_TID_COUNT; j++) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 271 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 272 | "[%d]:\t\t%u", j, |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 273 | station->tid[j].seq_number); |
| 274 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 275 | "\t%u\t\t%u\t\t%u\t\t", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 276 | station->tid[j].agg.txq_id, |
| 277 | station->tid[j].agg.frame_count, |
| 278 | station->tid[j].agg.wait_for_ba); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 279 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 280 | "%u\t%llu\t%u", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 281 | station->tid[j].agg.start_idx, |
John W. Linville | 1678859 | 2008-04-01 20:59:32 -0400 | [diff] [blame] | 282 | (unsigned long long)station->tid[j].agg.bitmap, |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 283 | station->tid[j].agg.rate_n_flags); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 284 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 285 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 286 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 287 | } |
| 288 | } |
| 289 | |
| 290 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 291 | kfree(buf); |
| 292 | return ret; |
| 293 | } |
| 294 | |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 295 | static ssize_t iwl_dbgfs_nvm_read(struct file *file, |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 296 | char __user *user_buf, |
| 297 | size_t count, |
| 298 | loff_t *ppos) |
| 299 | { |
| 300 | ssize_t ret; |
| 301 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 302 | int pos = 0, ofs = 0, buf_size = 0; |
| 303 | const u8 *ptr; |
| 304 | char *buf; |
| 305 | size_t eeprom_len = priv->cfg->eeprom_size; |
| 306 | buf_size = 4 * eeprom_len + 256; |
| 307 | |
| 308 | if (eeprom_len % 16) { |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 309 | IWL_ERR(priv, "NVM size is not multiple of 16.\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 310 | return -ENODATA; |
| 311 | } |
| 312 | |
| 313 | /* 4 characters for byte 0xYY */ |
| 314 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 315 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 316 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 317 | return -ENOMEM; |
| 318 | } |
| 319 | |
| 320 | ptr = priv->eeprom; |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 321 | if (!ptr) { |
| 322 | IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); |
| 323 | return -ENOMEM; |
| 324 | } |
| 325 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s\n", |
| 326 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
| 327 | ? "OTP" : "EEPROM"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 328 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 329 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 330 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 331 | buf_size - pos, 0); |
| 332 | pos += strlen(buf); |
| 333 | if (buf_size - pos > 0) |
| 334 | buf[pos++] = '\n'; |
| 335 | } |
| 336 | |
| 337 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 338 | kfree(buf); |
| 339 | return ret; |
| 340 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 341 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 342 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
| 343 | const char __user *user_buf, |
| 344 | size_t count, loff_t *ppos) |
| 345 | { |
| 346 | struct iwl_priv *priv = file->private_data; |
| 347 | u32 event_log_flag; |
| 348 | char buf[8]; |
| 349 | int buf_size; |
| 350 | |
| 351 | memset(buf, 0, sizeof(buf)); |
| 352 | buf_size = min(count, sizeof(buf) - 1); |
| 353 | if (copy_from_user(buf, user_buf, buf_size)) |
| 354 | return -EFAULT; |
| 355 | if (sscanf(buf, "%d", &event_log_flag) != 1) |
| 356 | return -EFAULT; |
| 357 | if (event_log_flag == 1) |
| 358 | iwl_dump_nic_event_log(priv); |
| 359 | |
| 360 | return count; |
| 361 | } |
| 362 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 363 | |
| 364 | |
| 365 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, |
| 366 | size_t count, loff_t *ppos) |
| 367 | { |
| 368 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 369 | struct ieee80211_channel *channels = NULL; |
| 370 | const struct ieee80211_supported_band *supp_band = NULL; |
| 371 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 372 | char *buf; |
| 373 | ssize_t ret; |
| 374 | |
| 375 | if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) |
| 376 | return -EAGAIN; |
| 377 | |
| 378 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 379 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 380 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 381 | return -ENOMEM; |
| 382 | } |
| 383 | |
| 384 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 385 | if (supp_band) { |
| 386 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 387 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 388 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 389 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 390 | supp_band->n_channels); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 391 | |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 392 | for (i = 0; i < supp_band->n_channels; i++) |
| 393 | pos += scnprintf(buf + pos, bufsz - pos, |
| 394 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 395 | ieee80211_frequency_to_channel( |
| 396 | channels[i].center_freq), |
| 397 | channels[i].max_power, |
| 398 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 399 | " (IEEE 802.11h required)" : "", |
| 400 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 401 | || (channels[i].flags & |
| 402 | IEEE80211_CHAN_RADAR)) ? "" : |
| 403 | ", IBSS", |
| 404 | channels[i].flags & |
| 405 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 406 | "passive only" : "active/passive"); |
| 407 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 408 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 409 | if (supp_band) { |
| 410 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 411 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 412 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 413 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 414 | supp_band->n_channels); |
| 415 | |
| 416 | for (i = 0; i < supp_band->n_channels; i++) |
| 417 | pos += scnprintf(buf + pos, bufsz - pos, |
| 418 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 419 | ieee80211_frequency_to_channel( |
| 420 | channels[i].center_freq), |
| 421 | channels[i].max_power, |
| 422 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 423 | " (IEEE 802.11h required)" : "", |
| 424 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 425 | || (channels[i].flags & |
| 426 | IEEE80211_CHAN_RADAR)) ? "" : |
| 427 | ", IBSS", |
| 428 | channels[i].flags & |
| 429 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 430 | "passive only" : "active/passive"); |
| 431 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 432 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 433 | kfree(buf); |
| 434 | return ret; |
| 435 | } |
| 436 | |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 437 | static ssize_t iwl_dbgfs_status_read(struct file *file, |
| 438 | char __user *user_buf, |
| 439 | size_t count, loff_t *ppos) { |
| 440 | |
| 441 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 442 | char buf[512]; |
| 443 | int pos = 0; |
| 444 | const size_t bufsz = sizeof(buf); |
| 445 | |
| 446 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", |
| 447 | test_bit(STATUS_HCMD_ACTIVE, &priv->status)); |
| 448 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_SYNC_ACTIVE: %d\n", |
| 449 | test_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status)); |
| 450 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", |
| 451 | test_bit(STATUS_INT_ENABLED, &priv->status)); |
| 452 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", |
| 453 | test_bit(STATUS_RF_KILL_HW, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 454 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", |
| 455 | test_bit(STATUS_INIT, &priv->status)); |
| 456 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", |
| 457 | test_bit(STATUS_ALIVE, &priv->status)); |
| 458 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", |
| 459 | test_bit(STATUS_READY, &priv->status)); |
| 460 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", |
| 461 | test_bit(STATUS_TEMPERATURE, &priv->status)); |
| 462 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", |
| 463 | test_bit(STATUS_GEO_CONFIGURED, &priv->status)); |
| 464 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", |
| 465 | test_bit(STATUS_EXIT_PENDING, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 466 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
| 467 | test_bit(STATUS_STATISTICS, &priv->status)); |
| 468 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", |
| 469 | test_bit(STATUS_SCANNING, &priv->status)); |
| 470 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", |
| 471 | test_bit(STATUS_SCAN_ABORTING, &priv->status)); |
| 472 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", |
| 473 | test_bit(STATUS_SCAN_HW, &priv->status)); |
| 474 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", |
| 475 | test_bit(STATUS_POWER_PMI, &priv->status)); |
| 476 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", |
| 477 | test_bit(STATUS_FW_ERROR, &priv->status)); |
| 478 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_MODE_PENDING:\t %d\n", |
| 479 | test_bit(STATUS_MODE_PENDING, &priv->status)); |
| 480 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 481 | } |
| 482 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 483 | static ssize_t iwl_dbgfs_interrupt_read(struct file *file, |
| 484 | char __user *user_buf, |
| 485 | size_t count, loff_t *ppos) { |
| 486 | |
| 487 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 488 | int pos = 0; |
| 489 | int cnt = 0; |
| 490 | char *buf; |
| 491 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
| 492 | ssize_t ret; |
| 493 | |
| 494 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 495 | if (!buf) { |
| 496 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 497 | return -ENOMEM; |
| 498 | } |
| 499 | |
| 500 | pos += scnprintf(buf + pos, bufsz - pos, |
| 501 | "Interrupt Statistics Report:\n"); |
| 502 | |
| 503 | pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", |
| 504 | priv->isr_stats.hw); |
| 505 | pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", |
| 506 | priv->isr_stats.sw); |
| 507 | if (priv->isr_stats.sw > 0) { |
| 508 | pos += scnprintf(buf + pos, bufsz - pos, |
| 509 | "\tLast Restarting Code: 0x%X\n", |
| 510 | priv->isr_stats.sw_err); |
| 511 | } |
| 512 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 513 | pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", |
| 514 | priv->isr_stats.sch); |
| 515 | pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", |
| 516 | priv->isr_stats.alive); |
| 517 | #endif |
| 518 | pos += scnprintf(buf + pos, bufsz - pos, |
| 519 | "HW RF KILL switch toggled:\t %u\n", |
| 520 | priv->isr_stats.rfkill); |
| 521 | |
| 522 | pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", |
| 523 | priv->isr_stats.ctkill); |
| 524 | |
| 525 | pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", |
| 526 | priv->isr_stats.wakeup); |
| 527 | |
| 528 | pos += scnprintf(buf + pos, bufsz - pos, |
| 529 | "Rx command responses:\t\t %u\n", |
| 530 | priv->isr_stats.rx); |
| 531 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { |
| 532 | if (priv->isr_stats.rx_handlers[cnt] > 0) |
| 533 | pos += scnprintf(buf + pos, bufsz - pos, |
| 534 | "\tRx handler[%36s]:\t\t %u\n", |
| 535 | get_cmd_string(cnt), |
| 536 | priv->isr_stats.rx_handlers[cnt]); |
| 537 | } |
| 538 | |
| 539 | pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", |
| 540 | priv->isr_stats.tx); |
| 541 | |
| 542 | pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", |
| 543 | priv->isr_stats.unhandled); |
| 544 | |
| 545 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 546 | kfree(buf); |
| 547 | return ret; |
| 548 | } |
| 549 | |
| 550 | static ssize_t iwl_dbgfs_interrupt_write(struct file *file, |
| 551 | const char __user *user_buf, |
| 552 | size_t count, loff_t *ppos) |
| 553 | { |
| 554 | struct iwl_priv *priv = file->private_data; |
| 555 | char buf[8]; |
| 556 | int buf_size; |
| 557 | u32 reset_flag; |
| 558 | |
| 559 | memset(buf, 0, sizeof(buf)); |
| 560 | buf_size = min(count, sizeof(buf) - 1); |
| 561 | if (copy_from_user(buf, user_buf, buf_size)) |
| 562 | return -EFAULT; |
| 563 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 564 | return -EFAULT; |
| 565 | if (reset_flag == 0) |
| 566 | iwl_clear_isr_stats(priv); |
| 567 | |
| 568 | return count; |
| 569 | } |
| 570 | |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 571 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
| 572 | size_t count, loff_t *ppos) |
| 573 | { |
| 574 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 575 | int pos = 0, i; |
| 576 | char buf[256]; |
| 577 | const size_t bufsz = sizeof(buf); |
| 578 | ssize_t ret; |
| 579 | |
| 580 | for (i = 0; i < AC_NUM; i++) { |
| 581 | pos += scnprintf(buf + pos, bufsz - pos, |
| 582 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 583 | pos += scnprintf(buf + pos, bufsz - pos, |
| 584 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
| 585 | priv->qos_data.def_qos_parm.ac[i].cw_min, |
| 586 | priv->qos_data.def_qos_parm.ac[i].cw_max, |
| 587 | priv->qos_data.def_qos_parm.ac[i].aifsn, |
| 588 | priv->qos_data.def_qos_parm.ac[i].edca_txop); |
| 589 | } |
| 590 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 591 | return ret; |
| 592 | } |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 593 | |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame^] | 594 | #ifdef CONFIG_IWLWIFI_LEDS |
| 595 | static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf, |
| 596 | size_t count, loff_t *ppos) |
| 597 | { |
| 598 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 599 | int pos = 0; |
| 600 | char buf[256]; |
| 601 | const size_t bufsz = sizeof(buf); |
| 602 | ssize_t ret; |
| 603 | |
| 604 | pos += scnprintf(buf + pos, bufsz - pos, |
| 605 | "allow blinking: %s\n", |
| 606 | (priv->allow_blinking) ? "True" : "False"); |
| 607 | if (priv->allow_blinking) { |
| 608 | pos += scnprintf(buf + pos, bufsz - pos, |
| 609 | "Led blinking rate: %u\n", |
| 610 | priv->last_blink_rate); |
| 611 | pos += scnprintf(buf + pos, bufsz - pos, |
| 612 | "Last blink time: %lu\n", |
| 613 | priv->last_blink_time); |
| 614 | } |
| 615 | |
| 616 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 617 | return ret; |
| 618 | } |
| 619 | #endif |
| 620 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 621 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 622 | DEBUGFS_WRITE_FILE_OPS(log_event); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 623 | DEBUGFS_READ_FILE_OPS(nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 624 | DEBUGFS_READ_FILE_OPS(stations); |
| 625 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 626 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 627 | DEBUGFS_READ_FILE_OPS(channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 628 | DEBUGFS_READ_FILE_OPS(status); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 629 | DEBUGFS_READ_WRITE_FILE_OPS(interrupt); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 630 | DEBUGFS_READ_FILE_OPS(qos); |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame^] | 631 | #ifdef CONFIG_IWLWIFI_LEDS |
| 632 | DEBUGFS_READ_FILE_OPS(led); |
| 633 | #endif |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 634 | |
| 635 | /* |
| 636 | * Create the debugfs files and directories |
| 637 | * |
| 638 | */ |
| 639 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 640 | { |
| 641 | struct iwl_debugfs *dbgfs; |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 642 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 643 | int ret = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 644 | |
| 645 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); |
| 646 | if (!dbgfs) { |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 647 | ret = -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 648 | goto err; |
| 649 | } |
| 650 | |
| 651 | priv->dbgfs = dbgfs; |
| 652 | dbgfs->name = name; |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 653 | dbgfs->dir_drv = debugfs_create_dir(name, phyd); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 654 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) { |
| 655 | ret = -ENOENT; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 656 | goto err; |
| 657 | } |
| 658 | |
| 659 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 660 | DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 661 | DEBUGFS_ADD_FILE(nvm, data); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 662 | DEBUGFS_ADD_FILE(sram, data); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 663 | DEBUGFS_ADD_FILE(log_event, data); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 664 | DEBUGFS_ADD_FILE(stations, data); |
| 665 | DEBUGFS_ADD_FILE(rx_statistics, data); |
| 666 | DEBUGFS_ADD_FILE(tx_statistics, data); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 667 | DEBUGFS_ADD_FILE(channels, data); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 668 | DEBUGFS_ADD_FILE(status, data); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 669 | DEBUGFS_ADD_FILE(interrupt, data); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 670 | DEBUGFS_ADD_FILE(qos, data); |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame^] | 671 | #ifdef CONFIG_IWLWIFI_LEDS |
| 672 | DEBUGFS_ADD_FILE(led, data); |
| 673 | #endif |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 674 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); |
| 675 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, |
| 676 | &priv->disable_chain_noise_cal); |
Wey-Yi Guy | 030b865 | 2009-06-12 13:22:55 -0700 | [diff] [blame] | 677 | if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || |
| 678 | ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) |
| 679 | DEBUGFS_ADD_BOOL(disable_tx_power, rf, |
| 680 | &priv->disable_tx_power_cal); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 681 | return 0; |
| 682 | |
| 683 | err: |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 684 | IWL_ERR(priv, "Can't open the debugfs directory\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 685 | iwl_dbgfs_unregister(priv); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 686 | return ret; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 687 | } |
| 688 | EXPORT_SYMBOL(iwl_dbgfs_register); |
| 689 | |
| 690 | /** |
| 691 | * Remove the debugfs files and directories |
| 692 | * |
| 693 | */ |
| 694 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 695 | { |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 696 | if (!priv->dbgfs) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 697 | return; |
| 698 | |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 699 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 700 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics); |
| 701 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics); |
| 702 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 703 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 704 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 705 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 706 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 707 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_interrupt); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 708 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_qos); |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame^] | 709 | #ifdef CONFIG_IWLWIFI_LEDS |
| 710 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_led); |
| 711 | #endif |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 712 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 713 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); |
| 714 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); |
Wey-Yi Guy | 030b865 | 2009-06-12 13:22:55 -0700 | [diff] [blame] | 715 | if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || |
| 716 | ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) |
| 717 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 718 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 719 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); |
| 720 | kfree(priv->dbgfs); |
| 721 | priv->dbgfs = NULL; |
| 722 | } |
| 723 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
| 724 | |
| 725 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 726 | |