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); \ |
Zhaolei | 9b24001 | 2008-10-22 17:06:12 +0800 | [diff] [blame] | 61 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \ |
| 62 | || !dbgfs->dbgfs_##parent##_files.file_##name) \ |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 63 | goto err; \ |
| 64 | } while (0) |
| 65 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 66 | #define DEBUGFS_REMOVE(name) do { \ |
| 67 | debugfs_remove(name); \ |
| 68 | name = NULL; \ |
| 69 | } while (0); |
| 70 | |
| 71 | /* file operation */ |
| 72 | #define DEBUGFS_READ_FUNC(name) \ |
| 73 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ |
| 74 | char __user *user_buf, \ |
| 75 | size_t count, loff_t *ppos); |
| 76 | |
| 77 | #define DEBUGFS_WRITE_FUNC(name) \ |
| 78 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ |
| 79 | const char __user *user_buf, \ |
| 80 | size_t count, loff_t *ppos); |
| 81 | |
| 82 | |
| 83 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
| 84 | { |
| 85 | file->private_data = inode->i_private; |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 90 | DEBUGFS_READ_FUNC(name); \ |
| 91 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 92 | .read = iwl_dbgfs_##name##_read, \ |
| 93 | .open = iwl_dbgfs_open_file_generic, \ |
| 94 | }; |
| 95 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 96 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 97 | DEBUGFS_WRITE_FUNC(name); \ |
| 98 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 99 | .write = iwl_dbgfs_##name##_write, \ |
| 100 | .open = iwl_dbgfs_open_file_generic, \ |
| 101 | }; |
| 102 | |
| 103 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 104 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 105 | DEBUGFS_READ_FUNC(name); \ |
| 106 | DEBUGFS_WRITE_FUNC(name); \ |
| 107 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 108 | .write = iwl_dbgfs_##name##_write, \ |
| 109 | .read = iwl_dbgfs_##name##_read, \ |
| 110 | .open = iwl_dbgfs_open_file_generic, \ |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
| 115 | char __user *user_buf, |
| 116 | size_t count, loff_t *ppos) { |
| 117 | |
| 118 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 119 | char buf[256]; |
| 120 | int pos = 0; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 121 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 122 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 123 | pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n", |
| 124 | priv->tx_stats[0].cnt); |
| 125 | pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n", |
| 126 | priv->tx_stats[1].cnt); |
| 127 | pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n", |
| 128 | priv->tx_stats[2].cnt); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 129 | |
| 130 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 131 | } |
| 132 | |
| 133 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, |
| 134 | char __user *user_buf, |
| 135 | size_t count, loff_t *ppos) { |
| 136 | |
| 137 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 138 | char buf[256]; |
| 139 | int pos = 0; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 140 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 141 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 142 | pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n", |
| 143 | priv->rx_stats[0].cnt); |
| 144 | pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n", |
| 145 | priv->rx_stats[1].cnt); |
| 146 | pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n", |
| 147 | priv->rx_stats[2].cnt); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 148 | |
| 149 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 150 | } |
| 151 | |
| 152 | #define BYTE1_MASK 0x000000ff; |
| 153 | #define BYTE2_MASK 0x0000ffff; |
| 154 | #define BYTE3_MASK 0x00ffffff; |
| 155 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 156 | char __user *user_buf, |
| 157 | size_t count, loff_t *ppos) |
| 158 | { |
| 159 | u32 val; |
| 160 | char buf[1024]; |
| 161 | ssize_t ret; |
| 162 | int i; |
| 163 | int pos = 0; |
| 164 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 165 | const size_t bufsz = sizeof(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 166 | |
| 167 | printk(KERN_DEBUG "offset is: 0x%x\tlen is: 0x%x\n", |
| 168 | priv->dbgfs->sram_offset, priv->dbgfs->sram_len); |
| 169 | |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 170 | iwl_grab_nic_access(priv); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 171 | for (i = priv->dbgfs->sram_len; i > 0; i -= 4) { |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 172 | val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 173 | priv->dbgfs->sram_len - i); |
| 174 | if (i < 4) { |
| 175 | switch (i) { |
| 176 | case 1: |
| 177 | val &= BYTE1_MASK; |
| 178 | break; |
| 179 | case 2: |
| 180 | val &= BYTE2_MASK; |
| 181 | break; |
| 182 | case 3: |
| 183 | val &= BYTE3_MASK; |
| 184 | break; |
| 185 | } |
| 186 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 187 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 188 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 189 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 190 | iwl_release_nic_access(priv); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 191 | |
| 192 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 193 | return ret; |
| 194 | } |
| 195 | |
| 196 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 197 | const char __user *user_buf, |
| 198 | size_t count, loff_t *ppos) |
| 199 | { |
| 200 | struct iwl_priv *priv = file->private_data; |
| 201 | char buf[64]; |
| 202 | int buf_size; |
| 203 | u32 offset, len; |
| 204 | |
| 205 | memset(buf, 0, sizeof(buf)); |
| 206 | buf_size = min(count, sizeof(buf) - 1); |
| 207 | if (copy_from_user(buf, user_buf, buf_size)) |
| 208 | return -EFAULT; |
| 209 | |
| 210 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
| 211 | priv->dbgfs->sram_offset = offset; |
| 212 | priv->dbgfs->sram_len = len; |
| 213 | } else { |
| 214 | priv->dbgfs->sram_offset = 0; |
| 215 | priv->dbgfs->sram_len = 0; |
| 216 | } |
| 217 | |
| 218 | return count; |
| 219 | } |
| 220 | |
| 221 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 222 | size_t count, loff_t *ppos) |
| 223 | { |
| 224 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 225 | struct iwl_station_entry *station; |
Tomas Winkler | 5425e49 | 2008-04-15 16:01:38 -0700 | [diff] [blame] | 226 | int max_sta = priv->hw_params.max_stations; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 227 | char *buf; |
| 228 | int i, j, pos = 0; |
| 229 | ssize_t ret; |
| 230 | /* Add 30 for initial string */ |
| 231 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 232 | |
| 233 | buf = kmalloc(bufsz, GFP_KERNEL); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 234 | if (!buf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 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); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 245 | pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 246 | station->sta.sta.sta_id); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 247 | pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 248 | station->sta.mode); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 249 | pos += scnprintf(buf + pos, bufsz - pos, |
| 250 | "flags: 0x%x\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 251 | station->sta.station_flags_msk); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 252 | pos += scnprintf(buf + pos, bufsz - pos, |
| 253 | "ps_status: %u\n", station->ps_status); |
| 254 | pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); |
| 255 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 256 | "seq_num\t\ttxq_id"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 257 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 258 | "\tframe_count\twait_for_ba\t"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 259 | pos += scnprintf(buf + pos, bufsz - pos, |
| 260 | "start_idx\tbitmap0\t"); |
| 261 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 262 | "bitmap1\trate_n_flags"); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 263 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 264 | |
| 265 | for (j = 0; j < MAX_TID_COUNT; j++) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 266 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 267 | "[%d]:\t\t%u", j, |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 268 | station->tid[j].seq_number); |
| 269 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 270 | "\t%u\t\t%u\t\t%u\t\t", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 271 | station->tid[j].agg.txq_id, |
| 272 | station->tid[j].agg.frame_count, |
| 273 | station->tid[j].agg.wait_for_ba); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 274 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 275 | "%u\t%llu\t%u", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 276 | station->tid[j].agg.start_idx, |
John W. Linville | 1678859 | 2008-04-01 20:59:32 -0400 | [diff] [blame] | 277 | (unsigned long long)station->tid[j].agg.bitmap, |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 278 | station->tid[j].agg.rate_n_flags); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 279 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 280 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 281 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
| 285 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 286 | kfree(buf); |
| 287 | return ret; |
| 288 | } |
| 289 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 290 | static ssize_t iwl_dbgfs_eeprom_read(struct file *file, |
| 291 | char __user *user_buf, |
| 292 | size_t count, |
| 293 | loff_t *ppos) |
| 294 | { |
| 295 | ssize_t ret; |
| 296 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 297 | int pos = 0, ofs = 0, buf_size = 0; |
| 298 | const u8 *ptr; |
| 299 | char *buf; |
| 300 | size_t eeprom_len = priv->cfg->eeprom_size; |
| 301 | buf_size = 4 * eeprom_len + 256; |
| 302 | |
| 303 | if (eeprom_len % 16) { |
| 304 | IWL_ERROR("EEPROM size is not multiple of 16.\n"); |
| 305 | return -ENODATA; |
| 306 | } |
| 307 | |
| 308 | /* 4 characters for byte 0xYY */ |
| 309 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 310 | if (!buf) { |
| 311 | IWL_ERROR("Can not allocate Buffer\n"); |
| 312 | return -ENOMEM; |
| 313 | } |
| 314 | |
| 315 | ptr = priv->eeprom; |
| 316 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 317 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 318 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 319 | buf_size - pos, 0); |
| 320 | pos += strlen(buf); |
| 321 | if (buf_size - pos > 0) |
| 322 | buf[pos++] = '\n'; |
| 323 | } |
| 324 | |
| 325 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 326 | kfree(buf); |
| 327 | return ret; |
| 328 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 329 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 330 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
| 331 | const char __user *user_buf, |
| 332 | size_t count, loff_t *ppos) |
| 333 | { |
| 334 | struct iwl_priv *priv = file->private_data; |
| 335 | u32 event_log_flag; |
| 336 | char buf[8]; |
| 337 | int buf_size; |
| 338 | |
| 339 | memset(buf, 0, sizeof(buf)); |
| 340 | buf_size = min(count, sizeof(buf) - 1); |
| 341 | if (copy_from_user(buf, user_buf, buf_size)) |
| 342 | return -EFAULT; |
| 343 | if (sscanf(buf, "%d", &event_log_flag) != 1) |
| 344 | return -EFAULT; |
| 345 | if (event_log_flag == 1) |
| 346 | iwl_dump_nic_event_log(priv); |
| 347 | |
| 348 | return count; |
| 349 | } |
| 350 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 351 | |
| 352 | |
| 353 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, |
| 354 | size_t count, loff_t *ppos) |
| 355 | { |
| 356 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 357 | struct ieee80211_channel *channels = NULL; |
| 358 | const struct ieee80211_supported_band *supp_band = NULL; |
| 359 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 360 | char *buf; |
| 361 | ssize_t ret; |
| 362 | |
| 363 | if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) |
| 364 | return -EAGAIN; |
| 365 | |
| 366 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 367 | if (!buf) { |
| 368 | IWL_ERROR("Can not allocate Buffer\n"); |
| 369 | return -ENOMEM; |
| 370 | } |
| 371 | |
| 372 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); |
| 373 | channels = supp_band->channels; |
| 374 | |
| 375 | pos += scnprintf(buf + pos, bufsz - pos, |
| 376 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 377 | supp_band->n_channels); |
| 378 | |
| 379 | for (i = 0; i < supp_band->n_channels; i++) |
| 380 | pos += scnprintf(buf + pos, bufsz - pos, |
| 381 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 382 | ieee80211_frequency_to_channel( |
| 383 | channels[i].center_freq), |
| 384 | channels[i].max_power, |
| 385 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 386 | " (IEEE 802.11h required)" : "", |
| 387 | (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 388 | || (channels[i].flags & |
| 389 | IEEE80211_CHAN_RADAR)) ? "" : |
| 390 | ", IBSS", |
| 391 | channels[i].flags & |
| 392 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 393 | "passive only" : "active/passive"); |
| 394 | |
| 395 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
| 396 | channels = supp_band->channels; |
| 397 | |
| 398 | pos += scnprintf(buf + pos, bufsz - pos, |
| 399 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 400 | supp_band->n_channels); |
| 401 | |
| 402 | for (i = 0; i < supp_band->n_channels; i++) |
| 403 | pos += scnprintf(buf + pos, bufsz - pos, |
| 404 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 405 | ieee80211_frequency_to_channel( |
| 406 | channels[i].center_freq), |
| 407 | channels[i].max_power, |
| 408 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 409 | " (IEEE 802.11h required)" : "", |
| 410 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 411 | || (channels[i].flags & |
| 412 | IEEE80211_CHAN_RADAR)) ? "" : |
| 413 | ", IBSS", |
| 414 | channels[i].flags & |
| 415 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 416 | "passive only" : "active/passive"); |
| 417 | |
| 418 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 419 | kfree(buf); |
| 420 | return ret; |
| 421 | } |
| 422 | |
| 423 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 424 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 425 | DEBUGFS_WRITE_FILE_OPS(log_event); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 426 | DEBUGFS_READ_FILE_OPS(eeprom); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 427 | DEBUGFS_READ_FILE_OPS(stations); |
| 428 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 429 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 430 | DEBUGFS_READ_FILE_OPS(channels); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 431 | |
| 432 | /* |
| 433 | * Create the debugfs files and directories |
| 434 | * |
| 435 | */ |
| 436 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 437 | { |
| 438 | struct iwl_debugfs *dbgfs; |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 439 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 440 | int ret = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 441 | |
| 442 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); |
| 443 | if (!dbgfs) { |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 444 | ret = -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 445 | goto err; |
| 446 | } |
| 447 | |
| 448 | priv->dbgfs = dbgfs; |
| 449 | dbgfs->name = name; |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 450 | dbgfs->dir_drv = debugfs_create_dir(name, phyd); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 451 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) { |
| 452 | ret = -ENOENT; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 453 | goto err; |
| 454 | } |
| 455 | |
| 456 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 457 | DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 458 | DEBUGFS_ADD_FILE(eeprom, data); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 459 | DEBUGFS_ADD_FILE(sram, data); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 460 | DEBUGFS_ADD_FILE(log_event, data); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 461 | DEBUGFS_ADD_FILE(stations, data); |
| 462 | DEBUGFS_ADD_FILE(rx_statistics, data); |
| 463 | DEBUGFS_ADD_FILE(tx_statistics, data); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 464 | DEBUGFS_ADD_FILE(channels, data); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 465 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); |
| 466 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, |
| 467 | &priv->disable_chain_noise_cal); |
Emmanuel Grumbach | 203566f | 2008-06-12 09:46:54 +0800 | [diff] [blame] | 468 | DEBUGFS_ADD_BOOL(disable_tx_power, rf, &priv->disable_tx_power_cal); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 469 | return 0; |
| 470 | |
| 471 | err: |
| 472 | IWL_ERROR("Can't open the debugfs directory\n"); |
| 473 | iwl_dbgfs_unregister(priv); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 474 | return ret; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 475 | } |
| 476 | EXPORT_SYMBOL(iwl_dbgfs_register); |
| 477 | |
| 478 | /** |
| 479 | * Remove the debugfs files and directories |
| 480 | * |
| 481 | */ |
| 482 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 483 | { |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 484 | if (!priv->dbgfs) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 485 | return; |
| 486 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 487 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_eeprom); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 488 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics); |
| 489 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics); |
| 490 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 491 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 492 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 493 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 494 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 495 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); |
| 496 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); |
Emmanuel Grumbach | 203566f | 2008-06-12 09:46:54 +0800 | [diff] [blame] | 497 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 498 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 499 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); |
| 500 | kfree(priv->dbgfs); |
| 501 | priv->dbgfs = NULL; |
| 502 | } |
| 503 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
| 504 | |
| 505 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 506 | |