2 * Copyright (c) 2004-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <linux/skbuff.h>
22 #include <linux/vmalloc.h>
23 #include <linux/export.h>
28 struct ath6kl_fwlog_slot {
32 /* max ATH6KL_FWLOG_PAYLOAD_SIZE bytes */
36 #define ATH6KL_FWLOG_MAX_ENTRIES 20
38 #define ATH6KL_FWLOG_VALID_MASK 0x1ffff
40 int ath6kl_printk(const char *level, const char *fmt, ...)
51 rtn = printk("%sath6kl: %pV", level, &vaf);
57 EXPORT_SYMBOL(ath6kl_printk);
59 #ifdef CONFIG_ATH6KL_DEBUG
61 void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)
66 if (!(debug_mask & mask))
74 ath6kl_printk(KERN_DEBUG, "%pV", &vaf);
78 EXPORT_SYMBOL(ath6kl_dbg);
80 void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
81 const char *msg, const char *prefix,
82 const void *buf, size_t len)
84 if (debug_mask & mask) {
86 ath6kl_dbg(mask, "%s\n", msg);
88 print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len);
91 EXPORT_SYMBOL(ath6kl_dbg_dump);
93 #define REG_OUTPUT_LEN_PER_LINE 25
94 #define REGTYPE_STR_LEN 100
96 struct ath6kl_diag_reg_info {
102 static const struct ath6kl_diag_reg_info diag_reg[] = {
103 { 0x20000, 0x200fc, "General DMA and Rx registers" },
104 { 0x28000, 0x28900, "MAC PCU register & keycache" },
105 { 0x20800, 0x20a40, "QCU" },
106 { 0x21000, 0x212f0, "DCU" },
107 { 0x4000, 0x42e4, "RTC" },
108 { 0x540000, 0x540000 + (256 * 1024), "RAM" },
109 { 0x29800, 0x2B210, "Base Band" },
110 { 0x1C000, 0x1C748, "Analog" },
113 void ath6kl_dump_registers(struct ath6kl_device *dev,
114 struct ath6kl_irq_proc_registers *irq_proc_reg,
115 struct ath6kl_irq_enable_reg *irq_enable_reg)
118 ath6kl_dbg(ATH6KL_DBG_IRQ, ("<------- Register Table -------->\n"));
120 if (irq_proc_reg != NULL) {
121 ath6kl_dbg(ATH6KL_DBG_IRQ,
122 "Host Int status: 0x%x\n",
123 irq_proc_reg->host_int_status);
124 ath6kl_dbg(ATH6KL_DBG_IRQ,
125 "CPU Int status: 0x%x\n",
126 irq_proc_reg->cpu_int_status);
127 ath6kl_dbg(ATH6KL_DBG_IRQ,
128 "Error Int status: 0x%x\n",
129 irq_proc_reg->error_int_status);
130 ath6kl_dbg(ATH6KL_DBG_IRQ,
131 "Counter Int status: 0x%x\n",
132 irq_proc_reg->counter_int_status);
133 ath6kl_dbg(ATH6KL_DBG_IRQ,
134 "Mbox Frame: 0x%x\n",
135 irq_proc_reg->mbox_frame);
136 ath6kl_dbg(ATH6KL_DBG_IRQ,
137 "Rx Lookahead Valid: 0x%x\n",
138 irq_proc_reg->rx_lkahd_valid);
139 ath6kl_dbg(ATH6KL_DBG_IRQ,
140 "Rx Lookahead 0: 0x%x\n",
141 irq_proc_reg->rx_lkahd[0]);
142 ath6kl_dbg(ATH6KL_DBG_IRQ,
143 "Rx Lookahead 1: 0x%x\n",
144 irq_proc_reg->rx_lkahd[1]);
146 if (dev->ar->mbox_info.gmbox_addr != 0) {
148 * If the target supports GMBOX hardware, dump some
151 ath6kl_dbg(ATH6KL_DBG_IRQ,
152 "GMBOX Host Int status 2: 0x%x\n",
153 irq_proc_reg->host_int_status2);
154 ath6kl_dbg(ATH6KL_DBG_IRQ,
155 "GMBOX RX Avail: 0x%x\n",
156 irq_proc_reg->gmbox_rx_avail);
157 ath6kl_dbg(ATH6KL_DBG_IRQ,
158 "GMBOX lookahead alias 0: 0x%x\n",
159 irq_proc_reg->rx_gmbox_lkahd_alias[0]);
160 ath6kl_dbg(ATH6KL_DBG_IRQ,
161 "GMBOX lookahead alias 1: 0x%x\n",
162 irq_proc_reg->rx_gmbox_lkahd_alias[1]);
167 if (irq_enable_reg != NULL) {
168 ath6kl_dbg(ATH6KL_DBG_IRQ,
169 "Int status Enable: 0x%x\n",
170 irq_enable_reg->int_status_en);
171 ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status Enable: 0x%x\n",
172 irq_enable_reg->cntr_int_status_en);
174 ath6kl_dbg(ATH6KL_DBG_IRQ, "<------------------------------->\n");
177 static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist)
179 ath6kl_dbg(ATH6KL_DBG_CREDIT,
180 "--- endpoint: %d svc_id: 0x%X ---\n",
181 ep_dist->endpoint, ep_dist->svc_id);
182 ath6kl_dbg(ATH6KL_DBG_CREDIT, " dist_flags : 0x%X\n",
183 ep_dist->dist_flags);
184 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_norm : %d\n",
186 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_min : %d\n",
188 ath6kl_dbg(ATH6KL_DBG_CREDIT, " credits : %d\n",
190 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_assngd : %d\n",
191 ep_dist->cred_assngd);
192 ath6kl_dbg(ATH6KL_DBG_CREDIT, " seek_cred : %d\n",
194 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_sz : %d\n",
196 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_per_msg : %d\n",
197 ep_dist->cred_per_msg);
198 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_to_dist : %d\n",
199 ep_dist->cred_to_dist);
200 ath6kl_dbg(ATH6KL_DBG_CREDIT, " txq_depth : %d\n",
201 get_queue_depth(&ep_dist->htc_ep->txq));
202 ath6kl_dbg(ATH6KL_DBG_CREDIT,
203 "----------------------------------\n");
206 /* FIXME: move to htc.c */
207 void dump_cred_dist_stats(struct htc_target *target)
209 struct htc_endpoint_credit_dist *ep_list;
211 list_for_each_entry(ep_list, &target->cred_dist_list, list)
212 dump_cred_dist(ep_list);
214 ath6kl_dbg(ATH6KL_DBG_CREDIT,
215 "credit distribution total %d free %d\n",
216 target->credit_info->total_avail_credits,
217 target->credit_info->cur_free_credits);
220 static int ath6kl_debugfs_open(struct inode *inode, struct file *file)
222 file->private_data = inode->i_private;
226 void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war)
229 case ATH6KL_WAR_INVALID_RATE:
230 ar->debug.war_stats.invalid_rate++;
235 static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
236 size_t count, loff_t *ppos)
238 struct ath6kl *ar = file->private_data;
240 unsigned int len = 0, buf_len = 1500;
243 buf = kzalloc(buf_len, GFP_KERNEL);
247 len += scnprintf(buf + len, buf_len - len, "\n");
248 len += scnprintf(buf + len, buf_len - len, "%25s\n",
250 len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
251 "=================");
252 len += scnprintf(buf + len, buf_len - len, "%20s %10u\n",
253 "Invalid rates", ar->debug.war_stats.invalid_rate);
255 if (WARN_ON(len > buf_len))
258 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
264 static const struct file_operations fops_war_stats = {
265 .read = read_file_war_stats,
266 .open = ath6kl_debugfs_open,
267 .owner = THIS_MODULE,
268 .llseek = default_llseek,
271 void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len)
273 struct ath6kl_fwlog_slot *slot;
277 if (WARN_ON(len > ATH6KL_FWLOG_PAYLOAD_SIZE))
280 slot_len = sizeof(*slot) + ATH6KL_FWLOG_PAYLOAD_SIZE;
282 skb = alloc_skb(slot_len, GFP_KERNEL);
286 slot = (struct ath6kl_fwlog_slot *) skb_put(skb, slot_len);
287 slot->timestamp = cpu_to_le32(jiffies);
288 slot->length = cpu_to_le32(len);
289 memcpy(slot->payload, buf, len);
291 /* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */
292 memset(slot->payload + len, 0, ATH6KL_FWLOG_PAYLOAD_SIZE - len);
294 spin_lock(&ar->debug.fwlog_queue.lock);
296 __skb_queue_tail(&ar->debug.fwlog_queue, skb);
297 complete(&ar->debug.fwlog_completion);
299 /* drop oldest entries */
300 while (skb_queue_len(&ar->debug.fwlog_queue) >
301 ATH6KL_FWLOG_MAX_ENTRIES) {
302 skb = __skb_dequeue(&ar->debug.fwlog_queue);
306 spin_unlock(&ar->debug.fwlog_queue.lock);
311 static int ath6kl_fwlog_open(struct inode *inode, struct file *file)
313 struct ath6kl *ar = inode->i_private;
315 if (ar->debug.fwlog_open)
318 ar->debug.fwlog_open = true;
320 file->private_data = inode->i_private;
324 static int ath6kl_fwlog_release(struct inode *inode, struct file *file)
326 struct ath6kl *ar = inode->i_private;
328 ar->debug.fwlog_open = false;
333 static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
334 size_t count, loff_t *ppos)
336 struct ath6kl *ar = file->private_data;
342 buf = vmalloc(count);
346 /* read undelivered logs from firmware */
347 ath6kl_read_fwlogs(ar);
349 spin_lock(&ar->debug.fwlog_queue.lock);
351 while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
352 if (skb->len > count - len) {
353 /* not enough space, put skb back and leave */
354 __skb_queue_head(&ar->debug.fwlog_queue, skb);
359 memcpy(buf + len, skb->data, skb->len);
365 spin_unlock(&ar->debug.fwlog_queue.lock);
367 /* FIXME: what to do if len == 0? */
369 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
376 static const struct file_operations fops_fwlog = {
377 .open = ath6kl_fwlog_open,
378 .release = ath6kl_fwlog_release,
379 .read = ath6kl_fwlog_read,
380 .owner = THIS_MODULE,
381 .llseek = default_llseek,
384 static ssize_t ath6kl_fwlog_block_read(struct file *file,
385 char __user *user_buf,
389 struct ath6kl *ar = file->private_data;
392 size_t len = 0, not_copied;
396 buf = vmalloc(count);
400 spin_lock(&ar->debug.fwlog_queue.lock);
402 if (skb_queue_len(&ar->debug.fwlog_queue) == 0) {
403 /* we must init under queue lock */
404 init_completion(&ar->debug.fwlog_completion);
406 spin_unlock(&ar->debug.fwlog_queue.lock);
408 ret = wait_for_completion_interruptible(
409 &ar->debug.fwlog_completion);
410 if (ret == -ERESTARTSYS)
413 spin_lock(&ar->debug.fwlog_queue.lock);
416 while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
417 if (skb->len > count - len) {
418 /* not enough space, put skb back and leave */
419 __skb_queue_head(&ar->debug.fwlog_queue, skb);
424 memcpy(buf + len, skb->data, skb->len);
430 spin_unlock(&ar->debug.fwlog_queue.lock);
432 /* FIXME: what to do if len == 0? */
434 not_copied = copy_to_user(user_buf, buf, len);
435 if (not_copied != 0) {
450 static const struct file_operations fops_fwlog_block = {
451 .open = ath6kl_fwlog_open,
452 .release = ath6kl_fwlog_release,
453 .read = ath6kl_fwlog_block_read,
454 .owner = THIS_MODULE,
455 .llseek = default_llseek,
458 static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf,
459 size_t count, loff_t *ppos)
461 struct ath6kl *ar = file->private_data;
465 len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask);
467 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
470 static ssize_t ath6kl_fwlog_mask_write(struct file *file,
471 const char __user *user_buf,
472 size_t count, loff_t *ppos)
474 struct ath6kl *ar = file->private_data;
477 ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask);
481 ret = ath6kl_wmi_config_debug_module_cmd(ar->wmi,
482 ATH6KL_FWLOG_VALID_MASK,
483 ar->debug.fwlog_mask);
490 static const struct file_operations fops_fwlog_mask = {
491 .open = ath6kl_debugfs_open,
492 .read = ath6kl_fwlog_mask_read,
493 .write = ath6kl_fwlog_mask_write,
494 .owner = THIS_MODULE,
495 .llseek = default_llseek,
498 static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
499 size_t count, loff_t *ppos)
501 struct ath6kl *ar = file->private_data;
502 struct ath6kl_vif *vif;
503 struct target_stats *tgt_stats;
505 unsigned int len = 0, buf_len = 1500;
510 vif = ath6kl_vif_first(ar);
514 tgt_stats = &vif->target_stats;
516 buf = kzalloc(buf_len, GFP_KERNEL);
520 if (down_interruptible(&ar->sem)) {
525 set_bit(STATS_UPDATE_PEND, &vif->flags);
527 if (ath6kl_wmi_get_stats_cmd(ar->wmi, 0)) {
533 left = wait_event_interruptible_timeout(ar->event_wq,
534 !test_bit(STATS_UPDATE_PEND,
535 &vif->flags), WMI_TIMEOUT);
544 len += scnprintf(buf + len, buf_len - len, "\n");
545 len += scnprintf(buf + len, buf_len - len, "%25s\n",
547 len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
548 "=================");
549 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
550 "Ucast packets", tgt_stats->tx_ucast_pkt);
551 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
552 "Bcast packets", tgt_stats->tx_bcast_pkt);
553 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
554 "Ucast byte", tgt_stats->tx_ucast_byte);
555 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
556 "Bcast byte", tgt_stats->tx_bcast_byte);
557 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
558 "Rts success cnt", tgt_stats->tx_rts_success_cnt);
559 for (i = 0; i < 4; i++)
560 len += scnprintf(buf + len, buf_len - len,
561 "%18s %d %10llu\n", "PER on ac",
562 i, tgt_stats->tx_pkt_per_ac[i]);
563 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
564 "Error", tgt_stats->tx_err);
565 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
566 "Fail count", tgt_stats->tx_fail_cnt);
567 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
568 "Retry count", tgt_stats->tx_retry_cnt);
569 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
570 "Multi retry cnt", tgt_stats->tx_mult_retry_cnt);
571 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
572 "Rts fail cnt", tgt_stats->tx_rts_fail_cnt);
573 len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n\n",
574 "TKIP counter measure used",
575 tgt_stats->tkip_cnter_measures_invoked);
577 len += scnprintf(buf + len, buf_len - len, "%25s\n",
579 len += scnprintf(buf + len, buf_len - len, "%25s\n",
580 "=================");
582 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
583 "Ucast packets", tgt_stats->rx_ucast_pkt);
584 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
585 "Ucast Rate", tgt_stats->rx_ucast_rate);
586 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
587 "Bcast packets", tgt_stats->rx_bcast_pkt);
588 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
589 "Ucast byte", tgt_stats->rx_ucast_byte);
590 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
591 "Bcast byte", tgt_stats->rx_bcast_byte);
592 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
593 "Fragmented pkt", tgt_stats->rx_frgment_pkt);
594 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
595 "Error", tgt_stats->rx_err);
596 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
597 "CRC Err", tgt_stats->rx_crc_err);
598 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
599 "Key chache miss", tgt_stats->rx_key_cache_miss);
600 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
601 "Decrypt Err", tgt_stats->rx_decrypt_err);
602 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
603 "Duplicate frame", tgt_stats->rx_dupl_frame);
604 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
605 "Tkip Mic failure", tgt_stats->tkip_local_mic_fail);
606 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
607 "TKIP format err", tgt_stats->tkip_fmt_err);
608 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
609 "CCMP format Err", tgt_stats->ccmp_fmt_err);
610 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n\n",
611 "CCMP Replay Err", tgt_stats->ccmp_replays);
613 len += scnprintf(buf + len, buf_len - len, "%25s\n",
614 "Misc Target stats");
615 len += scnprintf(buf + len, buf_len - len, "%25s\n",
616 "=================");
617 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
618 "Beacon Miss count", tgt_stats->cs_bmiss_cnt);
619 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
620 "Num Connects", tgt_stats->cs_connect_cnt);
621 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
622 "Num disconnects", tgt_stats->cs_discon_cnt);
623 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
624 "Beacon avg rssi", tgt_stats->cs_ave_beacon_rssi);
629 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
635 static const struct file_operations fops_tgt_stats = {
636 .read = read_file_tgt_stats,
637 .open = ath6kl_debugfs_open,
638 .owner = THIS_MODULE,
639 .llseek = default_llseek,
642 #define print_credit_info(fmt_str, ep_list_field) \
643 (len += scnprintf(buf + len, buf_len - len, fmt_str, \
644 ep_list->ep_list_field))
645 #define CREDIT_INFO_DISPLAY_STRING_LEN 200
646 #define CREDIT_INFO_LEN 128
648 static ssize_t read_file_credit_dist_stats(struct file *file,
649 char __user *user_buf,
650 size_t count, loff_t *ppos)
652 struct ath6kl *ar = file->private_data;
653 struct htc_target *target = ar->htc_target;
654 struct htc_endpoint_credit_dist *ep_list;
656 unsigned int buf_len, len = 0;
659 buf_len = CREDIT_INFO_DISPLAY_STRING_LEN +
660 get_queue_depth(&target->cred_dist_list) * CREDIT_INFO_LEN;
661 buf = kzalloc(buf_len, GFP_KERNEL);
665 len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
666 "Total Avail Credits: ",
667 target->credit_info->total_avail_credits);
668 len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
670 target->credit_info->cur_free_credits);
672 len += scnprintf(buf + len, buf_len - len,
673 " Epid Flags Cred_norm Cred_min Credits Cred_assngd"
674 " Seek_cred Cred_sz Cred_per_msg Cred_to_dist"
677 list_for_each_entry(ep_list, &target->cred_dist_list, list) {
678 print_credit_info(" %2d", endpoint);
679 print_credit_info("%10x", dist_flags);
680 print_credit_info("%8d", cred_norm);
681 print_credit_info("%9d", cred_min);
682 print_credit_info("%9d", credits);
683 print_credit_info("%10d", cred_assngd);
684 print_credit_info("%13d", seek_cred);
685 print_credit_info("%12d", cred_sz);
686 print_credit_info("%9d", cred_per_msg);
687 print_credit_info("%14d", cred_to_dist);
688 len += scnprintf(buf + len, buf_len - len, "%12d\n",
689 get_queue_depth(&ep_list->htc_ep->txq));
695 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
700 static const struct file_operations fops_credit_dist_stats = {
701 .read = read_file_credit_dist_stats,
702 .open = ath6kl_debugfs_open,
703 .owner = THIS_MODULE,
704 .llseek = default_llseek,
707 static unsigned int print_endpoint_stat(struct htc_target *target, char *buf,
708 unsigned int buf_len, unsigned int len,
709 int offset, const char *name)
712 struct htc_endpoint_stats *ep_st;
715 len += scnprintf(buf + len, buf_len - len, "%s:", name);
716 for (i = 0; i < ENDPOINT_MAX; i++) {
717 ep_st = &target->endpoint[i].ep_st;
718 counter = ((u32 *) ep_st) + (offset / 4);
719 len += scnprintf(buf + len, buf_len - len, " %u", *counter);
721 len += scnprintf(buf + len, buf_len - len, "\n");
726 static ssize_t ath6kl_endpoint_stats_read(struct file *file,
727 char __user *user_buf,
728 size_t count, loff_t *ppos)
730 struct ath6kl *ar = file->private_data;
731 struct htc_target *target = ar->htc_target;
733 unsigned int buf_len, len = 0;
736 buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) *
737 (25 + ENDPOINT_MAX * 11);
738 buf = kmalloc(buf_len, GFP_KERNEL);
742 #define EPSTAT(name) \
744 len = print_endpoint_stat(target, buf, buf_len, len, \
745 offsetof(struct htc_endpoint_stats, \
750 EPSTAT(cred_low_indicate);
752 EPSTAT(tx_pkt_bundled);
756 EPSTAT(cred_rpt_from_rx);
757 EPSTAT(cred_rpt_from_other);
758 EPSTAT(cred_rpt_ep0);
759 EPSTAT(cred_from_rx);
760 EPSTAT(cred_from_other);
761 EPSTAT(cred_from_ep0);
767 EPSTAT(rx_bundle_lkahd);
768 EPSTAT(rx_bundle_from_hdr);
769 EPSTAT(rx_alloc_thresh_hit);
770 EPSTAT(rxalloc_thresh_byte);
776 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
781 static ssize_t ath6kl_endpoint_stats_write(struct file *file,
782 const char __user *user_buf,
783 size_t count, loff_t *ppos)
785 struct ath6kl *ar = file->private_data;
786 struct htc_target *target = ar->htc_target;
789 struct htc_endpoint_stats *ep_st;
791 ret = kstrtou32_from_user(user_buf, count, 0, &val);
795 for (i = 0; i < ENDPOINT_MAX; i++) {
796 ep_st = &target->endpoint[i].ep_st;
797 memset(ep_st, 0, sizeof(*ep_st));
804 static const struct file_operations fops_endpoint_stats = {
805 .open = ath6kl_debugfs_open,
806 .read = ath6kl_endpoint_stats_read,
807 .write = ath6kl_endpoint_stats_write,
808 .owner = THIS_MODULE,
809 .llseek = default_llseek,
812 static unsigned long ath6kl_get_num_reg(void)
815 unsigned long n_reg = 0;
817 for (i = 0; i < ARRAY_SIZE(diag_reg); i++)
819 (diag_reg[i].reg_end - diag_reg[i].reg_start) / 4 + 1;
824 static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr)
828 for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
829 if (reg_addr >= diag_reg[i].reg_start &&
830 reg_addr <= diag_reg[i].reg_end)
837 static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
838 size_t count, loff_t *ppos)
840 struct ath6kl *ar = file->private_data;
842 unsigned int len = 0;
844 if (ar->debug.dbgfs_diag_reg)
845 len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n",
846 ar->debug.dbgfs_diag_reg);
848 len += scnprintf(buf + len, sizeof(buf) - len,
849 "All diag registers\n");
851 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
854 static ssize_t ath6kl_regread_write(struct file *file,
855 const char __user *user_buf,
856 size_t count, loff_t *ppos)
858 struct ath6kl *ar = file->private_data;
859 unsigned long reg_addr;
861 if (kstrtoul_from_user(user_buf, count, 0, ®_addr))
864 if ((reg_addr % 4) != 0)
867 if (reg_addr && !ath6kl_dbg_is_diag_reg_valid(reg_addr))
870 ar->debug.dbgfs_diag_reg = reg_addr;
875 static const struct file_operations fops_diag_reg_read = {
876 .read = ath6kl_regread_read,
877 .write = ath6kl_regread_write,
878 .open = ath6kl_debugfs_open,
879 .owner = THIS_MODULE,
880 .llseek = default_llseek,
883 static int ath6kl_regdump_open(struct inode *inode, struct file *file)
885 struct ath6kl *ar = inode->i_private;
887 unsigned long int reg_len;
888 unsigned int len = 0, n_reg;
893 /* Dump all the registers if no register is specified */
894 if (!ar->debug.dbgfs_diag_reg)
895 n_reg = ath6kl_get_num_reg();
899 reg_len = n_reg * REG_OUTPUT_LEN_PER_LINE;
901 reg_len += REGTYPE_STR_LEN;
903 buf = vmalloc(reg_len);
908 addr = ar->debug.dbgfs_diag_reg;
910 status = ath6kl_diag_read32(ar,
911 TARG_VTOP(ar->target_type, addr),
916 len += scnprintf(buf + len, reg_len - len,
917 "0x%06x 0x%08x\n", addr, le32_to_cpu(reg_val));
921 for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
922 len += scnprintf(buf + len, reg_len - len,
923 "%s\n", diag_reg[i].reg_info);
924 for (addr = diag_reg[i].reg_start;
925 addr <= diag_reg[i].reg_end; addr += 4) {
926 status = ath6kl_diag_read32(ar,
927 TARG_VTOP(ar->target_type, addr),
932 len += scnprintf(buf + len, reg_len - len,
934 addr, le32_to_cpu(reg_val));
939 file->private_data = buf;
943 ath6kl_warn("Unable to read memory:%u\n", addr);
948 static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf,
949 size_t count, loff_t *ppos)
951 u8 *buf = file->private_data;
952 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
955 static int ath6kl_regdump_release(struct inode *inode, struct file *file)
957 vfree(file->private_data);
961 static const struct file_operations fops_reg_dump = {
962 .open = ath6kl_regdump_open,
963 .read = ath6kl_regdump_read,
964 .release = ath6kl_regdump_release,
965 .owner = THIS_MODULE,
966 .llseek = default_llseek,
969 static ssize_t ath6kl_lrssi_roam_write(struct file *file,
970 const char __user *user_buf,
971 size_t count, loff_t *ppos)
973 struct ath6kl *ar = file->private_data;
974 unsigned long lrssi_roam_threshold;
976 if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
979 ar->lrssi_roam_threshold = lrssi_roam_threshold;
981 ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold);
986 static ssize_t ath6kl_lrssi_roam_read(struct file *file,
987 char __user *user_buf,
988 size_t count, loff_t *ppos)
990 struct ath6kl *ar = file->private_data;
994 len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold);
996 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
999 static const struct file_operations fops_lrssi_roam_threshold = {
1000 .read = ath6kl_lrssi_roam_read,
1001 .write = ath6kl_lrssi_roam_write,
1002 .open = ath6kl_debugfs_open,
1003 .owner = THIS_MODULE,
1004 .llseek = default_llseek,
1007 static ssize_t ath6kl_regwrite_read(struct file *file,
1008 char __user *user_buf,
1009 size_t count, loff_t *ppos)
1011 struct ath6kl *ar = file->private_data;
1013 unsigned int len = 0;
1015 len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
1016 ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
1018 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1021 static ssize_t ath6kl_regwrite_write(struct file *file,
1022 const char __user *user_buf,
1023 size_t count, loff_t *ppos)
1025 struct ath6kl *ar = file->private_data;
1028 unsigned int len = 0;
1029 u32 reg_addr, reg_val;
1031 len = min(count, sizeof(buf) - 1);
1032 if (copy_from_user(buf, user_buf, len))
1038 token = strsep(&sptr, "=");
1042 if (kstrtou32(token, 0, ®_addr))
1045 if (!ath6kl_dbg_is_diag_reg_valid(reg_addr))
1048 if (kstrtou32(sptr, 0, ®_val))
1051 ar->debug.diag_reg_addr_wr = reg_addr;
1052 ar->debug.diag_reg_val_wr = reg_val;
1054 if (ath6kl_diag_write32(ar, ar->debug.diag_reg_addr_wr,
1055 cpu_to_le32(ar->debug.diag_reg_val_wr)))
1061 static const struct file_operations fops_diag_reg_write = {
1062 .read = ath6kl_regwrite_read,
1063 .write = ath6kl_regwrite_write,
1064 .open = ath6kl_debugfs_open,
1065 .owner = THIS_MODULE,
1066 .llseek = default_llseek,
1069 int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf,
1072 const struct wmi_target_roam_tbl *tbl;
1075 if (len < sizeof(*tbl))
1078 tbl = (const struct wmi_target_roam_tbl *) buf;
1079 num_entries = le16_to_cpu(tbl->num_entries);
1080 if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) >
1084 if (ar->debug.roam_tbl == NULL ||
1085 ar->debug.roam_tbl_len < (unsigned int) len) {
1086 kfree(ar->debug.roam_tbl);
1087 ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC);
1088 if (ar->debug.roam_tbl == NULL)
1092 memcpy(ar->debug.roam_tbl, buf, len);
1093 ar->debug.roam_tbl_len = len;
1095 if (test_bit(ROAM_TBL_PEND, &ar->flag)) {
1096 clear_bit(ROAM_TBL_PEND, &ar->flag);
1097 wake_up(&ar->event_wq);
1103 static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
1104 size_t count, loff_t *ppos)
1106 struct ath6kl *ar = file->private_data;
1109 struct wmi_target_roam_tbl *tbl;
1112 unsigned int len, buf_len;
1115 if (down_interruptible(&ar->sem))
1118 set_bit(ROAM_TBL_PEND, &ar->flag);
1120 ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi);
1126 left = wait_event_interruptible_timeout(
1127 ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT);
1133 if (ar->debug.roam_tbl == NULL)
1136 tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl;
1137 num_entries = le16_to_cpu(tbl->num_entries);
1139 buf_len = 100 + num_entries * 100;
1140 buf = kzalloc(buf_len, GFP_KERNEL);
1144 len += scnprintf(buf + len, buf_len - len,
1146 "# roam_util bssid rssi rssidt last_rssi util bias\n",
1147 le16_to_cpu(tbl->roam_mode));
1149 for (i = 0; i < num_entries; i++) {
1150 struct wmi_bss_roam_info *info = &tbl->info[i];
1151 len += scnprintf(buf + len, buf_len - len,
1152 "%d %pM %d %d %d %d %d\n",
1153 a_sle32_to_cpu(info->roam_util), info->bssid,
1154 info->rssi, info->rssidt, info->last_rssi,
1155 info->util, info->bias);
1161 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1167 static const struct file_operations fops_roam_table = {
1168 .read = ath6kl_roam_table_read,
1169 .open = ath6kl_debugfs_open,
1170 .owner = THIS_MODULE,
1171 .llseek = default_llseek,
1174 static ssize_t ath6kl_force_roam_write(struct file *file,
1175 const char __user *user_buf,
1176 size_t count, loff_t *ppos)
1178 struct ath6kl *ar = file->private_data;
1186 len = min(count, sizeof(buf) - 1);
1187 if (copy_from_user(buf, user_buf, len))
1191 if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
1192 &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
1195 for (i = 0; i < ETH_ALEN; i++)
1198 ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid);
1205 static const struct file_operations fops_force_roam = {
1206 .write = ath6kl_force_roam_write,
1207 .open = ath6kl_debugfs_open,
1208 .owner = THIS_MODULE,
1209 .llseek = default_llseek,
1212 static ssize_t ath6kl_roam_mode_write(struct file *file,
1213 const char __user *user_buf,
1214 size_t count, loff_t *ppos)
1216 struct ath6kl *ar = file->private_data;
1220 enum wmi_roam_mode mode;
1222 len = min(count, sizeof(buf) - 1);
1223 if (copy_from_user(buf, user_buf, len))
1226 if (len > 0 && buf[len - 1] == '\n')
1227 buf[len - 1] = '\0';
1229 if (strcasecmp(buf, "default") == 0)
1230 mode = WMI_DEFAULT_ROAM_MODE;
1231 else if (strcasecmp(buf, "bssbias") == 0)
1232 mode = WMI_HOST_BIAS_ROAM_MODE;
1233 else if (strcasecmp(buf, "lock") == 0)
1234 mode = WMI_LOCK_BSS_MODE;
1238 ret = ath6kl_wmi_set_roam_mode_cmd(ar->wmi, mode);
1245 static const struct file_operations fops_roam_mode = {
1246 .write = ath6kl_roam_mode_write,
1247 .open = ath6kl_debugfs_open,
1248 .owner = THIS_MODULE,
1249 .llseek = default_llseek,
1252 void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive)
1254 ar->debug.keepalive = keepalive;
1257 static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf,
1258 size_t count, loff_t *ppos)
1260 struct ath6kl *ar = file->private_data;
1264 len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive);
1266 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1269 static ssize_t ath6kl_keepalive_write(struct file *file,
1270 const char __user *user_buf,
1271 size_t count, loff_t *ppos)
1273 struct ath6kl *ar = file->private_data;
1277 ret = kstrtou8_from_user(user_buf, count, 0, &val);
1281 ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, 0, val);
1288 static const struct file_operations fops_keepalive = {
1289 .open = ath6kl_debugfs_open,
1290 .read = ath6kl_keepalive_read,
1291 .write = ath6kl_keepalive_write,
1292 .owner = THIS_MODULE,
1293 .llseek = default_llseek,
1296 void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout)
1298 ar->debug.disc_timeout = timeout;
1301 static ssize_t ath6kl_disconnect_timeout_read(struct file *file,
1302 char __user *user_buf,
1303 size_t count, loff_t *ppos)
1305 struct ath6kl *ar = file->private_data;
1309 len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout);
1311 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1314 static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
1315 const char __user *user_buf,
1316 size_t count, loff_t *ppos)
1318 struct ath6kl *ar = file->private_data;
1322 ret = kstrtou8_from_user(user_buf, count, 0, &val);
1326 ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, 0, val);
1333 static const struct file_operations fops_disconnect_timeout = {
1334 .open = ath6kl_debugfs_open,
1335 .read = ath6kl_disconnect_timeout_read,
1336 .write = ath6kl_disconnect_timeout_write,
1337 .owner = THIS_MODULE,
1338 .llseek = default_llseek,
1341 static ssize_t ath6kl_create_qos_write(struct file *file,
1342 const char __user *user_buf,
1343 size_t count, loff_t *ppos)
1346 struct ath6kl *ar = file->private_data;
1347 struct ath6kl_vif *vif;
1351 struct wmi_create_pstream_cmd pstream;
1355 vif = ath6kl_vif_first(ar);
1359 len = min(count, sizeof(buf) - 1);
1360 if (copy_from_user(buf, user_buf, len))
1365 token = strsep(&sptr, " ");
1368 if (kstrtou8(token, 0, &pstream.user_pri))
1371 token = strsep(&sptr, " ");
1374 if (kstrtou8(token, 0, &pstream.traffic_direc))
1377 token = strsep(&sptr, " ");
1380 if (kstrtou8(token, 0, &pstream.traffic_class))
1383 token = strsep(&sptr, " ");
1386 if (kstrtou8(token, 0, &pstream.traffic_type))
1389 token = strsep(&sptr, " ");
1392 if (kstrtou8(token, 0, &pstream.voice_psc_cap))
1395 token = strsep(&sptr, " ");
1398 if (kstrtou32(token, 0, &val32))
1400 pstream.min_service_int = cpu_to_le32(val32);
1402 token = strsep(&sptr, " ");
1405 if (kstrtou32(token, 0, &val32))
1407 pstream.max_service_int = cpu_to_le32(val32);
1409 token = strsep(&sptr, " ");
1412 if (kstrtou32(token, 0, &val32))
1414 pstream.inactivity_int = cpu_to_le32(val32);
1416 token = strsep(&sptr, " ");
1419 if (kstrtou32(token, 0, &val32))
1421 pstream.suspension_int = cpu_to_le32(val32);
1423 token = strsep(&sptr, " ");
1426 if (kstrtou32(token, 0, &val32))
1428 pstream.service_start_time = cpu_to_le32(val32);
1430 token = strsep(&sptr, " ");
1433 if (kstrtou8(token, 0, &pstream.tsid))
1436 token = strsep(&sptr, " ");
1439 if (kstrtou16(token, 0, &val16))
1441 pstream.nominal_msdu = cpu_to_le16(val16);
1443 token = strsep(&sptr, " ");
1446 if (kstrtou16(token, 0, &val16))
1448 pstream.max_msdu = cpu_to_le16(val16);
1450 token = strsep(&sptr, " ");
1453 if (kstrtou32(token, 0, &val32))
1455 pstream.min_data_rate = cpu_to_le32(val32);
1457 token = strsep(&sptr, " ");
1460 if (kstrtou32(token, 0, &val32))
1462 pstream.mean_data_rate = cpu_to_le32(val32);
1464 token = strsep(&sptr, " ");
1467 if (kstrtou32(token, 0, &val32))
1469 pstream.peak_data_rate = cpu_to_le32(val32);
1471 token = strsep(&sptr, " ");
1474 if (kstrtou32(token, 0, &val32))
1476 pstream.max_burst_size = cpu_to_le32(val32);
1478 token = strsep(&sptr, " ");
1481 if (kstrtou32(token, 0, &val32))
1483 pstream.delay_bound = cpu_to_le32(val32);
1485 token = strsep(&sptr, " ");
1488 if (kstrtou32(token, 0, &val32))
1490 pstream.min_phy_rate = cpu_to_le32(val32);
1492 token = strsep(&sptr, " ");
1495 if (kstrtou32(token, 0, &val32))
1497 pstream.sba = cpu_to_le32(val32);
1499 token = strsep(&sptr, " ");
1502 if (kstrtou32(token, 0, &val32))
1504 pstream.medium_time = cpu_to_le32(val32);
1506 pstream.nominal_phy = le32_to_cpu(pstream.min_phy_rate) / 1000000;
1508 ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream);
1513 static const struct file_operations fops_create_qos = {
1514 .write = ath6kl_create_qos_write,
1515 .open = ath6kl_debugfs_open,
1516 .owner = THIS_MODULE,
1517 .llseek = default_llseek,
1520 static ssize_t ath6kl_delete_qos_write(struct file *file,
1521 const char __user *user_buf,
1522 size_t count, loff_t *ppos)
1525 struct ath6kl *ar = file->private_data;
1526 struct ath6kl_vif *vif;
1533 vif = ath6kl_vif_first(ar);
1537 len = min(count, sizeof(buf) - 1);
1538 if (copy_from_user(buf, user_buf, len))
1543 token = strsep(&sptr, " ");
1546 if (kstrtou8(token, 0, &traffic_class))
1549 token = strsep(&sptr, " ");
1552 if (kstrtou8(token, 0, &tsid))
1555 ath6kl_wmi_delete_pstream_cmd(ar->wmi, vif->fw_vif_idx,
1556 traffic_class, tsid);
1561 static const struct file_operations fops_delete_qos = {
1562 .write = ath6kl_delete_qos_write,
1563 .open = ath6kl_debugfs_open,
1564 .owner = THIS_MODULE,
1565 .llseek = default_llseek,
1568 static ssize_t ath6kl_bgscan_int_write(struct file *file,
1569 const char __user *user_buf,
1570 size_t count, loff_t *ppos)
1572 struct ath6kl *ar = file->private_data;
1577 len = min(count, sizeof(buf) - 1);
1578 if (copy_from_user(buf, user_buf, len))
1582 if (kstrtou16(buf, 0, &bgscan_int))
1585 if (bgscan_int == 0)
1586 bgscan_int = 0xffff;
1588 ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3,
1594 static const struct file_operations fops_bgscan_int = {
1595 .write = ath6kl_bgscan_int_write,
1596 .open = ath6kl_debugfs_open,
1597 .owner = THIS_MODULE,
1598 .llseek = default_llseek,
1601 static ssize_t ath6kl_listen_int_write(struct file *file,
1602 const char __user *user_buf,
1603 size_t count, loff_t *ppos)
1605 struct ath6kl *ar = file->private_data;
1606 struct ath6kl_vif *vif;
1607 u16 listen_interval;
1611 vif = ath6kl_vif_first(ar);
1615 len = min(count, sizeof(buf) - 1);
1616 if (copy_from_user(buf, user_buf, len))
1620 if (kstrtou16(buf, 0, &listen_interval))
1623 if ((listen_interval < 15) || (listen_interval > 3000))
1626 vif->listen_intvl_t = listen_interval;
1627 ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
1628 vif->listen_intvl_t, 0);
1633 static ssize_t ath6kl_listen_int_read(struct file *file,
1634 char __user *user_buf,
1635 size_t count, loff_t *ppos)
1637 struct ath6kl *ar = file->private_data;
1638 struct ath6kl_vif *vif;
1642 vif = ath6kl_vif_first(ar);
1646 len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t);
1648 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1651 static const struct file_operations fops_listen_int = {
1652 .read = ath6kl_listen_int_read,
1653 .write = ath6kl_listen_int_write,
1654 .open = ath6kl_debugfs_open,
1655 .owner = THIS_MODULE,
1656 .llseek = default_llseek,
1659 static ssize_t ath6kl_power_params_write(struct file *file,
1660 const char __user *user_buf,
1661 size_t count, loff_t *ppos)
1663 struct ath6kl *ar = file->private_data;
1665 unsigned int len = 0;
1667 u16 idle_period, ps_poll_num, dtim,
1670 len = min(count, sizeof(buf) - 1);
1671 if (copy_from_user(buf, user_buf, len))
1676 token = strsep(&sptr, " ");
1679 if (kstrtou16(token, 0, &idle_period))
1682 token = strsep(&sptr, " ");
1685 if (kstrtou16(token, 0, &ps_poll_num))
1688 token = strsep(&sptr, " ");
1691 if (kstrtou16(token, 0, &dtim))
1694 token = strsep(&sptr, " ");
1697 if (kstrtou16(token, 0, &tx_wakeup))
1700 token = strsep(&sptr, " ");
1703 if (kstrtou16(token, 0, &num_tx))
1706 ath6kl_wmi_pmparams_cmd(ar->wmi, 0, idle_period, ps_poll_num,
1707 dtim, tx_wakeup, num_tx, 0);
1712 static const struct file_operations fops_power_params = {
1713 .write = ath6kl_power_params_write,
1714 .open = ath6kl_debugfs_open,
1715 .owner = THIS_MODULE,
1716 .llseek = default_llseek,
1719 void ath6kl_debug_init(struct ath6kl *ar)
1721 skb_queue_head_init(&ar->debug.fwlog_queue);
1722 init_completion(&ar->debug.fwlog_completion);
1725 * Actually we are lying here but don't know how to read the mask
1726 * value from the firmware.
1728 ar->debug.fwlog_mask = 0;
1732 * Initialisation needs to happen in two stages as fwlog events can come
1733 * before cfg80211 is initialised, and debugfs depends on cfg80211
1736 int ath6kl_debug_init_fs(struct ath6kl *ar)
1738 ar->debugfs_phy = debugfs_create_dir("ath6kl",
1739 ar->wiphy->debugfsdir);
1740 if (!ar->debugfs_phy)
1743 debugfs_create_file("tgt_stats", S_IRUSR, ar->debugfs_phy, ar,
1746 debugfs_create_file("credit_dist_stats", S_IRUSR, ar->debugfs_phy, ar,
1747 &fops_credit_dist_stats);
1749 debugfs_create_file("endpoint_stats", S_IRUSR | S_IWUSR,
1750 ar->debugfs_phy, ar, &fops_endpoint_stats);
1752 debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar,
1755 debugfs_create_file("fwlog_block", S_IRUSR, ar->debugfs_phy, ar,
1758 debugfs_create_file("fwlog_mask", S_IRUSR | S_IWUSR, ar->debugfs_phy,
1759 ar, &fops_fwlog_mask);
1761 debugfs_create_file("reg_addr", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
1762 &fops_diag_reg_read);
1764 debugfs_create_file("reg_dump", S_IRUSR, ar->debugfs_phy, ar,
1767 debugfs_create_file("lrssi_roam_threshold", S_IRUSR | S_IWUSR,
1768 ar->debugfs_phy, ar, &fops_lrssi_roam_threshold);
1770 debugfs_create_file("reg_write", S_IRUSR | S_IWUSR,
1771 ar->debugfs_phy, ar, &fops_diag_reg_write);
1773 debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar,
1776 debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar,
1779 debugfs_create_file("force_roam", S_IWUSR, ar->debugfs_phy, ar,
1782 debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar,
1785 debugfs_create_file("keepalive", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
1788 debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR,
1789 ar->debugfs_phy, ar, &fops_disconnect_timeout);
1791 debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar,
1794 debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar,
1797 debugfs_create_file("bgscan_interval", S_IWUSR,
1798 ar->debugfs_phy, ar, &fops_bgscan_int);
1800 debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR,
1801 ar->debugfs_phy, ar, &fops_listen_int);
1803 debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar,
1804 &fops_power_params);
1809 void ath6kl_debug_cleanup(struct ath6kl *ar)
1811 skb_queue_purge(&ar->debug.fwlog_queue);
1812 kfree(ar->debug.roam_tbl);