debug.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications Inc.
  3. *
  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.
  7. *
  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.
  15. */
  16. #ifndef DEBUG_H
  17. #define DEBUG_H
  18. #include "hw.h"
  19. #include "dfs_debug.h"
  20. struct ath_txq;
  21. struct ath_buf;
  22. struct fft_sample_tlv;
  23. #ifdef CONFIG_ATH9K_DEBUGFS
  24. #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
  25. #define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++)
  26. #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++
  27. #define ANT_STAT_INC(i, c) sc->debug.stats.ant_stats[i].c++
  28. #define ANT_LNA_INC(i, c) sc->debug.stats.ant_stats[i].lna_recv_cnt[c]++;
  29. #else
  30. #define TX_STAT_INC(q, c) do { } while (0)
  31. #define RX_STAT_INC(c)
  32. #define RESET_STAT_INC(sc, type) do { } while (0)
  33. #define ANT_STAT_INC(i, c) do { } while (0)
  34. #define ANT_LNA_INC(i, c) do { } while (0)
  35. #endif
  36. enum ath_reset_type {
  37. RESET_TYPE_BB_HANG,
  38. RESET_TYPE_BB_WATCHDOG,
  39. RESET_TYPE_FATAL_INT,
  40. RESET_TYPE_TX_ERROR,
  41. RESET_TYPE_TX_GTT,
  42. RESET_TYPE_TX_HANG,
  43. RESET_TYPE_PLL_HANG,
  44. RESET_TYPE_MAC_HANG,
  45. RESET_TYPE_BEACON_STUCK,
  46. RESET_TYPE_MCI,
  47. RESET_TYPE_CALIBRATION,
  48. RESET_TX_DMA_ERROR,
  49. RESET_RX_DMA_ERROR,
  50. __RESET_TYPE_MAX
  51. };
  52. #ifdef CONFIG_ATH9K_DEBUGFS
  53. /**
  54. * struct ath_interrupt_stats - Contains statistics about interrupts
  55. * @total: Total no. of interrupts generated so far
  56. * @rxok: RX with no errors
  57. * @rxlp: RX with low priority RX
  58. * @rxhp: RX with high priority, uapsd only
  59. * @rxeol: RX with no more RXDESC available
  60. * @rxorn: RX FIFO overrun
  61. * @txok: TX completed at the requested rate
  62. * @txurn: TX FIFO underrun
  63. * @mib: MIB regs reaching its threshold
  64. * @rxphyerr: RX with phy errors
  65. * @rx_keycache_miss: RX with key cache misses
  66. * @swba: Software Beacon Alert
  67. * @bmiss: Beacon Miss
  68. * @bnr: Beacon Not Ready
  69. * @cst: Carrier Sense TImeout
  70. * @gtt: Global TX Timeout
  71. * @tim: RX beacon TIM occurrence
  72. * @cabend: RX End of CAB traffic
  73. * @dtimsync: DTIM sync lossage
  74. * @dtim: RX Beacon with DTIM
  75. * @bb_watchdog: Baseband watchdog
  76. * @tsfoor: TSF out of range, indicates that the corrected TSF received
  77. * from a beacon differs from the PCU's internal TSF by more than a
  78. * (programmable) threshold
  79. * @local_timeout: Internal bus timeout.
  80. * @mci: MCI interrupt, specific to MCI based BTCOEX chipsets
  81. * @gen_timer: Generic hardware timer interrupt
  82. */
  83. struct ath_interrupt_stats {
  84. u32 total;
  85. u32 rxok;
  86. u32 rxlp;
  87. u32 rxhp;
  88. u32 rxeol;
  89. u32 rxorn;
  90. u32 txok;
  91. u32 txeol;
  92. u32 txurn;
  93. u32 mib;
  94. u32 rxphyerr;
  95. u32 rx_keycache_miss;
  96. u32 swba;
  97. u32 bmiss;
  98. u32 bnr;
  99. u32 cst;
  100. u32 gtt;
  101. u32 tim;
  102. u32 cabend;
  103. u32 dtimsync;
  104. u32 dtim;
  105. u32 bb_watchdog;
  106. u32 tsfoor;
  107. u32 mci;
  108. u32 gen_timer;
  109. /* Sync-cause stats */
  110. u32 sync_cause_all;
  111. u32 sync_rtc_irq;
  112. u32 sync_mac_irq;
  113. u32 eeprom_illegal_access;
  114. u32 apb_timeout;
  115. u32 pci_mode_conflict;
  116. u32 host1_fatal;
  117. u32 host1_perr;
  118. u32 trcv_fifo_perr;
  119. u32 radm_cpl_ep;
  120. u32 radm_cpl_dllp_abort;
  121. u32 radm_cpl_tlp_abort;
  122. u32 radm_cpl_ecrc_err;
  123. u32 radm_cpl_timeout;
  124. u32 local_timeout;
  125. u32 pm_access;
  126. u32 mac_awake;
  127. u32 mac_asleep;
  128. u32 mac_sleep_access;
  129. };
  130. /**
  131. * struct ath_tx_stats - Statistics about TX
  132. * @tx_pkts_all: No. of total frames transmitted, including ones that
  133. may have had errors.
  134. * @tx_bytes_all: No. of total bytes transmitted, including ones that
  135. may have had errors.
  136. * @queued: Total MPDUs (non-aggr) queued
  137. * @completed: Total MPDUs (non-aggr) completed
  138. * @a_aggr: Total no. of aggregates queued
  139. * @a_queued_hw: Total AMPDUs queued to hardware
  140. * @a_queued_sw: Total AMPDUs queued to software queues
  141. * @a_completed: Total AMPDUs completed
  142. * @a_retries: No. of AMPDUs retried (SW)
  143. * @a_xretries: No. of AMPDUs dropped due to xretries
  144. * @txerr_filtered: No. of frames with TXERR_FILT flag set.
  145. * @fifo_underrun: FIFO underrun occurrences
  146. Valid only for:
  147. - non-aggregate condition.
  148. - first packet of aggregate.
  149. * @xtxop: No. of frames filtered because of TXOP limit
  150. * @timer_exp: Transmit timer expiry
  151. * @desc_cfg_err: Descriptor configuration errors
  152. * @data_urn: TX data underrun errors
  153. * @delim_urn: TX delimiter underrun errors
  154. * @puttxbuf: Number of times hardware was given txbuf to write.
  155. * @txstart: Number of times hardware was told to start tx.
  156. * @txprocdesc: Number of times tx descriptor was processed
  157. * @txfailed: Out-of-memory or other errors in xmit path.
  158. */
  159. struct ath_tx_stats {
  160. u32 tx_pkts_all;
  161. u32 tx_bytes_all;
  162. u32 queued;
  163. u32 completed;
  164. u32 xretries;
  165. u32 a_aggr;
  166. u32 a_queued_hw;
  167. u32 a_queued_sw;
  168. u32 a_completed;
  169. u32 a_retries;
  170. u32 a_xretries;
  171. u32 txerr_filtered;
  172. u32 fifo_underrun;
  173. u32 xtxop;
  174. u32 timer_exp;
  175. u32 desc_cfg_err;
  176. u32 data_underrun;
  177. u32 delim_underrun;
  178. u32 puttxbuf;
  179. u32 txstart;
  180. u32 txprocdesc;
  181. u32 txfailed;
  182. };
  183. /*
  184. * Various utility macros to print TX/Queue counters.
  185. */
  186. #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
  187. #define TXSTATS sc->debug.stats.txstats
  188. #define PR(str, elem) \
  189. do { \
  190. seq_printf(file, "%s%13u%11u%10u%10u\n", str, \
  191. TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,\
  192. TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,\
  193. TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,\
  194. TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \
  195. } while(0)
  196. struct ath_rx_rate_stats {
  197. struct {
  198. u32 ht20_cnt;
  199. u32 ht40_cnt;
  200. u32 sgi_cnt;
  201. u32 lgi_cnt;
  202. } ht_stats[24];
  203. struct {
  204. u32 ofdm_cnt;
  205. } ofdm_stats[8];
  206. struct {
  207. u32 cck_lp_cnt;
  208. u32 cck_sp_cnt;
  209. } cck_stats[4];
  210. };
  211. #define ANT_MAIN 0
  212. #define ANT_ALT 1
  213. struct ath_antenna_stats {
  214. u32 recv_cnt;
  215. u32 rssi_avg;
  216. u32 lna_recv_cnt[4];
  217. u32 lna_attempt_cnt[4];
  218. };
  219. struct ath_stats {
  220. struct ath_interrupt_stats istats;
  221. struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
  222. struct ath_rx_stats rxstats;
  223. struct ath_dfs_stats dfs_stats;
  224. struct ath_antenna_stats ant_stats[2];
  225. u32 reset[__RESET_TYPE_MAX];
  226. };
  227. struct ath9k_debug {
  228. struct dentry *debugfs_phy;
  229. u32 regidx;
  230. struct ath_stats stats;
  231. };
  232. int ath9k_init_debug(struct ath_hw *ah);
  233. void ath9k_deinit_debug(struct ath_softc *sc);
  234. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
  235. void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
  236. struct ath_tx_status *ts, struct ath_txq *txq,
  237. unsigned int flags);
  238. void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
  239. int ath9k_get_et_sset_count(struct ieee80211_hw *hw,
  240. struct ieee80211_vif *vif, int sset);
  241. void ath9k_get_et_stats(struct ieee80211_hw *hw,
  242. struct ieee80211_vif *vif,
  243. struct ethtool_stats *stats, u64 *data);
  244. void ath9k_get_et_strings(struct ieee80211_hw *hw,
  245. struct ieee80211_vif *vif,
  246. u32 sset, u8 *data);
  247. void ath9k_sta_add_debugfs(struct ieee80211_hw *hw,
  248. struct ieee80211_vif *vif,
  249. struct ieee80211_sta *sta,
  250. struct dentry *dir);
  251. void ath9k_debug_stat_ant(struct ath_softc *sc,
  252. struct ath_hw_antcomb_conf *div_ant_conf,
  253. int main_rssi_avg, int alt_rssi_avg);
  254. void ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause);
  255. #else
  256. static inline int ath9k_init_debug(struct ath_hw *ah)
  257. {
  258. return 0;
  259. }
  260. static inline void ath9k_deinit_debug(struct ath_softc *sc)
  261. {
  262. }
  263. static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
  264. enum ath9k_int status)
  265. {
  266. }
  267. static inline void ath_debug_stat_tx(struct ath_softc *sc,
  268. struct ath_buf *bf,
  269. struct ath_tx_status *ts,
  270. struct ath_txq *txq,
  271. unsigned int flags)
  272. {
  273. }
  274. static inline void ath_debug_stat_rx(struct ath_softc *sc,
  275. struct ath_rx_status *rs)
  276. {
  277. }
  278. static inline void ath9k_debug_stat_ant(struct ath_softc *sc,
  279. struct ath_hw_antcomb_conf *div_ant_conf,
  280. int main_rssi_avg, int alt_rssi_avg)
  281. {
  282. }
  283. static inline void
  284. ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause)
  285. {
  286. }
  287. #endif /* CONFIG_ATH9K_DEBUGFS */
  288. #ifdef CONFIG_ATH9K_STATION_STATISTICS
  289. void ath_debug_rate_stats(struct ath_softc *sc,
  290. struct ath_rx_status *rs,
  291. struct sk_buff *skb);
  292. #else
  293. static inline void ath_debug_rate_stats(struct ath_softc *sc,
  294. struct ath_rx_status *rs,
  295. struct sk_buff *skb)
  296. {
  297. }
  298. #endif /* CONFIG_ATH9K_STATION_STATISTICS */
  299. #endif /* DEBUG_H */