cfg80211: add scan flag to indicate its priority
[deliverable/linux.git] / drivers / net / wireless / mwifiex / debugfs.c
1 /*
2 * Marvell Wireless LAN device driver: debugfs
3 *
4 * Copyright (C) 2011, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
18 */
19
20 #include <linux/debugfs.h>
21
22 #include "main.h"
23 #include "11n.h"
24
25
26 static struct dentry *mwifiex_dfs_dir;
27
28 static char *bss_modes[] = {
29 "Unknown",
30 "Ad-hoc",
31 "Managed",
32 "Auto"
33 };
34
35 /* size/addr for mwifiex_debug_info */
36 #define item_size(n) (FIELD_SIZEOF(struct mwifiex_debug_info, n))
37 #define item_addr(n) (offsetof(struct mwifiex_debug_info, n))
38
39 /* size/addr for struct mwifiex_adapter */
40 #define adapter_item_size(n) (FIELD_SIZEOF(struct mwifiex_adapter, n))
41 #define adapter_item_addr(n) (offsetof(struct mwifiex_adapter, n))
42
43 struct mwifiex_debug_data {
44 char name[32]; /* variable/array name */
45 u32 size; /* size of the variable/array */
46 size_t addr; /* address of the variable/array */
47 int num; /* number of variables in an array */
48 };
49
50 static struct mwifiex_debug_data items[] = {
51 {"int_counter", item_size(int_counter),
52 item_addr(int_counter), 1},
53 {"wmm_ac_vo", item_size(packets_out[WMM_AC_VO]),
54 item_addr(packets_out[WMM_AC_VO]), 1},
55 {"wmm_ac_vi", item_size(packets_out[WMM_AC_VI]),
56 item_addr(packets_out[WMM_AC_VI]), 1},
57 {"wmm_ac_be", item_size(packets_out[WMM_AC_BE]),
58 item_addr(packets_out[WMM_AC_BE]), 1},
59 {"wmm_ac_bk", item_size(packets_out[WMM_AC_BK]),
60 item_addr(packets_out[WMM_AC_BK]), 1},
61 {"max_tx_buf_size", item_size(max_tx_buf_size),
62 item_addr(max_tx_buf_size), 1},
63 {"tx_buf_size", item_size(tx_buf_size),
64 item_addr(tx_buf_size), 1},
65 {"curr_tx_buf_size", item_size(curr_tx_buf_size),
66 item_addr(curr_tx_buf_size), 1},
67 {"ps_mode", item_size(ps_mode),
68 item_addr(ps_mode), 1},
69 {"ps_state", item_size(ps_state),
70 item_addr(ps_state), 1},
71 {"is_deep_sleep", item_size(is_deep_sleep),
72 item_addr(is_deep_sleep), 1},
73 {"wakeup_dev_req", item_size(pm_wakeup_card_req),
74 item_addr(pm_wakeup_card_req), 1},
75 {"wakeup_tries", item_size(pm_wakeup_fw_try),
76 item_addr(pm_wakeup_fw_try), 1},
77 {"hs_configured", item_size(is_hs_configured),
78 item_addr(is_hs_configured), 1},
79 {"hs_activated", item_size(hs_activated),
80 item_addr(hs_activated), 1},
81 {"num_tx_timeout", item_size(num_tx_timeout),
82 item_addr(num_tx_timeout), 1},
83 {"num_cmd_timeout", item_size(num_cmd_timeout),
84 item_addr(num_cmd_timeout), 1},
85 {"timeout_cmd_id", item_size(timeout_cmd_id),
86 item_addr(timeout_cmd_id), 1},
87 {"timeout_cmd_act", item_size(timeout_cmd_act),
88 item_addr(timeout_cmd_act), 1},
89 {"last_cmd_id", item_size(last_cmd_id),
90 item_addr(last_cmd_id), DBG_CMD_NUM},
91 {"last_cmd_act", item_size(last_cmd_act),
92 item_addr(last_cmd_act), DBG_CMD_NUM},
93 {"last_cmd_index", item_size(last_cmd_index),
94 item_addr(last_cmd_index), 1},
95 {"last_cmd_resp_id", item_size(last_cmd_resp_id),
96 item_addr(last_cmd_resp_id), DBG_CMD_NUM},
97 {"last_cmd_resp_index", item_size(last_cmd_resp_index),
98 item_addr(last_cmd_resp_index), 1},
99 {"last_event", item_size(last_event),
100 item_addr(last_event), DBG_CMD_NUM},
101 {"last_event_index", item_size(last_event_index),
102 item_addr(last_event_index), 1},
103 {"num_cmd_h2c_fail", item_size(num_cmd_host_to_card_failure),
104 item_addr(num_cmd_host_to_card_failure), 1},
105 {"num_cmd_sleep_cfm_fail",
106 item_size(num_cmd_sleep_cfm_host_to_card_failure),
107 item_addr(num_cmd_sleep_cfm_host_to_card_failure), 1},
108 {"num_tx_h2c_fail", item_size(num_tx_host_to_card_failure),
109 item_addr(num_tx_host_to_card_failure), 1},
110 {"num_evt_deauth", item_size(num_event_deauth),
111 item_addr(num_event_deauth), 1},
112 {"num_evt_disassoc", item_size(num_event_disassoc),
113 item_addr(num_event_disassoc), 1},
114 {"num_evt_link_lost", item_size(num_event_link_lost),
115 item_addr(num_event_link_lost), 1},
116 {"num_cmd_deauth", item_size(num_cmd_deauth),
117 item_addr(num_cmd_deauth), 1},
118 {"num_cmd_assoc_ok", item_size(num_cmd_assoc_success),
119 item_addr(num_cmd_assoc_success), 1},
120 {"num_cmd_assoc_fail", item_size(num_cmd_assoc_failure),
121 item_addr(num_cmd_assoc_failure), 1},
122 {"cmd_sent", item_size(cmd_sent),
123 item_addr(cmd_sent), 1},
124 {"data_sent", item_size(data_sent),
125 item_addr(data_sent), 1},
126 {"cmd_resp_received", item_size(cmd_resp_received),
127 item_addr(cmd_resp_received), 1},
128 {"event_received", item_size(event_received),
129 item_addr(event_received), 1},
130
131 /* variables defined in struct mwifiex_adapter */
132 {"cmd_pending", adapter_item_size(cmd_pending),
133 adapter_item_addr(cmd_pending), 1},
134 {"tx_pending", adapter_item_size(tx_pending),
135 adapter_item_addr(tx_pending), 1},
136 {"rx_pending", adapter_item_size(rx_pending),
137 adapter_item_addr(rx_pending), 1},
138 };
139
140 static int num_of_items = ARRAY_SIZE(items);
141
142 /*
143 * Proc info file read handler.
144 *
145 * This function is called when the 'info' file is opened for reading.
146 * It prints the following driver related information -
147 * - Driver name
148 * - Driver version
149 * - Driver extended version
150 * - Interface name
151 * - BSS mode
152 * - Media state (connected or disconnected)
153 * - MAC address
154 * - Total number of Tx bytes
155 * - Total number of Rx bytes
156 * - Total number of Tx packets
157 * - Total number of Rx packets
158 * - Total number of dropped Tx packets
159 * - Total number of dropped Rx packets
160 * - Total number of corrupted Tx packets
161 * - Total number of corrupted Rx packets
162 * - Carrier status (on or off)
163 * - Tx queue status (started or stopped)
164 *
165 * For STA mode drivers, it also prints the following extra -
166 * - ESSID
167 * - BSSID
168 * - Channel
169 * - Region code
170 * - Multicast count
171 * - Multicast addresses
172 */
173 static ssize_t
174 mwifiex_info_read(struct file *file, char __user *ubuf,
175 size_t count, loff_t *ppos)
176 {
177 struct mwifiex_private *priv =
178 (struct mwifiex_private *) file->private_data;
179 struct net_device *netdev = priv->netdev;
180 struct netdev_hw_addr *ha;
181 unsigned long page = get_zeroed_page(GFP_KERNEL);
182 char *p = (char *) page, fmt[64];
183 struct mwifiex_bss_info info;
184 ssize_t ret;
185 int i = 0;
186
187 if (!p)
188 return -ENOMEM;
189
190 memset(&info, 0, sizeof(info));
191 ret = mwifiex_get_bss_info(priv, &info);
192 if (ret)
193 goto free_and_exit;
194
195 mwifiex_drv_get_driver_version(priv->adapter, fmt, sizeof(fmt) - 1);
196
197 if (!priv->version_str[0])
198 mwifiex_get_ver_ext(priv);
199
200 p += sprintf(p, "driver_name = " "\"mwifiex\"\n");
201 p += sprintf(p, "driver_version = %s", fmt);
202 p += sprintf(p, "\nverext = %s", priv->version_str);
203 p += sprintf(p, "\ninterface_name=\"%s\"\n", netdev->name);
204 p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
205 p += sprintf(p, "media_state=\"%s\"\n",
206 (!priv->media_connected ? "Disconnected" : "Connected"));
207 p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr);
208
209 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) {
210 p += sprintf(p, "multicast_count=\"%d\"\n",
211 netdev_mc_count(netdev));
212 p += sprintf(p, "essid=\"%s\"\n", info.ssid.ssid);
213 p += sprintf(p, "bssid=\"%pM\"\n", info.bssid);
214 p += sprintf(p, "channel=\"%d\"\n", (int) info.bss_chan);
215 p += sprintf(p, "country_code = \"%s\"\n", info.country_code);
216
217 netdev_for_each_mc_addr(ha, netdev)
218 p += sprintf(p, "multicast_address[%d]=\"%pM\"\n",
219 i++, ha->addr);
220 }
221
222 p += sprintf(p, "num_tx_bytes = %lu\n", priv->stats.tx_bytes);
223 p += sprintf(p, "num_rx_bytes = %lu\n", priv->stats.rx_bytes);
224 p += sprintf(p, "num_tx_pkts = %lu\n", priv->stats.tx_packets);
225 p += sprintf(p, "num_rx_pkts = %lu\n", priv->stats.rx_packets);
226 p += sprintf(p, "num_tx_pkts_dropped = %lu\n", priv->stats.tx_dropped);
227 p += sprintf(p, "num_rx_pkts_dropped = %lu\n", priv->stats.rx_dropped);
228 p += sprintf(p, "num_tx_pkts_err = %lu\n", priv->stats.tx_errors);
229 p += sprintf(p, "num_rx_pkts_err = %lu\n", priv->stats.rx_errors);
230 p += sprintf(p, "carrier %s\n", ((netif_carrier_ok(priv->netdev))
231 ? "on" : "off"));
232 p += sprintf(p, "tx queue %s\n", ((netif_queue_stopped(priv->netdev))
233 ? "stopped" : "started"));
234
235 ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
236 (unsigned long) p - page);
237
238 free_and_exit:
239 free_page(page);
240 return ret;
241 }
242
243 /*
244 * Proc getlog file read handler.
245 *
246 * This function is called when the 'getlog' file is opened for reading
247 * It prints the following log information -
248 * - Number of multicast Tx frames
249 * - Number of failed packets
250 * - Number of Tx retries
251 * - Number of multicast Tx retries
252 * - Number of duplicate frames
253 * - Number of RTS successes
254 * - Number of RTS failures
255 * - Number of ACK failures
256 * - Number of fragmented Rx frames
257 * - Number of multicast Rx frames
258 * - Number of FCS errors
259 * - Number of Tx frames
260 * - WEP ICV error counts
261 */
262 static ssize_t
263 mwifiex_getlog_read(struct file *file, char __user *ubuf,
264 size_t count, loff_t *ppos)
265 {
266 struct mwifiex_private *priv =
267 (struct mwifiex_private *) file->private_data;
268 unsigned long page = get_zeroed_page(GFP_KERNEL);
269 char *p = (char *) page;
270 ssize_t ret;
271 struct mwifiex_ds_get_stats stats;
272
273 if (!p)
274 return -ENOMEM;
275
276 memset(&stats, 0, sizeof(stats));
277 ret = mwifiex_get_stats_info(priv, &stats);
278 if (ret)
279 goto free_and_exit;
280
281 p += sprintf(p, "\n"
282 "mcasttxframe %u\n"
283 "failed %u\n"
284 "retry %u\n"
285 "multiretry %u\n"
286 "framedup %u\n"
287 "rtssuccess %u\n"
288 "rtsfailure %u\n"
289 "ackfailure %u\n"
290 "rxfrag %u\n"
291 "mcastrxframe %u\n"
292 "fcserror %u\n"
293 "txframe %u\n"
294 "wepicverrcnt-1 %u\n"
295 "wepicverrcnt-2 %u\n"
296 "wepicverrcnt-3 %u\n"
297 "wepicverrcnt-4 %u\n",
298 stats.mcast_tx_frame,
299 stats.failed,
300 stats.retry,
301 stats.multi_retry,
302 stats.frame_dup,
303 stats.rts_success,
304 stats.rts_failure,
305 stats.ack_failure,
306 stats.rx_frag,
307 stats.mcast_rx_frame,
308 stats.fcs_error,
309 stats.tx_frame,
310 stats.wep_icv_error[0],
311 stats.wep_icv_error[1],
312 stats.wep_icv_error[2],
313 stats.wep_icv_error[3]);
314
315
316 ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
317 (unsigned long) p - page);
318
319 free_and_exit:
320 free_page(page);
321 return ret;
322 }
323
324 static struct mwifiex_debug_info info;
325
326 /*
327 * Proc debug file read handler.
328 *
329 * This function is called when the 'debug' file is opened for reading
330 * It prints the following log information -
331 * - Interrupt count
332 * - WMM AC VO packets count
333 * - WMM AC VI packets count
334 * - WMM AC BE packets count
335 * - WMM AC BK packets count
336 * - Maximum Tx buffer size
337 * - Tx buffer size
338 * - Current Tx buffer size
339 * - Power Save mode
340 * - Power Save state
341 * - Deep Sleep status
342 * - Device wakeup required status
343 * - Number of wakeup tries
344 * - Host Sleep configured status
345 * - Host Sleep activated status
346 * - Number of Tx timeouts
347 * - Number of command timeouts
348 * - Last timed out command ID
349 * - Last timed out command action
350 * - Last command ID
351 * - Last command action
352 * - Last command index
353 * - Last command response ID
354 * - Last command response index
355 * - Last event
356 * - Last event index
357 * - Number of host to card command failures
358 * - Number of sleep confirm command failures
359 * - Number of host to card data failure
360 * - Number of deauthentication events
361 * - Number of disassociation events
362 * - Number of link lost events
363 * - Number of deauthentication commands
364 * - Number of association success commands
365 * - Number of association failure commands
366 * - Number of commands sent
367 * - Number of data packets sent
368 * - Number of command responses received
369 * - Number of events received
370 * - Tx BA stream table (TID, RA)
371 * - Rx reorder table (TID, TA, Start window, Window size, Buffer)
372 */
373 static ssize_t
374 mwifiex_debug_read(struct file *file, char __user *ubuf,
375 size_t count, loff_t *ppos)
376 {
377 struct mwifiex_private *priv =
378 (struct mwifiex_private *) file->private_data;
379 struct mwifiex_debug_data *d = &items[0];
380 unsigned long page = get_zeroed_page(GFP_KERNEL);
381 char *p = (char *) page;
382 ssize_t ret;
383 size_t size, addr;
384 long val;
385 int i, j;
386
387 if (!p)
388 return -ENOMEM;
389
390 ret = mwifiex_get_debug_info(priv, &info);
391 if (ret)
392 goto free_and_exit;
393
394 for (i = 0; i < num_of_items; i++) {
395 p += sprintf(p, "%s=", d[i].name);
396
397 size = d[i].size / d[i].num;
398
399 if (i < (num_of_items - 3))
400 addr = d[i].addr + (size_t) &info;
401 else /* The last 3 items are struct mwifiex_adapter variables */
402 addr = d[i].addr + (size_t) priv->adapter;
403
404 for (j = 0; j < d[i].num; j++) {
405 switch (size) {
406 case 1:
407 val = *((u8 *) addr);
408 break;
409 case 2:
410 val = *((u16 *) addr);
411 break;
412 case 4:
413 val = *((u32 *) addr);
414 break;
415 case 8:
416 val = *((long long *) addr);
417 break;
418 default:
419 val = -1;
420 break;
421 }
422
423 p += sprintf(p, "%#lx ", val);
424 addr += size;
425 }
426
427 p += sprintf(p, "\n");
428 }
429
430 if (info.tx_tbl_num) {
431 p += sprintf(p, "Tx BA stream table:\n");
432 for (i = 0; i < info.tx_tbl_num; i++)
433 p += sprintf(p, "tid = %d, ra = %pM\n",
434 info.tx_tbl[i].tid, info.tx_tbl[i].ra);
435 }
436
437 if (info.rx_tbl_num) {
438 p += sprintf(p, "Rx reorder table:\n");
439 for (i = 0; i < info.rx_tbl_num; i++) {
440 p += sprintf(p, "tid = %d, ta = %pM, "
441 "start_win = %d, "
442 "win_size = %d, buffer: ",
443 info.rx_tbl[i].tid,
444 info.rx_tbl[i].ta,
445 info.rx_tbl[i].start_win,
446 info.rx_tbl[i].win_size);
447
448 for (j = 0; j < info.rx_tbl[i].win_size; j++)
449 p += sprintf(p, "%c ",
450 info.rx_tbl[i].buffer[j] ?
451 '1' : '0');
452
453 p += sprintf(p, "\n");
454 }
455 }
456
457 ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
458 (unsigned long) p - page);
459
460 free_and_exit:
461 free_page(page);
462 return ret;
463 }
464
465 static u32 saved_reg_type, saved_reg_offset, saved_reg_value;
466
467 /*
468 * Proc regrdwr file write handler.
469 *
470 * This function is called when the 'regrdwr' file is opened for writing
471 *
472 * This function can be used to write to a register.
473 */
474 static ssize_t
475 mwifiex_regrdwr_write(struct file *file,
476 const char __user *ubuf, size_t count, loff_t *ppos)
477 {
478 unsigned long addr = get_zeroed_page(GFP_KERNEL);
479 char *buf = (char *) addr;
480 size_t buf_size = min(count, (size_t) (PAGE_SIZE - 1));
481 int ret;
482 u32 reg_type = 0, reg_offset = 0, reg_value = UINT_MAX;
483
484 if (!buf)
485 return -ENOMEM;
486
487
488 if (copy_from_user(buf, ubuf, buf_size)) {
489 ret = -EFAULT;
490 goto done;
491 }
492
493 sscanf(buf, "%u %x %x", &reg_type, &reg_offset, &reg_value);
494
495 if (reg_type == 0 || reg_offset == 0) {
496 ret = -EINVAL;
497 goto done;
498 } else {
499 saved_reg_type = reg_type;
500 saved_reg_offset = reg_offset;
501 saved_reg_value = reg_value;
502 ret = count;
503 }
504 done:
505 free_page(addr);
506 return ret;
507 }
508
509 /*
510 * Proc regrdwr file read handler.
511 *
512 * This function is called when the 'regrdwr' file is opened for reading
513 *
514 * This function can be used to read from a register.
515 */
516 static ssize_t
517 mwifiex_regrdwr_read(struct file *file, char __user *ubuf,
518 size_t count, loff_t *ppos)
519 {
520 struct mwifiex_private *priv =
521 (struct mwifiex_private *) file->private_data;
522 unsigned long addr = get_zeroed_page(GFP_KERNEL);
523 char *buf = (char *) addr;
524 int pos = 0, ret = 0;
525 u32 reg_value;
526
527 if (!buf)
528 return -ENOMEM;
529
530 if (!saved_reg_type) {
531 /* No command has been given */
532 pos += snprintf(buf, PAGE_SIZE, "0");
533 goto done;
534 }
535 /* Set command has been given */
536 if (saved_reg_value != UINT_MAX) {
537 ret = mwifiex_reg_write(priv, saved_reg_type, saved_reg_offset,
538 saved_reg_value);
539
540 pos += snprintf(buf, PAGE_SIZE, "%u 0x%x 0x%x\n",
541 saved_reg_type, saved_reg_offset,
542 saved_reg_value);
543
544 ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
545
546 goto done;
547 }
548 /* Get command has been given */
549 ret = mwifiex_reg_read(priv, saved_reg_type,
550 saved_reg_offset, &reg_value);
551 if (ret) {
552 ret = -EINVAL;
553 goto done;
554 }
555
556 pos += snprintf(buf, PAGE_SIZE, "%u 0x%x 0x%x\n", saved_reg_type,
557 saved_reg_offset, reg_value);
558
559 ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
560
561 done:
562 free_page(addr);
563 return ret;
564 }
565
566 static u32 saved_offset = -1, saved_bytes = -1;
567
568 /*
569 * Proc rdeeprom file write handler.
570 *
571 * This function is called when the 'rdeeprom' file is opened for writing
572 *
573 * This function can be used to write to a RDEEPROM location.
574 */
575 static ssize_t
576 mwifiex_rdeeprom_write(struct file *file,
577 const char __user *ubuf, size_t count, loff_t *ppos)
578 {
579 unsigned long addr = get_zeroed_page(GFP_KERNEL);
580 char *buf = (char *) addr;
581 size_t buf_size = min(count, (size_t) (PAGE_SIZE - 1));
582 int ret = 0;
583 int offset = -1, bytes = -1;
584
585 if (!buf)
586 return -ENOMEM;
587
588
589 if (copy_from_user(buf, ubuf, buf_size)) {
590 ret = -EFAULT;
591 goto done;
592 }
593
594 sscanf(buf, "%d %d", &offset, &bytes);
595
596 if (offset == -1 || bytes == -1) {
597 ret = -EINVAL;
598 goto done;
599 } else {
600 saved_offset = offset;
601 saved_bytes = bytes;
602 ret = count;
603 }
604 done:
605 free_page(addr);
606 return ret;
607 }
608
609 /*
610 * Proc rdeeprom read write handler.
611 *
612 * This function is called when the 'rdeeprom' file is opened for reading
613 *
614 * This function can be used to read from a RDEEPROM location.
615 */
616 static ssize_t
617 mwifiex_rdeeprom_read(struct file *file, char __user *ubuf,
618 size_t count, loff_t *ppos)
619 {
620 struct mwifiex_private *priv =
621 (struct mwifiex_private *) file->private_data;
622 unsigned long addr = get_zeroed_page(GFP_KERNEL);
623 char *buf = (char *) addr;
624 int pos = 0, ret = 0, i;
625 u8 value[MAX_EEPROM_DATA];
626
627 if (!buf)
628 return -ENOMEM;
629
630 if (saved_offset == -1) {
631 /* No command has been given */
632 pos += snprintf(buf, PAGE_SIZE, "0");
633 goto done;
634 }
635
636 /* Get command has been given */
637 ret = mwifiex_eeprom_read(priv, (u16) saved_offset,
638 (u16) saved_bytes, value);
639 if (ret) {
640 ret = -EINVAL;
641 goto done;
642 }
643
644 pos += snprintf(buf, PAGE_SIZE, "%d %d ", saved_offset, saved_bytes);
645
646 for (i = 0; i < saved_bytes; i++)
647 pos += snprintf(buf + strlen(buf), PAGE_SIZE, "%d ", value[i]);
648
649 ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
650
651 done:
652 free_page(addr);
653 return ret;
654 }
655
656
657 #define MWIFIEX_DFS_ADD_FILE(name) do { \
658 if (!debugfs_create_file(#name, 0644, priv->dfs_dev_dir, \
659 priv, &mwifiex_dfs_##name##_fops)) \
660 return; \
661 } while (0);
662
663 #define MWIFIEX_DFS_FILE_OPS(name) \
664 static const struct file_operations mwifiex_dfs_##name##_fops = { \
665 .read = mwifiex_##name##_read, \
666 .write = mwifiex_##name##_write, \
667 .open = simple_open, \
668 };
669
670 #define MWIFIEX_DFS_FILE_READ_OPS(name) \
671 static const struct file_operations mwifiex_dfs_##name##_fops = { \
672 .read = mwifiex_##name##_read, \
673 .open = simple_open, \
674 };
675
676 #define MWIFIEX_DFS_FILE_WRITE_OPS(name) \
677 static const struct file_operations mwifiex_dfs_##name##_fops = { \
678 .write = mwifiex_##name##_write, \
679 .open = simple_open, \
680 };
681
682
683 MWIFIEX_DFS_FILE_READ_OPS(info);
684 MWIFIEX_DFS_FILE_READ_OPS(debug);
685 MWIFIEX_DFS_FILE_READ_OPS(getlog);
686 MWIFIEX_DFS_FILE_OPS(regrdwr);
687 MWIFIEX_DFS_FILE_OPS(rdeeprom);
688
689 /*
690 * This function creates the debug FS directory structure and the files.
691 */
692 void
693 mwifiex_dev_debugfs_init(struct mwifiex_private *priv)
694 {
695 if (!mwifiex_dfs_dir || !priv)
696 return;
697
698 priv->dfs_dev_dir = debugfs_create_dir(priv->netdev->name,
699 mwifiex_dfs_dir);
700
701 if (!priv->dfs_dev_dir)
702 return;
703
704 MWIFIEX_DFS_ADD_FILE(info);
705 MWIFIEX_DFS_ADD_FILE(debug);
706 MWIFIEX_DFS_ADD_FILE(getlog);
707 MWIFIEX_DFS_ADD_FILE(regrdwr);
708 MWIFIEX_DFS_ADD_FILE(rdeeprom);
709 }
710
711 /*
712 * This function removes the debug FS directory structure and the files.
713 */
714 void
715 mwifiex_dev_debugfs_remove(struct mwifiex_private *priv)
716 {
717 if (!priv)
718 return;
719
720 debugfs_remove_recursive(priv->dfs_dev_dir);
721 }
722
723 /*
724 * This function creates the top level proc directory.
725 */
726 void
727 mwifiex_debugfs_init(void)
728 {
729 if (!mwifiex_dfs_dir)
730 mwifiex_dfs_dir = debugfs_create_dir("mwifiex", NULL);
731 }
732
733 /*
734 * This function removes the top level proc directory.
735 */
736 void
737 mwifiex_debugfs_remove(void)
738 {
739 if (mwifiex_dfs_dir)
740 debugfs_remove(mwifiex_dfs_dir);
741 }
This page took 0.046644 seconds and 5 git commands to generate.