2 * Copyright (c) 2008-2011 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include "dfs_debug.h"
26 struct fft_sample_tlv
;
28 #ifdef CONFIG_ATH9K_DEBUGFS
29 #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
30 #define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++)
31 #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++
32 #define ANT_STAT_INC(i, c) sc->debug.stats.ant_stats[i].c++
33 #define ANT_LNA_INC(i, c) sc->debug.stats.ant_stats[i].lna_recv_cnt[c]++;
35 #define TX_STAT_INC(q, c) do { } while (0)
36 #define RX_STAT_INC(c)
37 #define RESET_STAT_INC(sc, type) do { } while (0)
38 #define ANT_STAT_INC(i, c) do { } while (0)
39 #define ANT_LNA_INC(i, c) do { } while (0)
44 RESET_TYPE_BB_WATCHDOG
,
51 RESET_TYPE_BEACON_STUCK
,
56 #ifdef CONFIG_ATH9K_DEBUGFS
59 * struct ath_interrupt_stats - Contains statistics about interrupts
60 * @total: Total no. of interrupts generated so far
61 * @rxok: RX with no errors
62 * @rxlp: RX with low priority RX
63 * @rxhp: RX with high priority, uapsd only
64 * @rxeol: RX with no more RXDESC available
65 * @rxorn: RX FIFO overrun
66 * @txok: TX completed at the requested rate
67 * @txurn: TX FIFO underrun
68 * @mib: MIB regs reaching its threshold
69 * @rxphyerr: RX with phy errors
70 * @rx_keycache_miss: RX with key cache misses
71 * @swba: Software Beacon Alert
73 * @bnr: Beacon Not Ready
74 * @cst: Carrier Sense TImeout
75 * @gtt: Global TX Timeout
76 * @tim: RX beacon TIM occurrence
77 * @cabend: RX End of CAB traffic
78 * @dtimsync: DTIM sync lossage
79 * @dtim: RX Beacon with DTIM
80 * @bb_watchdog: Baseband watchdog
81 * @tsfoor: TSF out of range, indicates that the corrected TSF received
82 * from a beacon differs from the PCU's internal TSF by more than a
83 * (programmable) threshold
84 * @local_timeout: Internal bus timeout.
85 * @mci: MCI interrupt, specific to MCI based BTCOEX chipsets
86 * @gen_timer: Generic hardware timer interrupt
88 struct ath_interrupt_stats
{
100 u32 rx_keycache_miss
;
115 /* Sync-cause stats */
119 u32 eeprom_illegal_access
;
121 u32 pci_mode_conflict
;
126 u32 radm_cpl_dllp_abort
;
127 u32 radm_cpl_tlp_abort
;
128 u32 radm_cpl_ecrc_err
;
129 u32 radm_cpl_timeout
;
134 u32 mac_sleep_access
;
139 * struct ath_tx_stats - Statistics about TX
140 * @tx_pkts_all: No. of total frames transmitted, including ones that
142 * @tx_bytes_all: No. of total bytes transmitted, including ones that
144 * @queued: Total MPDUs (non-aggr) queued
145 * @completed: Total MPDUs (non-aggr) completed
146 * @a_aggr: Total no. of aggregates queued
147 * @a_queued_hw: Total AMPDUs queued to hardware
148 * @a_queued_sw: Total AMPDUs queued to software queues
149 * @a_completed: Total AMPDUs completed
150 * @a_retries: No. of AMPDUs retried (SW)
151 * @a_xretries: No. of AMPDUs dropped due to xretries
152 * @txerr_filtered: No. of frames with TXERR_FILT flag set.
153 * @fifo_underrun: FIFO underrun occurrences
155 - non-aggregate condition.
156 - first packet of aggregate.
157 * @xtxop: No. of frames filtered because of TXOP limit
158 * @timer_exp: Transmit timer expiry
159 * @desc_cfg_err: Descriptor configuration errors
160 * @data_urn: TX data underrun errors
161 * @delim_urn: TX delimiter underrun errors
162 * @puttxbuf: Number of times hardware was given txbuf to write.
163 * @txstart: Number of times hardware was told to start tx.
164 * @txprocdesc: Number of times tx descriptor was processed
165 * @txfailed: Out-of-memory or other errors in xmit path.
167 struct ath_tx_stats
{
193 * Various utility macros to print TX/Queue counters.
195 #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
196 #define TXSTATS sc->debug.stats.txstats
197 #define PR(str, elem) \
199 len += scnprintf(buf + len, size - len, \
200 "%s%13u%11u%10u%10u\n", str, \
201 TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,\
202 TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,\
203 TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,\
204 TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \
207 struct ath_rx_rate_stats
{
226 * struct ath_rx_stats - RX Statistics
227 * @rx_pkts_all: No. of total frames received, including ones that
229 * @rx_bytes_all: No. of total bytes received, including ones that
231 * @crc_err: No. of frames with incorrect CRC value
232 * @decrypt_crc_err: No. of frames whose CRC check failed after
233 decryption process completed
234 * @phy_err: No. of frames whose reception failed because the PHY
236 * @mic_err: No. of frames with incorrect TKIP MIC verification failure
237 * @pre_delim_crc_err: Pre-Frame delimiter CRC error detections
238 * @post_delim_crc_err: Post-Frame delimiter CRC error detections
239 * @decrypt_busy_err: Decryption interruptions counter
240 * @phy_err_stats: Individual PHY error statistics
241 * @rx_len_err: No. of frames discarded due to bad length.
242 * @rx_oom_err: No. of frames dropped due to OOM issues.
243 * @rx_rate_err: No. of frames dropped due to rate errors.
244 * @rx_too_many_frags_err: Frames dropped due to too-many-frags received.
245 * @rx_beacons: No. of beacons received.
246 * @rx_frags: No. of rx-fragements received.
247 * @rx_spectral: No of spectral packets received.
249 struct ath_rx_stats
{
256 u32 pre_delim_crc_err
;
257 u32 post_delim_crc_err
;
258 u32 decrypt_busy_err
;
259 u32 phy_err_stats
[ATH9K_PHYERR_MAX
];
263 u32 rx_too_many_frags_err
;
272 struct ath_antenna_stats
{
276 u32 lna_attempt_cnt
[4];
280 struct ath_interrupt_stats istats
;
281 struct ath_tx_stats txstats
[ATH9K_NUM_TX_QUEUES
];
282 struct ath_rx_stats rxstats
;
283 struct ath_dfs_stats dfs_stats
;
284 struct ath_antenna_stats ant_stats
[2];
285 u32 reset
[__RESET_TYPE_MAX
];
289 struct dentry
*debugfs_phy
;
291 struct ath_stats stats
;
294 int ath9k_init_debug(struct ath_hw
*ah
);
295 void ath9k_deinit_debug(struct ath_softc
*sc
);
297 void ath_debug_stat_interrupt(struct ath_softc
*sc
, enum ath9k_int status
);
298 void ath_debug_stat_tx(struct ath_softc
*sc
, struct ath_buf
*bf
,
299 struct ath_tx_status
*ts
, struct ath_txq
*txq
,
301 void ath_debug_stat_rx(struct ath_softc
*sc
, struct ath_rx_status
*rs
);
302 int ath9k_get_et_sset_count(struct ieee80211_hw
*hw
,
303 struct ieee80211_vif
*vif
, int sset
);
304 void ath9k_get_et_stats(struct ieee80211_hw
*hw
,
305 struct ieee80211_vif
*vif
,
306 struct ethtool_stats
*stats
, u64
*data
);
307 void ath9k_get_et_strings(struct ieee80211_hw
*hw
,
308 struct ieee80211_vif
*vif
,
310 void ath9k_sta_add_debugfs(struct ieee80211_hw
*hw
,
311 struct ieee80211_vif
*vif
,
312 struct ieee80211_sta
*sta
,
314 void ath9k_debug_stat_ant(struct ath_softc
*sc
,
315 struct ath_hw_antcomb_conf
*div_ant_conf
,
316 int main_rssi_avg
, int alt_rssi_avg
);
317 void ath9k_debug_sync_cause(struct ath_softc
*sc
, u32 sync_cause
);
321 static inline int ath9k_init_debug(struct ath_hw
*ah
)
326 static inline void ath9k_deinit_debug(struct ath_softc
*sc
)
329 static inline void ath_debug_stat_interrupt(struct ath_softc
*sc
,
330 enum ath9k_int status
)
333 static inline void ath_debug_stat_tx(struct ath_softc
*sc
,
335 struct ath_tx_status
*ts
,
340 static inline void ath_debug_stat_rx(struct ath_softc
*sc
,
341 struct ath_rx_status
*rs
)
344 static inline void ath9k_debug_stat_ant(struct ath_softc
*sc
,
345 struct ath_hw_antcomb_conf
*div_ant_conf
,
346 int main_rssi_avg
, int alt_rssi_avg
)
352 ath9k_debug_sync_cause(struct ath_softc
*sc
, u32 sync_cause
)
356 #endif /* CONFIG_ATH9K_DEBUGFS */
358 #ifdef CONFIG_ATH9K_STATION_STATISTICS
359 void ath_debug_rate_stats(struct ath_softc
*sc
,
360 struct ath_rx_status
*rs
,
361 struct sk_buff
*skb
);
363 static inline void ath_debug_rate_stats(struct ath_softc
*sc
,
364 struct ath_rx_status
*rs
,
368 #endif /* CONFIG_ATH9K_STATION_STATISTICS */