debug.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /* SPDX-License-Identifier: ISC */
  2. /*
  3. * Copyright (c) 2005-2011 Atheros Communications Inc.
  4. * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
  5. * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  6. */
  7. #ifndef _DEBUG_H_
  8. #define _DEBUG_H_
  9. #include <linux/types.h>
  10. #include "trace.h"
  11. enum ath10k_debug_mask {
  12. ATH10K_DBG_PCI = 0x00000001,
  13. ATH10K_DBG_WMI = 0x00000002,
  14. ATH10K_DBG_HTC = 0x00000004,
  15. ATH10K_DBG_HTT = 0x00000008,
  16. ATH10K_DBG_MAC = 0x00000010,
  17. ATH10K_DBG_BOOT = 0x00000020,
  18. ATH10K_DBG_PCI_DUMP = 0x00000040,
  19. ATH10K_DBG_HTT_DUMP = 0x00000080,
  20. ATH10K_DBG_MGMT = 0x00000100,
  21. ATH10K_DBG_DATA = 0x00000200,
  22. ATH10K_DBG_BMI = 0x00000400,
  23. ATH10K_DBG_REGULATORY = 0x00000800,
  24. ATH10K_DBG_TESTMODE = 0x00001000,
  25. ATH10K_DBG_WMI_PRINT = 0x00002000,
  26. ATH10K_DBG_PCI_PS = 0x00004000,
  27. ATH10K_DBG_AHB = 0x00008000,
  28. ATH10K_DBG_SDIO = 0x00010000,
  29. ATH10K_DBG_SDIO_DUMP = 0x00020000,
  30. ATH10K_DBG_USB = 0x00040000,
  31. ATH10K_DBG_USB_BULK = 0x00080000,
  32. ATH10K_DBG_SNOC = 0x00100000,
  33. ATH10K_DBG_QMI = 0x00200000,
  34. ATH10K_DBG_STA = 0x00400000,
  35. ATH10K_DBG_ANY = 0xffffffff,
  36. };
  37. enum ath10k_pktlog_filter {
  38. ATH10K_PKTLOG_RX = 0x000000001,
  39. ATH10K_PKTLOG_TX = 0x000000002,
  40. ATH10K_PKTLOG_RCFIND = 0x000000004,
  41. ATH10K_PKTLOG_RCUPDATE = 0x000000008,
  42. ATH10K_PKTLOG_DBG_PRINT = 0x000000010,
  43. ATH10K_PKTLOG_PEER_STATS = 0x000000040,
  44. ATH10K_PKTLOG_ANY = 0x00000005f,
  45. };
  46. enum ath10k_dbg_aggr_mode {
  47. ATH10K_DBG_AGGR_MODE_AUTO,
  48. ATH10K_DBG_AGGR_MODE_MANUAL,
  49. ATH10K_DBG_AGGR_MODE_MAX,
  50. };
  51. /* Types of packet log events */
  52. enum ath_pktlog_type {
  53. ATH_PKTLOG_TYPE_TX_CTRL = 1,
  54. ATH_PKTLOG_TYPE_TX_STAT,
  55. };
  56. struct ath10k_pktlog_hdr {
  57. __le16 flags;
  58. __le16 missed_cnt;
  59. __le16 log_type; /* Type of log information foll this header */
  60. __le16 size; /* Size of variable length log information in bytes */
  61. __le32 timestamp;
  62. u8 payload[];
  63. } __packed;
  64. /* FIXME: How to calculate the buffer size sanely? */
  65. #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024)
  66. #define ATH10K_TX_POWER_MAX_VAL 70
  67. #define ATH10K_TX_POWER_MIN_VAL 0
  68. extern unsigned int ath10k_debug_mask;
  69. __printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...);
  70. __printf(2, 3) void ath10k_err(struct ath10k *ar, const char *fmt, ...);
  71. __printf(2, 3) void ath10k_warn(struct ath10k *ar, const char *fmt, ...);
  72. void ath10k_debug_print_hwfw_info(struct ath10k *ar);
  73. void ath10k_debug_print_board_info(struct ath10k *ar);
  74. void ath10k_debug_print_boot_info(struct ath10k *ar);
  75. void ath10k_print_driver_info(struct ath10k *ar);
  76. #ifdef CONFIG_ATH10K_DEBUGFS
  77. int ath10k_debug_start(struct ath10k *ar);
  78. void ath10k_debug_stop(struct ath10k *ar);
  79. int ath10k_debug_create(struct ath10k *ar);
  80. void ath10k_debug_destroy(struct ath10k *ar);
  81. int ath10k_debug_register(struct ath10k *ar);
  82. void ath10k_debug_unregister(struct ath10k *ar);
  83. void ath10k_debug_fw_stats_process(struct ath10k *ar, struct sk_buff *skb);
  84. void ath10k_debug_tpc_stats_process(struct ath10k *ar,
  85. struct ath10k_tpc_stats *tpc_stats);
  86. void
  87. ath10k_debug_tpc_stats_final_process(struct ath10k *ar,
  88. struct ath10k_tpc_stats_final *tpc_stats);
  89. void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer, int len);
  90. #define ATH10K_DFS_STAT_INC(ar, c) (ar->debug.dfs_stats.c++)
  91. void ath10k_debug_get_et_strings(struct ieee80211_hw *hw,
  92. struct ieee80211_vif *vif,
  93. u32 sset, u8 *data);
  94. int ath10k_debug_get_et_sset_count(struct ieee80211_hw *hw,
  95. struct ieee80211_vif *vif, int sset);
  96. void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
  97. struct ieee80211_vif *vif,
  98. struct ethtool_stats *stats, u64 *data);
  99. static inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar)
  100. {
  101. return ar->debug.fw_dbglog_mask;
  102. }
  103. static inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar)
  104. {
  105. return ar->debug.fw_dbglog_level;
  106. }
  107. static inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar)
  108. {
  109. return ar->debug.enable_extd_tx_stats;
  110. }
  111. int ath10k_debug_fw_stats_request(struct ath10k *ar);
  112. #else
  113. static inline int ath10k_debug_start(struct ath10k *ar)
  114. {
  115. return 0;
  116. }
  117. static inline void ath10k_debug_stop(struct ath10k *ar)
  118. {
  119. }
  120. static inline int ath10k_debug_create(struct ath10k *ar)
  121. {
  122. return 0;
  123. }
  124. static inline void ath10k_debug_destroy(struct ath10k *ar)
  125. {
  126. }
  127. static inline int ath10k_debug_register(struct ath10k *ar)
  128. {
  129. return 0;
  130. }
  131. static inline void ath10k_debug_unregister(struct ath10k *ar)
  132. {
  133. }
  134. static inline void ath10k_debug_fw_stats_process(struct ath10k *ar,
  135. struct sk_buff *skb)
  136. {
  137. }
  138. static inline void ath10k_debug_tpc_stats_process(struct ath10k *ar,
  139. struct ath10k_tpc_stats *tpc_stats)
  140. {
  141. kfree(tpc_stats);
  142. }
  143. static inline void
  144. ath10k_debug_tpc_stats_final_process(struct ath10k *ar,
  145. struct ath10k_tpc_stats_final *tpc_stats)
  146. {
  147. kfree(tpc_stats);
  148. }
  149. static inline void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer,
  150. int len)
  151. {
  152. }
  153. static inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar)
  154. {
  155. return 0;
  156. }
  157. static inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar)
  158. {
  159. return 0;
  160. }
  161. static inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar)
  162. {
  163. return 0;
  164. }
  165. static inline int ath10k_debug_fw_stats_request(struct ath10k *ar)
  166. {
  167. return 0;
  168. }
  169. #define ATH10K_DFS_STAT_INC(ar, c) do { } while (0)
  170. #define ath10k_debug_get_et_strings NULL
  171. #define ath10k_debug_get_et_sset_count NULL
  172. #define ath10k_debug_get_et_stats NULL
  173. #endif /* CONFIG_ATH10K_DEBUGFS */
  174. #ifdef CONFIG_MAC80211_DEBUGFS
  175. void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  176. struct ieee80211_sta *sta, struct dentry *dir);
  177. void ath10k_sta_update_rx_duration(struct ath10k *ar,
  178. struct ath10k_fw_stats *stats);
  179. void ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr,
  180. unsigned long num_msdus,
  181. enum ath10k_pkt_rx_err err,
  182. unsigned long unchain_cnt,
  183. unsigned long drop_cnt,
  184. unsigned long drop_cnt_filter,
  185. unsigned long queued_msdus);
  186. void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar,
  187. u16 peer_id, u8 tid,
  188. struct htt_rx_indication_mpdu_range *ranges,
  189. int num_ranges);
  190. #else
  191. static inline
  192. void ath10k_sta_update_rx_duration(struct ath10k *ar,
  193. struct ath10k_fw_stats *stats)
  194. {
  195. }
  196. static inline
  197. void ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr,
  198. unsigned long num_msdus,
  199. enum ath10k_pkt_rx_err err,
  200. unsigned long unchain_cnt,
  201. unsigned long drop_cnt,
  202. unsigned long drop_cnt_filter,
  203. unsigned long queued_msdus)
  204. {
  205. }
  206. static inline
  207. void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar,
  208. u16 peer_id, u8 tid,
  209. struct htt_rx_indication_mpdu_range *ranges,
  210. int num_ranges)
  211. {
  212. }
  213. #endif /* CONFIG_MAC80211_DEBUGFS */
  214. #ifdef CONFIG_ATH10K_DEBUG
  215. __printf(3, 4) void __ath10k_dbg(struct ath10k *ar,
  216. enum ath10k_debug_mask mask,
  217. const char *fmt, ...);
  218. void ath10k_dbg_dump(struct ath10k *ar,
  219. enum ath10k_debug_mask mask,
  220. const char *msg, const char *prefix,
  221. const void *buf, size_t len);
  222. #else /* CONFIG_ATH10K_DEBUG */
  223. static inline int __ath10k_dbg(struct ath10k *ar,
  224. enum ath10k_debug_mask dbg_mask,
  225. const char *fmt, ...)
  226. {
  227. return 0;
  228. }
  229. static inline void ath10k_dbg_dump(struct ath10k *ar,
  230. enum ath10k_debug_mask mask,
  231. const char *msg, const char *prefix,
  232. const void *buf, size_t len)
  233. {
  234. }
  235. #endif /* CONFIG_ATH10K_DEBUG */
  236. /* Avoid calling __ath10k_dbg() if debug_mask is not set and tracing
  237. * disabled.
  238. */
  239. #define ath10k_dbg(ar, dbg_mask, fmt, ...) \
  240. do { \
  241. if ((ath10k_debug_mask & dbg_mask) || \
  242. trace_ath10k_log_dbg_enabled()) \
  243. __ath10k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \
  244. } while (0)
  245. #endif /* _DEBUG_H_ */