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 void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war)
223 case ATH6KL_WAR_INVALID_RATE:
224 ar->debug.war_stats.invalid_rate++;
229 static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
230 size_t count, loff_t *ppos)
232 struct ath6kl *ar = file->private_data;
234 unsigned int len = 0, buf_len = 1500;
237 buf = kzalloc(buf_len, GFP_KERNEL);
241 len += scnprintf(buf + len, buf_len - len, "\n");
242 len += scnprintf(buf + len, buf_len - len, "%25s\n",
244 len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
245 "=================");
246 len += scnprintf(buf + len, buf_len - len, "%20s %10u\n",
247 "Invalid rates", ar->debug.war_stats.invalid_rate);
249 if (WARN_ON(len > buf_len))
252 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
258 static const struct file_operations fops_war_stats = {
259 .read = read_file_war_stats,
261 .owner = THIS_MODULE,
262 .llseek = default_llseek,
265 void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len)
267 struct ath6kl_fwlog_slot *slot;
271 if (WARN_ON(len > ATH6KL_FWLOG_PAYLOAD_SIZE))
274 slot_len = sizeof(*slot) + ATH6KL_FWLOG_PAYLOAD_SIZE;
276 skb = alloc_skb(slot_len, GFP_KERNEL);
280 slot = (struct ath6kl_fwlog_slot *) skb_put(skb, slot_len);
281 slot->timestamp = cpu_to_le32(jiffies);
282 slot->length = cpu_to_le32(len);
283 memcpy(slot->payload, buf, len);
285 /* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */
286 memset(slot->payload + len, 0, ATH6KL_FWLOG_PAYLOAD_SIZE - len);
288 spin_lock(&ar->debug.fwlog_queue.lock);
290 __skb_queue_tail(&ar->debug.fwlog_queue, skb);
291 complete(&ar->debug.fwlog_completion);
293 /* drop oldest entries */
294 while (skb_queue_len(&ar->debug.fwlog_queue) >
295 ATH6KL_FWLOG_MAX_ENTRIES) {
296 skb = __skb_dequeue(&ar->debug.fwlog_queue);
300 spin_unlock(&ar->debug.fwlog_queue.lock);
305 static int ath6kl_fwlog_open(struct inode *inode, struct file *file)
307 struct ath6kl *ar = inode->i_private;
309 if (ar->debug.fwlog_open)
312 ar->debug.fwlog_open = true;
314 file->private_data = inode->i_private;
318 static int ath6kl_fwlog_release(struct inode *inode, struct file *file)
320 struct ath6kl *ar = inode->i_private;
322 ar->debug.fwlog_open = false;
327 static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
328 size_t count, loff_t *ppos)
330 struct ath6kl *ar = file->private_data;
336 buf = vmalloc(count);
340 /* read undelivered logs from firmware */
341 ath6kl_read_fwlogs(ar);
343 spin_lock(&ar->debug.fwlog_queue.lock);
345 while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
346 if (skb->len > count - len) {
347 /* not enough space, put skb back and leave */
348 __skb_queue_head(&ar->debug.fwlog_queue, skb);
353 memcpy(buf + len, skb->data, skb->len);
359 spin_unlock(&ar->debug.fwlog_queue.lock);
361 /* FIXME: what to do if len == 0? */
363 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
370 static const struct file_operations fops_fwlog = {
371 .open = ath6kl_fwlog_open,
372 .release = ath6kl_fwlog_release,
373 .read = ath6kl_fwlog_read,
374 .owner = THIS_MODULE,
375 .llseek = default_llseek,
378 static ssize_t ath6kl_fwlog_block_read(struct file *file,
379 char __user *user_buf,
383 struct ath6kl *ar = file->private_data;
386 size_t len = 0, not_copied;
390 buf = vmalloc(count);
394 spin_lock(&ar->debug.fwlog_queue.lock);
396 if (skb_queue_len(&ar->debug.fwlog_queue) == 0) {
397 /* we must init under queue lock */
398 init_completion(&ar->debug.fwlog_completion);
400 spin_unlock(&ar->debug.fwlog_queue.lock);
402 ret = wait_for_completion_interruptible(
403 &ar->debug.fwlog_completion);
404 if (ret == -ERESTARTSYS) {
409 spin_lock(&ar->debug.fwlog_queue.lock);
412 while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
413 if (skb->len > count - len) {
414 /* not enough space, put skb back and leave */
415 __skb_queue_head(&ar->debug.fwlog_queue, skb);
420 memcpy(buf + len, skb->data, skb->len);
426 spin_unlock(&ar->debug.fwlog_queue.lock);
428 /* FIXME: what to do if len == 0? */
430 not_copied = copy_to_user(user_buf, buf, len);
431 if (not_copied != 0) {
446 static const struct file_operations fops_fwlog_block = {
447 .open = ath6kl_fwlog_open,
448 .release = ath6kl_fwlog_release,
449 .read = ath6kl_fwlog_block_read,
450 .owner = THIS_MODULE,
451 .llseek = default_llseek,
454 static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf,
455 size_t count, loff_t *ppos)
457 struct ath6kl *ar = file->private_data;
461 len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask);
463 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
466 static ssize_t ath6kl_fwlog_mask_write(struct file *file,
467 const char __user *user_buf,
468 size_t count, loff_t *ppos)
470 struct ath6kl *ar = file->private_data;
473 ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask);
477 ret = ath6kl_wmi_config_debug_module_cmd(ar->wmi,
478 ATH6KL_FWLOG_VALID_MASK,
479 ar->debug.fwlog_mask);
486 static const struct file_operations fops_fwlog_mask = {
488 .read = ath6kl_fwlog_mask_read,
489 .write = ath6kl_fwlog_mask_write,
490 .owner = THIS_MODULE,
491 .llseek = default_llseek,
494 static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
495 size_t count, loff_t *ppos)
497 struct ath6kl *ar = file->private_data;
498 struct ath6kl_vif *vif;
499 struct target_stats *tgt_stats;
501 unsigned int len = 0, buf_len = 1500;
506 vif = ath6kl_vif_first(ar);
510 tgt_stats = &vif->target_stats;
512 buf = kzalloc(buf_len, GFP_KERNEL);
516 if (down_interruptible(&ar->sem)) {
521 set_bit(STATS_UPDATE_PEND, &vif->flags);
523 if (ath6kl_wmi_get_stats_cmd(ar->wmi, 0)) {
529 left = wait_event_interruptible_timeout(ar->event_wq,
530 !test_bit(STATS_UPDATE_PEND,
531 &vif->flags), WMI_TIMEOUT);
540 len += scnprintf(buf + len, buf_len - len, "\n");
541 len += scnprintf(buf + len, buf_len - len, "%25s\n",
543 len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
544 "=================");
545 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
546 "Ucast packets", tgt_stats->tx_ucast_pkt);
547 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
548 "Bcast packets", tgt_stats->tx_bcast_pkt);
549 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
550 "Ucast byte", tgt_stats->tx_ucast_byte);
551 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
552 "Bcast byte", tgt_stats->tx_bcast_byte);
553 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
554 "Rts success cnt", tgt_stats->tx_rts_success_cnt);
555 for (i = 0; i < 4; i++)
556 len += scnprintf(buf + len, buf_len - len,
557 "%18s %d %10llu\n", "PER on ac",
558 i, tgt_stats->tx_pkt_per_ac[i]);
559 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
560 "Error", tgt_stats->tx_err);
561 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
562 "Fail count", tgt_stats->tx_fail_cnt);
563 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
564 "Retry count", tgt_stats->tx_retry_cnt);
565 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
566 "Multi retry cnt", tgt_stats->tx_mult_retry_cnt);
567 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
568 "Rts fail cnt", tgt_stats->tx_rts_fail_cnt);
569 len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n\n",
570 "TKIP counter measure used",
571 tgt_stats->tkip_cnter_measures_invoked);
573 len += scnprintf(buf + len, buf_len - len, "%25s\n",
575 len += scnprintf(buf + len, buf_len - len, "%25s\n",
576 "=================");
578 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
579 "Ucast packets", tgt_stats->rx_ucast_pkt);
580 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
581 "Ucast Rate", tgt_stats->rx_ucast_rate);
582 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
583 "Bcast packets", tgt_stats->rx_bcast_pkt);
584 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
585 "Ucast byte", tgt_stats->rx_ucast_byte);
586 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
587 "Bcast byte", tgt_stats->rx_bcast_byte);
588 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
589 "Fragmented pkt", tgt_stats->rx_frgment_pkt);
590 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
591 "Error", tgt_stats->rx_err);
592 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
593 "CRC Err", tgt_stats->rx_crc_err);
594 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
595 "Key chache miss", tgt_stats->rx_key_cache_miss);
596 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
597 "Decrypt Err", tgt_stats->rx_decrypt_err);
598 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
599 "Duplicate frame", tgt_stats->rx_dupl_frame);
600 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
601 "Tkip Mic failure", tgt_stats->tkip_local_mic_fail);
602 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
603 "TKIP format err", tgt_stats->tkip_fmt_err);
604 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
605 "CCMP format Err", tgt_stats->ccmp_fmt_err);
606 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n\n",
607 "CCMP Replay Err", tgt_stats->ccmp_replays);
609 len += scnprintf(buf + len, buf_len - len, "%25s\n",
610 "Misc Target stats");
611 len += scnprintf(buf + len, buf_len - len, "%25s\n",
612 "=================");
613 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
614 "Beacon Miss count", tgt_stats->cs_bmiss_cnt);
615 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
616 "Num Connects", tgt_stats->cs_connect_cnt);
617 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
618 "Num disconnects", tgt_stats->cs_discon_cnt);
619 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
620 "Beacon avg rssi", tgt_stats->cs_ave_beacon_rssi);
621 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
622 "ARP pkt received", tgt_stats->arp_received);
623 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
624 "ARP pkt matched", tgt_stats->arp_matched);
625 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
626 "ARP pkt replied", tgt_stats->arp_replied);
631 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
637 static const struct file_operations fops_tgt_stats = {
638 .read = read_file_tgt_stats,
640 .owner = THIS_MODULE,
641 .llseek = default_llseek,
644 #define print_credit_info(fmt_str, ep_list_field) \
645 (len += scnprintf(buf + len, buf_len - len, fmt_str, \
646 ep_list->ep_list_field))
647 #define CREDIT_INFO_DISPLAY_STRING_LEN 200
648 #define CREDIT_INFO_LEN 128
650 static ssize_t read_file_credit_dist_stats(struct file *file,
651 char __user *user_buf,
652 size_t count, loff_t *ppos)
654 struct ath6kl *ar = file->private_data;
655 struct htc_target *target = ar->htc_target;
656 struct htc_endpoint_credit_dist *ep_list;
658 unsigned int buf_len, len = 0;
661 buf_len = CREDIT_INFO_DISPLAY_STRING_LEN +
662 get_queue_depth(&target->cred_dist_list) * CREDIT_INFO_LEN;
663 buf = kzalloc(buf_len, GFP_KERNEL);
667 len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
668 "Total Avail Credits: ",
669 target->credit_info->total_avail_credits);
670 len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
672 target->credit_info->cur_free_credits);
674 len += scnprintf(buf + len, buf_len - len,
675 " Epid Flags Cred_norm Cred_min Credits Cred_assngd"
676 " Seek_cred Cred_sz Cred_per_msg Cred_to_dist"
679 list_for_each_entry(ep_list, &target->cred_dist_list, list) {
680 print_credit_info(" %2d", endpoint);
681 print_credit_info("%10x", dist_flags);
682 print_credit_info("%8d", cred_norm);
683 print_credit_info("%9d", cred_min);
684 print_credit_info("%9d", credits);
685 print_credit_info("%10d", cred_assngd);
686 print_credit_info("%13d", seek_cred);
687 print_credit_info("%12d", cred_sz);
688 print_credit_info("%9d", cred_per_msg);
689 print_credit_info("%14d", cred_to_dist);
690 len += scnprintf(buf + len, buf_len - len, "%12d\n",
691 get_queue_depth(&ep_list->htc_ep->txq));
697 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
702 static const struct file_operations fops_credit_dist_stats = {
703 .read = read_file_credit_dist_stats,
705 .owner = THIS_MODULE,
706 .llseek = default_llseek,
709 static unsigned int print_endpoint_stat(struct htc_target *target, char *buf,
710 unsigned int buf_len, unsigned int len,
711 int offset, const char *name)
714 struct htc_endpoint_stats *ep_st;
717 len += scnprintf(buf + len, buf_len - len, "%s:", name);
718 for (i = 0; i < ENDPOINT_MAX; i++) {
719 ep_st = &target->endpoint[i].ep_st;
720 counter = ((u32 *) ep_st) + (offset / 4);
721 len += scnprintf(buf + len, buf_len - len, " %u", *counter);
723 len += scnprintf(buf + len, buf_len - len, "\n");
728 static ssize_t ath6kl_endpoint_stats_read(struct file *file,
729 char __user *user_buf,
730 size_t count, loff_t *ppos)
732 struct ath6kl *ar = file->private_data;
733 struct htc_target *target = ar->htc_target;
735 unsigned int buf_len, len = 0;
738 buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) *
739 (25 + ENDPOINT_MAX * 11);
740 buf = kmalloc(buf_len, GFP_KERNEL);
744 #define EPSTAT(name) \
746 len = print_endpoint_stat(target, buf, buf_len, len, \
747 offsetof(struct htc_endpoint_stats, \
752 EPSTAT(cred_low_indicate);
754 EPSTAT(tx_pkt_bundled);
758 EPSTAT(cred_rpt_from_rx);
759 EPSTAT(cred_rpt_from_other);
760 EPSTAT(cred_rpt_ep0);
761 EPSTAT(cred_from_rx);
762 EPSTAT(cred_from_other);
763 EPSTAT(cred_from_ep0);
769 EPSTAT(rx_bundle_lkahd);
770 EPSTAT(rx_bundle_from_hdr);
771 EPSTAT(rx_alloc_thresh_hit);
772 EPSTAT(rxalloc_thresh_byte);
778 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
783 static ssize_t ath6kl_endpoint_stats_write(struct file *file,
784 const char __user *user_buf,
785 size_t count, loff_t *ppos)
787 struct ath6kl *ar = file->private_data;
788 struct htc_target *target = ar->htc_target;
791 struct htc_endpoint_stats *ep_st;
793 ret = kstrtou32_from_user(user_buf, count, 0, &val);
797 for (i = 0; i < ENDPOINT_MAX; i++) {
798 ep_st = &target->endpoint[i].ep_st;
799 memset(ep_st, 0, sizeof(*ep_st));
806 static const struct file_operations fops_endpoint_stats = {
808 .read = ath6kl_endpoint_stats_read,
809 .write = ath6kl_endpoint_stats_write,
810 .owner = THIS_MODULE,
811 .llseek = default_llseek,
814 static unsigned long ath6kl_get_num_reg(void)
817 unsigned long n_reg = 0;
819 for (i = 0; i < ARRAY_SIZE(diag_reg); i++)
821 (diag_reg[i].reg_end - diag_reg[i].reg_start) / 4 + 1;
826 static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr)
830 for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
831 if (reg_addr >= diag_reg[i].reg_start &&
832 reg_addr <= diag_reg[i].reg_end)
839 static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
840 size_t count, loff_t *ppos)
842 struct ath6kl *ar = file->private_data;
844 unsigned int len = 0;
846 if (ar->debug.dbgfs_diag_reg)
847 len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n",
848 ar->debug.dbgfs_diag_reg);
850 len += scnprintf(buf + len, sizeof(buf) - len,
851 "All diag registers\n");
853 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
856 static ssize_t ath6kl_regread_write(struct file *file,
857 const char __user *user_buf,
858 size_t count, loff_t *ppos)
860 struct ath6kl *ar = file->private_data;
861 unsigned long reg_addr;
863 if (kstrtoul_from_user(user_buf, count, 0, ®_addr))
866 if ((reg_addr % 4) != 0)
869 if (reg_addr && !ath6kl_dbg_is_diag_reg_valid(reg_addr))
872 ar->debug.dbgfs_diag_reg = reg_addr;
877 static const struct file_operations fops_diag_reg_read = {
878 .read = ath6kl_regread_read,
879 .write = ath6kl_regread_write,
881 .owner = THIS_MODULE,
882 .llseek = default_llseek,
885 static int ath6kl_regdump_open(struct inode *inode, struct file *file)
887 struct ath6kl *ar = inode->i_private;
889 unsigned long int reg_len;
890 unsigned int len = 0, n_reg;
895 /* Dump all the registers if no register is specified */
896 if (!ar->debug.dbgfs_diag_reg)
897 n_reg = ath6kl_get_num_reg();
901 reg_len = n_reg * REG_OUTPUT_LEN_PER_LINE;
903 reg_len += REGTYPE_STR_LEN;
905 buf = vmalloc(reg_len);
910 addr = ar->debug.dbgfs_diag_reg;
912 status = ath6kl_diag_read32(ar,
913 TARG_VTOP(ar->target_type, addr),
918 len += scnprintf(buf + len, reg_len - len,
919 "0x%06x 0x%08x\n", addr, le32_to_cpu(reg_val));
923 for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
924 len += scnprintf(buf + len, reg_len - len,
925 "%s\n", diag_reg[i].reg_info);
926 for (addr = diag_reg[i].reg_start;
927 addr <= diag_reg[i].reg_end; addr += 4) {
928 status = ath6kl_diag_read32(ar,
929 TARG_VTOP(ar->target_type, addr),
934 len += scnprintf(buf + len, reg_len - len,
936 addr, le32_to_cpu(reg_val));
941 file->private_data = buf;
945 ath6kl_warn("Unable to read memory:%u\n", addr);
950 static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf,
951 size_t count, loff_t *ppos)
953 u8 *buf = file->private_data;
954 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
957 static int ath6kl_regdump_release(struct inode *inode, struct file *file)
959 vfree(file->private_data);
963 static const struct file_operations fops_reg_dump = {
964 .open = ath6kl_regdump_open,
965 .read = ath6kl_regdump_read,
966 .release = ath6kl_regdump_release,
967 .owner = THIS_MODULE,
968 .llseek = default_llseek,
971 static ssize_t ath6kl_lrssi_roam_write(struct file *file,
972 const char __user *user_buf,
973 size_t count, loff_t *ppos)
975 struct ath6kl *ar = file->private_data;
976 unsigned long lrssi_roam_threshold;
978 if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
981 ar->lrssi_roam_threshold = lrssi_roam_threshold;
983 ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold);
988 static ssize_t ath6kl_lrssi_roam_read(struct file *file,
989 char __user *user_buf,
990 size_t count, loff_t *ppos)
992 struct ath6kl *ar = file->private_data;
996 len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold);
998 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1001 static const struct file_operations fops_lrssi_roam_threshold = {
1002 .read = ath6kl_lrssi_roam_read,
1003 .write = ath6kl_lrssi_roam_write,
1004 .open = simple_open,
1005 .owner = THIS_MODULE,
1006 .llseek = default_llseek,
1009 static ssize_t ath6kl_regwrite_read(struct file *file,
1010 char __user *user_buf,
1011 size_t count, loff_t *ppos)
1013 struct ath6kl *ar = file->private_data;
1015 unsigned int len = 0;
1017 len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
1018 ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
1020 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1023 static ssize_t ath6kl_regwrite_write(struct file *file,
1024 const char __user *user_buf,
1025 size_t count, loff_t *ppos)
1027 struct ath6kl *ar = file->private_data;
1030 unsigned int len = 0;
1031 u32 reg_addr, reg_val;
1033 len = min(count, sizeof(buf) - 1);
1034 if (copy_from_user(buf, user_buf, len))
1040 token = strsep(&sptr, "=");
1044 if (kstrtou32(token, 0, ®_addr))
1047 if (!ath6kl_dbg_is_diag_reg_valid(reg_addr))
1050 if (kstrtou32(sptr, 0, ®_val))
1053 ar->debug.diag_reg_addr_wr = reg_addr;
1054 ar->debug.diag_reg_val_wr = reg_val;
1056 if (ath6kl_diag_write32(ar, ar->debug.diag_reg_addr_wr,
1057 cpu_to_le32(ar->debug.diag_reg_val_wr)))
1063 static const struct file_operations fops_diag_reg_write = {
1064 .read = ath6kl_regwrite_read,
1065 .write = ath6kl_regwrite_write,
1066 .open = simple_open,
1067 .owner = THIS_MODULE,
1068 .llseek = default_llseek,
1071 int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf,
1074 const struct wmi_target_roam_tbl *tbl;
1077 if (len < sizeof(*tbl))
1080 tbl = (const struct wmi_target_roam_tbl *) buf;
1081 num_entries = le16_to_cpu(tbl->num_entries);
1082 if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) >
1086 if (ar->debug.roam_tbl == NULL ||
1087 ar->debug.roam_tbl_len < (unsigned int) len) {
1088 kfree(ar->debug.roam_tbl);
1089 ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC);
1090 if (ar->debug.roam_tbl == NULL)
1094 memcpy(ar->debug.roam_tbl, buf, len);
1095 ar->debug.roam_tbl_len = len;
1097 if (test_bit(ROAM_TBL_PEND, &ar->flag)) {
1098 clear_bit(ROAM_TBL_PEND, &ar->flag);
1099 wake_up(&ar->event_wq);
1105 static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
1106 size_t count, loff_t *ppos)
1108 struct ath6kl *ar = file->private_data;
1111 struct wmi_target_roam_tbl *tbl;
1114 unsigned int len, buf_len;
1117 if (down_interruptible(&ar->sem))
1120 set_bit(ROAM_TBL_PEND, &ar->flag);
1122 ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi);
1128 left = wait_event_interruptible_timeout(
1129 ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT);
1135 if (ar->debug.roam_tbl == NULL)
1138 tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl;
1139 num_entries = le16_to_cpu(tbl->num_entries);
1141 buf_len = 100 + num_entries * 100;
1142 buf = kzalloc(buf_len, GFP_KERNEL);
1146 len += scnprintf(buf + len, buf_len - len,
1148 "# roam_util bssid rssi rssidt last_rssi util bias\n",
1149 le16_to_cpu(tbl->roam_mode));
1151 for (i = 0; i < num_entries; i++) {
1152 struct wmi_bss_roam_info *info = &tbl->info[i];
1153 len += scnprintf(buf + len, buf_len - len,
1154 "%d %pM %d %d %d %d %d\n",
1155 a_sle32_to_cpu(info->roam_util), info->bssid,
1156 info->rssi, info->rssidt, info->last_rssi,
1157 info->util, info->bias);
1163 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1169 static const struct file_operations fops_roam_table = {
1170 .read = ath6kl_roam_table_read,
1171 .open = simple_open,
1172 .owner = THIS_MODULE,
1173 .llseek = default_llseek,
1176 static ssize_t ath6kl_force_roam_write(struct file *file,
1177 const char __user *user_buf,
1178 size_t count, loff_t *ppos)
1180 struct ath6kl *ar = file->private_data;
1188 len = min(count, sizeof(buf) - 1);
1189 if (copy_from_user(buf, user_buf, len))
1193 if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
1194 &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
1197 for (i = 0; i < ETH_ALEN; i++)
1200 ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid);
1207 static const struct file_operations fops_force_roam = {
1208 .write = ath6kl_force_roam_write,
1209 .open = simple_open,
1210 .owner = THIS_MODULE,
1211 .llseek = default_llseek,
1214 static ssize_t ath6kl_roam_mode_write(struct file *file,
1215 const char __user *user_buf,
1216 size_t count, loff_t *ppos)
1218 struct ath6kl *ar = file->private_data;
1222 enum wmi_roam_mode mode;
1224 len = min(count, sizeof(buf) - 1);
1225 if (copy_from_user(buf, user_buf, len))
1228 if (len > 0 && buf[len - 1] == '\n')
1229 buf[len - 1] = '\0';
1231 if (strcasecmp(buf, "default") == 0)
1232 mode = WMI_DEFAULT_ROAM_MODE;
1233 else if (strcasecmp(buf, "bssbias") == 0)
1234 mode = WMI_HOST_BIAS_ROAM_MODE;
1235 else if (strcasecmp(buf, "lock") == 0)
1236 mode = WMI_LOCK_BSS_MODE;
1240 ret = ath6kl_wmi_set_roam_mode_cmd(ar->wmi, mode);
1247 static const struct file_operations fops_roam_mode = {
1248 .write = ath6kl_roam_mode_write,
1249 .open = simple_open,
1250 .owner = THIS_MODULE,
1251 .llseek = default_llseek,
1254 void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive)
1256 ar->debug.keepalive = keepalive;
1259 static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf,
1260 size_t count, loff_t *ppos)
1262 struct ath6kl *ar = file->private_data;
1266 len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive);
1268 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1271 static ssize_t ath6kl_keepalive_write(struct file *file,
1272 const char __user *user_buf,
1273 size_t count, loff_t *ppos)
1275 struct ath6kl *ar = file->private_data;
1279 ret = kstrtou8_from_user(user_buf, count, 0, &val);
1283 ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, 0, val);
1290 static const struct file_operations fops_keepalive = {
1291 .open = simple_open,
1292 .read = ath6kl_keepalive_read,
1293 .write = ath6kl_keepalive_write,
1294 .owner = THIS_MODULE,
1295 .llseek = default_llseek,
1298 void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout)
1300 ar->debug.disc_timeout = timeout;
1303 static ssize_t ath6kl_disconnect_timeout_read(struct file *file,
1304 char __user *user_buf,
1305 size_t count, loff_t *ppos)
1307 struct ath6kl *ar = file->private_data;
1311 len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout);
1313 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1316 static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
1317 const char __user *user_buf,
1318 size_t count, loff_t *ppos)
1320 struct ath6kl *ar = file->private_data;
1324 ret = kstrtou8_from_user(user_buf, count, 0, &val);
1328 ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, 0, val);
1335 static const struct file_operations fops_disconnect_timeout = {
1336 .open = simple_open,
1337 .read = ath6kl_disconnect_timeout_read,
1338 .write = ath6kl_disconnect_timeout_write,
1339 .owner = THIS_MODULE,
1340 .llseek = default_llseek,
1343 static ssize_t ath6kl_create_qos_write(struct file *file,
1344 const char __user *user_buf,
1345 size_t count, loff_t *ppos)
1348 struct ath6kl *ar = file->private_data;
1349 struct ath6kl_vif *vif;
1353 struct wmi_create_pstream_cmd pstream;
1357 vif = ath6kl_vif_first(ar);
1361 len = min(count, sizeof(buf) - 1);
1362 if (copy_from_user(buf, user_buf, len))
1367 token = strsep(&sptr, " ");
1370 if (kstrtou8(token, 0, &pstream.user_pri))
1373 token = strsep(&sptr, " ");
1376 if (kstrtou8(token, 0, &pstream.traffic_direc))
1379 token = strsep(&sptr, " ");
1382 if (kstrtou8(token, 0, &pstream.traffic_class))
1385 token = strsep(&sptr, " ");
1388 if (kstrtou8(token, 0, &pstream.traffic_type))
1391 token = strsep(&sptr, " ");
1394 if (kstrtou8(token, 0, &pstream.voice_psc_cap))
1397 token = strsep(&sptr, " ");
1400 if (kstrtou32(token, 0, &val32))
1402 pstream.min_service_int = cpu_to_le32(val32);
1404 token = strsep(&sptr, " ");
1407 if (kstrtou32(token, 0, &val32))
1409 pstream.max_service_int = cpu_to_le32(val32);
1411 token = strsep(&sptr, " ");
1414 if (kstrtou32(token, 0, &val32))
1416 pstream.inactivity_int = cpu_to_le32(val32);
1418 token = strsep(&sptr, " ");
1421 if (kstrtou32(token, 0, &val32))
1423 pstream.suspension_int = cpu_to_le32(val32);
1425 token = strsep(&sptr, " ");
1428 if (kstrtou32(token, 0, &val32))
1430 pstream.service_start_time = cpu_to_le32(val32);
1432 token = strsep(&sptr, " ");
1435 if (kstrtou8(token, 0, &pstream.tsid))
1438 token = strsep(&sptr, " ");
1441 if (kstrtou16(token, 0, &val16))
1443 pstream.nominal_msdu = cpu_to_le16(val16);
1445 token = strsep(&sptr, " ");
1448 if (kstrtou16(token, 0, &val16))
1450 pstream.max_msdu = cpu_to_le16(val16);
1452 token = strsep(&sptr, " ");
1455 if (kstrtou32(token, 0, &val32))
1457 pstream.min_data_rate = cpu_to_le32(val32);
1459 token = strsep(&sptr, " ");
1462 if (kstrtou32(token, 0, &val32))
1464 pstream.mean_data_rate = cpu_to_le32(val32);
1466 token = strsep(&sptr, " ");
1469 if (kstrtou32(token, 0, &val32))
1471 pstream.peak_data_rate = cpu_to_le32(val32);
1473 token = strsep(&sptr, " ");
1476 if (kstrtou32(token, 0, &val32))
1478 pstream.max_burst_size = cpu_to_le32(val32);
1480 token = strsep(&sptr, " ");
1483 if (kstrtou32(token, 0, &val32))
1485 pstream.delay_bound = cpu_to_le32(val32);
1487 token = strsep(&sptr, " ");
1490 if (kstrtou32(token, 0, &val32))
1492 pstream.min_phy_rate = cpu_to_le32(val32);
1494 token = strsep(&sptr, " ");
1497 if (kstrtou32(token, 0, &val32))
1499 pstream.sba = cpu_to_le32(val32);
1501 token = strsep(&sptr, " ");
1504 if (kstrtou32(token, 0, &val32))
1506 pstream.medium_time = cpu_to_le32(val32);
1508 pstream.nominal_phy = le32_to_cpu(pstream.min_phy_rate) / 1000000;
1510 ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream);
1515 static const struct file_operations fops_create_qos = {
1516 .write = ath6kl_create_qos_write,
1517 .open = simple_open,
1518 .owner = THIS_MODULE,
1519 .llseek = default_llseek,
1522 static ssize_t ath6kl_delete_qos_write(struct file *file,
1523 const char __user *user_buf,
1524 size_t count, loff_t *ppos)
1527 struct ath6kl *ar = file->private_data;
1528 struct ath6kl_vif *vif;
1535 vif = ath6kl_vif_first(ar);
1539 len = min(count, sizeof(buf) - 1);
1540 if (copy_from_user(buf, user_buf, len))
1545 token = strsep(&sptr, " ");
1548 if (kstrtou8(token, 0, &traffic_class))
1551 token = strsep(&sptr, " ");
1554 if (kstrtou8(token, 0, &tsid))
1557 ath6kl_wmi_delete_pstream_cmd(ar->wmi, vif->fw_vif_idx,
1558 traffic_class, tsid);
1563 static const struct file_operations fops_delete_qos = {
1564 .write = ath6kl_delete_qos_write,
1565 .open = simple_open,
1566 .owner = THIS_MODULE,
1567 .llseek = default_llseek,
1570 static ssize_t ath6kl_bgscan_int_write(struct file *file,
1571 const char __user *user_buf,
1572 size_t count, loff_t *ppos)
1574 struct ath6kl *ar = file->private_data;
1575 struct ath6kl_vif *vif;
1580 vif = ath6kl_vif_first(ar);
1584 len = min(count, sizeof(buf) - 1);
1585 if (copy_from_user(buf, user_buf, len))
1589 if (kstrtou16(buf, 0, &bgscan_int))
1592 if (bgscan_int == 0)
1593 bgscan_int = 0xffff;
1595 vif->bg_scan_period = bgscan_int;
1597 ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3,
1603 static const struct file_operations fops_bgscan_int = {
1604 .write = ath6kl_bgscan_int_write,
1605 .open = simple_open,
1606 .owner = THIS_MODULE,
1607 .llseek = default_llseek,
1610 static ssize_t ath6kl_listen_int_write(struct file *file,
1611 const char __user *user_buf,
1612 size_t count, loff_t *ppos)
1614 struct ath6kl *ar = file->private_data;
1615 struct ath6kl_vif *vif;
1616 u16 listen_interval;
1620 vif = ath6kl_vif_first(ar);
1624 len = min(count, sizeof(buf) - 1);
1625 if (copy_from_user(buf, user_buf, len))
1629 if (kstrtou16(buf, 0, &listen_interval))
1632 if ((listen_interval < 15) || (listen_interval > 3000))
1635 vif->listen_intvl_t = listen_interval;
1636 ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
1637 vif->listen_intvl_t, 0);
1642 static ssize_t ath6kl_listen_int_read(struct file *file,
1643 char __user *user_buf,
1644 size_t count, loff_t *ppos)
1646 struct ath6kl *ar = file->private_data;
1647 struct ath6kl_vif *vif;
1651 vif = ath6kl_vif_first(ar);
1655 len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t);
1657 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1660 static const struct file_operations fops_listen_int = {
1661 .read = ath6kl_listen_int_read,
1662 .write = ath6kl_listen_int_write,
1663 .open = simple_open,
1664 .owner = THIS_MODULE,
1665 .llseek = default_llseek,
1668 static ssize_t ath6kl_power_params_write(struct file *file,
1669 const char __user *user_buf,
1670 size_t count, loff_t *ppos)
1672 struct ath6kl *ar = file->private_data;
1674 unsigned int len = 0;
1676 u16 idle_period, ps_poll_num, dtim,
1679 len = min(count, sizeof(buf) - 1);
1680 if (copy_from_user(buf, user_buf, len))
1685 token = strsep(&sptr, " ");
1688 if (kstrtou16(token, 0, &idle_period))
1691 token = strsep(&sptr, " ");
1694 if (kstrtou16(token, 0, &ps_poll_num))
1697 token = strsep(&sptr, " ");
1700 if (kstrtou16(token, 0, &dtim))
1703 token = strsep(&sptr, " ");
1706 if (kstrtou16(token, 0, &tx_wakeup))
1709 token = strsep(&sptr, " ");
1712 if (kstrtou16(token, 0, &num_tx))
1715 ath6kl_wmi_pmparams_cmd(ar->wmi, 0, idle_period, ps_poll_num,
1716 dtim, tx_wakeup, num_tx, 0);
1721 static const struct file_operations fops_power_params = {
1722 .write = ath6kl_power_params_write,
1723 .open = simple_open,
1724 .owner = THIS_MODULE,
1725 .llseek = default_llseek,
1728 void ath6kl_debug_init(struct ath6kl *ar)
1730 skb_queue_head_init(&ar->debug.fwlog_queue);
1731 init_completion(&ar->debug.fwlog_completion);
1734 * Actually we are lying here but don't know how to read the mask
1735 * value from the firmware.
1737 ar->debug.fwlog_mask = 0;
1741 * Initialisation needs to happen in two stages as fwlog events can come
1742 * before cfg80211 is initialised, and debugfs depends on cfg80211
1745 int ath6kl_debug_init_fs(struct ath6kl *ar)
1747 ar->debugfs_phy = debugfs_create_dir("ath6kl",
1748 ar->wiphy->debugfsdir);
1749 if (!ar->debugfs_phy)
1752 debugfs_create_file("tgt_stats", S_IRUSR, ar->debugfs_phy, ar,
1755 debugfs_create_file("credit_dist_stats", S_IRUSR, ar->debugfs_phy, ar,
1756 &fops_credit_dist_stats);
1758 debugfs_create_file("endpoint_stats", S_IRUSR | S_IWUSR,
1759 ar->debugfs_phy, ar, &fops_endpoint_stats);
1761 debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar,
1764 debugfs_create_file("fwlog_block", S_IRUSR, ar->debugfs_phy, ar,
1767 debugfs_create_file("fwlog_mask", S_IRUSR | S_IWUSR, ar->debugfs_phy,
1768 ar, &fops_fwlog_mask);
1770 debugfs_create_file("reg_addr", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
1771 &fops_diag_reg_read);
1773 debugfs_create_file("reg_dump", S_IRUSR, ar->debugfs_phy, ar,
1776 debugfs_create_file("lrssi_roam_threshold", S_IRUSR | S_IWUSR,
1777 ar->debugfs_phy, ar, &fops_lrssi_roam_threshold);
1779 debugfs_create_file("reg_write", S_IRUSR | S_IWUSR,
1780 ar->debugfs_phy, ar, &fops_diag_reg_write);
1782 debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar,
1785 debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar,
1788 debugfs_create_file("force_roam", S_IWUSR, ar->debugfs_phy, ar,
1791 debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar,
1794 debugfs_create_file("keepalive", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
1797 debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR,
1798 ar->debugfs_phy, ar, &fops_disconnect_timeout);
1800 debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar,
1803 debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar,
1806 debugfs_create_file("bgscan_interval", S_IWUSR,
1807 ar->debugfs_phy, ar, &fops_bgscan_int);
1809 debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR,
1810 ar->debugfs_phy, ar, &fops_listen_int);
1812 debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar,
1813 &fops_power_params);
1818 void ath6kl_debug_cleanup(struct ath6kl *ar)
1820 skb_queue_purge(&ar->debug.fwlog_queue);
1821 complete(&ar->debug.fwlog_completion);
1822 kfree(ar->debug.roam_tbl);