Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
| 5 | * Copyright(c) 2008 Intel Corporation. All rights reserved. |
| 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: |
| 25 | * Tomas Winkler <tomas.winkler@intel.com> |
| 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 = \ |
| 52 | debugfs_create_file(#name, 0644, dbgfs->dir_##parent, priv, \ |
| 53 | &iwl_dbgfs_##name##_ops); \ |
| 54 | if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \ |
| 55 | goto err; \ |
| 56 | } while (0) |
| 57 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 58 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 59 | dbgfs->dbgfs_##parent##_files.file_##name = \ |
| 60 | debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr); \ |
| 61 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name)) \ |
| 62 | goto err; \ |
| 63 | } while (0) |
| 64 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 65 | #define DEBUGFS_REMOVE(name) do { \ |
| 66 | debugfs_remove(name); \ |
| 67 | name = NULL; \ |
| 68 | } while (0); |
| 69 | |
| 70 | /* file operation */ |
| 71 | #define DEBUGFS_READ_FUNC(name) \ |
| 72 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ |
| 73 | char __user *user_buf, \ |
| 74 | size_t count, loff_t *ppos); |
| 75 | |
| 76 | #define DEBUGFS_WRITE_FUNC(name) \ |
| 77 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ |
| 78 | const char __user *user_buf, \ |
| 79 | size_t count, loff_t *ppos); |
| 80 | |
| 81 | |
| 82 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
| 83 | { |
| 84 | file->private_data = inode->i_private; |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 89 | DEBUGFS_READ_FUNC(name); \ |
| 90 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 91 | .read = iwl_dbgfs_##name##_read, \ |
| 92 | .open = iwl_dbgfs_open_file_generic, \ |
| 93 | }; |
| 94 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame^] | 95 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 96 | DEBUGFS_WRITE_FUNC(name); \ |
| 97 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 98 | .write = iwl_dbgfs_##name##_write, \ |
| 99 | .open = iwl_dbgfs_open_file_generic, \ |
| 100 | }; |
| 101 | |
| 102 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 103 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 104 | DEBUGFS_READ_FUNC(name); \ |
| 105 | DEBUGFS_WRITE_FUNC(name); \ |
| 106 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 107 | .write = iwl_dbgfs_##name##_write, \ |
| 108 | .read = iwl_dbgfs_##name##_read, \ |
| 109 | .open = iwl_dbgfs_open_file_generic, \ |
| 110 | }; |
| 111 | |
| 112 | |
| 113 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
| 114 | char __user *user_buf, |
| 115 | size_t count, loff_t *ppos) { |
| 116 | |
| 117 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 118 | char buf[256]; |
| 119 | int pos = 0; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 120 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 121 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 122 | pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n", |
| 123 | priv->tx_stats[0].cnt); |
| 124 | pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n", |
| 125 | priv->tx_stats[1].cnt); |
| 126 | pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n", |
| 127 | priv->tx_stats[2].cnt); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 128 | |
| 129 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 130 | } |
| 131 | |
| 132 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, |
| 133 | char __user *user_buf, |
| 134 | size_t count, loff_t *ppos) { |
| 135 | |
| 136 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 137 | char buf[256]; |
| 138 | int pos = 0; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 139 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 140 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 141 | pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n", |
| 142 | priv->rx_stats[0].cnt); |
| 143 | pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n", |
| 144 | priv->rx_stats[1].cnt); |
| 145 | pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n", |
| 146 | priv->rx_stats[2].cnt); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 147 | |
| 148 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 149 | } |
| 150 | |
| 151 | #define BYTE1_MASK 0x000000ff; |
| 152 | #define BYTE2_MASK 0x0000ffff; |
| 153 | #define BYTE3_MASK 0x00ffffff; |
| 154 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 155 | char __user *user_buf, |
| 156 | size_t count, loff_t *ppos) |
| 157 | { |
| 158 | u32 val; |
| 159 | char buf[1024]; |
| 160 | ssize_t ret; |
| 161 | int i; |
| 162 | int pos = 0; |
| 163 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 164 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 165 | |
| 166 | printk(KERN_DEBUG "offset is: 0x%x\tlen is: 0x%x\n", |
| 167 | priv->dbgfs->sram_offset, priv->dbgfs->sram_len); |
| 168 | |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 169 | iwl_grab_nic_access(priv); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 170 | for (i = priv->dbgfs->sram_len; i > 0; i -= 4) { |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 171 | val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 172 | priv->dbgfs->sram_len - i); |
| 173 | if (i < 4) { |
| 174 | switch (i) { |
| 175 | case 1: |
| 176 | val &= BYTE1_MASK; |
| 177 | break; |
| 178 | case 2: |
| 179 | val &= BYTE2_MASK; |
| 180 | break; |
| 181 | case 3: |
| 182 | val &= BYTE3_MASK; |
| 183 | break; |
| 184 | } |
| 185 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 186 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 187 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 188 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 189 | iwl_release_nic_access(priv); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 190 | |
| 191 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 192 | return ret; |
| 193 | } |
| 194 | |
| 195 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 196 | const char __user *user_buf, |
| 197 | size_t count, loff_t *ppos) |
| 198 | { |
| 199 | struct iwl_priv *priv = file->private_data; |
| 200 | char buf[64]; |
| 201 | int buf_size; |
| 202 | u32 offset, len; |
| 203 | |
| 204 | memset(buf, 0, sizeof(buf)); |
| 205 | buf_size = min(count, sizeof(buf) - 1); |
| 206 | if (copy_from_user(buf, user_buf, buf_size)) |
| 207 | return -EFAULT; |
| 208 | |
| 209 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
| 210 | priv->dbgfs->sram_offset = offset; |
| 211 | priv->dbgfs->sram_len = len; |
| 212 | } else { |
| 213 | priv->dbgfs->sram_offset = 0; |
| 214 | priv->dbgfs->sram_len = 0; |
| 215 | } |
| 216 | |
| 217 | return count; |
| 218 | } |
| 219 | |
| 220 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 221 | size_t count, loff_t *ppos) |
| 222 | { |
| 223 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 224 | struct iwl_station_entry *station; |
Tomas Winkler | 5425e49 | 2008-04-15 16:01:38 -0700 | [diff] [blame] | 225 | int max_sta = priv->hw_params.max_stations; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 226 | char *buf; |
| 227 | int i, j, pos = 0; |
| 228 | ssize_t ret; |
| 229 | /* Add 30 for initial string */ |
| 230 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
| 231 | DECLARE_MAC_BUF(mac); |
| 232 | |
| 233 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 234 | if(!buf) |
| 235 | return -ENOMEM; |
| 236 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 237 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 238 | priv->num_stations); |
| 239 | |
| 240 | for (i = 0; i < max_sta; i++) { |
| 241 | station = &priv->stations[i]; |
| 242 | if (station->used) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 243 | pos += scnprintf(buf + pos, bufsz - pos, |
| 244 | "station %d:\ngeneral data:\n", i+1); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 245 | print_mac(mac, station->sta.sta.addr); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 246 | pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 247 | station->sta.sta.sta_id); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 248 | pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 249 | station->sta.mode); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 250 | pos += scnprintf(buf + pos, bufsz - pos, |
| 251 | "flags: 0x%x\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 252 | station->sta.station_flags_msk); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 253 | pos += scnprintf(buf + pos, bufsz - pos, |
| 254 | "ps_status: %u\n", station->ps_status); |
| 255 | pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); |
| 256 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 257 | "seq_num\t\ttxq_id"); |
| 258 | #ifdef CONFIG_IWL4965_HT |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 259 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 260 | "\tframe_count\twait_for_ba\t"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 261 | pos += scnprintf(buf + pos, bufsz - pos, |
| 262 | "start_idx\tbitmap0\t"); |
| 263 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 264 | "bitmap1\trate_n_flags"); |
| 265 | #endif |
| 266 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 267 | |
| 268 | for (j = 0; j < MAX_TID_COUNT; j++) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 269 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 270 | "[%d]:\t\t%u", j, |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 271 | station->tid[j].seq_number); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 272 | #ifdef CONFIG_IWL4965_HT |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 273 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 274 | "\t%u\t\t%u\t\t%u\t\t", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 275 | station->tid[j].agg.txq_id, |
| 276 | station->tid[j].agg.frame_count, |
| 277 | station->tid[j].agg.wait_for_ba); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 278 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 279 | "%u\t%llu\t%u", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 280 | station->tid[j].agg.start_idx, |
John W. Linville | 1678859 | 2008-04-01 20:59:32 -0400 | [diff] [blame] | 281 | (unsigned long long)station->tid[j].agg.bitmap, |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 282 | station->tid[j].agg.rate_n_flags); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 283 | #endif |
| 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 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 295 | static ssize_t iwl_dbgfs_eeprom_read(struct file *file, |
| 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) { |
| 309 | IWL_ERROR("EEPROM size is not multiple of 16.\n"); |
| 310 | return -ENODATA; |
| 311 | } |
| 312 | |
| 313 | /* 4 characters for byte 0xYY */ |
| 314 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 315 | if (!buf) { |
| 316 | IWL_ERROR("Can not allocate Buffer\n"); |
| 317 | return -ENOMEM; |
| 318 | } |
| 319 | |
| 320 | ptr = priv->eeprom; |
| 321 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 322 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 323 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 324 | buf_size - pos, 0); |
| 325 | pos += strlen(buf); |
| 326 | if (buf_size - pos > 0) |
| 327 | buf[pos++] = '\n'; |
| 328 | } |
| 329 | |
| 330 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 331 | kfree(buf); |
| 332 | return ret; |
| 333 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 334 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame^] | 335 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
| 336 | const char __user *user_buf, |
| 337 | size_t count, loff_t *ppos) |
| 338 | { |
| 339 | struct iwl_priv *priv = file->private_data; |
| 340 | u32 event_log_flag; |
| 341 | char buf[8]; |
| 342 | int buf_size; |
| 343 | |
| 344 | memset(buf, 0, sizeof(buf)); |
| 345 | buf_size = min(count, sizeof(buf) - 1); |
| 346 | if (copy_from_user(buf, user_buf, buf_size)) |
| 347 | return -EFAULT; |
| 348 | if (sscanf(buf, "%d", &event_log_flag) != 1) |
| 349 | return -EFAULT; |
| 350 | if (event_log_flag == 1) |
| 351 | iwl_dump_nic_event_log(priv); |
| 352 | |
| 353 | return count; |
| 354 | } |
| 355 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 356 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame^] | 357 | DEBUGFS_WRITE_FILE_OPS(log_event); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 358 | DEBUGFS_READ_FILE_OPS(eeprom); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 359 | DEBUGFS_READ_FILE_OPS(stations); |
| 360 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 361 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
| 362 | |
| 363 | /* |
| 364 | * Create the debugfs files and directories |
| 365 | * |
| 366 | */ |
| 367 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 368 | { |
| 369 | struct iwl_debugfs *dbgfs; |
| 370 | |
| 371 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); |
| 372 | if (!dbgfs) { |
| 373 | goto err; |
| 374 | } |
| 375 | |
| 376 | priv->dbgfs = dbgfs; |
| 377 | dbgfs->name = name; |
| 378 | dbgfs->dir_drv = debugfs_create_dir(name, NULL); |
| 379 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)){ |
| 380 | goto err; |
| 381 | } |
| 382 | |
| 383 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 384 | DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 385 | DEBUGFS_ADD_FILE(eeprom, data); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 386 | DEBUGFS_ADD_FILE(sram, data); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame^] | 387 | DEBUGFS_ADD_FILE(log_event, data); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 388 | DEBUGFS_ADD_FILE(stations, data); |
| 389 | DEBUGFS_ADD_FILE(rx_statistics, data); |
| 390 | DEBUGFS_ADD_FILE(tx_statistics, data); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 391 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB |
| 392 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); |
| 393 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, |
| 394 | &priv->disable_chain_noise_cal); |
| 395 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 396 | return 0; |
| 397 | |
| 398 | err: |
| 399 | IWL_ERROR("Can't open the debugfs directory\n"); |
| 400 | iwl_dbgfs_unregister(priv); |
| 401 | return -ENOENT; |
| 402 | } |
| 403 | EXPORT_SYMBOL(iwl_dbgfs_register); |
| 404 | |
| 405 | /** |
| 406 | * Remove the debugfs files and directories |
| 407 | * |
| 408 | */ |
| 409 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 410 | { |
| 411 | if (!(priv->dbgfs)) |
| 412 | return; |
| 413 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 414 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_eeprom); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 415 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics); |
| 416 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics); |
| 417 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame^] | 418 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 419 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); |
| 420 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 421 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB |
| 422 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); |
| 423 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); |
| 424 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ |
| 425 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 426 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); |
| 427 | kfree(priv->dbgfs); |
| 428 | priv->dbgfs = NULL; |
| 429 | } |
| 430 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
| 431 | |
| 432 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 433 | |