debug.h 4.6 KB
Newer Older
S
Sujith 已提交
1
/*
2
 * Copyright (c) 2008-2009 Atheros Communications Inc.
S
Sujith 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef DEBUG_H
#define DEBUG_H

20
#include "hw.h"
21
#include "rc.h"
22

S
Sujith 已提交
23 24 25
struct ath_txq;
struct ath_buf;

26
#ifdef CONFIG_ATH9K_DEBUGFS
S
Sujith 已提交
27 28 29 30 31
#define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
#else
#define TX_STAT_INC(q, c) do { } while (0)
#endif

32
#ifdef CONFIG_ATH9K_DEBUGFS
S
Sujith 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

/**
 * struct ath_interrupt_stats - Contains statistics about interrupts
 * @total: Total no. of interrupts generated so far
 * @rxok: RX with no errors
 * @rxeol: RX with no more RXDESC available
 * @rxorn: RX FIFO overrun
 * @txok: TX completed at the requested rate
 * @txurn: TX FIFO underrun
 * @mib: MIB regs reaching its threshold
 * @rxphyerr: RX with phy errors
 * @rx_keycache_miss: RX with key cache misses
 * @swba: Software Beacon Alert
 * @bmiss: Beacon Miss
 * @bnr: Beacon Not Ready
 * @cst: Carrier Sense TImeout
 * @gtt: Global TX Timeout
 * @tim: RX beacon TIM occurrence
 * @cabend: RX End of CAB traffic
 * @dtimsync: DTIM sync lossage
 * @dtim: RX Beacon with DTIM
 */
struct ath_interrupt_stats {
	u32 total;
	u32 rxok;
	u32 rxeol;
	u32 rxorn;
	u32 txok;
	u32 txeol;
	u32 txurn;
	u32 mib;
	u32 rxphyerr;
	u32 rx_keycache_miss;
	u32 swba;
	u32 bmiss;
	u32 bnr;
	u32 cst;
	u32 gtt;
	u32 tim;
	u32 cabend;
	u32 dtimsync;
	u32 dtim;
};

77
struct ath_rc_stats {
S
Sujith 已提交
78 79 80
	u32 success;
	u32 retries;
	u32 xretries;
S
Sujith 已提交
81
	u8 per;
S
Sujith 已提交
82 83
};

S
Sujith 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
/**
 * struct ath_tx_stats - Statistics about TX
 * @queued: Total MPDUs (non-aggr) queued
 * @completed: Total MPDUs (non-aggr) completed
 * @a_aggr: Total no. of aggregates queued
 * @a_queued: Total AMPDUs queued
 * @a_completed: Total AMPDUs completed
 * @a_retries: No. of AMPDUs retried (SW)
 * @a_xretries: No. of AMPDUs dropped due to xretries
 * @fifo_underrun: FIFO underrun occurrences
	Valid only for:
		- non-aggregate condition.
		- first packet of aggregate.
 * @xtxop: No. of frames filtered because of TXOP limit
 * @timer_exp: Transmit timer expiry
 * @desc_cfg_err: Descriptor configuration errors
 * @data_urn: TX data underrun errors
 * @delim_urn: TX delimiter underrun errors
 */
struct ath_tx_stats {
	u32 queued;
	u32 completed;
	u32 a_aggr;
	u32 a_queued;
	u32 a_completed;
	u32 a_retries;
	u32 a_xretries;
	u32 fifo_underrun;
	u32 xtxop;
	u32 timer_exp;
	u32 desc_cfg_err;
	u32 data_underrun;
	u32 delim_underrun;
};

S
Sujith 已提交
119 120
struct ath_stats {
	struct ath_interrupt_stats istats;
121
	struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
S
Sujith 已提交
122
	struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
S
Sujith 已提交
123 124 125 126
};

struct ath9k_debug {
	struct dentry *debugfs_phy;
J
Jeff Hansen 已提交
127
	struct dentry *debugfs_debug;
S
Sujith 已提交
128 129 130
	struct dentry *debugfs_dma;
	struct dentry *debugfs_interrupt;
	struct dentry *debugfs_rcstat;
131
	struct dentry *debugfs_wiphy;
S
Sujith 已提交
132
	struct dentry *debugfs_xmit;
S
Sujith 已提交
133 134 135
	struct ath_stats stats;
};

136 137 138
int ath9k_init_debug(struct ath_hw *ah);
void ath9k_exit_debug(struct ath_hw *ah);

139 140
int ath9k_debug_create_root(void);
void ath9k_debug_remove_root(void);
S
Sujith 已提交
141
void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
142
void ath_debug_stat_rc(struct ath_softc *sc, int final_rate);
S
Sujith 已提交
143 144
void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
		       struct ath_buf *bf);
S
Sujith 已提交
145
void ath_debug_stat_retries(struct ath_softc *sc, int rix,
S
Sujith 已提交
146
			    int xretries, int retries, u8 per);
S
Sujith 已提交
147 148 149

#else

150
static inline int ath9k_init_debug(struct ath_hw *ah)
S
Sujith 已提交
151 152 153 154
{
	return 0;
}

155
static inline void ath9k_exit_debug(struct ath_hw *ah)
S
Sujith 已提交
156 157 158
{
}

159 160 161 162 163 164 165 166 167
static inline int ath9k_debug_create_root(void)
{
	return 0;
}

static inline void ath9k_debug_remove_root(void)
{
}

S
Sujith 已提交
168 169 170 171 172 173
static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
					    enum ath9k_int status)
{
}

static inline void ath_debug_stat_rc(struct ath_softc *sc,
174
				     int final_rate)
S
Sujith 已提交
175 176 177
{
}

S
Sujith 已提交
178 179 180 181 182 183
static inline void ath_debug_stat_tx(struct ath_softc *sc,
				     struct ath_txq *txq,
				     struct ath_buf *bf)
{
}

S
Sujith 已提交
184
static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix,
S
Sujith 已提交
185
					  int xretries, int retries, u8 per)
S
Sujith 已提交
186 187 188
{
}

189
#endif /* CONFIG_ATH9K_DEBUGFS */
S
Sujith 已提交
190 191

#endif /* DEBUG_H */