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 int ath6kl_info(const char *fmt, ...)
61 struct va_format vaf = {
69 ret = ath6kl_printk(KERN_INFO, "%pV", &vaf);
74 EXPORT_SYMBOL(ath6kl_info);
76 int ath6kl_err(const char *fmt, ...)
78 struct va_format vaf = {
86 ret = ath6kl_printk(KERN_ERR, "%pV", &vaf);
91 EXPORT_SYMBOL(ath6kl_err);
93 int ath6kl_warn(const char *fmt, ...)
95 struct va_format vaf = {
103 ret = ath6kl_printk(KERN_WARNING, "%pV", &vaf);
108 EXPORT_SYMBOL(ath6kl_warn);
110 #ifdef CONFIG_ATH6KL_DEBUG
112 void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)
114 struct va_format vaf;
117 if (!(debug_mask & mask))
125 ath6kl_printk(KERN_DEBUG, "%pV", &vaf);
129 EXPORT_SYMBOL(ath6kl_dbg);
131 void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
132 const char *msg, const char *prefix,
133 const void *buf, size_t len)
135 if (debug_mask & mask) {
137 ath6kl_dbg(mask, "%s\n", msg);
139 print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len);
142 EXPORT_SYMBOL(ath6kl_dbg_dump);
144 #define REG_OUTPUT_LEN_PER_LINE 25
145 #define REGTYPE_STR_LEN 100
147 struct ath6kl_diag_reg_info {
150 const char *reg_info;
153 static const struct ath6kl_diag_reg_info diag_reg[] = {
154 { 0x20000, 0x200fc, "General DMA and Rx registers" },
155 { 0x28000, 0x28900, "MAC PCU register & keycache" },
156 { 0x20800, 0x20a40, "QCU" },
157 { 0x21000, 0x212f0, "DCU" },
158 { 0x4000, 0x42e4, "RTC" },
159 { 0x540000, 0x540000 + (256 * 1024), "RAM" },
160 { 0x29800, 0x2B210, "Base Band" },
161 { 0x1C000, 0x1C748, "Analog" },
164 void ath6kl_dump_registers(struct ath6kl_device *dev,
165 struct ath6kl_irq_proc_registers *irq_proc_reg,
166 struct ath6kl_irq_enable_reg *irq_enable_reg)
169 ath6kl_dbg(ATH6KL_DBG_IRQ, ("<------- Register Table -------->\n"));
171 if (irq_proc_reg != NULL) {
172 ath6kl_dbg(ATH6KL_DBG_IRQ,
173 "Host Int status: 0x%x\n",
174 irq_proc_reg->host_int_status);
175 ath6kl_dbg(ATH6KL_DBG_IRQ,
176 "CPU Int status: 0x%x\n",
177 irq_proc_reg->cpu_int_status);
178 ath6kl_dbg(ATH6KL_DBG_IRQ,
179 "Error Int status: 0x%x\n",
180 irq_proc_reg->error_int_status);
181 ath6kl_dbg(ATH6KL_DBG_IRQ,
182 "Counter Int status: 0x%x\n",
183 irq_proc_reg->counter_int_status);
184 ath6kl_dbg(ATH6KL_DBG_IRQ,
185 "Mbox Frame: 0x%x\n",
186 irq_proc_reg->mbox_frame);
187 ath6kl_dbg(ATH6KL_DBG_IRQ,
188 "Rx Lookahead Valid: 0x%x\n",
189 irq_proc_reg->rx_lkahd_valid);
190 ath6kl_dbg(ATH6KL_DBG_IRQ,
191 "Rx Lookahead 0: 0x%x\n",
192 irq_proc_reg->rx_lkahd[0]);
193 ath6kl_dbg(ATH6KL_DBG_IRQ,
194 "Rx Lookahead 1: 0x%x\n",
195 irq_proc_reg->rx_lkahd[1]);
197 if (dev->ar->mbox_info.gmbox_addr != 0) {
199 * If the target supports GMBOX hardware, dump some
202 ath6kl_dbg(ATH6KL_DBG_IRQ,
203 "GMBOX Host Int status 2: 0x%x\n",
204 irq_proc_reg->host_int_status2);
205 ath6kl_dbg(ATH6KL_DBG_IRQ,
206 "GMBOX RX Avail: 0x%x\n",
207 irq_proc_reg->gmbox_rx_avail);
208 ath6kl_dbg(ATH6KL_DBG_IRQ,
209 "GMBOX lookahead alias 0: 0x%x\n",
210 irq_proc_reg->rx_gmbox_lkahd_alias[0]);
211 ath6kl_dbg(ATH6KL_DBG_IRQ,
212 "GMBOX lookahead alias 1: 0x%x\n",
213 irq_proc_reg->rx_gmbox_lkahd_alias[1]);
218 if (irq_enable_reg != NULL) {
219 ath6kl_dbg(ATH6KL_DBG_IRQ,
220 "Int status Enable: 0x%x\n",
221 irq_enable_reg->int_status_en);
222 ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status Enable: 0x%x\n",
223 irq_enable_reg->cntr_int_status_en);
225 ath6kl_dbg(ATH6KL_DBG_IRQ, "<------------------------------->\n");
228 static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist)
230 ath6kl_dbg(ATH6KL_DBG_CREDIT,
231 "--- endpoint: %d svc_id: 0x%X ---\n",
232 ep_dist->endpoint, ep_dist->svc_id);
233 ath6kl_dbg(ATH6KL_DBG_CREDIT, " dist_flags : 0x%X\n",
234 ep_dist->dist_flags);
235 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_norm : %d\n",
237 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_min : %d\n",
239 ath6kl_dbg(ATH6KL_DBG_CREDIT, " credits : %d\n",
241 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_assngd : %d\n",
242 ep_dist->cred_assngd);
243 ath6kl_dbg(ATH6KL_DBG_CREDIT, " seek_cred : %d\n",
245 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_sz : %d\n",
247 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_per_msg : %d\n",
248 ep_dist->cred_per_msg);
249 ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_to_dist : %d\n",
250 ep_dist->cred_to_dist);
251 ath6kl_dbg(ATH6KL_DBG_CREDIT, " txq_depth : %d\n",
252 get_queue_depth(&ep_dist->htc_ep->txq));
253 ath6kl_dbg(ATH6KL_DBG_CREDIT,
254 "----------------------------------\n");
257 /* FIXME: move to htc.c */
258 void dump_cred_dist_stats(struct htc_target *target)
260 struct htc_endpoint_credit_dist *ep_list;
262 list_for_each_entry(ep_list, &target->cred_dist_list, list)
263 dump_cred_dist(ep_list);
265 ath6kl_dbg(ATH6KL_DBG_CREDIT,
266 "credit distribution total %d free %d\n",
267 target->credit_info->total_avail_credits,
268 target->credit_info->cur_free_credits);
271 void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war)
274 case ATH6KL_WAR_INVALID_RATE:
275 ar->debug.war_stats.invalid_rate++;
280 static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
281 size_t count, loff_t *ppos)
283 struct ath6kl *ar = file->private_data;
285 unsigned int len = 0, buf_len = 1500;
288 buf = kzalloc(buf_len, GFP_KERNEL);
292 len += scnprintf(buf + len, buf_len - len, "\n");
293 len += scnprintf(buf + len, buf_len - len, "%25s\n",
295 len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
296 "=================");
297 len += scnprintf(buf + len, buf_len - len, "%20s %10u\n",
298 "Invalid rates", ar->debug.war_stats.invalid_rate);
300 if (WARN_ON(len > buf_len))
303 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
309 static const struct file_operations fops_war_stats = {
310 .read = read_file_war_stats,
312 .owner = THIS_MODULE,
313 .llseek = default_llseek,
316 void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len)
318 struct ath6kl_fwlog_slot *slot;
322 if (WARN_ON(len > ATH6KL_FWLOG_PAYLOAD_SIZE))
325 slot_len = sizeof(*slot) + ATH6KL_FWLOG_PAYLOAD_SIZE;
327 skb = alloc_skb(slot_len, GFP_KERNEL);
331 slot = (struct ath6kl_fwlog_slot *) skb_put(skb, slot_len);
332 slot->timestamp = cpu_to_le32(jiffies);
333 slot->length = cpu_to_le32(len);
334 memcpy(slot->payload, buf, len);
336 /* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */
337 memset(slot->payload + len, 0, ATH6KL_FWLOG_PAYLOAD_SIZE - len);
339 spin_lock(&ar->debug.fwlog_queue.lock);
341 __skb_queue_tail(&ar->debug.fwlog_queue, skb);
342 complete(&ar->debug.fwlog_completion);
344 /* drop oldest entries */
345 while (skb_queue_len(&ar->debug.fwlog_queue) >
346 ATH6KL_FWLOG_MAX_ENTRIES) {
347 skb = __skb_dequeue(&ar->debug.fwlog_queue);
351 spin_unlock(&ar->debug.fwlog_queue.lock);
356 static int ath6kl_fwlog_open(struct inode *inode, struct file *file)
358 struct ath6kl *ar = inode->i_private;
360 if (ar->debug.fwlog_open)
363 ar->debug.fwlog_open = true;
365 file->private_data = inode->i_private;
369 static int ath6kl_fwlog_release(struct inode *inode, struct file *file)
371 struct ath6kl *ar = inode->i_private;
373 ar->debug.fwlog_open = false;
378 static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
379 size_t count, loff_t *ppos)
381 struct ath6kl *ar = file->private_data;
387 buf = vmalloc(count);
391 /* read undelivered logs from firmware */
392 ath6kl_read_fwlogs(ar);
394 spin_lock(&ar->debug.fwlog_queue.lock);
396 while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
397 if (skb->len > count - len) {
398 /* not enough space, put skb back and leave */
399 __skb_queue_head(&ar->debug.fwlog_queue, skb);
404 memcpy(buf + len, skb->data, skb->len);
410 spin_unlock(&ar->debug.fwlog_queue.lock);
412 /* FIXME: what to do if len == 0? */
414 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
421 static const struct file_operations fops_fwlog = {
422 .open = ath6kl_fwlog_open,
423 .release = ath6kl_fwlog_release,
424 .read = ath6kl_fwlog_read,
425 .owner = THIS_MODULE,
426 .llseek = default_llseek,
429 static ssize_t ath6kl_fwlog_block_read(struct file *file,
430 char __user *user_buf,
434 struct ath6kl *ar = file->private_data;
437 size_t len = 0, not_copied;
441 buf = vmalloc(count);
445 spin_lock(&ar->debug.fwlog_queue.lock);
447 if (skb_queue_len(&ar->debug.fwlog_queue) == 0) {
448 /* we must init under queue lock */
449 init_completion(&ar->debug.fwlog_completion);
451 spin_unlock(&ar->debug.fwlog_queue.lock);
453 ret = wait_for_completion_interruptible(
454 &ar->debug.fwlog_completion);
455 if (ret == -ERESTARTSYS) {
460 spin_lock(&ar->debug.fwlog_queue.lock);
463 while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
464 if (skb->len > count - len) {
465 /* not enough space, put skb back and leave */
466 __skb_queue_head(&ar->debug.fwlog_queue, skb);
471 memcpy(buf + len, skb->data, skb->len);
477 spin_unlock(&ar->debug.fwlog_queue.lock);
479 /* FIXME: what to do if len == 0? */
481 not_copied = copy_to_user(user_buf, buf, len);
482 if (not_copied != 0) {
497 static const struct file_operations fops_fwlog_block = {
498 .open = ath6kl_fwlog_open,
499 .release = ath6kl_fwlog_release,
500 .read = ath6kl_fwlog_block_read,
501 .owner = THIS_MODULE,
502 .llseek = default_llseek,
505 static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf,
506 size_t count, loff_t *ppos)
508 struct ath6kl *ar = file->private_data;
512 len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask);
514 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
517 static ssize_t ath6kl_fwlog_mask_write(struct file *file,
518 const char __user *user_buf,
519 size_t count, loff_t *ppos)
521 struct ath6kl *ar = file->private_data;
524 ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask);
528 ret = ath6kl_wmi_config_debug_module_cmd(ar->wmi,
529 ATH6KL_FWLOG_VALID_MASK,
530 ar->debug.fwlog_mask);
537 static const struct file_operations fops_fwlog_mask = {
539 .read = ath6kl_fwlog_mask_read,
540 .write = ath6kl_fwlog_mask_write,
541 .owner = THIS_MODULE,
542 .llseek = default_llseek,
545 static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
546 size_t count, loff_t *ppos)
548 struct ath6kl *ar = file->private_data;
549 struct ath6kl_vif *vif;
550 struct target_stats *tgt_stats;
552 unsigned int len = 0, buf_len = 1500;
557 vif = ath6kl_vif_first(ar);
561 tgt_stats = &vif->target_stats;
563 buf = kzalloc(buf_len, GFP_KERNEL);
567 if (down_interruptible(&ar->sem)) {
572 set_bit(STATS_UPDATE_PEND, &vif->flags);
574 if (ath6kl_wmi_get_stats_cmd(ar->wmi, 0)) {
580 left = wait_event_interruptible_timeout(ar->event_wq,
581 !test_bit(STATS_UPDATE_PEND,
582 &vif->flags), WMI_TIMEOUT);
591 len += scnprintf(buf + len, buf_len - len, "\n");
592 len += scnprintf(buf + len, buf_len - len, "%25s\n",
594 len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
595 "=================");
596 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
597 "Ucast packets", tgt_stats->tx_ucast_pkt);
598 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
599 "Bcast packets", tgt_stats->tx_bcast_pkt);
600 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
601 "Ucast byte", tgt_stats->tx_ucast_byte);
602 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
603 "Bcast byte", tgt_stats->tx_bcast_byte);
604 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
605 "Rts success cnt", tgt_stats->tx_rts_success_cnt);
606 for (i = 0; i < 4; i++)
607 len += scnprintf(buf + len, buf_len - len,
608 "%18s %d %10llu\n", "PER on ac",
609 i, tgt_stats->tx_pkt_per_ac[i]);
610 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
611 "Error", tgt_stats->tx_err);
612 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
613 "Fail count", tgt_stats->tx_fail_cnt);
614 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
615 "Retry count", tgt_stats->tx_retry_cnt);
616 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
617 "Multi retry cnt", tgt_stats->tx_mult_retry_cnt);
618 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
619 "Rts fail cnt", tgt_stats->tx_rts_fail_cnt);
620 len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n\n",
621 "TKIP counter measure used",
622 tgt_stats->tkip_cnter_measures_invoked);
624 len += scnprintf(buf + len, buf_len - len, "%25s\n",
626 len += scnprintf(buf + len, buf_len - len, "%25s\n",
627 "=================");
629 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
630 "Ucast packets", tgt_stats->rx_ucast_pkt);
631 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
632 "Ucast Rate", tgt_stats->rx_ucast_rate);
633 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
634 "Bcast packets", tgt_stats->rx_bcast_pkt);
635 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
636 "Ucast byte", tgt_stats->rx_ucast_byte);
637 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
638 "Bcast byte", tgt_stats->rx_bcast_byte);
639 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
640 "Fragmented pkt", tgt_stats->rx_frgment_pkt);
641 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
642 "Error", tgt_stats->rx_err);
643 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
644 "CRC Err", tgt_stats->rx_crc_err);
645 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
646 "Key chache miss", tgt_stats->rx_key_cache_miss);
647 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
648 "Decrypt Err", tgt_stats->rx_decrypt_err);
649 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
650 "Duplicate frame", tgt_stats->rx_dupl_frame);
651 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
652 "Tkip Mic failure", tgt_stats->tkip_local_mic_fail);
653 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
654 "TKIP format err", tgt_stats->tkip_fmt_err);
655 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
656 "CCMP format Err", tgt_stats->ccmp_fmt_err);
657 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n\n",
658 "CCMP Replay Err", tgt_stats->ccmp_replays);
660 len += scnprintf(buf + len, buf_len - len, "%25s\n",
661 "Misc Target stats");
662 len += scnprintf(buf + len, buf_len - len, "%25s\n",
663 "=================");
664 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
665 "Beacon Miss count", tgt_stats->cs_bmiss_cnt);
666 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
667 "Num Connects", tgt_stats->cs_connect_cnt);
668 len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
669 "Num disconnects", tgt_stats->cs_discon_cnt);
670 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
671 "Beacon avg rssi", tgt_stats->cs_ave_beacon_rssi);
672 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
673 "ARP pkt received", tgt_stats->arp_received);
674 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
675 "ARP pkt matched", tgt_stats->arp_matched);
676 len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
677 "ARP pkt replied", tgt_stats->arp_replied);
682 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
688 static const struct file_operations fops_tgt_stats = {
689 .read = read_file_tgt_stats,
691 .owner = THIS_MODULE,
692 .llseek = default_llseek,
695 #define print_credit_info(fmt_str, ep_list_field) \
696 (len += scnprintf(buf + len, buf_len - len, fmt_str, \
697 ep_list->ep_list_field))
698 #define CREDIT_INFO_DISPLAY_STRING_LEN 200
699 #define CREDIT_INFO_LEN 128
701 static ssize_t read_file_credit_dist_stats(struct file *file,
702 char __user *user_buf,
703 size_t count, loff_t *ppos)
705 struct ath6kl *ar = file->private_data;
706 struct htc_target *target = ar->htc_target;
707 struct htc_endpoint_credit_dist *ep_list;
709 unsigned int buf_len, len = 0;
712 buf_len = CREDIT_INFO_DISPLAY_STRING_LEN +
713 get_queue_depth(&target->cred_dist_list) * CREDIT_INFO_LEN;
714 buf = kzalloc(buf_len, GFP_KERNEL);
718 len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
719 "Total Avail Credits: ",
720 target->credit_info->total_avail_credits);
721 len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
723 target->credit_info->cur_free_credits);
725 len += scnprintf(buf + len, buf_len - len,
726 " Epid Flags Cred_norm Cred_min Credits Cred_assngd"
727 " Seek_cred Cred_sz Cred_per_msg Cred_to_dist"
730 list_for_each_entry(ep_list, &target->cred_dist_list, list) {
731 print_credit_info(" %2d", endpoint);
732 print_credit_info("%10x", dist_flags);
733 print_credit_info("%8d", cred_norm);
734 print_credit_info("%9d", cred_min);
735 print_credit_info("%9d", credits);
736 print_credit_info("%10d", cred_assngd);
737 print_credit_info("%13d", seek_cred);
738 print_credit_info("%12d", cred_sz);
739 print_credit_info("%9d", cred_per_msg);
740 print_credit_info("%14d", cred_to_dist);
741 len += scnprintf(buf + len, buf_len - len, "%12d\n",
742 get_queue_depth(&ep_list->htc_ep->txq));
748 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
753 static const struct file_operations fops_credit_dist_stats = {
754 .read = read_file_credit_dist_stats,
756 .owner = THIS_MODULE,
757 .llseek = default_llseek,
760 static unsigned int print_endpoint_stat(struct htc_target *target, char *buf,
761 unsigned int buf_len, unsigned int len,
762 int offset, const char *name)
765 struct htc_endpoint_stats *ep_st;
768 len += scnprintf(buf + len, buf_len - len, "%s:", name);
769 for (i = 0; i < ENDPOINT_MAX; i++) {
770 ep_st = &target->endpoint[i].ep_st;
771 counter = ((u32 *) ep_st) + (offset / 4);
772 len += scnprintf(buf + len, buf_len - len, " %u", *counter);
774 len += scnprintf(buf + len, buf_len - len, "\n");
779 static ssize_t ath6kl_endpoint_stats_read(struct file *file,
780 char __user *user_buf,
781 size_t count, loff_t *ppos)
783 struct ath6kl *ar = file->private_data;
784 struct htc_target *target = ar->htc_target;
786 unsigned int buf_len, len = 0;
789 buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) *
790 (25 + ENDPOINT_MAX * 11);
791 buf = kmalloc(buf_len, GFP_KERNEL);
795 #define EPSTAT(name) \
797 len = print_endpoint_stat(target, buf, buf_len, len, \
798 offsetof(struct htc_endpoint_stats, \
803 EPSTAT(cred_low_indicate);
805 EPSTAT(tx_pkt_bundled);
809 EPSTAT(cred_rpt_from_rx);
810 EPSTAT(cred_rpt_from_other);
811 EPSTAT(cred_rpt_ep0);
812 EPSTAT(cred_from_rx);
813 EPSTAT(cred_from_other);
814 EPSTAT(cred_from_ep0);
820 EPSTAT(rx_bundle_lkahd);
821 EPSTAT(rx_bundle_from_hdr);
822 EPSTAT(rx_alloc_thresh_hit);
823 EPSTAT(rxalloc_thresh_byte);
829 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
834 static ssize_t ath6kl_endpoint_stats_write(struct file *file,
835 const char __user *user_buf,
836 size_t count, loff_t *ppos)
838 struct ath6kl *ar = file->private_data;
839 struct htc_target *target = ar->htc_target;
842 struct htc_endpoint_stats *ep_st;
844 ret = kstrtou32_from_user(user_buf, count, 0, &val);
848 for (i = 0; i < ENDPOINT_MAX; i++) {
849 ep_st = &target->endpoint[i].ep_st;
850 memset(ep_st, 0, sizeof(*ep_st));
857 static const struct file_operations fops_endpoint_stats = {
859 .read = ath6kl_endpoint_stats_read,
860 .write = ath6kl_endpoint_stats_write,
861 .owner = THIS_MODULE,
862 .llseek = default_llseek,
865 static unsigned long ath6kl_get_num_reg(void)
868 unsigned long n_reg = 0;
870 for (i = 0; i < ARRAY_SIZE(diag_reg); i++)
872 (diag_reg[i].reg_end - diag_reg[i].reg_start) / 4 + 1;
877 static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr)
881 for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
882 if (reg_addr >= diag_reg[i].reg_start &&
883 reg_addr <= diag_reg[i].reg_end)
890 static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
891 size_t count, loff_t *ppos)
893 struct ath6kl *ar = file->private_data;
895 unsigned int len = 0;
897 if (ar->debug.dbgfs_diag_reg)
898 len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n",
899 ar->debug.dbgfs_diag_reg);
901 len += scnprintf(buf + len, sizeof(buf) - len,
902 "All diag registers\n");
904 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
907 static ssize_t ath6kl_regread_write(struct file *file,
908 const char __user *user_buf,
909 size_t count, loff_t *ppos)
911 struct ath6kl *ar = file->private_data;
912 unsigned long reg_addr;
914 if (kstrtoul_from_user(user_buf, count, 0, ®_addr))
917 if ((reg_addr % 4) != 0)
920 if (reg_addr && !ath6kl_dbg_is_diag_reg_valid(reg_addr))
923 ar->debug.dbgfs_diag_reg = reg_addr;
928 static const struct file_operations fops_diag_reg_read = {
929 .read = ath6kl_regread_read,
930 .write = ath6kl_regread_write,
932 .owner = THIS_MODULE,
933 .llseek = default_llseek,
936 static int ath6kl_regdump_open(struct inode *inode, struct file *file)
938 struct ath6kl *ar = inode->i_private;
940 unsigned long int reg_len;
941 unsigned int len = 0, n_reg;
946 /* Dump all the registers if no register is specified */
947 if (!ar->debug.dbgfs_diag_reg)
948 n_reg = ath6kl_get_num_reg();
952 reg_len = n_reg * REG_OUTPUT_LEN_PER_LINE;
954 reg_len += REGTYPE_STR_LEN;
956 buf = vmalloc(reg_len);
961 addr = ar->debug.dbgfs_diag_reg;
963 status = ath6kl_diag_read32(ar,
964 TARG_VTOP(ar->target_type, addr),
969 len += scnprintf(buf + len, reg_len - len,
970 "0x%06x 0x%08x\n", addr, le32_to_cpu(reg_val));
974 for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
975 len += scnprintf(buf + len, reg_len - len,
976 "%s\n", diag_reg[i].reg_info);
977 for (addr = diag_reg[i].reg_start;
978 addr <= diag_reg[i].reg_end; addr += 4) {
979 status = ath6kl_diag_read32(ar,
980 TARG_VTOP(ar->target_type, addr),
985 len += scnprintf(buf + len, reg_len - len,
987 addr, le32_to_cpu(reg_val));
992 file->private_data = buf;
996 ath6kl_warn("Unable to read memory:%u\n", addr);
1001 static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf,
1002 size_t count, loff_t *ppos)
1004 u8 *buf = file->private_data;
1005 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
1008 static int ath6kl_regdump_release(struct inode *inode, struct file *file)
1010 vfree(file->private_data);
1014 static const struct file_operations fops_reg_dump = {
1015 .open = ath6kl_regdump_open,
1016 .read = ath6kl_regdump_read,
1017 .release = ath6kl_regdump_release,
1018 .owner = THIS_MODULE,
1019 .llseek = default_llseek,
1022 static ssize_t ath6kl_lrssi_roam_write(struct file *file,
1023 const char __user *user_buf,
1024 size_t count, loff_t *ppos)
1026 struct ath6kl *ar = file->private_data;
1027 unsigned long lrssi_roam_threshold;
1029 if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
1032 ar->lrssi_roam_threshold = lrssi_roam_threshold;
1034 ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold);
1039 static ssize_t ath6kl_lrssi_roam_read(struct file *file,
1040 char __user *user_buf,
1041 size_t count, loff_t *ppos)
1043 struct ath6kl *ar = file->private_data;
1047 len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold);
1049 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1052 static const struct file_operations fops_lrssi_roam_threshold = {
1053 .read = ath6kl_lrssi_roam_read,
1054 .write = ath6kl_lrssi_roam_write,
1055 .open = simple_open,
1056 .owner = THIS_MODULE,
1057 .llseek = default_llseek,
1060 static ssize_t ath6kl_regwrite_read(struct file *file,
1061 char __user *user_buf,
1062 size_t count, loff_t *ppos)
1064 struct ath6kl *ar = file->private_data;
1066 unsigned int len = 0;
1068 len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
1069 ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
1071 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1074 static ssize_t ath6kl_regwrite_write(struct file *file,
1075 const char __user *user_buf,
1076 size_t count, loff_t *ppos)
1078 struct ath6kl *ar = file->private_data;
1081 unsigned int len = 0;
1082 u32 reg_addr, reg_val;
1084 len = min(count, sizeof(buf) - 1);
1085 if (copy_from_user(buf, user_buf, len))
1091 token = strsep(&sptr, "=");
1095 if (kstrtou32(token, 0, ®_addr))
1098 if (!ath6kl_dbg_is_diag_reg_valid(reg_addr))
1101 if (kstrtou32(sptr, 0, ®_val))
1104 ar->debug.diag_reg_addr_wr = reg_addr;
1105 ar->debug.diag_reg_val_wr = reg_val;
1107 if (ath6kl_diag_write32(ar, ar->debug.diag_reg_addr_wr,
1108 cpu_to_le32(ar->debug.diag_reg_val_wr)))
1114 static const struct file_operations fops_diag_reg_write = {
1115 .read = ath6kl_regwrite_read,
1116 .write = ath6kl_regwrite_write,
1117 .open = simple_open,
1118 .owner = THIS_MODULE,
1119 .llseek = default_llseek,
1122 int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf,
1125 const struct wmi_target_roam_tbl *tbl;
1128 if (len < sizeof(*tbl))
1131 tbl = (const struct wmi_target_roam_tbl *) buf;
1132 num_entries = le16_to_cpu(tbl->num_entries);
1133 if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) >
1137 if (ar->debug.roam_tbl == NULL ||
1138 ar->debug.roam_tbl_len < (unsigned int) len) {
1139 kfree(ar->debug.roam_tbl);
1140 ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC);
1141 if (ar->debug.roam_tbl == NULL)
1145 memcpy(ar->debug.roam_tbl, buf, len);
1146 ar->debug.roam_tbl_len = len;
1148 if (test_bit(ROAM_TBL_PEND, &ar->flag)) {
1149 clear_bit(ROAM_TBL_PEND, &ar->flag);
1150 wake_up(&ar->event_wq);
1156 static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
1157 size_t count, loff_t *ppos)
1159 struct ath6kl *ar = file->private_data;
1162 struct wmi_target_roam_tbl *tbl;
1165 unsigned int len, buf_len;
1168 if (down_interruptible(&ar->sem))
1171 set_bit(ROAM_TBL_PEND, &ar->flag);
1173 ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi);
1179 left = wait_event_interruptible_timeout(
1180 ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT);
1186 if (ar->debug.roam_tbl == NULL)
1189 tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl;
1190 num_entries = le16_to_cpu(tbl->num_entries);
1192 buf_len = 100 + num_entries * 100;
1193 buf = kzalloc(buf_len, GFP_KERNEL);
1197 len += scnprintf(buf + len, buf_len - len,
1199 "# roam_util bssid rssi rssidt last_rssi util bias\n",
1200 le16_to_cpu(tbl->roam_mode));
1202 for (i = 0; i < num_entries; i++) {
1203 struct wmi_bss_roam_info *info = &tbl->info[i];
1204 len += scnprintf(buf + len, buf_len - len,
1205 "%d %pM %d %d %d %d %d\n",
1206 a_sle32_to_cpu(info->roam_util), info->bssid,
1207 info->rssi, info->rssidt, info->last_rssi,
1208 info->util, info->bias);
1214 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1220 static const struct file_operations fops_roam_table = {
1221 .read = ath6kl_roam_table_read,
1222 .open = simple_open,
1223 .owner = THIS_MODULE,
1224 .llseek = default_llseek,
1227 static ssize_t ath6kl_force_roam_write(struct file *file,
1228 const char __user *user_buf,
1229 size_t count, loff_t *ppos)
1231 struct ath6kl *ar = file->private_data;
1239 len = min(count, sizeof(buf) - 1);
1240 if (copy_from_user(buf, user_buf, len))
1244 if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
1245 &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
1248 for (i = 0; i < ETH_ALEN; i++)
1251 ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid);
1258 static const struct file_operations fops_force_roam = {
1259 .write = ath6kl_force_roam_write,
1260 .open = simple_open,
1261 .owner = THIS_MODULE,
1262 .llseek = default_llseek,
1265 static ssize_t ath6kl_roam_mode_write(struct file *file,
1266 const char __user *user_buf,
1267 size_t count, loff_t *ppos)
1269 struct ath6kl *ar = file->private_data;
1273 enum wmi_roam_mode mode;
1275 len = min(count, sizeof(buf) - 1);
1276 if (copy_from_user(buf, user_buf, len))
1279 if (len > 0 && buf[len - 1] == '\n')
1280 buf[len - 1] = '\0';
1282 if (strcasecmp(buf, "default") == 0)
1283 mode = WMI_DEFAULT_ROAM_MODE;
1284 else if (strcasecmp(buf, "bssbias") == 0)
1285 mode = WMI_HOST_BIAS_ROAM_MODE;
1286 else if (strcasecmp(buf, "lock") == 0)
1287 mode = WMI_LOCK_BSS_MODE;
1291 ret = ath6kl_wmi_set_roam_mode_cmd(ar->wmi, mode);
1298 static const struct file_operations fops_roam_mode = {
1299 .write = ath6kl_roam_mode_write,
1300 .open = simple_open,
1301 .owner = THIS_MODULE,
1302 .llseek = default_llseek,
1305 void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive)
1307 ar->debug.keepalive = keepalive;
1310 static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf,
1311 size_t count, loff_t *ppos)
1313 struct ath6kl *ar = file->private_data;
1317 len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive);
1319 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1322 static ssize_t ath6kl_keepalive_write(struct file *file,
1323 const char __user *user_buf,
1324 size_t count, loff_t *ppos)
1326 struct ath6kl *ar = file->private_data;
1330 ret = kstrtou8_from_user(user_buf, count, 0, &val);
1334 ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, 0, val);
1341 static const struct file_operations fops_keepalive = {
1342 .open = simple_open,
1343 .read = ath6kl_keepalive_read,
1344 .write = ath6kl_keepalive_write,
1345 .owner = THIS_MODULE,
1346 .llseek = default_llseek,
1349 void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout)
1351 ar->debug.disc_timeout = timeout;
1354 static ssize_t ath6kl_disconnect_timeout_read(struct file *file,
1355 char __user *user_buf,
1356 size_t count, loff_t *ppos)
1358 struct ath6kl *ar = file->private_data;
1362 len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout);
1364 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1367 static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
1368 const char __user *user_buf,
1369 size_t count, loff_t *ppos)
1371 struct ath6kl *ar = file->private_data;
1375 ret = kstrtou8_from_user(user_buf, count, 0, &val);
1379 ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, 0, val);
1386 static const struct file_operations fops_disconnect_timeout = {
1387 .open = simple_open,
1388 .read = ath6kl_disconnect_timeout_read,
1389 .write = ath6kl_disconnect_timeout_write,
1390 .owner = THIS_MODULE,
1391 .llseek = default_llseek,
1394 static ssize_t ath6kl_create_qos_write(struct file *file,
1395 const char __user *user_buf,
1396 size_t count, loff_t *ppos)
1399 struct ath6kl *ar = file->private_data;
1400 struct ath6kl_vif *vif;
1404 struct wmi_create_pstream_cmd pstream;
1408 vif = ath6kl_vif_first(ar);
1412 len = min(count, sizeof(buf) - 1);
1413 if (copy_from_user(buf, user_buf, len))
1418 token = strsep(&sptr, " ");
1421 if (kstrtou8(token, 0, &pstream.user_pri))
1424 token = strsep(&sptr, " ");
1427 if (kstrtou8(token, 0, &pstream.traffic_direc))
1430 token = strsep(&sptr, " ");
1433 if (kstrtou8(token, 0, &pstream.traffic_class))
1436 token = strsep(&sptr, " ");
1439 if (kstrtou8(token, 0, &pstream.traffic_type))
1442 token = strsep(&sptr, " ");
1445 if (kstrtou8(token, 0, &pstream.voice_psc_cap))
1448 token = strsep(&sptr, " ");
1451 if (kstrtou32(token, 0, &val32))
1453 pstream.min_service_int = cpu_to_le32(val32);
1455 token = strsep(&sptr, " ");
1458 if (kstrtou32(token, 0, &val32))
1460 pstream.max_service_int = cpu_to_le32(val32);
1462 token = strsep(&sptr, " ");
1465 if (kstrtou32(token, 0, &val32))
1467 pstream.inactivity_int = cpu_to_le32(val32);
1469 token = strsep(&sptr, " ");
1472 if (kstrtou32(token, 0, &val32))
1474 pstream.suspension_int = cpu_to_le32(val32);
1476 token = strsep(&sptr, " ");
1479 if (kstrtou32(token, 0, &val32))
1481 pstream.service_start_time = cpu_to_le32(val32);
1483 token = strsep(&sptr, " ");
1486 if (kstrtou8(token, 0, &pstream.tsid))
1489 token = strsep(&sptr, " ");
1492 if (kstrtou16(token, 0, &val16))
1494 pstream.nominal_msdu = cpu_to_le16(val16);
1496 token = strsep(&sptr, " ");
1499 if (kstrtou16(token, 0, &val16))
1501 pstream.max_msdu = cpu_to_le16(val16);
1503 token = strsep(&sptr, " ");
1506 if (kstrtou32(token, 0, &val32))
1508 pstream.min_data_rate = cpu_to_le32(val32);
1510 token = strsep(&sptr, " ");
1513 if (kstrtou32(token, 0, &val32))
1515 pstream.mean_data_rate = cpu_to_le32(val32);
1517 token = strsep(&sptr, " ");
1520 if (kstrtou32(token, 0, &val32))
1522 pstream.peak_data_rate = cpu_to_le32(val32);
1524 token = strsep(&sptr, " ");
1527 if (kstrtou32(token, 0, &val32))
1529 pstream.max_burst_size = cpu_to_le32(val32);
1531 token = strsep(&sptr, " ");
1534 if (kstrtou32(token, 0, &val32))
1536 pstream.delay_bound = cpu_to_le32(val32);
1538 token = strsep(&sptr, " ");
1541 if (kstrtou32(token, 0, &val32))
1543 pstream.min_phy_rate = cpu_to_le32(val32);
1545 token = strsep(&sptr, " ");
1548 if (kstrtou32(token, 0, &val32))
1550 pstream.sba = cpu_to_le32(val32);
1552 token = strsep(&sptr, " ");
1555 if (kstrtou32(token, 0, &val32))
1557 pstream.medium_time = cpu_to_le32(val32);
1559 pstream.nominal_phy = le32_to_cpu(pstream.min_phy_rate) / 1000000;
1561 ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream);
1566 static const struct file_operations fops_create_qos = {
1567 .write = ath6kl_create_qos_write,
1568 .open = simple_open,
1569 .owner = THIS_MODULE,
1570 .llseek = default_llseek,
1573 static ssize_t ath6kl_delete_qos_write(struct file *file,
1574 const char __user *user_buf,
1575 size_t count, loff_t *ppos)
1578 struct ath6kl *ar = file->private_data;
1579 struct ath6kl_vif *vif;
1586 vif = ath6kl_vif_first(ar);
1590 len = min(count, sizeof(buf) - 1);
1591 if (copy_from_user(buf, user_buf, len))
1596 token = strsep(&sptr, " ");
1599 if (kstrtou8(token, 0, &traffic_class))
1602 token = strsep(&sptr, " ");
1605 if (kstrtou8(token, 0, &tsid))
1608 ath6kl_wmi_delete_pstream_cmd(ar->wmi, vif->fw_vif_idx,
1609 traffic_class, tsid);
1614 static const struct file_operations fops_delete_qos = {
1615 .write = ath6kl_delete_qos_write,
1616 .open = simple_open,
1617 .owner = THIS_MODULE,
1618 .llseek = default_llseek,
1621 static ssize_t ath6kl_bgscan_int_write(struct file *file,
1622 const char __user *user_buf,
1623 size_t count, loff_t *ppos)
1625 struct ath6kl *ar = file->private_data;
1626 struct ath6kl_vif *vif;
1631 vif = ath6kl_vif_first(ar);
1635 len = min(count, sizeof(buf) - 1);
1636 if (copy_from_user(buf, user_buf, len))
1640 if (kstrtou16(buf, 0, &bgscan_int))
1643 if (bgscan_int == 0)
1644 bgscan_int = 0xffff;
1646 vif->bg_scan_period = bgscan_int;
1648 ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3,
1654 static const struct file_operations fops_bgscan_int = {
1655 .write = ath6kl_bgscan_int_write,
1656 .open = simple_open,
1657 .owner = THIS_MODULE,
1658 .llseek = default_llseek,
1661 static ssize_t ath6kl_listen_int_write(struct file *file,
1662 const char __user *user_buf,
1663 size_t count, loff_t *ppos)
1665 struct ath6kl *ar = file->private_data;
1666 struct ath6kl_vif *vif;
1667 u16 listen_interval;
1671 vif = ath6kl_vif_first(ar);
1675 len = min(count, sizeof(buf) - 1);
1676 if (copy_from_user(buf, user_buf, len))
1680 if (kstrtou16(buf, 0, &listen_interval))
1683 if ((listen_interval < 15) || (listen_interval > 3000))
1686 vif->listen_intvl_t = listen_interval;
1687 ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
1688 vif->listen_intvl_t, 0);
1693 static ssize_t ath6kl_listen_int_read(struct file *file,
1694 char __user *user_buf,
1695 size_t count, loff_t *ppos)
1697 struct ath6kl *ar = file->private_data;
1698 struct ath6kl_vif *vif;
1702 vif = ath6kl_vif_first(ar);
1706 len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t);
1708 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1711 static const struct file_operations fops_listen_int = {
1712 .read = ath6kl_listen_int_read,
1713 .write = ath6kl_listen_int_write,
1714 .open = simple_open,
1715 .owner = THIS_MODULE,
1716 .llseek = default_llseek,
1719 static ssize_t ath6kl_power_params_write(struct file *file,
1720 const char __user *user_buf,
1721 size_t count, loff_t *ppos)
1723 struct ath6kl *ar = file->private_data;
1725 unsigned int len = 0;
1727 u16 idle_period, ps_poll_num, dtim,
1730 len = min(count, sizeof(buf) - 1);
1731 if (copy_from_user(buf, user_buf, len))
1736 token = strsep(&sptr, " ");
1739 if (kstrtou16(token, 0, &idle_period))
1742 token = strsep(&sptr, " ");
1745 if (kstrtou16(token, 0, &ps_poll_num))
1748 token = strsep(&sptr, " ");
1751 if (kstrtou16(token, 0, &dtim))
1754 token = strsep(&sptr, " ");
1757 if (kstrtou16(token, 0, &tx_wakeup))
1760 token = strsep(&sptr, " ");
1763 if (kstrtou16(token, 0, &num_tx))
1766 ath6kl_wmi_pmparams_cmd(ar->wmi, 0, idle_period, ps_poll_num,
1767 dtim, tx_wakeup, num_tx, 0);
1772 static const struct file_operations fops_power_params = {
1773 .write = ath6kl_power_params_write,
1774 .open = simple_open,
1775 .owner = THIS_MODULE,
1776 .llseek = default_llseek,
1779 void ath6kl_debug_init(struct ath6kl *ar)
1781 skb_queue_head_init(&ar->debug.fwlog_queue);
1782 init_completion(&ar->debug.fwlog_completion);
1785 * Actually we are lying here but don't know how to read the mask
1786 * value from the firmware.
1788 ar->debug.fwlog_mask = 0;
1792 * Initialisation needs to happen in two stages as fwlog events can come
1793 * before cfg80211 is initialised, and debugfs depends on cfg80211
1796 int ath6kl_debug_init_fs(struct ath6kl *ar)
1798 ar->debugfs_phy = debugfs_create_dir("ath6kl",
1799 ar->wiphy->debugfsdir);
1800 if (!ar->debugfs_phy)
1803 debugfs_create_file("tgt_stats", S_IRUSR, ar->debugfs_phy, ar,
1806 debugfs_create_file("credit_dist_stats", S_IRUSR, ar->debugfs_phy, ar,
1807 &fops_credit_dist_stats);
1809 debugfs_create_file("endpoint_stats", S_IRUSR | S_IWUSR,
1810 ar->debugfs_phy, ar, &fops_endpoint_stats);
1812 debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar,
1815 debugfs_create_file("fwlog_block", S_IRUSR, ar->debugfs_phy, ar,
1818 debugfs_create_file("fwlog_mask", S_IRUSR | S_IWUSR, ar->debugfs_phy,
1819 ar, &fops_fwlog_mask);
1821 debugfs_create_file("reg_addr", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
1822 &fops_diag_reg_read);
1824 debugfs_create_file("reg_dump", S_IRUSR, ar->debugfs_phy, ar,
1827 debugfs_create_file("lrssi_roam_threshold", S_IRUSR | S_IWUSR,
1828 ar->debugfs_phy, ar, &fops_lrssi_roam_threshold);
1830 debugfs_create_file("reg_write", S_IRUSR | S_IWUSR,
1831 ar->debugfs_phy, ar, &fops_diag_reg_write);
1833 debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar,
1836 debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar,
1839 debugfs_create_file("force_roam", S_IWUSR, ar->debugfs_phy, ar,
1842 debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar,
1845 debugfs_create_file("keepalive", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
1848 debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR,
1849 ar->debugfs_phy, ar, &fops_disconnect_timeout);
1851 debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar,
1854 debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar,
1857 debugfs_create_file("bgscan_interval", S_IWUSR,
1858 ar->debugfs_phy, ar, &fops_bgscan_int);
1860 debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR,
1861 ar->debugfs_phy, ar, &fops_listen_int);
1863 debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar,
1864 &fops_power_params);
1869 void ath6kl_debug_cleanup(struct ath6kl *ar)
1871 skb_queue_purge(&ar->debug.fwlog_queue);
1872 complete(&ar->debug.fwlog_completion);
1873 kfree(ar->debug.roam_tbl);