blob: 749e85d5755158ad81c0cc7826da66ffe2ece6fc [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"
21
Sujithfec247c2009-07-27 12:08:16 +053022struct ath_txq;
23struct ath_buf;
24
25#ifdef CONFIG_ATH9K_DEBUG
26#define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
27#else
28#define TX_STAT_INC(q, c) do { } while (0)
29#endif
30
Sujith394cf0a2009-02-09 13:26:54 +053031#ifdef CONFIG_ATH9K_DEBUG
32
33/**
34 * struct ath_interrupt_stats - Contains statistics about interrupts
35 * @total: Total no. of interrupts generated so far
36 * @rxok: RX with no errors
37 * @rxeol: RX with no more RXDESC available
38 * @rxorn: RX FIFO overrun
39 * @txok: TX completed at the requested rate
40 * @txurn: TX FIFO underrun
41 * @mib: MIB regs reaching its threshold
42 * @rxphyerr: RX with phy errors
43 * @rx_keycache_miss: RX with key cache misses
44 * @swba: Software Beacon Alert
45 * @bmiss: Beacon Miss
46 * @bnr: Beacon Not Ready
47 * @cst: Carrier Sense TImeout
48 * @gtt: Global TX Timeout
49 * @tim: RX beacon TIM occurrence
50 * @cabend: RX End of CAB traffic
51 * @dtimsync: DTIM sync lossage
52 * @dtim: RX Beacon with DTIM
53 */
54struct ath_interrupt_stats {
55 u32 total;
56 u32 rxok;
57 u32 rxeol;
58 u32 rxorn;
59 u32 txok;
60 u32 txeol;
61 u32 txurn;
62 u32 mib;
63 u32 rxphyerr;
64 u32 rx_keycache_miss;
65 u32 swba;
66 u32 bmiss;
67 u32 bnr;
68 u32 cst;
69 u32 gtt;
70 u32 tim;
71 u32 cabend;
72 u32 dtimsync;
73 u32 dtim;
74};
75
Jeff Hansenbedf0872009-05-27 12:48:28 +000076struct ath_rc_stats {
Sujith394cf0a2009-02-09 13:26:54 +053077 u32 success;
78 u32 retries;
79 u32 xretries;
Sujith9e712792009-02-20 15:13:20 +053080 u8 per;
Sujith394cf0a2009-02-09 13:26:54 +053081};
82
Sujithfec247c2009-07-27 12:08:16 +053083/**
84 * struct ath_tx_stats - Statistics about TX
85 * @queued: Total MPDUs (non-aggr) queued
86 * @completed: Total MPDUs (non-aggr) completed
87 * @a_aggr: Total no. of aggregates queued
88 * @a_queued: Total AMPDUs queued
89 * @a_completed: Total AMPDUs completed
90 * @a_retries: No. of AMPDUs retried (SW)
91 * @a_xretries: No. of AMPDUs dropped due to xretries
92 * @fifo_underrun: FIFO underrun occurrences
93 Valid only for:
94 - non-aggregate condition.
95 - first packet of aggregate.
96 * @xtxop: No. of frames filtered because of TXOP limit
97 * @timer_exp: Transmit timer expiry
98 * @desc_cfg_err: Descriptor configuration errors
99 * @data_urn: TX data underrun errors
100 * @delim_urn: TX delimiter underrun errors
101 */
102struct ath_tx_stats {
103 u32 queued;
104 u32 completed;
105 u32 a_aggr;
106 u32 a_queued;
107 u32 a_completed;
108 u32 a_retries;
109 u32 a_xretries;
110 u32 fifo_underrun;
111 u32 xtxop;
112 u32 timer_exp;
113 u32 desc_cfg_err;
114 u32 data_underrun;
115 u32 delim_underrun;
116};
117
Sujith394cf0a2009-02-09 13:26:54 +0530118struct ath_stats {
119 struct ath_interrupt_stats istats;
Jeff Hansenbedf0872009-05-27 12:48:28 +0000120 struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
Sujithfec247c2009-07-27 12:08:16 +0530121 struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
Sujith394cf0a2009-02-09 13:26:54 +0530122};
123
124struct ath9k_debug {
Sujith394cf0a2009-02-09 13:26:54 +0530125 struct dentry *debugfs_phy;
Jeff Hansen24939282009-05-27 12:48:29 +0000126 struct dentry *debugfs_debug;
Sujith394cf0a2009-02-09 13:26:54 +0530127 struct dentry *debugfs_dma;
128 struct dentry *debugfs_interrupt;
129 struct dentry *debugfs_rcstat;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200130 struct dentry *debugfs_wiphy;
Sujithfec247c2009-07-27 12:08:16 +0530131 struct dentry *debugfs_xmit;
Sujith394cf0a2009-02-09 13:26:54 +0530132 struct ath_stats stats;
133};
134
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700135int ath9k_init_debug(struct ath_hw *ah);
136void ath9k_exit_debug(struct ath_hw *ah);
137
Gabor Juhos19d8bc22009-03-05 16:55:18 +0100138int ath9k_debug_create_root(void);
139void ath9k_debug_remove_root(void);
Sujith394cf0a2009-02-09 13:26:54 +0530140void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
141void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
Sujithfec247c2009-07-27 12:08:16 +0530142void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
143 struct ath_buf *bf);
Sujith394cf0a2009-02-09 13:26:54 +0530144void ath_debug_stat_retries(struct ath_softc *sc, int rix,
Sujith9e712792009-02-20 15:13:20 +0530145 int xretries, int retries, u8 per);
Sujith394cf0a2009-02-09 13:26:54 +0530146
147#else
148
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700149static inline int ath9k_init_debug(struct ath_hw *ah)
Sujith394cf0a2009-02-09 13:26:54 +0530150{
151 return 0;
152}
153
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700154static inline void ath9k_exit_debug(struct ath_hw *ah)
Sujith394cf0a2009-02-09 13:26:54 +0530155{
156}
157
Gabor Juhos19d8bc22009-03-05 16:55:18 +0100158static inline int ath9k_debug_create_root(void)
159{
160 return 0;
161}
162
163static inline void ath9k_debug_remove_root(void)
164{
165}
166
Sujith394cf0a2009-02-09 13:26:54 +0530167static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
168 enum ath9k_int status)
169{
170}
171
172static inline void ath_debug_stat_rc(struct ath_softc *sc,
173 struct sk_buff *skb)
174{
175}
176
Sujithfec247c2009-07-27 12:08:16 +0530177static inline void ath_debug_stat_tx(struct ath_softc *sc,
178 struct ath_txq *txq,
179 struct ath_buf *bf)
180{
181}
182
Sujith394cf0a2009-02-09 13:26:54 +0530183static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
Sujith9e712792009-02-20 15:13:20 +0530184 int xretries, int retries, u8 per)
Sujith394cf0a2009-02-09 13:26:54 +0530185{
186}
187
188#endif /* CONFIG_ATH9K_DEBUG */
189
190#endif /* DEBUG_H */