Commit | Line | Data |
---|---|---|
bb9f8692 ZY |
1 | /* |
2 | * Intel Wireless Multicomm 3200 WiFi driver | |
3 | * | |
4 | * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com> | |
5 | * Samuel Ortiz <samuel.ortiz@intel.com> | |
6 | * Zhu Yi <yi.zhu@intel.com> | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License version | |
10 | * 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
20 | * 02110-1301, USA. | |
21 | * | |
22 | */ | |
23 | ||
24 | #include <linux/kernel.h> | |
25 | #include <linux/bitops.h> | |
26 | #include <linux/debugfs.h> | |
27 | ||
28 | #include "iwm.h" | |
29 | #include "bus.h" | |
30 | #include "rx.h" | |
31 | #include "debug.h" | |
32 | ||
33 | static struct { | |
34 | u8 id; | |
35 | char *name; | |
36 | } iwm_debug_module[__IWM_DM_NR] = { | |
37 | {IWM_DM_BOOT, "boot"}, | |
38 | {IWM_DM_FW, "fw"}, | |
39 | {IWM_DM_SDIO, "sdio"}, | |
40 | {IWM_DM_NTF, "ntf"}, | |
41 | {IWM_DM_RX, "rx"}, | |
42 | {IWM_DM_TX, "tx"}, | |
43 | {IWM_DM_MLME, "mlme"}, | |
44 | {IWM_DM_CMD, "cmd"}, | |
45 | {IWM_DM_WEXT, "wext"}, | |
46 | }; | |
47 | ||
48 | #define add_dbg_module(dbg, name, id, initlevel) \ | |
49 | do { \ | |
50 | struct dentry *d; \ | |
51 | dbg.dbg_module[id] = (initlevel); \ | |
52 | d = debugfs_create_x8(name, 0600, dbg.dbgdir, \ | |
53 | &(dbg.dbg_module[id])); \ | |
54 | if (!IS_ERR(d)) \ | |
55 | dbg.dbg_module_dentries[id] = d; \ | |
56 | } while (0) | |
57 | ||
58 | static int iwm_debugfs_u32_read(void *data, u64 *val) | |
59 | { | |
60 | struct iwm_priv *iwm = data; | |
61 | ||
62 | *val = iwm->dbg.dbg_level; | |
63 | return 0; | |
64 | } | |
65 | ||
66 | static int iwm_debugfs_dbg_level_write(void *data, u64 val) | |
67 | { | |
68 | struct iwm_priv *iwm = data; | |
69 | int i; | |
70 | ||
71 | iwm->dbg.dbg_level = val; | |
72 | ||
73 | for (i = 0; i < __IWM_DM_NR; i++) | |
74 | iwm->dbg.dbg_module[i] = val; | |
75 | ||
76 | return 0; | |
77 | } | |
78 | DEFINE_SIMPLE_ATTRIBUTE(fops_iwm_dbg_level, | |
79 | iwm_debugfs_u32_read, iwm_debugfs_dbg_level_write, | |
80 | "%llu\n"); | |
81 | ||
82 | static int iwm_debugfs_dbg_modules_write(void *data, u64 val) | |
83 | { | |
84 | struct iwm_priv *iwm = data; | |
85 | int i, bit; | |
86 | ||
87 | iwm->dbg.dbg_modules = val; | |
88 | ||
89 | for (i = 0; i < __IWM_DM_NR; i++) | |
90 | iwm->dbg.dbg_module[i] = 0; | |
91 | ||
984b3f57 | 92 | for_each_set_bit(bit, &iwm->dbg.dbg_modules, __IWM_DM_NR) |
bb9f8692 ZY |
93 | iwm->dbg.dbg_module[bit] = iwm->dbg.dbg_level; |
94 | ||
95 | return 0; | |
96 | } | |
97 | DEFINE_SIMPLE_ATTRIBUTE(fops_iwm_dbg_modules, | |
98 | iwm_debugfs_u32_read, iwm_debugfs_dbg_modules_write, | |
99 | "%llu\n"); | |
100 | ||
04e715cd | 101 | static int iwm_generic_open(struct inode *inode, struct file *filp) |
bb9f8692 ZY |
102 | { |
103 | filp->private_data = inode->i_private; | |
104 | return 0; | |
105 | } | |
106 | ||
107 | ||
108 | static ssize_t iwm_debugfs_txq_read(struct file *filp, char __user *buffer, | |
109 | size_t count, loff_t *ppos) | |
110 | { | |
111 | struct iwm_priv *iwm = filp->private_data; | |
112 | char *buf; | |
113 | int i, buf_len = 4096; | |
114 | size_t len = 0; | |
115 | ssize_t ret; | |
116 | ||
117 | if (*ppos != 0) | |
118 | return 0; | |
119 | if (count < sizeof(buf)) | |
120 | return -ENOSPC; | |
121 | ||
122 | buf = kzalloc(buf_len, GFP_KERNEL); | |
123 | if (!buf) | |
124 | return -ENOMEM; | |
125 | ||
126 | for (i = 0; i < IWM_TX_QUEUES; i++) { | |
127 | struct iwm_tx_queue *txq = &iwm->txq[i]; | |
128 | struct sk_buff *skb; | |
129 | int j; | |
130 | unsigned long flags; | |
131 | ||
132 | spin_lock_irqsave(&txq->queue.lock, flags); | |
133 | ||
134 | skb = (struct sk_buff *)&txq->queue; | |
135 | ||
136 | len += snprintf(buf + len, buf_len - len, "TXQ #%d\n", i); | |
137 | len += snprintf(buf + len, buf_len - len, "\tStopped: %d\n", | |
138 | __netif_subqueue_stopped(iwm_to_ndev(iwm), | |
139 | txq->id)); | |
140 | len += snprintf(buf + len, buf_len - len, "\tConcat count:%d\n", | |
141 | txq->concat_count); | |
142 | len += snprintf(buf + len, buf_len - len, "\tQueue len: %d\n", | |
143 | skb_queue_len(&txq->queue)); | |
144 | for (j = 0; j < skb_queue_len(&txq->queue); j++) { | |
145 | struct iwm_tx_info *tx_info; | |
146 | ||
147 | skb = skb->next; | |
148 | tx_info = skb_to_tx_info(skb); | |
149 | ||
150 | len += snprintf(buf + len, buf_len - len, | |
151 | "\tSKB #%d\n", j); | |
152 | len += snprintf(buf + len, buf_len - len, | |
153 | "\t\tsta: %d\n", tx_info->sta); | |
154 | len += snprintf(buf + len, buf_len - len, | |
155 | "\t\tcolor: %d\n", tx_info->color); | |
156 | len += snprintf(buf + len, buf_len - len, | |
157 | "\t\ttid: %d\n", tx_info->tid); | |
158 | } | |
159 | ||
160 | spin_unlock_irqrestore(&txq->queue.lock, flags); | |
b136b3a2 SO |
161 | |
162 | spin_lock_irqsave(&txq->stopped_queue.lock, flags); | |
163 | ||
164 | len += snprintf(buf + len, buf_len - len, | |
165 | "\tStopped Queue len: %d\n", | |
166 | skb_queue_len(&txq->stopped_queue)); | |
167 | for (j = 0; j < skb_queue_len(&txq->stopped_queue); j++) { | |
168 | struct iwm_tx_info *tx_info; | |
169 | ||
170 | skb = skb->next; | |
171 | tx_info = skb_to_tx_info(skb); | |
172 | ||
173 | len += snprintf(buf + len, buf_len - len, | |
174 | "\tSKB #%d\n", j); | |
175 | len += snprintf(buf + len, buf_len - len, | |
176 | "\t\tsta: %d\n", tx_info->sta); | |
177 | len += snprintf(buf + len, buf_len - len, | |
178 | "\t\tcolor: %d\n", tx_info->color); | |
179 | len += snprintf(buf + len, buf_len - len, | |
180 | "\t\ttid: %d\n", tx_info->tid); | |
181 | } | |
182 | ||
183 | spin_unlock_irqrestore(&txq->stopped_queue.lock, flags); | |
bb9f8692 ZY |
184 | } |
185 | ||
186 | ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len); | |
187 | kfree(buf); | |
188 | ||
189 | return ret; | |
190 | } | |
191 | ||
192 | static ssize_t iwm_debugfs_tx_credit_read(struct file *filp, | |
193 | char __user *buffer, | |
194 | size_t count, loff_t *ppos) | |
195 | { | |
196 | struct iwm_priv *iwm = filp->private_data; | |
197 | struct iwm_tx_credit *credit = &iwm->tx_credit; | |
198 | char *buf; | |
199 | int i, buf_len = 4096; | |
200 | size_t len = 0; | |
201 | ssize_t ret; | |
202 | ||
203 | if (*ppos != 0) | |
204 | return 0; | |
205 | if (count < sizeof(buf)) | |
206 | return -ENOSPC; | |
207 | ||
208 | buf = kzalloc(buf_len, GFP_KERNEL); | |
209 | if (!buf) | |
210 | return -ENOMEM; | |
211 | ||
212 | len += snprintf(buf + len, buf_len - len, | |
213 | "NR pools: %d\n", credit->pool_nr); | |
214 | len += snprintf(buf + len, buf_len - len, | |
215 | "pools map: 0x%lx\n", credit->full_pools_map); | |
216 | ||
217 | len += snprintf(buf + len, buf_len - len, "\n### POOLS ###\n"); | |
218 | for (i = 0; i < IWM_MACS_OUT_GROUPS; i++) { | |
219 | len += snprintf(buf + len, buf_len - len, | |
220 | "pools entry #%d\n", i); | |
221 | len += snprintf(buf + len, buf_len - len, | |
222 | "\tid: %d\n", | |
223 | credit->pools[i].id); | |
224 | len += snprintf(buf + len, buf_len - len, | |
225 | "\tsid: %d\n", | |
226 | credit->pools[i].sid); | |
227 | len += snprintf(buf + len, buf_len - len, | |
228 | "\tmin_pages: %d\n", | |
229 | credit->pools[i].min_pages); | |
230 | len += snprintf(buf + len, buf_len - len, | |
231 | "\tmax_pages: %d\n", | |
232 | credit->pools[i].max_pages); | |
233 | len += snprintf(buf + len, buf_len - len, | |
234 | "\talloc_pages: %d\n", | |
235 | credit->pools[i].alloc_pages); | |
236 | len += snprintf(buf + len, buf_len - len, | |
237 | "\tfreed_pages: %d\n", | |
238 | credit->pools[i].total_freed_pages); | |
239 | } | |
240 | ||
241 | len += snprintf(buf + len, buf_len - len, "\n### SPOOLS ###\n"); | |
242 | for (i = 0; i < IWM_MACS_OUT_SGROUPS; i++) { | |
243 | len += snprintf(buf + len, buf_len - len, | |
244 | "spools entry #%d\n", i); | |
245 | len += snprintf(buf + len, buf_len - len, | |
246 | "\tid: %d\n", | |
247 | credit->spools[i].id); | |
248 | len += snprintf(buf + len, buf_len - len, | |
249 | "\tmax_pages: %d\n", | |
250 | credit->spools[i].max_pages); | |
251 | len += snprintf(buf + len, buf_len - len, | |
252 | "\talloc_pages: %d\n", | |
253 | credit->spools[i].alloc_pages); | |
254 | ||
255 | } | |
256 | ||
257 | ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len); | |
258 | kfree(buf); | |
259 | ||
260 | return ret; | |
261 | } | |
262 | ||
263 | static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp, | |
264 | char __user *buffer, | |
265 | size_t count, loff_t *ppos) | |
266 | { | |
267 | struct iwm_priv *iwm = filp->private_data; | |
268 | struct iwm_rx_ticket_node *ticket, *next; | |
269 | char *buf; | |
270 | int buf_len = 4096, i; | |
271 | size_t len = 0; | |
272 | ssize_t ret; | |
273 | ||
274 | if (*ppos != 0) | |
275 | return 0; | |
276 | if (count < sizeof(buf)) | |
277 | return -ENOSPC; | |
278 | ||
279 | buf = kzalloc(buf_len, GFP_KERNEL); | |
280 | if (!buf) | |
281 | return -ENOMEM; | |
282 | ||
283 | list_for_each_entry_safe(ticket, next, &iwm->rx_tickets, node) { | |
284 | len += snprintf(buf + len, buf_len - len, "Ticket #%d\n", | |
285 | ticket->ticket->id); | |
286 | len += snprintf(buf + len, buf_len - len, "\taction: 0x%x\n", | |
287 | ticket->ticket->action); | |
288 | len += snprintf(buf + len, buf_len - len, "\tflags: 0x%x\n", | |
289 | ticket->ticket->flags); | |
290 | } | |
291 | ||
292 | for (i = 0; i < IWM_RX_ID_HASH; i++) { | |
293 | struct iwm_rx_packet *packet, *nxt; | |
294 | struct list_head *pkt_list = &iwm->rx_packets[i]; | |
295 | if (!list_empty(pkt_list)) { | |
296 | len += snprintf(buf + len, buf_len - len, | |
297 | "Packet hash #%d\n", i); | |
298 | list_for_each_entry_safe(packet, nxt, pkt_list, node) { | |
299 | len += snprintf(buf + len, buf_len - len, | |
300 | "\tPacket id: %d\n", | |
301 | packet->id); | |
302 | len += snprintf(buf + len, buf_len - len, | |
303 | "\tPacket length: %lu\n", | |
304 | packet->pkt_size); | |
305 | } | |
306 | } | |
307 | } | |
308 | ||
309 | ret = simple_read_from_buffer(buffer, len, ppos, buf, buf_len); | |
310 | kfree(buf); | |
311 | ||
312 | return ret; | |
313 | } | |
314 | ||
04e715cd SO |
315 | static ssize_t iwm_debugfs_fw_err_read(struct file *filp, |
316 | char __user *buffer, | |
317 | size_t count, loff_t *ppos) | |
318 | { | |
319 | ||
320 | struct iwm_priv *iwm = filp->private_data; | |
321 | char buf[512]; | |
322 | int buf_len = 512; | |
323 | size_t len = 0; | |
324 | ||
325 | if (*ppos != 0) | |
326 | return 0; | |
327 | if (count < sizeof(buf)) | |
328 | return -ENOSPC; | |
329 | ||
330 | if (!iwm->last_fw_err) | |
331 | return -ENOMEM; | |
332 | ||
333 | if (iwm->last_fw_err->line_num == 0) | |
334 | goto out; | |
335 | ||
336 | len += snprintf(buf + len, buf_len - len, "%cMAC FW ERROR:\n", | |
337 | (le32_to_cpu(iwm->last_fw_err->category) == UMAC_SYS_ERR_CAT_LMAC) | |
338 | ? 'L' : 'U'); | |
339 | len += snprintf(buf + len, buf_len - len, | |
340 | "\tCategory: %d\n", | |
341 | le32_to_cpu(iwm->last_fw_err->category)); | |
342 | ||
343 | len += snprintf(buf + len, buf_len - len, | |
344 | "\tStatus: 0x%x\n", | |
345 | le32_to_cpu(iwm->last_fw_err->status)); | |
346 | ||
347 | len += snprintf(buf + len, buf_len - len, | |
348 | "\tPC: 0x%x\n", | |
349 | le32_to_cpu(iwm->last_fw_err->pc)); | |
350 | ||
351 | len += snprintf(buf + len, buf_len - len, | |
352 | "\tblink1: %d\n", | |
353 | le32_to_cpu(iwm->last_fw_err->blink1)); | |
354 | ||
355 | len += snprintf(buf + len, buf_len - len, | |
356 | "\tblink2: %d\n", | |
357 | le32_to_cpu(iwm->last_fw_err->blink2)); | |
358 | ||
359 | len += snprintf(buf + len, buf_len - len, | |
360 | "\tilink1: %d\n", | |
361 | le32_to_cpu(iwm->last_fw_err->ilink1)); | |
362 | ||
363 | len += snprintf(buf + len, buf_len - len, | |
364 | "\tilink2: %d\n", | |
365 | le32_to_cpu(iwm->last_fw_err->ilink2)); | |
366 | ||
367 | len += snprintf(buf + len, buf_len - len, | |
368 | "\tData1: 0x%x\n", | |
369 | le32_to_cpu(iwm->last_fw_err->data1)); | |
370 | ||
371 | len += snprintf(buf + len, buf_len - len, | |
372 | "\tData2: 0x%x\n", | |
373 | le32_to_cpu(iwm->last_fw_err->data2)); | |
374 | ||
375 | len += snprintf(buf + len, buf_len - len, | |
376 | "\tLine number: %d\n", | |
377 | le32_to_cpu(iwm->last_fw_err->line_num)); | |
378 | ||
379 | len += snprintf(buf + len, buf_len - len, | |
380 | "\tUMAC status: 0x%x\n", | |
381 | le32_to_cpu(iwm->last_fw_err->umac_status)); | |
382 | ||
383 | len += snprintf(buf + len, buf_len - len, | |
384 | "\tLMAC status: 0x%x\n", | |
385 | le32_to_cpu(iwm->last_fw_err->lmac_status)); | |
386 | ||
387 | len += snprintf(buf + len, buf_len - len, | |
388 | "\tSDIO status: 0x%x\n", | |
389 | le32_to_cpu(iwm->last_fw_err->sdio_status)); | |
390 | ||
391 | out: | |
392 | ||
393 | return simple_read_from_buffer(buffer, len, ppos, buf, buf_len); | |
394 | } | |
bb9f8692 ZY |
395 | |
396 | static const struct file_operations iwm_debugfs_txq_fops = { | |
397 | .owner = THIS_MODULE, | |
04e715cd | 398 | .open = iwm_generic_open, |
bb9f8692 ZY |
399 | .read = iwm_debugfs_txq_read, |
400 | }; | |
401 | ||
402 | static const struct file_operations iwm_debugfs_tx_credit_fops = { | |
403 | .owner = THIS_MODULE, | |
04e715cd | 404 | .open = iwm_generic_open, |
bb9f8692 ZY |
405 | .read = iwm_debugfs_tx_credit_read, |
406 | }; | |
407 | ||
408 | static const struct file_operations iwm_debugfs_rx_ticket_fops = { | |
409 | .owner = THIS_MODULE, | |
04e715cd | 410 | .open = iwm_generic_open, |
bb9f8692 ZY |
411 | .read = iwm_debugfs_rx_ticket_read, |
412 | }; | |
413 | ||
04e715cd SO |
414 | static const struct file_operations iwm_debugfs_fw_err_fops = { |
415 | .owner = THIS_MODULE, | |
416 | .open = iwm_generic_open, | |
417 | .read = iwm_debugfs_fw_err_read, | |
418 | }; | |
419 | ||
bb9f8692 ZY |
420 | int iwm_debugfs_init(struct iwm_priv *iwm) |
421 | { | |
422 | int i, result; | |
423 | char devdir[16]; | |
424 | ||
425 | iwm->dbg.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); | |
426 | result = PTR_ERR(iwm->dbg.rootdir); | |
427 | if (!result || IS_ERR(iwm->dbg.rootdir)) { | |
428 | if (result == -ENODEV) { | |
429 | IWM_ERR(iwm, "DebugFS (CONFIG_DEBUG_FS) not " | |
430 | "enabled in kernel config\n"); | |
431 | result = 0; /* No debugfs support */ | |
432 | } | |
433 | IWM_ERR(iwm, "Couldn't create rootdir: %d\n", result); | |
434 | goto error; | |
435 | } | |
436 | ||
437 | snprintf(devdir, sizeof(devdir), "%s", wiphy_name(iwm_to_wiphy(iwm))); | |
438 | ||
439 | iwm->dbg.devdir = debugfs_create_dir(devdir, iwm->dbg.rootdir); | |
440 | result = PTR_ERR(iwm->dbg.devdir); | |
441 | if (IS_ERR(iwm->dbg.devdir) && (result != -ENODEV)) { | |
442 | IWM_ERR(iwm, "Couldn't create devdir: %d\n", result); | |
443 | goto error; | |
444 | } | |
445 | ||
446 | iwm->dbg.dbgdir = debugfs_create_dir("debug", iwm->dbg.devdir); | |
447 | result = PTR_ERR(iwm->dbg.dbgdir); | |
448 | if (IS_ERR(iwm->dbg.dbgdir) && (result != -ENODEV)) { | |
449 | IWM_ERR(iwm, "Couldn't create dbgdir: %d\n", result); | |
450 | goto error; | |
451 | } | |
452 | ||
453 | iwm->dbg.rxdir = debugfs_create_dir("rx", iwm->dbg.devdir); | |
454 | result = PTR_ERR(iwm->dbg.rxdir); | |
455 | if (IS_ERR(iwm->dbg.rxdir) && (result != -ENODEV)) { | |
456 | IWM_ERR(iwm, "Couldn't create rx dir: %d\n", result); | |
457 | goto error; | |
458 | } | |
459 | ||
460 | iwm->dbg.txdir = debugfs_create_dir("tx", iwm->dbg.devdir); | |
461 | result = PTR_ERR(iwm->dbg.txdir); | |
462 | if (IS_ERR(iwm->dbg.txdir) && (result != -ENODEV)) { | |
463 | IWM_ERR(iwm, "Couldn't create tx dir: %d\n", result); | |
464 | goto error; | |
465 | } | |
466 | ||
467 | iwm->dbg.busdir = debugfs_create_dir("bus", iwm->dbg.devdir); | |
468 | result = PTR_ERR(iwm->dbg.busdir); | |
469 | if (IS_ERR(iwm->dbg.busdir) && (result != -ENODEV)) { | |
470 | IWM_ERR(iwm, "Couldn't create bus dir: %d\n", result); | |
471 | goto error; | |
472 | } | |
473 | ||
474 | if (iwm->bus_ops->debugfs_init) { | |
475 | result = iwm->bus_ops->debugfs_init(iwm, iwm->dbg.busdir); | |
476 | if (result < 0) { | |
477 | IWM_ERR(iwm, "Couldn't create bus entry: %d\n", result); | |
478 | goto error; | |
479 | } | |
480 | } | |
481 | ||
482 | ||
483 | iwm->dbg.dbg_level = IWM_DL_NONE; | |
484 | iwm->dbg.dbg_level_dentry = | |
485 | debugfs_create_file("level", 0200, iwm->dbg.dbgdir, iwm, | |
486 | &fops_iwm_dbg_level); | |
487 | result = PTR_ERR(iwm->dbg.dbg_level_dentry); | |
488 | if (IS_ERR(iwm->dbg.dbg_level_dentry) && (result != -ENODEV)) { | |
489 | IWM_ERR(iwm, "Couldn't create dbg_level: %d\n", result); | |
490 | goto error; | |
491 | } | |
492 | ||
493 | ||
494 | iwm->dbg.dbg_modules = IWM_DM_DEFAULT; | |
495 | iwm->dbg.dbg_modules_dentry = | |
496 | debugfs_create_file("modules", 0200, iwm->dbg.dbgdir, iwm, | |
497 | &fops_iwm_dbg_modules); | |
498 | result = PTR_ERR(iwm->dbg.dbg_modules_dentry); | |
499 | if (IS_ERR(iwm->dbg.dbg_modules_dentry) && (result != -ENODEV)) { | |
500 | IWM_ERR(iwm, "Couldn't create dbg_modules: %d\n", result); | |
501 | goto error; | |
502 | } | |
503 | ||
504 | for (i = 0; i < __IWM_DM_NR; i++) | |
505 | add_dbg_module(iwm->dbg, iwm_debug_module[i].name, | |
506 | iwm_debug_module[i].id, IWM_DL_DEFAULT); | |
507 | ||
508 | iwm->dbg.txq_dentry = debugfs_create_file("queues", 0200, | |
509 | iwm->dbg.txdir, iwm, | |
510 | &iwm_debugfs_txq_fops); | |
511 | result = PTR_ERR(iwm->dbg.txq_dentry); | |
512 | if (IS_ERR(iwm->dbg.txq_dentry) && (result != -ENODEV)) { | |
513 | IWM_ERR(iwm, "Couldn't create tx queue: %d\n", result); | |
514 | goto error; | |
515 | } | |
516 | ||
517 | iwm->dbg.tx_credit_dentry = debugfs_create_file("credits", 0200, | |
518 | iwm->dbg.txdir, iwm, | |
519 | &iwm_debugfs_tx_credit_fops); | |
520 | result = PTR_ERR(iwm->dbg.tx_credit_dentry); | |
521 | if (IS_ERR(iwm->dbg.tx_credit_dentry) && (result != -ENODEV)) { | |
522 | IWM_ERR(iwm, "Couldn't create tx credit: %d\n", result); | |
523 | goto error; | |
524 | } | |
525 | ||
526 | iwm->dbg.rx_ticket_dentry = debugfs_create_file("tickets", 0200, | |
527 | iwm->dbg.rxdir, iwm, | |
528 | &iwm_debugfs_rx_ticket_fops); | |
529 | result = PTR_ERR(iwm->dbg.rx_ticket_dentry); | |
530 | if (IS_ERR(iwm->dbg.rx_ticket_dentry) && (result != -ENODEV)) { | |
531 | IWM_ERR(iwm, "Couldn't create rx ticket: %d\n", result); | |
532 | goto error; | |
533 | } | |
534 | ||
04e715cd SO |
535 | iwm->dbg.fw_err_dentry = debugfs_create_file("last_fw_err", 0200, |
536 | iwm->dbg.dbgdir, iwm, | |
537 | &iwm_debugfs_fw_err_fops); | |
538 | result = PTR_ERR(iwm->dbg.fw_err_dentry); | |
539 | if (IS_ERR(iwm->dbg.fw_err_dentry) && (result != -ENODEV)) { | |
540 | IWM_ERR(iwm, "Couldn't create last FW err: %d\n", result); | |
541 | goto error; | |
542 | } | |
543 | ||
544 | ||
bb9f8692 ZY |
545 | return 0; |
546 | ||
547 | error: | |
548 | return result; | |
549 | } | |
550 | ||
551 | void iwm_debugfs_exit(struct iwm_priv *iwm) | |
552 | { | |
553 | int i; | |
554 | ||
555 | for (i = 0; i < __IWM_DM_NR; i++) | |
556 | debugfs_remove(iwm->dbg.dbg_module_dentries[i]); | |
557 | ||
558 | debugfs_remove(iwm->dbg.dbg_modules_dentry); | |
559 | debugfs_remove(iwm->dbg.dbg_level_dentry); | |
560 | debugfs_remove(iwm->dbg.txq_dentry); | |
561 | debugfs_remove(iwm->dbg.tx_credit_dentry); | |
562 | debugfs_remove(iwm->dbg.rx_ticket_dentry); | |
04e715cd | 563 | debugfs_remove(iwm->dbg.fw_err_dentry); |
bb9f8692 ZY |
564 | if (iwm->bus_ops->debugfs_exit) |
565 | iwm->bus_ops->debugfs_exit(iwm); | |
566 | ||
567 | debugfs_remove(iwm->dbg.busdir); | |
568 | debugfs_remove(iwm->dbg.dbgdir); | |
569 | debugfs_remove(iwm->dbg.txdir); | |
570 | debugfs_remove(iwm->dbg.rxdir); | |
571 | debugfs_remove(iwm->dbg.devdir); | |
572 | debugfs_remove(iwm->dbg.rootdir); | |
573 | } |