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 void ath6kl_printk(const char *level
, const char *fmt
, ...)
50 printk("%sath6kl: %pV", level
, &vaf
);
54 EXPORT_SYMBOL(ath6kl_printk
);
56 void ath6kl_info(const char *fmt
, ...)
58 struct va_format vaf
= {
65 ath6kl_printk(KERN_INFO
, "%pV", &vaf
);
66 trace_ath6kl_log_info(&vaf
);
69 EXPORT_SYMBOL(ath6kl_info
);
71 void ath6kl_err(const char *fmt
, ...)
73 struct va_format vaf
= {
80 ath6kl_printk(KERN_ERR
, "%pV", &vaf
);
81 trace_ath6kl_log_err(&vaf
);
84 EXPORT_SYMBOL(ath6kl_err
);
86 void ath6kl_warn(const char *fmt
, ...)
88 struct va_format vaf
= {
95 ath6kl_printk(KERN_WARNING
, "%pV", &vaf
);
96 trace_ath6kl_log_warn(&vaf
);
99 EXPORT_SYMBOL(ath6kl_warn
);
101 int ath6kl_read_tgt_stats(struct ath6kl
*ar
, struct ath6kl_vif
*vif
)
105 if (down_interruptible(&ar
->sem
))
108 set_bit(STATS_UPDATE_PEND
, &vif
->flags
);
110 if (ath6kl_wmi_get_stats_cmd(ar
->wmi
, 0)) {
115 left
= wait_event_interruptible_timeout(ar
->event_wq
,
116 !test_bit(STATS_UPDATE_PEND
,
117 &vif
->flags
), WMI_TIMEOUT
);
126 EXPORT_SYMBOL(ath6kl_read_tgt_stats
);
128 #ifdef CONFIG_ATH6KL_DEBUG
130 void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask
, const char *fmt
, ...)
132 struct va_format vaf
;
140 if (debug_mask
& mask
)
141 ath6kl_printk(KERN_DEBUG
, "%pV", &vaf
);
143 trace_ath6kl_log_dbg(mask
, &vaf
);
147 EXPORT_SYMBOL(ath6kl_dbg
);
149 void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask
,
150 const char *msg
, const char *prefix
,
151 const void *buf
, size_t len
)
153 if (debug_mask
& mask
) {
155 ath6kl_dbg(mask
, "%s\n", msg
);
157 print_hex_dump_bytes(prefix
, DUMP_PREFIX_OFFSET
, buf
, len
);
160 /* tracing code doesn't like null strings :/ */
161 trace_ath6kl_log_dbg_dump(msg
? msg
: "", prefix
? prefix
: "",
164 EXPORT_SYMBOL(ath6kl_dbg_dump
);
166 #define REG_OUTPUT_LEN_PER_LINE 25
167 #define REGTYPE_STR_LEN 100
169 struct ath6kl_diag_reg_info
{
172 const char *reg_info
;
175 static const struct ath6kl_diag_reg_info diag_reg
[] = {
176 { 0x20000, 0x200fc, "General DMA and Rx registers" },
177 { 0x28000, 0x28900, "MAC PCU register & keycache" },
178 { 0x20800, 0x20a40, "QCU" },
179 { 0x21000, 0x212f0, "DCU" },
180 { 0x4000, 0x42e4, "RTC" },
181 { 0x540000, 0x540000 + (256 * 1024), "RAM" },
182 { 0x29800, 0x2B210, "Base Band" },
183 { 0x1C000, 0x1C748, "Analog" },
186 void ath6kl_dump_registers(struct ath6kl_device
*dev
,
187 struct ath6kl_irq_proc_registers
*irq_proc_reg
,
188 struct ath6kl_irq_enable_reg
*irq_enable_reg
)
190 ath6kl_dbg(ATH6KL_DBG_IRQ
, ("<------- Register Table -------->\n"));
192 if (irq_proc_reg
!= NULL
) {
193 ath6kl_dbg(ATH6KL_DBG_IRQ
,
194 "Host Int status: 0x%x\n",
195 irq_proc_reg
->host_int_status
);
196 ath6kl_dbg(ATH6KL_DBG_IRQ
,
197 "CPU Int status: 0x%x\n",
198 irq_proc_reg
->cpu_int_status
);
199 ath6kl_dbg(ATH6KL_DBG_IRQ
,
200 "Error Int status: 0x%x\n",
201 irq_proc_reg
->error_int_status
);
202 ath6kl_dbg(ATH6KL_DBG_IRQ
,
203 "Counter Int status: 0x%x\n",
204 irq_proc_reg
->counter_int_status
);
205 ath6kl_dbg(ATH6KL_DBG_IRQ
,
206 "Mbox Frame: 0x%x\n",
207 irq_proc_reg
->mbox_frame
);
208 ath6kl_dbg(ATH6KL_DBG_IRQ
,
209 "Rx Lookahead Valid: 0x%x\n",
210 irq_proc_reg
->rx_lkahd_valid
);
211 ath6kl_dbg(ATH6KL_DBG_IRQ
,
212 "Rx Lookahead 0: 0x%x\n",
213 irq_proc_reg
->rx_lkahd
[0]);
214 ath6kl_dbg(ATH6KL_DBG_IRQ
,
215 "Rx Lookahead 1: 0x%x\n",
216 irq_proc_reg
->rx_lkahd
[1]);
218 if (dev
->ar
->mbox_info
.gmbox_addr
!= 0) {
220 * If the target supports GMBOX hardware, dump some
223 ath6kl_dbg(ATH6KL_DBG_IRQ
,
224 "GMBOX Host Int status 2: 0x%x\n",
225 irq_proc_reg
->host_int_status2
);
226 ath6kl_dbg(ATH6KL_DBG_IRQ
,
227 "GMBOX RX Avail: 0x%x\n",
228 irq_proc_reg
->gmbox_rx_avail
);
229 ath6kl_dbg(ATH6KL_DBG_IRQ
,
230 "GMBOX lookahead alias 0: 0x%x\n",
231 irq_proc_reg
->rx_gmbox_lkahd_alias
[0]);
232 ath6kl_dbg(ATH6KL_DBG_IRQ
,
233 "GMBOX lookahead alias 1: 0x%x\n",
234 irq_proc_reg
->rx_gmbox_lkahd_alias
[1]);
238 if (irq_enable_reg
!= NULL
) {
239 ath6kl_dbg(ATH6KL_DBG_IRQ
,
240 "Int status Enable: 0x%x\n",
241 irq_enable_reg
->int_status_en
);
242 ath6kl_dbg(ATH6KL_DBG_IRQ
, "Counter Int status Enable: 0x%x\n",
243 irq_enable_reg
->cntr_int_status_en
);
245 ath6kl_dbg(ATH6KL_DBG_IRQ
, "<------------------------------->\n");
248 static void dump_cred_dist(struct htc_endpoint_credit_dist
*ep_dist
)
250 ath6kl_dbg(ATH6KL_DBG_CREDIT
,
251 "--- endpoint: %d svc_id: 0x%X ---\n",
252 ep_dist
->endpoint
, ep_dist
->svc_id
);
253 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " dist_flags : 0x%X\n",
254 ep_dist
->dist_flags
);
255 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " cred_norm : %d\n",
257 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " cred_min : %d\n",
259 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " credits : %d\n",
261 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " cred_assngd : %d\n",
262 ep_dist
->cred_assngd
);
263 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " seek_cred : %d\n",
265 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " cred_sz : %d\n",
267 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " cred_per_msg : %d\n",
268 ep_dist
->cred_per_msg
);
269 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " cred_to_dist : %d\n",
270 ep_dist
->cred_to_dist
);
271 ath6kl_dbg(ATH6KL_DBG_CREDIT
, " txq_depth : %d\n",
272 get_queue_depth(&ep_dist
->htc_ep
->txq
));
273 ath6kl_dbg(ATH6KL_DBG_CREDIT
,
274 "----------------------------------\n");
277 /* FIXME: move to htc.c */
278 void dump_cred_dist_stats(struct htc_target
*target
)
280 struct htc_endpoint_credit_dist
*ep_list
;
282 list_for_each_entry(ep_list
, &target
->cred_dist_list
, list
)
283 dump_cred_dist(ep_list
);
285 ath6kl_dbg(ATH6KL_DBG_CREDIT
,
286 "credit distribution total %d free %d\n",
287 target
->credit_info
->total_avail_credits
,
288 target
->credit_info
->cur_free_credits
);
291 void ath6kl_debug_war(struct ath6kl
*ar
, enum ath6kl_war war
)
294 case ATH6KL_WAR_INVALID_RATE
:
295 ar
->debug
.war_stats
.invalid_rate
++;
300 static ssize_t
read_file_war_stats(struct file
*file
, char __user
*user_buf
,
301 size_t count
, loff_t
*ppos
)
303 struct ath6kl
*ar
= file
->private_data
;
305 unsigned int len
= 0, buf_len
= 1500;
308 buf
= kzalloc(buf_len
, GFP_KERNEL
);
312 len
+= scnprintf(buf
+ len
, buf_len
- len
, "\n");
313 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n",
315 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n\n",
316 "=================");
317 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10u\n",
318 "Invalid rates", ar
->debug
.war_stats
.invalid_rate
);
320 if (WARN_ON(len
> buf_len
))
323 ret_cnt
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
329 static const struct file_operations fops_war_stats
= {
330 .read
= read_file_war_stats
,
332 .owner
= THIS_MODULE
,
333 .llseek
= default_llseek
,
336 void ath6kl_debug_fwlog_event(struct ath6kl
*ar
, const void *buf
, size_t len
)
338 struct ath6kl_fwlog_slot
*slot
;
342 if (WARN_ON(len
> ATH6KL_FWLOG_PAYLOAD_SIZE
))
345 slot_len
= sizeof(*slot
) + ATH6KL_FWLOG_PAYLOAD_SIZE
;
347 skb
= alloc_skb(slot_len
, GFP_KERNEL
);
351 slot
= skb_put(skb
, slot_len
);
352 slot
->timestamp
= cpu_to_le32(jiffies
);
353 slot
->length
= cpu_to_le32(len
);
354 memcpy(slot
->payload
, buf
, len
);
356 /* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */
357 memset(slot
->payload
+ len
, 0, ATH6KL_FWLOG_PAYLOAD_SIZE
- len
);
359 spin_lock(&ar
->debug
.fwlog_queue
.lock
);
361 __skb_queue_tail(&ar
->debug
.fwlog_queue
, skb
);
362 complete(&ar
->debug
.fwlog_completion
);
364 /* drop oldest entries */
365 while (skb_queue_len(&ar
->debug
.fwlog_queue
) >
366 ATH6KL_FWLOG_MAX_ENTRIES
) {
367 skb
= __skb_dequeue(&ar
->debug
.fwlog_queue
);
371 spin_unlock(&ar
->debug
.fwlog_queue
.lock
);
376 static int ath6kl_fwlog_open(struct inode
*inode
, struct file
*file
)
378 struct ath6kl
*ar
= inode
->i_private
;
380 if (ar
->debug
.fwlog_open
)
383 ar
->debug
.fwlog_open
= true;
385 file
->private_data
= inode
->i_private
;
389 static int ath6kl_fwlog_release(struct inode
*inode
, struct file
*file
)
391 struct ath6kl
*ar
= inode
->i_private
;
393 ar
->debug
.fwlog_open
= false;
398 static ssize_t
ath6kl_fwlog_read(struct file
*file
, char __user
*user_buf
,
399 size_t count
, loff_t
*ppos
)
401 struct ath6kl
*ar
= file
->private_data
;
407 buf
= vmalloc(count
);
411 /* read undelivered logs from firmware */
412 ath6kl_read_fwlogs(ar
);
414 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 ret_cnt
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
441 static const struct file_operations fops_fwlog
= {
442 .open
= ath6kl_fwlog_open
,
443 .release
= ath6kl_fwlog_release
,
444 .read
= ath6kl_fwlog_read
,
445 .owner
= THIS_MODULE
,
446 .llseek
= default_llseek
,
449 static ssize_t
ath6kl_fwlog_block_read(struct file
*file
,
450 char __user
*user_buf
,
454 struct ath6kl
*ar
= file
->private_data
;
457 size_t len
= 0, not_copied
;
461 buf
= vmalloc(count
);
465 spin_lock(&ar
->debug
.fwlog_queue
.lock
);
467 if (skb_queue_len(&ar
->debug
.fwlog_queue
) == 0) {
468 /* we must init under queue lock */
469 init_completion(&ar
->debug
.fwlog_completion
);
471 spin_unlock(&ar
->debug
.fwlog_queue
.lock
);
473 ret
= wait_for_completion_interruptible(
474 &ar
->debug
.fwlog_completion
);
475 if (ret
== -ERESTARTSYS
) {
480 spin_lock(&ar
->debug
.fwlog_queue
.lock
);
483 while ((skb
= __skb_dequeue(&ar
->debug
.fwlog_queue
))) {
484 if (skb
->len
> count
- len
) {
485 /* not enough space, put skb back and leave */
486 __skb_queue_head(&ar
->debug
.fwlog_queue
, skb
);
491 memcpy(buf
+ len
, skb
->data
, skb
->len
);
497 spin_unlock(&ar
->debug
.fwlog_queue
.lock
);
499 /* FIXME: what to do if len == 0? */
501 not_copied
= copy_to_user(user_buf
, buf
, len
);
502 if (not_copied
!= 0) {
517 static const struct file_operations fops_fwlog_block
= {
518 .open
= ath6kl_fwlog_open
,
519 .release
= ath6kl_fwlog_release
,
520 .read
= ath6kl_fwlog_block_read
,
521 .owner
= THIS_MODULE
,
522 .llseek
= default_llseek
,
525 static ssize_t
ath6kl_fwlog_mask_read(struct file
*file
, char __user
*user_buf
,
526 size_t count
, loff_t
*ppos
)
528 struct ath6kl
*ar
= file
->private_data
;
532 len
= snprintf(buf
, sizeof(buf
), "0x%x\n", ar
->debug
.fwlog_mask
);
534 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
537 static ssize_t
ath6kl_fwlog_mask_write(struct file
*file
,
538 const char __user
*user_buf
,
539 size_t count
, loff_t
*ppos
)
541 struct ath6kl
*ar
= file
->private_data
;
544 ret
= kstrtou32_from_user(user_buf
, count
, 0, &ar
->debug
.fwlog_mask
);
548 ret
= ath6kl_wmi_config_debug_module_cmd(ar
->wmi
,
549 ATH6KL_FWLOG_VALID_MASK
,
550 ar
->debug
.fwlog_mask
);
557 static const struct file_operations fops_fwlog_mask
= {
559 .read
= ath6kl_fwlog_mask_read
,
560 .write
= ath6kl_fwlog_mask_write
,
561 .owner
= THIS_MODULE
,
562 .llseek
= default_llseek
,
565 static ssize_t
read_file_tgt_stats(struct file
*file
, char __user
*user_buf
,
566 size_t count
, loff_t
*ppos
)
568 struct ath6kl
*ar
= file
->private_data
;
569 struct ath6kl_vif
*vif
;
570 struct target_stats
*tgt_stats
;
572 unsigned int len
= 0, buf_len
= 1500;
577 vif
= ath6kl_vif_first(ar
);
581 buf
= kzalloc(buf_len
, GFP_KERNEL
);
585 rv
= ath6kl_read_tgt_stats(ar
, vif
);
591 tgt_stats
= &vif
->target_stats
;
593 len
+= scnprintf(buf
+ len
, buf_len
- len
, "\n");
594 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n",
596 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n\n",
597 "=================");
598 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
599 "Ucast packets", tgt_stats
->tx_ucast_pkt
);
600 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
601 "Bcast packets", tgt_stats
->tx_bcast_pkt
);
602 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
603 "Ucast byte", tgt_stats
->tx_ucast_byte
);
604 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
605 "Bcast byte", tgt_stats
->tx_bcast_byte
);
606 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
607 "Rts success cnt", tgt_stats
->tx_rts_success_cnt
);
608 for (i
= 0; i
< 4; i
++)
609 len
+= scnprintf(buf
+ len
, buf_len
- len
,
610 "%18s %d %10llu\n", "PER on ac",
611 i
, tgt_stats
->tx_pkt_per_ac
[i
]);
612 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
613 "Error", tgt_stats
->tx_err
);
614 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
615 "Fail count", tgt_stats
->tx_fail_cnt
);
616 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
617 "Retry count", tgt_stats
->tx_retry_cnt
);
618 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
619 "Multi retry cnt", tgt_stats
->tx_mult_retry_cnt
);
620 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
621 "Rts fail cnt", tgt_stats
->tx_rts_fail_cnt
);
622 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s %10llu\n\n",
623 "TKIP counter measure used",
624 tgt_stats
->tkip_cnter_measures_invoked
);
626 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n",
628 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n",
629 "=================");
631 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
632 "Ucast packets", tgt_stats
->rx_ucast_pkt
);
633 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10d\n",
634 "Ucast Rate", tgt_stats
->rx_ucast_rate
);
635 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
636 "Bcast packets", tgt_stats
->rx_bcast_pkt
);
637 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
638 "Ucast byte", tgt_stats
->rx_ucast_byte
);
639 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
640 "Bcast byte", tgt_stats
->rx_bcast_byte
);
641 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
642 "Fragmented pkt", tgt_stats
->rx_frgment_pkt
);
643 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
644 "Error", tgt_stats
->rx_err
);
645 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
646 "CRC Err", tgt_stats
->rx_crc_err
);
647 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
648 "Key cache miss", tgt_stats
->rx_key_cache_miss
);
649 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
650 "Decrypt Err", tgt_stats
->rx_decrypt_err
);
651 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
652 "Duplicate frame", tgt_stats
->rx_dupl_frame
);
653 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
654 "Tkip Mic failure", tgt_stats
->tkip_local_mic_fail
);
655 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
656 "TKIP format err", tgt_stats
->tkip_fmt_err
);
657 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
658 "CCMP format Err", tgt_stats
->ccmp_fmt_err
);
659 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n\n",
660 "CCMP Replay Err", tgt_stats
->ccmp_replays
);
662 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n",
663 "Misc Target stats");
664 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s\n",
665 "=================");
666 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
667 "Beacon Miss count", tgt_stats
->cs_bmiss_cnt
);
668 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
669 "Num Connects", tgt_stats
->cs_connect_cnt
);
670 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10llu\n",
671 "Num disconnects", tgt_stats
->cs_discon_cnt
);
672 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10d\n",
673 "Beacon avg rssi", tgt_stats
->cs_ave_beacon_rssi
);
674 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10d\n",
675 "ARP pkt received", tgt_stats
->arp_received
);
676 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10d\n",
677 "ARP pkt matched", tgt_stats
->arp_matched
);
678 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%20s %10d\n",
679 "ARP pkt replied", tgt_stats
->arp_replied
);
684 ret_cnt
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
690 static const struct file_operations fops_tgt_stats
= {
691 .read
= read_file_tgt_stats
,
693 .owner
= THIS_MODULE
,
694 .llseek
= default_llseek
,
697 #define print_credit_info(fmt_str, ep_list_field) \
698 (len += scnprintf(buf + len, buf_len - len, fmt_str, \
699 ep_list->ep_list_field))
700 #define CREDIT_INFO_DISPLAY_STRING_LEN 200
701 #define CREDIT_INFO_LEN 128
703 static ssize_t
read_file_credit_dist_stats(struct file
*file
,
704 char __user
*user_buf
,
705 size_t count
, loff_t
*ppos
)
707 struct ath6kl
*ar
= file
->private_data
;
708 struct htc_target
*target
= ar
->htc_target
;
709 struct htc_endpoint_credit_dist
*ep_list
;
711 unsigned int buf_len
, len
= 0;
714 buf_len
= CREDIT_INFO_DISPLAY_STRING_LEN
+
715 get_queue_depth(&target
->cred_dist_list
) * CREDIT_INFO_LEN
;
716 buf
= kzalloc(buf_len
, GFP_KERNEL
);
720 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s%5d\n",
721 "Total Avail Credits: ",
722 target
->credit_info
->total_avail_credits
);
723 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%25s%5d\n",
725 target
->credit_info
->cur_free_credits
);
727 len
+= scnprintf(buf
+ len
, buf_len
- len
,
728 " Epid Flags Cred_norm Cred_min Credits Cred_assngd"
729 " Seek_cred Cred_sz Cred_per_msg Cred_to_dist"
732 list_for_each_entry(ep_list
, &target
->cred_dist_list
, list
) {
733 print_credit_info(" %2d", endpoint
);
734 print_credit_info("%10x", dist_flags
);
735 print_credit_info("%8d", cred_norm
);
736 print_credit_info("%9d", cred_min
);
737 print_credit_info("%9d", credits
);
738 print_credit_info("%10d", cred_assngd
);
739 print_credit_info("%13d", seek_cred
);
740 print_credit_info("%12d", cred_sz
);
741 print_credit_info("%9d", cred_per_msg
);
742 print_credit_info("%14d", cred_to_dist
);
743 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%12d\n",
744 get_queue_depth(&ep_list
->htc_ep
->txq
));
750 ret_cnt
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
755 static const struct file_operations fops_credit_dist_stats
= {
756 .read
= read_file_credit_dist_stats
,
758 .owner
= THIS_MODULE
,
759 .llseek
= default_llseek
,
762 static unsigned int print_endpoint_stat(struct htc_target
*target
, char *buf
,
763 unsigned int buf_len
, unsigned int len
,
764 int offset
, const char *name
)
767 struct htc_endpoint_stats
*ep_st
;
770 len
+= scnprintf(buf
+ len
, buf_len
- len
, "%s:", name
);
771 for (i
= 0; i
< ENDPOINT_MAX
; i
++) {
772 ep_st
= &target
->endpoint
[i
].ep_st
;
773 counter
= ((u32
*) ep_st
) + (offset
/ 4);
774 len
+= scnprintf(buf
+ len
, buf_len
- len
, " %u", *counter
);
776 len
+= scnprintf(buf
+ len
, buf_len
- len
, "\n");
781 static ssize_t
ath6kl_endpoint_stats_read(struct file
*file
,
782 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
;
788 unsigned int buf_len
, len
= 0;
791 buf_len
= sizeof(struct htc_endpoint_stats
) / sizeof(u32
) *
792 (25 + ENDPOINT_MAX
* 11);
793 buf
= kmalloc(buf_len
, GFP_KERNEL
);
797 #define EPSTAT(name) \
799 len = print_endpoint_stat(target, buf, buf_len, len, \
800 offsetof(struct htc_endpoint_stats, \
805 EPSTAT(cred_low_indicate
);
807 EPSTAT(tx_pkt_bundled
);
811 EPSTAT(cred_rpt_from_rx
);
812 EPSTAT(cred_rpt_from_other
);
813 EPSTAT(cred_rpt_ep0
);
814 EPSTAT(cred_from_rx
);
815 EPSTAT(cred_from_other
);
816 EPSTAT(cred_from_ep0
);
822 EPSTAT(rx_bundle_lkahd
);
823 EPSTAT(rx_bundle_from_hdr
);
824 EPSTAT(rx_alloc_thresh_hit
);
825 EPSTAT(rxalloc_thresh_byte
);
831 ret_cnt
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
836 static ssize_t
ath6kl_endpoint_stats_write(struct file
*file
,
837 const char __user
*user_buf
,
838 size_t count
, loff_t
*ppos
)
840 struct ath6kl
*ar
= file
->private_data
;
841 struct htc_target
*target
= ar
->htc_target
;
844 struct htc_endpoint_stats
*ep_st
;
846 ret
= kstrtou32_from_user(user_buf
, count
, 0, &val
);
850 for (i
= 0; i
< ENDPOINT_MAX
; i
++) {
851 ep_st
= &target
->endpoint
[i
].ep_st
;
852 memset(ep_st
, 0, sizeof(*ep_st
));
859 static const struct file_operations fops_endpoint_stats
= {
861 .read
= ath6kl_endpoint_stats_read
,
862 .write
= ath6kl_endpoint_stats_write
,
863 .owner
= THIS_MODULE
,
864 .llseek
= default_llseek
,
867 static unsigned long ath6kl_get_num_reg(void)
870 unsigned long n_reg
= 0;
872 for (i
= 0; i
< ARRAY_SIZE(diag_reg
); i
++)
874 (diag_reg
[i
].reg_end
- diag_reg
[i
].reg_start
) / 4 + 1;
879 static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr
)
883 for (i
= 0; i
< ARRAY_SIZE(diag_reg
); i
++) {
884 if (reg_addr
>= diag_reg
[i
].reg_start
&&
885 reg_addr
<= diag_reg
[i
].reg_end
)
892 static ssize_t
ath6kl_regread_read(struct file
*file
, char __user
*user_buf
,
893 size_t count
, loff_t
*ppos
)
895 struct ath6kl
*ar
= file
->private_data
;
897 unsigned int len
= 0;
899 if (ar
->debug
.dbgfs_diag_reg
)
900 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, "0x%x\n",
901 ar
->debug
.dbgfs_diag_reg
);
903 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
904 "All diag registers\n");
906 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
909 static ssize_t
ath6kl_regread_write(struct file
*file
,
910 const char __user
*user_buf
,
911 size_t count
, loff_t
*ppos
)
913 struct ath6kl
*ar
= file
->private_data
;
914 unsigned long reg_addr
;
916 if (kstrtoul_from_user(user_buf
, count
, 0, ®_addr
))
919 if ((reg_addr
% 4) != 0)
922 if (reg_addr
&& !ath6kl_dbg_is_diag_reg_valid(reg_addr
))
925 ar
->debug
.dbgfs_diag_reg
= reg_addr
;
930 static const struct file_operations fops_diag_reg_read
= {
931 .read
= ath6kl_regread_read
,
932 .write
= ath6kl_regread_write
,
934 .owner
= THIS_MODULE
,
935 .llseek
= default_llseek
,
938 static int ath6kl_regdump_open(struct inode
*inode
, struct file
*file
)
940 struct ath6kl
*ar
= inode
->i_private
;
942 unsigned long int reg_len
;
943 unsigned int len
= 0, n_reg
;
948 /* Dump all the registers if no register is specified */
949 if (!ar
->debug
.dbgfs_diag_reg
)
950 n_reg
= ath6kl_get_num_reg();
954 reg_len
= n_reg
* REG_OUTPUT_LEN_PER_LINE
;
956 reg_len
+= REGTYPE_STR_LEN
;
958 buf
= vmalloc(reg_len
);
963 addr
= ar
->debug
.dbgfs_diag_reg
;
965 status
= ath6kl_diag_read32(ar
,
966 TARG_VTOP(ar
->target_type
, addr
),
971 len
+= scnprintf(buf
+ len
, reg_len
- len
,
972 "0x%06x 0x%08x\n", addr
, le32_to_cpu(reg_val
));
976 for (i
= 0; i
< ARRAY_SIZE(diag_reg
); i
++) {
977 len
+= scnprintf(buf
+ len
, reg_len
- len
,
978 "%s\n", diag_reg
[i
].reg_info
);
979 for (addr
= diag_reg
[i
].reg_start
;
980 addr
<= diag_reg
[i
].reg_end
; addr
+= 4) {
981 status
= ath6kl_diag_read32(ar
,
982 TARG_VTOP(ar
->target_type
, addr
),
987 len
+= scnprintf(buf
+ len
, reg_len
- len
,
989 addr
, le32_to_cpu(reg_val
));
994 file
->private_data
= buf
;
998 ath6kl_warn("Unable to read memory:%u\n", addr
);
1003 static ssize_t
ath6kl_regdump_read(struct file
*file
, char __user
*user_buf
,
1004 size_t count
, loff_t
*ppos
)
1006 u8
*buf
= file
->private_data
;
1007 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, strlen(buf
));
1010 static int ath6kl_regdump_release(struct inode
*inode
, struct file
*file
)
1012 vfree(file
->private_data
);
1016 static const struct file_operations fops_reg_dump
= {
1017 .open
= ath6kl_regdump_open
,
1018 .read
= ath6kl_regdump_read
,
1019 .release
= ath6kl_regdump_release
,
1020 .owner
= THIS_MODULE
,
1021 .llseek
= default_llseek
,
1024 static ssize_t
ath6kl_lrssi_roam_write(struct file
*file
,
1025 const char __user
*user_buf
,
1026 size_t count
, loff_t
*ppos
)
1028 struct ath6kl
*ar
= file
->private_data
;
1029 unsigned long lrssi_roam_threshold
;
1032 if (kstrtoul_from_user(user_buf
, count
, 0, &lrssi_roam_threshold
))
1035 ar
->lrssi_roam_threshold
= lrssi_roam_threshold
;
1037 ret
= ath6kl_wmi_set_roam_lrssi_cmd(ar
->wmi
, ar
->lrssi_roam_threshold
);
1044 static ssize_t
ath6kl_lrssi_roam_read(struct file
*file
,
1045 char __user
*user_buf
,
1046 size_t count
, loff_t
*ppos
)
1048 struct ath6kl
*ar
= file
->private_data
;
1052 len
= snprintf(buf
, sizeof(buf
), "%u\n", ar
->lrssi_roam_threshold
);
1054 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1057 static const struct file_operations fops_lrssi_roam_threshold
= {
1058 .read
= ath6kl_lrssi_roam_read
,
1059 .write
= ath6kl_lrssi_roam_write
,
1060 .open
= simple_open
,
1061 .owner
= THIS_MODULE
,
1062 .llseek
= default_llseek
,
1065 static ssize_t
ath6kl_regwrite_read(struct file
*file
,
1066 char __user
*user_buf
,
1067 size_t count
, loff_t
*ppos
)
1069 struct ath6kl
*ar
= file
->private_data
;
1071 unsigned int len
= 0;
1073 len
= scnprintf(buf
, sizeof(buf
), "Addr: 0x%x Val: 0x%x\n",
1074 ar
->debug
.diag_reg_addr_wr
, ar
->debug
.diag_reg_val_wr
);
1076 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1079 static ssize_t
ath6kl_regwrite_write(struct file
*file
,
1080 const char __user
*user_buf
,
1081 size_t count
, loff_t
*ppos
)
1083 struct ath6kl
*ar
= file
->private_data
;
1086 unsigned int len
= 0;
1087 u32 reg_addr
, reg_val
;
1089 len
= min(count
, sizeof(buf
) - 1);
1090 if (copy_from_user(buf
, user_buf
, len
))
1096 token
= strsep(&sptr
, "=");
1100 if (kstrtou32(token
, 0, ®_addr
))
1103 if (!ath6kl_dbg_is_diag_reg_valid(reg_addr
))
1106 if (kstrtou32(sptr
, 0, ®_val
))
1109 ar
->debug
.diag_reg_addr_wr
= reg_addr
;
1110 ar
->debug
.diag_reg_val_wr
= reg_val
;
1112 if (ath6kl_diag_write32(ar
, ar
->debug
.diag_reg_addr_wr
,
1113 cpu_to_le32(ar
->debug
.diag_reg_val_wr
)))
1119 static const struct file_operations fops_diag_reg_write
= {
1120 .read
= ath6kl_regwrite_read
,
1121 .write
= ath6kl_regwrite_write
,
1122 .open
= simple_open
,
1123 .owner
= THIS_MODULE
,
1124 .llseek
= default_llseek
,
1127 int ath6kl_debug_roam_tbl_event(struct ath6kl
*ar
, const void *buf
,
1130 const struct wmi_target_roam_tbl
*tbl
;
1133 if (len
< sizeof(*tbl
))
1136 tbl
= (const struct wmi_target_roam_tbl
*) buf
;
1137 num_entries
= le16_to_cpu(tbl
->num_entries
);
1138 if (struct_size(tbl
, info
, num_entries
) > len
)
1141 if (ar
->debug
.roam_tbl
== NULL
||
1142 ar
->debug
.roam_tbl_len
< (unsigned int) len
) {
1143 kfree(ar
->debug
.roam_tbl
);
1144 ar
->debug
.roam_tbl
= kmalloc(len
, GFP_ATOMIC
);
1145 if (ar
->debug
.roam_tbl
== NULL
)
1149 memcpy(ar
->debug
.roam_tbl
, buf
, len
);
1150 ar
->debug
.roam_tbl_len
= len
;
1152 if (test_bit(ROAM_TBL_PEND
, &ar
->flag
)) {
1153 clear_bit(ROAM_TBL_PEND
, &ar
->flag
);
1154 wake_up(&ar
->event_wq
);
1160 static ssize_t
ath6kl_roam_table_read(struct file
*file
, char __user
*user_buf
,
1161 size_t count
, loff_t
*ppos
)
1163 struct ath6kl
*ar
= file
->private_data
;
1166 struct wmi_target_roam_tbl
*tbl
;
1169 unsigned int len
, buf_len
;
1172 if (down_interruptible(&ar
->sem
))
1175 set_bit(ROAM_TBL_PEND
, &ar
->flag
);
1177 ret
= ath6kl_wmi_get_roam_tbl_cmd(ar
->wmi
);
1183 left
= wait_event_interruptible_timeout(
1184 ar
->event_wq
, !test_bit(ROAM_TBL_PEND
, &ar
->flag
), WMI_TIMEOUT
);
1190 if (ar
->debug
.roam_tbl
== NULL
)
1193 tbl
= (struct wmi_target_roam_tbl
*) ar
->debug
.roam_tbl
;
1194 num_entries
= le16_to_cpu(tbl
->num_entries
);
1196 buf_len
= 100 + num_entries
* 100;
1197 buf
= kzalloc(buf_len
, GFP_KERNEL
);
1201 len
+= scnprintf(buf
+ len
, buf_len
- len
,
1203 "# roam_util bssid rssi rssidt last_rssi util bias\n",
1204 le16_to_cpu(tbl
->roam_mode
));
1206 for (i
= 0; i
< num_entries
; i
++) {
1207 struct wmi_bss_roam_info
*info
= &tbl
->info
[i
];
1208 len
+= scnprintf(buf
+ len
, buf_len
- len
,
1209 "%d %pM %d %d %d %d %d\n",
1210 a_sle32_to_cpu(info
->roam_util
), info
->bssid
,
1211 info
->rssi
, info
->rssidt
, info
->last_rssi
,
1212 info
->util
, info
->bias
);
1218 ret_cnt
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1224 static const struct file_operations fops_roam_table
= {
1225 .read
= ath6kl_roam_table_read
,
1226 .open
= simple_open
,
1227 .owner
= THIS_MODULE
,
1228 .llseek
= default_llseek
,
1231 static ssize_t
ath6kl_force_roam_write(struct file
*file
,
1232 const char __user
*user_buf
,
1233 size_t count
, loff_t
*ppos
)
1235 struct ath6kl
*ar
= file
->private_data
;
1241 len
= min(count
, sizeof(buf
) - 1);
1242 if (copy_from_user(buf
, user_buf
, len
))
1246 if (!mac_pton(buf
, bssid
))
1249 ret
= ath6kl_wmi_force_roam_cmd(ar
->wmi
, bssid
);
1256 static const struct file_operations fops_force_roam
= {
1257 .write
= ath6kl_force_roam_write
,
1258 .open
= simple_open
,
1259 .owner
= THIS_MODULE
,
1260 .llseek
= default_llseek
,
1263 static ssize_t
ath6kl_roam_mode_write(struct file
*file
,
1264 const char __user
*user_buf
,
1265 size_t count
, loff_t
*ppos
)
1267 struct ath6kl
*ar
= file
->private_data
;
1271 enum wmi_roam_mode mode
;
1273 len
= min(count
, sizeof(buf
) - 1);
1274 if (copy_from_user(buf
, user_buf
, len
))
1277 if (len
> 0 && buf
[len
- 1] == '\n')
1278 buf
[len
- 1] = '\0';
1280 if (strcasecmp(buf
, "default") == 0)
1281 mode
= WMI_DEFAULT_ROAM_MODE
;
1282 else if (strcasecmp(buf
, "bssbias") == 0)
1283 mode
= WMI_HOST_BIAS_ROAM_MODE
;
1284 else if (strcasecmp(buf
, "lock") == 0)
1285 mode
= WMI_LOCK_BSS_MODE
;
1289 ret
= ath6kl_wmi_set_roam_mode_cmd(ar
->wmi
, mode
);
1296 static const struct file_operations fops_roam_mode
= {
1297 .write
= ath6kl_roam_mode_write
,
1298 .open
= simple_open
,
1299 .owner
= THIS_MODULE
,
1300 .llseek
= default_llseek
,
1303 void ath6kl_debug_set_keepalive(struct ath6kl
*ar
, u8 keepalive
)
1305 ar
->debug
.keepalive
= keepalive
;
1308 static ssize_t
ath6kl_keepalive_read(struct file
*file
, char __user
*user_buf
,
1309 size_t count
, loff_t
*ppos
)
1311 struct ath6kl
*ar
= file
->private_data
;
1315 len
= snprintf(buf
, sizeof(buf
), "%u\n", ar
->debug
.keepalive
);
1317 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1320 static ssize_t
ath6kl_keepalive_write(struct file
*file
,
1321 const char __user
*user_buf
,
1322 size_t count
, loff_t
*ppos
)
1324 struct ath6kl
*ar
= file
->private_data
;
1328 ret
= kstrtou8_from_user(user_buf
, count
, 0, &val
);
1332 ret
= ath6kl_wmi_set_keepalive_cmd(ar
->wmi
, 0, val
);
1339 static const struct file_operations fops_keepalive
= {
1340 .open
= simple_open
,
1341 .read
= ath6kl_keepalive_read
,
1342 .write
= ath6kl_keepalive_write
,
1343 .owner
= THIS_MODULE
,
1344 .llseek
= default_llseek
,
1347 void ath6kl_debug_set_disconnect_timeout(struct ath6kl
*ar
, u8 timeout
)
1349 ar
->debug
.disc_timeout
= timeout
;
1352 static ssize_t
ath6kl_disconnect_timeout_read(struct file
*file
,
1353 char __user
*user_buf
,
1354 size_t count
, loff_t
*ppos
)
1356 struct ath6kl
*ar
= file
->private_data
;
1360 len
= snprintf(buf
, sizeof(buf
), "%u\n", ar
->debug
.disc_timeout
);
1362 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1365 static ssize_t
ath6kl_disconnect_timeout_write(struct file
*file
,
1366 const char __user
*user_buf
,
1367 size_t count
, loff_t
*ppos
)
1369 struct ath6kl
*ar
= file
->private_data
;
1373 ret
= kstrtou8_from_user(user_buf
, count
, 0, &val
);
1377 ret
= ath6kl_wmi_disctimeout_cmd(ar
->wmi
, 0, val
);
1384 static const struct file_operations fops_disconnect_timeout
= {
1385 .open
= simple_open
,
1386 .read
= ath6kl_disconnect_timeout_read
,
1387 .write
= ath6kl_disconnect_timeout_write
,
1388 .owner
= THIS_MODULE
,
1389 .llseek
= default_llseek
,
1392 static ssize_t
ath6kl_create_qos_write(struct file
*file
,
1393 const char __user
*user_buf
,
1394 size_t count
, loff_t
*ppos
)
1396 struct ath6kl
*ar
= file
->private_data
;
1397 struct ath6kl_vif
*vif
;
1401 struct wmi_create_pstream_cmd pstream
;
1405 vif
= ath6kl_vif_first(ar
);
1409 len
= min(count
, sizeof(buf
) - 1);
1410 if (copy_from_user(buf
, user_buf
, len
))
1415 token
= strsep(&sptr
, " ");
1418 if (kstrtou8(token
, 0, &pstream
.user_pri
))
1421 token
= strsep(&sptr
, " ");
1424 if (kstrtou8(token
, 0, &pstream
.traffic_direc
))
1427 token
= strsep(&sptr
, " ");
1430 if (kstrtou8(token
, 0, &pstream
.traffic_class
))
1433 token
= strsep(&sptr
, " ");
1436 if (kstrtou8(token
, 0, &pstream
.traffic_type
))
1439 token
= strsep(&sptr
, " ");
1442 if (kstrtou8(token
, 0, &pstream
.voice_psc_cap
))
1445 token
= strsep(&sptr
, " ");
1448 if (kstrtou32(token
, 0, &val32
))
1450 pstream
.min_service_int
= cpu_to_le32(val32
);
1452 token
= strsep(&sptr
, " ");
1455 if (kstrtou32(token
, 0, &val32
))
1457 pstream
.max_service_int
= cpu_to_le32(val32
);
1459 token
= strsep(&sptr
, " ");
1462 if (kstrtou32(token
, 0, &val32
))
1464 pstream
.inactivity_int
= cpu_to_le32(val32
);
1466 token
= strsep(&sptr
, " ");
1469 if (kstrtou32(token
, 0, &val32
))
1471 pstream
.suspension_int
= cpu_to_le32(val32
);
1473 token
= strsep(&sptr
, " ");
1476 if (kstrtou32(token
, 0, &val32
))
1478 pstream
.service_start_time
= cpu_to_le32(val32
);
1480 token
= strsep(&sptr
, " ");
1483 if (kstrtou8(token
, 0, &pstream
.tsid
))
1486 token
= strsep(&sptr
, " ");
1489 if (kstrtou16(token
, 0, &val16
))
1491 pstream
.nominal_msdu
= cpu_to_le16(val16
);
1493 token
= strsep(&sptr
, " ");
1496 if (kstrtou16(token
, 0, &val16
))
1498 pstream
.max_msdu
= cpu_to_le16(val16
);
1500 token
= strsep(&sptr
, " ");
1503 if (kstrtou32(token
, 0, &val32
))
1505 pstream
.min_data_rate
= cpu_to_le32(val32
);
1507 token
= strsep(&sptr
, " ");
1510 if (kstrtou32(token
, 0, &val32
))
1512 pstream
.mean_data_rate
= cpu_to_le32(val32
);
1514 token
= strsep(&sptr
, " ");
1517 if (kstrtou32(token
, 0, &val32
))
1519 pstream
.peak_data_rate
= cpu_to_le32(val32
);
1521 token
= strsep(&sptr
, " ");
1524 if (kstrtou32(token
, 0, &val32
))
1526 pstream
.max_burst_size
= cpu_to_le32(val32
);
1528 token
= strsep(&sptr
, " ");
1531 if (kstrtou32(token
, 0, &val32
))
1533 pstream
.delay_bound
= cpu_to_le32(val32
);
1535 token
= strsep(&sptr
, " ");
1538 if (kstrtou32(token
, 0, &val32
))
1540 pstream
.min_phy_rate
= cpu_to_le32(val32
);
1542 token
= strsep(&sptr
, " ");
1545 if (kstrtou32(token
, 0, &val32
))
1547 pstream
.sba
= cpu_to_le32(val32
);
1549 token
= strsep(&sptr
, " ");
1552 if (kstrtou32(token
, 0, &val32
))
1554 pstream
.medium_time
= cpu_to_le32(val32
);
1556 pstream
.nominal_phy
= le32_to_cpu(pstream
.min_phy_rate
) / 1000000;
1558 ath6kl_wmi_create_pstream_cmd(ar
->wmi
, vif
->fw_vif_idx
, &pstream
);
1563 static const struct file_operations fops_create_qos
= {
1564 .write
= ath6kl_create_qos_write
,
1565 .open
= simple_open
,
1566 .owner
= THIS_MODULE
,
1567 .llseek
= default_llseek
,
1570 static ssize_t
ath6kl_delete_qos_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
;
1582 vif
= ath6kl_vif_first(ar
);
1586 len
= min(count
, sizeof(buf
) - 1);
1587 if (copy_from_user(buf
, user_buf
, len
))
1592 token
= strsep(&sptr
, " ");
1595 if (kstrtou8(token
, 0, &traffic_class
))
1598 token
= strsep(&sptr
, " ");
1601 if (kstrtou8(token
, 0, &tsid
))
1604 ath6kl_wmi_delete_pstream_cmd(ar
->wmi
, vif
->fw_vif_idx
,
1605 traffic_class
, tsid
);
1610 static const struct file_operations fops_delete_qos
= {
1611 .write
= ath6kl_delete_qos_write
,
1612 .open
= simple_open
,
1613 .owner
= THIS_MODULE
,
1614 .llseek
= default_llseek
,
1617 static ssize_t
ath6kl_bgscan_int_write(struct file
*file
,
1618 const char __user
*user_buf
,
1619 size_t count
, loff_t
*ppos
)
1621 struct ath6kl
*ar
= file
->private_data
;
1622 struct ath6kl_vif
*vif
;
1627 vif
= ath6kl_vif_first(ar
);
1631 len
= min(count
, sizeof(buf
) - 1);
1632 if (copy_from_user(buf
, user_buf
, len
))
1636 if (kstrtou16(buf
, 0, &bgscan_int
))
1639 if (bgscan_int
== 0)
1640 bgscan_int
= 0xffff;
1642 vif
->bg_scan_period
= bgscan_int
;
1644 ath6kl_wmi_scanparams_cmd(ar
->wmi
, 0, 0, 0, bgscan_int
, 0, 0, 0, 3,
1650 static const struct file_operations fops_bgscan_int
= {
1651 .write
= ath6kl_bgscan_int_write
,
1652 .open
= simple_open
,
1653 .owner
= THIS_MODULE
,
1654 .llseek
= default_llseek
,
1657 static ssize_t
ath6kl_listen_int_write(struct file
*file
,
1658 const char __user
*user_buf
,
1659 size_t count
, loff_t
*ppos
)
1661 struct ath6kl
*ar
= file
->private_data
;
1662 struct ath6kl_vif
*vif
;
1663 u16 listen_interval
;
1667 vif
= ath6kl_vif_first(ar
);
1671 len
= min(count
, sizeof(buf
) - 1);
1672 if (copy_from_user(buf
, user_buf
, len
))
1676 if (kstrtou16(buf
, 0, &listen_interval
))
1679 if ((listen_interval
< 15) || (listen_interval
> 3000))
1682 vif
->listen_intvl_t
= listen_interval
;
1683 ath6kl_wmi_listeninterval_cmd(ar
->wmi
, vif
->fw_vif_idx
,
1684 vif
->listen_intvl_t
, 0);
1689 static ssize_t
ath6kl_listen_int_read(struct file
*file
,
1690 char __user
*user_buf
,
1691 size_t count
, loff_t
*ppos
)
1693 struct ath6kl
*ar
= file
->private_data
;
1694 struct ath6kl_vif
*vif
;
1698 vif
= ath6kl_vif_first(ar
);
1702 len
= scnprintf(buf
, sizeof(buf
), "%u\n", vif
->listen_intvl_t
);
1704 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1707 static const struct file_operations fops_listen_int
= {
1708 .read
= ath6kl_listen_int_read
,
1709 .write
= ath6kl_listen_int_write
,
1710 .open
= simple_open
,
1711 .owner
= THIS_MODULE
,
1712 .llseek
= default_llseek
,
1715 static ssize_t
ath6kl_power_params_write(struct file
*file
,
1716 const char __user
*user_buf
,
1717 size_t count
, loff_t
*ppos
)
1719 struct ath6kl
*ar
= file
->private_data
;
1721 unsigned int len
= 0;
1723 u16 idle_period
, ps_poll_num
, dtim
,
1726 len
= min(count
, sizeof(buf
) - 1);
1727 if (copy_from_user(buf
, user_buf
, len
))
1732 token
= strsep(&sptr
, " ");
1735 if (kstrtou16(token
, 0, &idle_period
))
1738 token
= strsep(&sptr
, " ");
1741 if (kstrtou16(token
, 0, &ps_poll_num
))
1744 token
= strsep(&sptr
, " ");
1747 if (kstrtou16(token
, 0, &dtim
))
1750 token
= strsep(&sptr
, " ");
1753 if (kstrtou16(token
, 0, &tx_wakeup
))
1756 token
= strsep(&sptr
, " ");
1759 if (kstrtou16(token
, 0, &num_tx
))
1762 ath6kl_wmi_pmparams_cmd(ar
->wmi
, 0, idle_period
, ps_poll_num
,
1763 dtim
, tx_wakeup
, num_tx
, 0);
1768 static const struct file_operations fops_power_params
= {
1769 .write
= ath6kl_power_params_write
,
1770 .open
= simple_open
,
1771 .owner
= THIS_MODULE
,
1772 .llseek
= default_llseek
,
1775 void ath6kl_debug_init(struct ath6kl
*ar
)
1777 skb_queue_head_init(&ar
->debug
.fwlog_queue
);
1778 init_completion(&ar
->debug
.fwlog_completion
);
1781 * Actually we are lying here but don't know how to read the mask
1782 * value from the firmware.
1784 ar
->debug
.fwlog_mask
= 0;
1788 * Initialisation needs to happen in two stages as fwlog events can come
1789 * before cfg80211 is initialised, and debugfs depends on cfg80211
1792 int ath6kl_debug_init_fs(struct ath6kl
*ar
)
1794 ar
->debugfs_phy
= debugfs_create_dir("ath6kl",
1795 ar
->wiphy
->debugfsdir
);
1797 debugfs_create_file("tgt_stats", 0400, ar
->debugfs_phy
, ar
,
1800 if (ar
->hif_type
== ATH6KL_HIF_TYPE_SDIO
)
1801 debugfs_create_file("credit_dist_stats", 0400,
1802 ar
->debugfs_phy
, ar
,
1803 &fops_credit_dist_stats
);
1805 debugfs_create_file("endpoint_stats", 0600,
1806 ar
->debugfs_phy
, ar
, &fops_endpoint_stats
);
1808 debugfs_create_file("fwlog", 0400, ar
->debugfs_phy
, ar
, &fops_fwlog
);
1810 debugfs_create_file("fwlog_block", 0400, ar
->debugfs_phy
, ar
,
1813 debugfs_create_file("fwlog_mask", 0600, ar
->debugfs_phy
,
1814 ar
, &fops_fwlog_mask
);
1816 debugfs_create_file("reg_addr", 0600, ar
->debugfs_phy
, ar
,
1817 &fops_diag_reg_read
);
1819 debugfs_create_file("reg_dump", 0400, ar
->debugfs_phy
, ar
,
1822 debugfs_create_file("lrssi_roam_threshold", 0600,
1823 ar
->debugfs_phy
, ar
, &fops_lrssi_roam_threshold
);
1825 debugfs_create_file("reg_write", 0600,
1826 ar
->debugfs_phy
, ar
, &fops_diag_reg_write
);
1828 debugfs_create_file("war_stats", 0400, ar
->debugfs_phy
, ar
,
1831 debugfs_create_file("roam_table", 0400, ar
->debugfs_phy
, ar
,
1834 debugfs_create_file("force_roam", 0200, ar
->debugfs_phy
, ar
,
1837 debugfs_create_file("roam_mode", 0200, ar
->debugfs_phy
, ar
,
1840 debugfs_create_file("keepalive", 0600, ar
->debugfs_phy
, ar
,
1843 debugfs_create_file("disconnect_timeout", 0600,
1844 ar
->debugfs_phy
, ar
, &fops_disconnect_timeout
);
1846 debugfs_create_file("create_qos", 0200, ar
->debugfs_phy
, ar
,
1849 debugfs_create_file("delete_qos", 0200, ar
->debugfs_phy
, ar
,
1852 debugfs_create_file("bgscan_interval", 0200,
1853 ar
->debugfs_phy
, ar
, &fops_bgscan_int
);
1855 debugfs_create_file("listen_interval", 0600,
1856 ar
->debugfs_phy
, ar
, &fops_listen_int
);
1858 debugfs_create_file("power_params", 0200, ar
->debugfs_phy
, ar
,
1859 &fops_power_params
);
1864 void ath6kl_debug_cleanup(struct ath6kl
*ar
)
1866 skb_queue_purge(&ar
->debug
.fwlog_queue
);
1867 complete(&ar
->debug
.fwlog_completion
);
1868 kfree(ar
->debug
.roam_tbl
);