blob: c545960e7ec5190fe045117e9abfb70315daa946 [file] [log] [blame]
Sujith394cf0a2009-02-09 13:26:54 +05301/*
Sujithcee075a2009-03-13 09:07:23 +05302 * Copyright (c) 2008-2009 Atheros Communications Inc.
Sujith394cf0a2009-02-09 13:26:54 +05303 *
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#ifndef DEBUG_H
18#define DEBUG_H
19
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -070020#include "hw.h"
Felix Fietkau545750d2009-11-23 22:21:01 +010021#include "rc.h"
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -070022
Sujithfec247c2009-07-27 12:08:16 +053023struct ath_txq;
24struct ath_buf;
25
Felix Fietkaua830df02009-11-23 22:33:27 +010026#ifdef CONFIG_ATH9K_DEBUGFS
Sujithfec247c2009-07-27 12:08:16 +053027#define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
28#else
29#define TX_STAT_INC(q, c) do { } while (0)
30#endif
31
Felix Fietkaua830df02009-11-23 22:33:27 +010032#ifdef CONFIG_ATH9K_DEBUGFS
Sujith394cf0a2009-02-09 13:26:54 +053033
34/**
35 * struct ath_interrupt_stats - Contains statistics about interrupts
36 * @total: Total no. of interrupts generated so far
37 * @rxok: RX with no errors
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -040038 * @rxlp: RX with low priority RX
39 * @rxhp: RX with high priority, uapsd only
Sujith394cf0a2009-02-09 13:26:54 +053040 * @rxeol: RX with no more RXDESC available
41 * @rxorn: RX FIFO overrun
42 * @txok: TX completed at the requested rate
43 * @txurn: TX FIFO underrun
44 * @mib: MIB regs reaching its threshold
45 * @rxphyerr: RX with phy errors
46 * @rx_keycache_miss: RX with key cache misses
47 * @swba: Software Beacon Alert
48 * @bmiss: Beacon Miss
49 * @bnr: Beacon Not Ready
50 * @cst: Carrier Sense TImeout
51 * @gtt: Global TX Timeout
52 * @tim: RX beacon TIM occurrence
53 * @cabend: RX End of CAB traffic
54 * @dtimsync: DTIM sync lossage
55 * @dtim: RX Beacon with DTIM
56 */
57struct ath_interrupt_stats {
58 u32 total;
59 u32 rxok;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -040060 u32 rxlp;
61 u32 rxhp;
Sujith394cf0a2009-02-09 13:26:54 +053062 u32 rxeol;
63 u32 rxorn;
64 u32 txok;
65 u32 txeol;
66 u32 txurn;
67 u32 mib;
68 u32 rxphyerr;
69 u32 rx_keycache_miss;
70 u32 swba;
71 u32 bmiss;
72 u32 bnr;
73 u32 cst;
74 u32 gtt;
75 u32 tim;
76 u32 cabend;
77 u32 dtimsync;
78 u32 dtim;
79};
80
Jeff Hansenbedf0872009-05-27 12:48:28 +000081struct ath_rc_stats {
Sujith394cf0a2009-02-09 13:26:54 +053082 u32 success;
83 u32 retries;
84 u32 xretries;
Sujith9e712792009-02-20 15:13:20 +053085 u8 per;
Sujith394cf0a2009-02-09 13:26:54 +053086};
87
Sujithfec247c2009-07-27 12:08:16 +053088/**
89 * struct ath_tx_stats - Statistics about TX
90 * @queued: Total MPDUs (non-aggr) queued
91 * @completed: Total MPDUs (non-aggr) completed
92 * @a_aggr: Total no. of aggregates queued
93 * @a_queued: Total AMPDUs queued
94 * @a_completed: Total AMPDUs completed
95 * @a_retries: No. of AMPDUs retried (SW)
96 * @a_xretries: No. of AMPDUs dropped due to xretries
97 * @fifo_underrun: FIFO underrun occurrences
98 Valid only for:
99 - non-aggregate condition.
100 - first packet of aggregate.
101 * @xtxop: No. of frames filtered because of TXOP limit
102 * @timer_exp: Transmit timer expiry
103 * @desc_cfg_err: Descriptor configuration errors
104 * @data_urn: TX data underrun errors
105 * @delim_urn: TX delimiter underrun errors
106 */
107struct ath_tx_stats {
108 u32 queued;
109 u32 completed;
110 u32 a_aggr;
111 u32 a_queued;
112 u32 a_completed;
113 u32 a_retries;
114 u32 a_xretries;
115 u32 fifo_underrun;
116 u32 xtxop;
117 u32 timer_exp;
118 u32 desc_cfg_err;
119 u32 data_underrun;
120 u32 delim_underrun;
121};
122
Sujith1395d3f2010-01-08 10:36:11 +0530123/**
124 * struct ath_rx_stats - RX Statistics
125 * @crc_err: No. of frames with incorrect CRC value
126 * @decrypt_crc_err: No. of frames whose CRC check failed after
127 decryption process completed
128 * @phy_err: No. of frames whose reception failed because the PHY
129 encountered an error
130 * @mic_err: No. of frames with incorrect TKIP MIC verification failure
131 * @pre_delim_crc_err: Pre-Frame delimiter CRC error detections
132 * @post_delim_crc_err: Post-Frame delimiter CRC error detections
133 * @decrypt_busy_err: Decryption interruptions counter
134 * @phy_err_stats: Individual PHY error statistics
135 */
136struct ath_rx_stats {
137 u32 crc_err;
138 u32 decrypt_crc_err;
139 u32 phy_err;
140 u32 mic_err;
141 u32 pre_delim_crc_err;
142 u32 post_delim_crc_err;
143 u32 decrypt_busy_err;
144 u32 phy_err_stats[ATH9K_PHYERR_MAX];
145};
146
Sujith394cf0a2009-02-09 13:26:54 +0530147struct ath_stats {
148 struct ath_interrupt_stats istats;
Jeff Hansenbedf0872009-05-27 12:48:28 +0000149 struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
Sujithfec247c2009-07-27 12:08:16 +0530150 struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
Sujith1395d3f2010-01-08 10:36:11 +0530151 struct ath_rx_stats rxstats;
Sujith394cf0a2009-02-09 13:26:54 +0530152};
153
154struct ath9k_debug {
Sujith394cf0a2009-02-09 13:26:54 +0530155 struct dentry *debugfs_phy;
Jeff Hansen24939282009-05-27 12:48:29 +0000156 struct dentry *debugfs_debug;
Sujith394cf0a2009-02-09 13:26:54 +0530157 struct dentry *debugfs_dma;
158 struct dentry *debugfs_interrupt;
159 struct dentry *debugfs_rcstat;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200160 struct dentry *debugfs_wiphy;
Sujithfec247c2009-07-27 12:08:16 +0530161 struct dentry *debugfs_xmit;
Sujith1395d3f2010-01-08 10:36:11 +0530162 struct dentry *debugfs_recv;
Sujith394cf0a2009-02-09 13:26:54 +0530163 struct ath_stats stats;
164};
165
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700166int ath9k_init_debug(struct ath_hw *ah);
167void ath9k_exit_debug(struct ath_hw *ah);
168
Gabor Juhos19d8bc22009-03-05 16:55:18 +0100169int ath9k_debug_create_root(void);
170void ath9k_debug_remove_root(void);
Sujith394cf0a2009-02-09 13:26:54 +0530171void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
Felix Fietkau545750d2009-11-23 22:21:01 +0100172void ath_debug_stat_rc(struct ath_softc *sc, int final_rate);
Sujithfec247c2009-07-27 12:08:16 +0530173void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700174 struct ath_buf *bf, struct ath_tx_status *ts);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700175void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
Sujith394cf0a2009-02-09 13:26:54 +0530176void ath_debug_stat_retries(struct ath_softc *sc, int rix,
Sujith9e712792009-02-20 15:13:20 +0530177 int xretries, int retries, u8 per);
Sujith394cf0a2009-02-09 13:26:54 +0530178
179#else
180
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700181static inline int ath9k_init_debug(struct ath_hw *ah)
Sujith394cf0a2009-02-09 13:26:54 +0530182{
183 return 0;
184}
185
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700186static inline void ath9k_exit_debug(struct ath_hw *ah)
Sujith394cf0a2009-02-09 13:26:54 +0530187{
188}
189
Gabor Juhos19d8bc22009-03-05 16:55:18 +0100190static inline int ath9k_debug_create_root(void)
191{
192 return 0;
193}
194
195static inline void ath9k_debug_remove_root(void)
196{
197}
198
Sujith394cf0a2009-02-09 13:26:54 +0530199static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
200 enum ath9k_int status)
201{
202}
203
204static inline void ath_debug_stat_rc(struct ath_softc *sc,
Felix Fietkau545750d2009-11-23 22:21:01 +0100205 int final_rate)
Sujith394cf0a2009-02-09 13:26:54 +0530206{
207}
208
Sujithfec247c2009-07-27 12:08:16 +0530209static inline void ath_debug_stat_tx(struct ath_softc *sc,
210 struct ath_txq *txq,
Felix Fietkau32ffb1f2010-03-31 15:41:36 -0700211 struct ath_buf *bf,
212 struct ath_tx_status *ts)
Sujithfec247c2009-07-27 12:08:16 +0530213{
214}
215
Sujith1395d3f2010-01-08 10:36:11 +0530216static inline void ath_debug_stat_rx(struct ath_softc *sc,
Felix Fietkau32ffb1f2010-03-31 15:41:36 -0700217 struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +0530218{
219}
220
Sujith394cf0a2009-02-09 13:26:54 +0530221static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
Sujith9e712792009-02-20 15:13:20 +0530222 int xretries, int retries, u8 per)
Sujith394cf0a2009-02-09 13:26:54 +0530223{
224}
225
Felix Fietkaua830df02009-11-23 22:33:27 +0100226#endif /* CONFIG_ATH9K_DEBUGFS */
Sujith394cf0a2009-02-09 13:26:54 +0530227
228#endif /* DEBUG_H */