2 * Copyright (c) 2008-2011 Atheros Communications Inc.
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.
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.
17 #include <linux/slab.h>
18 #include <linux/vmalloc.h>
19 #include <linux/export.h>
20 #include <asm/unaligned.h>
24 #define REG_WRITE_D(_ah, _reg, _val) \
25 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
26 #define REG_READ_D(_ah, _reg) \
27 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
29 void ath9k_debug_sync_cause(struct ath_softc
*sc
, u32 sync_cause
)
32 sc
->debug
.stats
.istats
.sync_cause_all
++;
33 if (sync_cause
& AR_INTR_SYNC_RTC_IRQ
)
34 sc
->debug
.stats
.istats
.sync_rtc_irq
++;
35 if (sync_cause
& AR_INTR_SYNC_MAC_IRQ
)
36 sc
->debug
.stats
.istats
.sync_mac_irq
++;
37 if (sync_cause
& AR_INTR_SYNC_EEPROM_ILLEGAL_ACCESS
)
38 sc
->debug
.stats
.istats
.eeprom_illegal_access
++;
39 if (sync_cause
& AR_INTR_SYNC_APB_TIMEOUT
)
40 sc
->debug
.stats
.istats
.apb_timeout
++;
41 if (sync_cause
& AR_INTR_SYNC_PCI_MODE_CONFLICT
)
42 sc
->debug
.stats
.istats
.pci_mode_conflict
++;
43 if (sync_cause
& AR_INTR_SYNC_HOST1_FATAL
)
44 sc
->debug
.stats
.istats
.host1_fatal
++;
45 if (sync_cause
& AR_INTR_SYNC_HOST1_PERR
)
46 sc
->debug
.stats
.istats
.host1_perr
++;
47 if (sync_cause
& AR_INTR_SYNC_TRCV_FIFO_PERR
)
48 sc
->debug
.stats
.istats
.trcv_fifo_perr
++;
49 if (sync_cause
& AR_INTR_SYNC_RADM_CPL_EP
)
50 sc
->debug
.stats
.istats
.radm_cpl_ep
++;
51 if (sync_cause
& AR_INTR_SYNC_RADM_CPL_DLLP_ABORT
)
52 sc
->debug
.stats
.istats
.radm_cpl_dllp_abort
++;
53 if (sync_cause
& AR_INTR_SYNC_RADM_CPL_TLP_ABORT
)
54 sc
->debug
.stats
.istats
.radm_cpl_tlp_abort
++;
55 if (sync_cause
& AR_INTR_SYNC_RADM_CPL_ECRC_ERR
)
56 sc
->debug
.stats
.istats
.radm_cpl_ecrc_err
++;
57 if (sync_cause
& AR_INTR_SYNC_RADM_CPL_TIMEOUT
)
58 sc
->debug
.stats
.istats
.radm_cpl_timeout
++;
59 if (sync_cause
& AR_INTR_SYNC_LOCAL_TIMEOUT
)
60 sc
->debug
.stats
.istats
.local_timeout
++;
61 if (sync_cause
& AR_INTR_SYNC_PM_ACCESS
)
62 sc
->debug
.stats
.istats
.pm_access
++;
63 if (sync_cause
& AR_INTR_SYNC_MAC_AWAKE
)
64 sc
->debug
.stats
.istats
.mac_awake
++;
65 if (sync_cause
& AR_INTR_SYNC_MAC_ASLEEP
)
66 sc
->debug
.stats
.istats
.mac_asleep
++;
67 if (sync_cause
& AR_INTR_SYNC_MAC_SLEEP_ACCESS
)
68 sc
->debug
.stats
.istats
.mac_sleep_access
++;
71 static ssize_t
ath9k_debugfs_read_buf(struct file
*file
, char __user
*user_buf
,
72 size_t count
, loff_t
*ppos
)
74 u8
*buf
= file
->private_data
;
75 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, strlen(buf
));
78 static int ath9k_debugfs_release_buf(struct inode
*inode
, struct file
*file
)
80 vfree(file
->private_data
);
84 #ifdef CONFIG_ATH_DEBUG
86 static ssize_t
read_file_debug(struct file
*file
, char __user
*user_buf
,
87 size_t count
, loff_t
*ppos
)
89 struct ath_softc
*sc
= file
->private_data
;
90 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
94 len
= sprintf(buf
, "0x%08x\n", common
->debug_mask
);
95 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
98 static ssize_t
write_file_debug(struct file
*file
, const char __user
*user_buf
,
99 size_t count
, loff_t
*ppos
)
101 struct ath_softc
*sc
= file
->private_data
;
102 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
107 len
= min(count
, sizeof(buf
) - 1);
108 if (copy_from_user(buf
, user_buf
, len
))
112 if (kstrtoul(buf
, 0, &mask
))
115 common
->debug_mask
= mask
;
119 static const struct file_operations fops_debug
= {
120 .read
= read_file_debug
,
121 .write
= write_file_debug
,
123 .owner
= THIS_MODULE
,
124 .llseek
= default_llseek
,
129 #define DMA_BUF_LEN 1024
132 static ssize_t
read_file_ani(struct file
*file
, char __user
*user_buf
,
133 size_t count
, loff_t
*ppos
)
135 struct ath_softc
*sc
= file
->private_data
;
136 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
137 struct ath_hw
*ah
= sc
->sc_ah
;
138 unsigned int len
= 0, size
= 1024;
142 buf
= kzalloc(size
, GFP_KERNEL
);
146 if (common
->disable_ani
) {
147 len
+= scnprintf(buf
+ len
, size
- len
, "%s: %s\n",
152 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %s\n",
154 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
155 "ANI RESET", ah
->stats
.ast_ani_reset
);
156 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
157 "SPUR UP", ah
->stats
.ast_ani_spurup
);
158 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
159 "SPUR DOWN", ah
->stats
.ast_ani_spurup
);
160 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
161 "OFDM WS-DET ON", ah
->stats
.ast_ani_ofdmon
);
162 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
163 "OFDM WS-DET OFF", ah
->stats
.ast_ani_ofdmoff
);
164 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
165 "MRC-CCK ON", ah
->stats
.ast_ani_ccklow
);
166 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
167 "MRC-CCK OFF", ah
->stats
.ast_ani_cckhigh
);
168 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
169 "FIR-STEP UP", ah
->stats
.ast_ani_stepup
);
170 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
171 "FIR-STEP DOWN", ah
->stats
.ast_ani_stepdown
);
172 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
173 "INV LISTENTIME", ah
->stats
.ast_ani_lneg_or_lzero
);
174 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
175 "OFDM ERRORS", ah
->stats
.ast_ani_ofdmerrs
);
176 len
+= scnprintf(buf
+ len
, size
- len
, "%15s: %u\n",
177 "CCK ERRORS", ah
->stats
.ast_ani_cckerrs
);
182 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
188 static ssize_t
write_file_ani(struct file
*file
,
189 const char __user
*user_buf
,
190 size_t count
, loff_t
*ppos
)
192 struct ath_softc
*sc
= file
->private_data
;
193 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
198 len
= min(count
, sizeof(buf
) - 1);
199 if (copy_from_user(buf
, user_buf
, len
))
203 if (kstrtoul(buf
, 0, &ani
))
206 if (ani
< 0 || ani
> 1)
209 common
->disable_ani
= !ani
;
211 if (common
->disable_ani
) {
212 clear_bit(SC_OP_ANI_RUN
, &sc
->sc_flags
);
221 static const struct file_operations fops_ani
= {
222 .read
= read_file_ani
,
223 .write
= write_file_ani
,
225 .owner
= THIS_MODULE
,
226 .llseek
= default_llseek
,
229 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
231 static ssize_t
read_file_bt_ant_diversity(struct file
*file
,
232 char __user
*user_buf
,
233 size_t count
, loff_t
*ppos
)
235 struct ath_softc
*sc
= file
->private_data
;
236 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
240 len
= sprintf(buf
, "%d\n", common
->bt_ant_diversity
);
241 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
244 static ssize_t
write_file_bt_ant_diversity(struct file
*file
,
245 const char __user
*user_buf
,
246 size_t count
, loff_t
*ppos
)
248 struct ath_softc
*sc
= file
->private_data
;
249 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
250 struct ath9k_hw_capabilities
*pCap
= &sc
->sc_ah
->caps
;
251 unsigned long bt_ant_diversity
;
255 len
= min(count
, sizeof(buf
) - 1);
256 if (copy_from_user(buf
, user_buf
, len
))
259 if (!(pCap
->hw_caps
& ATH9K_HW_CAP_BT_ANT_DIV
))
263 if (kstrtoul(buf
, 0, &bt_ant_diversity
))
266 common
->bt_ant_diversity
= !!bt_ant_diversity
;
268 ath9k_hw_set_bt_ant_diversity(sc
->sc_ah
, common
->bt_ant_diversity
);
269 ath_dbg(common
, CONFIG
, "Enable WLAN/BT RX Antenna diversity: %d\n",
270 common
->bt_ant_diversity
);
271 ath9k_ps_restore(sc
);
276 static const struct file_operations fops_bt_ant_diversity
= {
277 .read
= read_file_bt_ant_diversity
,
278 .write
= write_file_bt_ant_diversity
,
280 .owner
= THIS_MODULE
,
281 .llseek
= default_llseek
,
286 void ath9k_debug_stat_ant(struct ath_softc
*sc
,
287 struct ath_hw_antcomb_conf
*div_ant_conf
,
288 int main_rssi_avg
, int alt_rssi_avg
)
290 struct ath_antenna_stats
*as_main
= &sc
->debug
.stats
.ant_stats
[ANT_MAIN
];
291 struct ath_antenna_stats
*as_alt
= &sc
->debug
.stats
.ant_stats
[ANT_ALT
];
293 as_main
->lna_attempt_cnt
[div_ant_conf
->main_lna_conf
]++;
294 as_alt
->lna_attempt_cnt
[div_ant_conf
->alt_lna_conf
]++;
296 as_main
->rssi_avg
= main_rssi_avg
;
297 as_alt
->rssi_avg
= alt_rssi_avg
;
300 static ssize_t
read_file_antenna_diversity(struct file
*file
,
301 char __user
*user_buf
,
302 size_t count
, loff_t
*ppos
)
304 struct ath_softc
*sc
= file
->private_data
;
305 struct ath_hw
*ah
= sc
->sc_ah
;
306 struct ath9k_hw_capabilities
*pCap
= &ah
->caps
;
307 struct ath_antenna_stats
*as_main
= &sc
->debug
.stats
.ant_stats
[ANT_MAIN
];
308 struct ath_antenna_stats
*as_alt
= &sc
->debug
.stats
.ant_stats
[ANT_ALT
];
309 struct ath_hw_antcomb_conf div_ant_conf
;
310 unsigned int len
= 0, size
= 1024;
313 char *lna_conf_str
[4] = {"LNA1_MINUS_LNA2",
318 buf
= kzalloc(size
, GFP_KERNEL
);
322 if (!(pCap
->hw_caps
& ATH9K_HW_CAP_ANT_DIV_COMB
)) {
323 len
+= scnprintf(buf
+ len
, size
- len
, "%s\n",
324 "Antenna Diversity Combining is disabled");
329 ath9k_hw_antdiv_comb_conf_get(ah
, &div_ant_conf
);
330 len
+= scnprintf(buf
+ len
, size
- len
, "Current MAIN config : %s\n",
331 lna_conf_str
[div_ant_conf
.main_lna_conf
]);
332 len
+= scnprintf(buf
+ len
, size
- len
, "Current ALT config : %s\n",
333 lna_conf_str
[div_ant_conf
.alt_lna_conf
]);
334 len
+= scnprintf(buf
+ len
, size
- len
, "Average MAIN RSSI : %d\n",
336 len
+= scnprintf(buf
+ len
, size
- len
, "Average ALT RSSI : %d\n\n",
338 ath9k_ps_restore(sc
);
340 len
+= scnprintf(buf
+ len
, size
- len
, "Packet Receive Cnt:\n");
341 len
+= scnprintf(buf
+ len
, size
- len
, "-------------------\n");
343 len
+= scnprintf(buf
+ len
, size
- len
, "%30s%15s\n",
345 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
349 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
351 as_main
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA1
],
352 as_alt
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA1
]);
353 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
355 as_main
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA2
],
356 as_alt
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA2
]);
357 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
359 as_main
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2
],
360 as_alt
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2
]);
361 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
363 as_main
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2
],
364 as_alt
->lna_recv_cnt
[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2
]);
366 len
+= scnprintf(buf
+ len
, size
- len
, "\nLNA Config Attempts:\n");
367 len
+= scnprintf(buf
+ len
, size
- len
, "--------------------\n");
369 len
+= scnprintf(buf
+ len
, size
- len
, "%30s%15s\n",
371 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
373 as_main
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA1
],
374 as_alt
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA1
]);
375 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
377 as_main
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA2
],
378 as_alt
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA2
]);
379 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
381 as_main
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2
],
382 as_alt
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2
]);
383 len
+= scnprintf(buf
+ len
, size
- len
, "%-14s:%15d%15d\n",
385 as_main
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2
],
386 as_alt
->lna_attempt_cnt
[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2
]);
392 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
398 static const struct file_operations fops_antenna_diversity
= {
399 .read
= read_file_antenna_diversity
,
401 .owner
= THIS_MODULE
,
402 .llseek
= default_llseek
,
405 static ssize_t
read_file_dma(struct file
*file
, char __user
*user_buf
,
406 size_t count
, loff_t
*ppos
)
408 struct ath_softc
*sc
= file
->private_data
;
409 struct ath_hw
*ah
= sc
->sc_ah
;
412 unsigned int len
= 0;
413 u32 val
[ATH9K_NUM_DMA_DEBUG_REGS
];
414 int i
, qcuOffset
= 0, dcuOffset
= 0;
415 u32
*qcuBase
= &val
[0], *dcuBase
= &val
[4];
417 buf
= kmalloc(DMA_BUF_LEN
, GFP_KERNEL
);
423 REG_WRITE_D(ah
, AR_MACMISC
,
424 ((AR_MACMISC_DMA_OBS_LINE_8
<< AR_MACMISC_DMA_OBS_S
) |
425 (AR_MACMISC_MISC_OBS_BUS_1
<<
426 AR_MACMISC_MISC_OBS_BUS_MSB_S
)));
428 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
429 "Raw DMA Debug values:\n");
431 for (i
= 0; i
< ATH9K_NUM_DMA_DEBUG_REGS
; i
++) {
433 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
435 val
[i
] = REG_READ_D(ah
, AR_DMADBG_0
+ (i
* sizeof(u32
)));
436 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
, "%d: %08x ",
440 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n\n");
441 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
442 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
444 for (i
= 0; i
< ATH9K_NUM_QUEUES
; i
++, qcuOffset
+= 4, dcuOffset
+= 5) {
455 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
456 "%2d %2x %1x %2x %2x\n",
457 i
, (*qcuBase
& (0x7 << qcuOffset
)) >> qcuOffset
,
458 (*qcuBase
& (0x8 << qcuOffset
)) >> (qcuOffset
+ 3),
459 val
[2] & (0x7 << (i
* 3)) >> (i
* 3),
460 (*dcuBase
& (0x1f << dcuOffset
)) >> dcuOffset
);
463 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
465 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
466 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
467 (val
[3] & 0x003c0000) >> 18, (val
[3] & 0x03c00000) >> 22);
468 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
469 "qcu_complete state: %2x dcu_complete state: %2x\n",
470 (val
[3] & 0x1c000000) >> 26, (val
[6] & 0x3));
471 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
472 "dcu_arb state: %2x dcu_fp state: %2x\n",
473 (val
[5] & 0x06000000) >> 25, (val
[5] & 0x38000000) >> 27);
474 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
475 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
476 (val
[6] & 0x000003fc) >> 2, (val
[6] & 0x00000400) >> 10);
477 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
478 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
479 (val
[6] & 0x00000800) >> 11, (val
[6] & 0x00001000) >> 12);
480 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
481 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
482 (val
[6] & 0x0001e000) >> 13, (val
[6] & 0x001e0000) >> 17);
484 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
, "pcu observe: 0x%x\n",
485 REG_READ_D(ah
, AR_OBS_BUS_1
));
486 len
+= scnprintf(buf
+ len
, DMA_BUF_LEN
- len
,
487 "AR_CR: 0x%x\n", REG_READ_D(ah
, AR_CR
));
489 ath9k_ps_restore(sc
);
491 if (len
> DMA_BUF_LEN
)
494 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
499 static const struct file_operations fops_dma
= {
500 .read
= read_file_dma
,
502 .owner
= THIS_MODULE
,
503 .llseek
= default_llseek
,
507 void ath_debug_stat_interrupt(struct ath_softc
*sc
, enum ath9k_int status
)
510 sc
->debug
.stats
.istats
.total
++;
511 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
512 if (status
& ATH9K_INT_RXLP
)
513 sc
->debug
.stats
.istats
.rxlp
++;
514 if (status
& ATH9K_INT_RXHP
)
515 sc
->debug
.stats
.istats
.rxhp
++;
516 if (status
& ATH9K_INT_BB_WATCHDOG
)
517 sc
->debug
.stats
.istats
.bb_watchdog
++;
519 if (status
& ATH9K_INT_RX
)
520 sc
->debug
.stats
.istats
.rxok
++;
522 if (status
& ATH9K_INT_RXEOL
)
523 sc
->debug
.stats
.istats
.rxeol
++;
524 if (status
& ATH9K_INT_RXORN
)
525 sc
->debug
.stats
.istats
.rxorn
++;
526 if (status
& ATH9K_INT_TX
)
527 sc
->debug
.stats
.istats
.txok
++;
528 if (status
& ATH9K_INT_TXURN
)
529 sc
->debug
.stats
.istats
.txurn
++;
530 if (status
& ATH9K_INT_RXPHY
)
531 sc
->debug
.stats
.istats
.rxphyerr
++;
532 if (status
& ATH9K_INT_RXKCM
)
533 sc
->debug
.stats
.istats
.rx_keycache_miss
++;
534 if (status
& ATH9K_INT_SWBA
)
535 sc
->debug
.stats
.istats
.swba
++;
536 if (status
& ATH9K_INT_BMISS
)
537 sc
->debug
.stats
.istats
.bmiss
++;
538 if (status
& ATH9K_INT_BNR
)
539 sc
->debug
.stats
.istats
.bnr
++;
540 if (status
& ATH9K_INT_CST
)
541 sc
->debug
.stats
.istats
.cst
++;
542 if (status
& ATH9K_INT_GTT
)
543 sc
->debug
.stats
.istats
.gtt
++;
544 if (status
& ATH9K_INT_TIM
)
545 sc
->debug
.stats
.istats
.tim
++;
546 if (status
& ATH9K_INT_CABEND
)
547 sc
->debug
.stats
.istats
.cabend
++;
548 if (status
& ATH9K_INT_DTIMSYNC
)
549 sc
->debug
.stats
.istats
.dtimsync
++;
550 if (status
& ATH9K_INT_DTIM
)
551 sc
->debug
.stats
.istats
.dtim
++;
552 if (status
& ATH9K_INT_TSFOOR
)
553 sc
->debug
.stats
.istats
.tsfoor
++;
554 if (status
& ATH9K_INT_MCI
)
555 sc
->debug
.stats
.istats
.mci
++;
556 if (status
& ATH9K_INT_GENTIMER
)
557 sc
->debug
.stats
.istats
.gen_timer
++;
560 static ssize_t
read_file_interrupt(struct file
*file
, char __user
*user_buf
,
561 size_t count
, loff_t
*ppos
)
563 struct ath_softc
*sc
= file
->private_data
;
564 unsigned int len
= 0;
567 char *buf
= kmalloc(mxlen
, GFP_KERNEL
);
571 #define PR_IS(a, s) \
573 len += scnprintf(buf + len, mxlen - len, \
575 sc->debug.stats.istats.s); \
578 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
581 PR_IS("WATHDOG", bb_watchdog
);
585 PR_IS("RXEOL", rxeol
);
586 PR_IS("RXORN", rxorn
);
588 PR_IS("TXURN", txurn
);
590 PR_IS("RXPHY", rxphyerr
);
591 PR_IS("RXKCM", rx_keycache_miss
);
593 PR_IS("BMISS", bmiss
);
598 PR_IS("CABEND", cabend
);
599 PR_IS("DTIMSYNC", dtimsync
);
601 PR_IS("TSFOOR", tsfoor
);
603 PR_IS("GENTIMER", gen_timer
);
604 PR_IS("TOTAL", total
);
606 len
+= scnprintf(buf
+ len
, mxlen
- len
,
607 "SYNC_CAUSE stats:\n");
609 PR_IS("Sync-All", sync_cause_all
);
610 PR_IS("RTC-IRQ", sync_rtc_irq
);
611 PR_IS("MAC-IRQ", sync_mac_irq
);
612 PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access
);
613 PR_IS("APB-Timeout", apb_timeout
);
614 PR_IS("PCI-Mode-Conflict", pci_mode_conflict
);
615 PR_IS("HOST1-Fatal", host1_fatal
);
616 PR_IS("HOST1-Perr", host1_perr
);
617 PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr
);
618 PR_IS("RADM-CPL-EP", radm_cpl_ep
);
619 PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort
);
620 PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort
);
621 PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err
);
622 PR_IS("RADM-CPL-Timeout", radm_cpl_timeout
);
623 PR_IS("Local-Bus-Timeout", local_timeout
);
624 PR_IS("PM-Access", pm_access
);
625 PR_IS("MAC-Awake", mac_awake
);
626 PR_IS("MAC-Asleep", mac_asleep
);
627 PR_IS("MAC-Sleep-Access", mac_sleep_access
);
632 rv
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
637 static const struct file_operations fops_interrupt
= {
638 .read
= read_file_interrupt
,
640 .owner
= THIS_MODULE
,
641 .llseek
= default_llseek
,
644 static ssize_t
read_file_xmit(struct file
*file
, char __user
*user_buf
,
645 size_t count
, loff_t
*ppos
)
647 struct ath_softc
*sc
= file
->private_data
;
649 unsigned int len
= 0, size
= 2048;
652 buf
= kzalloc(size
, GFP_KERNEL
);
656 len
+= sprintf(buf
, "%30s %10s%10s%10s\n\n",
657 "BE", "BK", "VI", "VO");
659 PR("MPDUs Queued: ", queued
);
660 PR("MPDUs Completed: ", completed
);
661 PR("MPDUs XRetried: ", xretries
);
662 PR("Aggregates: ", a_aggr
);
663 PR("AMPDUs Queued HW:", a_queued_hw
);
664 PR("AMPDUs Queued SW:", a_queued_sw
);
665 PR("AMPDUs Completed:", a_completed
);
666 PR("AMPDUs Retried: ", a_retries
);
667 PR("AMPDUs XRetried: ", a_xretries
);
668 PR("TXERR Filtered: ", txerr_filtered
);
669 PR("FIFO Underrun: ", fifo_underrun
);
670 PR("TXOP Exceeded: ", xtxop
);
671 PR("TXTIMER Expiry: ", timer_exp
);
672 PR("DESC CFG Error: ", desc_cfg_err
);
673 PR("DATA Underrun: ", data_underrun
);
674 PR("DELIM Underrun: ", delim_underrun
);
675 PR("TX-Pkts-All: ", tx_pkts_all
);
676 PR("TX-Bytes-All: ", tx_bytes_all
);
677 PR("HW-put-tx-buf: ", puttxbuf
);
678 PR("HW-tx-start: ", txstart
);
679 PR("HW-tx-proc-desc: ", txprocdesc
);
680 PR("TX-Failed: ", txfailed
);
685 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
691 static ssize_t
print_queue(struct ath_softc
*sc
, struct ath_txq
*txq
,
692 char *buf
, ssize_t size
)
696 ath_txq_lock(sc
, txq
);
698 len
+= scnprintf(buf
+ len
, size
- len
, "%s: %d ",
699 "qnum", txq
->axq_qnum
);
700 len
+= scnprintf(buf
+ len
, size
- len
, "%s: %2d ",
701 "qdepth", txq
->axq_depth
);
702 len
+= scnprintf(buf
+ len
, size
- len
, "%s: %2d ",
703 "ampdu-depth", txq
->axq_ampdu_depth
);
704 len
+= scnprintf(buf
+ len
, size
- len
, "%s: %3d ",
705 "pending", txq
->pending_frames
);
706 len
+= scnprintf(buf
+ len
, size
- len
, "%s: %d\n",
707 "stopped", txq
->stopped
);
709 ath_txq_unlock(sc
, txq
);
713 static ssize_t
read_file_queues(struct file
*file
, char __user
*user_buf
,
714 size_t count
, loff_t
*ppos
)
716 struct ath_softc
*sc
= file
->private_data
;
719 unsigned int len
= 0, size
= 1024;
722 char *qname
[4] = {"VO", "VI", "BE", "BK"};
724 buf
= kzalloc(size
, GFP_KERNEL
);
728 for (i
= 0; i
< IEEE80211_NUM_ACS
; i
++) {
729 txq
= sc
->tx
.txq_map
[i
];
730 len
+= scnprintf(buf
+ len
, size
- len
, "(%s): ", qname
[i
]);
731 len
+= print_queue(sc
, txq
, buf
+ len
, size
- len
);
734 len
+= scnprintf(buf
+ len
, size
- len
, "(CAB): ");
735 len
+= print_queue(sc
, sc
->beacon
.cabq
, buf
+ len
, size
- len
);
740 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
746 static ssize_t
read_file_misc(struct file
*file
, char __user
*user_buf
,
747 size_t count
, loff_t
*ppos
)
749 struct ath_softc
*sc
= file
->private_data
;
750 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
751 struct ieee80211_hw
*hw
= sc
->hw
;
752 struct ath9k_vif_iter_data iter_data
;
754 unsigned int len
= 0;
759 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
760 "BSSID: %pM\n", common
->curbssid
);
761 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
762 "BSSID-MASK: %pM\n", common
->bssidmask
);
763 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
765 ath_opmode_to_string(sc
->sc_ah
->opmode
));
768 rxfilter
= ath9k_hw_getrxfilter(sc
->sc_ah
);
769 ath9k_ps_restore(sc
);
771 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
772 "RXFILTER: 0x%x", rxfilter
);
774 if (rxfilter
& ATH9K_RX_FILTER_UCAST
)
775 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " UCAST");
776 if (rxfilter
& ATH9K_RX_FILTER_MCAST
)
777 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST");
778 if (rxfilter
& ATH9K_RX_FILTER_BCAST
)
779 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " BCAST");
780 if (rxfilter
& ATH9K_RX_FILTER_CONTROL
)
781 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " CONTROL");
782 if (rxfilter
& ATH9K_RX_FILTER_BEACON
)
783 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " BEACON");
784 if (rxfilter
& ATH9K_RX_FILTER_PROM
)
785 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " PROM");
786 if (rxfilter
& ATH9K_RX_FILTER_PROBEREQ
)
787 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " PROBEREQ");
788 if (rxfilter
& ATH9K_RX_FILTER_PHYERR
)
789 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " PHYERR");
790 if (rxfilter
& ATH9K_RX_FILTER_MYBEACON
)
791 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " MYBEACON");
792 if (rxfilter
& ATH9K_RX_FILTER_COMP_BAR
)
793 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " COMP_BAR");
794 if (rxfilter
& ATH9K_RX_FILTER_PSPOLL
)
795 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " PSPOLL");
796 if (rxfilter
& ATH9K_RX_FILTER_PHYRADAR
)
797 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " PHYRADAR");
798 if (rxfilter
& ATH9K_RX_FILTER_MCAST_BCAST_ALL
)
799 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST_BCAST_ALL");
800 if (rxfilter
& ATH9K_RX_FILTER_CONTROL_WRAPPER
)
801 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " CONTROL_WRAPPER");
803 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
805 reg
= sc
->sc_ah
->imask
;
807 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
808 "INTERRUPT-MASK: 0x%x", reg
);
810 if (reg
& ATH9K_INT_SWBA
)
811 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " SWBA");
812 if (reg
& ATH9K_INT_BMISS
)
813 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " BMISS");
814 if (reg
& ATH9K_INT_CST
)
815 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " CST");
816 if (reg
& ATH9K_INT_RX
)
817 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " RX");
818 if (reg
& ATH9K_INT_RXHP
)
819 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " RXHP");
820 if (reg
& ATH9K_INT_RXLP
)
821 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " RXLP");
822 if (reg
& ATH9K_INT_BB_WATCHDOG
)
823 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, " BB_WATCHDOG");
825 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
827 ath9k_calculate_iter_data(hw
, NULL
, &iter_data
);
829 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
830 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
831 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
832 iter_data
.naps
, iter_data
.nstations
, iter_data
.nmeshes
,
833 iter_data
.nwds
, iter_data
.nadhocs
,
834 sc
->nvifs
, sc
->nbcnvifs
);
836 if (len
> sizeof(buf
))
839 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
843 static ssize_t
read_file_reset(struct file
*file
, char __user
*user_buf
,
844 size_t count
, loff_t
*ppos
)
846 struct ath_softc
*sc
= file
->private_data
;
848 unsigned int len
= 0;
850 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
851 "%17s: %2d\n", "Baseband Hang",
852 sc
->debug
.stats
.reset
[RESET_TYPE_BB_HANG
]);
853 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
854 "%17s: %2d\n", "Baseband Watchdog",
855 sc
->debug
.stats
.reset
[RESET_TYPE_BB_WATCHDOG
]);
856 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
857 "%17s: %2d\n", "Fatal HW Error",
858 sc
->debug
.stats
.reset
[RESET_TYPE_FATAL_INT
]);
859 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
860 "%17s: %2d\n", "TX HW error",
861 sc
->debug
.stats
.reset
[RESET_TYPE_TX_ERROR
]);
862 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
863 "%17s: %2d\n", "TX Path Hang",
864 sc
->debug
.stats
.reset
[RESET_TYPE_TX_HANG
]);
865 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
866 "%17s: %2d\n", "PLL RX Hang",
867 sc
->debug
.stats
.reset
[RESET_TYPE_PLL_HANG
]);
868 len
+= scnprintf(buf
+ len
, sizeof(buf
) - len
,
869 "%17s: %2d\n", "MCI Reset",
870 sc
->debug
.stats
.reset
[RESET_TYPE_MCI
]);
872 if (len
> sizeof(buf
))
875 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
878 void ath_debug_stat_tx(struct ath_softc
*sc
, struct ath_buf
*bf
,
879 struct ath_tx_status
*ts
, struct ath_txq
*txq
,
882 int qnum
= txq
->axq_qnum
;
884 TX_STAT_INC(qnum
, tx_pkts_all
);
885 sc
->debug
.stats
.txstats
[qnum
].tx_bytes_all
+= bf
->bf_mpdu
->len
;
887 if (bf_isampdu(bf
)) {
888 if (flags
& ATH_TX_ERROR
)
889 TX_STAT_INC(qnum
, a_xretries
);
891 TX_STAT_INC(qnum
, a_completed
);
893 if (ts
->ts_status
& ATH9K_TXERR_XRETRY
)
894 TX_STAT_INC(qnum
, xretries
);
896 TX_STAT_INC(qnum
, completed
);
899 if (ts
->ts_status
& ATH9K_TXERR_FILT
)
900 TX_STAT_INC(qnum
, txerr_filtered
);
901 if (ts
->ts_status
& ATH9K_TXERR_FIFO
)
902 TX_STAT_INC(qnum
, fifo_underrun
);
903 if (ts
->ts_status
& ATH9K_TXERR_XTXOP
)
904 TX_STAT_INC(qnum
, xtxop
);
905 if (ts
->ts_status
& ATH9K_TXERR_TIMER_EXPIRED
)
906 TX_STAT_INC(qnum
, timer_exp
);
907 if (ts
->ts_flags
& ATH9K_TX_DESC_CFG_ERR
)
908 TX_STAT_INC(qnum
, desc_cfg_err
);
909 if (ts
->ts_flags
& ATH9K_TX_DATA_UNDERRUN
)
910 TX_STAT_INC(qnum
, data_underrun
);
911 if (ts
->ts_flags
& ATH9K_TX_DELIM_UNDERRUN
)
912 TX_STAT_INC(qnum
, delim_underrun
);
915 static const struct file_operations fops_xmit
= {
916 .read
= read_file_xmit
,
918 .owner
= THIS_MODULE
,
919 .llseek
= default_llseek
,
922 static const struct file_operations fops_queues
= {
923 .read
= read_file_queues
,
925 .owner
= THIS_MODULE
,
926 .llseek
= default_llseek
,
929 static const struct file_operations fops_misc
= {
930 .read
= read_file_misc
,
932 .owner
= THIS_MODULE
,
933 .llseek
= default_llseek
,
936 static const struct file_operations fops_reset
= {
937 .read
= read_file_reset
,
939 .owner
= THIS_MODULE
,
940 .llseek
= default_llseek
,
943 static ssize_t
read_file_recv(struct file
*file
, char __user
*user_buf
,
944 size_t count
, loff_t
*ppos
)
946 #define PHY_ERR(s, p) \
947 len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \
948 sc->debug.stats.rxstats.phy_err_stats[p]);
950 #define RXS_ERR(s, e) \
952 len += scnprintf(buf + len, size - len, \
953 "%22s : %10u\n", s, \
954 sc->debug.stats.rxstats.e);\
957 struct ath_softc
*sc
= file
->private_data
;
959 unsigned int len
= 0, size
= 1600;
962 buf
= kzalloc(size
, GFP_KERNEL
);
966 RXS_ERR("CRC ERR", crc_err
);
967 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err
);
968 RXS_ERR("PHY ERR", phy_err
);
969 RXS_ERR("MIC ERR", mic_err
);
970 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err
);
971 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err
);
972 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err
);
973 RXS_ERR("RX-LENGTH-ERR", rx_len_err
);
974 RXS_ERR("RX-OOM-ERR", rx_oom_err
);
975 RXS_ERR("RX-RATE-ERR", rx_rate_err
);
976 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err
);
978 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN
);
979 PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING
);
980 PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY
);
981 PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE
);
982 PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH
);
983 PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR
);
984 PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE
);
985 PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR
);
986 PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING
);
987 PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY
);
988 PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL
);
989 PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL
);
990 PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP
);
991 PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE
);
992 PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART
);
993 PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT
);
994 PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING
);
995 PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC
);
996 PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL
);
997 PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE
);
998 PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART
);
999 PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL
);
1000 PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP
);
1001 PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR
);
1002 PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL
);
1003 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL
);
1005 RXS_ERR("RX-Pkts-All", rx_pkts_all
);
1006 RXS_ERR("RX-Bytes-All", rx_bytes_all
);
1007 RXS_ERR("RX-Beacons", rx_beacons
);
1008 RXS_ERR("RX-Frags", rx_frags
);
1009 RXS_ERR("RX-Spectral", rx_spectral
);
1014 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1023 void ath_debug_stat_rx(struct ath_softc
*sc
, struct ath_rx_status
*rs
)
1025 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
1027 RX_STAT_INC(rx_pkts_all
);
1028 sc
->debug
.stats
.rxstats
.rx_bytes_all
+= rs
->rs_datalen
;
1030 if (rs
->rs_status
& ATH9K_RXERR_CRC
)
1031 RX_STAT_INC(crc_err
);
1032 if (rs
->rs_status
& ATH9K_RXERR_DECRYPT
)
1033 RX_STAT_INC(decrypt_crc_err
);
1034 if (rs
->rs_status
& ATH9K_RXERR_MIC
)
1035 RX_STAT_INC(mic_err
);
1036 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_PRE
)
1037 RX_STAT_INC(pre_delim_crc_err
);
1038 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_POST
)
1039 RX_STAT_INC(post_delim_crc_err
);
1040 if (rs
->rs_status
& ATH9K_RX_DECRYPT_BUSY
)
1041 RX_STAT_INC(decrypt_busy_err
);
1043 if (rs
->rs_status
& ATH9K_RXERR_PHY
) {
1044 RX_STAT_INC(phy_err
);
1045 if (rs
->rs_phyerr
< ATH9K_PHYERR_MAX
)
1046 RX_PHY_ERR_INC(rs
->rs_phyerr
);
1049 #undef RX_PHY_ERR_INC
1052 static const struct file_operations fops_recv
= {
1053 .read
= read_file_recv
,
1054 .open
= simple_open
,
1055 .owner
= THIS_MODULE
,
1056 .llseek
= default_llseek
,
1059 static ssize_t
read_file_regidx(struct file
*file
, char __user
*user_buf
,
1060 size_t count
, loff_t
*ppos
)
1062 struct ath_softc
*sc
= file
->private_data
;
1066 len
= sprintf(buf
, "0x%08x\n", sc
->debug
.regidx
);
1067 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1070 static ssize_t
write_file_regidx(struct file
*file
, const char __user
*user_buf
,
1071 size_t count
, loff_t
*ppos
)
1073 struct ath_softc
*sc
= file
->private_data
;
1074 unsigned long regidx
;
1078 len
= min(count
, sizeof(buf
) - 1);
1079 if (copy_from_user(buf
, user_buf
, len
))
1083 if (kstrtoul(buf
, 0, ®idx
))
1086 sc
->debug
.regidx
= regidx
;
1090 static const struct file_operations fops_regidx
= {
1091 .read
= read_file_regidx
,
1092 .write
= write_file_regidx
,
1093 .open
= simple_open
,
1094 .owner
= THIS_MODULE
,
1095 .llseek
= default_llseek
,
1098 static ssize_t
read_file_regval(struct file
*file
, char __user
*user_buf
,
1099 size_t count
, loff_t
*ppos
)
1101 struct ath_softc
*sc
= file
->private_data
;
1102 struct ath_hw
*ah
= sc
->sc_ah
;
1107 ath9k_ps_wakeup(sc
);
1108 regval
= REG_READ_D(ah
, sc
->debug
.regidx
);
1109 ath9k_ps_restore(sc
);
1110 len
= sprintf(buf
, "0x%08x\n", regval
);
1111 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1114 static ssize_t
write_file_regval(struct file
*file
, const char __user
*user_buf
,
1115 size_t count
, loff_t
*ppos
)
1117 struct ath_softc
*sc
= file
->private_data
;
1118 struct ath_hw
*ah
= sc
->sc_ah
;
1119 unsigned long regval
;
1123 len
= min(count
, sizeof(buf
) - 1);
1124 if (copy_from_user(buf
, user_buf
, len
))
1128 if (kstrtoul(buf
, 0, ®val
))
1131 ath9k_ps_wakeup(sc
);
1132 REG_WRITE_D(ah
, sc
->debug
.regidx
, regval
);
1133 ath9k_ps_restore(sc
);
1137 static const struct file_operations fops_regval
= {
1138 .read
= read_file_regval
,
1139 .write
= write_file_regval
,
1140 .open
= simple_open
,
1141 .owner
= THIS_MODULE
,
1142 .llseek
= default_llseek
,
1145 #define REGDUMP_LINE_SIZE 20
1147 static int open_file_regdump(struct inode
*inode
, struct file
*file
)
1149 struct ath_softc
*sc
= inode
->i_private
;
1150 unsigned int len
= 0;
1153 unsigned long num_regs
, regdump_len
, max_reg_offset
;
1155 max_reg_offset
= AR_SREV_9300_20_OR_LATER(sc
->sc_ah
) ? 0x16bd4 : 0xb500;
1156 num_regs
= max_reg_offset
/ 4 + 1;
1157 regdump_len
= num_regs
* REGDUMP_LINE_SIZE
+ 1;
1158 buf
= vmalloc(regdump_len
);
1162 ath9k_ps_wakeup(sc
);
1163 for (i
= 0; i
< num_regs
; i
++)
1164 len
+= scnprintf(buf
+ len
, regdump_len
- len
,
1165 "0x%06x 0x%08x\n", i
<< 2, REG_READ(sc
->sc_ah
, i
<< 2));
1166 ath9k_ps_restore(sc
);
1168 file
->private_data
= buf
;
1173 static const struct file_operations fops_regdump
= {
1174 .open
= open_file_regdump
,
1175 .read
= ath9k_debugfs_read_buf
,
1176 .release
= ath9k_debugfs_release_buf
,
1177 .owner
= THIS_MODULE
,
1178 .llseek
= default_llseek
,/* read accesses f_pos */
1181 static ssize_t
read_file_dump_nfcal(struct file
*file
, char __user
*user_buf
,
1182 size_t count
, loff_t
*ppos
)
1184 struct ath_softc
*sc
= file
->private_data
;
1185 struct ath_hw
*ah
= sc
->sc_ah
;
1186 struct ath9k_nfcal_hist
*h
= sc
->caldata
.nfCalHist
;
1187 struct ath_common
*common
= ath9k_hw_common(ah
);
1188 struct ieee80211_conf
*conf
= &common
->hw
->conf
;
1189 u32 len
= 0, size
= 1500;
1193 u8 chainmask
= (ah
->rxchainmask
<< 3) | ah
->rxchainmask
;
1196 buf
= kzalloc(size
, GFP_KERNEL
);
1200 len
+= scnprintf(buf
+ len
, size
- len
,
1201 "Channel Noise Floor : %d\n", ah
->noise
);
1202 len
+= scnprintf(buf
+ len
, size
- len
,
1203 "Chain | privNF | # Readings | NF Readings\n");
1204 for (i
= 0; i
< NUM_NF_READINGS
; i
++) {
1205 if (!(chainmask
& (1 << i
)) ||
1206 ((i
>= AR5416_MAX_CHAINS
) && !conf_is_ht40(conf
)))
1209 nread
= AR_PHY_CCA_FILTERWINDOW_LENGTH
- h
[i
].invalidNFcount
;
1210 len
+= scnprintf(buf
+ len
, size
- len
, " %d\t %d\t %d\t\t",
1211 i
, h
[i
].privNF
, nread
);
1212 for (j
= 0; j
< nread
; j
++)
1213 len
+= scnprintf(buf
+ len
, size
- len
,
1214 " %d", h
[i
].nfCalBuffer
[j
]);
1215 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
1221 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1227 static const struct file_operations fops_dump_nfcal
= {
1228 .read
= read_file_dump_nfcal
,
1229 .open
= simple_open
,
1230 .owner
= THIS_MODULE
,
1231 .llseek
= default_llseek
,
1234 static ssize_t
read_file_base_eeprom(struct file
*file
, char __user
*user_buf
,
1235 size_t count
, loff_t
*ppos
)
1237 struct ath_softc
*sc
= file
->private_data
;
1238 struct ath_hw
*ah
= sc
->sc_ah
;
1239 u32 len
= 0, size
= 1500;
1243 buf
= kzalloc(size
, GFP_KERNEL
);
1247 len
= ah
->eep_ops
->dump_eeprom(ah
, true, buf
, len
, size
);
1249 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1255 static const struct file_operations fops_base_eeprom
= {
1256 .read
= read_file_base_eeprom
,
1257 .open
= simple_open
,
1258 .owner
= THIS_MODULE
,
1259 .llseek
= default_llseek
,
1262 static ssize_t
read_file_modal_eeprom(struct file
*file
, char __user
*user_buf
,
1263 size_t count
, loff_t
*ppos
)
1265 struct ath_softc
*sc
= file
->private_data
;
1266 struct ath_hw
*ah
= sc
->sc_ah
;
1267 u32 len
= 0, size
= 6000;
1271 buf
= kzalloc(size
, GFP_KERNEL
);
1275 len
= ah
->eep_ops
->dump_eeprom(ah
, false, buf
, len
, size
);
1277 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1283 static const struct file_operations fops_modal_eeprom
= {
1284 .read
= read_file_modal_eeprom
,
1285 .open
= simple_open
,
1286 .owner
= THIS_MODULE
,
1287 .llseek
= default_llseek
,
1290 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1291 static ssize_t
read_file_btcoex(struct file
*file
, char __user
*user_buf
,
1292 size_t count
, loff_t
*ppos
)
1294 struct ath_softc
*sc
= file
->private_data
;
1295 u32 len
= 0, size
= 1500;
1299 buf
= kzalloc(size
, GFP_KERNEL
);
1303 if (!sc
->sc_ah
->common
.btcoex_enabled
) {
1304 len
= scnprintf(buf
, size
, "%s\n",
1305 "BTCOEX is disabled");
1309 len
= ath9k_dump_btcoex(sc
, buf
, size
);
1311 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1317 static const struct file_operations fops_btcoex
= {
1318 .read
= read_file_btcoex
,
1319 .open
= simple_open
,
1320 .owner
= THIS_MODULE
,
1321 .llseek
= default_llseek
,
1325 /* Ethtool support for get-stats */
1327 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
1328 static const char ath9k_gstrings_stats
[][ETH_GSTRING_LEN
] = {
1335 AMKSTR(d_tx_mpdus_queued
),
1336 AMKSTR(d_tx_mpdus_completed
),
1337 AMKSTR(d_tx_mpdu_xretries
),
1338 AMKSTR(d_tx_aggregates
),
1339 AMKSTR(d_tx_ampdus_queued_hw
),
1340 AMKSTR(d_tx_ampdus_queued_sw
),
1341 AMKSTR(d_tx_ampdus_completed
),
1342 AMKSTR(d_tx_ampdu_retries
),
1343 AMKSTR(d_tx_ampdu_xretries
),
1344 AMKSTR(d_tx_fifo_underrun
),
1345 AMKSTR(d_tx_op_exceeded
),
1346 AMKSTR(d_tx_timer_expiry
),
1347 AMKSTR(d_tx_desc_cfg_err
),
1348 AMKSTR(d_tx_data_underrun
),
1349 AMKSTR(d_tx_delim_underrun
),
1351 "d_rx_decrypt_crc_err",
1354 "d_rx_pre_delim_crc_err",
1355 "d_rx_post_delim_crc_err",
1356 "d_rx_decrypt_busy_err",
1358 "d_rx_phyerr_radar",
1359 "d_rx_phyerr_ofdm_timing",
1360 "d_rx_phyerr_cck_timing",
1363 #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
1365 void ath9k_get_et_strings(struct ieee80211_hw
*hw
,
1366 struct ieee80211_vif
*vif
,
1369 if (sset
== ETH_SS_STATS
)
1370 memcpy(data
, *ath9k_gstrings_stats
,
1371 sizeof(ath9k_gstrings_stats
));
1374 int ath9k_get_et_sset_count(struct ieee80211_hw
*hw
,
1375 struct ieee80211_vif
*vif
, int sset
)
1377 if (sset
== ETH_SS_STATS
)
1378 return ATH9K_SSTATS_LEN
;
1382 #define AWDATA(elem) \
1384 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \
1385 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \
1386 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \
1387 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \
1390 #define AWDATA_RX(elem) \
1392 data[i++] = sc->debug.stats.rxstats.elem; \
1395 void ath9k_get_et_stats(struct ieee80211_hw
*hw
,
1396 struct ieee80211_vif
*vif
,
1397 struct ethtool_stats
*stats
, u64
*data
)
1399 struct ath_softc
*sc
= hw
->priv
;
1402 data
[i
++] = (sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BE
)].tx_pkts_all
+
1403 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BK
)].tx_pkts_all
+
1404 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VI
)].tx_pkts_all
+
1405 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VO
)].tx_pkts_all
);
1406 data
[i
++] = (sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BE
)].tx_bytes_all
+
1407 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BK
)].tx_bytes_all
+
1408 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VI
)].tx_bytes_all
+
1409 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VO
)].tx_bytes_all
);
1410 AWDATA_RX(rx_pkts_all
);
1411 AWDATA_RX(rx_bytes_all
);
1413 AWDATA(tx_pkts_all
);
1414 AWDATA(tx_bytes_all
);
1419 AWDATA(a_queued_hw
);
1420 AWDATA(a_queued_sw
);
1421 AWDATA(a_completed
);
1424 AWDATA(fifo_underrun
);
1427 AWDATA(desc_cfg_err
);
1428 AWDATA(data_underrun
);
1429 AWDATA(delim_underrun
);
1432 AWDATA_RX(decrypt_crc_err
);
1435 AWDATA_RX(pre_delim_crc_err
);
1436 AWDATA_RX(post_delim_crc_err
);
1437 AWDATA_RX(decrypt_busy_err
);
1439 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_RADAR
]);
1440 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_OFDM_TIMING
]);
1441 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_CCK_TIMING
]);
1443 WARN_ON(i
!= ATH9K_SSTATS_LEN
);
1446 void ath9k_deinit_debug(struct ath_softc
*sc
)
1448 ath9k_spectral_deinit_debug(sc
);
1451 int ath9k_init_debug(struct ath_hw
*ah
)
1453 struct ath_common
*common
= ath9k_hw_common(ah
);
1454 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
1456 sc
->debug
.debugfs_phy
= debugfs_create_dir("ath9k",
1457 sc
->hw
->wiphy
->debugfsdir
);
1458 if (!sc
->debug
.debugfs_phy
)
1461 #ifdef CONFIG_ATH_DEBUG
1462 debugfs_create_file("debug", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1466 ath9k_dfs_init_debug(sc
);
1467 ath9k_tx99_init_debug(sc
);
1468 ath9k_spectral_init_debug(sc
);
1470 debugfs_create_file("dma", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1472 debugfs_create_file("interrupt", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1474 debugfs_create_file("xmit", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1476 debugfs_create_file("queues", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1478 debugfs_create_u32("qlen_bk", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1479 &sc
->tx
.txq_max_pending
[IEEE80211_AC_BK
]);
1480 debugfs_create_u32("qlen_be", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1481 &sc
->tx
.txq_max_pending
[IEEE80211_AC_BE
]);
1482 debugfs_create_u32("qlen_vi", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1483 &sc
->tx
.txq_max_pending
[IEEE80211_AC_VI
]);
1484 debugfs_create_u32("qlen_vo", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1485 &sc
->tx
.txq_max_pending
[IEEE80211_AC_VO
]);
1486 debugfs_create_file("misc", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1488 debugfs_create_file("reset", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1490 debugfs_create_file("recv", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1492 debugfs_create_u8("rx_chainmask", S_IRUSR
, sc
->debug
.debugfs_phy
,
1494 debugfs_create_u8("tx_chainmask", S_IRUSR
, sc
->debug
.debugfs_phy
,
1496 debugfs_create_file("ani", S_IRUSR
| S_IWUSR
,
1497 sc
->debug
.debugfs_phy
, sc
, &fops_ani
);
1498 debugfs_create_bool("paprd", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1499 &sc
->sc_ah
->config
.enable_paprd
);
1500 debugfs_create_file("regidx", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1502 debugfs_create_file("regval", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1504 debugfs_create_bool("ignore_extcca", S_IRUSR
| S_IWUSR
,
1505 sc
->debug
.debugfs_phy
,
1506 &ah
->config
.cwm_ignore_extcca
);
1507 debugfs_create_file("regdump", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1509 debugfs_create_file("dump_nfcal", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1511 debugfs_create_file("base_eeprom", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1513 debugfs_create_file("modal_eeprom", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1514 &fops_modal_eeprom
);
1515 debugfs_create_u32("gpio_mask", S_IRUSR
| S_IWUSR
,
1516 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_mask
);
1517 debugfs_create_u32("gpio_val", S_IRUSR
| S_IWUSR
,
1518 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_val
);
1519 debugfs_create_file("antenna_diversity", S_IRUSR
,
1520 sc
->debug
.debugfs_phy
, sc
, &fops_antenna_diversity
);
1521 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1522 debugfs_create_file("bt_ant_diversity", S_IRUSR
| S_IWUSR
,
1523 sc
->debug
.debugfs_phy
, sc
, &fops_bt_ant_diversity
);
1524 debugfs_create_file("btcoex", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,