]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/net/wireless/ath/ath9k/debug.h
ath9k: Add infrastructure for generic hw timers
[mv-sheeva.git] / drivers / net / wireless / ath / ath9k / debug.h
1 /*
2  * Copyright (c) 2008-2009 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 #ifndef DEBUG_H
18 #define DEBUG_H
19
20 enum ATH_DEBUG {
21         ATH_DBG_RESET           = 0x00000001,
22         ATH_DBG_QUEUE           = 0x00000002,
23         ATH_DBG_EEPROM          = 0x00000004,
24         ATH_DBG_CALIBRATE       = 0x00000008,
25         ATH_DBG_INTERRUPT       = 0x00000010,
26         ATH_DBG_REGULATORY      = 0x00000020,
27         ATH_DBG_ANI             = 0x00000040,
28         ATH_DBG_XMIT            = 0x00000080,
29         ATH_DBG_BEACON          = 0x00000100,
30         ATH_DBG_CONFIG          = 0x00000200,
31         ATH_DBG_FATAL           = 0x00000400,
32         ATH_DBG_PS              = 0x00000800,
33         ATH_DBG_HWTIMER         = 0x00001000,
34         ATH_DBG_ANY             = 0xffffffff
35 };
36
37 #define DBG_DEFAULT (ATH_DBG_FATAL)
38
39 struct ath_txq;
40 struct ath_buf;
41
42 #ifdef CONFIG_ATH9K_DEBUG
43 #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
44 #else
45 #define TX_STAT_INC(q, c) do { } while (0)
46 #endif
47
48 #ifdef CONFIG_ATH9K_DEBUG
49
50 /**
51  * struct ath_interrupt_stats - Contains statistics about interrupts
52  * @total: Total no. of interrupts generated so far
53  * @rxok: RX with no errors
54  * @rxeol: RX with no more RXDESC available
55  * @rxorn: RX FIFO overrun
56  * @txok: TX completed at the requested rate
57  * @txurn: TX FIFO underrun
58  * @mib: MIB regs reaching its threshold
59  * @rxphyerr: RX with phy errors
60  * @rx_keycache_miss: RX with key cache misses
61  * @swba: Software Beacon Alert
62  * @bmiss: Beacon Miss
63  * @bnr: Beacon Not Ready
64  * @cst: Carrier Sense TImeout
65  * @gtt: Global TX Timeout
66  * @tim: RX beacon TIM occurrence
67  * @cabend: RX End of CAB traffic
68  * @dtimsync: DTIM sync lossage
69  * @dtim: RX Beacon with DTIM
70  */
71 struct ath_interrupt_stats {
72         u32 total;
73         u32 rxok;
74         u32 rxeol;
75         u32 rxorn;
76         u32 txok;
77         u32 txeol;
78         u32 txurn;
79         u32 mib;
80         u32 rxphyerr;
81         u32 rx_keycache_miss;
82         u32 swba;
83         u32 bmiss;
84         u32 bnr;
85         u32 cst;
86         u32 gtt;
87         u32 tim;
88         u32 cabend;
89         u32 dtimsync;
90         u32 dtim;
91 };
92
93 struct ath_rc_stats {
94         u32 success;
95         u32 retries;
96         u32 xretries;
97         u8 per;
98 };
99
100 /**
101  * struct ath_tx_stats - Statistics about TX
102  * @queued: Total MPDUs (non-aggr) queued
103  * @completed: Total MPDUs (non-aggr) completed
104  * @a_aggr: Total no. of aggregates queued
105  * @a_queued: Total AMPDUs queued
106  * @a_completed: Total AMPDUs completed
107  * @a_retries: No. of AMPDUs retried (SW)
108  * @a_xretries: No. of AMPDUs dropped due to xretries
109  * @fifo_underrun: FIFO underrun occurrences
110         Valid only for:
111                 - non-aggregate condition.
112                 - first packet of aggregate.
113  * @xtxop: No. of frames filtered because of TXOP limit
114  * @timer_exp: Transmit timer expiry
115  * @desc_cfg_err: Descriptor configuration errors
116  * @data_urn: TX data underrun errors
117  * @delim_urn: TX delimiter underrun errors
118  */
119 struct ath_tx_stats {
120         u32 queued;
121         u32 completed;
122         u32 a_aggr;
123         u32 a_queued;
124         u32 a_completed;
125         u32 a_retries;
126         u32 a_xretries;
127         u32 fifo_underrun;
128         u32 xtxop;
129         u32 timer_exp;
130         u32 desc_cfg_err;
131         u32 data_underrun;
132         u32 delim_underrun;
133 };
134
135 struct ath_stats {
136         struct ath_interrupt_stats istats;
137         struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
138         struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
139 };
140
141 struct ath9k_debug {
142         int debug_mask;
143         struct dentry *debugfs_phy;
144         struct dentry *debugfs_debug;
145         struct dentry *debugfs_dma;
146         struct dentry *debugfs_interrupt;
147         struct dentry *debugfs_rcstat;
148         struct dentry *debugfs_wiphy;
149         struct dentry *debugfs_xmit;
150         struct ath_stats stats;
151 };
152
153 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
154 int ath9k_init_debug(struct ath_softc *sc);
155 void ath9k_exit_debug(struct ath_softc *sc);
156 int ath9k_debug_create_root(void);
157 void ath9k_debug_remove_root(void);
158 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
159 void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
160 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
161                        struct ath_buf *bf);
162 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
163                             int xretries, int retries, u8 per);
164
165 #else
166
167 static inline void DPRINTF(struct ath_softc *sc, int dbg_mask,
168                            const char *fmt, ...)
169 {
170 }
171
172 static inline int ath9k_init_debug(struct ath_softc *sc)
173 {
174         return 0;
175 }
176
177 static inline void ath9k_exit_debug(struct ath_softc *sc)
178 {
179 }
180
181 static inline int ath9k_debug_create_root(void)
182 {
183         return 0;
184 }
185
186 static inline void ath9k_debug_remove_root(void)
187 {
188 }
189
190 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
191                                             enum ath9k_int status)
192 {
193 }
194
195 static inline void ath_debug_stat_rc(struct ath_softc *sc,
196                                      struct sk_buff *skb)
197 {
198 }
199
200 static inline void ath_debug_stat_tx(struct ath_softc *sc,
201                                      struct ath_txq *txq,
202                                      struct ath_buf *bf)
203 {
204 }
205
206 static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
207                                           int xretries, int retries, u8 per)
208 {
209 }
210
211 #endif /* CONFIG_ATH9K_DEBUG */
212
213 #endif /* DEBUG_H */