Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004-2011 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include "core.h" |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 18 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 19 | #include <linux/skbuff.h> |
Kalle Valo | 939f1cc | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 20 | #include <linux/fs.h> |
Kalle Valo | 62c83ac | 2011-10-03 13:44:40 +0300 | [diff] [blame] | 21 | #include <linux/vmalloc.h> |
Paul Gortmaker | ee40fa0 | 2011-05-27 16:14:23 -0400 | [diff] [blame] | 22 | #include <linux/export.h> |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 23 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 24 | #include "debug.h" |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 25 | #include "target.h" |
| 26 | |
| 27 | struct ath6kl_fwlog_slot { |
| 28 | __le32 timestamp; |
| 29 | __le32 length; |
| 30 | |
| 31 | /* max ATH6KL_FWLOG_PAYLOAD_SIZE bytes */ |
| 32 | u8 payload[0]; |
| 33 | }; |
| 34 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 35 | #define ATH6KL_FWLOG_MAX_ENTRIES 20 |
| 36 | |
Kalle Valo | 939f1cc | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 37 | #define ATH6KL_FWLOG_VALID_MASK 0x1ffff |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 38 | |
| 39 | int ath6kl_printk(const char *level, const char *fmt, ...) |
| 40 | { |
| 41 | struct va_format vaf; |
| 42 | va_list args; |
| 43 | int rtn; |
| 44 | |
| 45 | va_start(args, fmt); |
| 46 | |
| 47 | vaf.fmt = fmt; |
| 48 | vaf.va = &args; |
| 49 | |
| 50 | rtn = printk("%sath6kl: %pV", level, &vaf); |
| 51 | |
| 52 | va_end(args); |
| 53 | |
| 54 | return rtn; |
| 55 | } |
Kalle Valo | d6a434d | 2012-01-17 20:09:36 +0200 | [diff] [blame] | 56 | EXPORT_SYMBOL(ath6kl_printk); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 57 | |
| 58 | #ifdef CONFIG_ATH6KL_DEBUG |
Vasanthakumar Thiagarajan | 91d57de | 2011-09-02 10:40:06 +0300 | [diff] [blame] | 59 | |
Kalle Valo | 3b1b7d0 | 2012-01-17 20:09:27 +0200 | [diff] [blame] | 60 | void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...) |
| 61 | { |
| 62 | struct va_format vaf; |
| 63 | va_list args; |
| 64 | |
| 65 | if (!(debug_mask & mask)) |
| 66 | return; |
| 67 | |
| 68 | va_start(args, fmt); |
| 69 | |
| 70 | vaf.fmt = fmt; |
| 71 | vaf.va = &args; |
| 72 | |
| 73 | ath6kl_printk(KERN_DEBUG, "%pV", &vaf); |
| 74 | |
| 75 | va_end(args); |
| 76 | } |
Kalle Valo | d6a434d | 2012-01-17 20:09:36 +0200 | [diff] [blame] | 77 | EXPORT_SYMBOL(ath6kl_dbg); |
Kalle Valo | 3b1b7d0 | 2012-01-17 20:09:27 +0200 | [diff] [blame] | 78 | |
| 79 | void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask, |
| 80 | const char *msg, const char *prefix, |
| 81 | const void *buf, size_t len) |
| 82 | { |
| 83 | if (debug_mask & mask) { |
| 84 | if (msg) |
| 85 | ath6kl_dbg(mask, "%s\n", msg); |
| 86 | |
| 87 | print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len); |
| 88 | } |
| 89 | } |
Kalle Valo | d6a434d | 2012-01-17 20:09:36 +0200 | [diff] [blame] | 90 | EXPORT_SYMBOL(ath6kl_dbg_dump); |
Kalle Valo | 3b1b7d0 | 2012-01-17 20:09:27 +0200 | [diff] [blame] | 91 | |
Vasanthakumar Thiagarajan | 91d57de | 2011-09-02 10:40:06 +0300 | [diff] [blame] | 92 | #define REG_OUTPUT_LEN_PER_LINE 25 |
| 93 | #define REGTYPE_STR_LEN 100 |
| 94 | |
| 95 | struct ath6kl_diag_reg_info { |
| 96 | u32 reg_start; |
| 97 | u32 reg_end; |
| 98 | const char *reg_info; |
| 99 | }; |
| 100 | |
| 101 | static const struct ath6kl_diag_reg_info diag_reg[] = { |
| 102 | { 0x20000, 0x200fc, "General DMA and Rx registers" }, |
| 103 | { 0x28000, 0x28900, "MAC PCU register & keycache" }, |
| 104 | { 0x20800, 0x20a40, "QCU" }, |
| 105 | { 0x21000, 0x212f0, "DCU" }, |
| 106 | { 0x4000, 0x42e4, "RTC" }, |
| 107 | { 0x540000, 0x540000 + (256 * 1024), "RAM" }, |
| 108 | { 0x29800, 0x2B210, "Base Band" }, |
| 109 | { 0x1C000, 0x1C748, "Analog" }, |
| 110 | }; |
| 111 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 112 | void ath6kl_dump_registers(struct ath6kl_device *dev, |
| 113 | struct ath6kl_irq_proc_registers *irq_proc_reg, |
| 114 | struct ath6kl_irq_enable_reg *irq_enable_reg) |
| 115 | { |
| 116 | |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 117 | ath6kl_dbg(ATH6KL_DBG_IRQ, ("<------- Register Table -------->\n")); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 118 | |
| 119 | if (irq_proc_reg != NULL) { |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 120 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 121 | "Host Int status: 0x%x\n", |
| 122 | irq_proc_reg->host_int_status); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 123 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 124 | "CPU Int status: 0x%x\n", |
| 125 | irq_proc_reg->cpu_int_status); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 126 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 127 | "Error Int status: 0x%x\n", |
| 128 | irq_proc_reg->error_int_status); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 129 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 130 | "Counter Int status: 0x%x\n", |
| 131 | irq_proc_reg->counter_int_status); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 132 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 133 | "Mbox Frame: 0x%x\n", |
| 134 | irq_proc_reg->mbox_frame); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 135 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 136 | "Rx Lookahead Valid: 0x%x\n", |
| 137 | irq_proc_reg->rx_lkahd_valid); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 138 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 139 | "Rx Lookahead 0: 0x%x\n", |
| 140 | irq_proc_reg->rx_lkahd[0]); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 141 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 142 | "Rx Lookahead 1: 0x%x\n", |
| 143 | irq_proc_reg->rx_lkahd[1]); |
| 144 | |
| 145 | if (dev->ar->mbox_info.gmbox_addr != 0) { |
| 146 | /* |
| 147 | * If the target supports GMBOX hardware, dump some |
| 148 | * additional state. |
| 149 | */ |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 150 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 151 | "GMBOX Host Int status 2: 0x%x\n", |
| 152 | irq_proc_reg->host_int_status2); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 153 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 154 | "GMBOX RX Avail: 0x%x\n", |
| 155 | irq_proc_reg->gmbox_rx_avail); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 156 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 157 | "GMBOX lookahead alias 0: 0x%x\n", |
| 158 | irq_proc_reg->rx_gmbox_lkahd_alias[0]); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 159 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 160 | "GMBOX lookahead alias 1: 0x%x\n", |
| 161 | irq_proc_reg->rx_gmbox_lkahd_alias[1]); |
| 162 | } |
| 163 | |
| 164 | } |
| 165 | |
| 166 | if (irq_enable_reg != NULL) { |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 167 | ath6kl_dbg(ATH6KL_DBG_IRQ, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 168 | "Int status Enable: 0x%x\n", |
| 169 | irq_enable_reg->int_status_en); |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 170 | ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status Enable: 0x%x\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 171 | irq_enable_reg->cntr_int_status_en); |
| 172 | } |
Kalle Valo | 5afa5aa | 2012-01-17 20:09:19 +0200 | [diff] [blame] | 173 | ath6kl_dbg(ATH6KL_DBG_IRQ, "<------------------------------->\n"); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist) |
| 177 | { |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 178 | ath6kl_dbg(ATH6KL_DBG_CREDIT, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 179 | "--- endpoint: %d svc_id: 0x%X ---\n", |
| 180 | ep_dist->endpoint, ep_dist->svc_id); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 181 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " dist_flags : 0x%X\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 182 | ep_dist->dist_flags); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 183 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_norm : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 184 | ep_dist->cred_norm); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 185 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_min : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 186 | ep_dist->cred_min); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 187 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " credits : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 188 | ep_dist->credits); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 189 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_assngd : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 190 | ep_dist->cred_assngd); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 191 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " seek_cred : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 192 | ep_dist->seek_cred); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 193 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_sz : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 194 | ep_dist->cred_sz); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 195 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_per_msg : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 196 | ep_dist->cred_per_msg); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 197 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_to_dist : %d\n", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 198 | ep_dist->cred_to_dist); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 199 | ath6kl_dbg(ATH6KL_DBG_CREDIT, " txq_depth : %d\n", |
Kalle Valo | e8c3979 | 2011-10-24 12:17:04 +0300 | [diff] [blame] | 200 | get_queue_depth(&ep_dist->htc_ep->txq)); |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 201 | ath6kl_dbg(ATH6KL_DBG_CREDIT, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 202 | "----------------------------------\n"); |
| 203 | } |
| 204 | |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 205 | /* FIXME: move to htc.c */ |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 206 | void dump_cred_dist_stats(struct htc_target *target) |
| 207 | { |
| 208 | struct htc_endpoint_credit_dist *ep_list; |
| 209 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 210 | list_for_each_entry(ep_list, &target->cred_dist_list, list) |
| 211 | dump_cred_dist(ep_list); |
| 212 | |
Kalle Valo | 02f0d6f | 2011-10-24 12:17:59 +0300 | [diff] [blame] | 213 | ath6kl_dbg(ATH6KL_DBG_CREDIT, |
| 214 | "credit distribution total %d free %d\n", |
Kalle Valo | 3c37039 | 2011-10-24 12:17:12 +0300 | [diff] [blame] | 215 | target->credit_info->total_avail_credits, |
| 216 | target->credit_info->cur_free_credits); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 217 | } |
| 218 | |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 219 | static int ath6kl_debugfs_open(struct inode *inode, struct file *file) |
| 220 | { |
| 221 | file->private_data = inode->i_private; |
| 222 | return 0; |
| 223 | } |
| 224 | |
Kalle Valo | 9a73083 | 2011-09-27 23:33:28 +0300 | [diff] [blame] | 225 | void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war) |
| 226 | { |
| 227 | switch (war) { |
| 228 | case ATH6KL_WAR_INVALID_RATE: |
| 229 | ar->debug.war_stats.invalid_rate++; |
| 230 | break; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | static ssize_t read_file_war_stats(struct file *file, char __user *user_buf, |
| 235 | size_t count, loff_t *ppos) |
| 236 | { |
| 237 | struct ath6kl *ar = file->private_data; |
| 238 | char *buf; |
| 239 | unsigned int len = 0, buf_len = 1500; |
| 240 | ssize_t ret_cnt; |
| 241 | |
| 242 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 243 | if (!buf) |
| 244 | return -ENOMEM; |
| 245 | |
| 246 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 247 | len += scnprintf(buf + len, buf_len - len, "%25s\n", |
| 248 | "Workaround stats"); |
| 249 | len += scnprintf(buf + len, buf_len - len, "%25s\n\n", |
| 250 | "================="); |
| 251 | len += scnprintf(buf + len, buf_len - len, "%20s %10u\n", |
| 252 | "Invalid rates", ar->debug.war_stats.invalid_rate); |
| 253 | |
| 254 | if (WARN_ON(len > buf_len)) |
| 255 | len = buf_len; |
| 256 | |
| 257 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 258 | |
| 259 | kfree(buf); |
| 260 | return ret_cnt; |
| 261 | } |
| 262 | |
| 263 | static const struct file_operations fops_war_stats = { |
| 264 | .read = read_file_war_stats, |
| 265 | .open = ath6kl_debugfs_open, |
| 266 | .owner = THIS_MODULE, |
| 267 | .llseek = default_llseek, |
| 268 | }; |
| 269 | |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 270 | void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len) |
| 271 | { |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 272 | struct ath6kl_fwlog_slot *slot; |
| 273 | struct sk_buff *skb; |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 274 | size_t slot_len; |
| 275 | |
| 276 | if (WARN_ON(len > ATH6KL_FWLOG_PAYLOAD_SIZE)) |
| 277 | return; |
| 278 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 279 | slot_len = sizeof(*slot) + len; |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 280 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 281 | skb = alloc_skb(slot_len, GFP_KERNEL); |
| 282 | if (!skb) |
| 283 | return; |
| 284 | |
| 285 | slot = (struct ath6kl_fwlog_slot *) skb_put(skb, slot_len); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 286 | slot->timestamp = cpu_to_le32(jiffies); |
| 287 | slot->length = cpu_to_le32(len); |
| 288 | memcpy(slot->payload, buf, len); |
| 289 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 290 | spin_lock(&ar->debug.fwlog_queue.lock); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 291 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 292 | __skb_queue_tail(&ar->debug.fwlog_queue, skb); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 293 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 294 | /* drop oldest entries */ |
| 295 | while (skb_queue_len(&ar->debug.fwlog_queue) > |
| 296 | ATH6KL_FWLOG_MAX_ENTRIES) { |
| 297 | skb = __skb_dequeue(&ar->debug.fwlog_queue); |
| 298 | kfree_skb(skb); |
| 299 | } |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 300 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 301 | spin_unlock(&ar->debug.fwlog_queue.lock); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 302 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 303 | return; |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf, |
| 307 | size_t count, loff_t *ppos) |
| 308 | { |
| 309 | struct ath6kl *ar = file->private_data; |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 310 | struct sk_buff *skb; |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 311 | ssize_t ret_cnt; |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 312 | size_t len = 0; |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 313 | char *buf; |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 314 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 315 | buf = vmalloc(count); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 316 | if (!buf) |
| 317 | return -ENOMEM; |
| 318 | |
Kalle Valo | bc07ddb | 2011-09-02 10:32:05 +0300 | [diff] [blame] | 319 | /* read undelivered logs from firmware */ |
| 320 | ath6kl_read_fwlogs(ar); |
| 321 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 322 | spin_lock(&ar->debug.fwlog_queue.lock); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 323 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 324 | while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) { |
| 325 | if (skb->len > count - len) { |
| 326 | /* not enough space, put skb back and leave */ |
| 327 | __skb_queue_head(&ar->debug.fwlog_queue, skb); |
| 328 | break; |
| 329 | } |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 330 | |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 331 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 332 | memcpy(buf + len, skb->data, skb->len); |
| 333 | len += skb->len; |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 334 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 335 | kfree_skb(skb); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 336 | } |
| 337 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 338 | spin_unlock(&ar->debug.fwlog_queue.lock); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 339 | |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 340 | /* FIXME: what to do if len == 0? */ |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 341 | |
| 342 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 343 | |
| 344 | vfree(buf); |
| 345 | |
| 346 | return ret_cnt; |
| 347 | } |
| 348 | |
| 349 | static const struct file_operations fops_fwlog = { |
| 350 | .open = ath6kl_debugfs_open, |
| 351 | .read = ath6kl_fwlog_read, |
| 352 | .owner = THIS_MODULE, |
| 353 | .llseek = default_llseek, |
| 354 | }; |
| 355 | |
Kalle Valo | 939f1cc | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 356 | static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf, |
| 357 | size_t count, loff_t *ppos) |
| 358 | { |
| 359 | struct ath6kl *ar = file->private_data; |
| 360 | char buf[16]; |
| 361 | int len; |
| 362 | |
| 363 | len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask); |
| 364 | |
| 365 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 366 | } |
| 367 | |
| 368 | static ssize_t ath6kl_fwlog_mask_write(struct file *file, |
| 369 | const char __user *user_buf, |
| 370 | size_t count, loff_t *ppos) |
| 371 | { |
| 372 | struct ath6kl *ar = file->private_data; |
| 373 | int ret; |
| 374 | |
| 375 | ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask); |
| 376 | if (ret) |
| 377 | return ret; |
| 378 | |
| 379 | ret = ath6kl_wmi_config_debug_module_cmd(ar->wmi, |
| 380 | ATH6KL_FWLOG_VALID_MASK, |
| 381 | ar->debug.fwlog_mask); |
| 382 | if (ret) |
| 383 | return ret; |
| 384 | |
| 385 | return count; |
| 386 | } |
| 387 | |
| 388 | static const struct file_operations fops_fwlog_mask = { |
| 389 | .open = ath6kl_debugfs_open, |
| 390 | .read = ath6kl_fwlog_mask_read, |
| 391 | .write = ath6kl_fwlog_mask_write, |
| 392 | .owner = THIS_MODULE, |
| 393 | .llseek = default_llseek, |
| 394 | }; |
| 395 | |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 396 | static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf, |
| 397 | size_t count, loff_t *ppos) |
| 398 | { |
| 399 | struct ath6kl *ar = file->private_data; |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 400 | struct ath6kl_vif *vif; |
| 401 | struct target_stats *tgt_stats; |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 402 | char *buf; |
| 403 | unsigned int len = 0, buf_len = 1500; |
| 404 | int i; |
| 405 | long left; |
| 406 | ssize_t ret_cnt; |
| 407 | |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 408 | vif = ath6kl_vif_first(ar); |
| 409 | if (!vif) |
| 410 | return -EIO; |
| 411 | |
| 412 | tgt_stats = &vif->target_stats; |
| 413 | |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 414 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 415 | if (!buf) |
| 416 | return -ENOMEM; |
| 417 | |
| 418 | if (down_interruptible(&ar->sem)) { |
| 419 | kfree(buf); |
| 420 | return -EBUSY; |
| 421 | } |
| 422 | |
Vasanthakumar Thiagarajan | b95907a | 2011-10-25 19:34:11 +0530 | [diff] [blame] | 423 | set_bit(STATS_UPDATE_PEND, &vif->flags); |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 424 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 425 | if (ath6kl_wmi_get_stats_cmd(ar->wmi, 0)) { |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 426 | up(&ar->sem); |
| 427 | kfree(buf); |
| 428 | return -EIO; |
| 429 | } |
| 430 | |
| 431 | left = wait_event_interruptible_timeout(ar->event_wq, |
| 432 | !test_bit(STATS_UPDATE_PEND, |
Vasanthakumar Thiagarajan | b95907a | 2011-10-25 19:34:11 +0530 | [diff] [blame] | 433 | &vif->flags), WMI_TIMEOUT); |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 434 | |
| 435 | up(&ar->sem); |
| 436 | |
| 437 | if (left <= 0) { |
| 438 | kfree(buf); |
| 439 | return -ETIMEDOUT; |
| 440 | } |
| 441 | |
| 442 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 443 | len += scnprintf(buf + len, buf_len - len, "%25s\n", |
| 444 | "Target Tx stats"); |
| 445 | len += scnprintf(buf + len, buf_len - len, "%25s\n\n", |
| 446 | "================="); |
| 447 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 448 | "Ucast packets", tgt_stats->tx_ucast_pkt); |
| 449 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 450 | "Bcast packets", tgt_stats->tx_bcast_pkt); |
| 451 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 452 | "Ucast byte", tgt_stats->tx_ucast_byte); |
| 453 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 454 | "Bcast byte", tgt_stats->tx_bcast_byte); |
| 455 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 456 | "Rts success cnt", tgt_stats->tx_rts_success_cnt); |
| 457 | for (i = 0; i < 4; i++) |
| 458 | len += scnprintf(buf + len, buf_len - len, |
| 459 | "%18s %d %10llu\n", "PER on ac", |
| 460 | i, tgt_stats->tx_pkt_per_ac[i]); |
| 461 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 462 | "Error", tgt_stats->tx_err); |
| 463 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 464 | "Fail count", tgt_stats->tx_fail_cnt); |
| 465 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 466 | "Retry count", tgt_stats->tx_retry_cnt); |
| 467 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 468 | "Multi retry cnt", tgt_stats->tx_mult_retry_cnt); |
| 469 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 470 | "Rts fail cnt", tgt_stats->tx_rts_fail_cnt); |
| 471 | len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n\n", |
| 472 | "TKIP counter measure used", |
| 473 | tgt_stats->tkip_cnter_measures_invoked); |
| 474 | |
| 475 | len += scnprintf(buf + len, buf_len - len, "%25s\n", |
| 476 | "Target Rx stats"); |
| 477 | len += scnprintf(buf + len, buf_len - len, "%25s\n", |
| 478 | "================="); |
| 479 | |
| 480 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 481 | "Ucast packets", tgt_stats->rx_ucast_pkt); |
| 482 | len += scnprintf(buf + len, buf_len - len, "%20s %10d\n", |
| 483 | "Ucast Rate", tgt_stats->rx_ucast_rate); |
| 484 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 485 | "Bcast packets", tgt_stats->rx_bcast_pkt); |
| 486 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 487 | "Ucast byte", tgt_stats->rx_ucast_byte); |
| 488 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 489 | "Bcast byte", tgt_stats->rx_bcast_byte); |
| 490 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 491 | "Fragmented pkt", tgt_stats->rx_frgment_pkt); |
| 492 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 493 | "Error", tgt_stats->rx_err); |
| 494 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 495 | "CRC Err", tgt_stats->rx_crc_err); |
| 496 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 497 | "Key chache miss", tgt_stats->rx_key_cache_miss); |
| 498 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 499 | "Decrypt Err", tgt_stats->rx_decrypt_err); |
| 500 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 501 | "Duplicate frame", tgt_stats->rx_dupl_frame); |
| 502 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 503 | "Tkip Mic failure", tgt_stats->tkip_local_mic_fail); |
| 504 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 505 | "TKIP format err", tgt_stats->tkip_fmt_err); |
| 506 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 507 | "CCMP format Err", tgt_stats->ccmp_fmt_err); |
| 508 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n\n", |
| 509 | "CCMP Replay Err", tgt_stats->ccmp_replays); |
| 510 | |
| 511 | len += scnprintf(buf + len, buf_len - len, "%25s\n", |
| 512 | "Misc Target stats"); |
| 513 | len += scnprintf(buf + len, buf_len - len, "%25s\n", |
| 514 | "================="); |
| 515 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 516 | "Beacon Miss count", tgt_stats->cs_bmiss_cnt); |
| 517 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 518 | "Num Connects", tgt_stats->cs_connect_cnt); |
| 519 | len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n", |
| 520 | "Num disconnects", tgt_stats->cs_discon_cnt); |
| 521 | len += scnprintf(buf + len, buf_len - len, "%20s %10d\n", |
| 522 | "Beacon avg rssi", tgt_stats->cs_ave_beacon_rssi); |
| 523 | |
| 524 | if (len > buf_len) |
| 525 | len = buf_len; |
| 526 | |
| 527 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 528 | |
| 529 | kfree(buf); |
| 530 | return ret_cnt; |
| 531 | } |
| 532 | |
| 533 | static const struct file_operations fops_tgt_stats = { |
| 534 | .read = read_file_tgt_stats, |
| 535 | .open = ath6kl_debugfs_open, |
| 536 | .owner = THIS_MODULE, |
| 537 | .llseek = default_llseek, |
| 538 | }; |
| 539 | |
Vasanthakumar Thiagarajan | 78fc485 | 2011-08-26 13:06:33 +0530 | [diff] [blame] | 540 | #define print_credit_info(fmt_str, ep_list_field) \ |
| 541 | (len += scnprintf(buf + len, buf_len - len, fmt_str, \ |
| 542 | ep_list->ep_list_field)) |
| 543 | #define CREDIT_INFO_DISPLAY_STRING_LEN 200 |
| 544 | #define CREDIT_INFO_LEN 128 |
| 545 | |
| 546 | static ssize_t read_file_credit_dist_stats(struct file *file, |
| 547 | char __user *user_buf, |
| 548 | size_t count, loff_t *ppos) |
| 549 | { |
| 550 | struct ath6kl *ar = file->private_data; |
| 551 | struct htc_target *target = ar->htc_target; |
| 552 | struct htc_endpoint_credit_dist *ep_list; |
| 553 | char *buf; |
| 554 | unsigned int buf_len, len = 0; |
| 555 | ssize_t ret_cnt; |
| 556 | |
| 557 | buf_len = CREDIT_INFO_DISPLAY_STRING_LEN + |
| 558 | get_queue_depth(&target->cred_dist_list) * CREDIT_INFO_LEN; |
| 559 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 560 | if (!buf) |
| 561 | return -ENOMEM; |
| 562 | |
| 563 | len += scnprintf(buf + len, buf_len - len, "%25s%5d\n", |
| 564 | "Total Avail Credits: ", |
Kalle Valo | 3c37039 | 2011-10-24 12:17:12 +0300 | [diff] [blame] | 565 | target->credit_info->total_avail_credits); |
Vasanthakumar Thiagarajan | 78fc485 | 2011-08-26 13:06:33 +0530 | [diff] [blame] | 566 | len += scnprintf(buf + len, buf_len - len, "%25s%5d\n", |
| 567 | "Free credits :", |
Kalle Valo | 3c37039 | 2011-10-24 12:17:12 +0300 | [diff] [blame] | 568 | target->credit_info->cur_free_credits); |
Vasanthakumar Thiagarajan | 78fc485 | 2011-08-26 13:06:33 +0530 | [diff] [blame] | 569 | |
| 570 | len += scnprintf(buf + len, buf_len - len, |
| 571 | " Epid Flags Cred_norm Cred_min Credits Cred_assngd" |
| 572 | " Seek_cred Cred_sz Cred_per_msg Cred_to_dist" |
| 573 | " qdepth\n"); |
| 574 | |
| 575 | list_for_each_entry(ep_list, &target->cred_dist_list, list) { |
| 576 | print_credit_info(" %2d", endpoint); |
| 577 | print_credit_info("%10x", dist_flags); |
| 578 | print_credit_info("%8d", cred_norm); |
| 579 | print_credit_info("%9d", cred_min); |
| 580 | print_credit_info("%9d", credits); |
| 581 | print_credit_info("%10d", cred_assngd); |
| 582 | print_credit_info("%13d", seek_cred); |
| 583 | print_credit_info("%12d", cred_sz); |
| 584 | print_credit_info("%9d", cred_per_msg); |
| 585 | print_credit_info("%14d", cred_to_dist); |
| 586 | len += scnprintf(buf + len, buf_len - len, "%12d\n", |
Kalle Valo | e8c3979 | 2011-10-24 12:17:04 +0300 | [diff] [blame] | 587 | get_queue_depth(&ep_list->htc_ep->txq)); |
Vasanthakumar Thiagarajan | 78fc485 | 2011-08-26 13:06:33 +0530 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | if (len > buf_len) |
| 591 | len = buf_len; |
| 592 | |
| 593 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 594 | kfree(buf); |
| 595 | return ret_cnt; |
| 596 | } |
| 597 | |
| 598 | static const struct file_operations fops_credit_dist_stats = { |
| 599 | .read = read_file_credit_dist_stats, |
| 600 | .open = ath6kl_debugfs_open, |
| 601 | .owner = THIS_MODULE, |
| 602 | .llseek = default_llseek, |
| 603 | }; |
| 604 | |
Jouni Malinen | e809128 | 2011-10-11 17:31:53 +0300 | [diff] [blame] | 605 | static unsigned int print_endpoint_stat(struct htc_target *target, char *buf, |
| 606 | unsigned int buf_len, unsigned int len, |
| 607 | int offset, const char *name) |
| 608 | { |
| 609 | int i; |
| 610 | struct htc_endpoint_stats *ep_st; |
| 611 | u32 *counter; |
| 612 | |
| 613 | len += scnprintf(buf + len, buf_len - len, "%s:", name); |
| 614 | for (i = 0; i < ENDPOINT_MAX; i++) { |
| 615 | ep_st = &target->endpoint[i].ep_st; |
| 616 | counter = ((u32 *) ep_st) + (offset / 4); |
| 617 | len += scnprintf(buf + len, buf_len - len, " %u", *counter); |
| 618 | } |
| 619 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 620 | |
| 621 | return len; |
| 622 | } |
| 623 | |
| 624 | static ssize_t ath6kl_endpoint_stats_read(struct file *file, |
| 625 | char __user *user_buf, |
| 626 | size_t count, loff_t *ppos) |
| 627 | { |
| 628 | struct ath6kl *ar = file->private_data; |
| 629 | struct htc_target *target = ar->htc_target; |
| 630 | char *buf; |
| 631 | unsigned int buf_len, len = 0; |
| 632 | ssize_t ret_cnt; |
| 633 | |
Jouni Malinen | 1716932 | 2011-10-11 22:08:21 +0300 | [diff] [blame] | 634 | buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) * |
| 635 | (25 + ENDPOINT_MAX * 11); |
| 636 | buf = kmalloc(buf_len, GFP_KERNEL); |
Jouni Malinen | e809128 | 2011-10-11 17:31:53 +0300 | [diff] [blame] | 637 | if (!buf) |
| 638 | return -ENOMEM; |
| 639 | |
| 640 | #define EPSTAT(name) \ |
| 641 | len = print_endpoint_stat(target, buf, buf_len, len, \ |
| 642 | offsetof(struct htc_endpoint_stats, name), \ |
| 643 | #name) |
| 644 | EPSTAT(cred_low_indicate); |
| 645 | EPSTAT(tx_issued); |
| 646 | EPSTAT(tx_pkt_bundled); |
| 647 | EPSTAT(tx_bundles); |
| 648 | EPSTAT(tx_dropped); |
| 649 | EPSTAT(tx_cred_rpt); |
| 650 | EPSTAT(cred_rpt_from_rx); |
Jouni Malinen | 1716932 | 2011-10-11 22:08:21 +0300 | [diff] [blame] | 651 | EPSTAT(cred_rpt_from_other); |
Jouni Malinen | e809128 | 2011-10-11 17:31:53 +0300 | [diff] [blame] | 652 | EPSTAT(cred_rpt_ep0); |
| 653 | EPSTAT(cred_from_rx); |
| 654 | EPSTAT(cred_from_other); |
| 655 | EPSTAT(cred_from_ep0); |
| 656 | EPSTAT(cred_cosumd); |
| 657 | EPSTAT(cred_retnd); |
| 658 | EPSTAT(rx_pkts); |
| 659 | EPSTAT(rx_lkahds); |
| 660 | EPSTAT(rx_bundl); |
| 661 | EPSTAT(rx_bundle_lkahd); |
| 662 | EPSTAT(rx_bundle_from_hdr); |
| 663 | EPSTAT(rx_alloc_thresh_hit); |
| 664 | EPSTAT(rxalloc_thresh_byte); |
| 665 | #undef EPSTAT |
| 666 | |
| 667 | if (len > buf_len) |
| 668 | len = buf_len; |
| 669 | |
| 670 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 671 | kfree(buf); |
| 672 | return ret_cnt; |
| 673 | } |
| 674 | |
| 675 | static ssize_t ath6kl_endpoint_stats_write(struct file *file, |
| 676 | const char __user *user_buf, |
| 677 | size_t count, loff_t *ppos) |
| 678 | { |
| 679 | struct ath6kl *ar = file->private_data; |
| 680 | struct htc_target *target = ar->htc_target; |
| 681 | int ret, i; |
| 682 | u32 val; |
| 683 | struct htc_endpoint_stats *ep_st; |
| 684 | |
| 685 | ret = kstrtou32_from_user(user_buf, count, 0, &val); |
| 686 | if (ret) |
| 687 | return ret; |
| 688 | if (val == 0) { |
| 689 | for (i = 0; i < ENDPOINT_MAX; i++) { |
| 690 | ep_st = &target->endpoint[i].ep_st; |
| 691 | memset(ep_st, 0, sizeof(*ep_st)); |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | return count; |
| 696 | } |
| 697 | |
| 698 | static const struct file_operations fops_endpoint_stats = { |
| 699 | .open = ath6kl_debugfs_open, |
| 700 | .read = ath6kl_endpoint_stats_read, |
| 701 | .write = ath6kl_endpoint_stats_write, |
| 702 | .owner = THIS_MODULE, |
| 703 | .llseek = default_llseek, |
| 704 | }; |
| 705 | |
Vasanthakumar Thiagarajan | 91d57de | 2011-09-02 10:40:06 +0300 | [diff] [blame] | 706 | static unsigned long ath6kl_get_num_reg(void) |
| 707 | { |
| 708 | int i; |
| 709 | unsigned long n_reg = 0; |
| 710 | |
| 711 | for (i = 0; i < ARRAY_SIZE(diag_reg); i++) |
| 712 | n_reg = n_reg + |
| 713 | (diag_reg[i].reg_end - diag_reg[i].reg_start) / 4 + 1; |
| 714 | |
| 715 | return n_reg; |
| 716 | } |
| 717 | |
| 718 | static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr) |
| 719 | { |
| 720 | int i; |
| 721 | |
| 722 | for (i = 0; i < ARRAY_SIZE(diag_reg); i++) { |
| 723 | if (reg_addr >= diag_reg[i].reg_start && |
| 724 | reg_addr <= diag_reg[i].reg_end) |
| 725 | return true; |
| 726 | } |
| 727 | |
| 728 | return false; |
| 729 | } |
| 730 | |
| 731 | static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf, |
| 732 | size_t count, loff_t *ppos) |
| 733 | { |
| 734 | struct ath6kl *ar = file->private_data; |
| 735 | u8 buf[50]; |
| 736 | unsigned int len = 0; |
| 737 | |
| 738 | if (ar->debug.dbgfs_diag_reg) |
| 739 | len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n", |
| 740 | ar->debug.dbgfs_diag_reg); |
| 741 | else |
| 742 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 743 | "All diag registers\n"); |
| 744 | |
| 745 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 746 | } |
| 747 | |
| 748 | static ssize_t ath6kl_regread_write(struct file *file, |
| 749 | const char __user *user_buf, |
| 750 | size_t count, loff_t *ppos) |
| 751 | { |
| 752 | struct ath6kl *ar = file->private_data; |
| 753 | u8 buf[50]; |
| 754 | unsigned int len; |
| 755 | unsigned long reg_addr; |
| 756 | |
| 757 | len = min(count, sizeof(buf) - 1); |
| 758 | if (copy_from_user(buf, user_buf, len)) |
| 759 | return -EFAULT; |
| 760 | |
| 761 | buf[len] = '\0'; |
| 762 | |
| 763 | if (strict_strtoul(buf, 0, ®_addr)) |
| 764 | return -EINVAL; |
| 765 | |
| 766 | if ((reg_addr % 4) != 0) |
| 767 | return -EINVAL; |
| 768 | |
| 769 | if (reg_addr && !ath6kl_dbg_is_diag_reg_valid(reg_addr)) |
| 770 | return -EINVAL; |
| 771 | |
| 772 | ar->debug.dbgfs_diag_reg = reg_addr; |
| 773 | |
| 774 | return count; |
| 775 | } |
| 776 | |
| 777 | static const struct file_operations fops_diag_reg_read = { |
| 778 | .read = ath6kl_regread_read, |
| 779 | .write = ath6kl_regread_write, |
| 780 | .open = ath6kl_debugfs_open, |
| 781 | .owner = THIS_MODULE, |
| 782 | .llseek = default_llseek, |
| 783 | }; |
| 784 | |
| 785 | static int ath6kl_regdump_open(struct inode *inode, struct file *file) |
| 786 | { |
| 787 | struct ath6kl *ar = inode->i_private; |
| 788 | u8 *buf; |
| 789 | unsigned long int reg_len; |
| 790 | unsigned int len = 0, n_reg; |
| 791 | u32 addr; |
| 792 | __le32 reg_val; |
| 793 | int i, status; |
| 794 | |
| 795 | /* Dump all the registers if no register is specified */ |
| 796 | if (!ar->debug.dbgfs_diag_reg) |
| 797 | n_reg = ath6kl_get_num_reg(); |
| 798 | else |
| 799 | n_reg = 1; |
| 800 | |
| 801 | reg_len = n_reg * REG_OUTPUT_LEN_PER_LINE; |
| 802 | if (n_reg > 1) |
| 803 | reg_len += REGTYPE_STR_LEN; |
| 804 | |
| 805 | buf = vmalloc(reg_len); |
| 806 | if (!buf) |
| 807 | return -ENOMEM; |
| 808 | |
| 809 | if (n_reg == 1) { |
| 810 | addr = ar->debug.dbgfs_diag_reg; |
| 811 | |
| 812 | status = ath6kl_diag_read32(ar, |
| 813 | TARG_VTOP(ar->target_type, addr), |
| 814 | (u32 *)®_val); |
| 815 | if (status) |
| 816 | goto fail_reg_read; |
| 817 | |
| 818 | len += scnprintf(buf + len, reg_len - len, |
| 819 | "0x%06x 0x%08x\n", addr, le32_to_cpu(reg_val)); |
| 820 | goto done; |
| 821 | } |
| 822 | |
| 823 | for (i = 0; i < ARRAY_SIZE(diag_reg); i++) { |
| 824 | len += scnprintf(buf + len, reg_len - len, |
| 825 | "%s\n", diag_reg[i].reg_info); |
| 826 | for (addr = diag_reg[i].reg_start; |
| 827 | addr <= diag_reg[i].reg_end; addr += 4) { |
| 828 | status = ath6kl_diag_read32(ar, |
| 829 | TARG_VTOP(ar->target_type, addr), |
| 830 | (u32 *)®_val); |
| 831 | if (status) |
| 832 | goto fail_reg_read; |
| 833 | |
| 834 | len += scnprintf(buf + len, reg_len - len, |
| 835 | "0x%06x 0x%08x\n", |
| 836 | addr, le32_to_cpu(reg_val)); |
| 837 | } |
| 838 | } |
| 839 | |
| 840 | done: |
| 841 | file->private_data = buf; |
| 842 | return 0; |
| 843 | |
| 844 | fail_reg_read: |
| 845 | ath6kl_warn("Unable to read memory:%u\n", addr); |
| 846 | vfree(buf); |
| 847 | return -EIO; |
| 848 | } |
| 849 | |
| 850 | static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf, |
| 851 | size_t count, loff_t *ppos) |
| 852 | { |
| 853 | u8 *buf = file->private_data; |
| 854 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 855 | } |
| 856 | |
| 857 | static int ath6kl_regdump_release(struct inode *inode, struct file *file) |
| 858 | { |
| 859 | vfree(file->private_data); |
| 860 | return 0; |
| 861 | } |
| 862 | |
| 863 | static const struct file_operations fops_reg_dump = { |
| 864 | .open = ath6kl_regdump_open, |
| 865 | .read = ath6kl_regdump_read, |
| 866 | .release = ath6kl_regdump_release, |
| 867 | .owner = THIS_MODULE, |
| 868 | .llseek = default_llseek, |
| 869 | }; |
| 870 | |
Vivek Natarajan | e509044 | 2011-08-31 15:02:19 +0530 | [diff] [blame] | 871 | static ssize_t ath6kl_lrssi_roam_write(struct file *file, |
| 872 | const char __user *user_buf, |
| 873 | size_t count, loff_t *ppos) |
| 874 | { |
| 875 | struct ath6kl *ar = file->private_data; |
| 876 | unsigned long lrssi_roam_threshold; |
| 877 | char buf[32]; |
| 878 | ssize_t len; |
| 879 | |
| 880 | len = min(count, sizeof(buf) - 1); |
| 881 | if (copy_from_user(buf, user_buf, len)) |
| 882 | return -EFAULT; |
| 883 | |
| 884 | buf[len] = '\0'; |
| 885 | if (strict_strtoul(buf, 0, &lrssi_roam_threshold)) |
| 886 | return -EINVAL; |
| 887 | |
| 888 | ar->lrssi_roam_threshold = lrssi_roam_threshold; |
| 889 | |
| 890 | ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold); |
| 891 | |
| 892 | return count; |
| 893 | } |
| 894 | |
| 895 | static ssize_t ath6kl_lrssi_roam_read(struct file *file, |
| 896 | char __user *user_buf, |
| 897 | size_t count, loff_t *ppos) |
| 898 | { |
| 899 | struct ath6kl *ar = file->private_data; |
| 900 | char buf[32]; |
| 901 | unsigned int len; |
| 902 | |
| 903 | len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold); |
| 904 | |
| 905 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 906 | } |
| 907 | |
| 908 | static const struct file_operations fops_lrssi_roam_threshold = { |
| 909 | .read = ath6kl_lrssi_roam_read, |
| 910 | .write = ath6kl_lrssi_roam_write, |
| 911 | .open = ath6kl_debugfs_open, |
| 912 | .owner = THIS_MODULE, |
| 913 | .llseek = default_llseek, |
| 914 | }; |
| 915 | |
Vasanthakumar Thiagarajan | 252c068 | 2011-09-05 11:19:46 +0300 | [diff] [blame] | 916 | static ssize_t ath6kl_regwrite_read(struct file *file, |
| 917 | char __user *user_buf, |
| 918 | size_t count, loff_t *ppos) |
| 919 | { |
| 920 | struct ath6kl *ar = file->private_data; |
| 921 | u8 buf[32]; |
| 922 | unsigned int len = 0; |
| 923 | |
| 924 | len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n", |
| 925 | ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr); |
| 926 | |
| 927 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 928 | } |
| 929 | |
| 930 | static ssize_t ath6kl_regwrite_write(struct file *file, |
| 931 | const char __user *user_buf, |
| 932 | size_t count, loff_t *ppos) |
| 933 | { |
| 934 | struct ath6kl *ar = file->private_data; |
| 935 | char buf[32]; |
| 936 | char *sptr, *token; |
| 937 | unsigned int len = 0; |
| 938 | u32 reg_addr, reg_val; |
| 939 | |
| 940 | len = min(count, sizeof(buf) - 1); |
| 941 | if (copy_from_user(buf, user_buf, len)) |
| 942 | return -EFAULT; |
| 943 | |
| 944 | buf[len] = '\0'; |
| 945 | sptr = buf; |
| 946 | |
| 947 | token = strsep(&sptr, "="); |
| 948 | if (!token) |
| 949 | return -EINVAL; |
| 950 | |
| 951 | if (kstrtou32(token, 0, ®_addr)) |
| 952 | return -EINVAL; |
| 953 | |
| 954 | if (!ath6kl_dbg_is_diag_reg_valid(reg_addr)) |
| 955 | return -EINVAL; |
| 956 | |
| 957 | if (kstrtou32(sptr, 0, ®_val)) |
| 958 | return -EINVAL; |
| 959 | |
| 960 | ar->debug.diag_reg_addr_wr = reg_addr; |
| 961 | ar->debug.diag_reg_val_wr = reg_val; |
| 962 | |
| 963 | if (ath6kl_diag_write32(ar, ar->debug.diag_reg_addr_wr, |
| 964 | cpu_to_le32(ar->debug.diag_reg_val_wr))) |
| 965 | return -EIO; |
| 966 | |
| 967 | return count; |
| 968 | } |
| 969 | |
| 970 | static const struct file_operations fops_diag_reg_write = { |
| 971 | .read = ath6kl_regwrite_read, |
| 972 | .write = ath6kl_regwrite_write, |
| 973 | .open = ath6kl_debugfs_open, |
| 974 | .owner = THIS_MODULE, |
| 975 | .llseek = default_llseek, |
| 976 | }; |
| 977 | |
Jouni Malinen | 4b28a80 | 2011-10-11 17:31:54 +0300 | [diff] [blame] | 978 | int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf, |
| 979 | size_t len) |
| 980 | { |
| 981 | const struct wmi_target_roam_tbl *tbl; |
| 982 | u16 num_entries; |
| 983 | |
| 984 | if (len < sizeof(*tbl)) |
| 985 | return -EINVAL; |
| 986 | |
| 987 | tbl = (const struct wmi_target_roam_tbl *) buf; |
| 988 | num_entries = le16_to_cpu(tbl->num_entries); |
| 989 | if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) > |
| 990 | len) |
| 991 | return -EINVAL; |
| 992 | |
| 993 | if (ar->debug.roam_tbl == NULL || |
| 994 | ar->debug.roam_tbl_len < (unsigned int) len) { |
| 995 | kfree(ar->debug.roam_tbl); |
| 996 | ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC); |
| 997 | if (ar->debug.roam_tbl == NULL) |
| 998 | return -ENOMEM; |
| 999 | } |
| 1000 | |
| 1001 | memcpy(ar->debug.roam_tbl, buf, len); |
| 1002 | ar->debug.roam_tbl_len = len; |
| 1003 | |
| 1004 | if (test_bit(ROAM_TBL_PEND, &ar->flag)) { |
| 1005 | clear_bit(ROAM_TBL_PEND, &ar->flag); |
| 1006 | wake_up(&ar->event_wq); |
| 1007 | } |
| 1008 | |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
| 1012 | static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf, |
| 1013 | size_t count, loff_t *ppos) |
| 1014 | { |
| 1015 | struct ath6kl *ar = file->private_data; |
| 1016 | int ret; |
| 1017 | long left; |
| 1018 | struct wmi_target_roam_tbl *tbl; |
| 1019 | u16 num_entries, i; |
| 1020 | char *buf; |
| 1021 | unsigned int len, buf_len; |
| 1022 | ssize_t ret_cnt; |
| 1023 | |
| 1024 | if (down_interruptible(&ar->sem)) |
| 1025 | return -EBUSY; |
| 1026 | |
| 1027 | set_bit(ROAM_TBL_PEND, &ar->flag); |
| 1028 | |
| 1029 | ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi); |
| 1030 | if (ret) { |
| 1031 | up(&ar->sem); |
| 1032 | return ret; |
| 1033 | } |
| 1034 | |
| 1035 | left = wait_event_interruptible_timeout( |
| 1036 | ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT); |
| 1037 | up(&ar->sem); |
| 1038 | |
| 1039 | if (left <= 0) |
| 1040 | return -ETIMEDOUT; |
| 1041 | |
| 1042 | if (ar->debug.roam_tbl == NULL) |
| 1043 | return -ENOMEM; |
| 1044 | |
| 1045 | tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl; |
| 1046 | num_entries = le16_to_cpu(tbl->num_entries); |
| 1047 | |
| 1048 | buf_len = 100 + num_entries * 100; |
| 1049 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 1050 | if (buf == NULL) |
| 1051 | return -ENOMEM; |
| 1052 | len = 0; |
| 1053 | len += scnprintf(buf + len, buf_len - len, |
| 1054 | "roam_mode=%u\n\n" |
| 1055 | "# roam_util bssid rssi rssidt last_rssi util bias\n", |
| 1056 | le16_to_cpu(tbl->roam_mode)); |
| 1057 | |
| 1058 | for (i = 0; i < num_entries; i++) { |
| 1059 | struct wmi_bss_roam_info *info = &tbl->info[i]; |
| 1060 | len += scnprintf(buf + len, buf_len - len, |
| 1061 | "%d %pM %d %d %d %d %d\n", |
| 1062 | a_sle32_to_cpu(info->roam_util), info->bssid, |
| 1063 | info->rssi, info->rssidt, info->last_rssi, |
| 1064 | info->util, info->bias); |
| 1065 | } |
| 1066 | |
| 1067 | if (len > buf_len) |
| 1068 | len = buf_len; |
| 1069 | |
| 1070 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1071 | |
| 1072 | kfree(buf); |
| 1073 | return ret_cnt; |
| 1074 | } |
| 1075 | |
| 1076 | static const struct file_operations fops_roam_table = { |
| 1077 | .read = ath6kl_roam_table_read, |
| 1078 | .open = ath6kl_debugfs_open, |
| 1079 | .owner = THIS_MODULE, |
| 1080 | .llseek = default_llseek, |
| 1081 | }; |
| 1082 | |
Jouni Malinen | 1261875 | 2011-10-11 17:31:55 +0300 | [diff] [blame] | 1083 | static ssize_t ath6kl_force_roam_write(struct file *file, |
| 1084 | const char __user *user_buf, |
| 1085 | size_t count, loff_t *ppos) |
| 1086 | { |
| 1087 | struct ath6kl *ar = file->private_data; |
| 1088 | int ret; |
| 1089 | char buf[20]; |
| 1090 | size_t len; |
| 1091 | u8 bssid[ETH_ALEN]; |
| 1092 | int i; |
| 1093 | int addr[ETH_ALEN]; |
| 1094 | |
| 1095 | len = min(count, sizeof(buf) - 1); |
| 1096 | if (copy_from_user(buf, user_buf, len)) |
| 1097 | return -EFAULT; |
| 1098 | buf[len] = '\0'; |
| 1099 | |
| 1100 | if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", |
| 1101 | &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) |
| 1102 | != ETH_ALEN) |
| 1103 | return -EINVAL; |
| 1104 | for (i = 0; i < ETH_ALEN; i++) |
| 1105 | bssid[i] = addr[i]; |
| 1106 | |
| 1107 | ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid); |
| 1108 | if (ret) |
| 1109 | return ret; |
| 1110 | |
| 1111 | return count; |
| 1112 | } |
| 1113 | |
| 1114 | static const struct file_operations fops_force_roam = { |
| 1115 | .write = ath6kl_force_roam_write, |
| 1116 | .open = ath6kl_debugfs_open, |
| 1117 | .owner = THIS_MODULE, |
| 1118 | .llseek = default_llseek, |
| 1119 | }; |
| 1120 | |
| 1121 | static ssize_t ath6kl_roam_mode_write(struct file *file, |
| 1122 | const char __user *user_buf, |
| 1123 | size_t count, loff_t *ppos) |
| 1124 | { |
| 1125 | struct ath6kl *ar = file->private_data; |
| 1126 | int ret; |
| 1127 | char buf[20]; |
| 1128 | size_t len; |
| 1129 | enum wmi_roam_mode mode; |
| 1130 | |
| 1131 | len = min(count, sizeof(buf) - 1); |
| 1132 | if (copy_from_user(buf, user_buf, len)) |
| 1133 | return -EFAULT; |
| 1134 | buf[len] = '\0'; |
| 1135 | if (len > 0 && buf[len - 1] == '\n') |
| 1136 | buf[len - 1] = '\0'; |
| 1137 | |
| 1138 | if (strcasecmp(buf, "default") == 0) |
| 1139 | mode = WMI_DEFAULT_ROAM_MODE; |
| 1140 | else if (strcasecmp(buf, "bssbias") == 0) |
| 1141 | mode = WMI_HOST_BIAS_ROAM_MODE; |
| 1142 | else if (strcasecmp(buf, "lock") == 0) |
| 1143 | mode = WMI_LOCK_BSS_MODE; |
| 1144 | else |
| 1145 | return -EINVAL; |
| 1146 | |
| 1147 | ret = ath6kl_wmi_set_roam_mode_cmd(ar->wmi, mode); |
| 1148 | if (ret) |
| 1149 | return ret; |
| 1150 | |
| 1151 | return count; |
| 1152 | } |
| 1153 | |
| 1154 | static const struct file_operations fops_roam_mode = { |
| 1155 | .write = ath6kl_roam_mode_write, |
| 1156 | .open = ath6kl_debugfs_open, |
| 1157 | .owner = THIS_MODULE, |
| 1158 | .llseek = default_llseek, |
| 1159 | }; |
| 1160 | |
Jouni Malinen | ff0b007 | 2011-10-11 17:31:56 +0300 | [diff] [blame] | 1161 | void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive) |
| 1162 | { |
| 1163 | ar->debug.keepalive = keepalive; |
| 1164 | } |
| 1165 | |
| 1166 | static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf, |
| 1167 | size_t count, loff_t *ppos) |
| 1168 | { |
| 1169 | struct ath6kl *ar = file->private_data; |
| 1170 | char buf[16]; |
| 1171 | int len; |
| 1172 | |
| 1173 | len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive); |
| 1174 | |
| 1175 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1176 | } |
| 1177 | |
| 1178 | static ssize_t ath6kl_keepalive_write(struct file *file, |
| 1179 | const char __user *user_buf, |
| 1180 | size_t count, loff_t *ppos) |
| 1181 | { |
| 1182 | struct ath6kl *ar = file->private_data; |
| 1183 | int ret; |
| 1184 | u8 val; |
| 1185 | |
| 1186 | ret = kstrtou8_from_user(user_buf, count, 0, &val); |
| 1187 | if (ret) |
| 1188 | return ret; |
| 1189 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 1190 | ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, 0, val); |
Jouni Malinen | ff0b007 | 2011-10-11 17:31:56 +0300 | [diff] [blame] | 1191 | if (ret) |
| 1192 | return ret; |
| 1193 | |
| 1194 | return count; |
| 1195 | } |
| 1196 | |
| 1197 | static const struct file_operations fops_keepalive = { |
| 1198 | .open = ath6kl_debugfs_open, |
| 1199 | .read = ath6kl_keepalive_read, |
| 1200 | .write = ath6kl_keepalive_write, |
| 1201 | .owner = THIS_MODULE, |
| 1202 | .llseek = default_llseek, |
| 1203 | }; |
| 1204 | |
| 1205 | void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout) |
| 1206 | { |
| 1207 | ar->debug.disc_timeout = timeout; |
| 1208 | } |
| 1209 | |
| 1210 | static ssize_t ath6kl_disconnect_timeout_read(struct file *file, |
| 1211 | char __user *user_buf, |
| 1212 | size_t count, loff_t *ppos) |
| 1213 | { |
| 1214 | struct ath6kl *ar = file->private_data; |
| 1215 | char buf[16]; |
| 1216 | int len; |
| 1217 | |
| 1218 | len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout); |
| 1219 | |
| 1220 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1221 | } |
| 1222 | |
| 1223 | static ssize_t ath6kl_disconnect_timeout_write(struct file *file, |
| 1224 | const char __user *user_buf, |
| 1225 | size_t count, loff_t *ppos) |
| 1226 | { |
| 1227 | struct ath6kl *ar = file->private_data; |
| 1228 | int ret; |
| 1229 | u8 val; |
| 1230 | |
| 1231 | ret = kstrtou8_from_user(user_buf, count, 0, &val); |
| 1232 | if (ret) |
| 1233 | return ret; |
| 1234 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 1235 | ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, 0, val); |
Jouni Malinen | ff0b007 | 2011-10-11 17:31:56 +0300 | [diff] [blame] | 1236 | if (ret) |
| 1237 | return ret; |
| 1238 | |
| 1239 | return count; |
| 1240 | } |
| 1241 | |
| 1242 | static const struct file_operations fops_disconnect_timeout = { |
| 1243 | .open = ath6kl_debugfs_open, |
| 1244 | .read = ath6kl_disconnect_timeout_read, |
| 1245 | .write = ath6kl_disconnect_timeout_write, |
| 1246 | .owner = THIS_MODULE, |
| 1247 | .llseek = default_llseek, |
| 1248 | }; |
| 1249 | |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1250 | static ssize_t ath6kl_create_qos_write(struct file *file, |
| 1251 | const char __user *user_buf, |
| 1252 | size_t count, loff_t *ppos) |
| 1253 | { |
| 1254 | |
| 1255 | struct ath6kl *ar = file->private_data; |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 1256 | struct ath6kl_vif *vif; |
Vasanthakumar Thiagarajan | 8cb6d99 | 2011-11-04 18:34:55 +0530 | [diff] [blame] | 1257 | char buf[200]; |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1258 | ssize_t len; |
| 1259 | char *sptr, *token; |
| 1260 | struct wmi_create_pstream_cmd pstream; |
| 1261 | u32 val32; |
| 1262 | u16 val16; |
| 1263 | |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 1264 | vif = ath6kl_vif_first(ar); |
| 1265 | if (!vif) |
| 1266 | return -EIO; |
| 1267 | |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1268 | len = min(count, sizeof(buf) - 1); |
| 1269 | if (copy_from_user(buf, user_buf, len)) |
| 1270 | return -EFAULT; |
| 1271 | buf[len] = '\0'; |
| 1272 | sptr = buf; |
| 1273 | |
| 1274 | token = strsep(&sptr, " "); |
| 1275 | if (!token) |
| 1276 | return -EINVAL; |
| 1277 | if (kstrtou8(token, 0, &pstream.user_pri)) |
| 1278 | return -EINVAL; |
| 1279 | |
| 1280 | token = strsep(&sptr, " "); |
| 1281 | if (!token) |
| 1282 | return -EINVAL; |
| 1283 | if (kstrtou8(token, 0, &pstream.traffic_direc)) |
| 1284 | return -EINVAL; |
| 1285 | |
| 1286 | token = strsep(&sptr, " "); |
| 1287 | if (!token) |
| 1288 | return -EINVAL; |
| 1289 | if (kstrtou8(token, 0, &pstream.traffic_class)) |
| 1290 | return -EINVAL; |
| 1291 | |
| 1292 | token = strsep(&sptr, " "); |
| 1293 | if (!token) |
| 1294 | return -EINVAL; |
| 1295 | if (kstrtou8(token, 0, &pstream.traffic_type)) |
| 1296 | return -EINVAL; |
| 1297 | |
| 1298 | token = strsep(&sptr, " "); |
| 1299 | if (!token) |
| 1300 | return -EINVAL; |
| 1301 | if (kstrtou8(token, 0, &pstream.voice_psc_cap)) |
| 1302 | return -EINVAL; |
| 1303 | |
| 1304 | token = strsep(&sptr, " "); |
| 1305 | if (!token) |
| 1306 | return -EINVAL; |
| 1307 | if (kstrtou32(token, 0, &val32)) |
| 1308 | return -EINVAL; |
| 1309 | pstream.min_service_int = cpu_to_le32(val32); |
| 1310 | |
| 1311 | token = strsep(&sptr, " "); |
| 1312 | if (!token) |
| 1313 | return -EINVAL; |
| 1314 | if (kstrtou32(token, 0, &val32)) |
| 1315 | return -EINVAL; |
| 1316 | pstream.max_service_int = cpu_to_le32(val32); |
| 1317 | |
| 1318 | token = strsep(&sptr, " "); |
| 1319 | if (!token) |
| 1320 | return -EINVAL; |
| 1321 | if (kstrtou32(token, 0, &val32)) |
| 1322 | return -EINVAL; |
| 1323 | pstream.inactivity_int = cpu_to_le32(val32); |
| 1324 | |
| 1325 | token = strsep(&sptr, " "); |
| 1326 | if (!token) |
| 1327 | return -EINVAL; |
| 1328 | if (kstrtou32(token, 0, &val32)) |
| 1329 | return -EINVAL; |
| 1330 | pstream.suspension_int = cpu_to_le32(val32); |
| 1331 | |
| 1332 | token = strsep(&sptr, " "); |
| 1333 | if (!token) |
| 1334 | return -EINVAL; |
| 1335 | if (kstrtou32(token, 0, &val32)) |
| 1336 | return -EINVAL; |
| 1337 | pstream.service_start_time = cpu_to_le32(val32); |
| 1338 | |
| 1339 | token = strsep(&sptr, " "); |
| 1340 | if (!token) |
| 1341 | return -EINVAL; |
| 1342 | if (kstrtou8(token, 0, &pstream.tsid)) |
| 1343 | return -EINVAL; |
| 1344 | |
| 1345 | token = strsep(&sptr, " "); |
| 1346 | if (!token) |
| 1347 | return -EINVAL; |
| 1348 | if (kstrtou16(token, 0, &val16)) |
| 1349 | return -EINVAL; |
| 1350 | pstream.nominal_msdu = cpu_to_le16(val16); |
| 1351 | |
| 1352 | token = strsep(&sptr, " "); |
| 1353 | if (!token) |
| 1354 | return -EINVAL; |
| 1355 | if (kstrtou16(token, 0, &val16)) |
| 1356 | return -EINVAL; |
| 1357 | pstream.max_msdu = cpu_to_le16(val16); |
| 1358 | |
| 1359 | token = strsep(&sptr, " "); |
| 1360 | if (!token) |
| 1361 | return -EINVAL; |
| 1362 | if (kstrtou32(token, 0, &val32)) |
| 1363 | return -EINVAL; |
| 1364 | pstream.min_data_rate = cpu_to_le32(val32); |
| 1365 | |
| 1366 | token = strsep(&sptr, " "); |
| 1367 | if (!token) |
| 1368 | return -EINVAL; |
| 1369 | if (kstrtou32(token, 0, &val32)) |
| 1370 | return -EINVAL; |
| 1371 | pstream.mean_data_rate = cpu_to_le32(val32); |
| 1372 | |
| 1373 | token = strsep(&sptr, " "); |
| 1374 | if (!token) |
| 1375 | return -EINVAL; |
| 1376 | if (kstrtou32(token, 0, &val32)) |
| 1377 | return -EINVAL; |
| 1378 | pstream.peak_data_rate = cpu_to_le32(val32); |
| 1379 | |
| 1380 | token = strsep(&sptr, " "); |
| 1381 | if (!token) |
| 1382 | return -EINVAL; |
| 1383 | if (kstrtou32(token, 0, &val32)) |
| 1384 | return -EINVAL; |
| 1385 | pstream.max_burst_size = cpu_to_le32(val32); |
| 1386 | |
| 1387 | token = strsep(&sptr, " "); |
| 1388 | if (!token) |
| 1389 | return -EINVAL; |
| 1390 | if (kstrtou32(token, 0, &val32)) |
| 1391 | return -EINVAL; |
| 1392 | pstream.delay_bound = cpu_to_le32(val32); |
| 1393 | |
| 1394 | token = strsep(&sptr, " "); |
| 1395 | if (!token) |
| 1396 | return -EINVAL; |
| 1397 | if (kstrtou32(token, 0, &val32)) |
| 1398 | return -EINVAL; |
| 1399 | pstream.min_phy_rate = cpu_to_le32(val32); |
| 1400 | |
| 1401 | token = strsep(&sptr, " "); |
| 1402 | if (!token) |
| 1403 | return -EINVAL; |
| 1404 | if (kstrtou32(token, 0, &val32)) |
| 1405 | return -EINVAL; |
| 1406 | pstream.sba = cpu_to_le32(val32); |
| 1407 | |
| 1408 | token = strsep(&sptr, " "); |
| 1409 | if (!token) |
| 1410 | return -EINVAL; |
| 1411 | if (kstrtou32(token, 0, &val32)) |
| 1412 | return -EINVAL; |
| 1413 | pstream.medium_time = cpu_to_le32(val32); |
| 1414 | |
Chilam Ng | 5fbea5d | 2012-02-01 01:03:37 -0800 | [diff] [blame] | 1415 | pstream.nominal_phy = le32_to_cpu(pstream.min_phy_rate) / 1000000; |
| 1416 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1417 | ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream); |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1418 | |
| 1419 | return count; |
| 1420 | } |
| 1421 | |
| 1422 | static const struct file_operations fops_create_qos = { |
| 1423 | .write = ath6kl_create_qos_write, |
| 1424 | .open = ath6kl_debugfs_open, |
| 1425 | .owner = THIS_MODULE, |
| 1426 | .llseek = default_llseek, |
| 1427 | }; |
| 1428 | |
| 1429 | static ssize_t ath6kl_delete_qos_write(struct file *file, |
| 1430 | const char __user *user_buf, |
| 1431 | size_t count, loff_t *ppos) |
| 1432 | { |
| 1433 | |
| 1434 | struct ath6kl *ar = file->private_data; |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 1435 | struct ath6kl_vif *vif; |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1436 | char buf[100]; |
| 1437 | ssize_t len; |
| 1438 | char *sptr, *token; |
| 1439 | u8 traffic_class; |
| 1440 | u8 tsid; |
| 1441 | |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 1442 | vif = ath6kl_vif_first(ar); |
| 1443 | if (!vif) |
| 1444 | return -EIO; |
| 1445 | |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1446 | len = min(count, sizeof(buf) - 1); |
| 1447 | if (copy_from_user(buf, user_buf, len)) |
| 1448 | return -EFAULT; |
| 1449 | buf[len] = '\0'; |
| 1450 | sptr = buf; |
| 1451 | |
| 1452 | token = strsep(&sptr, " "); |
| 1453 | if (!token) |
| 1454 | return -EINVAL; |
| 1455 | if (kstrtou8(token, 0, &traffic_class)) |
| 1456 | return -EINVAL; |
| 1457 | |
| 1458 | token = strsep(&sptr, " "); |
| 1459 | if (!token) |
| 1460 | return -EINVAL; |
| 1461 | if (kstrtou8(token, 0, &tsid)) |
| 1462 | return -EINVAL; |
| 1463 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1464 | ath6kl_wmi_delete_pstream_cmd(ar->wmi, vif->fw_vif_idx, |
| 1465 | traffic_class, tsid); |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1466 | |
| 1467 | return count; |
| 1468 | } |
| 1469 | |
| 1470 | static const struct file_operations fops_delete_qos = { |
| 1471 | .write = ath6kl_delete_qos_write, |
| 1472 | .open = ath6kl_debugfs_open, |
| 1473 | .owner = THIS_MODULE, |
| 1474 | .llseek = default_llseek, |
| 1475 | }; |
| 1476 | |
Rishi Panjwani | 116b3a2 | 2011-10-18 17:20:06 -0700 | [diff] [blame] | 1477 | static ssize_t ath6kl_bgscan_int_write(struct file *file, |
| 1478 | const char __user *user_buf, |
| 1479 | size_t count, loff_t *ppos) |
| 1480 | { |
| 1481 | struct ath6kl *ar = file->private_data; |
| 1482 | u16 bgscan_int; |
| 1483 | char buf[32]; |
| 1484 | ssize_t len; |
| 1485 | |
| 1486 | len = min(count, sizeof(buf) - 1); |
| 1487 | if (copy_from_user(buf, user_buf, len)) |
| 1488 | return -EFAULT; |
| 1489 | |
| 1490 | buf[len] = '\0'; |
| 1491 | if (kstrtou16(buf, 0, &bgscan_int)) |
| 1492 | return -EINVAL; |
| 1493 | |
| 1494 | if (bgscan_int == 0) |
| 1495 | bgscan_int = 0xffff; |
| 1496 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1497 | ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3, |
Rishi Panjwani | 116b3a2 | 2011-10-18 17:20:06 -0700 | [diff] [blame] | 1498 | 0, 0, 0); |
| 1499 | |
| 1500 | return count; |
| 1501 | } |
| 1502 | |
| 1503 | static const struct file_operations fops_bgscan_int = { |
| 1504 | .write = ath6kl_bgscan_int_write, |
| 1505 | .open = ath6kl_debugfs_open, |
| 1506 | .owner = THIS_MODULE, |
| 1507 | .llseek = default_llseek, |
| 1508 | }; |
| 1509 | |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1510 | static ssize_t ath6kl_listen_int_write(struct file *file, |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1511 | const char __user *user_buf, |
| 1512 | size_t count, loff_t *ppos) |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1513 | { |
| 1514 | struct ath6kl *ar = file->private_data; |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1515 | struct ath6kl_vif *vif; |
| 1516 | u16 listen_interval; |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1517 | char buf[32]; |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1518 | ssize_t len; |
| 1519 | |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1520 | vif = ath6kl_vif_first(ar); |
| 1521 | if (!vif) |
| 1522 | return -EIO; |
| 1523 | |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1524 | len = min(count, sizeof(buf) - 1); |
| 1525 | if (copy_from_user(buf, user_buf, len)) |
| 1526 | return -EFAULT; |
| 1527 | |
| 1528 | buf[len] = '\0'; |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1529 | if (kstrtou16(buf, 0, &listen_interval)) |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1530 | return -EINVAL; |
| 1531 | |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1532 | if ((listen_interval < 1) || (listen_interval > 50)) |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1533 | return -EINVAL; |
| 1534 | |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1535 | ar->listen_intvl_b = listen_interval; |
| 1536 | ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, 0, |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1537 | ar->listen_intvl_b); |
| 1538 | |
| 1539 | return count; |
| 1540 | } |
| 1541 | |
| 1542 | static ssize_t ath6kl_listen_int_read(struct file *file, |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1543 | char __user *user_buf, |
| 1544 | size_t count, loff_t *ppos) |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1545 | { |
| 1546 | struct ath6kl *ar = file->private_data; |
Dan Carpenter | 50553c2 | 2011-11-23 09:34:50 +0300 | [diff] [blame] | 1547 | char buf[32]; |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1548 | int len; |
| 1549 | |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1550 | len = scnprintf(buf, sizeof(buf), "%u\n", ar->listen_intvl_b); |
Rishi Panjwani | ef8f0eb | 2011-10-25 17:26:29 -0700 | [diff] [blame] | 1551 | |
| 1552 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1553 | } |
| 1554 | |
| 1555 | static const struct file_operations fops_listen_int = { |
| 1556 | .read = ath6kl_listen_int_read, |
| 1557 | .write = ath6kl_listen_int_write, |
| 1558 | .open = ath6kl_debugfs_open, |
| 1559 | .owner = THIS_MODULE, |
| 1560 | .llseek = default_llseek, |
| 1561 | }; |
| 1562 | |
Rishi Panjwani | a24fc7c | 2011-10-25 19:52:41 -0700 | [diff] [blame] | 1563 | static ssize_t ath6kl_power_params_write(struct file *file, |
| 1564 | const char __user *user_buf, |
| 1565 | size_t count, loff_t *ppos) |
| 1566 | { |
| 1567 | struct ath6kl *ar = file->private_data; |
| 1568 | u8 buf[100]; |
| 1569 | unsigned int len = 0; |
| 1570 | char *sptr, *token; |
| 1571 | u16 idle_period, ps_poll_num, dtim, |
| 1572 | tx_wakeup, num_tx; |
| 1573 | |
| 1574 | len = min(count, sizeof(buf) - 1); |
| 1575 | if (copy_from_user(buf, user_buf, len)) |
| 1576 | return -EFAULT; |
| 1577 | buf[len] = '\0'; |
| 1578 | sptr = buf; |
| 1579 | |
| 1580 | token = strsep(&sptr, " "); |
| 1581 | if (!token) |
| 1582 | return -EINVAL; |
| 1583 | if (kstrtou16(token, 0, &idle_period)) |
| 1584 | return -EINVAL; |
| 1585 | |
| 1586 | token = strsep(&sptr, " "); |
| 1587 | if (!token) |
| 1588 | return -EINVAL; |
| 1589 | if (kstrtou16(token, 0, &ps_poll_num)) |
| 1590 | return -EINVAL; |
| 1591 | |
| 1592 | token = strsep(&sptr, " "); |
| 1593 | if (!token) |
| 1594 | return -EINVAL; |
| 1595 | if (kstrtou16(token, 0, &dtim)) |
| 1596 | return -EINVAL; |
| 1597 | |
| 1598 | token = strsep(&sptr, " "); |
| 1599 | if (!token) |
| 1600 | return -EINVAL; |
| 1601 | if (kstrtou16(token, 0, &tx_wakeup)) |
| 1602 | return -EINVAL; |
| 1603 | |
| 1604 | token = strsep(&sptr, " "); |
| 1605 | if (!token) |
| 1606 | return -EINVAL; |
| 1607 | if (kstrtou16(token, 0, &num_tx)) |
| 1608 | return -EINVAL; |
| 1609 | |
| 1610 | ath6kl_wmi_pmparams_cmd(ar->wmi, 0, idle_period, ps_poll_num, |
| 1611 | dtim, tx_wakeup, num_tx, 0); |
| 1612 | |
| 1613 | return count; |
| 1614 | } |
| 1615 | |
| 1616 | static const struct file_operations fops_power_params = { |
| 1617 | .write = ath6kl_power_params_write, |
| 1618 | .open = ath6kl_debugfs_open, |
| 1619 | .owner = THIS_MODULE, |
| 1620 | .llseek = default_llseek, |
| 1621 | }; |
| 1622 | |
Vasanthakumar Thiagarajan | d999ba3 | 2011-08-26 13:06:31 +0530 | [diff] [blame] | 1623 | int ath6kl_debug_init(struct ath6kl *ar) |
| 1624 | { |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 1625 | skb_queue_head_init(&ar->debug.fwlog_queue); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 1626 | |
Kalle Valo | 939f1cc | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 1627 | /* |
| 1628 | * Actually we are lying here but don't know how to read the mask |
| 1629 | * value from the firmware. |
| 1630 | */ |
| 1631 | ar->debug.fwlog_mask = 0; |
| 1632 | |
Vasanthakumar Thiagarajan | d999ba3 | 2011-08-26 13:06:31 +0530 | [diff] [blame] | 1633 | ar->debugfs_phy = debugfs_create_dir("ath6kl", |
Vasanthakumar Thiagarajan | be98e3a | 2011-10-25 19:33:57 +0530 | [diff] [blame] | 1634 | ar->wiphy->debugfsdir); |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 1635 | if (!ar->debugfs_phy) |
Vasanthakumar Thiagarajan | d999ba3 | 2011-08-26 13:06:31 +0530 | [diff] [blame] | 1636 | return -ENOMEM; |
| 1637 | |
Vasanthakumar Thiagarajan | 03f68a9 | 2011-08-26 13:06:32 +0530 | [diff] [blame] | 1638 | debugfs_create_file("tgt_stats", S_IRUSR, ar->debugfs_phy, ar, |
| 1639 | &fops_tgt_stats); |
| 1640 | |
Vasanthakumar Thiagarajan | 78fc485 | 2011-08-26 13:06:33 +0530 | [diff] [blame] | 1641 | debugfs_create_file("credit_dist_stats", S_IRUSR, ar->debugfs_phy, ar, |
| 1642 | &fops_credit_dist_stats); |
| 1643 | |
Jouni Malinen | e809128 | 2011-10-11 17:31:53 +0300 | [diff] [blame] | 1644 | debugfs_create_file("endpoint_stats", S_IRUSR | S_IWUSR, |
| 1645 | ar->debugfs_phy, ar, &fops_endpoint_stats); |
| 1646 | |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 1647 | debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar, |
| 1648 | &fops_fwlog); |
| 1649 | |
Kalle Valo | 939f1cc | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 1650 | debugfs_create_file("fwlog_mask", S_IRUSR | S_IWUSR, ar->debugfs_phy, |
| 1651 | ar, &fops_fwlog_mask); |
| 1652 | |
Vasanthakumar Thiagarajan | 91d57de | 2011-09-02 10:40:06 +0300 | [diff] [blame] | 1653 | debugfs_create_file("reg_addr", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar, |
| 1654 | &fops_diag_reg_read); |
| 1655 | |
| 1656 | debugfs_create_file("reg_dump", S_IRUSR, ar->debugfs_phy, ar, |
| 1657 | &fops_reg_dump); |
| 1658 | |
Vivek Natarajan | e509044 | 2011-08-31 15:02:19 +0530 | [diff] [blame] | 1659 | debugfs_create_file("lrssi_roam_threshold", S_IRUSR | S_IWUSR, |
| 1660 | ar->debugfs_phy, ar, &fops_lrssi_roam_threshold); |
Vasanthakumar Thiagarajan | 252c068 | 2011-09-05 11:19:46 +0300 | [diff] [blame] | 1661 | |
| 1662 | debugfs_create_file("reg_write", S_IRUSR | S_IWUSR, |
| 1663 | ar->debugfs_phy, ar, &fops_diag_reg_write); |
| 1664 | |
Kalle Valo | 9a73083 | 2011-09-27 23:33:28 +0300 | [diff] [blame] | 1665 | debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar, |
| 1666 | &fops_war_stats); |
| 1667 | |
Jouni Malinen | 4b28a80 | 2011-10-11 17:31:54 +0300 | [diff] [blame] | 1668 | debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar, |
| 1669 | &fops_roam_table); |
| 1670 | |
Jouni Malinen | 1261875 | 2011-10-11 17:31:55 +0300 | [diff] [blame] | 1671 | debugfs_create_file("force_roam", S_IWUSR, ar->debugfs_phy, ar, |
| 1672 | &fops_force_roam); |
| 1673 | |
| 1674 | debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar, |
| 1675 | &fops_roam_mode); |
| 1676 | |
Jouni Malinen | ff0b007 | 2011-10-11 17:31:56 +0300 | [diff] [blame] | 1677 | debugfs_create_file("keepalive", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar, |
| 1678 | &fops_keepalive); |
| 1679 | |
| 1680 | debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR, |
| 1681 | ar->debugfs_phy, ar, &fops_disconnect_timeout); |
| 1682 | |
Rishi Panjwani | 8fffd9e | 2011-10-14 17:48:07 -0700 | [diff] [blame] | 1683 | debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar, |
| 1684 | &fops_create_qos); |
| 1685 | |
| 1686 | debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar, |
| 1687 | &fops_delete_qos); |
| 1688 | |
Rishi Panjwani | 116b3a2 | 2011-10-18 17:20:06 -0700 | [diff] [blame] | 1689 | debugfs_create_file("bgscan_interval", S_IWUSR, |
| 1690 | ar->debugfs_phy, ar, &fops_bgscan_int); |
| 1691 | |
Sujith Manoharan | 8232736 | 2012-01-10 09:54:10 +0530 | [diff] [blame] | 1692 | debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR, |
| 1693 | ar->debugfs_phy, ar, &fops_listen_int); |
| 1694 | |
Rishi Panjwani | a24fc7c | 2011-10-25 19:52:41 -0700 | [diff] [blame] | 1695 | debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar, |
| 1696 | &fops_power_params); |
| 1697 | |
Vasanthakumar Thiagarajan | d999ba3 | 2011-08-26 13:06:31 +0530 | [diff] [blame] | 1698 | return 0; |
| 1699 | } |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 1700 | |
| 1701 | void ath6kl_debug_cleanup(struct ath6kl *ar) |
| 1702 | { |
Kalle Valo | 9b9a4f2 | 2012-02-06 08:23:27 +0200 | [diff] [blame^] | 1703 | skb_queue_purge(&ar->debug.fwlog_queue); |
Jouni Malinen | 4b28a80 | 2011-10-11 17:31:54 +0300 | [diff] [blame] | 1704 | kfree(ar->debug.roam_tbl); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 1705 | } |
| 1706 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1707 | #endif |