162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (c) 2008-2011 Atheros Communications Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 562306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 662306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 962306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1062306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1162306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1262306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1362306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1462306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifndef DEBUG_H 1862306a36Sopenharmony_ci#define DEBUG_H 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#include "hw.h" 2162306a36Sopenharmony_ci#include "dfs_debug.h" 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_cistruct ath_txq; 2462306a36Sopenharmony_cistruct ath_buf; 2562306a36Sopenharmony_cistruct fft_sample_tlv; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_DEBUGFS 2862306a36Sopenharmony_ci#define TX_STAT_INC(sc, q, c) do { (sc)->debug.stats.txstats[q].c++; } while (0) 2962306a36Sopenharmony_ci#define RX_STAT_INC(sc, c) do { (sc)->debug.stats.rxstats.c++; } while (0) 3062306a36Sopenharmony_ci#define RESET_STAT_INC(sc, type) do { (sc)->debug.stats.reset[type]++; } while (0) 3162306a36Sopenharmony_ci#define ANT_STAT_INC(sc, i, c) do { (sc)->debug.stats.ant_stats[i].c++; } while (0) 3262306a36Sopenharmony_ci#define ANT_LNA_INC(sc, i, c) do { (sc)->debug.stats.ant_stats[i].lna_recv_cnt[c]++; } while (0) 3362306a36Sopenharmony_ci#else 3462306a36Sopenharmony_ci#define TX_STAT_INC(sc, q, c) do { (void)(sc); } while (0) 3562306a36Sopenharmony_ci#define RX_STAT_INC(sc, c) do { (void)(sc); } while (0) 3662306a36Sopenharmony_ci#define RESET_STAT_INC(sc, type) do { (void)(sc); } while (0) 3762306a36Sopenharmony_ci#define ANT_STAT_INC(sc, i, c) do { (void)(sc); } while (0) 3862306a36Sopenharmony_ci#define ANT_LNA_INC(sc, i, c) do { (void)(sc); } while (0) 3962306a36Sopenharmony_ci#endif 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cienum ath_reset_type { 4262306a36Sopenharmony_ci RESET_TYPE_USER, 4362306a36Sopenharmony_ci RESET_TYPE_BB_HANG, 4462306a36Sopenharmony_ci RESET_TYPE_BB_WATCHDOG, 4562306a36Sopenharmony_ci RESET_TYPE_FATAL_INT, 4662306a36Sopenharmony_ci RESET_TYPE_TX_ERROR, 4762306a36Sopenharmony_ci RESET_TYPE_TX_GTT, 4862306a36Sopenharmony_ci RESET_TYPE_TX_HANG, 4962306a36Sopenharmony_ci RESET_TYPE_PLL_HANG, 5062306a36Sopenharmony_ci RESET_TYPE_MAC_HANG, 5162306a36Sopenharmony_ci RESET_TYPE_BEACON_STUCK, 5262306a36Sopenharmony_ci RESET_TYPE_MCI, 5362306a36Sopenharmony_ci RESET_TYPE_CALIBRATION, 5462306a36Sopenharmony_ci RESET_TX_DMA_ERROR, 5562306a36Sopenharmony_ci RESET_RX_DMA_ERROR, 5662306a36Sopenharmony_ci __RESET_TYPE_MAX 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_DEBUGFS 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/** 6262306a36Sopenharmony_ci * struct ath_interrupt_stats - Contains statistics about interrupts 6362306a36Sopenharmony_ci * @total: Total no. of interrupts generated so far 6462306a36Sopenharmony_ci * @rxok: RX with no errors 6562306a36Sopenharmony_ci * @rxlp: RX with low priority RX 6662306a36Sopenharmony_ci * @rxhp: RX with high priority, uapsd only 6762306a36Sopenharmony_ci * @rxeol: RX with no more RXDESC available 6862306a36Sopenharmony_ci * @rxorn: RX FIFO overrun 6962306a36Sopenharmony_ci * @txok: TX completed at the requested rate 7062306a36Sopenharmony_ci * @txurn: TX FIFO underrun 7162306a36Sopenharmony_ci * @mib: MIB regs reaching its threshold 7262306a36Sopenharmony_ci * @rxphyerr: RX with phy errors 7362306a36Sopenharmony_ci * @rx_keycache_miss: RX with key cache misses 7462306a36Sopenharmony_ci * @swba: Software Beacon Alert 7562306a36Sopenharmony_ci * @bmiss: Beacon Miss 7662306a36Sopenharmony_ci * @bnr: Beacon Not Ready 7762306a36Sopenharmony_ci * @cst: Carrier Sense TImeout 7862306a36Sopenharmony_ci * @gtt: Global TX Timeout 7962306a36Sopenharmony_ci * @tim: RX beacon TIM occurrence 8062306a36Sopenharmony_ci * @cabend: RX End of CAB traffic 8162306a36Sopenharmony_ci * @dtimsync: DTIM sync lossage 8262306a36Sopenharmony_ci * @dtim: RX Beacon with DTIM 8362306a36Sopenharmony_ci * @bb_watchdog: Baseband watchdog 8462306a36Sopenharmony_ci * @tsfoor: TSF out of range, indicates that the corrected TSF received 8562306a36Sopenharmony_ci * from a beacon differs from the PCU's internal TSF by more than a 8662306a36Sopenharmony_ci * (programmable) threshold 8762306a36Sopenharmony_ci * @local_timeout: Internal bus timeout. 8862306a36Sopenharmony_ci * @mci: MCI interrupt, specific to MCI based BTCOEX chipsets 8962306a36Sopenharmony_ci * @gen_timer: Generic hardware timer interrupt 9062306a36Sopenharmony_ci */ 9162306a36Sopenharmony_cistruct ath_interrupt_stats { 9262306a36Sopenharmony_ci u32 total; 9362306a36Sopenharmony_ci u32 rxok; 9462306a36Sopenharmony_ci u32 rxlp; 9562306a36Sopenharmony_ci u32 rxhp; 9662306a36Sopenharmony_ci u32 rxeol; 9762306a36Sopenharmony_ci u32 rxorn; 9862306a36Sopenharmony_ci u32 txok; 9962306a36Sopenharmony_ci u32 txeol; 10062306a36Sopenharmony_ci u32 txurn; 10162306a36Sopenharmony_ci u32 mib; 10262306a36Sopenharmony_ci u32 rxphyerr; 10362306a36Sopenharmony_ci u32 rx_keycache_miss; 10462306a36Sopenharmony_ci u32 swba; 10562306a36Sopenharmony_ci u32 bmiss; 10662306a36Sopenharmony_ci u32 bnr; 10762306a36Sopenharmony_ci u32 cst; 10862306a36Sopenharmony_ci u32 gtt; 10962306a36Sopenharmony_ci u32 tim; 11062306a36Sopenharmony_ci u32 cabend; 11162306a36Sopenharmony_ci u32 dtimsync; 11262306a36Sopenharmony_ci u32 dtim; 11362306a36Sopenharmony_ci u32 bb_watchdog; 11462306a36Sopenharmony_ci u32 tsfoor; 11562306a36Sopenharmony_ci u32 mci; 11662306a36Sopenharmony_ci u32 gen_timer; 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci /* Sync-cause stats */ 11962306a36Sopenharmony_ci u32 sync_cause_all; 12062306a36Sopenharmony_ci u32 sync_rtc_irq; 12162306a36Sopenharmony_ci u32 sync_mac_irq; 12262306a36Sopenharmony_ci u32 eeprom_illegal_access; 12362306a36Sopenharmony_ci u32 apb_timeout; 12462306a36Sopenharmony_ci u32 pci_mode_conflict; 12562306a36Sopenharmony_ci u32 host1_fatal; 12662306a36Sopenharmony_ci u32 host1_perr; 12762306a36Sopenharmony_ci u32 trcv_fifo_perr; 12862306a36Sopenharmony_ci u32 radm_cpl_ep; 12962306a36Sopenharmony_ci u32 radm_cpl_dllp_abort; 13062306a36Sopenharmony_ci u32 radm_cpl_tlp_abort; 13162306a36Sopenharmony_ci u32 radm_cpl_ecrc_err; 13262306a36Sopenharmony_ci u32 radm_cpl_timeout; 13362306a36Sopenharmony_ci u32 local_timeout; 13462306a36Sopenharmony_ci u32 pm_access; 13562306a36Sopenharmony_ci u32 mac_awake; 13662306a36Sopenharmony_ci u32 mac_asleep; 13762306a36Sopenharmony_ci u32 mac_sleep_access; 13862306a36Sopenharmony_ci}; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci/** 14262306a36Sopenharmony_ci * struct ath_tx_stats - Statistics about TX 14362306a36Sopenharmony_ci * @tx_pkts_all: No. of total frames transmitted, including ones that 14462306a36Sopenharmony_ci may have had errors. 14562306a36Sopenharmony_ci * @tx_bytes_all: No. of total bytes transmitted, including ones that 14662306a36Sopenharmony_ci may have had errors. 14762306a36Sopenharmony_ci * @queued: Total MPDUs (non-aggr) queued 14862306a36Sopenharmony_ci * @completed: Total MPDUs (non-aggr) completed 14962306a36Sopenharmony_ci * @a_aggr: Total no. of aggregates queued 15062306a36Sopenharmony_ci * @a_queued_hw: Total AMPDUs queued to hardware 15162306a36Sopenharmony_ci * @a_completed: Total AMPDUs completed 15262306a36Sopenharmony_ci * @a_retries: No. of AMPDUs retried (SW) 15362306a36Sopenharmony_ci * @a_xretries: No. of AMPDUs dropped due to xretries 15462306a36Sopenharmony_ci * @txerr_filtered: No. of frames with TXERR_FILT flag set. 15562306a36Sopenharmony_ci * @fifo_underrun: FIFO underrun occurrences 15662306a36Sopenharmony_ci Valid only for: 15762306a36Sopenharmony_ci - non-aggregate condition. 15862306a36Sopenharmony_ci - first packet of aggregate. 15962306a36Sopenharmony_ci * @xtxop: No. of frames filtered because of TXOP limit 16062306a36Sopenharmony_ci * @timer_exp: Transmit timer expiry 16162306a36Sopenharmony_ci * @desc_cfg_err: Descriptor configuration errors 16262306a36Sopenharmony_ci * @data_urn: TX data underrun errors 16362306a36Sopenharmony_ci * @delim_urn: TX delimiter underrun errors 16462306a36Sopenharmony_ci * @puttxbuf: Number of times hardware was given txbuf to write. 16562306a36Sopenharmony_ci * @txstart: Number of times hardware was told to start tx. 16662306a36Sopenharmony_ci * @txprocdesc: Number of times tx descriptor was processed 16762306a36Sopenharmony_ci * @txfailed: Out-of-memory or other errors in xmit path. 16862306a36Sopenharmony_ci */ 16962306a36Sopenharmony_cistruct ath_tx_stats { 17062306a36Sopenharmony_ci u32 tx_pkts_all; 17162306a36Sopenharmony_ci u32 tx_bytes_all; 17262306a36Sopenharmony_ci u32 queued; 17362306a36Sopenharmony_ci u32 completed; 17462306a36Sopenharmony_ci u32 xretries; 17562306a36Sopenharmony_ci u32 a_aggr; 17662306a36Sopenharmony_ci u32 a_queued_hw; 17762306a36Sopenharmony_ci u32 a_completed; 17862306a36Sopenharmony_ci u32 a_retries; 17962306a36Sopenharmony_ci u32 a_xretries; 18062306a36Sopenharmony_ci u32 txerr_filtered; 18162306a36Sopenharmony_ci u32 fifo_underrun; 18262306a36Sopenharmony_ci u32 xtxop; 18362306a36Sopenharmony_ci u32 timer_exp; 18462306a36Sopenharmony_ci u32 desc_cfg_err; 18562306a36Sopenharmony_ci u32 data_underrun; 18662306a36Sopenharmony_ci u32 delim_underrun; 18762306a36Sopenharmony_ci u32 puttxbuf; 18862306a36Sopenharmony_ci u32 txstart; 18962306a36Sopenharmony_ci u32 txprocdesc; 19062306a36Sopenharmony_ci u32 txfailed; 19162306a36Sopenharmony_ci}; 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci/* 19462306a36Sopenharmony_ci * Various utility macros to print TX/Queue counters. 19562306a36Sopenharmony_ci */ 19662306a36Sopenharmony_ci#define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum 19762306a36Sopenharmony_ci#define TXSTATS sc->debug.stats.txstats 19862306a36Sopenharmony_ci#define PR(str, elem) \ 19962306a36Sopenharmony_ci do { \ 20062306a36Sopenharmony_ci seq_printf(file, "%s%13u%11u%10u%10u\n", str, \ 20162306a36Sopenharmony_ci TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,\ 20262306a36Sopenharmony_ci TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,\ 20362306a36Sopenharmony_ci TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,\ 20462306a36Sopenharmony_ci TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \ 20562306a36Sopenharmony_ci } while(0) 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_cistruct ath_rx_rate_stats { 20862306a36Sopenharmony_ci struct { 20962306a36Sopenharmony_ci u32 ht20_cnt; 21062306a36Sopenharmony_ci u32 ht40_cnt; 21162306a36Sopenharmony_ci u32 sgi_cnt; 21262306a36Sopenharmony_ci u32 lgi_cnt; 21362306a36Sopenharmony_ci } ht_stats[24]; 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci struct { 21662306a36Sopenharmony_ci u32 ofdm_cnt; 21762306a36Sopenharmony_ci } ofdm_stats[8]; 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci struct { 22062306a36Sopenharmony_ci u32 cck_lp_cnt; 22162306a36Sopenharmony_ci u32 cck_sp_cnt; 22262306a36Sopenharmony_ci } cck_stats[4]; 22362306a36Sopenharmony_ci}; 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_cistruct ath_airtime_stats { 22662306a36Sopenharmony_ci u32 rx_airtime; 22762306a36Sopenharmony_ci u32 tx_airtime; 22862306a36Sopenharmony_ci}; 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci#define ANT_MAIN 0 23162306a36Sopenharmony_ci#define ANT_ALT 1 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_cistruct ath_antenna_stats { 23462306a36Sopenharmony_ci u32 recv_cnt; 23562306a36Sopenharmony_ci u32 rssi_avg; 23662306a36Sopenharmony_ci u32 lna_recv_cnt[4]; 23762306a36Sopenharmony_ci u32 lna_attempt_cnt[4]; 23862306a36Sopenharmony_ci}; 23962306a36Sopenharmony_ci 24062306a36Sopenharmony_cistruct ath_stats { 24162306a36Sopenharmony_ci struct ath_interrupt_stats istats; 24262306a36Sopenharmony_ci struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES]; 24362306a36Sopenharmony_ci struct ath_rx_stats rxstats; 24462306a36Sopenharmony_ci struct ath_dfs_stats dfs_stats; 24562306a36Sopenharmony_ci struct ath_antenna_stats ant_stats[2]; 24662306a36Sopenharmony_ci u32 reset[__RESET_TYPE_MAX]; 24762306a36Sopenharmony_ci}; 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_cistruct ath9k_debug { 25062306a36Sopenharmony_ci struct dentry *debugfs_phy; 25162306a36Sopenharmony_ci u32 regidx; 25262306a36Sopenharmony_ci struct ath_stats stats; 25362306a36Sopenharmony_ci}; 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ciint ath9k_init_debug(struct ath_hw *ah); 25662306a36Sopenharmony_civoid ath9k_deinit_debug(struct ath_softc *sc); 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_civoid ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); 25962306a36Sopenharmony_civoid ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 26062306a36Sopenharmony_ci struct ath_tx_status *ts, struct ath_txq *txq, 26162306a36Sopenharmony_ci unsigned int flags); 26262306a36Sopenharmony_civoid ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs); 26362306a36Sopenharmony_ciint ath9k_get_et_sset_count(struct ieee80211_hw *hw, 26462306a36Sopenharmony_ci struct ieee80211_vif *vif, int sset); 26562306a36Sopenharmony_civoid ath9k_get_et_stats(struct ieee80211_hw *hw, 26662306a36Sopenharmony_ci struct ieee80211_vif *vif, 26762306a36Sopenharmony_ci struct ethtool_stats *stats, u64 *data); 26862306a36Sopenharmony_civoid ath9k_get_et_strings(struct ieee80211_hw *hw, 26962306a36Sopenharmony_ci struct ieee80211_vif *vif, 27062306a36Sopenharmony_ci u32 sset, u8 *data); 27162306a36Sopenharmony_civoid ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 27262306a36Sopenharmony_ci struct ieee80211_vif *vif, 27362306a36Sopenharmony_ci struct ieee80211_sta *sta, 27462306a36Sopenharmony_ci struct dentry *dir); 27562306a36Sopenharmony_civoid ath9k_debug_stat_ant(struct ath_softc *sc, 27662306a36Sopenharmony_ci struct ath_hw_antcomb_conf *div_ant_conf, 27762306a36Sopenharmony_ci int main_rssi_avg, int alt_rssi_avg); 27862306a36Sopenharmony_civoid ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause); 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci#else 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_cistatic inline int ath9k_init_debug(struct ath_hw *ah) 28362306a36Sopenharmony_ci{ 28462306a36Sopenharmony_ci return 0; 28562306a36Sopenharmony_ci} 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_cistatic inline void ath9k_deinit_debug(struct ath_softc *sc) 28862306a36Sopenharmony_ci{ 28962306a36Sopenharmony_ci} 29062306a36Sopenharmony_cistatic inline void ath_debug_stat_interrupt(struct ath_softc *sc, 29162306a36Sopenharmony_ci enum ath9k_int status) 29262306a36Sopenharmony_ci{ 29362306a36Sopenharmony_ci} 29462306a36Sopenharmony_cistatic inline void ath_debug_stat_tx(struct ath_softc *sc, 29562306a36Sopenharmony_ci struct ath_buf *bf, 29662306a36Sopenharmony_ci struct ath_tx_status *ts, 29762306a36Sopenharmony_ci struct ath_txq *txq, 29862306a36Sopenharmony_ci unsigned int flags) 29962306a36Sopenharmony_ci{ 30062306a36Sopenharmony_ci} 30162306a36Sopenharmony_cistatic inline void ath_debug_stat_rx(struct ath_softc *sc, 30262306a36Sopenharmony_ci struct ath_rx_status *rs) 30362306a36Sopenharmony_ci{ 30462306a36Sopenharmony_ci} 30562306a36Sopenharmony_cistatic inline void ath9k_debug_stat_ant(struct ath_softc *sc, 30662306a36Sopenharmony_ci struct ath_hw_antcomb_conf *div_ant_conf, 30762306a36Sopenharmony_ci int main_rssi_avg, int alt_rssi_avg) 30862306a36Sopenharmony_ci{ 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci} 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_cistatic inline void 31362306a36Sopenharmony_ciath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause) 31462306a36Sopenharmony_ci{ 31562306a36Sopenharmony_ci} 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ci#endif /* CONFIG_ATH9K_DEBUGFS */ 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_STATION_STATISTICS 32062306a36Sopenharmony_civoid ath_debug_rate_stats(struct ath_softc *sc, 32162306a36Sopenharmony_ci struct ath_rx_status *rs, 32262306a36Sopenharmony_ci struct sk_buff *skb); 32362306a36Sopenharmony_ci#else 32462306a36Sopenharmony_cistatic inline void ath_debug_rate_stats(struct ath_softc *sc, 32562306a36Sopenharmony_ci struct ath_rx_status *rs, 32662306a36Sopenharmony_ci struct sk_buff *skb) 32762306a36Sopenharmony_ci{ 32862306a36Sopenharmony_ci} 32962306a36Sopenharmony_ci#endif /* CONFIG_ATH9K_STATION_STATISTICS */ 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci#endif /* DEBUG_H */ 332