Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
| 5 | * Copyright(c) 2008 - 2011 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 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | *****************************************************************************/ |
| 28 | #include <linux/ieee80211.h> |
| 29 | #include <net/mac80211.h> |
| 30 | |
Stanislaw Gruszka | 98613be | 2011-11-15 14:19:34 +0100 | [diff] [blame] | 31 | #include "common.h" |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 32 | |
| 33 | /* create and remove of files */ |
| 34 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 35 | if (!debugfs_create_file(#name, mode, parent, il, \ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 36 | &il_dbgfs_##name##_ops)) \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 37 | goto err; \ |
| 38 | } while (0) |
| 39 | |
| 40 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 41 | struct dentry *__tmp; \ |
| 42 | __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ |
| 43 | parent, ptr); \ |
| 44 | if (IS_ERR(__tmp) || !__tmp) \ |
| 45 | goto err; \ |
| 46 | } while (0) |
| 47 | |
| 48 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
| 49 | struct dentry *__tmp; \ |
| 50 | __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ |
| 51 | parent, ptr); \ |
| 52 | if (IS_ERR(__tmp) || !__tmp) \ |
| 53 | goto err; \ |
| 54 | } while (0) |
| 55 | |
| 56 | /* file operation */ |
| 57 | #define DEBUGFS_READ_FUNC(name) \ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 58 | static ssize_t il_dbgfs_##name##_read(struct file *file, \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 59 | char __user *user_buf, \ |
| 60 | size_t count, loff_t *ppos); |
| 61 | |
| 62 | #define DEBUGFS_WRITE_FUNC(name) \ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 63 | static ssize_t il_dbgfs_##name##_write(struct file *file, \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 64 | const char __user *user_buf, \ |
| 65 | size_t count, loff_t *ppos); |
| 66 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 67 | static int |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 68 | il_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 69 | { |
| 70 | file->private_data = inode->i_private; |
| 71 | return 0; |
| 72 | } |
| 73 | |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 74 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 75 | DEBUGFS_READ_FUNC(name); \ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 76 | static const struct file_operations il_dbgfs_##name##_ops = { \ |
| 77 | .read = il_dbgfs_##name##_read, \ |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 78 | .open = il_dbgfs_open_file_generic, \ |
| 79 | .llseek = generic_file_llseek, \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 82 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 83 | DEBUGFS_WRITE_FUNC(name); \ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 84 | static const struct file_operations il_dbgfs_##name##_ops = { \ |
| 85 | .write = il_dbgfs_##name##_write, \ |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 86 | .open = il_dbgfs_open_file_generic, \ |
| 87 | .llseek = generic_file_llseek, \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 88 | }; |
| 89 | |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 90 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 91 | DEBUGFS_READ_FUNC(name); \ |
| 92 | DEBUGFS_WRITE_FUNC(name); \ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 93 | static const struct file_operations il_dbgfs_##name##_ops = { \ |
| 94 | .write = il_dbgfs_##name##_write, \ |
| 95 | .read = il_dbgfs_##name##_read, \ |
| 96 | .open = il_dbgfs_open_file_generic, \ |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 97 | .llseek = generic_file_llseek, \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 98 | }; |
| 99 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 100 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 101 | il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count, |
| 102 | loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 103 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 104 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 105 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 106 | char *buf; |
| 107 | int pos = 0; |
| 108 | |
| 109 | int cnt; |
| 110 | ssize_t ret; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 111 | const size_t bufsz = |
| 112 | 100 + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 113 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 114 | if (!buf) |
| 115 | return -ENOMEM; |
| 116 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 117 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 118 | pos += |
| 119 | scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", |
| 120 | il_get_mgmt_string(cnt), il->tx_stats.mgmt[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 121 | } |
| 122 | pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); |
| 123 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 124 | pos += |
| 125 | scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", |
| 126 | il_get_ctrl_string(cnt), il->tx_stats.ctrl[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 127 | } |
| 128 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 129 | pos += |
| 130 | scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 131 | il->tx_stats.data_cnt); |
| 132 | pos += |
| 133 | scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 134 | il->tx_stats.data_bytes); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 135 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 136 | kfree(buf); |
| 137 | return ret; |
| 138 | } |
| 139 | |
| 140 | static ssize_t |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 141 | il_dbgfs_clear_traffic_stats_write(struct file *file, |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 142 | const char __user *user_buf, size_t count, |
| 143 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 144 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 145 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 146 | u32 clear_flag; |
| 147 | char buf[8]; |
| 148 | int buf_size; |
| 149 | |
| 150 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 151 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 152 | if (copy_from_user(buf, user_buf, buf_size)) |
| 153 | return -EFAULT; |
| 154 | if (sscanf(buf, "%x", &clear_flag) != 1) |
| 155 | return -EFAULT; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 156 | il_clear_traffic_stats(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 157 | |
| 158 | return count; |
| 159 | } |
| 160 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 161 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 162 | il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count, |
| 163 | loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 164 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 165 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 166 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 167 | char *buf; |
| 168 | int pos = 0; |
| 169 | int cnt; |
| 170 | ssize_t ret; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 171 | const size_t bufsz = |
| 172 | 100 + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 173 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 174 | if (!buf) |
| 175 | return -ENOMEM; |
| 176 | |
| 177 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 178 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 179 | pos += |
| 180 | scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", |
| 181 | il_get_mgmt_string(cnt), il->rx_stats.mgmt[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 182 | } |
| 183 | pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); |
| 184 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 185 | pos += |
| 186 | scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", |
| 187 | il_get_ctrl_string(cnt), il->rx_stats.ctrl[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 188 | } |
| 189 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 190 | pos += |
| 191 | scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 192 | il->rx_stats.data_cnt); |
| 193 | pos += |
| 194 | scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 195 | il->rx_stats.data_bytes); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 196 | |
| 197 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 198 | kfree(buf); |
| 199 | return ret; |
| 200 | } |
| 201 | |
| 202 | #define BYTE1_MASK 0x000000ff; |
| 203 | #define BYTE2_MASK 0x0000ffff; |
| 204 | #define BYTE3_MASK 0x00ffffff; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 205 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 206 | il_dbgfs_sram_read(struct file *file, char __user *user_buf, size_t count, |
| 207 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 208 | { |
| 209 | u32 val; |
| 210 | char *buf; |
| 211 | ssize_t ret; |
| 212 | int i; |
| 213 | int pos = 0; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 214 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 215 | size_t bufsz; |
| 216 | |
| 217 | /* default is to dump the entire data segment */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 218 | if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) { |
| 219 | il->dbgfs_sram_offset = 0x800000; |
| 220 | if (il->ucode_type == UCODE_INIT) |
| 221 | il->dbgfs_sram_len = il->ucode_init_data.len; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 222 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 223 | il->dbgfs_sram_len = il->ucode_data.len; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 224 | } |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 225 | bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 226 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 227 | if (!buf) |
| 228 | return -ENOMEM; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 229 | pos += |
| 230 | scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", |
| 231 | il->dbgfs_sram_len); |
| 232 | pos += |
| 233 | scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", |
| 234 | il->dbgfs_sram_offset); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 235 | for (i = il->dbgfs_sram_len; i > 0; i -= 4) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 236 | val = |
| 237 | il_read_targ_mem(il, |
| 238 | il->dbgfs_sram_offset + |
| 239 | il->dbgfs_sram_len - i); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 240 | if (i < 4) { |
| 241 | switch (i) { |
| 242 | case 1: |
| 243 | val &= BYTE1_MASK; |
| 244 | break; |
| 245 | case 2: |
| 246 | val &= BYTE2_MASK; |
| 247 | break; |
| 248 | case 3: |
| 249 | val &= BYTE3_MASK; |
| 250 | break; |
| 251 | } |
| 252 | } |
| 253 | if (!(i % 16)) |
| 254 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 255 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
| 256 | } |
| 257 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 258 | |
| 259 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 260 | kfree(buf); |
| 261 | return ret; |
| 262 | } |
| 263 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 264 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 265 | il_dbgfs_sram_write(struct file *file, const char __user *user_buf, |
| 266 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 267 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 268 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 269 | char buf[64]; |
| 270 | int buf_size; |
| 271 | u32 offset, len; |
| 272 | |
| 273 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 274 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 275 | if (copy_from_user(buf, user_buf, buf_size)) |
| 276 | return -EFAULT; |
| 277 | |
| 278 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 279 | il->dbgfs_sram_offset = offset; |
| 280 | il->dbgfs_sram_len = len; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 281 | } else { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 282 | il->dbgfs_sram_offset = 0; |
| 283 | il->dbgfs_sram_len = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | return count; |
| 287 | } |
| 288 | |
| 289 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 290 | il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, |
| 291 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 292 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 293 | struct il_priv *il = file->private_data; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 294 | struct il_station_entry *station; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 295 | int max_sta = il->hw_params.max_stations; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 296 | char *buf; |
| 297 | int i, j, pos = 0; |
| 298 | ssize_t ret; |
| 299 | /* Add 30 for initial string */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 300 | const size_t bufsz = 30 + sizeof(char) * 500 * (il->num_stations); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 301 | |
| 302 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 303 | if (!buf) |
| 304 | return -ENOMEM; |
| 305 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 306 | pos += |
| 307 | scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
| 308 | il->num_stations); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 309 | |
| 310 | for (i = 0; i < max_sta; i++) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 311 | station = &il->stations[i]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 312 | if (!station->used) |
| 313 | continue; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 314 | pos += |
| 315 | scnprintf(buf + pos, bufsz - pos, |
| 316 | "station %d - addr: %pM, flags: %#x\n", i, |
| 317 | station->sta.sta.addr, |
| 318 | station->sta.station_flags_msk); |
| 319 | pos += |
| 320 | scnprintf(buf + pos, bufsz - pos, |
| 321 | "TID\tseq_num\ttxq_id\tframes\ttfds\t"); |
| 322 | pos += |
| 323 | scnprintf(buf + pos, bufsz - pos, |
| 324 | "start_idx\tbitmap\t\t\trate_n_flags\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 325 | |
| 326 | for (j = 0; j < MAX_TID_COUNT; j++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 327 | pos += |
| 328 | scnprintf(buf + pos, bufsz - pos, |
| 329 | "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", |
| 330 | j, station->tid[j].seq_number, |
| 331 | station->tid[j].agg.txq_id, |
| 332 | station->tid[j].agg.frame_count, |
| 333 | station->tid[j].tfds_in_queue, |
| 334 | station->tid[j].agg.start_idx, |
| 335 | station->tid[j].agg.bitmap, |
| 336 | station->tid[j].agg.rate_n_flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 337 | |
| 338 | if (station->tid[j].agg.wait_for_ba) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 339 | pos += |
| 340 | scnprintf(buf + pos, bufsz - pos, |
| 341 | " - waitforba"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 342 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 343 | } |
| 344 | |
| 345 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 346 | } |
| 347 | |
| 348 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 349 | kfree(buf); |
| 350 | return ret; |
| 351 | } |
| 352 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 353 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 354 | il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count, |
| 355 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 356 | { |
| 357 | ssize_t ret; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 358 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 359 | int pos = 0, ofs = 0, buf_size = 0; |
| 360 | const u8 *ptr; |
| 361 | char *buf; |
| 362 | u16 eeprom_ver; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 363 | size_t eeprom_len = il->cfg->base_params->eeprom_size; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 364 | buf_size = 4 * eeprom_len + 256; |
| 365 | |
| 366 | if (eeprom_len % 16) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 367 | IL_ERR("NVM size is not multiple of 16.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 368 | return -ENODATA; |
| 369 | } |
| 370 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 371 | ptr = il->eeprom; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 372 | if (!ptr) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 373 | IL_ERR("Invalid EEPROM memory\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 374 | return -ENOMEM; |
| 375 | } |
| 376 | |
| 377 | /* 4 characters for byte 0xYY */ |
| 378 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 379 | if (!buf) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 380 | IL_ERR("Can not allocate Buffer\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 381 | return -ENOMEM; |
| 382 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 383 | eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 384 | pos += |
| 385 | scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n", |
| 386 | eeprom_ver); |
| 387 | for (ofs = 0; ofs < eeprom_len; ofs += 16) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 388 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 389 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 390 | buf_size - pos, 0); |
| 391 | pos += strlen(buf + pos); |
| 392 | if (buf_size - pos > 0) |
| 393 | buf[pos++] = '\n'; |
| 394 | } |
| 395 | |
| 396 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 397 | kfree(buf); |
| 398 | return ret; |
| 399 | } |
| 400 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 401 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 402 | il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, |
| 403 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 404 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 405 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 406 | struct ieee80211_channel *channels = NULL; |
| 407 | const struct ieee80211_supported_band *supp_band = NULL; |
| 408 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 409 | char *buf; |
| 410 | ssize_t ret; |
| 411 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 412 | if (!test_bit(S_GEO_CONFIGURED, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 413 | return -EAGAIN; |
| 414 | |
| 415 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 416 | if (!buf) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 417 | IL_ERR("Can not allocate Buffer\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 418 | return -ENOMEM; |
| 419 | } |
| 420 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 421 | supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 422 | if (supp_band) { |
| 423 | channels = supp_band->channels; |
| 424 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 425 | pos += |
| 426 | scnprintf(buf + pos, bufsz - pos, |
| 427 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 428 | supp_band->n_channels); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 429 | |
| 430 | for (i = 0; i < supp_band->n_channels; i++) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 431 | pos += |
| 432 | scnprintf(buf + pos, bufsz - pos, |
| 433 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 434 | channels[i].hw_value, |
| 435 | channels[i].max_power, |
| 436 | channels[i]. |
| 437 | flags & IEEE80211_CHAN_RADAR ? |
| 438 | " (IEEE 802.11h required)" : "", |
| 439 | ((channels[i]. |
| 440 | flags & IEEE80211_CHAN_NO_IBSS) || |
| 441 | (channels[i]. |
| 442 | flags & IEEE80211_CHAN_RADAR)) ? "" : |
| 443 | ", IBSS", |
| 444 | channels[i]. |
| 445 | flags & IEEE80211_CHAN_PASSIVE_SCAN ? |
| 446 | "passive only" : "active/passive"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 447 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 448 | supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 449 | if (supp_band) { |
| 450 | channels = supp_band->channels; |
| 451 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 452 | pos += |
| 453 | scnprintf(buf + pos, bufsz - pos, |
| 454 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 455 | supp_band->n_channels); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 456 | |
| 457 | for (i = 0; i < supp_band->n_channels; i++) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 458 | pos += |
| 459 | scnprintf(buf + pos, bufsz - pos, |
| 460 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 461 | channels[i].hw_value, |
| 462 | channels[i].max_power, |
| 463 | channels[i]. |
| 464 | flags & IEEE80211_CHAN_RADAR ? |
| 465 | " (IEEE 802.11h required)" : "", |
| 466 | ((channels[i]. |
| 467 | flags & IEEE80211_CHAN_NO_IBSS) || |
| 468 | (channels[i]. |
| 469 | flags & IEEE80211_CHAN_RADAR)) ? "" : |
| 470 | ", IBSS", |
| 471 | channels[i]. |
| 472 | flags & IEEE80211_CHAN_PASSIVE_SCAN ? |
| 473 | "passive only" : "active/passive"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 474 | } |
| 475 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 476 | kfree(buf); |
| 477 | return ret; |
| 478 | } |
| 479 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 480 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 481 | il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, |
| 482 | loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 483 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 484 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 485 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 486 | char buf[512]; |
| 487 | int pos = 0; |
| 488 | const size_t bufsz = sizeof(buf); |
| 489 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 490 | pos += |
| 491 | scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", |
| 492 | test_bit(S_HCMD_ACTIVE, &il->status)); |
| 493 | pos += |
| 494 | scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", |
| 495 | test_bit(S_INT_ENABLED, &il->status)); |
| 496 | pos += |
| 497 | scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", |
| 498 | test_bit(S_RF_KILL_HW, &il->status)); |
| 499 | pos += |
| 500 | scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", |
| 501 | test_bit(S_CT_KILL, &il->status)); |
| 502 | pos += |
| 503 | scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", |
| 504 | test_bit(S_INIT, &il->status)); |
| 505 | pos += |
| 506 | scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", |
| 507 | test_bit(S_ALIVE, &il->status)); |
| 508 | pos += |
| 509 | scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", |
| 510 | test_bit(S_READY, &il->status)); |
| 511 | pos += |
| 512 | scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", |
| 513 | test_bit(S_TEMPERATURE, &il->status)); |
| 514 | pos += |
| 515 | scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", |
| 516 | test_bit(S_GEO_CONFIGURED, &il->status)); |
| 517 | pos += |
| 518 | scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", |
| 519 | test_bit(S_EXIT_PENDING, &il->status)); |
| 520 | pos += |
| 521 | scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", |
| 522 | test_bit(S_STATS, &il->status)); |
| 523 | pos += |
| 524 | scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", |
| 525 | test_bit(S_SCANNING, &il->status)); |
| 526 | pos += |
| 527 | scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", |
| 528 | test_bit(S_SCAN_ABORTING, &il->status)); |
| 529 | pos += |
| 530 | scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", |
| 531 | test_bit(S_SCAN_HW, &il->status)); |
| 532 | pos += |
| 533 | scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", |
| 534 | test_bit(S_POWER_PMI, &il->status)); |
| 535 | pos += |
| 536 | scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", |
| 537 | test_bit(S_FW_ERROR, &il->status)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 538 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 539 | } |
| 540 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 541 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 542 | il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count, |
| 543 | loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 544 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 545 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 546 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 547 | int pos = 0; |
| 548 | int cnt = 0; |
| 549 | char *buf; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 550 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 551 | ssize_t ret; |
| 552 | |
| 553 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 554 | if (!buf) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 555 | IL_ERR("Can not allocate Buffer\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 556 | return -ENOMEM; |
| 557 | } |
| 558 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 559 | pos += |
| 560 | scnprintf(buf + pos, bufsz - pos, "Interrupt Statistics Report:\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 561 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 562 | pos += |
| 563 | scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", |
| 564 | il->isr_stats.hw); |
| 565 | pos += |
| 566 | scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", |
| 567 | il->isr_stats.sw); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 568 | if (il->isr_stats.sw || il->isr_stats.hw) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 569 | pos += |
| 570 | scnprintf(buf + pos, bufsz - pos, |
| 571 | "\tLast Restarting Code: 0x%X\n", |
| 572 | il->isr_stats.err_code); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 573 | } |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 574 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 575 | pos += |
| 576 | scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", |
| 577 | il->isr_stats.sch); |
| 578 | pos += |
| 579 | scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", |
| 580 | il->isr_stats.alive); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 581 | #endif |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 582 | pos += |
| 583 | scnprintf(buf + pos, bufsz - pos, |
| 584 | "HW RF KILL switch toggled:\t %u\n", |
| 585 | il->isr_stats.rfkill); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 586 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 587 | pos += |
| 588 | scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", |
| 589 | il->isr_stats.ctkill); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 590 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 591 | pos += |
| 592 | scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", |
| 593 | il->isr_stats.wakeup); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 594 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 595 | pos += |
| 596 | scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n", |
| 597 | il->isr_stats.rx); |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 598 | for (cnt = 0; cnt < IL_CN_MAX; cnt++) { |
Stanislaw Gruszka | d0c7234 | 2011-08-30 15:39:42 +0200 | [diff] [blame] | 599 | if (il->isr_stats.handlers[cnt] > 0) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 600 | pos += |
| 601 | scnprintf(buf + pos, bufsz - pos, |
| 602 | "\tRx handler[%36s]:\t\t %u\n", |
| 603 | il_get_cmd_string(cnt), |
| 604 | il->isr_stats.handlers[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 605 | } |
| 606 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 607 | pos += |
| 608 | scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", |
| 609 | il->isr_stats.tx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 610 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 611 | pos += |
| 612 | scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", |
| 613 | il->isr_stats.unhandled); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 614 | |
| 615 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 616 | kfree(buf); |
| 617 | return ret; |
| 618 | } |
| 619 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 620 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 621 | il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf, |
| 622 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 623 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 624 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 625 | char buf[8]; |
| 626 | int buf_size; |
| 627 | u32 reset_flag; |
| 628 | |
| 629 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 630 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 631 | if (copy_from_user(buf, user_buf, buf_size)) |
| 632 | return -EFAULT; |
| 633 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 634 | return -EFAULT; |
| 635 | if (reset_flag == 0) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 636 | il_clear_isr_stats(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 637 | |
| 638 | return count; |
| 639 | } |
| 640 | |
| 641 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 642 | il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, |
| 643 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 644 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 645 | struct il_priv *il = file->private_data; |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 646 | struct il_rxon_context *ctx = &il->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 647 | int pos = 0, i; |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 648 | char buf[256]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 649 | const size_t bufsz = sizeof(buf); |
| 650 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 651 | pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", ctx->ctxid); |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 652 | for (i = 0; i < AC_NUM; i++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 653 | pos += |
| 654 | scnprintf(buf + pos, bufsz - pos, |
| 655 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 656 | pos += |
| 657 | scnprintf(buf + pos, bufsz - pos, |
| 658 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
| 659 | ctx->qos_data.def_qos_parm.ac[i].cw_min, |
| 660 | ctx->qos_data.def_qos_parm.ac[i].cw_max, |
| 661 | ctx->qos_data.def_qos_parm.ac[i].aifsn, |
| 662 | ctx->qos_data.def_qos_parm.ac[i].edca_txop); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 663 | } |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 664 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 665 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 666 | } |
| 667 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 668 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 669 | il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf, |
| 670 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 671 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 672 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 673 | char buf[8]; |
| 674 | int buf_size; |
| 675 | int ht40; |
| 676 | |
| 677 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 678 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 679 | if (copy_from_user(buf, user_buf, buf_size)) |
| 680 | return -EFAULT; |
| 681 | if (sscanf(buf, "%d", &ht40) != 1) |
| 682 | return -EFAULT; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 683 | if (!il_is_any_associated(il)) |
| 684 | il->disable_ht40 = ht40 ? true : false; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 685 | else { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 686 | IL_ERR("Sta associated with AP - " |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 687 | "Change to 40MHz channel support is not allowed\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 688 | return -EINVAL; |
| 689 | } |
| 690 | |
| 691 | return count; |
| 692 | } |
| 693 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 694 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 695 | il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf, |
| 696 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 697 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 698 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 699 | char buf[100]; |
| 700 | int pos = 0; |
| 701 | const size_t bufsz = sizeof(buf); |
| 702 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 703 | pos += |
| 704 | scnprintf(buf + pos, bufsz - pos, "11n 40MHz Mode: %s\n", |
| 705 | il->disable_ht40 ? "Disabled" : "Enabled"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 706 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 707 | } |
| 708 | |
| 709 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 710 | DEBUGFS_READ_FILE_OPS(nvm); |
| 711 | DEBUGFS_READ_FILE_OPS(stations); |
| 712 | DEBUGFS_READ_FILE_OPS(channels); |
| 713 | DEBUGFS_READ_FILE_OPS(status); |
| 714 | DEBUGFS_READ_WRITE_FILE_OPS(interrupt); |
| 715 | DEBUGFS_READ_FILE_OPS(qos); |
| 716 | DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); |
| 717 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 718 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 719 | il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, |
| 720 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 721 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 722 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 723 | int pos = 0, ofs = 0; |
| 724 | int cnt = 0, entry; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 725 | struct il_tx_queue *txq; |
| 726 | struct il_queue *q; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 727 | struct il_rx_queue *rxq = &il->rxq; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 728 | char *buf; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 729 | int bufsz = |
| 730 | ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + |
| 731 | (il->cfg->base_params->num_of_queues * 32 * 8) + 400; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 732 | const u8 *ptr; |
| 733 | ssize_t ret; |
| 734 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 735 | if (!il->txq) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 736 | IL_ERR("txq not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 737 | return -EAGAIN; |
| 738 | } |
| 739 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 740 | if (!buf) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 741 | IL_ERR("Can not allocate buffer\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 742 | return -ENOMEM; |
| 743 | } |
| 744 | pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 745 | for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { |
| 746 | txq = &il->txq[cnt]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 747 | q = &txq->q; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 748 | pos += |
| 749 | scnprintf(buf + pos, bufsz - pos, |
| 750 | "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, |
| 751 | q->read_ptr, q->write_ptr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 752 | } |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 753 | if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 754 | ptr = il->tx_traffic; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 755 | pos += |
| 756 | scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", |
| 757 | il->tx_traffic_idx); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 758 | for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { |
| 759 | for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 760 | entry++, ofs += 16) { |
| 761 | pos += |
| 762 | scnprintf(buf + pos, bufsz - pos, "0x%.4x ", |
| 763 | ofs); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 764 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 765 | buf + pos, bufsz - pos, 0); |
| 766 | pos += strlen(buf + pos); |
| 767 | if (bufsz - pos > 0) |
| 768 | buf[pos++] = '\n'; |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 774 | pos += |
| 775 | scnprintf(buf + pos, bufsz - pos, "read: %u, write: %u\n", |
| 776 | rxq->read, rxq->write); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 777 | |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 778 | if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 779 | ptr = il->rx_traffic; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 780 | pos += |
| 781 | scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", |
| 782 | il->rx_traffic_idx); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 783 | for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { |
| 784 | for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 785 | entry++, ofs += 16) { |
| 786 | pos += |
| 787 | scnprintf(buf + pos, bufsz - pos, "0x%.4x ", |
| 788 | ofs); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 789 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 790 | buf + pos, bufsz - pos, 0); |
| 791 | pos += strlen(buf + pos); |
| 792 | if (bufsz - pos > 0) |
| 793 | buf[pos++] = '\n'; |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 799 | kfree(buf); |
| 800 | return ret; |
| 801 | } |
| 802 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 803 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 804 | il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf, |
| 805 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 806 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 807 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 808 | char buf[8]; |
| 809 | int buf_size; |
| 810 | int traffic_log; |
| 811 | |
| 812 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 813 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 814 | if (copy_from_user(buf, user_buf, buf_size)) |
| 815 | return -EFAULT; |
| 816 | if (sscanf(buf, "%d", &traffic_log) != 1) |
| 817 | return -EFAULT; |
| 818 | if (traffic_log == 0) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 819 | il_reset_traffic_log(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 820 | |
| 821 | return count; |
| 822 | } |
| 823 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 824 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 825 | il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, |
| 826 | loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 827 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 828 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 829 | struct il_priv *il = file->private_data; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 830 | struct il_tx_queue *txq; |
| 831 | struct il_queue *q; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 832 | char *buf; |
| 833 | int pos = 0; |
| 834 | int cnt; |
| 835 | int ret; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 836 | const size_t bufsz = |
| 837 | sizeof(char) * 64 * il->cfg->base_params->num_of_queues; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 838 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 839 | if (!il->txq) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 840 | IL_ERR("txq not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 841 | return -EAGAIN; |
| 842 | } |
| 843 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 844 | if (!buf) |
| 845 | return -ENOMEM; |
| 846 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 847 | for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { |
| 848 | txq = &il->txq[cnt]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 849 | q = &txq->q; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 850 | pos += |
| 851 | scnprintf(buf + pos, bufsz - pos, |
| 852 | "hwq %.2d: read=%u write=%u stop=%d" |
| 853 | " swq_id=%#.2x (ac %d/hwq %d)\n", cnt, |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 854 | q->read_ptr, q->write_ptr, |
| 855 | !!test_bit(cnt, il->queue_stopped), |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 856 | txq->swq_id, txq->swq_id & 3, |
| 857 | (txq->swq_id >> 2) & 0x1f); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 858 | if (cnt >= 4) |
| 859 | continue; |
| 860 | /* for the ACs, display the stop count too */ |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 861 | pos += |
| 862 | scnprintf(buf + pos, bufsz - pos, |
| 863 | " stop-count: %d\n", |
| 864 | atomic_read(&il->queue_stop_count[cnt])); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 865 | } |
| 866 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 867 | kfree(buf); |
| 868 | return ret; |
| 869 | } |
| 870 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 871 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 872 | il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count, |
| 873 | loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 874 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 875 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 876 | struct il_priv *il = file->private_data; |
| 877 | struct il_rx_queue *rxq = &il->rxq; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 878 | char buf[256]; |
| 879 | int pos = 0; |
| 880 | const size_t bufsz = sizeof(buf); |
| 881 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 882 | pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", rxq->read); |
| 883 | pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", rxq->write); |
| 884 | pos += |
| 885 | scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", |
| 886 | rxq->free_count); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 887 | if (rxq->rb_stts) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 888 | pos += |
| 889 | scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", |
| 890 | le16_to_cpu(rxq->rb_stts-> |
| 891 | closed_rb_num) & 0x0FFF); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 892 | } else { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 893 | pos += |
| 894 | scnprintf(buf + pos, bufsz - pos, |
| 895 | "closed_rb_num: Not Allocated\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 896 | } |
| 897 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 898 | } |
| 899 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 900 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 901 | il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf, |
| 902 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 903 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 904 | struct il_priv *il = file->private_data; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 905 | return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, |
| 906 | count, ppos); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 907 | } |
| 908 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 909 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 910 | il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf, |
| 911 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 912 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 913 | struct il_priv *il = file->private_data; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 914 | return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, |
| 915 | count, ppos); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 916 | } |
| 917 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 918 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 919 | il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf, |
| 920 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 921 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 922 | struct il_priv *il = file->private_data; |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 923 | return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, |
| 924 | count, ppos); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 925 | } |
| 926 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 927 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 928 | il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf, |
| 929 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 930 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 931 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 932 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 933 | int pos = 0; |
| 934 | int cnt = 0; |
| 935 | char *buf; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 936 | int bufsz = sizeof(struct il_sensitivity_data) * 4 + 100; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 937 | ssize_t ret; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 938 | struct il_sensitivity_data *data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 939 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 940 | data = &il->sensitivity_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 941 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 942 | if (!buf) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 943 | IL_ERR("Can not allocate Buffer\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 944 | return -ENOMEM; |
| 945 | } |
| 946 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 947 | pos += |
| 948 | scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", |
| 949 | data->auto_corr_ofdm); |
| 950 | pos += |
| 951 | scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_mrc:\t\t %u\n", |
| 952 | data->auto_corr_ofdm_mrc); |
| 953 | pos += |
| 954 | scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", |
| 955 | data->auto_corr_ofdm_x1); |
| 956 | pos += |
| 957 | scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_mrc_x1:\t\t %u\n", |
| 958 | data->auto_corr_ofdm_mrc_x1); |
| 959 | pos += |
| 960 | scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", |
| 961 | data->auto_corr_cck); |
| 962 | pos += |
| 963 | scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", |
| 964 | data->auto_corr_cck_mrc); |
| 965 | pos += |
| 966 | scnprintf(buf + pos, bufsz - pos, |
| 967 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", |
| 968 | data->last_bad_plcp_cnt_ofdm); |
| 969 | pos += |
| 970 | scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", |
| 971 | data->last_fa_cnt_ofdm); |
| 972 | pos += |
| 973 | scnprintf(buf + pos, bufsz - pos, "last_bad_plcp_cnt_cck:\t\t %u\n", |
| 974 | data->last_bad_plcp_cnt_cck); |
| 975 | pos += |
| 976 | scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", |
| 977 | data->last_fa_cnt_cck); |
| 978 | pos += |
| 979 | scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", |
| 980 | data->nrg_curr_state); |
| 981 | pos += |
| 982 | scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", |
| 983 | data->nrg_prev_state); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 984 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); |
| 985 | for (cnt = 0; cnt < 10; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 986 | pos += |
| 987 | scnprintf(buf + pos, bufsz - pos, " %u", |
| 988 | data->nrg_value[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 989 | } |
| 990 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 991 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); |
| 992 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 993 | pos += |
| 994 | scnprintf(buf + pos, bufsz - pos, " %u", |
| 995 | data->nrg_silence_rssi[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 996 | } |
| 997 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 998 | pos += |
| 999 | scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", |
| 1000 | data->nrg_silence_ref); |
| 1001 | pos += |
| 1002 | scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", |
| 1003 | data->nrg_energy_idx); |
| 1004 | pos += |
| 1005 | scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", |
| 1006 | data->nrg_silence_idx); |
| 1007 | pos += |
| 1008 | scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", |
| 1009 | data->nrg_th_cck); |
| 1010 | pos += |
| 1011 | scnprintf(buf + pos, bufsz - pos, |
| 1012 | "nrg_auto_corr_silence_diff:\t %u\n", |
| 1013 | data->nrg_auto_corr_silence_diff); |
| 1014 | pos += |
| 1015 | scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", |
| 1016 | data->num_in_cck_no_fa); |
| 1017 | pos += |
| 1018 | scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", |
| 1019 | data->nrg_th_ofdm); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1020 | |
| 1021 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1022 | kfree(buf); |
| 1023 | return ret; |
| 1024 | } |
| 1025 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1026 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1027 | il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf, |
| 1028 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1029 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1030 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1031 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1032 | int pos = 0; |
| 1033 | int cnt = 0; |
| 1034 | char *buf; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1035 | int bufsz = sizeof(struct il_chain_noise_data) * 4 + 100; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1036 | ssize_t ret; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1037 | struct il_chain_noise_data *data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1038 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1039 | data = &il->chain_noise_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1040 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1041 | if (!buf) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1042 | IL_ERR("Can not allocate Buffer\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1043 | return -ENOMEM; |
| 1044 | } |
| 1045 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1046 | pos += |
| 1047 | scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", |
| 1048 | data->active_chains); |
| 1049 | pos += |
| 1050 | scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", |
| 1051 | data->chain_noise_a); |
| 1052 | pos += |
| 1053 | scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", |
| 1054 | data->chain_noise_b); |
| 1055 | pos += |
| 1056 | scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", |
| 1057 | data->chain_noise_c); |
| 1058 | pos += |
| 1059 | scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", |
| 1060 | data->chain_signal_a); |
| 1061 | pos += |
| 1062 | scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", |
| 1063 | data->chain_signal_b); |
| 1064 | pos += |
| 1065 | scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", |
| 1066 | data->chain_signal_c); |
| 1067 | pos += |
| 1068 | scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", |
| 1069 | data->beacon_count); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1070 | |
| 1071 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); |
| 1072 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1073 | pos += |
| 1074 | scnprintf(buf + pos, bufsz - pos, " %u", |
| 1075 | data->disconn_array[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1076 | } |
| 1077 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1078 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); |
| 1079 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1080 | pos += |
| 1081 | scnprintf(buf + pos, bufsz - pos, " %u", |
| 1082 | data->delta_gain_code[cnt]); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1083 | } |
| 1084 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1085 | pos += |
| 1086 | scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", |
| 1087 | data->radio_write); |
| 1088 | pos += |
| 1089 | scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", |
| 1090 | data->state); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1091 | |
| 1092 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1093 | kfree(buf); |
| 1094 | return ret; |
| 1095 | } |
| 1096 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1097 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1098 | il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf, |
| 1099 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1100 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1101 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1102 | char buf[60]; |
| 1103 | int pos = 0; |
| 1104 | const size_t bufsz = sizeof(buf); |
| 1105 | u32 pwrsave_status; |
| 1106 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1107 | pwrsave_status = |
| 1108 | _il_rd(il, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1109 | |
| 1110 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1111 | pos += |
| 1112 | scnprintf(buf + pos, bufsz - pos, "%s\n", |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1113 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : |
| 1114 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : |
| 1115 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : |
| 1116 | "error"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1117 | |
| 1118 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1119 | } |
| 1120 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1121 | static ssize_t |
| 1122 | il_dbgfs_clear_ucode_stats_write(struct file *file, |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1123 | const char __user *user_buf, size_t count, |
| 1124 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1125 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1126 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1127 | char buf[8]; |
| 1128 | int buf_size; |
| 1129 | int clear; |
| 1130 | |
| 1131 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1132 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1133 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1134 | return -EFAULT; |
| 1135 | if (sscanf(buf, "%d", &clear) != 1) |
| 1136 | return -EFAULT; |
| 1137 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1138 | /* make request to uCode to retrieve stats information */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1139 | mutex_lock(&il->mutex); |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1140 | il_send_stats_request(il, CMD_SYNC, true); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1141 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1142 | |
| 1143 | return count; |
| 1144 | } |
| 1145 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1146 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1147 | il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, |
| 1148 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1149 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1150 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1151 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1152 | int len = 0; |
| 1153 | char buf[20]; |
| 1154 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1155 | len = sprintf(buf, "0x%04X\n", le32_to_cpu(il->ctx.active.flags)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1156 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1157 | } |
| 1158 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1159 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1160 | il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, |
| 1161 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1162 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1163 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1164 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1165 | int len = 0; |
| 1166 | char buf[20]; |
| 1167 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1168 | len = |
| 1169 | sprintf(buf, "0x%04X\n", le32_to_cpu(il->ctx.active.filter_flags)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1170 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1171 | } |
| 1172 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1173 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1174 | il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, |
| 1175 | loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1176 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1177 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1178 | char *buf; |
| 1179 | int pos = 0; |
| 1180 | ssize_t ret = -EFAULT; |
| 1181 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1182 | if (il->cfg->ops->lib->dump_fh) { |
| 1183 | ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1184 | if (buf) { |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1185 | ret = |
| 1186 | simple_read_from_buffer(user_buf, count, ppos, buf, |
| 1187 | pos); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1188 | kfree(buf); |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | return ret; |
| 1193 | } |
| 1194 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1195 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1196 | il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf, |
| 1197 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1198 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1199 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1200 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1201 | int pos = 0; |
| 1202 | char buf[12]; |
| 1203 | const size_t bufsz = sizeof(buf); |
| 1204 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1205 | pos += |
| 1206 | scnprintf(buf + pos, bufsz - pos, "%d\n", |
| 1207 | il->missed_beacon_threshold); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1208 | |
| 1209 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1210 | } |
| 1211 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1212 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1213 | il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf, |
| 1214 | size_t count, loff_t *ppos) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1215 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1216 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1217 | char buf[8]; |
| 1218 | int buf_size; |
| 1219 | int missed; |
| 1220 | |
| 1221 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1222 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1223 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1224 | return -EFAULT; |
| 1225 | if (sscanf(buf, "%d", &missed) != 1) |
| 1226 | return -EINVAL; |
| 1227 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1228 | if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || |
| 1229 | missed > IL_MISSED_BEACON_THRESHOLD_MAX) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1230 | il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1231 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1232 | il->missed_beacon_threshold = missed; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1233 | |
| 1234 | return count; |
| 1235 | } |
| 1236 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1237 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1238 | il_dbgfs_force_reset_read(struct file *file, char __user *user_buf, |
| 1239 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1240 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1241 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1242 | struct il_priv *il = file->private_data; |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1243 | int pos = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1244 | char buf[300]; |
| 1245 | const size_t bufsz = sizeof(buf); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1246 | struct il_force_reset *force_reset; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1247 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1248 | force_reset = &il->force_reset; |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1249 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1250 | pos += |
| 1251 | scnprintf(buf + pos, bufsz - pos, "\tnumber of reset request: %d\n", |
| 1252 | force_reset->reset_request_count); |
| 1253 | pos += |
| 1254 | scnprintf(buf + pos, bufsz - pos, |
| 1255 | "\tnumber of reset request success: %d\n", |
| 1256 | force_reset->reset_success_count); |
| 1257 | pos += |
| 1258 | scnprintf(buf + pos, bufsz - pos, |
| 1259 | "\tnumber of reset request reject: %d\n", |
| 1260 | force_reset->reset_reject_count); |
| 1261 | pos += |
| 1262 | scnprintf(buf + pos, bufsz - pos, "\treset duration: %lu\n", |
| 1263 | force_reset->reset_duration); |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1264 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1265 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1266 | } |
| 1267 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1268 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1269 | il_dbgfs_force_reset_write(struct file *file, const char __user *user_buf, |
| 1270 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1271 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1272 | |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1273 | int ret; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1274 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1275 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1276 | ret = il_force_reset(il, true); |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1277 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1278 | return ret ? ret : count; |
| 1279 | } |
| 1280 | |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1281 | static ssize_t |
Stanislaw Gruszka | 1722f8e | 2011-11-15 14:51:01 +0100 | [diff] [blame^] | 1282 | il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, |
| 1283 | size_t count, loff_t *ppos) |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1284 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1285 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1286 | struct il_priv *il = file->private_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1287 | char buf[8]; |
| 1288 | int buf_size; |
| 1289 | int timeout; |
| 1290 | |
| 1291 | memset(buf, 0, sizeof(buf)); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1292 | buf_size = min(count, sizeof(buf) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1293 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1294 | return -EFAULT; |
| 1295 | if (sscanf(buf, "%d", &timeout) != 1) |
| 1296 | return -EINVAL; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1297 | if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) |
| 1298 | timeout = IL_DEF_WD_TIMEOUT; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1299 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1300 | il->cfg->base_params->wd_timeout = timeout; |
| 1301 | il_setup_watchdog(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1302 | return count; |
| 1303 | } |
| 1304 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1305 | DEBUGFS_READ_FILE_OPS(rx_stats); |
| 1306 | DEBUGFS_READ_FILE_OPS(tx_stats); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1307 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); |
| 1308 | DEBUGFS_READ_FILE_OPS(rx_queue); |
| 1309 | DEBUGFS_READ_FILE_OPS(tx_queue); |
| 1310 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
| 1311 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
| 1312 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
| 1313 | DEBUGFS_READ_FILE_OPS(sensitivity); |
| 1314 | DEBUGFS_READ_FILE_OPS(chain_noise); |
| 1315 | DEBUGFS_READ_FILE_OPS(power_save_status); |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1316 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_stats); |
| 1317 | DEBUGFS_WRITE_FILE_OPS(clear_traffic_stats); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1318 | DEBUGFS_READ_FILE_OPS(fh_reg); |
| 1319 | DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1320 | DEBUGFS_READ_WRITE_FILE_OPS(force_reset); |
| 1321 | DEBUGFS_READ_FILE_OPS(rxon_flags); |
| 1322 | DEBUGFS_READ_FILE_OPS(rxon_filter_flags); |
| 1323 | DEBUGFS_WRITE_FILE_OPS(wd_timeout); |
| 1324 | |
| 1325 | /* |
| 1326 | * Create the debugfs files and directories |
| 1327 | * |
| 1328 | */ |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1329 | int |
| 1330 | il_dbgfs_register(struct il_priv *il, const char *name) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1331 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1332 | struct dentry *phyd = il->hw->wiphy->debugfsdir; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1333 | struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; |
| 1334 | |
| 1335 | dir_drv = debugfs_create_dir(name, phyd); |
| 1336 | if (!dir_drv) |
| 1337 | return -ENOMEM; |
| 1338 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1339 | il->debugfs_dir = dir_drv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1340 | |
| 1341 | dir_data = debugfs_create_dir("data", dir_drv); |
| 1342 | if (!dir_data) |
| 1343 | goto err; |
| 1344 | dir_rf = debugfs_create_dir("rf", dir_drv); |
| 1345 | if (!dir_rf) |
| 1346 | goto err; |
| 1347 | dir_debug = debugfs_create_dir("debug", dir_drv); |
| 1348 | if (!dir_debug) |
| 1349 | goto err; |
| 1350 | |
| 1351 | DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); |
| 1352 | DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1353 | DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); |
| 1354 | DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); |
| 1355 | DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); |
| 1356 | DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); |
| 1357 | DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); |
| 1358 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1359 | DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); |
| 1360 | DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1361 | DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); |
| 1362 | DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); |
| 1363 | DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); |
| 1364 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1365 | DEBUGFS_ADD_FILE(clear_ucode_stats, dir_debug, S_IWUSR); |
| 1366 | DEBUGFS_ADD_FILE(clear_traffic_stats, dir_debug, S_IWUSR); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1367 | DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); |
| 1368 | DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1369 | DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); |
| 1370 | DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); |
| 1371 | DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); |
| 1372 | DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); |
| 1373 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1374 | if (il->cfg->base_params->sensitivity_calib_by_driver) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1375 | DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1376 | if (il->cfg->base_params->chain_noise_calib_by_driver) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1377 | DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1378 | DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); |
| 1379 | DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); |
| 1380 | DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1381 | if (il->cfg->base_params->sensitivity_calib_by_driver) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1382 | DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1383 | &il->disable_sens_cal); |
| 1384 | if (il->cfg->base_params->chain_noise_calib_by_driver) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1385 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1386 | &il->disable_chain_noise_cal); |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1387 | DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, &il->disable_tx_power_cal); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1388 | return 0; |
| 1389 | |
| 1390 | err: |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1391 | IL_ERR("Can't create the debugfs directory\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1392 | il_dbgfs_unregister(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1393 | return -ENOMEM; |
| 1394 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1395 | EXPORT_SYMBOL(il_dbgfs_register); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1396 | |
| 1397 | /** |
| 1398 | * Remove the debugfs files and directories |
| 1399 | * |
| 1400 | */ |
Stanislaw Gruszka | e739236 | 2011-11-15 14:45:59 +0100 | [diff] [blame] | 1401 | void |
| 1402 | il_dbgfs_unregister(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1403 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1404 | if (!il->debugfs_dir) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1405 | return; |
| 1406 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1407 | debugfs_remove_recursive(il->debugfs_dir); |
| 1408 | il->debugfs_dir = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1409 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1410 | EXPORT_SYMBOL(il_dbgfs_unregister); |