debug.h 9.4 KB

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