Commit | Line | Data |
---|---|---|
712b6cf5 TW |
1 | /****************************************************************************** |
2 | * | |
3 | * GPL LICENSE SUMMARY | |
4 | * | |
1f447808 | 5 | * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved. |
712b6cf5 TW |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of version 2 of the GNU General Public License as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | |
19 | * USA | |
20 | * | |
21 | * The full GNU General Public License is included in this distribution | |
22 | * in the file called LICENSE.GPL. | |
23 | * | |
24 | * Contact Information: | |
759ef89f | 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
712b6cf5 TW |
26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
27 | *****************************************************************************/ | |
28 | ||
5a0e3ad6 | 29 | #include <linux/slab.h> |
712b6cf5 TW |
30 | #include <linux/kernel.h> |
31 | #include <linux/module.h> | |
32 | #include <linux/debugfs.h> | |
33 | ||
34 | #include <linux/ieee80211.h> | |
35 | #include <net/mac80211.h> | |
36 | ||
37 | ||
3e0d4cb1 | 38 | #include "iwl-dev.h" |
712b6cf5 | 39 | #include "iwl-debug.h" |
fee1247a | 40 | #include "iwl-core.h" |
3395f6e9 | 41 | #include "iwl-io.h" |
712b6cf5 TW |
42 | |
43 | /* create and remove of files */ | |
4c84a8f1 JB |
44 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
45 | if (!debugfs_create_file(#name, mode, parent, priv, \ | |
46 | &iwl_dbgfs_##name##_ops)) \ | |
47 | goto err; \ | |
712b6cf5 TW |
48 | } while (0) |
49 | ||
4c84a8f1 JB |
50 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
51 | struct dentry *__tmp; \ | |
52 | __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ | |
53 | parent, ptr); \ | |
54 | if (IS_ERR(__tmp) || !__tmp) \ | |
55 | goto err; \ | |
712b6cf5 TW |
56 | } while (0) |
57 | ||
4c84a8f1 JB |
58 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
59 | struct dentry *__tmp; \ | |
60 | __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ | |
61 | parent, ptr); \ | |
62 | if (IS_ERR(__tmp) || !__tmp) \ | |
63 | goto err; \ | |
445c2dff TW |
64 | } while (0) |
65 | ||
712b6cf5 TW |
66 | /* file operation */ |
67 | #define DEBUGFS_READ_FUNC(name) \ | |
68 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ | |
69 | char __user *user_buf, \ | |
70 | size_t count, loff_t *ppos); | |
71 | ||
72 | #define DEBUGFS_WRITE_FUNC(name) \ | |
73 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ | |
74 | const char __user *user_buf, \ | |
75 | size_t count, loff_t *ppos); | |
76 | ||
77 | ||
78 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) | |
79 | { | |
80 | file->private_data = inode->i_private; | |
81 | return 0; | |
82 | } | |
83 | ||
84 | #define DEBUGFS_READ_FILE_OPS(name) \ | |
85 | DEBUGFS_READ_FUNC(name); \ | |
86 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |
87 | .read = iwl_dbgfs_##name##_read, \ | |
88 | .open = iwl_dbgfs_open_file_generic, \ | |
2b18ab36 | 89 | .llseek = generic_file_llseek, \ |
712b6cf5 TW |
90 | }; |
91 | ||
189a2b59 EK |
92 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
93 | DEBUGFS_WRITE_FUNC(name); \ | |
94 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |
95 | .write = iwl_dbgfs_##name##_write, \ | |
96 | .open = iwl_dbgfs_open_file_generic, \ | |
2b18ab36 | 97 | .llseek = generic_file_llseek, \ |
189a2b59 EK |
98 | }; |
99 | ||
100 | ||
712b6cf5 TW |
101 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
102 | DEBUGFS_READ_FUNC(name); \ | |
103 | DEBUGFS_WRITE_FUNC(name); \ | |
104 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |
105 | .write = iwl_dbgfs_##name##_write, \ | |
106 | .read = iwl_dbgfs_##name##_read, \ | |
107 | .open = iwl_dbgfs_open_file_generic, \ | |
2b18ab36 | 108 | .llseek = generic_file_llseek, \ |
712b6cf5 TW |
109 | }; |
110 | ||
712b6cf5 TW |
111 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
112 | char __user *user_buf, | |
113 | size_t count, loff_t *ppos) { | |
114 | ||
28f63a4b | 115 | struct iwl_priv *priv = file->private_data; |
22fdf3c9 | 116 | char *buf; |
712b6cf5 TW |
117 | int pos = 0; |
118 | ||
22fdf3c9 WYG |
119 | int cnt; |
120 | ssize_t ret; | |
98a7b43b WYG |
121 | const size_t bufsz = 100 + |
122 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); | |
22fdf3c9 WYG |
123 | buf = kzalloc(bufsz, GFP_KERNEL); |
124 | if (!buf) | |
125 | return -ENOMEM; | |
126 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); | |
127 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { | |
128 | pos += scnprintf(buf + pos, bufsz - pos, | |
98a7b43b | 129 | "\t%25s\t\t: %u\n", |
22fdf3c9 WYG |
130 | get_mgmt_string(cnt), |
131 | priv->tx_stats.mgmt[cnt]); | |
132 | } | |
133 | pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); | |
134 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { | |
135 | pos += scnprintf(buf + pos, bufsz - pos, | |
98a7b43b | 136 | "\t%25s\t\t: %u\n", |
22fdf3c9 WYG |
137 | get_ctrl_string(cnt), |
138 | priv->tx_stats.ctrl[cnt]); | |
139 | } | |
140 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); | |
141 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", | |
142 | priv->tx_stats.data_cnt); | |
143 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", | |
144 | priv->tx_stats.data_bytes); | |
145 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
146 | kfree(buf); | |
147 | return ret; | |
148 | } | |
149 | ||
7163b8a4 | 150 | static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file, |
22fdf3c9 WYG |
151 | const char __user *user_buf, |
152 | size_t count, loff_t *ppos) | |
153 | { | |
154 | struct iwl_priv *priv = file->private_data; | |
155 | u32 clear_flag; | |
156 | char buf[8]; | |
157 | int buf_size; | |
712b6cf5 | 158 | |
22fdf3c9 WYG |
159 | memset(buf, 0, sizeof(buf)); |
160 | buf_size = min(count, sizeof(buf) - 1); | |
161 | if (copy_from_user(buf, user_buf, buf_size)) | |
162 | return -EFAULT; | |
163 | if (sscanf(buf, "%x", &clear_flag) != 1) | |
164 | return -EFAULT; | |
7163b8a4 | 165 | iwl_clear_traffic_stats(priv); |
22fdf3c9 WYG |
166 | |
167 | return count; | |
712b6cf5 TW |
168 | } |
169 | ||
170 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, | |
171 | char __user *user_buf, | |
172 | size_t count, loff_t *ppos) { | |
173 | ||
28f63a4b | 174 | struct iwl_priv *priv = file->private_data; |
22fdf3c9 | 175 | char *buf; |
712b6cf5 | 176 | int pos = 0; |
22fdf3c9 WYG |
177 | int cnt; |
178 | ssize_t ret; | |
179 | const size_t bufsz = 100 + | |
98a7b43b | 180 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
22fdf3c9 WYG |
181 | buf = kzalloc(bufsz, GFP_KERNEL); |
182 | if (!buf) | |
183 | return -ENOMEM; | |
712b6cf5 | 184 | |
22fdf3c9 WYG |
185 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
186 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { | |
187 | pos += scnprintf(buf + pos, bufsz - pos, | |
98a7b43b | 188 | "\t%25s\t\t: %u\n", |
22fdf3c9 WYG |
189 | get_mgmt_string(cnt), |
190 | priv->rx_stats.mgmt[cnt]); | |
191 | } | |
192 | pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); | |
193 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { | |
194 | pos += scnprintf(buf + pos, bufsz - pos, | |
98a7b43b | 195 | "\t%25s\t\t: %u\n", |
22fdf3c9 WYG |
196 | get_ctrl_string(cnt), |
197 | priv->rx_stats.ctrl[cnt]); | |
198 | } | |
199 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); | |
200 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", | |
201 | priv->rx_stats.data_cnt); | |
202 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", | |
203 | priv->rx_stats.data_bytes); | |
712b6cf5 | 204 | |
22fdf3c9 WYG |
205 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
206 | kfree(buf); | |
207 | return ret; | |
208 | } | |
209 | ||
712b6cf5 TW |
210 | #define BYTE1_MASK 0x000000ff; |
211 | #define BYTE2_MASK 0x0000ffff; | |
212 | #define BYTE3_MASK 0x00ffffff; | |
213 | static ssize_t iwl_dbgfs_sram_read(struct file *file, | |
214 | char __user *user_buf, | |
215 | size_t count, loff_t *ppos) | |
216 | { | |
217 | u32 val; | |
2943f136 | 218 | char *buf; |
712b6cf5 TW |
219 | ssize_t ret; |
220 | int i; | |
221 | int pos = 0; | |
28f63a4b | 222 | struct iwl_priv *priv = file->private_data; |
2943f136 | 223 | size_t bufsz; |
712b6cf5 | 224 | |
5ade1e4d | 225 | /* default is to dump the entire data segment */ |
4c84a8f1 JB |
226 | if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { |
227 | priv->dbgfs_sram_offset = 0x800000; | |
5ade1e4d | 228 | if (priv->ucode_type == UCODE_INIT) |
4c84a8f1 | 229 | priv->dbgfs_sram_len = priv->ucode_init_data.len; |
5ade1e4d | 230 | else |
4c84a8f1 | 231 | priv->dbgfs_sram_len = priv->ucode_data.len; |
5ade1e4d | 232 | } |
4c84a8f1 | 233 | bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10; |
2943f136 WYG |
234 | buf = kmalloc(bufsz, GFP_KERNEL); |
235 | if (!buf) | |
236 | return -ENOMEM; | |
5ade1e4d | 237 | pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", |
4c84a8f1 | 238 | priv->dbgfs_sram_len); |
5ade1e4d | 239 | pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", |
4c84a8f1 JB |
240 | priv->dbgfs_sram_offset); |
241 | for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { | |
242 | val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \ | |
243 | priv->dbgfs_sram_len - i); | |
712b6cf5 TW |
244 | if (i < 4) { |
245 | switch (i) { | |
246 | case 1: | |
247 | val &= BYTE1_MASK; | |
248 | break; | |
249 | case 2: | |
250 | val &= BYTE2_MASK; | |
251 | break; | |
252 | case 3: | |
253 | val &= BYTE3_MASK; | |
254 | break; | |
255 | } | |
256 | } | |
2943f136 WYG |
257 | if (!(i % 16)) |
258 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | |
db0589f3 | 259 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
712b6cf5 | 260 | } |
db0589f3 | 261 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
712b6cf5 TW |
262 | |
263 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
2943f136 | 264 | kfree(buf); |
712b6cf5 TW |
265 | return ret; |
266 | } | |
267 | ||
268 | static ssize_t iwl_dbgfs_sram_write(struct file *file, | |
269 | const char __user *user_buf, | |
270 | size_t count, loff_t *ppos) | |
271 | { | |
272 | struct iwl_priv *priv = file->private_data; | |
273 | char buf[64]; | |
274 | int buf_size; | |
275 | u32 offset, len; | |
276 | ||
277 | memset(buf, 0, sizeof(buf)); | |
278 | buf_size = min(count, sizeof(buf) - 1); | |
279 | if (copy_from_user(buf, user_buf, buf_size)) | |
280 | return -EFAULT; | |
281 | ||
282 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { | |
4c84a8f1 JB |
283 | priv->dbgfs_sram_offset = offset; |
284 | priv->dbgfs_sram_len = len; | |
712b6cf5 | 285 | } else { |
4c84a8f1 JB |
286 | priv->dbgfs_sram_offset = 0; |
287 | priv->dbgfs_sram_len = 0; | |
712b6cf5 TW |
288 | } |
289 | ||
290 | return count; | |
291 | } | |
292 | ||
293 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, | |
294 | size_t count, loff_t *ppos) | |
295 | { | |
28f63a4b | 296 | struct iwl_priv *priv = file->private_data; |
6def9761 | 297 | struct iwl_station_entry *station; |
5425e490 | 298 | int max_sta = priv->hw_params.max_stations; |
712b6cf5 TW |
299 | char *buf; |
300 | int i, j, pos = 0; | |
301 | ssize_t ret; | |
302 | /* Add 30 for initial string */ | |
303 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); | |
712b6cf5 TW |
304 | |
305 | buf = kmalloc(bufsz, GFP_KERNEL); | |
3ac7f146 | 306 | if (!buf) |
712b6cf5 TW |
307 | return -ENOMEM; |
308 | ||
db0589f3 | 309 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
712b6cf5 TW |
310 | priv->num_stations); |
311 | ||
312 | for (i = 0; i < max_sta; i++) { | |
313 | station = &priv->stations[i]; | |
da73511d JB |
314 | if (!station->used) |
315 | continue; | |
316 | pos += scnprintf(buf + pos, bufsz - pos, | |
317 | "station %d - addr: %pM, flags: %#x\n", | |
318 | i, station->sta.sta.addr, | |
319 | station->sta.station_flags_msk); | |
320 | pos += scnprintf(buf + pos, bufsz - pos, | |
321 | "TID\tseq_num\ttxq_id\tframes\ttfds\t"); | |
322 | pos += scnprintf(buf + pos, bufsz - pos, | |
323 | "start_idx\tbitmap\t\t\trate_n_flags\n"); | |
712b6cf5 | 324 | |
da73511d JB |
325 | for (j = 0; j < MAX_TID_COUNT; j++) { |
326 | pos += scnprintf(buf + pos, bufsz - pos, | |
327 | "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", | |
328 | j, station->tid[j].seq_number, | |
329 | station->tid[j].agg.txq_id, | |
330 | station->tid[j].agg.frame_count, | |
331 | station->tid[j].tfds_in_queue, | |
332 | station->tid[j].agg.start_idx, | |
333 | station->tid[j].agg.bitmap, | |
334 | station->tid[j].agg.rate_n_flags); | |
335 | ||
336 | if (station->tid[j].agg.wait_for_ba) | |
db0589f3 | 337 | pos += scnprintf(buf + pos, bufsz - pos, |
da73511d | 338 | " - waitforba"); |
db0589f3 | 339 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
712b6cf5 | 340 | } |
da73511d JB |
341 | |
342 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | |
712b6cf5 TW |
343 | } |
344 | ||
345 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
346 | kfree(buf); | |
347 | return ret; | |
348 | } | |
349 | ||
0848e297 | 350 | static ssize_t iwl_dbgfs_nvm_read(struct file *file, |
8dd266ef TW |
351 | char __user *user_buf, |
352 | size_t count, | |
353 | loff_t *ppos) | |
354 | { | |
355 | ssize_t ret; | |
28f63a4b | 356 | struct iwl_priv *priv = file->private_data; |
8dd266ef TW |
357 | int pos = 0, ofs = 0, buf_size = 0; |
358 | const u8 *ptr; | |
359 | char *buf; | |
e307ddce | 360 | u16 eeprom_ver; |
7cb1b088 | 361 | size_t eeprom_len = priv->cfg->base_params->eeprom_size; |
8dd266ef TW |
362 | buf_size = 4 * eeprom_len + 256; |
363 | ||
364 | if (eeprom_len % 16) { | |
0848e297 | 365 | IWL_ERR(priv, "NVM size is not multiple of 16.\n"); |
8dd266ef TW |
366 | return -ENODATA; |
367 | } | |
368 | ||
c37457e6 JL |
369 | ptr = priv->eeprom; |
370 | if (!ptr) { | |
371 | IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); | |
372 | return -ENOMEM; | |
373 | } | |
374 | ||
8dd266ef TW |
375 | /* 4 characters for byte 0xYY */ |
376 | buf = kzalloc(buf_size, GFP_KERNEL); | |
377 | if (!buf) { | |
15b1687c | 378 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
8dd266ef TW |
379 | return -ENOMEM; |
380 | } | |
e307ddce WYG |
381 | eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); |
382 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " | |
383 | "version: 0x%x\n", | |
0848e297 | 384 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
e307ddce | 385 | ? "OTP" : "EEPROM", eeprom_ver); |
8dd266ef TW |
386 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
387 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); | |
388 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, | |
389 | buf_size - pos, 0); | |
2fac9717 | 390 | pos += strlen(buf + pos); |
8dd266ef TW |
391 | if (buf_size - pos > 0) |
392 | buf[pos++] = '\n'; | |
393 | } | |
394 | ||
395 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
396 | kfree(buf); | |
397 | return ret; | |
398 | } | |
712b6cf5 | 399 | |
b03d7d0f WYG |
400 | static ssize_t iwl_dbgfs_log_event_read(struct file *file, |
401 | char __user *user_buf, | |
402 | size_t count, loff_t *ppos) | |
403 | { | |
404 | struct iwl_priv *priv = file->private_data; | |
405 | char *buf; | |
406 | int pos = 0; | |
407 | ssize_t ret = -ENOMEM; | |
408 | ||
937c397e WYG |
409 | ret = pos = priv->cfg->ops->lib->dump_nic_event_log( |
410 | priv, true, &buf, true); | |
411 | if (buf) { | |
b03d7d0f WYG |
412 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
413 | kfree(buf); | |
414 | } | |
415 | return ret; | |
416 | } | |
417 | ||
189a2b59 EK |
418 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
419 | const char __user *user_buf, | |
420 | size_t count, loff_t *ppos) | |
421 | { | |
422 | struct iwl_priv *priv = file->private_data; | |
423 | u32 event_log_flag; | |
424 | char buf[8]; | |
425 | int buf_size; | |
426 | ||
427 | memset(buf, 0, sizeof(buf)); | |
428 | buf_size = min(count, sizeof(buf) - 1); | |
429 | if (copy_from_user(buf, user_buf, buf_size)) | |
430 | return -EFAULT; | |
431 | if (sscanf(buf, "%d", &event_log_flag) != 1) | |
432 | return -EFAULT; | |
433 | if (event_log_flag == 1) | |
b03d7d0f WYG |
434 | priv->cfg->ops->lib->dump_nic_event_log(priv, true, |
435 | NULL, false); | |
189a2b59 EK |
436 | |
437 | return count; | |
438 | } | |
439 | ||
d366df5a WT |
440 | |
441 | ||
442 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, | |
443 | size_t count, loff_t *ppos) | |
444 | { | |
28f63a4b | 445 | struct iwl_priv *priv = file->private_data; |
d366df5a WT |
446 | struct ieee80211_channel *channels = NULL; |
447 | const struct ieee80211_supported_band *supp_band = NULL; | |
448 | int pos = 0, i, bufsz = PAGE_SIZE; | |
449 | char *buf; | |
450 | ssize_t ret; | |
451 | ||
452 | if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) | |
453 | return -EAGAIN; | |
454 | ||
455 | buf = kzalloc(bufsz, GFP_KERNEL); | |
456 | if (!buf) { | |
15b1687c | 457 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
d366df5a WT |
458 | return -ENOMEM; |
459 | } | |
460 | ||
461 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); | |
a2e2322d WYG |
462 | if (supp_band) { |
463 | channels = supp_band->channels; | |
d366df5a | 464 | |
d366df5a | 465 | pos += scnprintf(buf + pos, bufsz - pos, |
a2e2322d WYG |
466 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
467 | supp_band->n_channels); | |
d366df5a | 468 | |
a2e2322d WYG |
469 | for (i = 0; i < supp_band->n_channels; i++) |
470 | pos += scnprintf(buf + pos, bufsz - pos, | |
471 | "%d: %ddBm: BSS%s%s, %s.\n", | |
81e95430 | 472 | channels[i].hw_value, |
a2e2322d WYG |
473 | channels[i].max_power, |
474 | channels[i].flags & IEEE80211_CHAN_RADAR ? | |
475 | " (IEEE 802.11h required)" : "", | |
476 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) | |
477 | || (channels[i].flags & | |
478 | IEEE80211_CHAN_RADAR)) ? "" : | |
479 | ", IBSS", | |
480 | channels[i].flags & | |
481 | IEEE80211_CHAN_PASSIVE_SCAN ? | |
482 | "passive only" : "active/passive"); | |
483 | } | |
d366df5a | 484 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
a2e2322d WYG |
485 | if (supp_band) { |
486 | channels = supp_band->channels; | |
d366df5a | 487 | |
d366df5a | 488 | pos += scnprintf(buf + pos, bufsz - pos, |
a2e2322d WYG |
489 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
490 | supp_band->n_channels); | |
491 | ||
492 | for (i = 0; i < supp_band->n_channels; i++) | |
493 | pos += scnprintf(buf + pos, bufsz - pos, | |
494 | "%d: %ddBm: BSS%s%s, %s.\n", | |
81e95430 | 495 | channels[i].hw_value, |
a2e2322d WYG |
496 | channels[i].max_power, |
497 | channels[i].flags & IEEE80211_CHAN_RADAR ? | |
498 | " (IEEE 802.11h required)" : "", | |
499 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) | |
500 | || (channels[i].flags & | |
501 | IEEE80211_CHAN_RADAR)) ? "" : | |
502 | ", IBSS", | |
503 | channels[i].flags & | |
504 | IEEE80211_CHAN_PASSIVE_SCAN ? | |
505 | "passive only" : "active/passive"); | |
506 | } | |
d366df5a WT |
507 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
508 | kfree(buf); | |
509 | return ret; | |
510 | } | |
511 | ||
08df05aa WYG |
512 | static ssize_t iwl_dbgfs_status_read(struct file *file, |
513 | char __user *user_buf, | |
514 | size_t count, loff_t *ppos) { | |
515 | ||
28f63a4b | 516 | struct iwl_priv *priv = file->private_data; |
08df05aa WYG |
517 | char buf[512]; |
518 | int pos = 0; | |
519 | const size_t bufsz = sizeof(buf); | |
520 | ||
521 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", | |
522 | test_bit(STATUS_HCMD_ACTIVE, &priv->status)); | |
08df05aa WYG |
523 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", |
524 | test_bit(STATUS_INT_ENABLED, &priv->status)); | |
525 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", | |
526 | test_bit(STATUS_RF_KILL_HW, &priv->status)); | |
7812b167 WYG |
527 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", |
528 | test_bit(STATUS_CT_KILL, &priv->status)); | |
08df05aa WYG |
529 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", |
530 | test_bit(STATUS_INIT, &priv->status)); | |
531 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", | |
532 | test_bit(STATUS_ALIVE, &priv->status)); | |
533 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", | |
534 | test_bit(STATUS_READY, &priv->status)); | |
535 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", | |
536 | test_bit(STATUS_TEMPERATURE, &priv->status)); | |
537 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", | |
538 | test_bit(STATUS_GEO_CONFIGURED, &priv->status)); | |
539 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", | |
540 | test_bit(STATUS_EXIT_PENDING, &priv->status)); | |
08df05aa WYG |
541 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
542 | test_bit(STATUS_STATISTICS, &priv->status)); | |
543 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", | |
544 | test_bit(STATUS_SCANNING, &priv->status)); | |
545 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", | |
546 | test_bit(STATUS_SCAN_ABORTING, &priv->status)); | |
547 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", | |
548 | test_bit(STATUS_SCAN_HW, &priv->status)); | |
549 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", | |
550 | test_bit(STATUS_POWER_PMI, &priv->status)); | |
551 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", | |
552 | test_bit(STATUS_FW_ERROR, &priv->status)); | |
08df05aa WYG |
553 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
554 | } | |
555 | ||
a83b9141 WYG |
556 | static ssize_t iwl_dbgfs_interrupt_read(struct file *file, |
557 | char __user *user_buf, | |
558 | size_t count, loff_t *ppos) { | |
559 | ||
28f63a4b | 560 | struct iwl_priv *priv = file->private_data; |
a83b9141 WYG |
561 | int pos = 0; |
562 | int cnt = 0; | |
563 | char *buf; | |
564 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ | |
565 | ssize_t ret; | |
566 | ||
567 | buf = kzalloc(bufsz, GFP_KERNEL); | |
568 | if (!buf) { | |
569 | IWL_ERR(priv, "Can not allocate Buffer\n"); | |
570 | return -ENOMEM; | |
571 | } | |
572 | ||
573 | pos += scnprintf(buf + pos, bufsz - pos, | |
574 | "Interrupt Statistics Report:\n"); | |
575 | ||
576 | pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", | |
577 | priv->isr_stats.hw); | |
578 | pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", | |
579 | priv->isr_stats.sw); | |
6e6ebf4b | 580 | if (priv->isr_stats.sw || priv->isr_stats.hw) { |
a83b9141 WYG |
581 | pos += scnprintf(buf + pos, bufsz - pos, |
582 | "\tLast Restarting Code: 0x%X\n", | |
6e6ebf4b | 583 | priv->isr_stats.err_code); |
a83b9141 WYG |
584 | } |
585 | #ifdef CONFIG_IWLWIFI_DEBUG | |
586 | pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", | |
587 | priv->isr_stats.sch); | |
588 | pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", | |
589 | priv->isr_stats.alive); | |
590 | #endif | |
591 | pos += scnprintf(buf + pos, bufsz - pos, | |
592 | "HW RF KILL switch toggled:\t %u\n", | |
593 | priv->isr_stats.rfkill); | |
594 | ||
595 | pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", | |
596 | priv->isr_stats.ctkill); | |
597 | ||
598 | pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", | |
599 | priv->isr_stats.wakeup); | |
600 | ||
601 | pos += scnprintf(buf + pos, bufsz - pos, | |
602 | "Rx command responses:\t\t %u\n", | |
603 | priv->isr_stats.rx); | |
604 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { | |
605 | if (priv->isr_stats.rx_handlers[cnt] > 0) | |
606 | pos += scnprintf(buf + pos, bufsz - pos, | |
607 | "\tRx handler[%36s]:\t\t %u\n", | |
608 | get_cmd_string(cnt), | |
609 | priv->isr_stats.rx_handlers[cnt]); | |
610 | } | |
611 | ||
612 | pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", | |
613 | priv->isr_stats.tx); | |
614 | ||
615 | pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", | |
616 | priv->isr_stats.unhandled); | |
617 | ||
618 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
619 | kfree(buf); | |
620 | return ret; | |
621 | } | |
622 | ||
623 | static ssize_t iwl_dbgfs_interrupt_write(struct file *file, | |
624 | const char __user *user_buf, | |
625 | size_t count, loff_t *ppos) | |
626 | { | |
627 | struct iwl_priv *priv = file->private_data; | |
628 | char buf[8]; | |
629 | int buf_size; | |
630 | u32 reset_flag; | |
631 | ||
632 | memset(buf, 0, sizeof(buf)); | |
633 | buf_size = min(count, sizeof(buf) - 1); | |
634 | if (copy_from_user(buf, user_buf, buf_size)) | |
635 | return -EFAULT; | |
636 | if (sscanf(buf, "%x", &reset_flag) != 1) | |
637 | return -EFAULT; | |
638 | if (reset_flag == 0) | |
639 | iwl_clear_isr_stats(priv); | |
640 | ||
641 | return count; | |
642 | } | |
643 | ||
f5ad69fa WYG |
644 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
645 | size_t count, loff_t *ppos) | |
646 | { | |
28f63a4b | 647 | struct iwl_priv *priv = file->private_data; |
8dfdb9d5 | 648 | struct iwl_rxon_context *ctx; |
f5ad69fa | 649 | int pos = 0, i; |
8dfdb9d5 | 650 | char buf[256 * NUM_IWL_RXON_CTX]; |
f5ad69fa | 651 | const size_t bufsz = sizeof(buf); |
f5ad69fa | 652 | |
8dfdb9d5 JB |
653 | for_each_context(priv, ctx) { |
654 | pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", | |
655 | ctx->ctxid); | |
656 | for (i = 0; i < AC_NUM; i++) { | |
657 | pos += scnprintf(buf + pos, bufsz - pos, | |
658 | "\tcw_min\tcw_max\taifsn\ttxop\n"); | |
659 | pos += scnprintf(buf + pos, bufsz - pos, | |
f5ad69fa | 660 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
8dfdb9d5 JB |
661 | ctx->qos_data.def_qos_parm.ac[i].cw_min, |
662 | ctx->qos_data.def_qos_parm.ac[i].cw_max, | |
663 | ctx->qos_data.def_qos_parm.ac[i].aifsn, | |
664 | ctx->qos_data.def_qos_parm.ac[i].edca_txop); | |
665 | } | |
666 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | |
f5ad69fa | 667 | } |
4967c316 | 668 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
f5ad69fa | 669 | } |
a83b9141 | 670 | |
a283c011 WYG |
671 | static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf, |
672 | size_t count, loff_t *ppos) | |
673 | { | |
28f63a4b | 674 | struct iwl_priv *priv = file->private_data; |
a283c011 WYG |
675 | int pos = 0; |
676 | char buf[256]; | |
677 | const size_t bufsz = sizeof(buf); | |
a283c011 WYG |
678 | |
679 | pos += scnprintf(buf + pos, bufsz - pos, | |
680 | "allow blinking: %s\n", | |
681 | (priv->allow_blinking) ? "True" : "False"); | |
682 | if (priv->allow_blinking) { | |
683 | pos += scnprintf(buf + pos, bufsz - pos, | |
684 | "Led blinking rate: %u\n", | |
685 | priv->last_blink_rate); | |
686 | pos += scnprintf(buf + pos, bufsz - pos, | |
687 | "Last blink time: %lu\n", | |
688 | priv->last_blink_time); | |
689 | } | |
690 | ||
4967c316 | 691 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
a283c011 | 692 | } |
a283c011 | 693 | |
fbf3a2af WYG |
694 | static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, |
695 | char __user *user_buf, | |
696 | size_t count, loff_t *ppos) | |
697 | { | |
28f63a4b | 698 | struct iwl_priv *priv = file->private_data; |
3ad3b92a | 699 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
fbf3a2af WYG |
700 | struct iwl_tt_restriction *restriction; |
701 | char buf[100]; | |
702 | int pos = 0; | |
703 | const size_t bufsz = sizeof(buf); | |
fbf3a2af WYG |
704 | |
705 | pos += scnprintf(buf + pos, bufsz - pos, | |
706 | "Thermal Throttling Mode: %s\n", | |
3ad3b92a | 707 | tt->advanced_tt ? "Advance" : "Legacy"); |
fbf3a2af WYG |
708 | pos += scnprintf(buf + pos, bufsz - pos, |
709 | "Thermal Throttling State: %d\n", | |
710 | tt->state); | |
3ad3b92a | 711 | if (tt->advanced_tt) { |
fbf3a2af WYG |
712 | restriction = tt->restriction + tt->state; |
713 | pos += scnprintf(buf + pos, bufsz - pos, | |
714 | "Tx mode: %d\n", | |
715 | restriction->tx_stream); | |
716 | pos += scnprintf(buf + pos, bufsz - pos, | |
717 | "Rx mode: %d\n", | |
718 | restriction->rx_stream); | |
719 | pos += scnprintf(buf + pos, bufsz - pos, | |
720 | "HT mode: %d\n", | |
721 | restriction->is_ht); | |
722 | } | |
4967c316 | 723 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
fbf3a2af WYG |
724 | } |
725 | ||
1e4247d4 WYG |
726 | static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, |
727 | const char __user *user_buf, | |
728 | size_t count, loff_t *ppos) | |
729 | { | |
730 | struct iwl_priv *priv = file->private_data; | |
731 | char buf[8]; | |
732 | int buf_size; | |
733 | int ht40; | |
734 | ||
735 | memset(buf, 0, sizeof(buf)); | |
736 | buf_size = min(count, sizeof(buf) - 1); | |
737 | if (copy_from_user(buf, user_buf, buf_size)) | |
738 | return -EFAULT; | |
739 | if (sscanf(buf, "%d", &ht40) != 1) | |
740 | return -EFAULT; | |
246ed355 | 741 | if (!iwl_is_any_associated(priv)) |
1e4247d4 WYG |
742 | priv->disable_ht40 = ht40 ? true : false; |
743 | else { | |
744 | IWL_ERR(priv, "Sta associated with AP - " | |
745 | "Change to 40MHz channel support is not allowed\n"); | |
746 | return -EINVAL; | |
747 | } | |
748 | ||
749 | return count; | |
750 | } | |
751 | ||
752 | static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file, | |
753 | char __user *user_buf, | |
754 | size_t count, loff_t *ppos) | |
755 | { | |
28f63a4b | 756 | struct iwl_priv *priv = file->private_data; |
1e4247d4 WYG |
757 | char buf[100]; |
758 | int pos = 0; | |
759 | const size_t bufsz = sizeof(buf); | |
1e4247d4 WYG |
760 | |
761 | pos += scnprintf(buf + pos, bufsz - pos, | |
762 | "11n 40MHz Mode: %s\n", | |
763 | priv->disable_ht40 ? "Disabled" : "Enabled"); | |
4967c316 | 764 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
1e4247d4 WYG |
765 | } |
766 | ||
e312c24c JB |
767 | static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, |
768 | const char __user *user_buf, | |
769 | size_t count, loff_t *ppos) | |
770 | { | |
771 | struct iwl_priv *priv = file->private_data; | |
772 | char buf[8]; | |
773 | int buf_size; | |
774 | int value; | |
775 | ||
776 | memset(buf, 0, sizeof(buf)); | |
777 | buf_size = min(count, sizeof(buf) - 1); | |
778 | if (copy_from_user(buf, user_buf, buf_size)) | |
779 | return -EFAULT; | |
780 | ||
781 | if (sscanf(buf, "%d", &value) != 1) | |
782 | return -EINVAL; | |
783 | ||
784 | /* | |
785 | * Our users expect 0 to be "CAM", but 0 isn't actually | |
786 | * valid here. However, let's not confuse them and present | |
787 | * IWL_POWER_INDEX_1 as "1", not "0". | |
788 | */ | |
1a34c043 RC |
789 | if (value == 0) |
790 | return -EINVAL; | |
791 | else if (value > 0) | |
e312c24c JB |
792 | value -= 1; |
793 | ||
794 | if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) | |
795 | return -EINVAL; | |
796 | ||
4ad177b5 WYG |
797 | if (!iwl_is_ready_rf(priv)) |
798 | return -EAGAIN; | |
799 | ||
e312c24c JB |
800 | priv->power_data.debug_sleep_level_override = value; |
801 | ||
d3a57197 | 802 | mutex_lock(&priv->mutex); |
4ad177b5 | 803 | iwl_power_update_mode(priv, true); |
d3a57197 | 804 | mutex_unlock(&priv->mutex); |
e312c24c JB |
805 | |
806 | return count; | |
807 | } | |
808 | ||
809 | static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file, | |
810 | char __user *user_buf, | |
811 | size_t count, loff_t *ppos) | |
812 | { | |
28f63a4b | 813 | struct iwl_priv *priv = file->private_data; |
e312c24c JB |
814 | char buf[10]; |
815 | int pos, value; | |
816 | const size_t bufsz = sizeof(buf); | |
817 | ||
818 | /* see the write function */ | |
819 | value = priv->power_data.debug_sleep_level_override; | |
820 | if (value >= 0) | |
821 | value += 1; | |
822 | ||
823 | pos = scnprintf(buf, bufsz, "%d\n", value); | |
824 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
825 | } | |
826 | ||
827 | static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file, | |
828 | char __user *user_buf, | |
829 | size_t count, loff_t *ppos) | |
830 | { | |
28f63a4b | 831 | struct iwl_priv *priv = file->private_data; |
e312c24c JB |
832 | char buf[200]; |
833 | int pos = 0, i; | |
834 | const size_t bufsz = sizeof(buf); | |
835 | struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd; | |
836 | ||
837 | pos += scnprintf(buf + pos, bufsz - pos, | |
838 | "flags: %#.2x\n", le16_to_cpu(cmd->flags)); | |
839 | pos += scnprintf(buf + pos, bufsz - pos, | |
840 | "RX/TX timeout: %d/%d usec\n", | |
841 | le32_to_cpu(cmd->rx_data_timeout), | |
842 | le32_to_cpu(cmd->tx_data_timeout)); | |
843 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) | |
844 | pos += scnprintf(buf + pos, bufsz - pos, | |
845 | "sleep_interval[%d]: %d\n", i, | |
846 | le32_to_cpu(cmd->sleep_interval[i])); | |
847 | ||
848 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
849 | } | |
850 | ||
712b6cf5 | 851 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
b03d7d0f | 852 | DEBUGFS_READ_WRITE_FILE_OPS(log_event); |
0848e297 | 853 | DEBUGFS_READ_FILE_OPS(nvm); |
712b6cf5 | 854 | DEBUGFS_READ_FILE_OPS(stations); |
d366df5a | 855 | DEBUGFS_READ_FILE_OPS(channels); |
08df05aa | 856 | DEBUGFS_READ_FILE_OPS(status); |
a83b9141 | 857 | DEBUGFS_READ_WRITE_FILE_OPS(interrupt); |
f5ad69fa | 858 | DEBUGFS_READ_FILE_OPS(qos); |
a283c011 | 859 | DEBUGFS_READ_FILE_OPS(led); |
fbf3a2af | 860 | DEBUGFS_READ_FILE_OPS(thermal_throttling); |
1e4247d4 | 861 | DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); |
e312c24c JB |
862 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); |
863 | DEBUGFS_READ_FILE_OPS(current_sleep_command); | |
712b6cf5 | 864 | |
20594eb0 WYG |
865 | static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, |
866 | char __user *user_buf, | |
867 | size_t count, loff_t *ppos) | |
868 | { | |
869 | struct iwl_priv *priv = file->private_data; | |
870 | int pos = 0, ofs = 0; | |
871 | int cnt = 0, entry; | |
872 | struct iwl_tx_queue *txq; | |
873 | struct iwl_queue *q; | |
874 | struct iwl_rx_queue *rxq = &priv->rxq; | |
875 | char *buf; | |
876 | int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + | |
7cb1b088 | 877 | (priv->cfg->base_params->num_of_queues * 32 * 8) + 400; |
20594eb0 WYG |
878 | const u8 *ptr; |
879 | ssize_t ret; | |
880 | ||
88804e2b WYG |
881 | if (!priv->txq) { |
882 | IWL_ERR(priv, "txq not ready\n"); | |
883 | return -EAGAIN; | |
884 | } | |
20594eb0 WYG |
885 | buf = kzalloc(bufsz, GFP_KERNEL); |
886 | if (!buf) { | |
887 | IWL_ERR(priv, "Can not allocate buffer\n"); | |
888 | return -ENOMEM; | |
889 | } | |
890 | pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); | |
891 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { | |
892 | txq = &priv->txq[cnt]; | |
893 | q = &txq->q; | |
894 | pos += scnprintf(buf + pos, bufsz - pos, | |
895 | "q[%d]: read_ptr: %u, write_ptr: %u\n", | |
896 | cnt, q->read_ptr, q->write_ptr); | |
897 | } | |
898 | if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) { | |
899 | ptr = priv->tx_traffic; | |
900 | pos += scnprintf(buf + pos, bufsz - pos, | |
901 | "Tx Traffic idx: %u\n", priv->tx_traffic_idx); | |
902 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { | |
903 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; | |
904 | entry++, ofs += 16) { | |
905 | pos += scnprintf(buf + pos, bufsz - pos, | |
906 | "0x%.4x ", ofs); | |
907 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, | |
908 | buf + pos, bufsz - pos, 0); | |
2fac9717 | 909 | pos += strlen(buf + pos); |
20594eb0 WYG |
910 | if (bufsz - pos > 0) |
911 | buf[pos++] = '\n'; | |
912 | } | |
913 | } | |
914 | } | |
915 | ||
916 | pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); | |
917 | pos += scnprintf(buf + pos, bufsz - pos, | |
918 | "read: %u, write: %u\n", | |
919 | rxq->read, rxq->write); | |
920 | ||
921 | if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) { | |
922 | ptr = priv->rx_traffic; | |
923 | pos += scnprintf(buf + pos, bufsz - pos, | |
924 | "Rx Traffic idx: %u\n", priv->rx_traffic_idx); | |
925 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { | |
926 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; | |
927 | entry++, ofs += 16) { | |
928 | pos += scnprintf(buf + pos, bufsz - pos, | |
929 | "0x%.4x ", ofs); | |
930 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, | |
931 | buf + pos, bufsz - pos, 0); | |
2fac9717 | 932 | pos += strlen(buf + pos); |
20594eb0 WYG |
933 | if (bufsz - pos > 0) |
934 | buf[pos++] = '\n'; | |
935 | } | |
936 | } | |
937 | } | |
938 | ||
939 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
940 | kfree(buf); | |
941 | return ret; | |
942 | } | |
943 | ||
944 | static ssize_t iwl_dbgfs_traffic_log_write(struct file *file, | |
945 | const char __user *user_buf, | |
946 | size_t count, loff_t *ppos) | |
947 | { | |
948 | struct iwl_priv *priv = file->private_data; | |
949 | char buf[8]; | |
950 | int buf_size; | |
951 | int traffic_log; | |
952 | ||
953 | memset(buf, 0, sizeof(buf)); | |
954 | buf_size = min(count, sizeof(buf) - 1); | |
955 | if (copy_from_user(buf, user_buf, buf_size)) | |
956 | return -EFAULT; | |
957 | if (sscanf(buf, "%d", &traffic_log) != 1) | |
958 | return -EFAULT; | |
959 | if (traffic_log == 0) | |
960 | iwl_reset_traffic_log(priv); | |
961 | ||
962 | return count; | |
963 | } | |
964 | ||
141b03e0 WYG |
965 | static ssize_t iwl_dbgfs_tx_queue_read(struct file *file, |
966 | char __user *user_buf, | |
967 | size_t count, loff_t *ppos) { | |
968 | ||
28f63a4b | 969 | struct iwl_priv *priv = file->private_data; |
141b03e0 WYG |
970 | struct iwl_tx_queue *txq; |
971 | struct iwl_queue *q; | |
972 | char *buf; | |
973 | int pos = 0; | |
974 | int cnt; | |
975 | int ret; | |
7cb1b088 WYG |
976 | const size_t bufsz = sizeof(char) * 64 * |
977 | priv->cfg->base_params->num_of_queues; | |
141b03e0 | 978 | |
88804e2b WYG |
979 | if (!priv->txq) { |
980 | IWL_ERR(priv, "txq not ready\n"); | |
981 | return -EAGAIN; | |
982 | } | |
141b03e0 WYG |
983 | buf = kzalloc(bufsz, GFP_KERNEL); |
984 | if (!buf) | |
985 | return -ENOMEM; | |
986 | ||
987 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { | |
988 | txq = &priv->txq[cnt]; | |
989 | q = &txq->q; | |
990 | pos += scnprintf(buf + pos, bufsz - pos, | |
991 | "hwq %.2d: read=%u write=%u stop=%d" | |
992 | " swq_id=%#.2x (ac %d/hwq %d)\n", | |
993 | cnt, q->read_ptr, q->write_ptr, | |
994 | !!test_bit(cnt, priv->queue_stopped), | |
995 | txq->swq_id, | |
996 | txq->swq_id & 0x80 ? txq->swq_id & 3 : | |
997 | txq->swq_id, | |
998 | txq->swq_id & 0x80 ? (txq->swq_id >> 2) & | |
999 | 0x1f : txq->swq_id); | |
1000 | if (cnt >= 4) | |
1001 | continue; | |
1002 | /* for the ACs, display the stop count too */ | |
1003 | pos += scnprintf(buf + pos, bufsz - pos, | |
1004 | " stop-count: %d\n", | |
1005 | atomic_read(&priv->queue_stop_count[cnt])); | |
1006 | } | |
1007 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
1008 | kfree(buf); | |
1009 | return ret; | |
1010 | } | |
1011 | ||
1012 | static ssize_t iwl_dbgfs_rx_queue_read(struct file *file, | |
1013 | char __user *user_buf, | |
1014 | size_t count, loff_t *ppos) { | |
1015 | ||
28f63a4b | 1016 | struct iwl_priv *priv = file->private_data; |
141b03e0 WYG |
1017 | struct iwl_rx_queue *rxq = &priv->rxq; |
1018 | char buf[256]; | |
1019 | int pos = 0; | |
1020 | const size_t bufsz = sizeof(buf); | |
1021 | ||
1022 | pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", | |
1023 | rxq->read); | |
1024 | pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", | |
1025 | rxq->write); | |
1026 | pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", | |
1027 | rxq->free_count); | |
f5cc6a22 DS |
1028 | if (rxq->rb_stts) { |
1029 | pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", | |
141b03e0 | 1030 | le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); |
f5cc6a22 DS |
1031 | } else { |
1032 | pos += scnprintf(buf + pos, bufsz - pos, | |
1033 | "closed_rb_num: Not Allocated\n"); | |
1034 | } | |
141b03e0 WYG |
1035 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
1036 | } | |
1037 | ||
e8fe59ae WYG |
1038 | static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, |
1039 | char __user *user_buf, | |
1040 | size_t count, loff_t *ppos) | |
1041 | { | |
28f63a4b | 1042 | struct iwl_priv *priv = file->private_data; |
17f36fc6 AK |
1043 | return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, |
1044 | user_buf, count, ppos); | |
e8fe59ae WYG |
1045 | } |
1046 | ||
1047 | static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, | |
1048 | char __user *user_buf, | |
1049 | size_t count, loff_t *ppos) | |
1050 | { | |
28f63a4b | 1051 | struct iwl_priv *priv = file->private_data; |
17f36fc6 AK |
1052 | return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, |
1053 | user_buf, count, ppos); | |
e8fe59ae WYG |
1054 | } |
1055 | ||
1056 | static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, | |
1057 | char __user *user_buf, | |
1058 | size_t count, loff_t *ppos) | |
1059 | { | |
28f63a4b | 1060 | struct iwl_priv *priv = file->private_data; |
17f36fc6 AK |
1061 | return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, |
1062 | user_buf, count, ppos); | |
e8fe59ae WYG |
1063 | } |
1064 | ||
5225935b WYG |
1065 | static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, |
1066 | char __user *user_buf, | |
1067 | size_t count, loff_t *ppos) { | |
1068 | ||
28f63a4b | 1069 | struct iwl_priv *priv = file->private_data; |
5225935b WYG |
1070 | int pos = 0; |
1071 | int cnt = 0; | |
1072 | char *buf; | |
1073 | int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; | |
1074 | ssize_t ret; | |
1075 | struct iwl_sensitivity_data *data; | |
1076 | ||
1077 | data = &priv->sensitivity_data; | |
1078 | buf = kzalloc(bufsz, GFP_KERNEL); | |
1079 | if (!buf) { | |
1080 | IWL_ERR(priv, "Can not allocate Buffer\n"); | |
1081 | return -ENOMEM; | |
1082 | } | |
1083 | ||
1084 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", | |
1085 | data->auto_corr_ofdm); | |
1086 | pos += scnprintf(buf + pos, bufsz - pos, | |
1087 | "auto_corr_ofdm_mrc:\t\t %u\n", | |
1088 | data->auto_corr_ofdm_mrc); | |
1089 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", | |
1090 | data->auto_corr_ofdm_x1); | |
1091 | pos += scnprintf(buf + pos, bufsz - pos, | |
1092 | "auto_corr_ofdm_mrc_x1:\t\t %u\n", | |
1093 | data->auto_corr_ofdm_mrc_x1); | |
1094 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", | |
1095 | data->auto_corr_cck); | |
1096 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", | |
1097 | data->auto_corr_cck_mrc); | |
1098 | pos += scnprintf(buf + pos, bufsz - pos, | |
1099 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", | |
1100 | data->last_bad_plcp_cnt_ofdm); | |
1101 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", | |
1102 | data->last_fa_cnt_ofdm); | |
1103 | pos += scnprintf(buf + pos, bufsz - pos, | |
1104 | "last_bad_plcp_cnt_cck:\t\t %u\n", | |
1105 | data->last_bad_plcp_cnt_cck); | |
1106 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", | |
1107 | data->last_fa_cnt_cck); | |
1108 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", | |
1109 | data->nrg_curr_state); | |
1110 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", | |
1111 | data->nrg_prev_state); | |
1112 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); | |
1113 | for (cnt = 0; cnt < 10; cnt++) { | |
1114 | pos += scnprintf(buf + pos, bufsz - pos, " %u", | |
1115 | data->nrg_value[cnt]); | |
1116 | } | |
1117 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | |
1118 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); | |
1119 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { | |
1120 | pos += scnprintf(buf + pos, bufsz - pos, " %u", | |
1121 | data->nrg_silence_rssi[cnt]); | |
1122 | } | |
1123 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | |
1124 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", | |
1125 | data->nrg_silence_ref); | |
1126 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", | |
1127 | data->nrg_energy_idx); | |
1128 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", | |
1129 | data->nrg_silence_idx); | |
1130 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", | |
1131 | data->nrg_th_cck); | |
1132 | pos += scnprintf(buf + pos, bufsz - pos, | |
1133 | "nrg_auto_corr_silence_diff:\t %u\n", | |
1134 | data->nrg_auto_corr_silence_diff); | |
1135 | pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", | |
1136 | data->num_in_cck_no_fa); | |
1137 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", | |
1138 | data->nrg_th_ofdm); | |
1139 | ||
1140 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
1141 | kfree(buf); | |
1142 | return ret; | |
1143 | } | |
1144 | ||
1145 | ||
1146 | static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, | |
1147 | char __user *user_buf, | |
1148 | size_t count, loff_t *ppos) { | |
1149 | ||
28f63a4b | 1150 | struct iwl_priv *priv = file->private_data; |
5225935b WYG |
1151 | int pos = 0; |
1152 | int cnt = 0; | |
1153 | char *buf; | |
1154 | int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; | |
1155 | ssize_t ret; | |
1156 | struct iwl_chain_noise_data *data; | |
1157 | ||
1158 | data = &priv->chain_noise_data; | |
1159 | buf = kzalloc(bufsz, GFP_KERNEL); | |
1160 | if (!buf) { | |
1161 | IWL_ERR(priv, "Can not allocate Buffer\n"); | |
1162 | return -ENOMEM; | |
1163 | } | |
1164 | ||
1165 | pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", | |
1166 | data->active_chains); | |
1167 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", | |
1168 | data->chain_noise_a); | |
1169 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", | |
1170 | data->chain_noise_b); | |
1171 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", | |
1172 | data->chain_noise_c); | |
1173 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", | |
1174 | data->chain_signal_a); | |
1175 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", | |
1176 | data->chain_signal_b); | |
1177 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", | |
1178 | data->chain_signal_c); | |
1179 | pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", | |
1180 | data->beacon_count); | |
1181 | ||
1182 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); | |
1183 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { | |
1184 | pos += scnprintf(buf + pos, bufsz - pos, " %u", | |
1185 | data->disconn_array[cnt]); | |
1186 | } | |
1187 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | |
1188 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); | |
1189 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { | |
1190 | pos += scnprintf(buf + pos, bufsz - pos, " %u", | |
1191 | data->delta_gain_code[cnt]); | |
1192 | } | |
1193 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); | |
1194 | pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", | |
1195 | data->radio_write); | |
1196 | pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", | |
1197 | data->state); | |
1198 | ||
1199 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
1200 | kfree(buf); | |
1201 | return ret; | |
1202 | } | |
1203 | ||
c09430ab WYG |
1204 | static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, |
1205 | char __user *user_buf, | |
1206 | size_t count, loff_t *ppos) | |
1207 | { | |
28f63a4b | 1208 | struct iwl_priv *priv = file->private_data; |
c09430ab WYG |
1209 | char buf[60]; |
1210 | int pos = 0; | |
1211 | const size_t bufsz = sizeof(buf); | |
1212 | u32 pwrsave_status; | |
1213 | ||
1214 | pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) & | |
1215 | CSR_GP_REG_POWER_SAVE_STATUS_MSK; | |
1216 | ||
1217 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); | |
1218 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", | |
1219 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : | |
1220 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : | |
1221 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : | |
1222 | "error"); | |
1223 | ||
1224 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
1225 | } | |
1226 | ||
7163b8a4 | 1227 | static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file, |
ef8d5529 WYG |
1228 | const char __user *user_buf, |
1229 | size_t count, loff_t *ppos) | |
1230 | { | |
1231 | struct iwl_priv *priv = file->private_data; | |
1232 | char buf[8]; | |
1233 | int buf_size; | |
1234 | int clear; | |
1235 | ||
1236 | memset(buf, 0, sizeof(buf)); | |
1237 | buf_size = min(count, sizeof(buf) - 1); | |
1238 | if (copy_from_user(buf, user_buf, buf_size)) | |
1239 | return -EFAULT; | |
1240 | if (sscanf(buf, "%d", &clear) != 1) | |
1241 | return -EFAULT; | |
1242 | ||
1243 | /* make request to uCode to retrieve statistics information */ | |
1244 | mutex_lock(&priv->mutex); | |
1245 | iwl_send_statistics_request(priv, CMD_SYNC, true); | |
1246 | mutex_unlock(&priv->mutex); | |
1247 | ||
1248 | return count; | |
1249 | } | |
1250 | ||
696bdee3 WYG |
1251 | static ssize_t iwl_dbgfs_csr_write(struct file *file, |
1252 | const char __user *user_buf, | |
1253 | size_t count, loff_t *ppos) | |
1254 | { | |
1255 | struct iwl_priv *priv = file->private_data; | |
1256 | char buf[8]; | |
1257 | int buf_size; | |
1258 | int csr; | |
1259 | ||
1260 | memset(buf, 0, sizeof(buf)); | |
1261 | buf_size = min(count, sizeof(buf) - 1); | |
1262 | if (copy_from_user(buf, user_buf, buf_size)) | |
1263 | return -EFAULT; | |
1264 | if (sscanf(buf, "%d", &csr) != 1) | |
1265 | return -EFAULT; | |
1266 | ||
1267 | if (priv->cfg->ops->lib->dump_csr) | |
1268 | priv->cfg->ops->lib->dump_csr(priv); | |
1269 | ||
1270 | return count; | |
1271 | } | |
1272 | ||
a9e1cb6a WYG |
1273 | static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, |
1274 | char __user *user_buf, | |
1275 | size_t count, loff_t *ppos) { | |
1276 | ||
57674308 | 1277 | struct iwl_priv *priv = file->private_data; |
a9e1cb6a WYG |
1278 | int pos = 0; |
1279 | char buf[128]; | |
1280 | const size_t bufsz = sizeof(buf); | |
a9e1cb6a WYG |
1281 | |
1282 | pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", | |
1283 | priv->event_log.ucode_trace ? "On" : "Off"); | |
1284 | pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", | |
1285 | priv->event_log.non_wraps_count); | |
1286 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", | |
1287 | priv->event_log.wraps_once_count); | |
1288 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", | |
1289 | priv->event_log.wraps_more_count); | |
1290 | ||
4967c316 | 1291 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
a9e1cb6a WYG |
1292 | } |
1293 | ||
1294 | static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, | |
1295 | const char __user *user_buf, | |
1296 | size_t count, loff_t *ppos) | |
1297 | { | |
1298 | struct iwl_priv *priv = file->private_data; | |
1299 | char buf[8]; | |
1300 | int buf_size; | |
1301 | int trace; | |
1302 | ||
1303 | memset(buf, 0, sizeof(buf)); | |
1304 | buf_size = min(count, sizeof(buf) - 1); | |
1305 | if (copy_from_user(buf, user_buf, buf_size)) | |
1306 | return -EFAULT; | |
1307 | if (sscanf(buf, "%d", &trace) != 1) | |
1308 | return -EFAULT; | |
1309 | ||
1310 | if (trace) { | |
1311 | priv->event_log.ucode_trace = true; | |
1312 | /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ | |
1313 | mod_timer(&priv->ucode_trace, | |
1314 | jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); | |
1315 | } else { | |
1316 | priv->event_log.ucode_trace = false; | |
1317 | del_timer_sync(&priv->ucode_trace); | |
1318 | } | |
1319 | ||
1320 | return count; | |
1321 | } | |
1322 | ||
60987206 JB |
1323 | static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file, |
1324 | char __user *user_buf, | |
1325 | size_t count, loff_t *ppos) { | |
1326 | ||
57674308 | 1327 | struct iwl_priv *priv = file->private_data; |
60987206 JB |
1328 | int len = 0; |
1329 | char buf[20]; | |
1330 | ||
246ed355 JB |
1331 | len = sprintf(buf, "0x%04X\n", |
1332 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); | |
60987206 JB |
1333 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
1334 | } | |
1335 | ||
1336 | static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file, | |
1337 | char __user *user_buf, | |
1338 | size_t count, loff_t *ppos) { | |
1339 | ||
57674308 | 1340 | struct iwl_priv *priv = file->private_data; |
60987206 JB |
1341 | int len = 0; |
1342 | char buf[20]; | |
1343 | ||
1344 | len = sprintf(buf, "0x%04X\n", | |
246ed355 | 1345 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); |
60987206 JB |
1346 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
1347 | } | |
1348 | ||
1b3eb823 WYG |
1349 | static ssize_t iwl_dbgfs_fh_reg_read(struct file *file, |
1350 | char __user *user_buf, | |
1351 | size_t count, loff_t *ppos) | |
1352 | { | |
57674308 | 1353 | struct iwl_priv *priv = file->private_data; |
1b3eb823 WYG |
1354 | char *buf; |
1355 | int pos = 0; | |
1356 | ssize_t ret = -EFAULT; | |
1357 | ||
1358 | if (priv->cfg->ops->lib->dump_fh) { | |
1359 | ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true); | |
1360 | if (buf) { | |
1361 | ret = simple_read_from_buffer(user_buf, | |
1362 | count, ppos, buf, pos); | |
1363 | kfree(buf); | |
1364 | } | |
1365 | } | |
1366 | ||
1367 | return ret; | |
1368 | } | |
1369 | ||
a13d276f WYG |
1370 | static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file, |
1371 | char __user *user_buf, | |
1372 | size_t count, loff_t *ppos) { | |
1373 | ||
1374 | struct iwl_priv *priv = file->private_data; | |
1375 | int pos = 0; | |
1376 | char buf[12]; | |
1377 | const size_t bufsz = sizeof(buf); | |
a13d276f WYG |
1378 | |
1379 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", | |
1380 | priv->missed_beacon_threshold); | |
1381 | ||
4967c316 | 1382 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
a13d276f WYG |
1383 | } |
1384 | ||
1385 | static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, | |
1386 | const char __user *user_buf, | |
1387 | size_t count, loff_t *ppos) | |
1388 | { | |
1389 | struct iwl_priv *priv = file->private_data; | |
1390 | char buf[8]; | |
1391 | int buf_size; | |
1392 | int missed; | |
1393 | ||
1394 | memset(buf, 0, sizeof(buf)); | |
1395 | buf_size = min(count, sizeof(buf) - 1); | |
1396 | if (copy_from_user(buf, user_buf, buf_size)) | |
1397 | return -EFAULT; | |
1398 | if (sscanf(buf, "%d", &missed) != 1) | |
1399 | return -EINVAL; | |
1400 | ||
1401 | if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || | |
1402 | missed > IWL_MISSED_BEACON_THRESHOLD_MAX) | |
1403 | priv->missed_beacon_threshold = | |
1404 | IWL_MISSED_BEACON_THRESHOLD_DEF; | |
1405 | else | |
1406 | priv->missed_beacon_threshold = missed; | |
1407 | ||
1408 | return count; | |
1409 | } | |
1410 | ||
3e4fb5fa TAN |
1411 | static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, |
1412 | char __user *user_buf, | |
1413 | size_t count, loff_t *ppos) { | |
1414 | ||
57674308 | 1415 | struct iwl_priv *priv = file->private_data; |
3e4fb5fa TAN |
1416 | int pos = 0; |
1417 | char buf[12]; | |
1418 | const size_t bufsz = sizeof(buf); | |
3e4fb5fa TAN |
1419 | |
1420 | pos += scnprintf(buf + pos, bufsz - pos, "%u\n", | |
7cb1b088 | 1421 | priv->cfg->base_params->plcp_delta_threshold); |
3e4fb5fa | 1422 | |
4967c316 | 1423 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
3e4fb5fa TAN |
1424 | } |
1425 | ||
1426 | static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, | |
1427 | const char __user *user_buf, | |
1428 | size_t count, loff_t *ppos) { | |
1429 | ||
1430 | struct iwl_priv *priv = file->private_data; | |
1431 | char buf[8]; | |
1432 | int buf_size; | |
1433 | int plcp; | |
1434 | ||
1435 | memset(buf, 0, sizeof(buf)); | |
1436 | buf_size = min(count, sizeof(buf) - 1); | |
1437 | if (copy_from_user(buf, user_buf, buf_size)) | |
1438 | return -EFAULT; | |
1439 | if (sscanf(buf, "%d", &plcp) != 1) | |
1440 | return -EINVAL; | |
680788ac | 1441 | if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || |
3e4fb5fa | 1442 | (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) |
7cb1b088 | 1443 | priv->cfg->base_params->plcp_delta_threshold = |
680788ac | 1444 | IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; |
3e4fb5fa | 1445 | else |
7cb1b088 | 1446 | priv->cfg->base_params->plcp_delta_threshold = plcp; |
3e4fb5fa TAN |
1447 | return count; |
1448 | } | |
1449 | ||
528c3126 WYG |
1450 | static ssize_t iwl_dbgfs_force_reset_read(struct file *file, |
1451 | char __user *user_buf, | |
1452 | size_t count, loff_t *ppos) { | |
1453 | ||
1454 | struct iwl_priv *priv = file->private_data; | |
1455 | int i, pos = 0; | |
1456 | char buf[300]; | |
1457 | const size_t bufsz = sizeof(buf); | |
1458 | struct iwl_force_reset *force_reset; | |
1459 | ||
1460 | for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { | |
1461 | force_reset = &priv->force_reset[i]; | |
1462 | pos += scnprintf(buf + pos, bufsz - pos, | |
1463 | "Force reset method %d\n", i); | |
1464 | pos += scnprintf(buf + pos, bufsz - pos, | |
1465 | "\tnumber of reset request: %d\n", | |
1466 | force_reset->reset_request_count); | |
1467 | pos += scnprintf(buf + pos, bufsz - pos, | |
1468 | "\tnumber of reset request success: %d\n", | |
1469 | force_reset->reset_success_count); | |
1470 | pos += scnprintf(buf + pos, bufsz - pos, | |
1471 | "\tnumber of reset request reject: %d\n", | |
1472 | force_reset->reset_reject_count); | |
1473 | pos += scnprintf(buf + pos, bufsz - pos, | |
1474 | "\treset duration: %lu\n", | |
1475 | force_reset->reset_duration); | |
1476 | } | |
1477 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
1478 | } | |
1479 | ||
04cafd7f WYG |
1480 | static ssize_t iwl_dbgfs_force_reset_write(struct file *file, |
1481 | const char __user *user_buf, | |
1482 | size_t count, loff_t *ppos) { | |
1483 | ||
1484 | struct iwl_priv *priv = file->private_data; | |
1485 | char buf[8]; | |
1486 | int buf_size; | |
1487 | int reset, ret; | |
1488 | ||
1489 | memset(buf, 0, sizeof(buf)); | |
1490 | buf_size = min(count, sizeof(buf) - 1); | |
1491 | if (copy_from_user(buf, user_buf, buf_size)) | |
1492 | return -EFAULT; | |
1493 | if (sscanf(buf, "%d", &reset) != 1) | |
1494 | return -EINVAL; | |
1495 | switch (reset) { | |
1496 | case IWL_RF_RESET: | |
1497 | case IWL_FW_RESET: | |
c04f9f22 | 1498 | ret = iwl_force_reset(priv, reset, true); |
04cafd7f WYG |
1499 | break; |
1500 | default: | |
1501 | return -EINVAL; | |
1502 | } | |
1503 | return ret ? ret : count; | |
1504 | } | |
1505 | ||
4bf49a90 WYG |
1506 | static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, |
1507 | const char __user *user_buf, | |
1508 | size_t count, loff_t *ppos) { | |
1509 | ||
1510 | struct iwl_priv *priv = file->private_data; | |
1511 | char buf[8]; | |
1512 | int buf_size; | |
1513 | int flush; | |
1514 | ||
1515 | memset(buf, 0, sizeof(buf)); | |
1516 | buf_size = min(count, sizeof(buf) - 1); | |
1517 | if (copy_from_user(buf, user_buf, buf_size)) | |
1518 | return -EFAULT; | |
1519 | if (sscanf(buf, "%d", &flush) != 1) | |
1520 | return -EINVAL; | |
1521 | ||
1522 | if (iwl_is_rfkill(priv)) | |
1523 | return -EFAULT; | |
1524 | ||
1525 | priv->cfg->ops->lib->dev_txfifo_flush(priv, IWL_DROP_ALL); | |
1526 | ||
1527 | return count; | |
1528 | } | |
1529 | ||
ffb7d896 WYG |
1530 | static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, |
1531 | char __user *user_buf, | |
1532 | size_t count, loff_t *ppos) | |
1533 | { | |
1534 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; | |
1535 | ||
1536 | return priv->cfg->ops->lib->debugfs_ops.bt_stats_read(file, | |
1537 | user_buf, count, ppos); | |
1538 | } | |
1539 | ||
7bdc473c WYG |
1540 | static ssize_t iwl_dbgfs_monitor_period_write(struct file *file, |
1541 | const char __user *user_buf, | |
1542 | size_t count, loff_t *ppos) { | |
1543 | ||
1544 | struct iwl_priv *priv = file->private_data; | |
1545 | char buf[8]; | |
1546 | int buf_size; | |
1547 | int period; | |
1548 | ||
1549 | memset(buf, 0, sizeof(buf)); | |
1550 | buf_size = min(count, sizeof(buf) - 1); | |
1551 | if (copy_from_user(buf, user_buf, buf_size)) | |
1552 | return -EFAULT; | |
1553 | if (sscanf(buf, "%d", &period) != 1) | |
1554 | return -EINVAL; | |
1555 | if (period < 0 || period > IWL_MAX_MONITORING_PERIOD) | |
7cb1b088 WYG |
1556 | priv->cfg->base_params->monitor_recover_period = |
1557 | IWL_DEF_MONITORING_PERIOD; | |
7bdc473c | 1558 | else |
7cb1b088 | 1559 | priv->cfg->base_params->monitor_recover_period = period; |
7bdc473c | 1560 | |
7cb1b088 | 1561 | if (priv->cfg->base_params->monitor_recover_period) |
7bdc473c | 1562 | mod_timer(&priv->monitor_recover, jiffies + msecs_to_jiffies( |
7cb1b088 | 1563 | priv->cfg->base_params->monitor_recover_period)); |
7bdc473c WYG |
1564 | else |
1565 | del_timer_sync(&priv->monitor_recover); | |
1566 | return count; | |
1567 | } | |
1568 | ||
befe8c46 WYG |
1569 | static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file, |
1570 | char __user *user_buf, | |
1571 | size_t count, loff_t *ppos) { | |
1572 | ||
1573 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; | |
1574 | int pos = 0; | |
1575 | char buf[200]; | |
1576 | const size_t bufsz = sizeof(buf); | |
1577 | ssize_t ret; | |
1578 | ||
1579 | pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n", | |
1580 | priv->bt_full_concurrent ? "full concurrency" : "3-wire"); | |
1581 | pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, " | |
1582 | "last traffic notif: %d\n", | |
1583 | priv->bt_status ? "On" : "Off", priv->notif_bt_traffic_load); | |
1584 | pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, " | |
1585 | "sco_active: %d, kill_ack_mask: %x, " | |
1586 | "kill_cts_mask: %x\n", | |
1587 | priv->bt_ch_announce, priv->bt_sco_active, | |
1588 | priv->kill_ack_mask, priv->kill_cts_mask); | |
1589 | ||
1590 | pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: "); | |
1591 | switch (priv->bt_traffic_load) { | |
1592 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: | |
1593 | pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n"); | |
1594 | break; | |
1595 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: | |
1596 | pos += scnprintf(buf + pos, bufsz - pos, "High\n"); | |
1597 | break; | |
1598 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: | |
1599 | pos += scnprintf(buf + pos, bufsz - pos, "Low\n"); | |
1600 | break; | |
1601 | case IWL_BT_COEX_TRAFFIC_LOAD_NONE: | |
1602 | default: | |
1603 | pos += scnprintf(buf + pos, bufsz - pos, "None\n"); | |
1604 | break; | |
1605 | } | |
1606 | ||
1607 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | |
1608 | return ret; | |
1609 | } | |
1610 | ||
c6abdc0d WYG |
1611 | static ssize_t iwl_dbgfs_protection_mode_read(struct file *file, |
1612 | char __user *user_buf, | |
1613 | size_t count, loff_t *ppos) | |
1614 | { | |
1615 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; | |
1616 | ||
1617 | int pos = 0; | |
1618 | char buf[40]; | |
1619 | const size_t bufsz = sizeof(buf); | |
1620 | ||
7cb1b088 WYG |
1621 | if (priv->cfg->ht_params) |
1622 | pos += scnprintf(buf + pos, bufsz - pos, | |
1623 | "use %s for aggregation\n", | |
1624 | (priv->cfg->ht_params->use_rts_for_aggregation) ? | |
1625 | "rts/cts" : "cts-to-self"); | |
1626 | else | |
1627 | pos += scnprintf(buf + pos, bufsz - pos, "N/A"); | |
1628 | ||
c6abdc0d WYG |
1629 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
1630 | } | |
1631 | ||
1632 | static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, | |
1633 | const char __user *user_buf, | |
1634 | size_t count, loff_t *ppos) { | |
1635 | ||
1636 | struct iwl_priv *priv = file->private_data; | |
1637 | char buf[8]; | |
1638 | int buf_size; | |
1639 | int rts; | |
1640 | ||
7cb1b088 WYG |
1641 | if (!priv->cfg->ht_params) |
1642 | return -EINVAL; | |
1643 | ||
c6abdc0d WYG |
1644 | memset(buf, 0, sizeof(buf)); |
1645 | buf_size = min(count, sizeof(buf) - 1); | |
1646 | if (copy_from_user(buf, user_buf, buf_size)) | |
1647 | return -EFAULT; | |
1648 | if (sscanf(buf, "%d", &rts) != 1) | |
1649 | return -EINVAL; | |
1650 | if (rts) | |
7cb1b088 | 1651 | priv->cfg->ht_params->use_rts_for_aggregation = true; |
c6abdc0d | 1652 | else |
7cb1b088 | 1653 | priv->cfg->ht_params->use_rts_for_aggregation = false; |
c6abdc0d WYG |
1654 | return count; |
1655 | } | |
1656 | ||
54a9aa65 WYG |
1657 | static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file, |
1658 | char __user *user_buf, | |
1659 | size_t count, loff_t *ppos) | |
1660 | { | |
1661 | struct iwl_priv *priv = file->private_data; | |
1662 | ||
1663 | if (priv->cfg->ops->lib->debugfs_ops.reply_tx_error) | |
1664 | return priv->cfg->ops->lib->debugfs_ops.reply_tx_error( | |
1665 | file, user_buf, count, ppos); | |
1666 | else | |
1667 | return -ENODATA; | |
1668 | } | |
7163b8a4 WYG |
1669 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
1670 | DEBUGFS_READ_FILE_OPS(tx_statistics); | |
20594eb0 | 1671 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); |
141b03e0 WYG |
1672 | DEBUGFS_READ_FILE_OPS(rx_queue); |
1673 | DEBUGFS_READ_FILE_OPS(tx_queue); | |
e8fe59ae WYG |
1674 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
1675 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); | |
1676 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); | |
5225935b WYG |
1677 | DEBUGFS_READ_FILE_OPS(sensitivity); |
1678 | DEBUGFS_READ_FILE_OPS(chain_noise); | |
c09430ab | 1679 | DEBUGFS_READ_FILE_OPS(power_save_status); |
7163b8a4 WYG |
1680 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); |
1681 | DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); | |
696bdee3 | 1682 | DEBUGFS_WRITE_FILE_OPS(csr); |
a9e1cb6a | 1683 | DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); |
1b3eb823 | 1684 | DEBUGFS_READ_FILE_OPS(fh_reg); |
a13d276f | 1685 | DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); |
3e4fb5fa | 1686 | DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); |
528c3126 | 1687 | DEBUGFS_READ_WRITE_FILE_OPS(force_reset); |
60987206 JB |
1688 | DEBUGFS_READ_FILE_OPS(rxon_flags); |
1689 | DEBUGFS_READ_FILE_OPS(rxon_filter_flags); | |
4bf49a90 | 1690 | DEBUGFS_WRITE_FILE_OPS(txfifo_flush); |
ffb7d896 | 1691 | DEBUGFS_READ_FILE_OPS(ucode_bt_stats); |
7bdc473c | 1692 | DEBUGFS_WRITE_FILE_OPS(monitor_period); |
befe8c46 | 1693 | DEBUGFS_READ_FILE_OPS(bt_traffic); |
c6abdc0d | 1694 | DEBUGFS_READ_WRITE_FILE_OPS(protection_mode); |
54a9aa65 | 1695 | DEBUGFS_READ_FILE_OPS(reply_tx_error); |
20594eb0 | 1696 | |
712b6cf5 TW |
1697 | /* |
1698 | * Create the debugfs files and directories | |
1699 | * | |
1700 | */ | |
1701 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | |
1702 | { | |
95b1a822 | 1703 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
4c84a8f1 | 1704 | struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; |
712b6cf5 | 1705 | |
4c84a8f1 JB |
1706 | dir_drv = debugfs_create_dir(name, phyd); |
1707 | if (!dir_drv) | |
1708 | return -ENOMEM; | |
712b6cf5 | 1709 | |
4c84a8f1 JB |
1710 | priv->debugfs_dir = dir_drv; |
1711 | ||
1712 | dir_data = debugfs_create_dir("data", dir_drv); | |
1713 | if (!dir_data) | |
1714 | goto err; | |
1715 | dir_rf = debugfs_create_dir("rf", dir_drv); | |
1716 | if (!dir_rf) | |
1717 | goto err; | |
1718 | dir_debug = debugfs_create_dir("debug", dir_drv); | |
1719 | if (!dir_debug) | |
712b6cf5 | 1720 | goto err; |
712b6cf5 | 1721 | |
4c84a8f1 JB |
1722 | DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); |
1723 | DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); | |
1724 | DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR); | |
1725 | DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); | |
1726 | DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); | |
1727 | DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); | |
1728 | DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); | |
1729 | DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); | |
1730 | DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR); | |
7cb1b088 | 1731 | if (!priv->cfg->base_params->broken_powersave) { |
381733cc WYG |
1732 | DEBUGFS_ADD_FILE(sleep_level_override, dir_data, |
1733 | S_IWUSR | S_IRUSR); | |
1734 | DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); | |
1735 | } | |
4c84a8f1 JB |
1736 | DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); |
1737 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); | |
1738 | DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); | |
1739 | DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); | |
1740 | DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); | |
1741 | DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); | |
1742 | DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); | |
4c84a8f1 JB |
1743 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
1744 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); | |
1745 | DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); | |
1746 | DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR); | |
1747 | DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); | |
1748 | DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); | |
4c84a8f1 | 1749 | DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); |
528c3126 | 1750 | DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); |
b8c76267 AK |
1751 | DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); |
1752 | DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); | |
1753 | DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); | |
4bf49a90 WYG |
1754 | if (priv->cfg->ops->lib->dev_txfifo_flush) |
1755 | DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); | |
c6abdc0d | 1756 | DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR); |
b8c76267 | 1757 | |
7cb1b088 | 1758 | if (priv->cfg->base_params->sensitivity_calib_by_driver) |
4c84a8f1 | 1759 | DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); |
7cb1b088 | 1760 | if (priv->cfg->base_params->chain_noise_calib_by_driver) |
4c84a8f1 | 1761 | DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); |
7cb1b088 | 1762 | if (priv->cfg->base_params->ucode_tracing) |
4c84a8f1 | 1763 | DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); |
7cb1b088 | 1764 | if (priv->cfg->bt_params && priv->cfg->bt_params->bt_statistics) |
ffb7d896 | 1765 | DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); |
54a9aa65 | 1766 | DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); |
60987206 JB |
1767 | DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); |
1768 | DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); | |
7bdc473c | 1769 | DEBUGFS_ADD_FILE(monitor_period, dir_debug, S_IWUSR); |
7cb1b088 | 1770 | if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist) |
befe8c46 | 1771 | DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); |
7cb1b088 | 1772 | if (priv->cfg->base_params->sensitivity_calib_by_driver) |
65d1f896 WYG |
1773 | DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, |
1774 | &priv->disable_sens_cal); | |
7cb1b088 | 1775 | if (priv->cfg->base_params->chain_noise_calib_by_driver) |
65d1f896 WYG |
1776 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, |
1777 | &priv->disable_chain_noise_cal); | |
7cb1b088 | 1778 | if (priv->cfg->base_params->tx_power_by_driver) |
4c84a8f1 | 1779 | DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, |
030b8655 | 1780 | &priv->disable_tx_power_cal); |
712b6cf5 TW |
1781 | return 0; |
1782 | ||
1783 | err: | |
4c84a8f1 | 1784 | IWL_ERR(priv, "Can't create the debugfs directory\n"); |
712b6cf5 | 1785 | iwl_dbgfs_unregister(priv); |
4c84a8f1 | 1786 | return -ENOMEM; |
712b6cf5 TW |
1787 | } |
1788 | EXPORT_SYMBOL(iwl_dbgfs_register); | |
1789 | ||
1790 | /** | |
1791 | * Remove the debugfs files and directories | |
1792 | * | |
1793 | */ | |
1794 | void iwl_dbgfs_unregister(struct iwl_priv *priv) | |
1795 | { | |
4c84a8f1 | 1796 | if (!priv->debugfs_dir) |
712b6cf5 TW |
1797 | return; |
1798 | ||
4c84a8f1 JB |
1799 | debugfs_remove_recursive(priv->debugfs_dir); |
1800 | priv->debugfs_dir = NULL; | |
712b6cf5 TW |
1801 | } |
1802 | EXPORT_SYMBOL(iwl_dbgfs_unregister); | |
1803 | ||
1804 | ||
445c2dff | 1805 |