debug.h 8.8 KB

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