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