debug.h 7.6 KB

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