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