Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 5 | * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved. |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of version 2 of the GNU General Public License as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 19 | * USA |
| 20 | * |
| 21 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 22 | * in the file called COPYING. |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 23 | * |
| 24 | * Contact Information: |
Winkler, Tomas | 759ef89 | 2008-12-09 11:28:58 -0800 | [diff] [blame] | 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | *****************************************************************************/ |
| 28 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 30 | #include <linux/kernel.h> |
| 31 | #include <linux/module.h> |
| 32 | #include <linux/debugfs.h> |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 33 | #include <linux/ieee80211.h> |
| 34 | #include <net/mac80211.h> |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 35 | #include "iwl-debug.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 36 | #include "iwl-io.h" |
Johannes Berg | 1023fdc | 2012-05-15 12:16:34 +0200 | [diff] [blame] | 37 | #include "dev.h" |
| 38 | #include "agn.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 39 | |
| 40 | /* create and remove of files */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 41 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
| 42 | if (!debugfs_create_file(#name, mode, parent, priv, \ |
| 43 | &iwl_dbgfs_##name##_ops)) \ |
| 44 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 45 | } while (0) |
| 46 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 47 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 48 | struct dentry *__tmp; \ |
| 49 | __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ |
| 50 | parent, ptr); \ |
| 51 | if (IS_ERR(__tmp) || !__tmp) \ |
| 52 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 53 | } while (0) |
| 54 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 55 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
| 56 | struct dentry *__tmp; \ |
| 57 | __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ |
| 58 | parent, ptr); \ |
| 59 | if (IS_ERR(__tmp) || !__tmp) \ |
| 60 | goto err; \ |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 61 | } while (0) |
| 62 | |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 63 | #define DEBUGFS_ADD_U32(name, parent, ptr, mode) do { \ |
| 64 | struct dentry *__tmp; \ |
| 65 | __tmp = debugfs_create_u32(#name, mode, \ |
| 66 | parent, ptr); \ |
| 67 | if (IS_ERR(__tmp) || !__tmp) \ |
| 68 | goto err; \ |
| 69 | } while (0) |
| 70 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 71 | /* file operation */ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 72 | #define DEBUGFS_READ_FILE_OPS(name) \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 73 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
Richard A. Griffiths | 0ff1bd3 | 2012-06-28 13:14:11 -0700 | [diff] [blame] | 74 | .read = iwl_dbgfs_##name##_read, \ |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 75 | .open = simple_open, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 76 | .llseek = generic_file_llseek, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 79 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 80 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 81 | .write = iwl_dbgfs_##name##_write, \ |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 82 | .open = simple_open, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 83 | .llseek = generic_file_llseek, \ |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 87 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 88 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 89 | .write = iwl_dbgfs_##name##_write, \ |
| 90 | .read = iwl_dbgfs_##name##_read, \ |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 91 | .open = simple_open, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 92 | .llseek = generic_file_llseek, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 95 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 96 | char __user *user_buf, |
| 97 | size_t count, loff_t *ppos) |
| 98 | { |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 99 | u32 val = 0; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 100 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 101 | ssize_t ret; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 102 | int i = 0; |
| 103 | bool device_format = false; |
| 104 | int offset = 0; |
| 105 | int len = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 106 | int pos = 0; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 107 | int sram; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 108 | struct iwl_priv *priv = file->private_data; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 109 | const struct fw_img *img; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 110 | size_t bufsz; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 111 | |
Johannes Berg | 4fc79db | 2012-08-21 18:57:11 +0200 | [diff] [blame] | 112 | if (!iwl_is_ready_rf(priv)) |
| 113 | return -EAGAIN; |
| 114 | |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 115 | /* default is to dump the entire data segment */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 116 | if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { |
| 117 | priv->dbgfs_sram_offset = 0x800000; |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 118 | if (!priv->ucode_loaded) |
David Spinadel | 8f7ffbe | 2012-03-10 13:00:10 -0800 | [diff] [blame] | 119 | return -EINVAL; |
Meenakshi Venkataraman | a42506e | 2012-03-15 13:26:57 -0700 | [diff] [blame] | 120 | img = &priv->fw->img[priv->cur_ucode]; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 121 | priv->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 122 | } |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 123 | len = priv->dbgfs_sram_len; |
| 124 | |
| 125 | if (len == -4) { |
| 126 | device_format = true; |
| 127 | len = 4; |
| 128 | } |
| 129 | |
| 130 | bufsz = 50 + len * 4; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 131 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 132 | if (!buf) |
| 133 | return -ENOMEM; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 134 | |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 135 | pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 136 | len); |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 137 | pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 138 | priv->dbgfs_sram_offset); |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 139 | |
| 140 | /* adjust sram address since reads are only on even u32 boundaries */ |
| 141 | offset = priv->dbgfs_sram_offset & 0x3; |
| 142 | sram = priv->dbgfs_sram_offset & ~0x3; |
| 143 | |
| 144 | /* read the first u32 from sram */ |
Emmanuel Grumbach | 4fd442d | 2012-12-24 14:27:11 +0200 | [diff] [blame] | 145 | val = iwl_trans_read_mem32(priv->trans, sram); |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 146 | |
| 147 | for (; len; len--) { |
| 148 | /* put the address at the start of every line */ |
| 149 | if (i == 0) |
| 150 | pos += scnprintf(buf + pos, bufsz - pos, |
| 151 | "%08X: ", sram + offset); |
| 152 | |
| 153 | if (device_format) |
| 154 | pos += scnprintf(buf + pos, bufsz - pos, |
| 155 | "%02x", (val >> (8 * (3 - offset))) & 0xff); |
| 156 | else |
| 157 | pos += scnprintf(buf + pos, bufsz - pos, |
| 158 | "%02x ", (val >> (8 * offset)) & 0xff); |
| 159 | |
| 160 | /* if all bytes processed, read the next u32 from sram */ |
| 161 | if (++offset == 4) { |
| 162 | sram += 4; |
| 163 | offset = 0; |
Emmanuel Grumbach | 4fd442d | 2012-12-24 14:27:11 +0200 | [diff] [blame] | 164 | val = iwl_trans_read_mem32(priv->trans, sram); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 165 | } |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 166 | |
| 167 | /* put in extra spaces and split lines for human readability */ |
| 168 | if (++i == 16) { |
| 169 | i = 0; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 170 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 171 | } else if (!(i & 7)) { |
| 172 | pos += scnprintf(buf + pos, bufsz - pos, " "); |
| 173 | } else if (!(i & 3)) { |
| 174 | pos += scnprintf(buf + pos, bufsz - pos, " "); |
| 175 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 176 | } |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 177 | if (i) |
| 178 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 179 | |
| 180 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 181 | kfree(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 182 | return ret; |
| 183 | } |
| 184 | |
| 185 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 186 | const char __user *user_buf, |
| 187 | size_t count, loff_t *ppos) |
| 188 | { |
| 189 | struct iwl_priv *priv = file->private_data; |
| 190 | char buf[64]; |
| 191 | int buf_size; |
| 192 | u32 offset, len; |
| 193 | |
| 194 | memset(buf, 0, sizeof(buf)); |
| 195 | buf_size = min(count, sizeof(buf) - 1); |
| 196 | if (copy_from_user(buf, user_buf, buf_size)) |
| 197 | return -EFAULT; |
| 198 | |
| 199 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 200 | priv->dbgfs_sram_offset = offset; |
| 201 | priv->dbgfs_sram_len = len; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 202 | } else if (sscanf(buf, "%x", &offset) == 1) { |
| 203 | priv->dbgfs_sram_offset = offset; |
| 204 | priv->dbgfs_sram_len = -4; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 205 | } else { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 206 | priv->dbgfs_sram_offset = 0; |
| 207 | priv->dbgfs_sram_len = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | return count; |
| 211 | } |
| 212 | |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 213 | static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, |
| 214 | char __user *user_buf, |
| 215 | size_t count, loff_t *ppos) |
| 216 | { |
| 217 | struct iwl_priv *priv = file->private_data; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 218 | const struct fw_img *img = &priv->fw->img[IWL_UCODE_WOWLAN]; |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 219 | |
| 220 | if (!priv->wowlan_sram) |
| 221 | return -ENODATA; |
| 222 | |
| 223 | return simple_read_from_buffer(user_buf, count, ppos, |
| 224 | priv->wowlan_sram, |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 225 | img->sec[IWL_UCODE_SECTION_DATA].len); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 226 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 227 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 228 | size_t count, loff_t *ppos) |
| 229 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 230 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 231 | struct iwl_station_entry *station; |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 232 | struct iwl_tid_data *tid_data; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 233 | char *buf; |
| 234 | int i, j, pos = 0; |
| 235 | ssize_t ret; |
| 236 | /* Add 30 for initial string */ |
| 237 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 238 | |
| 239 | buf = kmalloc(bufsz, GFP_KERNEL); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 240 | if (!buf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 241 | return -ENOMEM; |
| 242 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 243 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 244 | priv->num_stations); |
| 245 | |
Emmanuel Grumbach | 3eae4bb | 2011-10-10 07:26:55 -0700 | [diff] [blame] | 246 | for (i = 0; i < IWLAGN_STATION_COUNT; i++) { |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 247 | station = &priv->stations[i]; |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 248 | if (!station->used) |
| 249 | continue; |
| 250 | pos += scnprintf(buf + pos, bufsz - pos, |
| 251 | "station %d - addr: %pM, flags: %#x\n", |
| 252 | i, station->sta.sta.addr, |
| 253 | station->sta.station_flags_msk); |
| 254 | pos += scnprintf(buf + pos, bufsz - pos, |
Johannes Berg | 9eae88f | 2012-03-15 13:26:52 -0700 | [diff] [blame] | 255 | "TID seqno next_rclmd " |
| 256 | "rate_n_flags state txq\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 257 | |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 258 | for (j = 0; j < IWL_MAX_TID_COUNT; j++) { |
Emmanuel Grumbach | 04cf682 | 2011-11-23 11:06:12 +0200 | [diff] [blame] | 259 | tid_data = &priv->tid_data[i][j]; |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 260 | pos += scnprintf(buf + pos, bufsz - pos, |
Johannes Berg | 9eae88f | 2012-03-15 13:26:52 -0700 | [diff] [blame] | 261 | "%d: 0x%.4x 0x%.4x 0x%.8x " |
| 262 | "%d %.2d", |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 263 | j, tid_data->seq_number, |
Johannes Berg | 9eae88f | 2012-03-15 13:26:52 -0700 | [diff] [blame] | 264 | tid_data->next_reclaimed, |
| 265 | tid_data->agg.rate_n_flags, |
| 266 | tid_data->agg.state, |
| 267 | tid_data->agg.txq_id); |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 268 | |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 269 | if (tid_data->agg.wait_for_ba) |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 270 | pos += scnprintf(buf + pos, bufsz - pos, |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 271 | " - waitforba"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 272 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 273 | } |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 274 | |
| 275 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 279 | kfree(buf); |
| 280 | return ret; |
| 281 | } |
| 282 | |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 283 | static ssize_t iwl_dbgfs_nvm_read(struct file *file, |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 284 | char __user *user_buf, |
| 285 | size_t count, |
| 286 | loff_t *ppos) |
| 287 | { |
| 288 | ssize_t ret; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 289 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 290 | int pos = 0, ofs = 0, buf_size = 0; |
| 291 | const u8 *ptr; |
| 292 | char *buf; |
Eytan Lifshitz | b7998c8 | 2012-12-01 20:59:49 +0200 | [diff] [blame] | 293 | u16 nvm_ver; |
Johannes Berg | 26a7ca9 | 2012-05-21 11:55:54 +0200 | [diff] [blame] | 294 | size_t eeprom_len = priv->eeprom_blob_size; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 295 | buf_size = 4 * eeprom_len + 256; |
| 296 | |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 297 | if (eeprom_len % 16) |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 298 | return -ENODATA; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 299 | |
Johannes Berg | 26a7ca9 | 2012-05-21 11:55:54 +0200 | [diff] [blame] | 300 | ptr = priv->eeprom_blob; |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 301 | if (!ptr) |
Julia Lawall | c37457e | 2009-08-03 11:11:45 +0200 | [diff] [blame] | 302 | return -ENOMEM; |
Julia Lawall | c37457e | 2009-08-03 11:11:45 +0200 | [diff] [blame] | 303 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 304 | /* 4 characters for byte 0xYY */ |
| 305 | buf = kzalloc(buf_size, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 306 | if (!buf) |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 307 | return -ENOMEM; |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 308 | |
Eytan Lifshitz | b7998c8 | 2012-12-01 20:59:49 +0200 | [diff] [blame] | 309 | nvm_ver = priv->nvm_data->nvm_version; |
Johannes Berg | 26a7ca9 | 2012-05-21 11:55:54 +0200 | [diff] [blame] | 310 | pos += scnprintf(buf + pos, buf_size - pos, |
Eytan Lifshitz | b7998c8 | 2012-12-01 20:59:49 +0200 | [diff] [blame] | 311 | "NVM version: 0x%x\n", nvm_ver); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 312 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 313 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 314 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 315 | buf_size - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 316 | pos += strlen(buf + pos); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 317 | if (buf_size - pos > 0) |
| 318 | buf[pos++] = '\n'; |
| 319 | } |
| 320 | |
| 321 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 322 | kfree(buf); |
| 323 | return ret; |
| 324 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 325 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 326 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, |
| 327 | size_t count, loff_t *ppos) |
| 328 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 329 | struct iwl_priv *priv = file->private_data; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 330 | struct ieee80211_channel *channels = NULL; |
| 331 | const struct ieee80211_supported_band *supp_band = NULL; |
| 332 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 333 | char *buf; |
| 334 | ssize_t ret; |
| 335 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 336 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 337 | if (!buf) |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 338 | return -ENOMEM; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 339 | |
| 340 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 341 | if (supp_band) { |
| 342 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 343 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 344 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 345 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 346 | supp_band->n_channels); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 347 | |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 348 | for (i = 0; i < supp_band->n_channels; i++) |
| 349 | pos += scnprintf(buf + pos, bufsz - pos, |
| 350 | "%d: %ddBm: BSS%s%s, %s.\n", |
Shanyu Zhao | 81e9543 | 2010-07-28 13:40:27 -0700 | [diff] [blame] | 351 | channels[i].hw_value, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 352 | channels[i].max_power, |
| 353 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 354 | " (IEEE 802.11h required)" : "", |
Luis R. Rodriguez | 8fe02e1 | 2013-10-21 19:22:25 +0200 | [diff] [blame] | 355 | ((channels[i].flags & IEEE80211_CHAN_NO_IR) |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 356 | || (channels[i].flags & |
| 357 | IEEE80211_CHAN_RADAR)) ? "" : |
| 358 | ", IBSS", |
| 359 | channels[i].flags & |
Luis R. Rodriguez | 8fe02e1 | 2013-10-21 19:22:25 +0200 | [diff] [blame] | 360 | IEEE80211_CHAN_NO_IR ? |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 361 | "passive only" : "active/passive"); |
| 362 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 363 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 364 | if (supp_band) { |
| 365 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 366 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 367 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 368 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 369 | supp_band->n_channels); |
| 370 | |
| 371 | for (i = 0; i < supp_band->n_channels; i++) |
| 372 | pos += scnprintf(buf + pos, bufsz - pos, |
| 373 | "%d: %ddBm: BSS%s%s, %s.\n", |
Shanyu Zhao | 81e9543 | 2010-07-28 13:40:27 -0700 | [diff] [blame] | 374 | channels[i].hw_value, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 375 | channels[i].max_power, |
| 376 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 377 | " (IEEE 802.11h required)" : "", |
Luis R. Rodriguez | 8fe02e1 | 2013-10-21 19:22:25 +0200 | [diff] [blame] | 378 | ((channels[i].flags & IEEE80211_CHAN_NO_IR) |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 379 | || (channels[i].flags & |
| 380 | IEEE80211_CHAN_RADAR)) ? "" : |
| 381 | ", IBSS", |
| 382 | channels[i].flags & |
Luis R. Rodriguez | 8fe02e1 | 2013-10-21 19:22:25 +0200 | [diff] [blame] | 383 | IEEE80211_CHAN_NO_IR ? |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 384 | "passive only" : "active/passive"); |
| 385 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 386 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 387 | kfree(buf); |
| 388 | return ret; |
| 389 | } |
| 390 | |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 391 | static ssize_t iwl_dbgfs_status_read(struct file *file, |
| 392 | char __user *user_buf, |
| 393 | size_t count, loff_t *ppos) { |
| 394 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 395 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 396 | char buf[512]; |
| 397 | int pos = 0; |
| 398 | const size_t bufsz = sizeof(buf); |
| 399 | |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 400 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 401 | test_bit(STATUS_RF_KILL_HW, &priv->status)); |
Wey-Yi Guy | 7812b16 | 2009-10-02 13:43:58 -0700 | [diff] [blame] | 402 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", |
Don Fry | 9a71686 | 2012-03-07 09:52:32 -0800 | [diff] [blame] | 403 | test_bit(STATUS_CT_KILL, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 404 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 405 | test_bit(STATUS_ALIVE, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 406 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 407 | test_bit(STATUS_READY, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 408 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 409 | test_bit(STATUS_EXIT_PENDING, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 410 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 411 | test_bit(STATUS_STATISTICS, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 412 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 413 | test_bit(STATUS_SCANNING, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 414 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 415 | test_bit(STATUS_SCAN_ABORTING, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 416 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 417 | test_bit(STATUS_SCAN_HW, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 418 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", |
Don Fry | 47107e8 | 2012-03-15 13:27:06 -0700 | [diff] [blame] | 419 | test_bit(STATUS_POWER_PMI, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 420 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", |
Don Fry | 17acd0b | 2012-03-15 13:27:05 -0700 | [diff] [blame] | 421 | test_bit(STATUS_FW_ERROR, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 422 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 423 | } |
| 424 | |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 425 | static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file, |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 426 | char __user *user_buf, |
| 427 | size_t count, loff_t *ppos) { |
| 428 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 429 | struct iwl_priv *priv = file->private_data; |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 430 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 431 | int pos = 0; |
| 432 | int cnt = 0; |
| 433 | char *buf; |
| 434 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
| 435 | ssize_t ret; |
| 436 | |
| 437 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 438 | if (!buf) |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 439 | return -ENOMEM; |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 440 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 441 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 442 | if (priv->rx_handlers_stats[cnt] > 0) |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 443 | pos += scnprintf(buf + pos, bufsz - pos, |
| 444 | "\tRx handler[%36s]:\t\t %u\n", |
Johannes Berg | d9fb646 | 2012-03-26 08:23:39 -0700 | [diff] [blame] | 445 | iwl_dvm_get_cmd_string(cnt), |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 446 | priv->rx_handlers_stats[cnt]); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 449 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 450 | kfree(buf); |
| 451 | return ret; |
| 452 | } |
| 453 | |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 454 | static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file, |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 455 | const char __user *user_buf, |
| 456 | size_t count, loff_t *ppos) |
| 457 | { |
| 458 | struct iwl_priv *priv = file->private_data; |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 459 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 460 | char buf[8]; |
| 461 | int buf_size; |
| 462 | u32 reset_flag; |
| 463 | |
| 464 | memset(buf, 0, sizeof(buf)); |
| 465 | buf_size = min(count, sizeof(buf) - 1); |
| 466 | if (copy_from_user(buf, user_buf, buf_size)) |
| 467 | return -EFAULT; |
| 468 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 469 | return -EFAULT; |
| 470 | if (reset_flag == 0) |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 471 | memset(&priv->rx_handlers_stats[0], 0, |
| 472 | sizeof(priv->rx_handlers_stats)); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 473 | |
| 474 | return count; |
| 475 | } |
| 476 | |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 477 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
| 478 | size_t count, loff_t *ppos) |
| 479 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 480 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 481 | struct iwl_rxon_context *ctx; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 482 | int pos = 0, i; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 483 | char buf[256 * NUM_IWL_RXON_CTX]; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 484 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 485 | |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 486 | for_each_context(priv, ctx) { |
| 487 | pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", |
| 488 | ctx->ctxid); |
| 489 | for (i = 0; i < AC_NUM; i++) { |
| 490 | pos += scnprintf(buf + pos, bufsz - pos, |
| 491 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 492 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 493 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 494 | ctx->qos_data.def_qos_parm.ac[i].cw_min, |
| 495 | ctx->qos_data.def_qos_parm.ac[i].cw_max, |
| 496 | ctx->qos_data.def_qos_parm.ac[i].aifsn, |
| 497 | ctx->qos_data.def_qos_parm.ac[i].edca_txop); |
| 498 | } |
| 499 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 500 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 501 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 502 | } |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 503 | |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 504 | static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, |
| 505 | char __user *user_buf, |
| 506 | size_t count, loff_t *ppos) |
| 507 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 508 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 509 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 510 | struct iwl_tt_restriction *restriction; |
| 511 | char buf[100]; |
| 512 | int pos = 0; |
| 513 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 514 | |
| 515 | pos += scnprintf(buf + pos, bufsz - pos, |
| 516 | "Thermal Throttling Mode: %s\n", |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 517 | tt->advanced_tt ? "Advance" : "Legacy"); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 518 | pos += scnprintf(buf + pos, bufsz - pos, |
| 519 | "Thermal Throttling State: %d\n", |
| 520 | tt->state); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 521 | if (tt->advanced_tt) { |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 522 | restriction = tt->restriction + tt->state; |
| 523 | pos += scnprintf(buf + pos, bufsz - pos, |
| 524 | "Tx mode: %d\n", |
| 525 | restriction->tx_stream); |
| 526 | pos += scnprintf(buf + pos, bufsz - pos, |
| 527 | "Rx mode: %d\n", |
| 528 | restriction->rx_stream); |
| 529 | pos += scnprintf(buf + pos, bufsz - pos, |
| 530 | "HT mode: %d\n", |
| 531 | restriction->is_ht); |
| 532 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 533 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 534 | } |
| 535 | |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 536 | static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, |
| 537 | const char __user *user_buf, |
| 538 | size_t count, loff_t *ppos) |
| 539 | { |
| 540 | struct iwl_priv *priv = file->private_data; |
| 541 | char buf[8]; |
| 542 | int buf_size; |
| 543 | int ht40; |
| 544 | |
| 545 | memset(buf, 0, sizeof(buf)); |
| 546 | buf_size = min(count, sizeof(buf) - 1); |
| 547 | if (copy_from_user(buf, user_buf, buf_size)) |
| 548 | return -EFAULT; |
| 549 | if (sscanf(buf, "%d", &ht40) != 1) |
| 550 | return -EFAULT; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 551 | if (!iwl_is_any_associated(priv)) |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 552 | priv->disable_ht40 = ht40 ? true : false; |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 553 | else |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 554 | return -EINVAL; |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 555 | |
| 556 | return count; |
| 557 | } |
| 558 | |
| 559 | static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file, |
| 560 | char __user *user_buf, |
| 561 | size_t count, loff_t *ppos) |
| 562 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 563 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 564 | char buf[100]; |
| 565 | int pos = 0; |
| 566 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 567 | |
| 568 | pos += scnprintf(buf + pos, bufsz - pos, |
| 569 | "11n 40MHz Mode: %s\n", |
| 570 | priv->disable_ht40 ? "Disabled" : "Enabled"); |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 571 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 572 | } |
| 573 | |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 574 | static ssize_t iwl_dbgfs_temperature_read(struct file *file, |
| 575 | char __user *user_buf, |
| 576 | size_t count, loff_t *ppos) |
| 577 | { |
| 578 | struct iwl_priv *priv = file->private_data; |
| 579 | char buf[8]; |
| 580 | int pos = 0; |
| 581 | const size_t bufsz = sizeof(buf); |
| 582 | |
| 583 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature); |
| 584 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 585 | } |
| 586 | |
| 587 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 588 | static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, |
| 589 | const char __user *user_buf, |
| 590 | size_t count, loff_t *ppos) |
| 591 | { |
| 592 | struct iwl_priv *priv = file->private_data; |
| 593 | char buf[8]; |
| 594 | int buf_size; |
| 595 | int value; |
| 596 | |
| 597 | memset(buf, 0, sizeof(buf)); |
| 598 | buf_size = min(count, sizeof(buf) - 1); |
| 599 | if (copy_from_user(buf, user_buf, buf_size)) |
| 600 | return -EFAULT; |
| 601 | |
| 602 | if (sscanf(buf, "%d", &value) != 1) |
| 603 | return -EINVAL; |
| 604 | |
| 605 | /* |
| 606 | * Our users expect 0 to be "CAM", but 0 isn't actually |
| 607 | * valid here. However, let's not confuse them and present |
| 608 | * IWL_POWER_INDEX_1 as "1", not "0". |
| 609 | */ |
Reinette Chatre | 1a34c04 | 2009-10-09 13:20:25 -0700 | [diff] [blame] | 610 | if (value == 0) |
| 611 | return -EINVAL; |
| 612 | else if (value > 0) |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 613 | value -= 1; |
| 614 | |
| 615 | if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) |
| 616 | return -EINVAL; |
| 617 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 618 | if (!iwl_is_ready_rf(priv)) |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 619 | return -EAGAIN; |
| 620 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 621 | priv->power_data.debug_sleep_level_override = value; |
| 622 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 623 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 624 | iwl_power_update_mode(priv, true); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 625 | mutex_unlock(&priv->mutex); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 626 | |
| 627 | return count; |
| 628 | } |
| 629 | |
| 630 | static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file, |
| 631 | char __user *user_buf, |
| 632 | size_t count, loff_t *ppos) |
| 633 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 634 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 635 | char buf[10]; |
| 636 | int pos, value; |
| 637 | const size_t bufsz = sizeof(buf); |
| 638 | |
| 639 | /* see the write function */ |
| 640 | value = priv->power_data.debug_sleep_level_override; |
| 641 | if (value >= 0) |
| 642 | value += 1; |
| 643 | |
| 644 | pos = scnprintf(buf, bufsz, "%d\n", value); |
| 645 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 646 | } |
| 647 | |
| 648 | static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file, |
| 649 | char __user *user_buf, |
| 650 | size_t count, loff_t *ppos) |
| 651 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 652 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 653 | char buf[200]; |
| 654 | int pos = 0, i; |
| 655 | const size_t bufsz = sizeof(buf); |
| 656 | struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd; |
| 657 | |
| 658 | pos += scnprintf(buf + pos, bufsz - pos, |
| 659 | "flags: %#.2x\n", le16_to_cpu(cmd->flags)); |
| 660 | pos += scnprintf(buf + pos, bufsz - pos, |
| 661 | "RX/TX timeout: %d/%d usec\n", |
| 662 | le32_to_cpu(cmd->rx_data_timeout), |
| 663 | le32_to_cpu(cmd->tx_data_timeout)); |
| 664 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
| 665 | pos += scnprintf(buf + pos, bufsz - pos, |
| 666 | "sleep_interval[%d]: %d\n", i, |
| 667 | le32_to_cpu(cmd->sleep_interval[i])); |
| 668 | |
| 669 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 670 | } |
| 671 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 672 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 673 | DEBUGFS_READ_FILE_OPS(wowlan_sram); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 674 | DEBUGFS_READ_FILE_OPS(nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 675 | DEBUGFS_READ_FILE_OPS(stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 676 | DEBUGFS_READ_FILE_OPS(channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 677 | DEBUGFS_READ_FILE_OPS(status); |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 678 | DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 679 | DEBUGFS_READ_FILE_OPS(qos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 680 | DEBUGFS_READ_FILE_OPS(thermal_throttling); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 681 | DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 682 | DEBUGFS_READ_FILE_OPS(temperature); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 683 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); |
| 684 | DEBUGFS_READ_FILE_OPS(current_sleep_command); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 685 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 686 | static const char *fmt_value = " %-30s %10u\n"; |
| 687 | static const char *fmt_hex = " %-30s 0x%02X\n"; |
| 688 | static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; |
| 689 | static const char *fmt_header = |
| 690 | "%-32s current cumulative delta max\n"; |
| 691 | |
| 692 | static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) |
| 693 | { |
| 694 | int p = 0; |
| 695 | u32 flag; |
| 696 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 697 | lockdep_assert_held(&priv->statistics.lock); |
| 698 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 699 | flag = le32_to_cpu(priv->statistics.flag); |
| 700 | |
| 701 | p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); |
| 702 | if (flag & UCODE_STATISTICS_CLEAR_MSK) |
| 703 | p += scnprintf(buf + p, bufsz - p, |
| 704 | "\tStatistics have been cleared\n"); |
| 705 | p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", |
| 706 | (flag & UCODE_STATISTICS_FREQUENCY_MSK) |
| 707 | ? "2.4 GHz" : "5.2 GHz"); |
| 708 | p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", |
| 709 | (flag & UCODE_STATISTICS_NARROW_BAND_MSK) |
| 710 | ? "enabled" : "disabled"); |
| 711 | |
| 712 | return p; |
| 713 | } |
| 714 | |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 715 | static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, |
| 716 | char __user *user_buf, |
| 717 | size_t count, loff_t *ppos) |
| 718 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 719 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 720 | int pos = 0; |
| 721 | char *buf; |
| 722 | int bufsz = sizeof(struct statistics_rx_phy) * 40 + |
| 723 | sizeof(struct statistics_rx_non_phy) * 40 + |
| 724 | sizeof(struct statistics_rx_ht_phy) * 40 + 400; |
| 725 | ssize_t ret; |
| 726 | struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; |
| 727 | struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; |
| 728 | struct statistics_rx_non_phy *general, *accum_general; |
| 729 | struct statistics_rx_non_phy *delta_general, *max_general; |
| 730 | struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; |
| 731 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 732 | if (!iwl_is_alive(priv)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 733 | return -EAGAIN; |
| 734 | |
| 735 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 736 | if (!buf) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 737 | return -ENOMEM; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 738 | |
| 739 | /* |
| 740 | * the statistic information display here is based on |
| 741 | * the last statistics notification from uCode |
| 742 | * might not reflect the current uCode activity |
| 743 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 744 | spin_lock_bh(&priv->statistics.lock); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 745 | ofdm = &priv->statistics.rx_ofdm; |
| 746 | cck = &priv->statistics.rx_cck; |
| 747 | general = &priv->statistics.rx_non_phy; |
| 748 | ht = &priv->statistics.rx_ofdm_ht; |
| 749 | accum_ofdm = &priv->accum_stats.rx_ofdm; |
| 750 | accum_cck = &priv->accum_stats.rx_cck; |
| 751 | accum_general = &priv->accum_stats.rx_non_phy; |
| 752 | accum_ht = &priv->accum_stats.rx_ofdm_ht; |
| 753 | delta_ofdm = &priv->delta_stats.rx_ofdm; |
| 754 | delta_cck = &priv->delta_stats.rx_cck; |
| 755 | delta_general = &priv->delta_stats.rx_non_phy; |
| 756 | delta_ht = &priv->delta_stats.rx_ofdm_ht; |
| 757 | max_ofdm = &priv->max_delta_stats.rx_ofdm; |
| 758 | max_cck = &priv->max_delta_stats.rx_cck; |
| 759 | max_general = &priv->max_delta_stats.rx_non_phy; |
| 760 | max_ht = &priv->max_delta_stats.rx_ofdm_ht; |
| 761 | |
| 762 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 763 | pos += scnprintf(buf + pos, bufsz - pos, |
| 764 | fmt_header, "Statistics_Rx - OFDM:"); |
| 765 | pos += scnprintf(buf + pos, bufsz - pos, |
| 766 | fmt_table, "ina_cnt:", |
| 767 | le32_to_cpu(ofdm->ina_cnt), |
| 768 | accum_ofdm->ina_cnt, |
| 769 | delta_ofdm->ina_cnt, max_ofdm->ina_cnt); |
| 770 | pos += scnprintf(buf + pos, bufsz - pos, |
| 771 | fmt_table, "fina_cnt:", |
| 772 | le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, |
| 773 | delta_ofdm->fina_cnt, max_ofdm->fina_cnt); |
| 774 | pos += scnprintf(buf + pos, bufsz - pos, |
| 775 | fmt_table, "plcp_err:", |
| 776 | le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, |
| 777 | delta_ofdm->plcp_err, max_ofdm->plcp_err); |
| 778 | pos += scnprintf(buf + pos, bufsz - pos, |
| 779 | fmt_table, "crc32_err:", |
| 780 | le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, |
| 781 | delta_ofdm->crc32_err, max_ofdm->crc32_err); |
| 782 | pos += scnprintf(buf + pos, bufsz - pos, |
| 783 | fmt_table, "overrun_err:", |
| 784 | le32_to_cpu(ofdm->overrun_err), |
| 785 | accum_ofdm->overrun_err, delta_ofdm->overrun_err, |
| 786 | max_ofdm->overrun_err); |
| 787 | pos += scnprintf(buf + pos, bufsz - pos, |
| 788 | fmt_table, "early_overrun_err:", |
| 789 | le32_to_cpu(ofdm->early_overrun_err), |
| 790 | accum_ofdm->early_overrun_err, |
| 791 | delta_ofdm->early_overrun_err, |
| 792 | max_ofdm->early_overrun_err); |
| 793 | pos += scnprintf(buf + pos, bufsz - pos, |
| 794 | fmt_table, "crc32_good:", |
| 795 | le32_to_cpu(ofdm->crc32_good), |
| 796 | accum_ofdm->crc32_good, delta_ofdm->crc32_good, |
| 797 | max_ofdm->crc32_good); |
| 798 | pos += scnprintf(buf + pos, bufsz - pos, |
| 799 | fmt_table, "false_alarm_cnt:", |
| 800 | le32_to_cpu(ofdm->false_alarm_cnt), |
| 801 | accum_ofdm->false_alarm_cnt, |
| 802 | delta_ofdm->false_alarm_cnt, |
| 803 | max_ofdm->false_alarm_cnt); |
| 804 | pos += scnprintf(buf + pos, bufsz - pos, |
| 805 | fmt_table, "fina_sync_err_cnt:", |
| 806 | le32_to_cpu(ofdm->fina_sync_err_cnt), |
| 807 | accum_ofdm->fina_sync_err_cnt, |
| 808 | delta_ofdm->fina_sync_err_cnt, |
| 809 | max_ofdm->fina_sync_err_cnt); |
| 810 | pos += scnprintf(buf + pos, bufsz - pos, |
| 811 | fmt_table, "sfd_timeout:", |
| 812 | le32_to_cpu(ofdm->sfd_timeout), |
| 813 | accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, |
| 814 | max_ofdm->sfd_timeout); |
| 815 | pos += scnprintf(buf + pos, bufsz - pos, |
| 816 | fmt_table, "fina_timeout:", |
| 817 | le32_to_cpu(ofdm->fina_timeout), |
| 818 | accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, |
| 819 | max_ofdm->fina_timeout); |
| 820 | pos += scnprintf(buf + pos, bufsz - pos, |
| 821 | fmt_table, "unresponded_rts:", |
| 822 | le32_to_cpu(ofdm->unresponded_rts), |
| 823 | accum_ofdm->unresponded_rts, |
| 824 | delta_ofdm->unresponded_rts, |
| 825 | max_ofdm->unresponded_rts); |
| 826 | pos += scnprintf(buf + pos, bufsz - pos, |
| 827 | fmt_table, "rxe_frame_lmt_ovrun:", |
| 828 | le32_to_cpu(ofdm->rxe_frame_limit_overrun), |
| 829 | accum_ofdm->rxe_frame_limit_overrun, |
| 830 | delta_ofdm->rxe_frame_limit_overrun, |
| 831 | max_ofdm->rxe_frame_limit_overrun); |
| 832 | pos += scnprintf(buf + pos, bufsz - pos, |
| 833 | fmt_table, "sent_ack_cnt:", |
| 834 | le32_to_cpu(ofdm->sent_ack_cnt), |
| 835 | accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, |
| 836 | max_ofdm->sent_ack_cnt); |
| 837 | pos += scnprintf(buf + pos, bufsz - pos, |
| 838 | fmt_table, "sent_cts_cnt:", |
| 839 | le32_to_cpu(ofdm->sent_cts_cnt), |
| 840 | accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, |
| 841 | max_ofdm->sent_cts_cnt); |
| 842 | pos += scnprintf(buf + pos, bufsz - pos, |
| 843 | fmt_table, "sent_ba_rsp_cnt:", |
| 844 | le32_to_cpu(ofdm->sent_ba_rsp_cnt), |
| 845 | accum_ofdm->sent_ba_rsp_cnt, |
| 846 | delta_ofdm->sent_ba_rsp_cnt, |
| 847 | max_ofdm->sent_ba_rsp_cnt); |
| 848 | pos += scnprintf(buf + pos, bufsz - pos, |
| 849 | fmt_table, "dsp_self_kill:", |
| 850 | le32_to_cpu(ofdm->dsp_self_kill), |
| 851 | accum_ofdm->dsp_self_kill, |
| 852 | delta_ofdm->dsp_self_kill, |
| 853 | max_ofdm->dsp_self_kill); |
| 854 | pos += scnprintf(buf + pos, bufsz - pos, |
| 855 | fmt_table, "mh_format_err:", |
| 856 | le32_to_cpu(ofdm->mh_format_err), |
| 857 | accum_ofdm->mh_format_err, |
| 858 | delta_ofdm->mh_format_err, |
| 859 | max_ofdm->mh_format_err); |
| 860 | pos += scnprintf(buf + pos, bufsz - pos, |
| 861 | fmt_table, "re_acq_main_rssi_sum:", |
| 862 | le32_to_cpu(ofdm->re_acq_main_rssi_sum), |
| 863 | accum_ofdm->re_acq_main_rssi_sum, |
| 864 | delta_ofdm->re_acq_main_rssi_sum, |
| 865 | max_ofdm->re_acq_main_rssi_sum); |
| 866 | |
| 867 | pos += scnprintf(buf + pos, bufsz - pos, |
| 868 | fmt_header, "Statistics_Rx - CCK:"); |
| 869 | pos += scnprintf(buf + pos, bufsz - pos, |
| 870 | fmt_table, "ina_cnt:", |
| 871 | le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, |
| 872 | delta_cck->ina_cnt, max_cck->ina_cnt); |
| 873 | pos += scnprintf(buf + pos, bufsz - pos, |
| 874 | fmt_table, "fina_cnt:", |
| 875 | le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, |
| 876 | delta_cck->fina_cnt, max_cck->fina_cnt); |
| 877 | pos += scnprintf(buf + pos, bufsz - pos, |
| 878 | fmt_table, "plcp_err:", |
| 879 | le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, |
| 880 | delta_cck->plcp_err, max_cck->plcp_err); |
| 881 | pos += scnprintf(buf + pos, bufsz - pos, |
| 882 | fmt_table, "crc32_err:", |
| 883 | le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, |
| 884 | delta_cck->crc32_err, max_cck->crc32_err); |
| 885 | pos += scnprintf(buf + pos, bufsz - pos, |
| 886 | fmt_table, "overrun_err:", |
| 887 | le32_to_cpu(cck->overrun_err), |
| 888 | accum_cck->overrun_err, delta_cck->overrun_err, |
| 889 | max_cck->overrun_err); |
| 890 | pos += scnprintf(buf + pos, bufsz - pos, |
| 891 | fmt_table, "early_overrun_err:", |
| 892 | le32_to_cpu(cck->early_overrun_err), |
| 893 | accum_cck->early_overrun_err, |
| 894 | delta_cck->early_overrun_err, |
| 895 | max_cck->early_overrun_err); |
| 896 | pos += scnprintf(buf + pos, bufsz - pos, |
| 897 | fmt_table, "crc32_good:", |
| 898 | le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, |
| 899 | delta_cck->crc32_good, max_cck->crc32_good); |
| 900 | pos += scnprintf(buf + pos, bufsz - pos, |
| 901 | fmt_table, "false_alarm_cnt:", |
| 902 | le32_to_cpu(cck->false_alarm_cnt), |
| 903 | accum_cck->false_alarm_cnt, |
| 904 | delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); |
| 905 | pos += scnprintf(buf + pos, bufsz - pos, |
| 906 | fmt_table, "fina_sync_err_cnt:", |
| 907 | le32_to_cpu(cck->fina_sync_err_cnt), |
| 908 | accum_cck->fina_sync_err_cnt, |
| 909 | delta_cck->fina_sync_err_cnt, |
| 910 | max_cck->fina_sync_err_cnt); |
| 911 | pos += scnprintf(buf + pos, bufsz - pos, |
| 912 | fmt_table, "sfd_timeout:", |
| 913 | le32_to_cpu(cck->sfd_timeout), |
| 914 | accum_cck->sfd_timeout, delta_cck->sfd_timeout, |
| 915 | max_cck->sfd_timeout); |
| 916 | pos += scnprintf(buf + pos, bufsz - pos, |
| 917 | fmt_table, "fina_timeout:", |
| 918 | le32_to_cpu(cck->fina_timeout), |
| 919 | accum_cck->fina_timeout, delta_cck->fina_timeout, |
| 920 | max_cck->fina_timeout); |
| 921 | pos += scnprintf(buf + pos, bufsz - pos, |
| 922 | fmt_table, "unresponded_rts:", |
| 923 | le32_to_cpu(cck->unresponded_rts), |
| 924 | accum_cck->unresponded_rts, delta_cck->unresponded_rts, |
| 925 | max_cck->unresponded_rts); |
| 926 | pos += scnprintf(buf + pos, bufsz - pos, |
| 927 | fmt_table, "rxe_frame_lmt_ovrun:", |
| 928 | le32_to_cpu(cck->rxe_frame_limit_overrun), |
| 929 | accum_cck->rxe_frame_limit_overrun, |
| 930 | delta_cck->rxe_frame_limit_overrun, |
| 931 | max_cck->rxe_frame_limit_overrun); |
| 932 | pos += scnprintf(buf + pos, bufsz - pos, |
| 933 | fmt_table, "sent_ack_cnt:", |
| 934 | le32_to_cpu(cck->sent_ack_cnt), |
| 935 | accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, |
| 936 | max_cck->sent_ack_cnt); |
| 937 | pos += scnprintf(buf + pos, bufsz - pos, |
| 938 | fmt_table, "sent_cts_cnt:", |
| 939 | le32_to_cpu(cck->sent_cts_cnt), |
| 940 | accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, |
| 941 | max_cck->sent_cts_cnt); |
| 942 | pos += scnprintf(buf + pos, bufsz - pos, |
| 943 | fmt_table, "sent_ba_rsp_cnt:", |
| 944 | le32_to_cpu(cck->sent_ba_rsp_cnt), |
| 945 | accum_cck->sent_ba_rsp_cnt, |
| 946 | delta_cck->sent_ba_rsp_cnt, |
| 947 | max_cck->sent_ba_rsp_cnt); |
| 948 | pos += scnprintf(buf + pos, bufsz - pos, |
| 949 | fmt_table, "dsp_self_kill:", |
| 950 | le32_to_cpu(cck->dsp_self_kill), |
| 951 | accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, |
| 952 | max_cck->dsp_self_kill); |
| 953 | pos += scnprintf(buf + pos, bufsz - pos, |
| 954 | fmt_table, "mh_format_err:", |
| 955 | le32_to_cpu(cck->mh_format_err), |
| 956 | accum_cck->mh_format_err, delta_cck->mh_format_err, |
| 957 | max_cck->mh_format_err); |
| 958 | pos += scnprintf(buf + pos, bufsz - pos, |
| 959 | fmt_table, "re_acq_main_rssi_sum:", |
| 960 | le32_to_cpu(cck->re_acq_main_rssi_sum), |
| 961 | accum_cck->re_acq_main_rssi_sum, |
| 962 | delta_cck->re_acq_main_rssi_sum, |
| 963 | max_cck->re_acq_main_rssi_sum); |
| 964 | |
| 965 | pos += scnprintf(buf + pos, bufsz - pos, |
| 966 | fmt_header, "Statistics_Rx - GENERAL:"); |
| 967 | pos += scnprintf(buf + pos, bufsz - pos, |
| 968 | fmt_table, "bogus_cts:", |
| 969 | le32_to_cpu(general->bogus_cts), |
| 970 | accum_general->bogus_cts, delta_general->bogus_cts, |
| 971 | max_general->bogus_cts); |
| 972 | pos += scnprintf(buf + pos, bufsz - pos, |
| 973 | fmt_table, "bogus_ack:", |
| 974 | le32_to_cpu(general->bogus_ack), |
| 975 | accum_general->bogus_ack, delta_general->bogus_ack, |
| 976 | max_general->bogus_ack); |
| 977 | pos += scnprintf(buf + pos, bufsz - pos, |
| 978 | fmt_table, "non_bssid_frames:", |
| 979 | le32_to_cpu(general->non_bssid_frames), |
| 980 | accum_general->non_bssid_frames, |
| 981 | delta_general->non_bssid_frames, |
| 982 | max_general->non_bssid_frames); |
| 983 | pos += scnprintf(buf + pos, bufsz - pos, |
| 984 | fmt_table, "filtered_frames:", |
| 985 | le32_to_cpu(general->filtered_frames), |
| 986 | accum_general->filtered_frames, |
| 987 | delta_general->filtered_frames, |
| 988 | max_general->filtered_frames); |
| 989 | pos += scnprintf(buf + pos, bufsz - pos, |
| 990 | fmt_table, "non_channel_beacons:", |
| 991 | le32_to_cpu(general->non_channel_beacons), |
| 992 | accum_general->non_channel_beacons, |
| 993 | delta_general->non_channel_beacons, |
| 994 | max_general->non_channel_beacons); |
| 995 | pos += scnprintf(buf + pos, bufsz - pos, |
| 996 | fmt_table, "channel_beacons:", |
| 997 | le32_to_cpu(general->channel_beacons), |
| 998 | accum_general->channel_beacons, |
| 999 | delta_general->channel_beacons, |
| 1000 | max_general->channel_beacons); |
| 1001 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1002 | fmt_table, "num_missed_bcon:", |
| 1003 | le32_to_cpu(general->num_missed_bcon), |
| 1004 | accum_general->num_missed_bcon, |
| 1005 | delta_general->num_missed_bcon, |
| 1006 | max_general->num_missed_bcon); |
| 1007 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1008 | fmt_table, "adc_rx_saturation_time:", |
| 1009 | le32_to_cpu(general->adc_rx_saturation_time), |
| 1010 | accum_general->adc_rx_saturation_time, |
| 1011 | delta_general->adc_rx_saturation_time, |
| 1012 | max_general->adc_rx_saturation_time); |
| 1013 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1014 | fmt_table, "ina_detect_search_tm:", |
| 1015 | le32_to_cpu(general->ina_detection_search_time), |
| 1016 | accum_general->ina_detection_search_time, |
| 1017 | delta_general->ina_detection_search_time, |
| 1018 | max_general->ina_detection_search_time); |
| 1019 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1020 | fmt_table, "beacon_silence_rssi_a:", |
| 1021 | le32_to_cpu(general->beacon_silence_rssi_a), |
| 1022 | accum_general->beacon_silence_rssi_a, |
| 1023 | delta_general->beacon_silence_rssi_a, |
| 1024 | max_general->beacon_silence_rssi_a); |
| 1025 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1026 | fmt_table, "beacon_silence_rssi_b:", |
| 1027 | le32_to_cpu(general->beacon_silence_rssi_b), |
| 1028 | accum_general->beacon_silence_rssi_b, |
| 1029 | delta_general->beacon_silence_rssi_b, |
| 1030 | max_general->beacon_silence_rssi_b); |
| 1031 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1032 | fmt_table, "beacon_silence_rssi_c:", |
| 1033 | le32_to_cpu(general->beacon_silence_rssi_c), |
| 1034 | accum_general->beacon_silence_rssi_c, |
| 1035 | delta_general->beacon_silence_rssi_c, |
| 1036 | max_general->beacon_silence_rssi_c); |
| 1037 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1038 | fmt_table, "interference_data_flag:", |
| 1039 | le32_to_cpu(general->interference_data_flag), |
| 1040 | accum_general->interference_data_flag, |
| 1041 | delta_general->interference_data_flag, |
| 1042 | max_general->interference_data_flag); |
| 1043 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1044 | fmt_table, "channel_load:", |
| 1045 | le32_to_cpu(general->channel_load), |
| 1046 | accum_general->channel_load, |
| 1047 | delta_general->channel_load, |
| 1048 | max_general->channel_load); |
| 1049 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1050 | fmt_table, "dsp_false_alarms:", |
| 1051 | le32_to_cpu(general->dsp_false_alarms), |
| 1052 | accum_general->dsp_false_alarms, |
| 1053 | delta_general->dsp_false_alarms, |
| 1054 | max_general->dsp_false_alarms); |
| 1055 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1056 | fmt_table, "beacon_rssi_a:", |
| 1057 | le32_to_cpu(general->beacon_rssi_a), |
| 1058 | accum_general->beacon_rssi_a, |
| 1059 | delta_general->beacon_rssi_a, |
| 1060 | max_general->beacon_rssi_a); |
| 1061 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1062 | fmt_table, "beacon_rssi_b:", |
| 1063 | le32_to_cpu(general->beacon_rssi_b), |
| 1064 | accum_general->beacon_rssi_b, |
| 1065 | delta_general->beacon_rssi_b, |
| 1066 | max_general->beacon_rssi_b); |
| 1067 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1068 | fmt_table, "beacon_rssi_c:", |
| 1069 | le32_to_cpu(general->beacon_rssi_c), |
| 1070 | accum_general->beacon_rssi_c, |
| 1071 | delta_general->beacon_rssi_c, |
| 1072 | max_general->beacon_rssi_c); |
| 1073 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1074 | fmt_table, "beacon_energy_a:", |
| 1075 | le32_to_cpu(general->beacon_energy_a), |
| 1076 | accum_general->beacon_energy_a, |
| 1077 | delta_general->beacon_energy_a, |
| 1078 | max_general->beacon_energy_a); |
| 1079 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1080 | fmt_table, "beacon_energy_b:", |
| 1081 | le32_to_cpu(general->beacon_energy_b), |
| 1082 | accum_general->beacon_energy_b, |
| 1083 | delta_general->beacon_energy_b, |
| 1084 | max_general->beacon_energy_b); |
| 1085 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1086 | fmt_table, "beacon_energy_c:", |
| 1087 | le32_to_cpu(general->beacon_energy_c), |
| 1088 | accum_general->beacon_energy_c, |
| 1089 | delta_general->beacon_energy_c, |
| 1090 | max_general->beacon_energy_c); |
| 1091 | |
| 1092 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1093 | fmt_header, "Statistics_Rx - OFDM_HT:"); |
| 1094 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1095 | fmt_table, "plcp_err:", |
| 1096 | le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, |
| 1097 | delta_ht->plcp_err, max_ht->plcp_err); |
| 1098 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1099 | fmt_table, "overrun_err:", |
| 1100 | le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, |
| 1101 | delta_ht->overrun_err, max_ht->overrun_err); |
| 1102 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1103 | fmt_table, "early_overrun_err:", |
| 1104 | le32_to_cpu(ht->early_overrun_err), |
| 1105 | accum_ht->early_overrun_err, |
| 1106 | delta_ht->early_overrun_err, |
| 1107 | max_ht->early_overrun_err); |
| 1108 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1109 | fmt_table, "crc32_good:", |
| 1110 | le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, |
| 1111 | delta_ht->crc32_good, max_ht->crc32_good); |
| 1112 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1113 | fmt_table, "crc32_err:", |
| 1114 | le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, |
| 1115 | delta_ht->crc32_err, max_ht->crc32_err); |
| 1116 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1117 | fmt_table, "mh_format_err:", |
| 1118 | le32_to_cpu(ht->mh_format_err), |
| 1119 | accum_ht->mh_format_err, |
| 1120 | delta_ht->mh_format_err, max_ht->mh_format_err); |
| 1121 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1122 | fmt_table, "agg_crc32_good:", |
| 1123 | le32_to_cpu(ht->agg_crc32_good), |
| 1124 | accum_ht->agg_crc32_good, |
| 1125 | delta_ht->agg_crc32_good, max_ht->agg_crc32_good); |
| 1126 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1127 | fmt_table, "agg_mpdu_cnt:", |
| 1128 | le32_to_cpu(ht->agg_mpdu_cnt), |
| 1129 | accum_ht->agg_mpdu_cnt, |
| 1130 | delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); |
| 1131 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1132 | fmt_table, "agg_cnt:", |
| 1133 | le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, |
| 1134 | delta_ht->agg_cnt, max_ht->agg_cnt); |
| 1135 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1136 | fmt_table, "unsupport_mcs:", |
| 1137 | le32_to_cpu(ht->unsupport_mcs), |
| 1138 | accum_ht->unsupport_mcs, |
| 1139 | delta_ht->unsupport_mcs, max_ht->unsupport_mcs); |
| 1140 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1141 | spin_unlock_bh(&priv->statistics.lock); |
| 1142 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1143 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1144 | kfree(buf); |
| 1145 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1146 | } |
| 1147 | |
| 1148 | static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, |
| 1149 | char __user *user_buf, |
| 1150 | size_t count, loff_t *ppos) |
| 1151 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1152 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1153 | int pos = 0; |
| 1154 | char *buf; |
| 1155 | int bufsz = (sizeof(struct statistics_tx) * 48) + 250; |
| 1156 | ssize_t ret; |
| 1157 | struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; |
| 1158 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 1159 | if (!iwl_is_alive(priv)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1160 | return -EAGAIN; |
| 1161 | |
| 1162 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 1163 | if (!buf) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1164 | return -ENOMEM; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1165 | |
| 1166 | /* the statistic information display here is based on |
| 1167 | * the last statistics notification from uCode |
| 1168 | * might not reflect the current uCode activity |
| 1169 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1170 | spin_lock_bh(&priv->statistics.lock); |
| 1171 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1172 | tx = &priv->statistics.tx; |
| 1173 | accum_tx = &priv->accum_stats.tx; |
| 1174 | delta_tx = &priv->delta_stats.tx; |
| 1175 | max_tx = &priv->max_delta_stats.tx; |
| 1176 | |
| 1177 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1178 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1179 | fmt_header, "Statistics_Tx:"); |
| 1180 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1181 | fmt_table, "preamble:", |
| 1182 | le32_to_cpu(tx->preamble_cnt), |
| 1183 | accum_tx->preamble_cnt, |
| 1184 | delta_tx->preamble_cnt, max_tx->preamble_cnt); |
| 1185 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1186 | fmt_table, "rx_detected_cnt:", |
| 1187 | le32_to_cpu(tx->rx_detected_cnt), |
| 1188 | accum_tx->rx_detected_cnt, |
| 1189 | delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); |
| 1190 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1191 | fmt_table, "bt_prio_defer_cnt:", |
| 1192 | le32_to_cpu(tx->bt_prio_defer_cnt), |
| 1193 | accum_tx->bt_prio_defer_cnt, |
| 1194 | delta_tx->bt_prio_defer_cnt, |
| 1195 | max_tx->bt_prio_defer_cnt); |
| 1196 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1197 | fmt_table, "bt_prio_kill_cnt:", |
| 1198 | le32_to_cpu(tx->bt_prio_kill_cnt), |
| 1199 | accum_tx->bt_prio_kill_cnt, |
| 1200 | delta_tx->bt_prio_kill_cnt, |
| 1201 | max_tx->bt_prio_kill_cnt); |
| 1202 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1203 | fmt_table, "few_bytes_cnt:", |
| 1204 | le32_to_cpu(tx->few_bytes_cnt), |
| 1205 | accum_tx->few_bytes_cnt, |
| 1206 | delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); |
| 1207 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1208 | fmt_table, "cts_timeout:", |
| 1209 | le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, |
| 1210 | delta_tx->cts_timeout, max_tx->cts_timeout); |
| 1211 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1212 | fmt_table, "ack_timeout:", |
| 1213 | le32_to_cpu(tx->ack_timeout), |
| 1214 | accum_tx->ack_timeout, |
| 1215 | delta_tx->ack_timeout, max_tx->ack_timeout); |
| 1216 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1217 | fmt_table, "expected_ack_cnt:", |
| 1218 | le32_to_cpu(tx->expected_ack_cnt), |
| 1219 | accum_tx->expected_ack_cnt, |
| 1220 | delta_tx->expected_ack_cnt, |
| 1221 | max_tx->expected_ack_cnt); |
| 1222 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1223 | fmt_table, "actual_ack_cnt:", |
| 1224 | le32_to_cpu(tx->actual_ack_cnt), |
| 1225 | accum_tx->actual_ack_cnt, |
| 1226 | delta_tx->actual_ack_cnt, |
| 1227 | max_tx->actual_ack_cnt); |
| 1228 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1229 | fmt_table, "dump_msdu_cnt:", |
| 1230 | le32_to_cpu(tx->dump_msdu_cnt), |
| 1231 | accum_tx->dump_msdu_cnt, |
| 1232 | delta_tx->dump_msdu_cnt, |
| 1233 | max_tx->dump_msdu_cnt); |
| 1234 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1235 | fmt_table, "abort_nxt_frame_mismatch:", |
| 1236 | le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), |
| 1237 | accum_tx->burst_abort_next_frame_mismatch_cnt, |
| 1238 | delta_tx->burst_abort_next_frame_mismatch_cnt, |
| 1239 | max_tx->burst_abort_next_frame_mismatch_cnt); |
| 1240 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1241 | fmt_table, "abort_missing_nxt_frame:", |
| 1242 | le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), |
| 1243 | accum_tx->burst_abort_missing_next_frame_cnt, |
| 1244 | delta_tx->burst_abort_missing_next_frame_cnt, |
| 1245 | max_tx->burst_abort_missing_next_frame_cnt); |
| 1246 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1247 | fmt_table, "cts_timeout_collision:", |
| 1248 | le32_to_cpu(tx->cts_timeout_collision), |
| 1249 | accum_tx->cts_timeout_collision, |
| 1250 | delta_tx->cts_timeout_collision, |
| 1251 | max_tx->cts_timeout_collision); |
| 1252 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1253 | fmt_table, "ack_ba_timeout_collision:", |
| 1254 | le32_to_cpu(tx->ack_or_ba_timeout_collision), |
| 1255 | accum_tx->ack_or_ba_timeout_collision, |
| 1256 | delta_tx->ack_or_ba_timeout_collision, |
| 1257 | max_tx->ack_or_ba_timeout_collision); |
| 1258 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1259 | fmt_table, "agg ba_timeout:", |
| 1260 | le32_to_cpu(tx->agg.ba_timeout), |
| 1261 | accum_tx->agg.ba_timeout, |
| 1262 | delta_tx->agg.ba_timeout, |
| 1263 | max_tx->agg.ba_timeout); |
| 1264 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1265 | fmt_table, "agg ba_resched_frames:", |
| 1266 | le32_to_cpu(tx->agg.ba_reschedule_frames), |
| 1267 | accum_tx->agg.ba_reschedule_frames, |
| 1268 | delta_tx->agg.ba_reschedule_frames, |
| 1269 | max_tx->agg.ba_reschedule_frames); |
| 1270 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1271 | fmt_table, "agg scd_query_agg_frame:", |
| 1272 | le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), |
| 1273 | accum_tx->agg.scd_query_agg_frame_cnt, |
| 1274 | delta_tx->agg.scd_query_agg_frame_cnt, |
| 1275 | max_tx->agg.scd_query_agg_frame_cnt); |
| 1276 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1277 | fmt_table, "agg scd_query_no_agg:", |
| 1278 | le32_to_cpu(tx->agg.scd_query_no_agg), |
| 1279 | accum_tx->agg.scd_query_no_agg, |
| 1280 | delta_tx->agg.scd_query_no_agg, |
| 1281 | max_tx->agg.scd_query_no_agg); |
| 1282 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1283 | fmt_table, "agg scd_query_agg:", |
| 1284 | le32_to_cpu(tx->agg.scd_query_agg), |
| 1285 | accum_tx->agg.scd_query_agg, |
| 1286 | delta_tx->agg.scd_query_agg, |
| 1287 | max_tx->agg.scd_query_agg); |
| 1288 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1289 | fmt_table, "agg scd_query_mismatch:", |
| 1290 | le32_to_cpu(tx->agg.scd_query_mismatch), |
| 1291 | accum_tx->agg.scd_query_mismatch, |
| 1292 | delta_tx->agg.scd_query_mismatch, |
| 1293 | max_tx->agg.scd_query_mismatch); |
| 1294 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1295 | fmt_table, "agg frame_not_ready:", |
| 1296 | le32_to_cpu(tx->agg.frame_not_ready), |
| 1297 | accum_tx->agg.frame_not_ready, |
| 1298 | delta_tx->agg.frame_not_ready, |
| 1299 | max_tx->agg.frame_not_ready); |
| 1300 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1301 | fmt_table, "agg underrun:", |
| 1302 | le32_to_cpu(tx->agg.underrun), |
| 1303 | accum_tx->agg.underrun, |
| 1304 | delta_tx->agg.underrun, max_tx->agg.underrun); |
| 1305 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1306 | fmt_table, "agg bt_prio_kill:", |
| 1307 | le32_to_cpu(tx->agg.bt_prio_kill), |
| 1308 | accum_tx->agg.bt_prio_kill, |
| 1309 | delta_tx->agg.bt_prio_kill, |
| 1310 | max_tx->agg.bt_prio_kill); |
| 1311 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1312 | fmt_table, "agg rx_ba_rsp_cnt:", |
| 1313 | le32_to_cpu(tx->agg.rx_ba_rsp_cnt), |
| 1314 | accum_tx->agg.rx_ba_rsp_cnt, |
| 1315 | delta_tx->agg.rx_ba_rsp_cnt, |
| 1316 | max_tx->agg.rx_ba_rsp_cnt); |
| 1317 | |
| 1318 | if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) { |
| 1319 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1320 | "tx power: (1/2 dB step)\n"); |
Eytan Lifshitz | b7998c8 | 2012-12-01 20:59:49 +0200 | [diff] [blame] | 1321 | if ((priv->nvm_data->valid_tx_ant & ANT_A) && |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1322 | tx->tx_power.ant_a) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1323 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1324 | fmt_hex, "antenna A:", |
| 1325 | tx->tx_power.ant_a); |
Eytan Lifshitz | b7998c8 | 2012-12-01 20:59:49 +0200 | [diff] [blame] | 1326 | if ((priv->nvm_data->valid_tx_ant & ANT_B) && |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1327 | tx->tx_power.ant_b) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1328 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1329 | fmt_hex, "antenna B:", |
| 1330 | tx->tx_power.ant_b); |
Eytan Lifshitz | b7998c8 | 2012-12-01 20:59:49 +0200 | [diff] [blame] | 1331 | if ((priv->nvm_data->valid_tx_ant & ANT_C) && |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1332 | tx->tx_power.ant_c) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1333 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1334 | fmt_hex, "antenna C:", |
| 1335 | tx->tx_power.ant_c); |
| 1336 | } |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1337 | |
| 1338 | spin_unlock_bh(&priv->statistics.lock); |
| 1339 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1340 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1341 | kfree(buf); |
| 1342 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1343 | } |
| 1344 | |
| 1345 | static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, |
| 1346 | char __user *user_buf, |
| 1347 | size_t count, loff_t *ppos) |
| 1348 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1349 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1350 | int pos = 0; |
| 1351 | char *buf; |
| 1352 | int bufsz = sizeof(struct statistics_general) * 10 + 300; |
| 1353 | ssize_t ret; |
| 1354 | struct statistics_general_common *general, *accum_general; |
| 1355 | struct statistics_general_common *delta_general, *max_general; |
| 1356 | struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; |
| 1357 | struct statistics_div *div, *accum_div, *delta_div, *max_div; |
| 1358 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 1359 | if (!iwl_is_alive(priv)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1360 | return -EAGAIN; |
| 1361 | |
| 1362 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 1363 | if (!buf) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1364 | return -ENOMEM; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1365 | |
| 1366 | /* the statistic information display here is based on |
| 1367 | * the last statistics notification from uCode |
| 1368 | * might not reflect the current uCode activity |
| 1369 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1370 | |
| 1371 | spin_lock_bh(&priv->statistics.lock); |
| 1372 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1373 | general = &priv->statistics.common; |
| 1374 | dbg = &priv->statistics.common.dbg; |
| 1375 | div = &priv->statistics.common.div; |
| 1376 | accum_general = &priv->accum_stats.common; |
| 1377 | accum_dbg = &priv->accum_stats.common.dbg; |
| 1378 | accum_div = &priv->accum_stats.common.div; |
| 1379 | delta_general = &priv->delta_stats.common; |
| 1380 | max_general = &priv->max_delta_stats.common; |
| 1381 | delta_dbg = &priv->delta_stats.common.dbg; |
| 1382 | max_dbg = &priv->max_delta_stats.common.dbg; |
| 1383 | delta_div = &priv->delta_stats.common.div; |
| 1384 | max_div = &priv->max_delta_stats.common.div; |
| 1385 | |
| 1386 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1387 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1388 | fmt_header, "Statistics_General:"); |
| 1389 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1390 | fmt_value, "temperature:", |
| 1391 | le32_to_cpu(general->temperature)); |
| 1392 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1393 | fmt_value, "temperature_m:", |
| 1394 | le32_to_cpu(general->temperature_m)); |
| 1395 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1396 | fmt_value, "ttl_timestamp:", |
| 1397 | le32_to_cpu(general->ttl_timestamp)); |
| 1398 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1399 | fmt_table, "burst_check:", |
| 1400 | le32_to_cpu(dbg->burst_check), |
| 1401 | accum_dbg->burst_check, |
| 1402 | delta_dbg->burst_check, max_dbg->burst_check); |
| 1403 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1404 | fmt_table, "burst_count:", |
| 1405 | le32_to_cpu(dbg->burst_count), |
| 1406 | accum_dbg->burst_count, |
| 1407 | delta_dbg->burst_count, max_dbg->burst_count); |
| 1408 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1409 | fmt_table, "wait_for_silence_timeout_count:", |
| 1410 | le32_to_cpu(dbg->wait_for_silence_timeout_cnt), |
| 1411 | accum_dbg->wait_for_silence_timeout_cnt, |
| 1412 | delta_dbg->wait_for_silence_timeout_cnt, |
| 1413 | max_dbg->wait_for_silence_timeout_cnt); |
| 1414 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1415 | fmt_table, "sleep_time:", |
| 1416 | le32_to_cpu(general->sleep_time), |
| 1417 | accum_general->sleep_time, |
| 1418 | delta_general->sleep_time, max_general->sleep_time); |
| 1419 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1420 | fmt_table, "slots_out:", |
| 1421 | le32_to_cpu(general->slots_out), |
| 1422 | accum_general->slots_out, |
| 1423 | delta_general->slots_out, max_general->slots_out); |
| 1424 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1425 | fmt_table, "slots_idle:", |
| 1426 | le32_to_cpu(general->slots_idle), |
| 1427 | accum_general->slots_idle, |
| 1428 | delta_general->slots_idle, max_general->slots_idle); |
| 1429 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1430 | fmt_table, "tx_on_a:", |
| 1431 | le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, |
| 1432 | delta_div->tx_on_a, max_div->tx_on_a); |
| 1433 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1434 | fmt_table, "tx_on_b:", |
| 1435 | le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, |
| 1436 | delta_div->tx_on_b, max_div->tx_on_b); |
| 1437 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1438 | fmt_table, "exec_time:", |
| 1439 | le32_to_cpu(div->exec_time), accum_div->exec_time, |
| 1440 | delta_div->exec_time, max_div->exec_time); |
| 1441 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1442 | fmt_table, "probe_time:", |
| 1443 | le32_to_cpu(div->probe_time), accum_div->probe_time, |
| 1444 | delta_div->probe_time, max_div->probe_time); |
| 1445 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1446 | fmt_table, "rx_enable_counter:", |
| 1447 | le32_to_cpu(general->rx_enable_counter), |
| 1448 | accum_general->rx_enable_counter, |
| 1449 | delta_general->rx_enable_counter, |
| 1450 | max_general->rx_enable_counter); |
| 1451 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1452 | fmt_table, "num_of_sos_states:", |
| 1453 | le32_to_cpu(general->num_of_sos_states), |
| 1454 | accum_general->num_of_sos_states, |
| 1455 | delta_general->num_of_sos_states, |
| 1456 | max_general->num_of_sos_states); |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1457 | |
| 1458 | spin_unlock_bh(&priv->statistics.lock); |
| 1459 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1460 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1461 | kfree(buf); |
| 1462 | return ret; |
| 1463 | } |
| 1464 | |
| 1465 | static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, |
| 1466 | char __user *user_buf, |
| 1467 | size_t count, loff_t *ppos) |
| 1468 | { |
| 1469 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1470 | int pos = 0; |
| 1471 | char *buf; |
| 1472 | int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200; |
| 1473 | ssize_t ret; |
| 1474 | struct statistics_bt_activity *bt, *accum_bt; |
| 1475 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 1476 | if (!iwl_is_alive(priv)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1477 | return -EAGAIN; |
| 1478 | |
| 1479 | if (!priv->bt_enable_flag) |
| 1480 | return -EINVAL; |
| 1481 | |
| 1482 | /* make request to uCode to retrieve statistics information */ |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 1483 | mutex_lock(&priv->mutex); |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame^] | 1484 | ret = iwl_send_statistics_request(priv, 0, false); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 1485 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1486 | |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 1487 | if (ret) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1488 | return -EAGAIN; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1489 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 1490 | if (!buf) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1491 | return -ENOMEM; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1492 | |
| 1493 | /* |
| 1494 | * the statistic information display here is based on |
| 1495 | * the last statistics notification from uCode |
| 1496 | * might not reflect the current uCode activity |
| 1497 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1498 | |
| 1499 | spin_lock_bh(&priv->statistics.lock); |
| 1500 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1501 | bt = &priv->statistics.bt_activity; |
| 1502 | accum_bt = &priv->accum_stats.bt_activity; |
| 1503 | |
| 1504 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1505 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n"); |
| 1506 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1507 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1508 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1509 | "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1510 | le32_to_cpu(bt->hi_priority_tx_req_cnt), |
| 1511 | accum_bt->hi_priority_tx_req_cnt); |
| 1512 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1513 | "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n", |
| 1514 | le32_to_cpu(bt->hi_priority_tx_denied_cnt), |
| 1515 | accum_bt->hi_priority_tx_denied_cnt); |
| 1516 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1517 | "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1518 | le32_to_cpu(bt->lo_priority_tx_req_cnt), |
| 1519 | accum_bt->lo_priority_tx_req_cnt); |
| 1520 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1521 | "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n", |
| 1522 | le32_to_cpu(bt->lo_priority_tx_denied_cnt), |
| 1523 | accum_bt->lo_priority_tx_denied_cnt); |
| 1524 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1525 | "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1526 | le32_to_cpu(bt->hi_priority_rx_req_cnt), |
| 1527 | accum_bt->hi_priority_rx_req_cnt); |
| 1528 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1529 | "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n", |
| 1530 | le32_to_cpu(bt->hi_priority_rx_denied_cnt), |
| 1531 | accum_bt->hi_priority_rx_denied_cnt); |
| 1532 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1533 | "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1534 | le32_to_cpu(bt->lo_priority_rx_req_cnt), |
| 1535 | accum_bt->lo_priority_rx_req_cnt); |
| 1536 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1537 | "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n", |
| 1538 | le32_to_cpu(bt->lo_priority_rx_denied_cnt), |
| 1539 | accum_bt->lo_priority_rx_denied_cnt); |
| 1540 | |
| 1541 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1542 | "(rx)num_bt_kills:\t\t%u\t\t\t%u\n", |
| 1543 | le32_to_cpu(priv->statistics.num_bt_kills), |
| 1544 | priv->statistics.accum_num_bt_kills); |
| 1545 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1546 | spin_unlock_bh(&priv->statistics.lock); |
| 1547 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1548 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1549 | kfree(buf); |
| 1550 | return ret; |
| 1551 | } |
| 1552 | |
| 1553 | static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file, |
| 1554 | char __user *user_buf, |
| 1555 | size_t count, loff_t *ppos) |
| 1556 | { |
| 1557 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1558 | int pos = 0; |
| 1559 | char *buf; |
| 1560 | int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) + |
| 1561 | (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200; |
| 1562 | ssize_t ret; |
| 1563 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 1564 | if (!iwl_is_alive(priv)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1565 | return -EAGAIN; |
| 1566 | |
| 1567 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 1568 | if (!buf) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1569 | return -ENOMEM; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1570 | |
| 1571 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n"); |
| 1572 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n", |
| 1573 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1574 | priv->reply_tx_stats.pp_delay); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1575 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1576 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1577 | priv->reply_tx_stats.pp_few_bytes); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1578 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1579 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1580 | priv->reply_tx_stats.pp_bt_prio); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1581 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1582 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1583 | priv->reply_tx_stats.pp_quiet_period); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1584 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1585 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1586 | priv->reply_tx_stats.pp_calc_ttak); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1587 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1588 | iwl_get_tx_fail_reason( |
| 1589 | TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1590 | priv->reply_tx_stats.int_crossed_retry); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1591 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1592 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1593 | priv->reply_tx_stats.short_limit); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1594 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1595 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1596 | priv->reply_tx_stats.long_limit); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1597 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1598 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1599 | priv->reply_tx_stats.fifo_underrun); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1600 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1601 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1602 | priv->reply_tx_stats.drain_flow); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1603 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1604 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1605 | priv->reply_tx_stats.rfkill_flush); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1606 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1607 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1608 | priv->reply_tx_stats.life_expire); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1609 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1610 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1611 | priv->reply_tx_stats.dest_ps); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1612 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1613 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1614 | priv->reply_tx_stats.host_abort); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1615 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1616 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1617 | priv->reply_tx_stats.pp_delay); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1618 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1619 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1620 | priv->reply_tx_stats.sta_invalid); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1621 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1622 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1623 | priv->reply_tx_stats.frag_drop); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1624 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1625 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1626 | priv->reply_tx_stats.tid_disable); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1627 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1628 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1629 | priv->reply_tx_stats.fifo_flush); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1630 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1631 | iwl_get_tx_fail_reason( |
| 1632 | TX_STATUS_FAIL_INSUFFICIENT_CF_POLL), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1633 | priv->reply_tx_stats.insuff_cf_poll); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1634 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1635 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1636 | priv->reply_tx_stats.fail_hw_drop); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1637 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1638 | iwl_get_tx_fail_reason( |
| 1639 | TX_STATUS_FAIL_NO_BEACON_ON_RADAR), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1640 | priv->reply_tx_stats.sta_color_mismatch); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1641 | pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1642 | priv->reply_tx_stats.unknown); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1643 | |
| 1644 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1645 | "\nStatistics_Agg_TX_Error:\n"); |
| 1646 | |
| 1647 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1648 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1649 | priv->reply_agg_tx_stats.underrun); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1650 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1651 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1652 | priv->reply_agg_tx_stats.bt_prio); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1653 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1654 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1655 | priv->reply_agg_tx_stats.few_bytes); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1656 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1657 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1658 | priv->reply_agg_tx_stats.abort); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1659 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1660 | iwl_get_agg_tx_fail_reason( |
| 1661 | AGG_TX_STATE_LAST_SENT_TTL_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1662 | priv->reply_agg_tx_stats.last_sent_ttl); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1663 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1664 | iwl_get_agg_tx_fail_reason( |
| 1665 | AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1666 | priv->reply_agg_tx_stats.last_sent_try); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1667 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1668 | iwl_get_agg_tx_fail_reason( |
| 1669 | AGG_TX_STATE_LAST_SENT_BT_KILL_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1670 | priv->reply_agg_tx_stats.last_sent_bt_kill); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1671 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1672 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1673 | priv->reply_agg_tx_stats.scd_query); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1674 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1675 | iwl_get_agg_tx_fail_reason( |
| 1676 | AGG_TX_STATE_TEST_BAD_CRC32_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1677 | priv->reply_agg_tx_stats.bad_crc32); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1678 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1679 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1680 | priv->reply_agg_tx_stats.response); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1681 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1682 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1683 | priv->reply_agg_tx_stats.dump_tx); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1684 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1685 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1686 | priv->reply_agg_tx_stats.delay_tx); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1687 | pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1688 | priv->reply_agg_tx_stats.unknown); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1689 | |
| 1690 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1691 | kfree(buf); |
| 1692 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1693 | } |
| 1694 | |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1695 | static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, |
| 1696 | char __user *user_buf, |
| 1697 | size_t count, loff_t *ppos) { |
| 1698 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1699 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1700 | int pos = 0; |
| 1701 | int cnt = 0; |
| 1702 | char *buf; |
| 1703 | int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; |
| 1704 | ssize_t ret; |
| 1705 | struct iwl_sensitivity_data *data; |
| 1706 | |
| 1707 | data = &priv->sensitivity_data; |
| 1708 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 1709 | if (!buf) |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1710 | return -ENOMEM; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1711 | |
| 1712 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", |
| 1713 | data->auto_corr_ofdm); |
| 1714 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1715 | "auto_corr_ofdm_mrc:\t\t %u\n", |
| 1716 | data->auto_corr_ofdm_mrc); |
| 1717 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", |
| 1718 | data->auto_corr_ofdm_x1); |
| 1719 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1720 | "auto_corr_ofdm_mrc_x1:\t\t %u\n", |
| 1721 | data->auto_corr_ofdm_mrc_x1); |
| 1722 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", |
| 1723 | data->auto_corr_cck); |
| 1724 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", |
| 1725 | data->auto_corr_cck_mrc); |
| 1726 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1727 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", |
| 1728 | data->last_bad_plcp_cnt_ofdm); |
| 1729 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", |
| 1730 | data->last_fa_cnt_ofdm); |
| 1731 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1732 | "last_bad_plcp_cnt_cck:\t\t %u\n", |
| 1733 | data->last_bad_plcp_cnt_cck); |
| 1734 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", |
| 1735 | data->last_fa_cnt_cck); |
| 1736 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", |
| 1737 | data->nrg_curr_state); |
| 1738 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", |
| 1739 | data->nrg_prev_state); |
| 1740 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); |
| 1741 | for (cnt = 0; cnt < 10; cnt++) { |
| 1742 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1743 | data->nrg_value[cnt]); |
| 1744 | } |
| 1745 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1746 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); |
| 1747 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { |
| 1748 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1749 | data->nrg_silence_rssi[cnt]); |
| 1750 | } |
| 1751 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1752 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", |
| 1753 | data->nrg_silence_ref); |
| 1754 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", |
| 1755 | data->nrg_energy_idx); |
| 1756 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", |
| 1757 | data->nrg_silence_idx); |
| 1758 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", |
| 1759 | data->nrg_th_cck); |
| 1760 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1761 | "nrg_auto_corr_silence_diff:\t %u\n", |
| 1762 | data->nrg_auto_corr_silence_diff); |
| 1763 | pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", |
| 1764 | data->num_in_cck_no_fa); |
| 1765 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", |
| 1766 | data->nrg_th_ofdm); |
| 1767 | |
| 1768 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1769 | kfree(buf); |
| 1770 | return ret; |
| 1771 | } |
| 1772 | |
| 1773 | |
| 1774 | static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, |
| 1775 | char __user *user_buf, |
| 1776 | size_t count, loff_t *ppos) { |
| 1777 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1778 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1779 | int pos = 0; |
| 1780 | int cnt = 0; |
| 1781 | char *buf; |
| 1782 | int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; |
| 1783 | ssize_t ret; |
| 1784 | struct iwl_chain_noise_data *data; |
| 1785 | |
| 1786 | data = &priv->chain_noise_data; |
| 1787 | buf = kzalloc(bufsz, GFP_KERNEL); |
Johannes Berg | f9e7544 | 2012-03-30 09:37:39 +0200 | [diff] [blame] | 1788 | if (!buf) |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1789 | return -ENOMEM; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1790 | |
| 1791 | pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", |
| 1792 | data->active_chains); |
| 1793 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", |
| 1794 | data->chain_noise_a); |
| 1795 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", |
| 1796 | data->chain_noise_b); |
| 1797 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", |
| 1798 | data->chain_noise_c); |
| 1799 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", |
| 1800 | data->chain_signal_a); |
| 1801 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", |
| 1802 | data->chain_signal_b); |
| 1803 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", |
| 1804 | data->chain_signal_c); |
| 1805 | pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", |
| 1806 | data->beacon_count); |
| 1807 | |
| 1808 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); |
| 1809 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1810 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1811 | data->disconn_array[cnt]); |
| 1812 | } |
| 1813 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1814 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); |
| 1815 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1816 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1817 | data->delta_gain_code[cnt]); |
| 1818 | } |
| 1819 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1820 | pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", |
| 1821 | data->radio_write); |
| 1822 | pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", |
| 1823 | data->state); |
| 1824 | |
| 1825 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1826 | kfree(buf); |
| 1827 | return ret; |
| 1828 | } |
| 1829 | |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1830 | static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, |
| 1831 | char __user *user_buf, |
| 1832 | size_t count, loff_t *ppos) |
| 1833 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1834 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1835 | char buf[60]; |
| 1836 | int pos = 0; |
| 1837 | const size_t bufsz = sizeof(buf); |
| 1838 | u32 pwrsave_status; |
| 1839 | |
Emmanuel Grumbach | 68e8dfd | 2012-04-18 07:28:17 -0700 | [diff] [blame] | 1840 | pwrsave_status = iwl_read32(priv->trans, CSR_GP_CNTRL) & |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1841 | CSR_GP_REG_POWER_SAVE_STATUS_MSK; |
| 1842 | |
| 1843 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); |
| 1844 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", |
| 1845 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : |
| 1846 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : |
| 1847 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : |
| 1848 | "error"); |
| 1849 | |
| 1850 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1851 | } |
| 1852 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1853 | static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file, |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 1854 | const char __user *user_buf, |
| 1855 | size_t count, loff_t *ppos) |
| 1856 | { |
| 1857 | struct iwl_priv *priv = file->private_data; |
| 1858 | char buf[8]; |
| 1859 | int buf_size; |
| 1860 | int clear; |
| 1861 | |
| 1862 | memset(buf, 0, sizeof(buf)); |
| 1863 | buf_size = min(count, sizeof(buf) - 1); |
| 1864 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1865 | return -EFAULT; |
| 1866 | if (sscanf(buf, "%d", &clear) != 1) |
| 1867 | return -EFAULT; |
| 1868 | |
| 1869 | /* make request to uCode to retrieve statistics information */ |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 1870 | mutex_lock(&priv->mutex); |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame^] | 1871 | iwl_send_statistics_request(priv, 0, true); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 1872 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 1873 | |
| 1874 | return count; |
| 1875 | } |
| 1876 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1877 | static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, |
| 1878 | char __user *user_buf, |
| 1879 | size_t count, loff_t *ppos) { |
| 1880 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1881 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1882 | int pos = 0; |
| 1883 | char buf[128]; |
| 1884 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1885 | |
| 1886 | pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", |
| 1887 | priv->event_log.ucode_trace ? "On" : "Off"); |
| 1888 | pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", |
| 1889 | priv->event_log.non_wraps_count); |
| 1890 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", |
| 1891 | priv->event_log.wraps_once_count); |
| 1892 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", |
| 1893 | priv->event_log.wraps_more_count); |
| 1894 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1895 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1896 | } |
| 1897 | |
| 1898 | static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, |
| 1899 | const char __user *user_buf, |
| 1900 | size_t count, loff_t *ppos) |
| 1901 | { |
| 1902 | struct iwl_priv *priv = file->private_data; |
| 1903 | char buf[8]; |
| 1904 | int buf_size; |
| 1905 | int trace; |
| 1906 | |
| 1907 | memset(buf, 0, sizeof(buf)); |
| 1908 | buf_size = min(count, sizeof(buf) - 1); |
| 1909 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1910 | return -EFAULT; |
| 1911 | if (sscanf(buf, "%d", &trace) != 1) |
| 1912 | return -EFAULT; |
| 1913 | |
| 1914 | if (trace) { |
| 1915 | priv->event_log.ucode_trace = true; |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 1916 | if (iwl_is_alive(priv)) { |
Johannes Berg | 98d4bf0 | 2012-01-13 11:56:11 +0100 | [diff] [blame] | 1917 | /* start collecting data now */ |
| 1918 | mod_timer(&priv->ucode_trace, jiffies); |
| 1919 | } |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1920 | } else { |
| 1921 | priv->event_log.ucode_trace = false; |
| 1922 | del_timer_sync(&priv->ucode_trace); |
| 1923 | } |
| 1924 | |
| 1925 | return count; |
| 1926 | } |
| 1927 | |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1928 | static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file, |
| 1929 | char __user *user_buf, |
| 1930 | size_t count, loff_t *ppos) { |
| 1931 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1932 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1933 | int len = 0; |
| 1934 | char buf[20]; |
| 1935 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 1936 | len = sprintf(buf, "0x%04X\n", |
| 1937 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1938 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1939 | } |
| 1940 | |
| 1941 | static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file, |
| 1942 | char __user *user_buf, |
| 1943 | size_t count, loff_t *ppos) { |
| 1944 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1945 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1946 | int len = 0; |
| 1947 | char buf[20]; |
| 1948 | |
| 1949 | len = sprintf(buf, "0x%04X\n", |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 1950 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1951 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1952 | } |
| 1953 | |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1954 | static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file, |
| 1955 | char __user *user_buf, |
| 1956 | size_t count, loff_t *ppos) { |
| 1957 | |
| 1958 | struct iwl_priv *priv = file->private_data; |
| 1959 | int pos = 0; |
| 1960 | char buf[12]; |
| 1961 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1962 | |
| 1963 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", |
| 1964 | priv->missed_beacon_threshold); |
| 1965 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1966 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1967 | } |
| 1968 | |
| 1969 | static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, |
| 1970 | const char __user *user_buf, |
| 1971 | size_t count, loff_t *ppos) |
| 1972 | { |
| 1973 | struct iwl_priv *priv = file->private_data; |
| 1974 | char buf[8]; |
| 1975 | int buf_size; |
| 1976 | int missed; |
| 1977 | |
| 1978 | memset(buf, 0, sizeof(buf)); |
| 1979 | buf_size = min(count, sizeof(buf) - 1); |
| 1980 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1981 | return -EFAULT; |
| 1982 | if (sscanf(buf, "%d", &missed) != 1) |
| 1983 | return -EINVAL; |
| 1984 | |
| 1985 | if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || |
| 1986 | missed > IWL_MISSED_BEACON_THRESHOLD_MAX) |
| 1987 | priv->missed_beacon_threshold = |
| 1988 | IWL_MISSED_BEACON_THRESHOLD_DEF; |
| 1989 | else |
| 1990 | priv->missed_beacon_threshold = missed; |
| 1991 | |
| 1992 | return count; |
| 1993 | } |
| 1994 | |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1995 | static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, |
| 1996 | char __user *user_buf, |
| 1997 | size_t count, loff_t *ppos) { |
| 1998 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1999 | struct iwl_priv *priv = file->private_data; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2000 | int pos = 0; |
| 2001 | char buf[12]; |
| 2002 | const size_t bufsz = sizeof(buf); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2003 | |
| 2004 | pos += scnprintf(buf + pos, bufsz - pos, "%u\n", |
Johannes Berg | ab5c0f1 | 2012-03-06 13:30:53 -0800 | [diff] [blame] | 2005 | priv->plcp_delta_threshold); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2006 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 2007 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2008 | } |
| 2009 | |
| 2010 | static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, |
| 2011 | const char __user *user_buf, |
| 2012 | size_t count, loff_t *ppos) { |
| 2013 | |
| 2014 | struct iwl_priv *priv = file->private_data; |
| 2015 | char buf[8]; |
| 2016 | int buf_size; |
| 2017 | int plcp; |
| 2018 | |
| 2019 | memset(buf, 0, sizeof(buf)); |
| 2020 | buf_size = min(count, sizeof(buf) - 1); |
| 2021 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2022 | return -EFAULT; |
| 2023 | if (sscanf(buf, "%d", &plcp) != 1) |
| 2024 | return -EINVAL; |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 2025 | if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2026 | (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) |
Johannes Berg | ab5c0f1 | 2012-03-06 13:30:53 -0800 | [diff] [blame] | 2027 | priv->plcp_delta_threshold = |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 2028 | IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2029 | else |
Johannes Berg | ab5c0f1 | 2012-03-06 13:30:53 -0800 | [diff] [blame] | 2030 | priv->plcp_delta_threshold = plcp; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2031 | return count; |
| 2032 | } |
| 2033 | |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2034 | static ssize_t iwl_dbgfs_rf_reset_read(struct file *file, |
| 2035 | char __user *user_buf, |
| 2036 | size_t count, loff_t *ppos) |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2037 | { |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2038 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2039 | int pos = 0; |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2040 | char buf[300]; |
| 2041 | const size_t bufsz = sizeof(buf); |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2042 | struct iwl_rf_reset *rf_reset = &priv->rf_reset; |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2043 | |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2044 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2045 | "RF reset statistics\n"); |
| 2046 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2047 | "\tnumber of reset request: %d\n", |
| 2048 | rf_reset->reset_request_count); |
| 2049 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2050 | "\tnumber of reset request success: %d\n", |
| 2051 | rf_reset->reset_success_count); |
| 2052 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2053 | "\tnumber of reset request reject: %d\n", |
| 2054 | rf_reset->reset_reject_count); |
| 2055 | |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2056 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2057 | } |
| 2058 | |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2059 | static ssize_t iwl_dbgfs_rf_reset_write(struct file *file, |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 2060 | const char __user *user_buf, |
| 2061 | size_t count, loff_t *ppos) { |
| 2062 | |
| 2063 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2064 | int ret; |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 2065 | |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2066 | ret = iwl_force_rf_reset(priv, true); |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 2067 | return ret ? ret : count; |
| 2068 | } |
| 2069 | |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2070 | static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, |
| 2071 | const char __user *user_buf, |
| 2072 | size_t count, loff_t *ppos) { |
| 2073 | |
| 2074 | struct iwl_priv *priv = file->private_data; |
| 2075 | char buf[8]; |
| 2076 | int buf_size; |
| 2077 | int flush; |
| 2078 | |
| 2079 | memset(buf, 0, sizeof(buf)); |
| 2080 | buf_size = min(count, sizeof(buf) - 1); |
| 2081 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2082 | return -EFAULT; |
| 2083 | if (sscanf(buf, "%d", &flush) != 1) |
| 2084 | return -EINVAL; |
| 2085 | |
Don Fry | 8362640 | 2012-03-07 09:52:37 -0800 | [diff] [blame] | 2086 | if (iwl_is_rfkill(priv)) |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2087 | return -EFAULT; |
| 2088 | |
Johannes Berg | a4dece9 | 2012-10-31 22:21:28 +0100 | [diff] [blame] | 2089 | iwlagn_dev_txfifo_flush(priv); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2090 | |
| 2091 | return count; |
| 2092 | } |
| 2093 | |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2094 | static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file, |
| 2095 | char __user *user_buf, |
| 2096 | size_t count, loff_t *ppos) { |
| 2097 | |
| 2098 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 2099 | int pos = 0; |
| 2100 | char buf[200]; |
| 2101 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2102 | |
Wey-Yi Guy | f21dd00 | 2010-12-08 15:34:52 -0800 | [diff] [blame] | 2103 | if (!priv->bt_enable_flag) { |
| 2104 | pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n"); |
Johannes Berg | 08960de | 2011-04-05 09:41:53 -0700 | [diff] [blame] | 2105 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | f21dd00 | 2010-12-08 15:34:52 -0800 | [diff] [blame] | 2106 | } |
| 2107 | pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n", |
| 2108 | priv->bt_enable_flag); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2109 | pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n", |
| 2110 | priv->bt_full_concurrent ? "full concurrency" : "3-wire"); |
| 2111 | pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, " |
| 2112 | "last traffic notif: %d\n", |
Wey-Yi Guy | 66e863a5 | 2010-11-08 14:54:37 -0800 | [diff] [blame] | 2113 | priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2114 | pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, " |
Wey-Yi Guy | 187bc4f | 2011-01-27 13:01:33 -0800 | [diff] [blame] | 2115 | "kill_ack_mask: %x, kill_cts_mask: %x\n", |
| 2116 | priv->bt_ch_announce, priv->kill_ack_mask, |
| 2117 | priv->kill_cts_mask); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2118 | |
| 2119 | pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: "); |
| 2120 | switch (priv->bt_traffic_load) { |
| 2121 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: |
| 2122 | pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n"); |
| 2123 | break; |
| 2124 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: |
| 2125 | pos += scnprintf(buf + pos, bufsz - pos, "High\n"); |
| 2126 | break; |
| 2127 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
| 2128 | pos += scnprintf(buf + pos, bufsz - pos, "Low\n"); |
| 2129 | break; |
| 2130 | case IWL_BT_COEX_TRAFFIC_LOAD_NONE: |
| 2131 | default: |
| 2132 | pos += scnprintf(buf + pos, bufsz - pos, "None\n"); |
| 2133 | break; |
| 2134 | } |
| 2135 | |
Johannes Berg | 08960de | 2011-04-05 09:41:53 -0700 | [diff] [blame] | 2136 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2137 | } |
| 2138 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2139 | static ssize_t iwl_dbgfs_protection_mode_read(struct file *file, |
| 2140 | char __user *user_buf, |
| 2141 | size_t count, loff_t *ppos) |
| 2142 | { |
| 2143 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 2144 | |
| 2145 | int pos = 0; |
| 2146 | char buf[40]; |
| 2147 | const size_t bufsz = sizeof(buf); |
| 2148 | |
Emmanuel Grumbach | 2152268 | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 2149 | if (priv->cfg->ht_params) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2150 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2151 | "use %s for aggregation\n", |
Johannes Berg | 9e29511 | 2012-04-09 17:46:55 -0700 | [diff] [blame] | 2152 | (priv->hw_params.use_rts_for_aggregation) ? |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2153 | "rts/cts" : "cts-to-self"); |
| 2154 | else |
| 2155 | pos += scnprintf(buf + pos, bufsz - pos, "N/A"); |
| 2156 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2157 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2158 | } |
| 2159 | |
| 2160 | static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, |
| 2161 | const char __user *user_buf, |
| 2162 | size_t count, loff_t *ppos) { |
| 2163 | |
| 2164 | struct iwl_priv *priv = file->private_data; |
| 2165 | char buf[8]; |
| 2166 | int buf_size; |
| 2167 | int rts; |
| 2168 | |
Emmanuel Grumbach | 2152268 | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 2169 | if (!priv->cfg->ht_params) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2170 | return -EINVAL; |
| 2171 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2172 | memset(buf, 0, sizeof(buf)); |
| 2173 | buf_size = min(count, sizeof(buf) - 1); |
| 2174 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2175 | return -EFAULT; |
| 2176 | if (sscanf(buf, "%d", &rts) != 1) |
| 2177 | return -EINVAL; |
| 2178 | if (rts) |
Johannes Berg | 9e29511 | 2012-04-09 17:46:55 -0700 | [diff] [blame] | 2179 | priv->hw_params.use_rts_for_aggregation = true; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2180 | else |
Johannes Berg | 9e29511 | 2012-04-09 17:46:55 -0700 | [diff] [blame] | 2181 | priv->hw_params.use_rts_for_aggregation = false; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2182 | return count; |
| 2183 | } |
| 2184 | |
Johannes Berg | c98c8d9 | 2012-04-02 15:15:58 +0200 | [diff] [blame] | 2185 | static int iwl_cmd_echo_test(struct iwl_priv *priv) |
| 2186 | { |
| 2187 | int ret; |
| 2188 | struct iwl_host_cmd cmd = { |
| 2189 | .id = REPLY_ECHO, |
| 2190 | .len = { 0 }, |
Johannes Berg | c98c8d9 | 2012-04-02 15:15:58 +0200 | [diff] [blame] | 2191 | }; |
| 2192 | |
| 2193 | ret = iwl_dvm_send_cmd(priv, &cmd); |
| 2194 | if (ret) |
| 2195 | IWL_ERR(priv, "echo testing fail: 0X%x\n", ret); |
| 2196 | else |
| 2197 | IWL_DEBUG_INFO(priv, "echo testing pass\n"); |
| 2198 | return ret; |
| 2199 | } |
| 2200 | |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2201 | static ssize_t iwl_dbgfs_echo_test_write(struct file *file, |
| 2202 | const char __user *user_buf, |
| 2203 | size_t count, loff_t *ppos) |
| 2204 | { |
| 2205 | struct iwl_priv *priv = file->private_data; |
| 2206 | char buf[8]; |
| 2207 | int buf_size; |
| 2208 | |
| 2209 | memset(buf, 0, sizeof(buf)); |
| 2210 | buf_size = min(count, sizeof(buf) - 1); |
| 2211 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2212 | return -EFAULT; |
| 2213 | |
| 2214 | iwl_cmd_echo_test(priv); |
| 2215 | return count; |
| 2216 | } |
| 2217 | |
Johannes Berg | 882b7b7 | 2012-06-20 08:46:25 +0200 | [diff] [blame] | 2218 | #ifdef CONFIG_IWLWIFI_DEBUG |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2219 | static ssize_t iwl_dbgfs_log_event_read(struct file *file, |
| 2220 | char __user *user_buf, |
| 2221 | size_t count, loff_t *ppos) |
| 2222 | { |
| 2223 | struct iwl_priv *priv = file->private_data; |
Stanislaw Gruszka | 3309ccf | 2013-04-16 15:38:29 +0200 | [diff] [blame] | 2224 | char *buf = NULL; |
| 2225 | ssize_t ret; |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2226 | |
Stanislaw Gruszka | a6db006 | 2013-04-16 15:40:54 +0200 | [diff] [blame] | 2227 | ret = iwl_dump_nic_event_log(priv, true, &buf); |
Stanislaw Gruszka | d557894 | 2013-04-17 08:23:50 +0200 | [diff] [blame] | 2228 | if (ret > 0) |
| 2229 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); |
Stanislaw Gruszka | 3309ccf | 2013-04-16 15:38:29 +0200 | [diff] [blame] | 2230 | kfree(buf); |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2231 | return ret; |
| 2232 | } |
| 2233 | |
| 2234 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
| 2235 | const char __user *user_buf, |
| 2236 | size_t count, loff_t *ppos) |
| 2237 | { |
| 2238 | struct iwl_priv *priv = file->private_data; |
| 2239 | u32 event_log_flag; |
| 2240 | char buf[8]; |
| 2241 | int buf_size; |
| 2242 | |
Richard A. Griffiths | 0ff1bd3 | 2012-06-28 13:14:11 -0700 | [diff] [blame] | 2243 | /* check that the interface is up */ |
| 2244 | if (!iwl_is_ready(priv)) |
| 2245 | return -EAGAIN; |
| 2246 | |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2247 | memset(buf, 0, sizeof(buf)); |
| 2248 | buf_size = min(count, sizeof(buf) - 1); |
| 2249 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2250 | return -EFAULT; |
| 2251 | if (sscanf(buf, "%d", &event_log_flag) != 1) |
| 2252 | return -EFAULT; |
| 2253 | if (event_log_flag == 1) |
Stanislaw Gruszka | a6db006 | 2013-04-16 15:40:54 +0200 | [diff] [blame] | 2254 | iwl_dump_nic_event_log(priv, true, NULL); |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2255 | |
| 2256 | return count; |
| 2257 | } |
Johannes Berg | 882b7b7 | 2012-06-20 08:46:25 +0200 | [diff] [blame] | 2258 | #endif |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2259 | |
Dor Shaish | bfb45f5 | 2012-03-26 08:20:55 -0700 | [diff] [blame] | 2260 | static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file, |
| 2261 | char __user *user_buf, |
| 2262 | size_t count, loff_t *ppos) |
| 2263 | { |
| 2264 | struct iwl_priv *priv = file->private_data; |
| 2265 | char buf[120]; |
| 2266 | int pos = 0; |
| 2267 | const size_t bufsz = sizeof(buf); |
| 2268 | |
| 2269 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2270 | "Sensitivity calibrations %s\n", |
| 2271 | (priv->calib_disabled & |
| 2272 | IWL_SENSITIVITY_CALIB_DISABLED) ? |
| 2273 | "DISABLED" : "ENABLED"); |
| 2274 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2275 | "Chain noise calibrations %s\n", |
| 2276 | (priv->calib_disabled & |
| 2277 | IWL_CHAIN_NOISE_CALIB_DISABLED) ? |
| 2278 | "DISABLED" : "ENABLED"); |
| 2279 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2280 | "Tx power calibrations %s\n", |
| 2281 | (priv->calib_disabled & |
| 2282 | IWL_TX_POWER_CALIB_DISABLED) ? |
| 2283 | "DISABLED" : "ENABLED"); |
| 2284 | |
| 2285 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2286 | } |
| 2287 | |
David Spinadel | 647ad13 | 2012-03-31 08:31:05 -0700 | [diff] [blame] | 2288 | static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file, |
| 2289 | const char __user *user_buf, |
| 2290 | size_t count, loff_t *ppos) |
| 2291 | { |
| 2292 | struct iwl_priv *priv = file->private_data; |
| 2293 | char buf[8]; |
| 2294 | u32 calib_disabled; |
| 2295 | int buf_size; |
| 2296 | |
| 2297 | memset(buf, 0, sizeof(buf)); |
| 2298 | buf_size = min(count, sizeof(buf) - 1); |
| 2299 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2300 | return -EFAULT; |
| 2301 | if (sscanf(buf, "%x", &calib_disabled) != 1) |
| 2302 | return -EFAULT; |
| 2303 | |
| 2304 | priv->calib_disabled = calib_disabled; |
| 2305 | |
| 2306 | return count; |
| 2307 | } |
| 2308 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 2309 | static ssize_t iwl_dbgfs_fw_restart_write(struct file *file, |
| 2310 | const char __user *user_buf, |
| 2311 | size_t count, loff_t *ppos) |
| 2312 | { |
| 2313 | struct iwl_priv *priv = file->private_data; |
| 2314 | bool restart_fw = iwlwifi_mod_params.restart_fw; |
| 2315 | int ret; |
| 2316 | |
| 2317 | iwlwifi_mod_params.restart_fw = true; |
| 2318 | |
| 2319 | mutex_lock(&priv->mutex); |
| 2320 | |
| 2321 | /* take the return value to make compiler happy - it will fail anyway */ |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame^] | 2322 | ret = iwl_dvm_send_cmd_pdu(priv, REPLY_ERROR, 0, 0, NULL); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 2323 | |
| 2324 | mutex_unlock(&priv->mutex); |
| 2325 | |
| 2326 | iwlwifi_mod_params.restart_fw = restart_fw; |
| 2327 | |
| 2328 | return count; |
| 2329 | } |
| 2330 | |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 2331 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
| 2332 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
| 2333 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 2334 | DEBUGFS_READ_FILE_OPS(sensitivity); |
| 2335 | DEBUGFS_READ_FILE_OPS(chain_noise); |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2336 | DEBUGFS_READ_FILE_OPS(power_save_status); |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2337 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2338 | DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2339 | DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2340 | DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2341 | DEBUGFS_READ_WRITE_FILE_OPS(rf_reset); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2342 | DEBUGFS_READ_FILE_OPS(rxon_flags); |
| 2343 | DEBUGFS_READ_FILE_OPS(rxon_filter_flags); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2344 | DEBUGFS_WRITE_FILE_OPS(txfifo_flush); |
Wey-Yi Guy | ffb7d89 | 2010-07-14 08:09:55 -0700 | [diff] [blame] | 2345 | DEBUGFS_READ_FILE_OPS(ucode_bt_stats); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2346 | DEBUGFS_READ_FILE_OPS(bt_traffic); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2347 | DEBUGFS_READ_WRITE_FILE_OPS(protection_mode); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 2348 | DEBUGFS_READ_FILE_OPS(reply_tx_error); |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2349 | DEBUGFS_WRITE_FILE_OPS(echo_test); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 2350 | DEBUGFS_WRITE_FILE_OPS(fw_restart); |
Johannes Berg | 882b7b7 | 2012-06-20 08:46:25 +0200 | [diff] [blame] | 2351 | #ifdef CONFIG_IWLWIFI_DEBUG |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2352 | DEBUGFS_READ_WRITE_FILE_OPS(log_event); |
Johannes Berg | 882b7b7 | 2012-06-20 08:46:25 +0200 | [diff] [blame] | 2353 | #endif |
David Spinadel | 647ad13 | 2012-03-31 08:31:05 -0700 | [diff] [blame] | 2354 | DEBUGFS_READ_WRITE_FILE_OPS(calib_disabled); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 2355 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2356 | /* |
| 2357 | * Create the debugfs files and directories |
| 2358 | * |
| 2359 | */ |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2360 | int iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2361 | { |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2362 | struct dentry *dir_data, *dir_rf, *dir_debug; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2363 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2364 | priv->debugfs_dir = dbgfs_dir; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2365 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2366 | dir_data = debugfs_create_dir("data", dbgfs_dir); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2367 | if (!dir_data) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2368 | goto err; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2369 | dir_rf = debugfs_create_dir("rf", dbgfs_dir); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2370 | if (!dir_rf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2371 | goto err; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2372 | dir_debug = debugfs_create_dir("debug", dbgfs_dir); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2373 | if (!dir_debug) |
| 2374 | goto err; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2375 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2376 | DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); |
| 2377 | DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 2378 | DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2379 | DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); |
| 2380 | DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); |
| 2381 | DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 2382 | DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2383 | DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); |
Wey-Yi Guy | 23c0fcc | 2011-04-01 16:29:53 -0700 | [diff] [blame] | 2384 | DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR); |
| 2385 | DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2386 | DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); |
| 2387 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 2388 | DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR); |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2389 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2390 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
| 2391 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2392 | DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2393 | DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 48dffd3 | 2012-04-09 17:46:57 -0700 | [diff] [blame] | 2394 | DEBUGFS_ADD_FILE(rf_reset, dir_debug, S_IWUSR | S_IRUSR); |
Abhijeet Kolekar | b8c7626 | 2010-04-08 15:29:07 -0700 | [diff] [blame] | 2395 | DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); |
| 2396 | DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); |
| 2397 | DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | c68744f | 2011-06-18 08:03:18 -0700 | [diff] [blame] | 2398 | DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2399 | DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 703bc58 | 2011-04-03 08:14:41 -0700 | [diff] [blame] | 2400 | DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); |
| 2401 | DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); |
Wey-Yi Guy | b7af6a9 | 2011-04-06 15:55:25 -0700 | [diff] [blame] | 2402 | DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 0da0e5b | 2011-04-08 08:14:56 -0700 | [diff] [blame] | 2403 | DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 2404 | DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2405 | DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); |
| 2406 | DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2407 | DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 2408 | DEBUGFS_ADD_FILE(fw_restart, dir_debug, S_IWUSR); |
Johannes Berg | 882b7b7 | 2012-06-20 08:46:25 +0200 | [diff] [blame] | 2409 | #ifdef CONFIG_IWLWIFI_DEBUG |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2410 | DEBUGFS_ADD_FILE(log_event, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 882b7b7 | 2012-06-20 08:46:25 +0200 | [diff] [blame] | 2411 | #endif |
Meenakshi Venkataraman | 2fdfc47 | 2012-03-15 13:26:56 -0700 | [diff] [blame] | 2412 | |
Stanislaw Gruszka | 88e58fc | 2011-01-28 16:47:47 +0100 | [diff] [blame] | 2413 | if (iwl_advanced_bt_coexist(priv)) |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2414 | DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2415 | |
Dor Shaish | bfb45f5 | 2012-03-26 08:20:55 -0700 | [diff] [blame] | 2416 | /* Calibrations disabled/enabled status*/ |
David Spinadel | 647ad13 | 2012-03-31 08:31:05 -0700 | [diff] [blame] | 2417 | DEBUGFS_ADD_FILE(calib_disabled, dir_rf, S_IWUSR | S_IRUSR); |
Emmanuel Grumbach | 87e5666 | 2011-08-25 23:10:50 -0700 | [diff] [blame] | 2418 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2419 | /* |
| 2420 | * Create a symlink with mac80211. This is not very robust, as it does |
| 2421 | * not remove the symlink created. The implicit assumption is that |
| 2422 | * when the opmode exits, mac80211 will also exit, and will remove |
| 2423 | * this symlink as part of its cleanup. |
| 2424 | */ |
| 2425 | if (priv->mac80211_registered) { |
| 2426 | char buf[100]; |
| 2427 | struct dentry *mac80211_dir, *dev_dir, *root_dir; |
| 2428 | |
| 2429 | dev_dir = dbgfs_dir->d_parent; |
| 2430 | root_dir = dev_dir->d_parent; |
| 2431 | mac80211_dir = priv->hw->wiphy->debugfsdir; |
| 2432 | |
| 2433 | snprintf(buf, 100, "../../%s/%s", root_dir->d_name.name, |
| 2434 | dev_dir->d_name.name); |
| 2435 | |
| 2436 | if (!debugfs_create_symlink("iwlwifi", mac80211_dir, buf)) |
| 2437 | goto err; |
| 2438 | } |
| 2439 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2440 | return 0; |
| 2441 | |
| 2442 | err: |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame] | 2443 | IWL_ERR(priv, "failed to create the dvm debugfs entries\n"); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2444 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2445 | } |