debug.h 6.9 KB
Newer Older
S
Sujith 已提交
1
/*
2
 * Copyright (c) 2008-2011 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

/**
 * struct ath_interrupt_stats - Contains statistics about interrupts
 * @total: Total no. of interrupts generated so far
 * @rxok: RX with no errors
38 39
 * @rxlp: RX with low priority RX
 * @rxhp: RX with high priority, uapsd only
S
Sujith 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
 * @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
56
 * @bb_watchdog: Baseband watchdog
57 58 59
 * @tsfoor: TSF out of range, indicates that the corrected TSF received
 * from a beacon differs from the PCU's internal TSF by more than a
 * (programmable) threshold
S
Sujith 已提交
60 61 62 63
 */
struct ath_interrupt_stats {
	u32 total;
	u32 rxok;
64 65
	u32 rxlp;
	u32 rxhp;
S
Sujith 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
	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;
83
	u32 bb_watchdog;
84
	u32 tsfoor;
S
Sujith 已提交
85 86
};

S
Sujith 已提交
87 88
/**
 * struct ath_tx_stats - Statistics about TX
89 90 91 92
 * @tx_pkts_all:  No. of total frames transmitted, including ones that
	may have had errors.
 * @tx_bytes_all:  No. of total bytes transmitted, including ones that
	may have had errors.
S
Sujith 已提交
93 94 95
 * @queued: Total MPDUs (non-aggr) queued
 * @completed: Total MPDUs (non-aggr) completed
 * @a_aggr: Total no. of aggregates queued
96 97
 * @a_queued_hw: Total AMPDUs queued to hardware
 * @a_queued_sw: Total AMPDUs queued to software queues
S
Sujith 已提交
98 99 100 101 102 103 104 105 106 107 108 109
 * @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
110 111 112
 * @puttxbuf: Number of times hardware was given txbuf to write.
 * @txstart:  Number of times hardware was told to start tx.
 * @txprocdesc:  Number of times tx descriptor was processed
S
Sujith 已提交
113 114
 */
struct ath_tx_stats {
115 116
	u32 tx_pkts_all;
	u32 tx_bytes_all;
S
Sujith 已提交
117 118
	u32 queued;
	u32 completed;
119
	u32 xretries;
S
Sujith 已提交
120
	u32 a_aggr;
121 122
	u32 a_queued_hw;
	u32 a_queued_sw;
S
Sujith 已提交
123 124 125 126 127 128 129 130 131
	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;
132 133 134
	u32 puttxbuf;
	u32 txstart;
	u32 txprocdesc;
S
Sujith 已提交
135 136
};

S
Sujith 已提交
137 138
/**
 * struct ath_rx_stats - RX Statistics
139 140 141 142
 * @rx_pkts_all:  No. of total frames received, including ones that
	may have had errors.
 * @rx_bytes_all:  No. of total bytes received, including ones that
	may have had errors.
S
Sujith 已提交
143 144 145 146 147 148 149 150 151 152 153 154
 * @crc_err: No. of frames with incorrect CRC value
 * @decrypt_crc_err: No. of frames whose CRC check failed after
	decryption process completed
 * @phy_err: No. of frames whose reception failed because the PHY
	encountered an error
 * @mic_err: No. of frames with incorrect TKIP MIC verification failure
 * @pre_delim_crc_err: Pre-Frame delimiter CRC error detections
 * @post_delim_crc_err: Post-Frame delimiter CRC error detections
 * @decrypt_busy_err: Decryption interruptions counter
 * @phy_err_stats: Individual PHY error statistics
 */
struct ath_rx_stats {
155 156
	u32 rx_pkts_all;
	u32 rx_bytes_all;
S
Sujith 已提交
157 158 159 160 161 162 163 164
	u32 crc_err;
	u32 decrypt_crc_err;
	u32 phy_err;
	u32 mic_err;
	u32 pre_delim_crc_err;
	u32 post_delim_crc_err;
	u32 decrypt_busy_err;
	u32 phy_err_stats[ATH9K_PHYERR_MAX];
165 166 167 168 169 170 171
	int8_t rs_rssi_ctl0;
	int8_t rs_rssi_ctl1;
	int8_t rs_rssi_ctl2;
	int8_t rs_rssi_ext0;
	int8_t rs_rssi_ext1;
	int8_t rs_rssi_ext2;
	u8 rs_antenna;
S
Sujith 已提交
172 173
};

S
Sujith 已提交
174 175
struct ath_stats {
	struct ath_interrupt_stats istats;
S
Sujith 已提交
176
	struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
S
Sujith 已提交
177
	struct ath_rx_stats rxstats;
S
Sujith 已提交
178 179
};

180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
#define ATH_DBG_MAX_SAMPLES	10
struct ath_dbg_bb_mac_samp {
	u32 dma_dbg_reg_vals[ATH9K_NUM_DMA_DEBUG_REGS];
	u32 pcu_obs, pcu_cr, noise;
	struct {
		u64 jiffies;
		int8_t rssi_ctl0;
		int8_t rssi_ctl1;
		int8_t rssi_ctl2;
		int8_t rssi_ext0;
		int8_t rssi_ext1;
		int8_t rssi_ext2;
		int8_t rssi;
		bool isok;
		u8 rts_fail_cnt;
		u8 data_fail_cnt;
		u8 rateindex;
		u8 qid;
		u8 tid;
	} ts[ATH_DBG_MAX_SAMPLES];
	struct {
		u64 jiffies;
		int8_t rssi_ctl0;
		int8_t rssi_ctl1;
		int8_t rssi_ctl2;
		int8_t rssi_ext0;
		int8_t rssi_ext1;
		int8_t rssi_ext2;
		int8_t rssi;
		bool is_mybeacon;
		u8 antenna;
		u8 rate;
	} rs[ATH_DBG_MAX_SAMPLES];
	struct ath_cycle_counters cc;
	struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
};

S
Sujith 已提交
217 218
struct ath9k_debug {
	struct dentry *debugfs_phy;
219
	u32 regidx;
S
Sujith 已提交
220
	struct ath_stats stats;
221 222 223 224 225
	spinlock_t samp_lock;
	struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES];
	u8 sampidx;
	u8 tsidx;
	u8 rsidx;
S
Sujith 已提交
226 227
};

228 229
int ath9k_init_debug(struct ath_hw *ah);

230
void ath9k_debug_samp_bb_mac(struct ath_softc *sc);
S
Sujith 已提交
231
void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
232
void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
233
		       struct ath_tx_status *ts, struct ath_txq *txq);
234
void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
S
Sujith 已提交
235 236 237

#else

238
static inline int ath9k_init_debug(struct ath_hw *ah)
S
Sujith 已提交
239 240 241 242
{
	return 0;
}

243 244 245 246
static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
{
}

S
Sujith 已提交
247 248 249 250 251
static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
					    enum ath9k_int status)
{
}

S
Sujith 已提交
252
static inline void ath_debug_stat_tx(struct ath_softc *sc,
253
				     struct ath_buf *bf,
254 255
				     struct ath_tx_status *ts,
				     struct ath_txq *txq)
S
Sujith 已提交
256 257 258
{
}

S
Sujith 已提交
259
static inline void ath_debug_stat_rx(struct ath_softc *sc,
260
				     struct ath_rx_status *rs)
S
Sujith 已提交
261 262 263
{
}

264
#endif /* CONFIG_ATH9K_DEBUGFS */
S
Sujith 已提交
265 266

#endif /* DEBUG_H */