debug.h 9.7 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
#include "dfs_debug.h"
23

S
Sujith 已提交
24 25
struct ath_txq;
struct ath_buf;
26
struct fft_sample_tlv;
S
Sujith 已提交
27

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

36 37 38 39 40 41 42 43 44
enum ath_reset_type {
	RESET_TYPE_BB_HANG,
	RESET_TYPE_BB_WATCHDOG,
	RESET_TYPE_FATAL_INT,
	RESET_TYPE_TX_ERROR,
	RESET_TYPE_TX_HANG,
	RESET_TYPE_PLL_HANG,
	RESET_TYPE_MAC_HANG,
	RESET_TYPE_BEACON_STUCK,
45
	RESET_TYPE_MCI,
46 47 48
	__RESET_TYPE_MAX
};

49
#ifdef CONFIG_ATH9K_DEBUGFS
S
Sujith 已提交
50 51 52 53 54

/**
 * struct ath_interrupt_stats - Contains statistics about interrupts
 * @total: Total no. of interrupts generated so far
 * @rxok: RX with no errors
55 56
 * @rxlp: RX with low priority RX
 * @rxhp: RX with high priority, uapsd only
S
Sujith 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
 * @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
73
 * @bb_watchdog: Baseband watchdog
74 75 76
 * @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
77
 * @local_timeout: Internal bus timeout.
78 79
 * @mci: MCI interrupt, specific to MCI based BTCOEX chipsets
 * @gen_timer: Generic hardware timer interrupt
S
Sujith 已提交
80 81 82 83
 */
struct ath_interrupt_stats {
	u32 total;
	u32 rxok;
84 85
	u32 rxlp;
	u32 rxhp;
S
Sujith 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
	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;
103
	u32 bb_watchdog;
104
	u32 tsfoor;
105
	u32 mci;
106
	u32 gen_timer;
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

	/* Sync-cause stats */
	u32 sync_cause_all;
	u32 sync_rtc_irq;
	u32 sync_mac_irq;
	u32 eeprom_illegal_access;
	u32 apb_timeout;
	u32 pci_mode_conflict;
	u32 host1_fatal;
	u32 host1_perr;
	u32 trcv_fifo_perr;
	u32 radm_cpl_ep;
	u32 radm_cpl_dllp_abort;
	u32 radm_cpl_tlp_abort;
	u32 radm_cpl_ecrc_err;
	u32 radm_cpl_timeout;
	u32 local_timeout;
	u32 pm_access;
	u32 mac_awake;
	u32 mac_asleep;
	u32 mac_sleep_access;
S
Sujith 已提交
128 129
};

130

S
Sujith 已提交
131 132
/**
 * struct ath_tx_stats - Statistics about TX
133 134 135 136
 * @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 已提交
137 138 139
 * @queued: Total MPDUs (non-aggr) queued
 * @completed: Total MPDUs (non-aggr) completed
 * @a_aggr: Total no. of aggregates queued
140 141
 * @a_queued_hw: Total AMPDUs queued to hardware
 * @a_queued_sw: Total AMPDUs queued to software queues
S
Sujith 已提交
142 143 144 145 146 147 148 149 150 151 152 153
 * @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
154 155 156
 * @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
B
Ben Greear 已提交
157
 * @txfailed:  Out-of-memory or other errors in xmit path.
S
Sujith 已提交
158 159
 */
struct ath_tx_stats {
160 161
	u32 tx_pkts_all;
	u32 tx_bytes_all;
S
Sujith 已提交
162 163
	u32 queued;
	u32 completed;
164
	u32 xretries;
S
Sujith 已提交
165
	u32 a_aggr;
166 167
	u32 a_queued_hw;
	u32 a_queued_sw;
S
Sujith 已提交
168 169 170 171 172 173 174 175 176
	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;
177 178 179
	u32 puttxbuf;
	u32 txstart;
	u32 txprocdesc;
B
Ben Greear 已提交
180
	u32 txfailed;
S
Sujith 已提交
181 182
};

183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
/*
 * Various utility macros to print TX/Queue counters.
 */
