1203c4805SLuis R. Rodriguez /* 25b68138eSSujith Manoharan * Copyright (c) 2008-2011 Atheros Communications Inc. 3203c4805SLuis R. Rodriguez * 4203c4805SLuis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 5203c4805SLuis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 6203c4805SLuis R. Rodriguez * copyright notice and this permission notice appear in all copies. 7203c4805SLuis R. Rodriguez * 8203c4805SLuis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9203c4805SLuis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10203c4805SLuis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11203c4805SLuis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12203c4805SLuis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13203c4805SLuis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14203c4805SLuis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15203c4805SLuis R. Rodriguez */ 16203c4805SLuis R. Rodriguez 17203c4805SLuis R. Rodriguez #ifndef DEBUG_H 18203c4805SLuis R. Rodriguez #define DEBUG_H 19203c4805SLuis R. Rodriguez 204d6b228dSLuis R. Rodriguez #include "hw.h" 2129942bc1SZefir Kurtisi #include "dfs_debug.h" 224d6b228dSLuis R. Rodriguez 23fec247c0SSujith struct ath_txq; 24fec247c0SSujith struct ath_buf; 25e93d083fSSimon Wunderlich struct fft_sample_tlv; 26fec247c0SSujith 27a830df07SFelix Fietkau #ifdef CONFIG_ATH9K_DEBUGFS 28fec247c0SSujith #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++ 29350e2dcbSSujith Manoharan #define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++) 30030d6294SFelix Fietkau #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++ 313fbaf4c5SSujith Manoharan #define ANT_STAT_INC(i, c) sc->debug.stats.ant_stats[i].c++ 32e3d52914SSujith Manoharan #define ANT_LNA_INC(i, c) sc->debug.stats.ant_stats[i].lna_recv_cnt[c]++; 33fec247c0SSujith #else 34fec247c0SSujith #define TX_STAT_INC(q, c) do { } while (0) 35350e2dcbSSujith Manoharan #define RX_STAT_INC(c) 36030d6294SFelix Fietkau #define RESET_STAT_INC(sc, type) do { } while (0) 373fbaf4c5SSujith Manoharan #define ANT_STAT_INC(i, c) do { } while (0) 383fbaf4c5SSujith Manoharan #define ANT_LNA_INC(i, c) do { } while (0) 39fec247c0SSujith #endif 40fec247c0SSujith 41124b979bSRajkumar Manoharan enum ath_reset_type { 42124b979bSRajkumar Manoharan RESET_TYPE_BB_HANG, 43124b979bSRajkumar Manoharan RESET_TYPE_BB_WATCHDOG, 44124b979bSRajkumar Manoharan RESET_TYPE_FATAL_INT, 45124b979bSRajkumar Manoharan RESET_TYPE_TX_ERROR, 46071aa9a8SSujith Manoharan RESET_TYPE_TX_GTT, 47124b979bSRajkumar Manoharan RESET_TYPE_TX_HANG, 48124b979bSRajkumar Manoharan RESET_TYPE_PLL_HANG, 49124b979bSRajkumar Manoharan RESET_TYPE_MAC_HANG, 50124b979bSRajkumar Manoharan RESET_TYPE_BEACON_STUCK, 51b88083bfSRajkumar Manoharan RESET_TYPE_MCI, 527b8aaeadSFelix Fietkau RESET_TYPE_CALIBRATION, 53124b979bSRajkumar Manoharan __RESET_TYPE_MAX 54124b979bSRajkumar Manoharan }; 55124b979bSRajkumar Manoharan 56a830df07SFelix Fietkau #ifdef CONFIG_ATH9K_DEBUGFS 57203c4805SLuis R. Rodriguez 58203c4805SLuis R. Rodriguez /** 59203c4805SLuis R. Rodriguez * struct ath_interrupt_stats - Contains statistics about interrupts 60203c4805SLuis R. Rodriguez * @total: Total no. of interrupts generated so far 61203c4805SLuis R. Rodriguez * @rxok: RX with no errors 62a9616f41SLuis R. Rodriguez * @rxlp: RX with low priority RX 63a9616f41SLuis R. Rodriguez * @rxhp: RX with high priority, uapsd only 64203c4805SLuis R. Rodriguez * @rxeol: RX with no more RXDESC available 65203c4805SLuis R. Rodriguez * @rxorn: RX FIFO overrun 66203c4805SLuis R. Rodriguez * @txok: TX completed at the requested rate 67203c4805SLuis R. Rodriguez * @txurn: TX FIFO underrun 68203c4805SLuis R. Rodriguez * @mib: MIB regs reaching its threshold 69203c4805SLuis R. Rodriguez * @rxphyerr: RX with phy errors 70203c4805SLuis R. Rodriguez * @rx_keycache_miss: RX with key cache misses 71203c4805SLuis R. Rodriguez * @swba: Software Beacon Alert 72203c4805SLuis R. Rodriguez * @bmiss: Beacon Miss 73203c4805SLuis R. Rodriguez * @bnr: Beacon Not Ready 74203c4805SLuis R. Rodriguez * @cst: Carrier Sense TImeout 75203c4805SLuis R. Rodriguez * @gtt: Global TX Timeout 76203c4805SLuis R. Rodriguez * @tim: RX beacon TIM occurrence 77203c4805SLuis R. Rodriguez * @cabend: RX End of CAB traffic 78203c4805SLuis R. Rodriguez * @dtimsync: DTIM sync lossage 79203c4805SLuis R. Rodriguez * @dtim: RX Beacon with DTIM 8008578b8fSLuis R. Rodriguez * @bb_watchdog: Baseband watchdog 816dde1aabSMohammed Shafi Shajakhan * @tsfoor: TSF out of range, indicates that the corrected TSF received 826dde1aabSMohammed Shafi Shajakhan * from a beacon differs from the PCU's internal TSF by more than a 836dde1aabSMohammed Shafi Shajakhan * (programmable) threshold 84462e58f2SBen Greear * @local_timeout: Internal bus timeout. 85c9e6e980SMohammed Shafi Shajakhan * @mci: MCI interrupt, specific to MCI based BTCOEX chipsets 86c9e6e980SMohammed Shafi Shajakhan * @gen_timer: Generic hardware timer interrupt 87203c4805SLuis R. Rodriguez */ 88203c4805SLuis R. Rodriguez struct ath_interrupt_stats { 89203c4805SLuis R. Rodriguez u32 total; 90203c4805SLuis R. Rodriguez u32 rxok; 91a9616f41SLuis R. Rodriguez u32 rxlp; 92a9616f41SLuis R. Rodriguez u32 rxhp; 93203c4805SLuis R. Rodriguez u32 rxeol; 94203c4805SLuis R. Rodriguez u32 rxorn; 95203c4805SLuis R. Rodriguez u32 txok; 96203c4805SLuis R. Rodriguez u32 txeol; 97203c4805SLuis R. Rodriguez u32 txurn; 98203c4805SLuis R. Rodriguez u32 mib; 99203c4805SLuis R. Rodriguez u32 rxphyerr; 100203c4805SLuis R. Rodriguez u32 rx_keycache_miss; 101203c4805SLuis R. Rodriguez u32 swba; 102203c4805SLuis R. Rodriguez u32 bmiss; 103203c4805SLuis R. Rodriguez u32 bnr; 104203c4805SLuis R. Rodriguez u32 cst; 105203c4805SLuis R. Rodriguez u32 gtt; 106203c4805SLuis R. Rodriguez u32 tim; 107203c4805SLuis R. Rodriguez u32 cabend; 108203c4805SLuis R. Rodriguez u32 dtimsync; 109203c4805SLuis R. Rodriguez u32 dtim; 11008578b8fSLuis R. Rodriguez u32 bb_watchdog; 1116dde1aabSMohammed Shafi Shajakhan u32 tsfoor; 11297ba515aSSujith Manoharan u32 mci; 113c9e6e980SMohammed Shafi Shajakhan u32 gen_timer; 114462e58f2SBen Greear 115462e58f2SBen Greear /* Sync-cause stats */ 116462e58f2SBen Greear u32 sync_cause_all; 117462e58f2SBen Greear u32 sync_rtc_irq; 118462e58f2SBen Greear u32 sync_mac_irq; 119462e58f2SBen Greear u32 eeprom_illegal_access; 120462e58f2SBen Greear u32 apb_timeout; 121462e58f2SBen Greear u32 pci_mode_conflict; 122462e58f2SBen Greear u32 host1_fatal; 123462e58f2SBen Greear u32 host1_perr; 124462e58f2SBen Greear u32 trcv_fifo_perr; 125462e58f2SBen Greear u32 radm_cpl_ep; 126462e58f2SBen Greear u32 radm_cpl_dllp_abort; 127462e58f2SBen Greear u32 radm_cpl_tlp_abort; 128462e58f2SBen Greear u32 radm_cpl_ecrc_err; 129462e58f2SBen Greear u32 radm_cpl_timeout; 130462e58f2SBen Greear u32 local_timeout; 131462e58f2SBen Greear u32 pm_access; 132462e58f2SBen Greear u32 mac_awake; 133462e58f2SBen Greear u32 mac_asleep; 134462e58f2SBen Greear u32 mac_sleep_access; 135203c4805SLuis R. Rodriguez }; 136203c4805SLuis R. Rodriguez 137462e58f2SBen Greear 138fec247c0SSujith /** 139fec247c0SSujith * struct ath_tx_stats - Statistics about TX 14099c15bf5SBen Greear * @tx_pkts_all: No. of total frames transmitted, including ones that 14199c15bf5SBen Greear may have had errors. 14299c15bf5SBen Greear * @tx_bytes_all: No. of total bytes transmitted, including ones that 14399c15bf5SBen Greear may have had errors. 144fec247c0SSujith * @queued: Total MPDUs (non-aggr) queued 145fec247c0SSujith * @completed: Total MPDUs (non-aggr) completed 146fec247c0SSujith * @a_aggr: Total no. of aggregates queued 147bda8addaSBen Greear * @a_queued_hw: Total AMPDUs queued to hardware 148bda8addaSBen Greear * @a_queued_sw: Total AMPDUs queued to software queues 149fec247c0SSujith * @a_completed: Total AMPDUs completed 150fec247c0SSujith * @a_retries: No. of AMPDUs retried (SW) 151fec247c0SSujith * @a_xretries: No. of AMPDUs dropped due to xretries 1524d900389SBen Greear * @txerr_filtered: No. of frames with TXERR_FILT flag set. 153fec247c0SSujith * @fifo_underrun: FIFO underrun occurrences 154fec247c0SSujith Valid only for: 155fec247c0SSujith - non-aggregate condition. 156fec247c0SSujith - first packet of aggregate. 157fec247c0SSujith * @xtxop: No. of frames filtered because of TXOP limit 158fec247c0SSujith * @timer_exp: Transmit timer expiry 159fec247c0SSujith * @desc_cfg_err: Descriptor configuration errors 160fec247c0SSujith * @data_urn: TX data underrun errors 161fec247c0SSujith * @delim_urn: TX delimiter underrun errors 1622dac4fb9SBen Greear * @puttxbuf: Number of times hardware was given txbuf to write. 1632dac4fb9SBen Greear * @txstart: Number of times hardware was told to start tx. 1642dac4fb9SBen Greear * @txprocdesc: Number of times tx descriptor was processed 165a5a0bca1SBen Greear * @txfailed: Out-of-memory or other errors in xmit path. 166fec247c0SSujith */ 167fec247c0SSujith struct ath_tx_stats { 16899c15bf5SBen Greear u32 tx_pkts_all; 16999c15bf5SBen Greear u32 tx_bytes_all; 170fec247c0SSujith u32 queued; 171fec247c0SSujith u32 completed; 1725a6f78afSFelix Fietkau u32 xretries; 173fec247c0SSujith u32 a_aggr; 174bda8addaSBen Greear u32 a_queued_hw; 175bda8addaSBen Greear u32 a_queued_sw; 176fec247c0SSujith u32 a_completed; 177fec247c0SSujith u32 a_retries; 178fec247c0SSujith u32 a_xretries; 1794d900389SBen Greear u32 txerr_filtered; 180fec247c0SSujith u32 fifo_underrun; 181fec247c0SSujith u32 xtxop; 182fec247c0SSujith u32 timer_exp; 183fec247c0SSujith u32 desc_cfg_err; 184fec247c0SSujith u32 data_underrun; 185fec247c0SSujith u32 delim_underrun; 1862dac4fb9SBen Greear u32 puttxbuf; 1872dac4fb9SBen Greear u32 txstart; 1882dac4fb9SBen Greear u32 txprocdesc; 189a5a0bca1SBen Greear u32 txfailed; 190fec247c0SSujith }; 191fec247c0SSujith 19278ef731cSSujith Manoharan /* 19378ef731cSSujith Manoharan * Various utility macros to print TX/Queue counters. 19478ef731cSSujith Manoharan */ 19578ef731cSSujith Manoharan #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum 19678ef731cSSujith Manoharan #define TXSTATS sc->debug.stats.txstats 19778ef731cSSujith Manoharan #define PR(str, elem) \ 19878ef731cSSujith Manoharan do { \ 1995e88ba62SZefir Kurtisi len += scnprintf(buf + len, size - len, \ 20078ef731cSSujith Manoharan "%s%13u%11u%10u%10u\n", str, \ 20178ef731cSSujith Manoharan TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,\ 20278ef731cSSujith Manoharan TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,\ 20378ef731cSSujith Manoharan TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,\ 20478ef731cSSujith Manoharan TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \ 20578ef731cSSujith Manoharan } while(0) 20678ef731cSSujith Manoharan 207350e2dcbSSujith Manoharan struct ath_rx_rate_stats { 208350e2dcbSSujith Manoharan struct { 209350e2dcbSSujith Manoharan u32 ht20_cnt; 210350e2dcbSSujith Manoharan u32 ht40_cnt; 211350e2dcbSSujith Manoharan u32 sgi_cnt; 212350e2dcbSSujith Manoharan u32 lgi_cnt; 213350e2dcbSSujith Manoharan } ht_stats[24]; 214350e2dcbSSujith Manoharan 215350e2dcbSSujith Manoharan struct { 216350e2dcbSSujith Manoharan u32 ofdm_cnt; 217350e2dcbSSujith Manoharan } ofdm_stats[8]; 218350e2dcbSSujith Manoharan 219350e2dcbSSujith Manoharan struct { 220350e2dcbSSujith Manoharan u32 cck_lp_cnt; 221350e2dcbSSujith Manoharan u32 cck_sp_cnt; 222350e2dcbSSujith Manoharan } cck_stats[4]; 223350e2dcbSSujith Manoharan }; 22415072189SBen Greear 2253fbaf4c5SSujith Manoharan #define ANT_MAIN 0 2263fbaf4c5SSujith Manoharan #define ANT_ALT 1 2273fbaf4c5SSujith Manoharan 2283fbaf4c5SSujith Manoharan struct ath_antenna_stats { 2293fbaf4c5SSujith Manoharan u32 recv_cnt; 230e3d52914SSujith Manoharan u32 rssi_avg; 231e3d52914SSujith Manoharan u32 lna_recv_cnt[4]; 232e3d52914SSujith Manoharan u32 lna_attempt_cnt[4]; 2333fbaf4c5SSujith Manoharan }; 2343fbaf4c5SSujith Manoharan 235203c4805SLuis R. Rodriguez struct ath_stats { 236203c4805SLuis R. Rodriguez struct ath_interrupt_stats istats; 2374f7dc951SSujith Manoharan struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES]; 2381395d3f0SSujith struct ath_rx_stats rxstats; 23929942bc1SZefir Kurtisi struct ath_dfs_stats dfs_stats; 2403fbaf4c5SSujith Manoharan struct ath_antenna_stats ant_stats[2]; 241030d6294SFelix Fietkau u32 reset[__RESET_TYPE_MAX]; 242203c4805SLuis R. Rodriguez }; 243203c4805SLuis R. Rodriguez 244203c4805SLuis R. Rodriguez struct ath9k_debug { 245203c4805SLuis R. Rodriguez struct dentry *debugfs_phy; 2469bff0bc4SFelix Fietkau u32 regidx; 247203c4805SLuis R. Rodriguez struct ath_stats stats; 248203c4805SLuis R. Rodriguez }; 249203c4805SLuis R. Rodriguez 2504d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah); 251af690092SSujith Manoharan void ath9k_deinit_debug(struct ath_softc *sc); 2524d6b228dSLuis R. Rodriguez 253203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); 254066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 25555797b1aSFelix Fietkau struct ath_tx_status *ts, struct ath_txq *txq, 25655797b1aSFelix Fietkau unsigned int flags); 2578e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs); 258c175db87SSujith Manoharan int ath9k_get_et_sset_count(struct ieee80211_hw *hw, 259c175db87SSujith Manoharan struct ieee80211_vif *vif, int sset); 260c175db87SSujith Manoharan void ath9k_get_et_stats(struct ieee80211_hw *hw, 261c175db87SSujith Manoharan struct ieee80211_vif *vif, 262c175db87SSujith Manoharan struct ethtool_stats *stats, u64 *data); 263c175db87SSujith Manoharan void ath9k_get_et_strings(struct ieee80211_hw *hw, 264c175db87SSujith Manoharan struct ieee80211_vif *vif, 265c175db87SSujith Manoharan u32 sset, u8 *data); 266a145daf7SSujith Manoharan void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 267a145daf7SSujith Manoharan struct ieee80211_vif *vif, 268a145daf7SSujith Manoharan struct ieee80211_sta *sta, 269a145daf7SSujith Manoharan struct dentry *dir); 270e3d52914SSujith Manoharan void ath9k_debug_stat_ant(struct ath_softc *sc, 271e3d52914SSujith Manoharan struct ath_hw_antcomb_conf *div_ant_conf, 272e3d52914SSujith Manoharan int main_rssi_avg, int alt_rssi_avg); 2736a4d05dcSFelix Fietkau void ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause); 2746a4d05dcSFelix Fietkau 275203c4805SLuis R. Rodriguez #else 276203c4805SLuis R. Rodriguez 2774d6b228dSLuis R. Rodriguez static inline int ath9k_init_debug(struct ath_hw *ah) 278203c4805SLuis R. Rodriguez { 279203c4805SLuis R. Rodriguez return 0; 280203c4805SLuis R. Rodriguez } 281203c4805SLuis R. Rodriguez 282af690092SSujith Manoharan static inline void ath9k_deinit_debug(struct ath_softc *sc) 283af690092SSujith Manoharan { 284af690092SSujith Manoharan } 285203c4805SLuis R. Rodriguez static inline void ath_debug_stat_interrupt(struct ath_softc *sc, 286203c4805SLuis R. Rodriguez enum ath9k_int status) 287203c4805SLuis R. Rodriguez { 288203c4805SLuis R. Rodriguez } 289fec247c0SSujith static inline void ath_debug_stat_tx(struct ath_softc *sc, 29032ffb1f4SFelix Fietkau struct ath_buf *bf, 2913bf63e59SFelix Fietkau struct ath_tx_status *ts, 29255797b1aSFelix Fietkau struct ath_txq *txq, 29355797b1aSFelix Fietkau unsigned int flags) 294fec247c0SSujith { 295fec247c0SSujith } 2961395d3f0SSujith static inline void ath_debug_stat_rx(struct ath_softc *sc, 29732ffb1f4SFelix Fietkau struct ath_rx_status *rs) 2981395d3f0SSujith { 2991395d3f0SSujith } 300e3d52914SSujith Manoharan static inline void ath9k_debug_stat_ant(struct ath_softc *sc, 301e3d52914SSujith Manoharan struct ath_hw_antcomb_conf *div_ant_conf, 302e3d52914SSujith Manoharan int main_rssi_avg, int alt_rssi_avg) 303e3d52914SSujith Manoharan { 304e3d52914SSujith Manoharan 305e3d52914SSujith Manoharan } 3061395d3f0SSujith 3076a4d05dcSFelix Fietkau static inline void 3086a4d05dcSFelix Fietkau ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause) 3096a4d05dcSFelix Fietkau { 3106a4d05dcSFelix Fietkau } 3116a4d05dcSFelix Fietkau 312a830df07SFelix Fietkau #endif /* CONFIG_ATH9K_DEBUGFS */ 313203c4805SLuis R. Rodriguez 314350e2dcbSSujith Manoharan #ifdef CONFIG_ATH9K_STATION_STATISTICS 315350e2dcbSSujith Manoharan void ath_debug_rate_stats(struct ath_softc *sc, 316350e2dcbSSujith Manoharan struct ath_rx_status *rs, 317350e2dcbSSujith Manoharan struct sk_buff *skb); 318350e2dcbSSujith Manoharan #else 319350e2dcbSSujith Manoharan static inline void ath_debug_rate_stats(struct ath_softc *sc, 320350e2dcbSSujith Manoharan struct ath_rx_status *rs, 321350e2dcbSSujith Manoharan struct sk_buff *skb) 322350e2dcbSSujith Manoharan { 323350e2dcbSSujith Manoharan } 324350e2dcbSSujith Manoharan #endif /* CONFIG_ATH9K_STATION_STATISTICS */ 325350e2dcbSSujith Manoharan 326203c4805SLuis R. Rodriguez #endif /* DEBUG_H */ 327