mac80211: unify config_interface and bss_info_changed
[linux-2.6] / 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_ANY             = 0xffffffff
33 };
34
35 #define DBG_DEFAULT (ATH_DBG_FATAL)
36
37 #ifdef CONFIG_ATH9K_DEBUG
38
39 /**
40  * struct ath_interrupt_stats - Contains statistics about interrupts
41  * @total: Total no. of interrupts generated so far
42  * @rxok: RX with no errors
43  * @rxeol: RX with no more RXDESC available
44  * @rxorn: RX FIFO overrun
45  * @txok: TX completed at the requested rate
46  * @txurn: TX FIFO underrun
47  * @mib: MIB regs reaching its threshold
48  * @rxphyerr: RX with phy errors
49  * @rx_keycache_miss: RX with key cache misses
50  * @swba: Software Beacon Alert
51  * @bmiss: Beacon Miss
52  * @bnr: Beacon Not Ready
53  * @cst: Carrier Sense TImeout
54  * @gtt: Global TX Timeout
55  * @tim: RX beacon TIM occurrence
56  * @cabend: RX End of CAB traffic
57  * @dtimsync: DTIM sync lossage
58  * @dtim: RX Beacon with DTIM
59  */
60 struct ath_interrupt_stats {
61         u32 total;
62         u32 rxok;
63         u32 rxeol;
64         u32 rxorn;
65         u32 txok;
66         u32 txeol;
67         u32 txurn;
68         u32 mib;
69         u32 rxphyerr;
70         u32 rx_keycache_miss;
71         u32 swba;
72         u32 bmiss;
73         u32 bnr;
74         u32 cst;
75         u32 gtt;
76         u32 tim;
77         u32 cabend;
78         u32 dtimsync;
79         u32 dtim;
80 };
81
82 struct ath_legacy_rc_stats {
83         u32 success;
84 };
85
86 struct ath_11n_rc_stats {
87         u32 success;
88         u32 retries;
89         u32 xretries;
90         u8 per;
91 };
92
93 struct ath_stats {
94         struct ath_interrupt_stats istats;
95         struct ath_legacy_rc_stats legacy_rcstats[12];  /* max(11a,11b,11g) */
96         struct ath_11n_rc_stats n_rcstats[16];          /* 0..15 MCS rates */
97 };
98
99 struct ath9k_debug {
100         int debug_mask;
101         struct dentry *debugfs_phy;
102         struct dentry *debugfs_dma;
103         struct dentry *debugfs_interrupt;
104         struct dentry *debugfs_rcstat;
105         struct dentry *debugfs_wiphy;
106         struct ath_stats stats;
107 };
108
109 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
110 int ath9k_init_debug(struct ath_softc *sc);
111 void ath9k_exit_debug(struct ath_softc *sc);
112 int ath9k_debug_create_root(void);
113 void ath9k_debug_remove_root(void);
114 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
115 void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
116 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
117                             int xretries, int retries, u8 per);
118
119 #else
120
121 static inline void DPRINTF(struct ath_softc *sc, int dbg_mask,
122                            const char *fmt, ...)
123 {
124 }
125
126 static inline int ath9k_init_debug(struct ath_softc *sc)
127 {
128         return 0;
129 }
130
131 static inline void ath9k_exit_debug(struct ath_softc *sc)
132 {
133 }
134
135 static inline int ath9k_debug_create_root(void)
136 {
137         return 0;
138 }
139
140 static inline void ath9k_debug_remove_root(void)
141 {
142 }
143
144 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
145                                             enum ath9k_int status)
146 {
147 }
148
149 static inline void ath_debug_stat_rc(struct ath_softc *sc,
150                                      struct sk_buff *skb)
151 {
152 }
153
154 static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
155                                           int xretries, int retries, u8 per)
156 {
157 }
158
159 #endif /* CONFIG_ATH9K_DEBUG */
160
161 #endif /* DEBUG_H */