#define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
#define TXSTATS sc->debug.stats.txstats
#define PR(str, elem)							\
	do {								\
		len += snprintf(buf + len, size - len,			\
				"%s%13u%11u%10u%10u\n", str,		\
				TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,	\
				TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,	\
				TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,	\
				TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \
	} while(0)

B
Ben Greear 已提交
198 199
#define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++)

S
Sujith 已提交
200 201
/**
 * struct ath_rx_stats - RX Statistics
202 203 204 205
 * @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 已提交
206 207 208 209 210 211 212 213 214 215
 * @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
B
Ben Greear 已提交
216 217 218 219 220 221
 * @rx_len_err:  No. of frames discarded due to bad length.
 * @rx_oom_err:  No. of frames dropped due to OOM issues.
 * @rx_rate_err:  No. of frames dropped due to rate errors.
 * @rx_too_many_frags_err:  Frames dropped due to too-many-frags received.
 * @rx_beacons:  No. of beacons received.
 * @rx_frags:  No. of rx-fragements received.
S
Sujith 已提交
222 223
 */
struct ath_rx_stats {
224 225
	u32 rx_pkts_all;
	u32 rx_bytes_all;
S
Sujith 已提交
226 227 228 229 230 231 232 233
	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];
B
Ben Greear 已提交
234 235 236 237 238 239
	u32 rx_len_err;
	u32 rx_oom_err;
	u32 rx_rate_err;
	u32 rx_too_many_frags_err;
	u32 rx_beacons;
	u32 rx_frags;
S
Sujith 已提交
240 241
};

S
Sujith 已提交
242 243
struct ath_stats {
	struct ath_interrupt_stats istats;
244
	struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
S
Sujith 已提交
245
	struct ath_rx_stats rxstats;
246
	struct ath_dfs_stats dfs_stats;
247
	u32 reset[__RESET_TYPE_MAX];
S
Sujith 已提交
248 249
};

250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
#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;
269 270
		u32 ba_low;
		u32 ba_high;
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
	} 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 已提交
289 290
struct ath9k_debug {
	struct dentry *debugfs_phy;
291
	u32 regidx;
S
Sujith 已提交
292
	struct ath_stats stats;
293
#ifdef CONFIG_ATH9K_MAC_DEBUG
294 295 296 297 298
	spinlock_t samp_lock;
	struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES];
	u8 sampidx;
	u8 tsidx;
	u8 rsidx;
299
#endif
S
Sujith 已提交
300 301
};

302 303
int ath9k_init_debug(struct ath_hw *ah);

S
Sujith 已提交
304
void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
305
void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
306 307
		       struct ath_tx_status *ts, struct ath_txq *txq,
		       unsigned int flags);
308
void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
309 310 311 312 313 314 315 316
int ath9k_get_et_sset_count(struct ieee80211_hw *hw,
			    struct ieee80211_vif *vif, int sset);
void ath9k_get_et_stats(struct ieee80211_hw *hw,
			struct ieee80211_vif *vif,
			struct ethtool_stats *stats, u64 *data);
void ath9k_get_et_strings(struct ieee80211_hw *hw,
			  struct ieee80211_vif *vif,
			  u32 sset, u8 *data);
317 318 319 320 321 322 323 324
void ath9k_sta_add_debugfs(struct ieee80211_hw *hw,
			   struct ieee80211_vif *vif,
			   struct ieee80211_sta *sta,
			   struct dentry *dir);
void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw,
			      struct ieee80211_vif *vif,
			      struct ieee80211_sta *sta,
			      struct dentry *dir);
325 326 327 328

void ath_debug_send_fft_sample(struct ath_softc *sc,
			       struct fft_sample_tlv *fft_sample);

S
Sujith 已提交
329 330
#else

B
Ben Greear 已提交
331 332
#define RX_STAT_INC(c) /* NOP */

333
static inline int ath9k_init_debug(struct ath_hw *ah)
S
Sujith 已提交
334 335 336 337 338 339 340 341 342
{
	return 0;
}

static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
					    enum ath9k_int status)
{
}

S
Sujith 已提交
343
static inline void ath_debug_stat_tx(struct ath_softc *sc,
344
				     struct ath_buf *bf,
345
				     struct ath_tx_status *ts,
346 347
				     struct ath_txq *txq,
				     unsigned int flags)
S
Sujith 已提交
348 349 350
{
}

S
Sujith 已提交
351
static inline void ath_debug_stat_rx(struct ath_softc *sc,
352
				     struct ath_rx_status *rs)
S
Sujith 已提交
353 354 355
{
}

356
#endif /* CONFIG_ATH9K_DEBUGFS */
S
Sujith 已提交
357

358 359 360 361 362 363 364 365 366 367 368 369 370
#ifdef CONFIG_ATH9K_MAC_DEBUG

void ath9k_debug_samp_bb_mac(struct ath_softc *sc);

#else

static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
{
}

#endif


S
Sujith 已提交
371
#endif /* DEBUG_H */