2 * This file is part of wl1271
4 * Copyright (C) 2009 Nokia Corporation
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
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 St, Fifth Floor, Boston, MA
26 #include <linux/skbuff.h>
27 #include <linux/slab.h>
28 #include <linux/module.h>
39 #define WL1271_DEBUGFS_STATS_LIFETIME 1000
41 /* debugfs macros idea from mac80211 */
42 int wl1271_format_buffer(char __user *userbuf, size_t count,
43 loff_t *ppos, char *fmt, ...)
46 char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
50 res = vscnprintf(buf, sizeof(buf), fmt, args);
53 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
55 EXPORT_SYMBOL_GPL(wl1271_format_buffer);
57 void wl1271_debugfs_update_stats(struct wl1271 *wl)
61 mutex_lock(&wl->mutex);
63 ret = wl1271_ps_elp_wakeup(wl);
67 if (wl->state == WL1271_STATE_ON && !wl->plt &&
68 time_after(jiffies, wl->stats.fw_stats_update +
69 msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) {
70 wl1271_acx_statistics(wl, wl->stats.fw_stats);
71 wl->stats.fw_stats_update = jiffies;
74 wl1271_ps_elp_sleep(wl);
77 mutex_unlock(&wl->mutex);
79 EXPORT_SYMBOL_GPL(wl1271_debugfs_update_stats);
81 DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count);
82 DEBUGFS_READONLY_FILE(excessive_retries, "%u",
83 wl->stats.excessive_retries);
85 static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
86 size_t count, loff_t *ppos)
88 struct wl1271 *wl = file->private_data;
93 queue_len = wl1271_tx_total_queue_count(wl);
95 res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
96 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
99 static const struct file_operations tx_queue_len_ops = {
100 .read = tx_queue_len_read,
102 .llseek = default_llseek,
105 static void chip_op_handler(struct wl1271 *wl, unsigned long value,
109 int (*chip_op) (struct wl1271 *wl);
112 wl1271_warning("debugfs chip_op_handler with no callback");
116 ret = wl1271_ps_elp_wakeup(wl);
123 wl1271_ps_elp_sleep(wl);
127 static inline void no_write_handler(struct wl1271 *wl,
133 #define WL12XX_CONF_DEBUGFS(param, conf_sub_struct, \
134 min_val, max_val, write_handler_locked, \
136 static ssize_t param##_read(struct file *file, \
137 char __user *user_buf, \
138 size_t count, loff_t *ppos) \
140 struct wl1271 *wl = file->private_data; \
141 return wl1271_format_buffer(user_buf, count, \
143 wl->conf.conf_sub_struct.param); \
146 static ssize_t param##_write(struct file *file, \
147 const char __user *user_buf, \
148 size_t count, loff_t *ppos) \
150 struct wl1271 *wl = file->private_data; \
151 unsigned long value; \
154 ret = kstrtoul_from_user(user_buf, count, 10, &value); \
156 wl1271_warning("illegal value for " #param); \
160 if (value < min_val || value > max_val) { \
161 wl1271_warning(#param " is not in valid range"); \
165 mutex_lock(&wl->mutex); \
166 wl->conf.conf_sub_struct.param = value; \
168 write_handler_locked(wl, value, write_handler_arg); \
170 mutex_unlock(&wl->mutex); \
174 static const struct file_operations param##_ops = { \
175 .read = param##_read, \
176 .write = param##_write, \
177 .open = simple_open, \
178 .llseek = default_llseek, \
181 WL12XX_CONF_DEBUGFS(irq_pkt_threshold, rx, 0, 65535,
182 chip_op_handler, wl1271_acx_init_rx_interrupt)
183 WL12XX_CONF_DEBUGFS(irq_blk_threshold, rx, 0, 65535,
184 chip_op_handler, wl1271_acx_init_rx_interrupt)
185 WL12XX_CONF_DEBUGFS(irq_timeout, rx, 0, 100,
186 chip_op_handler, wl1271_acx_init_rx_interrupt)
188 static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
189 size_t count, loff_t *ppos)
191 struct wl1271 *wl = file->private_data;
192 bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
197 res = scnprintf(buf, sizeof(buf), "%d\n", state);
199 return simple_read_from_buffer(user_buf, count, ppos, buf, res);
202 static ssize_t gpio_power_write(struct file *file,
203 const char __user *user_buf,
204 size_t count, loff_t *ppos)
206 struct wl1271 *wl = file->private_data;
210 ret = kstrtoul_from_user(user_buf, count, 10, &value);
212 wl1271_warning("illegal value in gpio_power");
216 mutex_lock(&wl->mutex);
221 wl1271_power_off(wl);
223 mutex_unlock(&wl->mutex);
227 static const struct file_operations gpio_power_ops = {
228 .read = gpio_power_read,
229 .write = gpio_power_write,
231 .llseek = default_llseek,
234 static ssize_t start_recovery_write(struct file *file,
235 const char __user *user_buf,
236 size_t count, loff_t *ppos)
238 struct wl1271 *wl = file->private_data;
240 mutex_lock(&wl->mutex);
241 wl12xx_queue_recovery_work(wl);
242 mutex_unlock(&wl->mutex);
247 static const struct file_operations start_recovery_ops = {
248 .write = start_recovery_write,
250 .llseek = default_llseek,
253 static ssize_t dynamic_ps_timeout_read(struct file *file, char __user *user_buf,
254 size_t count, loff_t *ppos)
256 struct wl1271 *wl = file->private_data;
258 return wl1271_format_buffer(user_buf, count,
260 wl->conf.conn.dynamic_ps_timeout);
263 static ssize_t dynamic_ps_timeout_write(struct file *file,
264 const char __user *user_buf,
265 size_t count, loff_t *ppos)
267 struct wl1271 *wl = file->private_data;
268 struct wl12xx_vif *wlvif;
272 ret = kstrtoul_from_user(user_buf, count, 10, &value);
274 wl1271_warning("illegal value in dynamic_ps");
278 if (value < 1 || value > 65535) {
279 wl1271_warning("dyanmic_ps_timeout is not in valid range");
283 mutex_lock(&wl->mutex);
285 wl->conf.conn.dynamic_ps_timeout = value;
287 if (wl->state == WL1271_STATE_OFF)
290 ret = wl1271_ps_elp_wakeup(wl);
294 /* In case we're already in PSM, trigger it again to set new timeout
295 * immediately without waiting for re-association
298 wl12xx_for_each_wlvif_sta(wl, wlvif) {
299 if (test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags))
300 wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE);
303 wl1271_ps_elp_sleep(wl);
306 mutex_unlock(&wl->mutex);
310 static const struct file_operations dynamic_ps_timeout_ops = {
311 .read = dynamic_ps_timeout_read,
312 .write = dynamic_ps_timeout_write,
314 .llseek = default_llseek,
317 static ssize_t forced_ps_read(struct file *file, char __user *user_buf,
318 size_t count, loff_t *ppos)
320 struct wl1271 *wl = file->private_data;
322 return wl1271_format_buffer(user_buf, count,
324 wl->conf.conn.forced_ps);
327 static ssize_t forced_ps_write(struct file *file,
328 const char __user *user_buf,
329 size_t count, loff_t *ppos)
331 struct wl1271 *wl = file->private_data;
332 struct wl12xx_vif *wlvif;
336 ret = kstrtoul_from_user(user_buf, count, 10, &value);
338 wl1271_warning("illegal value in forced_ps");
342 if (value != 1 && value != 0) {
343 wl1271_warning("forced_ps should be either 0 or 1");
347 mutex_lock(&wl->mutex);
349 if (wl->conf.conn.forced_ps == value)
352 wl->conf.conn.forced_ps = value;
354 if (wl->state == WL1271_STATE_OFF)
357 ret = wl1271_ps_elp_wakeup(wl);
361 /* In case we're already in PSM, trigger it again to switch mode
362 * immediately without waiting for re-association
365 ps_mode = value ? STATION_POWER_SAVE_MODE : STATION_AUTO_PS_MODE;
367 wl12xx_for_each_wlvif_sta(wl, wlvif) {
368 if (test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags))
369 wl1271_ps_set_mode(wl, wlvif, ps_mode);
372 wl1271_ps_elp_sleep(wl);
375 mutex_unlock(&wl->mutex);
379 static const struct file_operations forced_ps_ops = {
380 .read = forced_ps_read,
381 .write = forced_ps_write,
383 .llseek = default_llseek,
386 static ssize_t split_scan_timeout_read(struct file *file, char __user *user_buf,
387 size_t count, loff_t *ppos)
389 struct wl1271 *wl = file->private_data;
391 return wl1271_format_buffer(user_buf, count,
393 wl->conf.scan.split_scan_timeout / 1000);
396 static ssize_t split_scan_timeout_write(struct file *file,
397 const char __user *user_buf,
398 size_t count, loff_t *ppos)
400 struct wl1271 *wl = file->private_data;
404 ret = kstrtoul_from_user(user_buf, count, 10, &value);
406 wl1271_warning("illegal value in split_scan_timeout");
411 wl1271_info("split scan will be disabled");
413 mutex_lock(&wl->mutex);
415 wl->conf.scan.split_scan_timeout = value * 1000;
417 mutex_unlock(&wl->mutex);
421 static const struct file_operations split_scan_timeout_ops = {
422 .read = split_scan_timeout_read,
423 .write = split_scan_timeout_write,
425 .llseek = default_llseek,
428 static ssize_t driver_state_read(struct file *file, char __user *user_buf,
429 size_t count, loff_t *ppos)
431 struct wl1271 *wl = file->private_data;
436 #define DRIVER_STATE_BUF_LEN 1024
438 buf = kmalloc(DRIVER_STATE_BUF_LEN, GFP_KERNEL);
442 mutex_lock(&wl->mutex);
444 #define DRIVER_STATE_PRINT(x, fmt) \
445 (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
446 #x " = " fmt "\n", wl->x))
448 #define DRIVER_STATE_PRINT_LONG(x) DRIVER_STATE_PRINT(x, "%ld")
449 #define DRIVER_STATE_PRINT_INT(x) DRIVER_STATE_PRINT(x, "%d")
450 #define DRIVER_STATE_PRINT_STR(x) DRIVER_STATE_PRINT(x, "%s")
451 #define DRIVER_STATE_PRINT_LHEX(x) DRIVER_STATE_PRINT(x, "0x%lx")
452 #define DRIVER_STATE_PRINT_HEX(x) DRIVER_STATE_PRINT(x, "0x%x")
454 DRIVER_STATE_PRINT_INT(tx_blocks_available);
455 DRIVER_STATE_PRINT_INT(tx_allocated_blocks);
456 DRIVER_STATE_PRINT_INT(tx_allocated_pkts[0]);
457 DRIVER_STATE_PRINT_INT(tx_allocated_pkts[1]);
458 DRIVER_STATE_PRINT_INT(tx_allocated_pkts[2]);
459 DRIVER_STATE_PRINT_INT(tx_allocated_pkts[3]);
460 DRIVER_STATE_PRINT_INT(tx_frames_cnt);
461 DRIVER_STATE_PRINT_LHEX(tx_frames_map[0]);
462 DRIVER_STATE_PRINT_INT(tx_queue_count[0]);
463 DRIVER_STATE_PRINT_INT(tx_queue_count[1]);
464 DRIVER_STATE_PRINT_INT(tx_queue_count[2]);
465 DRIVER_STATE_PRINT_INT(tx_queue_count[3]);
466 DRIVER_STATE_PRINT_INT(tx_packets_count);
467 DRIVER_STATE_PRINT_INT(tx_results_count);
468 DRIVER_STATE_PRINT_LHEX(flags);
469 DRIVER_STATE_PRINT_INT(tx_blocks_freed);
470 DRIVER_STATE_PRINT_INT(rx_counter);
471 DRIVER_STATE_PRINT_INT(state);
472 DRIVER_STATE_PRINT_INT(channel);
473 DRIVER_STATE_PRINT_INT(band);
474 DRIVER_STATE_PRINT_INT(power_level);
475 DRIVER_STATE_PRINT_INT(sg_enabled);
476 DRIVER_STATE_PRINT_INT(enable_11a);
477 DRIVER_STATE_PRINT_INT(noise);
478 DRIVER_STATE_PRINT_HEX(ap_fw_ps_map);
479 DRIVER_STATE_PRINT_LHEX(ap_ps_map);
480 DRIVER_STATE_PRINT_HEX(quirks);
481 DRIVER_STATE_PRINT_HEX(irq);
482 /* TODO: ref_clock and tcxo_clock were moved to wl12xx priv */
483 DRIVER_STATE_PRINT_HEX(hw_pg_ver);
484 DRIVER_STATE_PRINT_HEX(platform_quirks);
485 DRIVER_STATE_PRINT_HEX(chip.id);
486 DRIVER_STATE_PRINT_STR(chip.fw_ver_str);
487 DRIVER_STATE_PRINT_INT(sched_scanning);
489 #undef DRIVER_STATE_PRINT_INT
490 #undef DRIVER_STATE_PRINT_LONG
491 #undef DRIVER_STATE_PRINT_HEX
492 #undef DRIVER_STATE_PRINT_LHEX
493 #undef DRIVER_STATE_PRINT_STR
494 #undef DRIVER_STATE_PRINT
495 #undef DRIVER_STATE_BUF_LEN
497 mutex_unlock(&wl->mutex);
499 ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
504 static const struct file_operations driver_state_ops = {
505 .read = driver_state_read,
507 .llseek = default_llseek,
510 static ssize_t vifs_state_read(struct file *file, char __user *user_buf,
511 size_t count, loff_t *ppos)
513 struct wl1271 *wl = file->private_data;
514 struct wl12xx_vif *wlvif;
516 const int buf_size = 4096;
520 buf = kzalloc(buf_size, GFP_KERNEL);
524 mutex_lock(&wl->mutex);
526 #define VIF_STATE_PRINT(x, fmt) \
527 (res += scnprintf(buf + res, buf_size - res, \
528 #x " = " fmt "\n", wlvif->x))
530 #define VIF_STATE_PRINT_LONG(x) VIF_STATE_PRINT(x, "%ld")
531 #define VIF_STATE_PRINT_INT(x) VIF_STATE_PRINT(x, "%d")
532 #define VIF_STATE_PRINT_STR(x) VIF_STATE_PRINT(x, "%s")
533 #define VIF_STATE_PRINT_LHEX(x) VIF_STATE_PRINT(x, "0x%lx")
534 #define VIF_STATE_PRINT_LLHEX(x) VIF_STATE_PRINT(x, "0x%llx")
535 #define VIF_STATE_PRINT_HEX(x) VIF_STATE_PRINT(x, "0x%x")
537 #define VIF_STATE_PRINT_NSTR(x, len) \
539 memset(tmp_buf, 0, sizeof(tmp_buf)); \
540 memcpy(tmp_buf, wlvif->x, \
541 min_t(u8, len, sizeof(tmp_buf) - 1)); \
542 res += scnprintf(buf + res, buf_size - res, \
543 #x " = %s\n", tmp_buf); \
546 wl12xx_for_each_wlvif(wl, wlvif) {
547 VIF_STATE_PRINT_INT(role_id);
548 VIF_STATE_PRINT_INT(bss_type);
549 VIF_STATE_PRINT_LHEX(flags);
550 VIF_STATE_PRINT_INT(p2p);
551 VIF_STATE_PRINT_INT(dev_role_id);
552 VIF_STATE_PRINT_INT(dev_hlid);
554 if (wlvif->bss_type == BSS_TYPE_STA_BSS ||
555 wlvif->bss_type == BSS_TYPE_IBSS) {
556 VIF_STATE_PRINT_INT(sta.hlid);
557 VIF_STATE_PRINT_INT(sta.ba_rx_bitmap);
558 VIF_STATE_PRINT_INT(sta.basic_rate_idx);
559 VIF_STATE_PRINT_INT(sta.ap_rate_idx);
560 VIF_STATE_PRINT_INT(sta.p2p_rate_idx);
561 VIF_STATE_PRINT_INT(sta.qos);
563 VIF_STATE_PRINT_INT(ap.global_hlid);
564 VIF_STATE_PRINT_INT(ap.bcast_hlid);
565 VIF_STATE_PRINT_LHEX(ap.sta_hlid_map[0]);
566 VIF_STATE_PRINT_INT(ap.mgmt_rate_idx);
567 VIF_STATE_PRINT_INT(ap.bcast_rate_idx);
568 VIF_STATE_PRINT_INT(ap.ucast_rate_idx[0]);
569 VIF_STATE_PRINT_INT(ap.ucast_rate_idx[1]);
570 VIF_STATE_PRINT_INT(ap.ucast_rate_idx[2]);
571 VIF_STATE_PRINT_INT(ap.ucast_rate_idx[3]);
573 VIF_STATE_PRINT_INT(last_tx_hlid);
574 VIF_STATE_PRINT_LHEX(links_map[0]);
575 VIF_STATE_PRINT_NSTR(ssid, wlvif->ssid_len);
576 VIF_STATE_PRINT_INT(band);
577 VIF_STATE_PRINT_INT(channel);
578 VIF_STATE_PRINT_HEX(bitrate_masks[0]);
579 VIF_STATE_PRINT_HEX(bitrate_masks[1]);
580 VIF_STATE_PRINT_HEX(basic_rate_set);
581 VIF_STATE_PRINT_HEX(basic_rate);
582 VIF_STATE_PRINT_HEX(rate_set);
583 VIF_STATE_PRINT_INT(beacon_int);
584 VIF_STATE_PRINT_INT(default_key);
585 VIF_STATE_PRINT_INT(aid);
586 VIF_STATE_PRINT_INT(session_counter);
587 VIF_STATE_PRINT_INT(psm_entry_retry);
588 VIF_STATE_PRINT_INT(power_level);
589 VIF_STATE_PRINT_INT(rssi_thold);
590 VIF_STATE_PRINT_INT(last_rssi_event);
591 VIF_STATE_PRINT_INT(ba_support);
592 VIF_STATE_PRINT_INT(ba_allowed);
593 VIF_STATE_PRINT_LLHEX(tx_security_seq);
594 VIF_STATE_PRINT_INT(tx_security_last_seq_lsb);
597 #undef VIF_STATE_PRINT_INT
598 #undef VIF_STATE_PRINT_LONG
599 #undef VIF_STATE_PRINT_HEX
600 #undef VIF_STATE_PRINT_LHEX
601 #undef VIF_STATE_PRINT_LLHEX
602 #undef VIF_STATE_PRINT_STR
603 #undef VIF_STATE_PRINT_NSTR
604 #undef VIF_STATE_PRINT
606 mutex_unlock(&wl->mutex);
608 ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
613 static const struct file_operations vifs_state_ops = {
614 .read = vifs_state_read,
616 .llseek = default_llseek,
619 static ssize_t dtim_interval_read(struct file *file, char __user *user_buf,
620 size_t count, loff_t *ppos)
622 struct wl1271 *wl = file->private_data;
625 if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_DTIM ||
626 wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_DTIM)
627 value = wl->conf.conn.listen_interval;
631 return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
634 static ssize_t dtim_interval_write(struct file *file,
635 const char __user *user_buf,
636 size_t count, loff_t *ppos)
638 struct wl1271 *wl = file->private_data;
642 ret = kstrtoul_from_user(user_buf, count, 10, &value);
644 wl1271_warning("illegal value for dtim_interval");
648 if (value < 1 || value > 10) {
649 wl1271_warning("dtim value is not in valid range");
653 mutex_lock(&wl->mutex);
655 wl->conf.conn.listen_interval = value;
656 /* for some reason there are different event types for 1 and >1 */
658 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_DTIM;
660 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM;
663 * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only
664 * take effect on the next time we enter psm.
666 mutex_unlock(&wl->mutex);
670 static const struct file_operations dtim_interval_ops = {
671 .read = dtim_interval_read,
672 .write = dtim_interval_write,
674 .llseek = default_llseek,
679 static ssize_t suspend_dtim_interval_read(struct file *file,
680 char __user *user_buf,
681 size_t count, loff_t *ppos)
683 struct wl1271 *wl = file->private_data;
686 if (wl->conf.conn.suspend_wake_up_event == CONF_WAKE_UP_EVENT_DTIM ||
687 wl->conf.conn.suspend_wake_up_event == CONF_WAKE_UP_EVENT_N_DTIM)
688 value = wl->conf.conn.suspend_listen_interval;
692 return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
695 static ssize_t suspend_dtim_interval_write(struct file *file,
696 const char __user *user_buf,
697 size_t count, loff_t *ppos)
699 struct wl1271 *wl = file->private_data;
703 ret = kstrtoul_from_user(user_buf, count, 10, &value);
705 wl1271_warning("illegal value for suspend_dtim_interval");
709 if (value < 1 || value > 10) {
710 wl1271_warning("suspend_dtim value is not in valid range");
714 mutex_lock(&wl->mutex);
716 wl->conf.conn.suspend_listen_interval = value;
717 /* for some reason there are different event types for 1 and >1 */
719 wl->conf.conn.suspend_wake_up_event = CONF_WAKE_UP_EVENT_DTIM;
721 wl->conf.conn.suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM;
723 mutex_unlock(&wl->mutex);
728 static const struct file_operations suspend_dtim_interval_ops = {
729 .read = suspend_dtim_interval_read,
730 .write = suspend_dtim_interval_write,
732 .llseek = default_llseek,
735 static ssize_t beacon_interval_read(struct file *file, char __user *user_buf,
736 size_t count, loff_t *ppos)
738 struct wl1271 *wl = file->private_data;
741 if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_BEACON ||
742 wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_BEACONS)
743 value = wl->conf.conn.listen_interval;
747 return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
750 static ssize_t beacon_interval_write(struct file *file,
751 const char __user *user_buf,
752 size_t count, loff_t *ppos)
754 struct wl1271 *wl = file->private_data;
758 ret = kstrtoul_from_user(user_buf, count, 10, &value);
760 wl1271_warning("illegal value for beacon_interval");
764 if (value < 1 || value > 255) {
765 wl1271_warning("beacon interval value is not in valid range");
769 mutex_lock(&wl->mutex);
771 wl->conf.conn.listen_interval = value;
772 /* for some reason there are different event types for 1 and >1 */
774 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_BEACON;
776 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_BEACONS;
779 * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only
780 * take effect on the next time we enter psm.
782 mutex_unlock(&wl->mutex);
786 static const struct file_operations beacon_interval_ops = {
787 .read = beacon_interval_read,
788 .write = beacon_interval_write,
790 .llseek = default_llseek,
793 static ssize_t rx_streaming_interval_write(struct file *file,
794 const char __user *user_buf,
795 size_t count, loff_t *ppos)
797 struct wl1271 *wl = file->private_data;
798 struct wl12xx_vif *wlvif;
802 ret = kstrtoul_from_user(user_buf, count, 10, &value);
804 wl1271_warning("illegal value in rx_streaming_interval!");
808 /* valid values: 0, 10-100 */
809 if (value && (value < 10 || value > 100)) {
810 wl1271_warning("value is not in range!");
814 mutex_lock(&wl->mutex);
816 wl->conf.rx_streaming.interval = value;
818 ret = wl1271_ps_elp_wakeup(wl);
822 wl12xx_for_each_wlvif_sta(wl, wlvif) {
823 wl1271_recalc_rx_streaming(wl, wlvif);
826 wl1271_ps_elp_sleep(wl);
828 mutex_unlock(&wl->mutex);
832 static ssize_t rx_streaming_interval_read(struct file *file,
833 char __user *userbuf,
834 size_t count, loff_t *ppos)
836 struct wl1271 *wl = file->private_data;
837 return wl1271_format_buffer(userbuf, count, ppos,
838 "%d\n", wl->conf.rx_streaming.interval);
841 static const struct file_operations rx_streaming_interval_ops = {
842 .read = rx_streaming_interval_read,
843 .write = rx_streaming_interval_write,
845 .llseek = default_llseek,
848 static ssize_t rx_streaming_always_write(struct file *file,
849 const char __user *user_buf,
850 size_t count, loff_t *ppos)
852 struct wl1271 *wl = file->private_data;
853 struct wl12xx_vif *wlvif;
857 ret = kstrtoul_from_user(user_buf, count, 10, &value);
859 wl1271_warning("illegal value in rx_streaming_write!");
863 /* valid values: 0, 10-100 */
864 if (!(value == 0 || value == 1)) {
865 wl1271_warning("value is not in valid!");
869 mutex_lock(&wl->mutex);
871 wl->conf.rx_streaming.always = value;
873 ret = wl1271_ps_elp_wakeup(wl);
877 wl12xx_for_each_wlvif_sta(wl, wlvif) {
878 wl1271_recalc_rx_streaming(wl, wlvif);
881 wl1271_ps_elp_sleep(wl);
883 mutex_unlock(&wl->mutex);
887 static ssize_t rx_streaming_always_read(struct file *file,
888 char __user *userbuf,
889 size_t count, loff_t *ppos)
891 struct wl1271 *wl = file->private_data;
892 return wl1271_format_buffer(userbuf, count, ppos,
893 "%d\n", wl->conf.rx_streaming.always);
896 static const struct file_operations rx_streaming_always_ops = {
897 .read = rx_streaming_always_read,
898 .write = rx_streaming_always_write,
900 .llseek = default_llseek,
903 static ssize_t beacon_filtering_write(struct file *file,
904 const char __user *user_buf,
905 size_t count, loff_t *ppos)
907 struct wl1271 *wl = file->private_data;
908 struct wl12xx_vif *wlvif;
914 len = min(count, sizeof(buf) - 1);
915 if (copy_from_user(buf, user_buf, len))
919 ret = kstrtoul(buf, 0, &value);
921 wl1271_warning("illegal value for beacon_filtering!");
925 mutex_lock(&wl->mutex);
927 ret = wl1271_ps_elp_wakeup(wl);
931 wl12xx_for_each_wlvif(wl, wlvif) {
932 ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value);
935 wl1271_ps_elp_sleep(wl);
937 mutex_unlock(&wl->mutex);
941 static const struct file_operations beacon_filtering_ops = {
942 .write = beacon_filtering_write,
944 .llseek = default_llseek,
947 static int wl1271_debugfs_add_files(struct wl1271 *wl,
948 struct dentry *rootdir)
951 struct dentry *entry, *streaming;
953 DEBUGFS_ADD(tx_queue_len, rootdir);
954 DEBUGFS_ADD(retry_count, rootdir);
955 DEBUGFS_ADD(excessive_retries, rootdir);
957 DEBUGFS_ADD(gpio_power, rootdir);
958 DEBUGFS_ADD(start_recovery, rootdir);
959 DEBUGFS_ADD(driver_state, rootdir);
960 DEBUGFS_ADD(vifs_state, rootdir);
961 DEBUGFS_ADD(dtim_interval, rootdir);
962 DEBUGFS_ADD(suspend_dtim_interval, rootdir);
963 DEBUGFS_ADD(beacon_interval, rootdir);
964 DEBUGFS_ADD(beacon_filtering, rootdir);
965 DEBUGFS_ADD(dynamic_ps_timeout, rootdir);
966 DEBUGFS_ADD(forced_ps, rootdir);
967 DEBUGFS_ADD(split_scan_timeout, rootdir);
968 DEBUGFS_ADD(irq_pkt_threshold, rootdir);
969 DEBUGFS_ADD(irq_blk_threshold, rootdir);
970 DEBUGFS_ADD(irq_timeout, rootdir);
972 streaming = debugfs_create_dir("rx_streaming", rootdir);
973 if (!streaming || IS_ERR(streaming))
976 DEBUGFS_ADD_PREFIX(rx_streaming, interval, streaming);
977 DEBUGFS_ADD_PREFIX(rx_streaming, always, streaming);
984 ret = PTR_ERR(entry);
991 void wl1271_debugfs_reset(struct wl1271 *wl)
993 if (!wl->stats.fw_stats)
996 memset(wl->stats.fw_stats, 0, wl->stats.fw_stats_len);
997 wl->stats.retry_count = 0;
998 wl->stats.excessive_retries = 0;
1001 int wl1271_debugfs_init(struct wl1271 *wl)
1004 struct dentry *rootdir;
1006 rootdir = debugfs_create_dir(KBUILD_MODNAME,
1007 wl->hw->wiphy->debugfsdir);
1009 if (IS_ERR(rootdir)) {
1010 ret = PTR_ERR(rootdir);
1014 wl->stats.fw_stats = kzalloc(wl->stats.fw_stats_len, GFP_KERNEL);
1015 if (!wl->stats.fw_stats) {
1020 wl->stats.fw_stats_update = jiffies;
1022 ret = wl1271_debugfs_add_files(wl, rootdir);
1026 ret = wlcore_debugfs_init(wl, rootdir);
1033 wl1271_debugfs_exit(wl);
1036 debugfs_remove_recursive(rootdir);
1042 void wl1271_debugfs_exit(struct wl1271 *wl)
1044 kfree(wl->stats.fw_stats);
1045 wl->stats.fw_stats = NULL;