2 * Marvell Wireless LAN device driver: debugfs
4 * Copyright (C) 2011-2014, Marvell International Ltd.
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.
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.
20 #include <linux/debugfs.h>
26 static struct dentry
*mwifiex_dfs_dir
;
28 static char *bss_modes
[] = {
43 * Proc info file read handler.
45 * This function is called when the 'info' file is opened for reading.
46 * It prints the following driver related information -
49 * - Driver extended version
52 * - Media state (connected or disconnected)
54 * - Total number of Tx bytes
55 * - Total number of Rx bytes
56 * - Total number of Tx packets
57 * - Total number of Rx packets
58 * - Total number of dropped Tx packets
59 * - Total number of dropped Rx packets
60 * - Total number of corrupted Tx packets
61 * - Total number of corrupted Rx packets
62 * - Carrier status (on or off)
63 * - Tx queue status (started or stopped)
65 * For STA mode drivers, it also prints the following extra -
71 * - Multicast addresses
74 mwifiex_info_read(struct file
*file
, char __user
*ubuf
,
75 size_t count
, loff_t
*ppos
)
77 struct mwifiex_private
*priv
=
78 (struct mwifiex_private
*) file
->private_data
;
79 struct net_device
*netdev
= priv
->netdev
;
80 struct netdev_hw_addr
*ha
;
81 struct netdev_queue
*txq
;
82 unsigned long page
= get_zeroed_page(GFP_KERNEL
);
83 char *p
= (char *) page
, fmt
[64];
84 struct mwifiex_bss_info info
;
91 memset(&info
, 0, sizeof(info
));
92 ret
= mwifiex_get_bss_info(priv
, &info
);
96 mwifiex_drv_get_driver_version(priv
->adapter
, fmt
, sizeof(fmt
) - 1);
98 mwifiex_get_ver_ext(priv
, 0);
100 p
+= sprintf(p
, "driver_name = " "\"mwifiex\"\n");
101 p
+= sprintf(p
, "driver_version = %s", fmt
);
102 p
+= sprintf(p
, "\nverext = %s", priv
->version_str
);
103 p
+= sprintf(p
, "\ninterface_name=\"%s\"\n", netdev
->name
);
105 if (info
.bss_mode
>= ARRAY_SIZE(bss_modes
))
106 p
+= sprintf(p
, "bss_mode=\"%d\"\n", info
.bss_mode
);
108 p
+= sprintf(p
, "bss_mode=\"%s\"\n", bss_modes
[info
.bss_mode
]);
110 p
+= sprintf(p
, "media_state=\"%s\"\n",
111 (!priv
->media_connected
? "Disconnected" : "Connected"));
112 p
+= sprintf(p
, "mac_address=\"%pM\"\n", netdev
->dev_addr
);
114 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) {
115 p
+= sprintf(p
, "multicast_count=\"%d\"\n",
116 netdev_mc_count(netdev
));
117 p
+= sprintf(p
, "essid=\"%.*s\"\n", info
.ssid
.ssid_len
,
119 p
+= sprintf(p
, "bssid=\"%pM\"\n", info
.bssid
);
120 p
+= sprintf(p
, "channel=\"%d\"\n", (int) info
.bss_chan
);
121 p
+= sprintf(p
, "country_code = \"%s\"\n", info
.country_code
);
122 p
+= sprintf(p
, "region_code=\"0x%x\"\n",
123 priv
->adapter
->region_code
);
125 netdev_for_each_mc_addr(ha
, netdev
)
126 p
+= sprintf(p
, "multicast_address[%d]=\"%pM\"\n",
130 p
+= sprintf(p
, "num_tx_bytes = %lu\n", priv
->stats
.tx_bytes
);
131 p
+= sprintf(p
, "num_rx_bytes = %lu\n", priv
->stats
.rx_bytes
);
132 p
+= sprintf(p
, "num_tx_pkts = %lu\n", priv
->stats
.tx_packets
);
133 p
+= sprintf(p
, "num_rx_pkts = %lu\n", priv
->stats
.rx_packets
);
134 p
+= sprintf(p
, "num_tx_pkts_dropped = %lu\n", priv
->stats
.tx_dropped
);
135 p
+= sprintf(p
, "num_rx_pkts_dropped = %lu\n", priv
->stats
.rx_dropped
);
136 p
+= sprintf(p
, "num_tx_pkts_err = %lu\n", priv
->stats
.tx_errors
);
137 p
+= sprintf(p
, "num_rx_pkts_err = %lu\n", priv
->stats
.rx_errors
);
138 p
+= sprintf(p
, "carrier %s\n", ((netif_carrier_ok(priv
->netdev
))
140 p
+= sprintf(p
, "tx queue");
141 for (i
= 0; i
< netdev
->num_tx_queues
; i
++) {
142 txq
= netdev_get_tx_queue(netdev
, i
);
143 p
+= sprintf(p
, " %d:%s", i
, netif_tx_queue_stopped(txq
) ?
144 "stopped" : "started");
146 p
+= sprintf(p
, "\n");
148 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, (char *) page
,
149 (unsigned long) p
- page
);
157 * Proc device dump read handler.
159 * This function is called when the 'device_dump' file is opened for
161 * This function dumps driver information and firmware memory segments
162 * (ex. DTCM, ITCM, SQRAM etc.) for
166 mwifiex_device_dump_read(struct file
*file
, char __user
*ubuf
,
167 size_t count
, loff_t
*ppos
)
169 struct mwifiex_private
*priv
= file
->private_data
;
171 /* For command timeouts, USB firmware will automatically emit
172 * firmware dump events, so we don't implement device_dump().
173 * For user-initiated dumps, we trigger it ourselves.
175 if (priv
->adapter
->iface_type
== MWIFIEX_USB
)
176 mwifiex_send_cmd(priv
, HostCmd_CMD_FW_DUMP_EVENT
,
177 HostCmd_ACT_GEN_SET
, 0, NULL
, true);
179 priv
->adapter
->if_ops
.device_dump(priv
->adapter
);
185 * Proc getlog file read handler.
187 * This function is called when the 'getlog' file is opened for reading
188 * It prints the following log information -
189 * - Number of multicast Tx frames
190 * - Number of failed packets
191 * - Number of Tx retries
192 * - Number of multicast Tx retries
193 * - Number of duplicate frames
194 * - Number of RTS successes
195 * - Number of RTS failures
196 * - Number of ACK failures
197 * - Number of fragmented Rx frames
198 * - Number of multicast Rx frames
199 * - Number of FCS errors
200 * - Number of Tx frames
201 * - WEP ICV error counts
202 * - Number of received beacons
203 * - Number of missed beacons
206 mwifiex_getlog_read(struct file
*file
, char __user
*ubuf
,
207 size_t count
, loff_t
*ppos
)
209 struct mwifiex_private
*priv
=
210 (struct mwifiex_private
*) file
->private_data
;
211 unsigned long page
= get_zeroed_page(GFP_KERNEL
);
212 char *p
= (char *) page
;
214 struct mwifiex_ds_get_stats stats
;
219 memset(&stats
, 0, sizeof(stats
));
220 ret
= mwifiex_get_stats_info(priv
, &stats
);
237 "wepicverrcnt-1 %u\n"
238 "wepicverrcnt-2 %u\n"
239 "wepicverrcnt-3 %u\n"
240 "wepicverrcnt-4 %u\n"
243 stats
.mcast_tx_frame
,
252 stats
.mcast_rx_frame
,
255 stats
.wep_icv_error
[0],
256 stats
.wep_icv_error
[1],
257 stats
.wep_icv_error
[2],
258 stats
.wep_icv_error
[3],
263 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, (char *) page
,
264 (unsigned long) p
- page
);
271 /* Sysfs histogram file read handler.
273 * This function is called when the 'histogram' file is opened for reading
274 * It prints the following histogram information -
275 * - Number of histogram samples
276 * - Receive packet number of each rx_rate
277 * - Receive packet number of each snr
278 * - Receive packet number of each nosie_flr
279 * - Receive packet number of each signal streath
282 mwifiex_histogram_read(struct file
*file
, char __user
*ubuf
,
283 size_t count
, loff_t
*ppos
)
285 struct mwifiex_private
*priv
=
286 (struct mwifiex_private
*)file
->private_data
;
288 struct mwifiex_histogram_data
*phist_data
;
290 unsigned long page
= get_zeroed_page(GFP_KERNEL
);
291 char *p
= (char *)page
;
296 if (!priv
|| !priv
->hist_data
)
298 phist_data
= priv
->hist_data
;
301 "total samples = %d\n",
302 atomic_read(&phist_data
->num_samples
));
304 p
+= sprintf(p
, "rx rates (in Mbps): 0=1M 1=2M");
305 p
+= sprintf(p
, "2=5.5M 3=11M 4=6M 5=9M 6=12M\n");
306 p
+= sprintf(p
, "7=18M 8=24M 9=36M 10=48M 11=54M");
307 p
+= sprintf(p
, "12-27=MCS0-15(BW20) 28-43=MCS0-15(BW40)\n");
309 if (ISSUPP_11ACENABLED(priv
->adapter
->fw_cap_info
)) {
310 p
+= sprintf(p
, "44-53=MCS0-9(VHT:BW20)");
311 p
+= sprintf(p
, "54-63=MCS0-9(VHT:BW40)");
312 p
+= sprintf(p
, "64-73=MCS0-9(VHT:BW80)\n\n");
314 p
+= sprintf(p
, "\n");
317 for (i
= 0; i
< MWIFIEX_MAX_RX_RATES
; i
++) {
318 value
= atomic_read(&phist_data
->rx_rate
[i
]);
320 p
+= sprintf(p
, "rx_rate[%02d] = %d\n", i
, value
);
323 if (ISSUPP_11ACENABLED(priv
->adapter
->fw_cap_info
)) {
324 for (i
= MWIFIEX_MAX_RX_RATES
; i
< MWIFIEX_MAX_AC_RX_RATES
;
326 value
= atomic_read(&phist_data
->rx_rate
[i
]);
328 p
+= sprintf(p
, "rx_rate[%02d] = %d\n",
333 for (i
= 0; i
< MWIFIEX_MAX_SNR
; i
++) {
334 value
= atomic_read(&phist_data
->snr
[i
]);
336 p
+= sprintf(p
, "snr[%02ddB] = %d\n", i
, value
);
338 for (i
= 0; i
< MWIFIEX_MAX_NOISE_FLR
; i
++) {
339 value
= atomic_read(&phist_data
->noise_flr
[i
]);
341 p
+= sprintf(p
, "noise_flr[-%02ddBm] = %d\n",
342 (int)(i
-128), value
);
344 for (i
= 0; i
< MWIFIEX_MAX_SIG_STRENGTH
; i
++) {
345 value
= atomic_read(&phist_data
->sig_str
[i
]);
347 p
+= sprintf(p
, "sig_strength[-%02ddBm] = %d\n",
351 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, (char *)page
,
352 (unsigned long)p
- page
);
358 mwifiex_histogram_write(struct file
*file
, const char __user
*ubuf
,
359 size_t count
, loff_t
*ppos
)
361 struct mwifiex_private
*priv
= (void *)file
->private_data
;
363 if (priv
&& priv
->hist_data
)
364 mwifiex_hist_data_reset(priv
);
368 static struct mwifiex_debug_info info
;
371 * Proc debug file read handler.
373 * This function is called when the 'debug' file is opened for reading
374 * It prints the following log information -
376 * - WMM AC VO packets count
377 * - WMM AC VI packets count
378 * - WMM AC BE packets count
379 * - WMM AC BK packets count
380 * - Maximum Tx buffer size
382 * - Current Tx buffer size
385 * - Deep Sleep status
386 * - Device wakeup required status
387 * - Number of wakeup tries
388 * - Host Sleep configured status
389 * - Host Sleep activated status
390 * - Number of Tx timeouts
391 * - Number of command timeouts
392 * - Last timed out command ID
393 * - Last timed out command action
395 * - Last command action
396 * - Last command index
397 * - Last command response ID
398 * - Last command response index
401 * - Number of host to card command failures
402 * - Number of sleep confirm command failures
403 * - Number of host to card data failure
404 * - Number of deauthentication events
405 * - Number of disassociation events
406 * - Number of link lost events
407 * - Number of deauthentication commands
408 * - Number of association success commands
409 * - Number of association failure commands
410 * - Number of commands sent
411 * - Number of data packets sent
412 * - Number of command responses received
413 * - Number of events received
414 * - Tx BA stream table (TID, RA)
415 * - Rx reorder table (TID, TA, Start window, Window size, Buffer)
418 mwifiex_debug_read(struct file
*file
, char __user
*ubuf
,
419 size_t count
, loff_t
*ppos
)
421 struct mwifiex_private
*priv
=
422 (struct mwifiex_private
*) file
->private_data
;
423 unsigned long page
= get_zeroed_page(GFP_KERNEL
);
424 char *p
= (char *) page
;
430 ret
= mwifiex_get_debug_info(priv
, &info
);
434 p
+= mwifiex_debug_info_to_buffer(priv
, p
, &info
);
436 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, (char *) page
,
437 (unsigned long) p
- page
);
444 static u32 saved_reg_type
, saved_reg_offset
, saved_reg_value
;
447 * Proc regrdwr file write handler.
449 * This function is called when the 'regrdwr' file is opened for writing
451 * This function can be used to write to a register.
454 mwifiex_regrdwr_write(struct file
*file
,
455 const char __user
*ubuf
, size_t count
, loff_t
*ppos
)
459 u32 reg_type
= 0, reg_offset
= 0, reg_value
= UINT_MAX
;
461 buf
= memdup_user_nul(ubuf
, min(count
, (size_t)(PAGE_SIZE
- 1)));
465 sscanf(buf
, "%u %x %x", ®_type
, ®_offset
, ®_value
);
467 if (reg_type
== 0 || reg_offset
== 0) {
471 saved_reg_type
= reg_type
;
472 saved_reg_offset
= reg_offset
;
473 saved_reg_value
= reg_value
;
482 * Proc regrdwr file read handler.
484 * This function is called when the 'regrdwr' file is opened for reading
486 * This function can be used to read from a register.
489 mwifiex_regrdwr_read(struct file
*file
, char __user
*ubuf
,
490 size_t count
, loff_t
*ppos
)
492 struct mwifiex_private
*priv
=
493 (struct mwifiex_private
*) file
->private_data
;
494 unsigned long addr
= get_zeroed_page(GFP_KERNEL
);
495 char *buf
= (char *) addr
;
496 int pos
= 0, ret
= 0;
502 if (!saved_reg_type
) {
503 /* No command has been given */
504 pos
+= snprintf(buf
, PAGE_SIZE
, "0");
507 /* Set command has been given */
508 if (saved_reg_value
!= UINT_MAX
) {
509 ret
= mwifiex_reg_write(priv
, saved_reg_type
, saved_reg_offset
,
512 pos
+= snprintf(buf
, PAGE_SIZE
, "%u 0x%x 0x%x\n",
513 saved_reg_type
, saved_reg_offset
,
516 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, buf
, pos
);
520 /* Get command has been given */
521 ret
= mwifiex_reg_read(priv
, saved_reg_type
,
522 saved_reg_offset
, ®_value
);
528 pos
+= snprintf(buf
, PAGE_SIZE
, "%u 0x%x 0x%x\n", saved_reg_type
,
529 saved_reg_offset
, reg_value
);
531 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, buf
, pos
);
538 /* Proc debug_mask file read handler.
539 * This function is called when the 'debug_mask' file is opened for reading
540 * This function can be used read driver debugging mask value.
543 mwifiex_debug_mask_read(struct file
*file
, char __user
*ubuf
,
544 size_t count
, loff_t
*ppos
)
546 struct mwifiex_private
*priv
=
547 (struct mwifiex_private
*)file
->private_data
;
548 unsigned long page
= get_zeroed_page(GFP_KERNEL
);
549 char *buf
= (char *)page
;
556 pos
+= snprintf(buf
, PAGE_SIZE
, "debug mask=0x%08x\n",
557 priv
->adapter
->debug_mask
);
558 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, buf
, pos
);
564 /* Proc debug_mask file read handler.
565 * This function is called when the 'debug_mask' file is opened for reading
566 * This function can be used read driver debugging mask value.
569 mwifiex_debug_mask_write(struct file
*file
, const char __user
*ubuf
,
570 size_t count
, loff_t
*ppos
)
573 unsigned long debug_mask
;
574 struct mwifiex_private
*priv
= (void *)file
->private_data
;
577 buf
= memdup_user_nul(ubuf
, min(count
, (size_t)(PAGE_SIZE
- 1)));
581 if (kstrtoul(buf
, 0, &debug_mask
)) {
586 priv
->adapter
->debug_mask
= debug_mask
;
593 /* debugfs verext file write handler.
594 * This function is called when the 'verext' file is opened for write
597 mwifiex_verext_write(struct file
*file
, const char __user
*ubuf
,
598 size_t count
, loff_t
*ppos
)
602 struct mwifiex_private
*priv
= (void *)file
->private_data
;
605 memset(buf
, 0, sizeof(buf
));
607 if (copy_from_user(&buf
, ubuf
, min_t(size_t, sizeof(buf
) - 1, count
)))
610 ret
= kstrtou32(buf
, 10, &versionstrsel
);
614 priv
->versionstrsel
= versionstrsel
;
619 /* Proc verext file read handler.
620 * This function is called when the 'verext' file is opened for reading
621 * This function can be used read driver exteneed verion string.
624 mwifiex_verext_read(struct file
*file
, char __user
*ubuf
,
625 size_t count
, loff_t
*ppos
)
627 struct mwifiex_private
*priv
=
628 (struct mwifiex_private
*)file
->private_data
;
632 mwifiex_get_ver_ext(priv
, priv
->versionstrsel
);
633 ret
= snprintf(buf
, sizeof(buf
), "version string: %s\n",
636 return simple_read_from_buffer(ubuf
, count
, ppos
, buf
, ret
);
639 /* Proc memrw file write handler.
640 * This function is called when the 'memrw' file is opened for writing
641 * This function can be used to write to a memory location.
644 mwifiex_memrw_write(struct file
*file
, const char __user
*ubuf
, size_t count
,
649 struct mwifiex_ds_mem_rw mem_rw
;
651 struct mwifiex_private
*priv
= (void *)file
->private_data
;
654 buf
= memdup_user_nul(ubuf
, min(count
, (size_t)(PAGE_SIZE
- 1)));
658 ret
= sscanf(buf
, "%c %x %x", &cmd
, &mem_rw
.addr
, &mem_rw
.value
);
664 if ((cmd
== 'r') || (cmd
== 'R')) {
665 cmd_action
= HostCmd_ACT_GEN_GET
;
667 } else if ((cmd
== 'w') || (cmd
== 'W')) {
668 cmd_action
= HostCmd_ACT_GEN_SET
;
674 memcpy(&priv
->mem_rw
, &mem_rw
, sizeof(mem_rw
));
675 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MEM_ACCESS
, cmd_action
, 0,
686 /* Proc memrw file read handler.
687 * This function is called when the 'memrw' file is opened for reading
688 * This function can be used to read from a memory location.
691 mwifiex_memrw_read(struct file
*file
, char __user
*ubuf
,
692 size_t count
, loff_t
*ppos
)
694 struct mwifiex_private
*priv
= (void *)file
->private_data
;
695 unsigned long addr
= get_zeroed_page(GFP_KERNEL
);
696 char *buf
= (char *)addr
;
702 pos
+= snprintf(buf
, PAGE_SIZE
, "0x%x 0x%x\n", priv
->mem_rw
.addr
,
704 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, buf
, pos
);
710 static u32 saved_offset
= -1, saved_bytes
= -1;
713 * Proc rdeeprom file write handler.
715 * This function is called when the 'rdeeprom' file is opened for writing
717 * This function can be used to write to a RDEEPROM location.
720 mwifiex_rdeeprom_write(struct file
*file
,
721 const char __user
*ubuf
, size_t count
, loff_t
*ppos
)
725 int offset
= -1, bytes
= -1;
727 buf
= memdup_user_nul(ubuf
, min(count
, (size_t)(PAGE_SIZE
- 1)));
731 sscanf(buf
, "%d %d", &offset
, &bytes
);
733 if (offset
== -1 || bytes
== -1) {
737 saved_offset
= offset
;
747 * Proc rdeeprom read write handler.
749 * This function is called when the 'rdeeprom' file is opened for reading
751 * This function can be used to read from a RDEEPROM location.
754 mwifiex_rdeeprom_read(struct file
*file
, char __user
*ubuf
,
755 size_t count
, loff_t
*ppos
)
757 struct mwifiex_private
*priv
=
758 (struct mwifiex_private
*) file
->private_data
;
759 unsigned long addr
= get_zeroed_page(GFP_KERNEL
);
760 char *buf
= (char *) addr
;
762 u8 value
[MAX_EEPROM_DATA
];
767 if (saved_offset
== -1) {
768 /* No command has been given */
769 pos
= snprintf(buf
, PAGE_SIZE
, "0");
773 /* Get command has been given */
774 ret
= mwifiex_eeprom_read(priv
, (u16
) saved_offset
,
775 (u16
) saved_bytes
, value
);
781 pos
= snprintf(buf
, PAGE_SIZE
, "%d %d ", saved_offset
, saved_bytes
);
783 for (i
= 0; i
< saved_bytes
; i
++)
784 pos
+= scnprintf(buf
+ pos
, PAGE_SIZE
- pos
, "%d ", value
[i
]);
787 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, buf
, pos
);
793 /* Proc hscfg file write handler
794 * This function can be used to configure the host sleep parameters.
797 mwifiex_hscfg_write(struct file
*file
, const char __user
*ubuf
,
798 size_t count
, loff_t
*ppos
)
800 struct mwifiex_private
*priv
= (void *)file
->private_data
;
803 struct mwifiex_ds_hs_cfg hscfg
;
804 int conditions
= HS_CFG_COND_DEF
;
805 u32 gpio
= HS_CFG_GPIO_DEF
, gap
= HS_CFG_GAP_DEF
;
807 buf
= memdup_user_nul(ubuf
, min(count
, (size_t)(PAGE_SIZE
- 1)));
811 arg_num
= sscanf(buf
, "%d %x %x", &conditions
, &gpio
, &gap
);
813 memset(&hscfg
, 0, sizeof(struct mwifiex_ds_hs_cfg
));
816 mwifiex_dbg(priv
->adapter
, ERROR
,
817 "Too many arguments\n");
822 if (arg_num
>= 1 && arg_num
< 3)
823 mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_GET
,
824 MWIFIEX_SYNC_CMD
, &hscfg
);
827 if (conditions
== HS_CFG_CANCEL
) {
828 mwifiex_cancel_hs(priv
, MWIFIEX_ASYNC_CMD
);
832 hscfg
.conditions
= conditions
;
839 hscfg
.is_invoke_hostcmd
= false;
840 mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
841 MWIFIEX_SYNC_CMD
, &hscfg
);
843 mwifiex_enable_hs(priv
->adapter
);
844 priv
->adapter
->hs_enabling
= false;
851 /* Proc hscfg file read handler
852 * This function can be used to read host sleep configuration
853 * parameters from driver.
856 mwifiex_hscfg_read(struct file
*file
, char __user
*ubuf
,
857 size_t count
, loff_t
*ppos
)
859 struct mwifiex_private
*priv
= (void *)file
->private_data
;
860 unsigned long addr
= get_zeroed_page(GFP_KERNEL
);
861 char *buf
= (char *)addr
;
863 struct mwifiex_ds_hs_cfg hscfg
;
868 mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_GET
,
869 MWIFIEX_SYNC_CMD
, &hscfg
);
871 pos
= snprintf(buf
, PAGE_SIZE
, "%u 0x%x 0x%x\n", hscfg
.conditions
,
872 hscfg
.gpio
, hscfg
.gap
);
874 ret
= simple_read_from_buffer(ubuf
, count
, ppos
, buf
, pos
);
881 mwifiex_timeshare_coex_read(struct file
*file
, char __user
*ubuf
,
882 size_t count
, loff_t
*ppos
)
884 struct mwifiex_private
*priv
= file
->private_data
;
890 if (priv
->adapter
->fw_api_ver
!= MWIFIEX_FW_V15
)
893 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_ROBUST_COEX
,
894 HostCmd_ACT_GEN_GET
, 0, ×hare_coex
, true);
898 len
= sprintf(buf
, "%d\n", timeshare_coex
);
899 return simple_read_from_buffer(ubuf
, count
, ppos
, buf
, len
);
903 mwifiex_timeshare_coex_write(struct file
*file
, const char __user
*ubuf
,
904 size_t count
, loff_t
*ppos
)
907 struct mwifiex_private
*priv
= file
->private_data
;
911 if (priv
->adapter
->fw_api_ver
!= MWIFIEX_FW_V15
)
914 memset(kbuf
, 0, sizeof(kbuf
));
916 if (copy_from_user(&kbuf
, ubuf
, min_t(size_t, sizeof(kbuf
) - 1, count
)))
919 if (strtobool(kbuf
, ×hare_coex
))
922 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_ROBUST_COEX
,
923 HostCmd_ACT_GEN_SET
, 0, ×hare_coex
, true);
931 mwifiex_reset_write(struct file
*file
,
932 const char __user
*ubuf
, size_t count
, loff_t
*ppos
)
934 struct mwifiex_private
*priv
= file
->private_data
;
935 struct mwifiex_adapter
*adapter
= priv
->adapter
;
939 rc
= kstrtobool_from_user(ubuf
, count
, &result
);
946 if (adapter
->if_ops
.card_reset
) {
947 dev_info(adapter
->dev
, "Resetting per request\n");
948 adapter
->if_ops
.card_reset(adapter
);
954 #define MWIFIEX_DFS_ADD_FILE(name) do { \
955 if (!debugfs_create_file(#name, 0644, priv->dfs_dev_dir, \
956 priv, &mwifiex_dfs_##name##_fops)) \
960 #define MWIFIEX_DFS_FILE_OPS(name) \
961 static const struct file_operations mwifiex_dfs_##name##_fops = { \
962 .read = mwifiex_##name##_read, \
963 .write = mwifiex_##name##_write, \
964 .open = simple_open, \
967 #define MWIFIEX_DFS_FILE_READ_OPS(name) \
968 static const struct file_operations mwifiex_dfs_##name##_fops = { \
969 .read = mwifiex_##name##_read, \
970 .open = simple_open, \
973 #define MWIFIEX_DFS_FILE_WRITE_OPS(name) \
974 static const struct file_operations mwifiex_dfs_##name##_fops = { \
975 .write = mwifiex_##name##_write, \
976 .open = simple_open, \
980 MWIFIEX_DFS_FILE_READ_OPS(info
);
981 MWIFIEX_DFS_FILE_READ_OPS(debug
);
982 MWIFIEX_DFS_FILE_READ_OPS(getlog
);
983 MWIFIEX_DFS_FILE_READ_OPS(device_dump
);
984 MWIFIEX_DFS_FILE_OPS(regrdwr
);
985 MWIFIEX_DFS_FILE_OPS(rdeeprom
);
986 MWIFIEX_DFS_FILE_OPS(memrw
);
987 MWIFIEX_DFS_FILE_OPS(hscfg
);
988 MWIFIEX_DFS_FILE_OPS(histogram
);
989 MWIFIEX_DFS_FILE_OPS(debug_mask
);
990 MWIFIEX_DFS_FILE_OPS(timeshare_coex
);
991 MWIFIEX_DFS_FILE_WRITE_OPS(reset
);
992 MWIFIEX_DFS_FILE_OPS(verext
);
995 * This function creates the debug FS directory structure and the files.
998 mwifiex_dev_debugfs_init(struct mwifiex_private
*priv
)
1000 if (!mwifiex_dfs_dir
|| !priv
)
1003 priv
->dfs_dev_dir
= debugfs_create_dir(priv
->netdev
->name
,
1006 if (!priv
->dfs_dev_dir
)
1009 MWIFIEX_DFS_ADD_FILE(info
);
1010 MWIFIEX_DFS_ADD_FILE(debug
);
1011 MWIFIEX_DFS_ADD_FILE(getlog
);
1012 MWIFIEX_DFS_ADD_FILE(regrdwr
);
1013 MWIFIEX_DFS_ADD_FILE(rdeeprom
);
1014 MWIFIEX_DFS_ADD_FILE(device_dump
);
1015 MWIFIEX_DFS_ADD_FILE(memrw
);
1016 MWIFIEX_DFS_ADD_FILE(hscfg
);
1017 MWIFIEX_DFS_ADD_FILE(histogram
);
1018 MWIFIEX_DFS_ADD_FILE(debug_mask
);
1019 MWIFIEX_DFS_ADD_FILE(timeshare_coex
);
1020 MWIFIEX_DFS_ADD_FILE(reset
);
1021 MWIFIEX_DFS_ADD_FILE(verext
);
1025 * This function removes the debug FS directory structure and the files.
1028 mwifiex_dev_debugfs_remove(struct mwifiex_private
*priv
)
1033 debugfs_remove_recursive(priv
->dfs_dev_dir
);
1037 * This function creates the top level proc directory.
1040 mwifiex_debugfs_init(void)
1042 if (!mwifiex_dfs_dir
)
1043 mwifiex_dfs_dir
= debugfs_create_dir("mwifiex", NULL
);
1047 * This function removes the top level proc directory.
1050 mwifiex_debugfs_remove(void)
1052 debugfs_remove(mwifiex_dfs_dir
);