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 <asm/unaligned.h>
23 #define REG_WRITE_D(_ah, _reg, _val) \
24 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
25 #define REG_READ_D(_ah, _reg) \
26 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
28 static int ath9k_debugfs_open(struct inode
*inode
, struct file
*file
)
30 file
->private_data
= inode
->i_private
;
34 static ssize_t
ath9k_debugfs_read_buf(struct file
*file
, char __user
*user_buf
,
35 size_t count
, loff_t
*ppos
)
37 u8
*buf
= file
->private_data
;
38 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, strlen(buf
));
41 static int ath9k_debugfs_release_buf(struct inode
*inode
, struct file
*file
)
43 vfree(file
->private_data
);
47 #ifdef CONFIG_ATH_DEBUG
49 static ssize_t
read_file_debug(struct file
*file
, char __user
*user_buf
,
50 size_t count
, loff_t
*ppos
)
52 struct ath_softc
*sc
= file
->private_data
;
53 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
57 len
= sprintf(buf
, "0x%08x\n", common
->debug_mask
);
58 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
61 static ssize_t
write_file_debug(struct file
*file
, const char __user
*user_buf
,
62 size_t count
, loff_t
*ppos
)
64 struct ath_softc
*sc
= file
->private_data
;
65 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
70 len
= min(count
, sizeof(buf
) - 1);
71 if (copy_from_user(buf
, user_buf
, len
))
75 if (strict_strtoul(buf
, 0, &mask
))
78 common
->debug_mask
= mask
;
82 static const struct file_operations fops_debug
= {
83 .read
= read_file_debug
,
84 .write
= write_file_debug
,
85 .open
= ath9k_debugfs_open
,
87 .llseek
= default_llseek
,
92 #define DMA_BUF_LEN 1024
94 static ssize_t
read_file_tx_chainmask(struct file
*file
, char __user
*user_buf
,
95 size_t count
, loff_t
*ppos
)
97 struct ath_softc
*sc
= file
->private_data
;
98 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
102 len
= sprintf(buf
, "0x%08x\n", common
->tx_chainmask
);
103 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
106 static ssize_t
write_file_tx_chainmask(struct file
*file
, const char __user
*user_buf
,
107 size_t count
, loff_t
*ppos
)
109 struct ath_softc
*sc
= file
->private_data
;
110 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
115 len
= min(count
, sizeof(buf
) - 1);
116 if (copy_from_user(buf
, user_buf
, len
))
120 if (strict_strtoul(buf
, 0, &mask
))
123 common
->tx_chainmask
= mask
;
124 sc
->sc_ah
->caps
.tx_chainmask
= mask
;
128 static const struct file_operations fops_tx_chainmask
= {
129 .read
= read_file_tx_chainmask
,
130 .write
= write_file_tx_chainmask
,
131 .open
= ath9k_debugfs_open
,
132 .owner
= THIS_MODULE
,
133 .llseek
= default_llseek
,
137 static ssize_t
read_file_rx_chainmask(struct file
*file
, char __user
*user_buf
,
138 size_t count
, loff_t
*ppos
)
140 struct ath_softc
*sc
= file
->private_data
;
141 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
145 len
= sprintf(buf
, "0x%08x\n", common
->rx_chainmask
);
146 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
149 static ssize_t
write_file_rx_chainmask(struct file
*file
, const char __user
*user_buf
,
150 size_t count
, loff_t
*ppos
)
152 struct ath_softc
*sc
= file
->private_data
;
153 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
158 len
= min(count
, sizeof(buf
) - 1);
159 if (copy_from_user(buf
, user_buf
, len
))
163 if (strict_strtoul(buf
, 0, &mask
))
166 common
->rx_chainmask
= mask
;
167 sc
->sc_ah
->caps
.rx_chainmask
= mask
;
171 static const struct file_operations fops_rx_chainmask
= {
172 .read
= read_file_rx_chainmask
,
173 .write
= write_file_rx_chainmask
,
174 .open
= ath9k_debugfs_open
,
175 .owner
= THIS_MODULE
,
176 .llseek
= default_llseek
,
179 static ssize_t
read_file_disable_ani(struct file
*file
, char __user
*user_buf
,
180 size_t count
, loff_t
*ppos
)
182 struct ath_softc
*sc
= file
->private_data
;
183 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
187 len
= sprintf(buf
, "%d\n", common
->disable_ani
);
188 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
191 static ssize_t
write_file_disable_ani(struct file
*file
,
192 const char __user
*user_buf
,
193 size_t count
, loff_t
*ppos
)
195 struct ath_softc
*sc
= file
->private_data
;
196 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
197 unsigned long disable_ani
;
201 len
= min(count
, sizeof(buf
) - 1);
202 if (copy_from_user(buf
, user_buf
, len
))
206 if (strict_strtoul(buf
, 0, &disable_ani
))
209 common
->disable_ani
= !!disable_ani
;
212 sc
->sc_flags
&= ~SC_OP_ANI_RUN
;
213 del_timer_sync(&common
->ani
.timer
);
215 sc
->sc_flags
|= SC_OP_ANI_RUN
;
216 ath_start_ani(common
);
222 static const struct file_operations fops_disable_ani
= {
223 .read
= read_file_disable_ani
,
224 .write
= write_file_disable_ani
,
225 .open
= ath9k_debugfs_open
,
226 .owner
= THIS_MODULE
,
227 .llseek
= default_llseek
,
230 static ssize_t
read_file_dma(struct file
*file
, char __user
*user_buf
,
231 size_t count
, loff_t
*ppos
)
233 struct ath_softc
*sc
= file
->private_data
;
234 struct ath_hw
*ah
= sc
->sc_ah
;
237 unsigned int len
= 0;
238 u32 val
[ATH9K_NUM_DMA_DEBUG_REGS
];
239 int i
, qcuOffset
= 0, dcuOffset
= 0;
240 u32
*qcuBase
= &val
[0], *dcuBase
= &val
[4];
242 buf
= kmalloc(DMA_BUF_LEN
, GFP_KERNEL
);
248 REG_WRITE_D(ah
, AR_MACMISC
,
249 ((AR_MACMISC_DMA_OBS_LINE_8
<< AR_MACMISC_DMA_OBS_S
) |
250 (AR_MACMISC_MISC_OBS_BUS_1
<<
251 AR_MACMISC_MISC_OBS_BUS_MSB_S
)));
253 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
254 "Raw DMA Debug values:\n");
256 for (i
= 0; i
< ATH9K_NUM_DMA_DEBUG_REGS
; i
++) {
258 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
260 val
[i
] = REG_READ_D(ah
, AR_DMADBG_0
+ (i
* sizeof(u32
)));
261 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "%d: %08x ",
265 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n\n");
266 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
267 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
269 for (i
= 0; i
< ATH9K_NUM_QUEUES
; i
++, qcuOffset
+= 4, dcuOffset
+= 5) {
280 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
281 "%2d %2x %1x %2x %2x\n",
282 i
, (*qcuBase
& (0x7 << qcuOffset
)) >> qcuOffset
,
283 (*qcuBase
& (0x8 << qcuOffset
)) >> (qcuOffset
+ 3),
284 val
[2] & (0x7 << (i
* 3)) >> (i
* 3),
285 (*dcuBase
& (0x1f << dcuOffset
)) >> dcuOffset
);
288 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
290 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
291 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
292 (val
[3] & 0x003c0000) >> 18, (val
[3] & 0x03c00000) >> 22);
293 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
294 "qcu_complete state: %2x dcu_complete state: %2x\n",
295 (val
[3] & 0x1c000000) >> 26, (val
[6] & 0x3));
296 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
297 "dcu_arb state: %2x dcu_fp state: %2x\n",
298 (val
[5] & 0x06000000) >> 25, (val
[5] & 0x38000000) >> 27);
299 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
300 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
301 (val
[6] & 0x000003fc) >> 2, (val
[6] & 0x00000400) >> 10);
302 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
303 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
304 (val
[6] & 0x00000800) >> 11, (val
[6] & 0x00001000) >> 12);
305 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
306 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
307 (val
[6] & 0x0001e000) >> 13, (val
[6] & 0x001e0000) >> 17);
309 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "pcu observe: 0x%x\n",
310 REG_READ_D(ah
, AR_OBS_BUS_1
));
311 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
312 "AR_CR: 0x%x\n", REG_READ_D(ah
, AR_CR
));
314 ath9k_ps_restore(sc
);
316 if (len
> DMA_BUF_LEN
)
319 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
324 static const struct file_operations fops_dma
= {
325 .read
= read_file_dma
,
326 .open
= ath9k_debugfs_open
,
327 .owner
= THIS_MODULE
,
328 .llseek
= default_llseek
,
332 void ath_debug_stat_interrupt(struct ath_softc
*sc
, enum ath9k_int status
)
335 sc
->debug
.stats
.istats
.total
++;
336 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
337 if (status
& ATH9K_INT_RXLP
)
338 sc
->debug
.stats
.istats
.rxlp
++;
339 if (status
& ATH9K_INT_RXHP
)
340 sc
->debug
.stats
.istats
.rxhp
++;
341 if (status
& ATH9K_INT_BB_WATCHDOG
)
342 sc
->debug
.stats
.istats
.bb_watchdog
++;
344 if (status
& ATH9K_INT_RX
)
345 sc
->debug
.stats
.istats
.rxok
++;
347 if (status
& ATH9K_INT_RXEOL
)
348 sc
->debug
.stats
.istats
.rxeol
++;
349 if (status
& ATH9K_INT_RXORN
)
350 sc
->debug
.stats
.istats
.rxorn
++;
351 if (status
& ATH9K_INT_TX
)
352 sc
->debug
.stats
.istats
.txok
++;
353 if (status
& ATH9K_INT_TXURN
)
354 sc
->debug
.stats
.istats
.txurn
++;
355 if (status
& ATH9K_INT_MIB
)
356 sc
->debug
.stats
.istats
.mib
++;
357 if (status
& ATH9K_INT_RXPHY
)
358 sc
->debug
.stats
.istats
.rxphyerr
++;
359 if (status
& ATH9K_INT_RXKCM
)
360 sc
->debug
.stats
.istats
.rx_keycache_miss
++;
361 if (status
& ATH9K_INT_SWBA
)
362 sc
->debug
.stats
.istats
.swba
++;
363 if (status
& ATH9K_INT_BMISS
)
364 sc
->debug
.stats
.istats
.bmiss
++;
365 if (status
& ATH9K_INT_BNR
)
366 sc
->debug
.stats
.istats
.bnr
++;
367 if (status
& ATH9K_INT_CST
)
368 sc
->debug
.stats
.istats
.cst
++;
369 if (status
& ATH9K_INT_GTT
)
370 sc
->debug
.stats
.istats
.gtt
++;
371 if (status
& ATH9K_INT_TIM
)
372 sc
->debug
.stats
.istats
.tim
++;
373 if (status
& ATH9K_INT_CABEND
)
374 sc
->debug
.stats
.istats
.cabend
++;
375 if (status
& ATH9K_INT_DTIMSYNC
)
376 sc
->debug
.stats
.istats
.dtimsync
++;
377 if (status
& ATH9K_INT_DTIM
)
378 sc
->debug
.stats
.istats
.dtim
++;
379 if (status
& ATH9K_INT_TSFOOR
)
380 sc
->debug
.stats
.istats
.tsfoor
++;
383 static ssize_t
read_file_interrupt(struct file
*file
, char __user
*user_buf
,
384 size_t count
, loff_t
*ppos
)
386 struct ath_softc
*sc
= file
->private_data
;
388 unsigned int len
= 0;
390 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
391 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
392 "%8s: %10u\n", "RXLP", sc
->debug
.stats
.istats
.rxlp
);
393 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
394 "%8s: %10u\n", "RXHP", sc
->debug
.stats
.istats
.rxhp
);
395 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
396 "%8s: %10u\n", "WATCHDOG",
397 sc
->debug
.stats
.istats
.bb_watchdog
);
399 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
400 "%8s: %10u\n", "RX", sc
->debug
.stats
.istats
.rxok
);
402 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
403 "%8s: %10u\n", "RXEOL", sc
->debug
.stats
.istats
.rxeol
);
404 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
405 "%8s: %10u\n", "RXORN", sc
->debug
.stats
.istats
.rxorn
);
406 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
407 "%8s: %10u\n", "TX", sc
->debug
.stats
.istats
.txok
);
408 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
409 "%8s: %10u\n", "TXURN", sc
->debug
.stats
.istats
.txurn
);
410 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
411 "%8s: %10u\n", "MIB", sc
->debug
.stats
.istats
.mib
);
412 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
413 "%8s: %10u\n", "RXPHY", sc
->debug
.stats
.istats
.rxphyerr
);
414 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
415 "%8s: %10u\n", "RXKCM", sc
->debug
.stats
.istats
.rx_keycache_miss
);
416 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
417 "%8s: %10u\n", "SWBA", sc
->debug
.stats
.istats
.swba
);
418 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
419 "%8s: %10u\n", "BMISS", sc
->debug
.stats
.istats
.bmiss
);
420 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
421 "%8s: %10u\n", "BNR", sc
->debug
.stats
.istats
.bnr
);
422 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
423 "%8s: %10u\n", "CST", sc
->debug
.stats
.istats
.cst
);
424 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
425 "%8s: %10u\n", "GTT", sc
->debug
.stats
.istats
.gtt
);
426 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
427 "%8s: %10u\n", "TIM", sc
->debug
.stats
.istats
.tim
);
428 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
429 "%8s: %10u\n", "CABEND", sc
->debug
.stats
.istats
.cabend
);
430 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
431 "%8s: %10u\n", "DTIMSYNC", sc
->debug
.stats
.istats
.dtimsync
);
432 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
433 "%8s: %10u\n", "DTIM", sc
->debug
.stats
.istats
.dtim
);
434 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
435 "%8s: %10u\n", "TSFOOR", sc
->debug
.stats
.istats
.tsfoor
);
436 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
437 "%8s: %10u\n", "TOTAL", sc
->debug
.stats
.istats
.total
);
440 if (len
> sizeof(buf
))
443 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
446 static const struct file_operations fops_interrupt
= {
447 .read
= read_file_interrupt
,
448 .open
= ath9k_debugfs_open
,
449 .owner
= THIS_MODULE
,
450 .llseek
= default_llseek
,
453 static const char *channel_type_str(enum nl80211_channel_type t
)
456 case NL80211_CHAN_NO_HT
:
458 case NL80211_CHAN_HT20
:
460 case NL80211_CHAN_HT40MINUS
:
462 case NL80211_CHAN_HT40PLUS
:
469 static ssize_t
read_file_wiphy(struct file
*file
, char __user
*user_buf
,
470 size_t count
, loff_t
*ppos
)
472 struct ath_softc
*sc
= file
->private_data
;
473 struct ieee80211_channel
*chan
= sc
->hw
->conf
.channel
;
474 struct ieee80211_conf
*conf
= &(sc
->hw
->conf
);
476 unsigned int len
= 0;
480 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
481 "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n",
482 wiphy_name(sc
->hw
->wiphy
),
483 ieee80211_frequency_to_channel(chan
->center_freq
),
486 channel_type_str(conf
->channel_type
));
489 put_unaligned_le32(REG_READ_D(sc
->sc_ah
, AR_STA_ID0
), addr
);
490 put_unaligned_le16(REG_READ_D(sc
->sc_ah
, AR_STA_ID1
) & 0xffff, addr
+ 4);
491 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
492 "addr: %pM\n", addr
);
493 put_unaligned_le32(REG_READ_D(sc
->sc_ah
, AR_BSSMSKL
), addr
);
494 put_unaligned_le16(REG_READ_D(sc
->sc_ah
, AR_BSSMSKU
) & 0xffff, addr
+ 4);
495 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
496 "addrmask: %pM\n", addr
);
497 tmp
= ath9k_hw_getrxfilter(sc
->sc_ah
);
498 ath9k_ps_restore(sc
);
499 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
501 if (tmp
& ATH9K_RX_FILTER_UCAST
)
502 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " UCAST");
503 if (tmp
& ATH9K_RX_FILTER_MCAST
)
504 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST");
505 if (tmp
& ATH9K_RX_FILTER_BCAST
)
506 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BCAST");
507 if (tmp
& ATH9K_RX_FILTER_CONTROL
)
508 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " CONTROL");
509 if (tmp
& ATH9K_RX_FILTER_BEACON
)
510 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BEACON");
511 if (tmp
& ATH9K_RX_FILTER_PROM
)
512 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PROM");
513 if (tmp
& ATH9K_RX_FILTER_PROBEREQ
)
514 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PROBEREQ");
515 if (tmp
& ATH9K_RX_FILTER_PHYERR
)
516 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PHYERR");
517 if (tmp
& ATH9K_RX_FILTER_MYBEACON
)
518 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MYBEACON");
519 if (tmp
& ATH9K_RX_FILTER_COMP_BAR
)
520 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " COMP_BAR");
521 if (tmp
& ATH9K_RX_FILTER_PSPOLL
)
522 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PSPOLL");
523 if (tmp
& ATH9K_RX_FILTER_PHYRADAR
)
524 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PHYRADAR");
525 if (tmp
& ATH9K_RX_FILTER_MCAST_BCAST_ALL
)
526 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST_BCAST_ALL\n");
528 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
530 if (len
> sizeof(buf
))
533 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
536 static const struct file_operations fops_wiphy
= {
537 .read
= read_file_wiphy
,
538 .open
= ath9k_debugfs_open
,
539 .owner
= THIS_MODULE
,
540 .llseek
= default_llseek
,
543 #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
544 #define PR(str, elem) \
546 len += snprintf(buf + len, size - len, \
547 "%s%13u%11u%10u%10u\n", str, \
548 sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \
549 sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \
550 sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \
551 sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \
556 #define PRX(str, elem) \
558 len += snprintf(buf + len, size - len, \
559 "%s%13u%11u%10u%10u\n", str, \
560 (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \
561 (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \
562 (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \
563 (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \
568 #define PRQLE(str, elem) \
570 len += snprintf(buf + len, size - len, \
571 "%s%13i%11i%10i%10i\n", str, \
572 list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \
573 list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \
574 list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \
575 list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \
580 static ssize_t
read_file_xmit(struct file
*file
, char __user
*user_buf
,
581 size_t count
, loff_t
*ppos
)
583 struct ath_softc
*sc
= file
->private_data
;
585 unsigned int len
= 0, size
= 8000;
590 buf
= kzalloc(size
, GFP_KERNEL
);
594 len
+= sprintf(buf
, "Num-Tx-Queues: %i tx-queues-setup: 0x%x"
595 " poll-work-seen: %u\n"
596 "%30s %10s%10s%10s\n\n",
597 ATH9K_NUM_TX_QUEUES
, sc
->tx
.txqsetup
,
598 sc
->tx_complete_poll_work_seen
,
599 "BE", "BK", "VI", "VO");
601 PR("MPDUs Queued: ", queued
);
602 PR("MPDUs Completed: ", completed
);
603 PR("MPDUs XRetried: ", xretries
);
604 PR("Aggregates: ", a_aggr
);
605 PR("AMPDUs Queued HW:", a_queued_hw
);
606 PR("AMPDUs Queued SW:", a_queued_sw
);
607 PR("AMPDUs Completed:", a_completed
);
608 PR("AMPDUs Retried: ", a_retries
);
609 PR("AMPDUs XRetried: ", a_xretries
);
610 PR("FIFO Underrun: ", fifo_underrun
);
611 PR("TXOP Exceeded: ", xtxop
);
612 PR("TXTIMER Expiry: ", timer_exp
);
613 PR("DESC CFG Error: ", desc_cfg_err
);
614 PR("DATA Underrun: ", data_underrun
);
615 PR("DELIM Underrun: ", delim_underrun
);
616 PR("TX-Pkts-All: ", tx_pkts_all
);
617 PR("TX-Bytes-All: ", tx_bytes_all
);
618 PR("hw-put-tx-buf: ", puttxbuf
);
619 PR("hw-tx-start: ", txstart
);
620 PR("hw-tx-proc-desc: ", txprocdesc
);
621 len
+= snprintf(buf
+ len
, size
- len
,
622 "%s%11p%11p%10p%10p\n", "txq-memory-address:",
623 sc
->tx
.txq_map
[WME_AC_BE
],
624 sc
->tx
.txq_map
[WME_AC_BK
],
625 sc
->tx
.txq_map
[WME_AC_VI
],
626 sc
->tx
.txq_map
[WME_AC_VO
]);
630 PRX("axq-qnum: ", axq_qnum
);
631 PRX("axq-depth: ", axq_depth
);
632 PRX("axq-ampdu_depth: ", axq_ampdu_depth
);
633 PRX("axq-stopped ", stopped
);
634 PRX("tx-in-progress ", axq_tx_inprogress
);
635 PRX("pending-frames ", pending_frames
);
636 PRX("txq_headidx: ", txq_headidx
);
637 PRX("txq_tailidx: ", txq_headidx
);
639 PRQLE("axq_q empty: ", axq_q
);
640 PRQLE("axq_acq empty: ", axq_acq
);
641 for (i
= 0; i
< ATH_TXFIFO_DEPTH
; i
++) {
642 snprintf(tmp
, sizeof(tmp
) - 1, "txq_fifo[%i] empty: ", i
);
643 PRQLE(tmp
, txq_fifo
[i
]);
646 /* Print out more detailed queue-info */
647 for (i
= 0; i
<= WME_AC_BK
; i
++) {
648 struct ath_txq
*txq
= &(sc
->tx
.txq
[i
]);
649 struct ath_atx_ac
*ac
;
650 struct ath_atx_tid
*tid
;
653 spin_lock_bh(&txq
->axq_lock
);
654 if (!list_empty(&txq
->axq_acq
)) {
655 ac
= list_first_entry(&txq
->axq_acq
, struct ath_atx_ac
,
657 len
+= snprintf(buf
+ len
, size
- len
,
658 "txq[%i] first-ac: %p sched: %i\n",
660 if (list_empty(&ac
->tid_q
) || (len
>= size
))
662 tid
= list_first_entry(&ac
->tid_q
, struct ath_atx_tid
,
664 len
+= snprintf(buf
+ len
, size
- len
,
665 " first-tid: %p sched: %i paused: %i\n",
666 tid
, tid
->sched
, tid
->paused
);
669 spin_unlock_bh(&txq
->axq_lock
);
676 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
682 static ssize_t
read_file_stations(struct file
*file
, char __user
*user_buf
,
683 size_t count
, loff_t
*ppos
)
685 struct ath_softc
*sc
= file
->private_data
;
687 unsigned int len
= 0, size
= 64000;
688 struct ath_node
*an
= NULL
;
692 buf
= kzalloc(size
, GFP_KERNEL
);
696 len
+= snprintf(buf
+ len
, size
- len
,
698 " tid: addr sched paused buf_q-empty an ac\n"
699 " ac: addr sched tid_q-empty txq\n");
701 spin_lock(&sc
->nodes_lock
);
702 list_for_each_entry(an
, &sc
->nodes
, list
) {
703 len
+= snprintf(buf
+ len
, size
- len
,
704 "%pM\n", an
->sta
->addr
);
708 for (q
= 0; q
< WME_NUM_TID
; q
++) {
709 struct ath_atx_tid
*tid
= &(an
->tid
[q
]);
710 len
+= snprintf(buf
+ len
, size
- len
,
711 " tid: %p %s %s %i %p %p\n",
712 tid
, tid
->sched
? "sched" : "idle",
713 tid
->paused
? "paused" : "running",
714 list_empty(&tid
->buf_q
),
720 for (q
= 0; q
< WME_NUM_AC
; q
++) {
721 struct ath_atx_ac
*ac
= &(an
->ac
[q
]);
722 len
+= snprintf(buf
+ len
, size
- len
,
723 " ac: %p %s %i %p\n",
724 ac
, ac
->sched
? "sched" : "idle",
725 list_empty(&ac
->tid_q
), ac
->txq
);
732 spin_unlock(&sc
->nodes_lock
);
736 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
742 static ssize_t
read_file_misc(struct file
*file
, char __user
*user_buf
,
743 size_t count
, loff_t
*ppos
)
745 struct ath_softc
*sc
= file
->private_data
;
746 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
747 struct ath_hw
*ah
= sc
->sc_ah
;
748 struct ieee80211_hw
*hw
= sc
->hw
;
750 unsigned int len
= 0, size
= 8000;
753 struct ath9k_vif_iter_data iter_data
;
755 ath9k_calculate_iter_data(hw
, NULL
, &iter_data
);
757 buf
= kzalloc(size
, GFP_KERNEL
);
762 len
+= snprintf(buf
+ len
, size
- len
,
765 "Beacon-Timer-Register: 0x%x\n",
767 ath_opmode_to_string(sc
->sc_ah
->opmode
),
768 (int)(sc
->sc_ah
->opmode
),
769 REG_READ(ah
, AR_BEACON_PERIOD
));
771 reg
= REG_READ(ah
, AR_TIMER_MODE
);
772 ath9k_ps_restore(sc
);
773 len
+= snprintf(buf
+ len
, size
- len
, "Timer-Mode-Register: 0x%x (",
775 if (reg
& AR_TBTT_TIMER_EN
)
776 len
+= snprintf(buf
+ len
, size
- len
, "TBTT ");
777 if (reg
& AR_DBA_TIMER_EN
)
778 len
+= snprintf(buf
+ len
, size
- len
, "DBA ");
779 if (reg
& AR_SWBA_TIMER_EN
)
780 len
+= snprintf(buf
+ len
, size
- len
, "SWBA ");
781 if (reg
& AR_HCF_TIMER_EN
)
782 len
+= snprintf(buf
+ len
, size
- len
, "HCF ");
783 if (reg
& AR_TIM_TIMER_EN
)
784 len
+= snprintf(buf
+ len
, size
- len
, "TIM ");
785 if (reg
& AR_DTIM_TIMER_EN
)
786 len
+= snprintf(buf
+ len
, size
- len
, "DTIM ");
787 len
+= snprintf(buf
+ len
, size
- len
, ")\n");
789 reg
= sc
->sc_ah
->imask
;
790 len
+= snprintf(buf
+ len
, size
- len
, "imask: 0x%x (", reg
);
791 if (reg
& ATH9K_INT_SWBA
)
792 len
+= snprintf(buf
+ len
, size
- len
, "SWBA ");
793 if (reg
& ATH9K_INT_BMISS
)
794 len
+= snprintf(buf
+ len
, size
- len
, "BMISS ");
795 if (reg
& ATH9K_INT_CST
)
796 len
+= snprintf(buf
+ len
, size
- len
, "CST ");
797 if (reg
& ATH9K_INT_RX
)
798 len
+= snprintf(buf
+ len
, size
- len
, "RX ");
799 if (reg
& ATH9K_INT_RXHP
)
800 len
+= snprintf(buf
+ len
, size
- len
, "RXHP ");
801 if (reg
& ATH9K_INT_RXLP
)
802 len
+= snprintf(buf
+ len
, size
- len
, "RXLP ");
803 if (reg
& ATH9K_INT_BB_WATCHDOG
)
804 len
+= snprintf(buf
+ len
, size
- len
, "BB_WATCHDOG ");
805 /* there are other IRQs if one wanted to add them. */
806 len
+= snprintf(buf
+ len
, size
- len
, ")\n");
808 len
+= snprintf(buf
+ len
, size
- len
,
809 "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i"
810 " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n",
811 iter_data
.naps
, iter_data
.nstations
, iter_data
.nmeshes
,
812 iter_data
.nwds
, iter_data
.nadhocs
, iter_data
.nothers
,
813 sc
->nvifs
, sc
->nbcnvifs
);
815 len
+= snprintf(buf
+ len
, size
- len
,
816 "Calculated-BSSID-Mask: %pM\n",
822 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
828 void ath_debug_stat_tx(struct ath_softc
*sc
, struct ath_buf
*bf
,
829 struct ath_tx_status
*ts
, struct ath_txq
*txq
)
831 int qnum
= txq
->axq_qnum
;
833 TX_STAT_INC(qnum
, tx_pkts_all
);
834 sc
->debug
.stats
.txstats
[qnum
].tx_bytes_all
+= bf
->bf_mpdu
->len
;
836 if (bf_isampdu(bf
)) {
837 if (bf_isxretried(bf
))
838 TX_STAT_INC(qnum
, a_xretries
);
840 TX_STAT_INC(qnum
, a_completed
);
842 if (bf_isxretried(bf
))
843 TX_STAT_INC(qnum
, xretries
);
845 TX_STAT_INC(qnum
, completed
);
848 if (ts
->ts_status
& ATH9K_TXERR_FIFO
)
849 TX_STAT_INC(qnum
, fifo_underrun
);
850 if (ts
->ts_status
& ATH9K_TXERR_XTXOP
)
851 TX_STAT_INC(qnum
, xtxop
);
852 if (ts
->ts_status
& ATH9K_TXERR_TIMER_EXPIRED
)
853 TX_STAT_INC(qnum
, timer_exp
);
854 if (ts
->ts_flags
& ATH9K_TX_DESC_CFG_ERR
)
855 TX_STAT_INC(qnum
, desc_cfg_err
);
856 if (ts
->ts_flags
& ATH9K_TX_DATA_UNDERRUN
)
857 TX_STAT_INC(qnum
, data_underrun
);
858 if (ts
->ts_flags
& ATH9K_TX_DELIM_UNDERRUN
)
859 TX_STAT_INC(qnum
, delim_underrun
);
862 static const struct file_operations fops_xmit
= {
863 .read
= read_file_xmit
,
864 .open
= ath9k_debugfs_open
,
865 .owner
= THIS_MODULE
,
866 .llseek
= default_llseek
,
869 static const struct file_operations fops_stations
= {
870 .read
= read_file_stations
,
871 .open
= ath9k_debugfs_open
,
872 .owner
= THIS_MODULE
,
873 .llseek
= default_llseek
,
876 static const struct file_operations fops_misc
= {
877 .read
= read_file_misc
,
878 .open
= ath9k_debugfs_open
,
879 .owner
= THIS_MODULE
,
880 .llseek
= default_llseek
,
883 static ssize_t
read_file_recv(struct file
*file
, char __user
*user_buf
,
884 size_t count
, loff_t
*ppos
)
886 #define PHY_ERR(s, p) \
887 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
888 sc->debug.stats.rxstats.phy_err_stats[p]);
890 struct ath_softc
*sc
= file
->private_data
;
892 unsigned int len
= 0, size
= 1400;
895 buf
= kzalloc(size
, GFP_KERNEL
);
899 len
+= snprintf(buf
+ len
, size
- len
,
900 "%18s : %10u\n", "CRC ERR",
901 sc
->debug
.stats
.rxstats
.crc_err
);
902 len
+= snprintf(buf
+ len
, size
- len
,
903 "%18s : %10u\n", "DECRYPT CRC ERR",
904 sc
->debug
.stats
.rxstats
.decrypt_crc_err
);
905 len
+= snprintf(buf
+ len
, size
- len
,
906 "%18s : %10u\n", "PHY ERR",
907 sc
->debug
.stats
.rxstats
.phy_err
);
908 len
+= snprintf(buf
+ len
, size
- len
,
909 "%18s : %10u\n", "MIC ERR",
910 sc
->debug
.stats
.rxstats
.mic_err
);
911 len
+= snprintf(buf
+ len
, size
- len
,
912 "%18s : %10u\n", "PRE-DELIM CRC ERR",
913 sc
->debug
.stats
.rxstats
.pre_delim_crc_err
);
914 len
+= snprintf(buf
+ len
, size
- len
,
915 "%18s : %10u\n", "POST-DELIM CRC ERR",
916 sc
->debug
.stats
.rxstats
.post_delim_crc_err
);
917 len
+= snprintf(buf
+ len
, size
- len
,
918 "%18s : %10u\n", "DECRYPT BUSY ERR",
919 sc
->debug
.stats
.rxstats
.decrypt_busy_err
);
921 len
+= snprintf(buf
+ len
, size
- len
,
922 "%18s : %10d\n", "RSSI-CTL0",
923 sc
->debug
.stats
.rxstats
.rs_rssi_ctl0
);
925 len
+= snprintf(buf
+ len
, size
- len
,
926 "%18s : %10d\n", "RSSI-CTL1",
927 sc
->debug
.stats
.rxstats
.rs_rssi_ctl1
);
929 len
+= snprintf(buf
+ len
, size
- len
,
930 "%18s : %10d\n", "RSSI-CTL2",
931 sc
->debug
.stats
.rxstats
.rs_rssi_ctl2
);
933 len
+= snprintf(buf
+ len
, size
- len
,
934 "%18s : %10d\n", "RSSI-EXT0",
935 sc
->debug
.stats
.rxstats
.rs_rssi_ext0
);
937 len
+= snprintf(buf
+ len
, size
- len
,
938 "%18s : %10d\n", "RSSI-EXT1",
939 sc
->debug
.stats
.rxstats
.rs_rssi_ext1
);
941 len
+= snprintf(buf
+ len
, size
- len
,
942 "%18s : %10d\n", "RSSI-EXT2",
943 sc
->debug
.stats
.rxstats
.rs_rssi_ext2
);
945 len
+= snprintf(buf
+ len
, size
- len
,
946 "%18s : %10d\n", "Rx Antenna",
947 sc
->debug
.stats
.rxstats
.rs_antenna
);
949 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN
);
950 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING
);
951 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY
);
952 PHY_ERR("RATE", ATH9K_PHYERR_RATE
);
953 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH
);
954 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR
);
955 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE
);
956 PHY_ERR("TOR", ATH9K_PHYERR_TOR
);
957 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING
);
958 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY
);
959 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL
);
960 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL
);
961 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP
);
962 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE
);
963 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART
);
964 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT
);
965 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING
);
966 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC
);
967 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL
);
968 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE
);
969 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART
);
970 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL
);
971 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP
);
972 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR
);
973 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL
);
974 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL
);
976 len
+= snprintf(buf
+ len
, size
- len
,
977 "%18s : %10u\n", "RX-Pkts-All",
978 sc
->debug
.stats
.rxstats
.rx_pkts_all
);
979 len
+= snprintf(buf
+ len
, size
- len
,
980 "%18s : %10u\n", "RX-Bytes-All",
981 sc
->debug
.stats
.rxstats
.rx_bytes_all
);
986 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
994 void ath_debug_stat_rx(struct ath_softc
*sc
, struct ath_rx_status
*rs
)
996 #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
997 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
1001 RX_STAT_INC(rx_pkts_all
);
1002 sc
->debug
.stats
.rxstats
.rx_bytes_all
+= rs
->rs_datalen
;
1004 if (rs
->rs_status
& ATH9K_RXERR_CRC
)
1005 RX_STAT_INC(crc_err
);
1006 if (rs
->rs_status
& ATH9K_RXERR_DECRYPT
)
1007 RX_STAT_INC(decrypt_crc_err
);
1008 if (rs
->rs_status
& ATH9K_RXERR_MIC
)
1009 RX_STAT_INC(mic_err
);
1010 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_PRE
)
1011 RX_STAT_INC(pre_delim_crc_err
);
1012 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_POST
)
1013 RX_STAT_INC(post_delim_crc_err
);
1014 if (rs
->rs_status
& ATH9K_RX_DECRYPT_BUSY
)
1015 RX_STAT_INC(decrypt_busy_err
);
1017 if (rs
->rs_status
& ATH9K_RXERR_PHY
) {
1018 RX_STAT_INC(phy_err
);
1019 phyerr
= rs
->rs_phyerr
& 0x24;
1020 RX_PHY_ERR_INC(phyerr
);
1023 sc
->debug
.stats
.rxstats
.rs_rssi_ctl0
= rs
->rs_rssi_ctl0
;
1024 sc
->debug
.stats
.rxstats
.rs_rssi_ctl1
= rs
->rs_rssi_ctl1
;
1025 sc
->debug
.stats
.rxstats
.rs_rssi_ctl2
= rs
->rs_rssi_ctl2
;
1027 sc
->debug
.stats
.rxstats
.rs_rssi_ext0
= rs
->rs_rssi_ext0
;
1028 sc
->debug
.stats
.rxstats
.rs_rssi_ext1
= rs
->rs_rssi_ext1
;
1029 sc
->debug
.stats
.rxstats
.rs_rssi_ext2
= rs
->rs_rssi_ext2
;
1031 sc
->debug
.stats
.rxstats
.rs_antenna
= rs
->rs_antenna
;
1034 #undef RX_PHY_ERR_INC
1037 static const struct file_operations fops_recv
= {
1038 .read
= read_file_recv
,
1039 .open
= ath9k_debugfs_open
,
1040 .owner
= THIS_MODULE
,
1041 .llseek
= default_llseek
,
1044 static ssize_t
read_file_regidx(struct file
*file
, char __user
*user_buf
,
1045 size_t count
, loff_t
*ppos
)
1047 struct ath_softc
*sc
= file
->private_data
;
1051 len
= sprintf(buf
, "0x%08x\n", sc
->debug
.regidx
);
1052 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1055 static ssize_t
write_file_regidx(struct file
*file
, const char __user
*user_buf
,
1056 size_t count
, loff_t
*ppos
)
1058 struct ath_softc
*sc
= file
->private_data
;
1059 unsigned long regidx
;
1063 len
= min(count
, sizeof(buf
) - 1);
1064 if (copy_from_user(buf
, user_buf
, len
))
1068 if (strict_strtoul(buf
, 0, ®idx
))
1071 sc
->debug
.regidx
= regidx
;
1075 static const struct file_operations fops_regidx
= {
1076 .read
= read_file_regidx
,
1077 .write
= write_file_regidx
,
1078 .open
= ath9k_debugfs_open
,
1079 .owner
= THIS_MODULE
,
1080 .llseek
= default_llseek
,
1083 static ssize_t
read_file_regval(struct file
*file
, char __user
*user_buf
,
1084 size_t count
, loff_t
*ppos
)
1086 struct ath_softc
*sc
= file
->private_data
;
1087 struct ath_hw
*ah
= sc
->sc_ah
;
1092 ath9k_ps_wakeup(sc
);
1093 regval
= REG_READ_D(ah
, sc
->debug
.regidx
);
1094 ath9k_ps_restore(sc
);
1095 len
= sprintf(buf
, "0x%08x\n", regval
);
1096 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1099 static ssize_t
write_file_regval(struct file
*file
, const char __user
*user_buf
,
1100 size_t count
, loff_t
*ppos
)
1102 struct ath_softc
*sc
= file
->private_data
;
1103 struct ath_hw
*ah
= sc
->sc_ah
;
1104 unsigned long regval
;
1108 len
= min(count
, sizeof(buf
) - 1);
1109 if (copy_from_user(buf
, user_buf
, len
))
1113 if (strict_strtoul(buf
, 0, ®val
))
1116 ath9k_ps_wakeup(sc
);
1117 REG_WRITE_D(ah
, sc
->debug
.regidx
, regval
);
1118 ath9k_ps_restore(sc
);
1122 static const struct file_operations fops_regval
= {
1123 .read
= read_file_regval
,
1124 .write
= write_file_regval
,
1125 .open
= ath9k_debugfs_open
,
1126 .owner
= THIS_MODULE
,
1127 .llseek
= default_llseek
,
1130 #define REGDUMP_LINE_SIZE 20
1132 static int open_file_regdump(struct inode
*inode
, struct file
*file
)
1134 struct ath_softc
*sc
= inode
->i_private
;
1135 unsigned int len
= 0;
1138 unsigned long num_regs
, regdump_len
, max_reg_offset
;
1140 max_reg_offset
= AR_SREV_9300_20_OR_LATER(sc
->sc_ah
) ? 0x16bd4 : 0xb500;
1141 num_regs
= max_reg_offset
/ 4 + 1;
1142 regdump_len
= num_regs
* REGDUMP_LINE_SIZE
+ 1;
1143 buf
= vmalloc(regdump_len
);
1147 ath9k_ps_wakeup(sc
);
1148 for (i
= 0; i
< num_regs
; i
++)
1149 len
+= scnprintf(buf
+ len
, regdump_len
- len
,
1150 "0x%06x 0x%08x\n", i
<< 2, REG_READ(sc
->sc_ah
, i
<< 2));
1151 ath9k_ps_restore(sc
);
1153 file
->private_data
= buf
;
1158 static const struct file_operations fops_regdump
= {
1159 .open
= open_file_regdump
,
1160 .read
= ath9k_debugfs_read_buf
,
1161 .release
= ath9k_debugfs_release_buf
,
1162 .owner
= THIS_MODULE
,
1163 .llseek
= default_llseek
,/* read accesses f_pos */
1166 int ath9k_init_debug(struct ath_hw
*ah
)
1168 struct ath_common
*common
= ath9k_hw_common(ah
);
1169 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
1171 sc
->debug
.debugfs_phy
= debugfs_create_dir("ath9k",
1172 sc
->hw
->wiphy
->debugfsdir
);
1173 if (!sc
->debug
.debugfs_phy
)
1176 #ifdef CONFIG_ATH_DEBUG
1177 debugfs_create_file("debug", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1180 debugfs_create_file("dma", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1182 debugfs_create_file("interrupt", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1184 debugfs_create_file("wiphy", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1186 debugfs_create_file("xmit", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1188 debugfs_create_file("stations", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1190 debugfs_create_file("misc", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1192 debugfs_create_file("recv", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1194 debugfs_create_file("rx_chainmask", S_IRUSR
| S_IWUSR
,
1195 sc
->debug
.debugfs_phy
, sc
, &fops_rx_chainmask
);
1196 debugfs_create_file("tx_chainmask", S_IRUSR
| S_IWUSR
,
1197 sc
->debug
.debugfs_phy
, sc
, &fops_tx_chainmask
);
1198 debugfs_create_file("disable_ani", S_IRUSR
| S_IWUSR
,
1199 sc
->debug
.debugfs_phy
, sc
, &fops_disable_ani
);
1200 debugfs_create_file("regidx", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1202 debugfs_create_file("regval", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1204 debugfs_create_bool("ignore_extcca", S_IRUSR
| S_IWUSR
,
1205 sc
->debug
.debugfs_phy
,
1206 &ah
->config
.cwm_ignore_extcca
);
1207 debugfs_create_file("regdump", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1210 debugfs_create_u32("gpio_mask", S_IRUSR
| S_IWUSR
,
1211 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_mask
);
1213 debugfs_create_u32("gpio_val", S_IRUSR
| S_IWUSR
,
1214 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_val
);
1216 sc
->debug
.regidx
= 0;