xref: /linux/drivers/net/wireless/ath/ath10k/debug.h (revision d0034a7a4ac7fae708146ac0059b9c47a1543f0d)
1f0553ca9SKalle Valo /* SPDX-License-Identifier: ISC */
25e3dd157SKalle Valo /*
35e3dd157SKalle Valo  * Copyright (c) 2005-2011 Atheros Communications Inc.
48b1083d6SKalle Valo  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5caee728aSVasanthakumar Thiagarajan  * Copyright (c) 2018, The Linux Foundation. All rights reserved.
65e3dd157SKalle Valo  */
75e3dd157SKalle Valo 
85e3dd157SKalle Valo #ifndef _DEBUG_H_
95e3dd157SKalle Valo #define _DEBUG_H_
105e3dd157SKalle Valo 
115e3dd157SKalle Valo #include <linux/types.h>
125e3dd157SKalle Valo #include "trace.h"
135e3dd157SKalle Valo 
145e3dd157SKalle Valo enum ath10k_debug_mask {
155e3dd157SKalle Valo 	ATH10K_DBG_PCI		= 0x00000001,
165e3dd157SKalle Valo 	ATH10K_DBG_WMI		= 0x00000002,
175e3dd157SKalle Valo 	ATH10K_DBG_HTC		= 0x00000004,
185e3dd157SKalle Valo 	ATH10K_DBG_HTT		= 0x00000008,
195e3dd157SKalle Valo 	ATH10K_DBG_MAC		= 0x00000010,
20b52b7688SKalle Valo 	ATH10K_DBG_BOOT		= 0x00000020,
215e3dd157SKalle Valo 	ATH10K_DBG_PCI_DUMP	= 0x00000040,
225e3dd157SKalle Valo 	ATH10K_DBG_HTT_DUMP	= 0x00000080,
235e3dd157SKalle Valo 	ATH10K_DBG_MGMT		= 0x00000100,
245e3dd157SKalle Valo 	ATH10K_DBG_DATA		= 0x00000200,
25f0bbea99SKalle Valo 	ATH10K_DBG_BMI		= 0x00000400,
269702c686SJanusz Dziedzic 	ATH10K_DBG_REGULATORY	= 0x00000800,
2743d2a30fSKalle Valo 	ATH10K_DBG_TESTMODE	= 0x00001000,
283be004c3SBen Greear 	ATH10K_DBG_WMI_PRINT	= 0x00002000,
2977258d40SMichal Kazior 	ATH10K_DBG_PCI_PS	= 0x00004000,
300b523cedSRaja Mani 	ATH10K_DBG_AHB		= 0x00008000,
3101d6fd69SErik Stromdahl 	ATH10K_DBG_SDIO		= 0x00010000,
3201d6fd69SErik Stromdahl 	ATH10K_DBG_SDIO_DUMP	= 0x00020000,
33b00435e6SErik Stromdahl 	ATH10K_DBG_USB		= 0x00040000,
34b00435e6SErik Stromdahl 	ATH10K_DBG_USB_BULK	= 0x00080000,
35b7962404SGovind Singh 	ATH10K_DBG_SNOC		= 0x00100000,
3635a66576SGovind Singh 	ATH10K_DBG_QMI		= 0x00200000,
37*97614c59STamizh Chelvam 	ATH10K_DBG_STA		= 0x00400000,
385e3dd157SKalle Valo 	ATH10K_DBG_ANY		= 0xffffffff,
395e3dd157SKalle Valo };
405e3dd157SKalle Valo 
4190174455SRajkumar Manoharan enum ath10k_pktlog_filter {
4290174455SRajkumar Manoharan 	ATH10K_PKTLOG_RX         = 0x000000001,
4390174455SRajkumar Manoharan 	ATH10K_PKTLOG_TX         = 0x000000002,
4490174455SRajkumar Manoharan 	ATH10K_PKTLOG_RCFIND     = 0x000000004,
4590174455SRajkumar Manoharan 	ATH10K_PKTLOG_RCUPDATE   = 0x000000008,
4690174455SRajkumar Manoharan 	ATH10K_PKTLOG_DBG_PRINT  = 0x000000010,
47e8123bb7SAnilkumar Kolli 	ATH10K_PKTLOG_PEER_STATS = 0x000000040,
48e8123bb7SAnilkumar Kolli 	ATH10K_PKTLOG_ANY        = 0x00000005f,
4990174455SRajkumar Manoharan };
5090174455SRajkumar Manoharan 
51f5045988SRajkumar Manoharan enum ath10k_dbg_aggr_mode {
52f5045988SRajkumar Manoharan 	ATH10K_DBG_AGGR_MODE_AUTO,
53f5045988SRajkumar Manoharan 	ATH10K_DBG_AGGR_MODE_MANUAL,
54f5045988SRajkumar Manoharan 	ATH10K_DBG_AGGR_MODE_MAX,
55f5045988SRajkumar Manoharan };
56f5045988SRajkumar Manoharan 
57e8123bb7SAnilkumar Kolli /* Types of packet log events */
58e8123bb7SAnilkumar Kolli enum ath_pktlog_type {
59e8123bb7SAnilkumar Kolli 	ATH_PKTLOG_TYPE_TX_CTRL = 1,
60e8123bb7SAnilkumar Kolli 	ATH_PKTLOG_TYPE_TX_STAT,
61e8123bb7SAnilkumar Kolli };
62e8123bb7SAnilkumar Kolli 
63e8123bb7SAnilkumar Kolli struct ath10k_pktlog_hdr {
64e8123bb7SAnilkumar Kolli 	__le16 flags;
65e8123bb7SAnilkumar Kolli 	__le16 missed_cnt;
66e8123bb7SAnilkumar Kolli 	__le16 log_type; /* Type of log information foll this header */
67e8123bb7SAnilkumar Kolli 	__le16 size; /* Size of variable length log information in bytes */
68e8123bb7SAnilkumar Kolli 	__le32 timestamp;
69d3ed0cf0SGustavo A. R. Silva 	u8 payload[];
70e8123bb7SAnilkumar Kolli } __packed;
71e8123bb7SAnilkumar Kolli 
72bc6f9ae6SManikanta Pubbisetty /* FIXME: How to calculate the buffer size sanely? */
73bc6f9ae6SManikanta Pubbisetty #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024)
74bc6f9ae6SManikanta Pubbisetty 
7533410a51SAshok Raj Nagarajan #define ATH10K_TX_POWER_MAX_VAL 70
7633410a51SAshok Raj Nagarajan #define ATH10K_TX_POWER_MIN_VAL 0
7733410a51SAshok Raj Nagarajan 
785e3dd157SKalle Valo extern unsigned int ath10k_debug_mask;
795e3dd157SKalle Valo 
80babcb3edSJoe Perches __printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...);
81babcb3edSJoe Perches __printf(2, 3) void ath10k_err(struct ath10k *ar, const char *fmt, ...);
82babcb3edSJoe Perches __printf(2, 3) void ath10k_warn(struct ath10k *ar, const char *fmt, ...);
8323f591eaSKalle Valo 
8423f591eaSKalle Valo void ath10k_debug_print_hwfw_info(struct ath10k *ar);
8523f591eaSKalle Valo void ath10k_debug_print_board_info(struct ath10k *ar);
8623f591eaSKalle Valo void ath10k_debug_print_boot_info(struct ath10k *ar);
878a0c797eSKalle Valo void ath10k_print_driver_info(struct ath10k *ar);
885e3dd157SKalle Valo 
895e3dd157SKalle Valo #ifdef CONFIG_ATH10K_DEBUGFS
90db66ea04SKalle Valo int ath10k_debug_start(struct ath10k *ar);
91db66ea04SKalle Valo void ath10k_debug_stop(struct ath10k *ar);
925e3dd157SKalle Valo int ath10k_debug_create(struct ath10k *ar);
9360631c5cSKalle Valo void ath10k_debug_destroy(struct ath10k *ar);
94e13cf7a3SMichal Kazior int ath10k_debug_register(struct ath10k *ar);
95e13cf7a3SMichal Kazior void ath10k_debug_unregister(struct ath10k *ar);
9660ef401aSMichal Kazior void ath10k_debug_fw_stats_process(struct ath10k *ar, struct sk_buff *skb);
9729542666SMaharaja Kennadyrajan void ath10k_debug_tpc_stats_process(struct ath10k *ar,
9829542666SMaharaja Kennadyrajan 				    struct ath10k_tpc_stats *tpc_stats);
99bc64d052SMaharaja Kennadyrajan void
100bc64d052SMaharaja Kennadyrajan ath10k_debug_tpc_stats_final_process(struct ath10k *ar,
101bc64d052SMaharaja Kennadyrajan 				     struct ath10k_tpc_stats_final *tpc_stats);
102384914b2SBen Greear void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer, int len);
103727000e6SArun Khandavalli 
1049702c686SJanusz Dziedzic #define ATH10K_DFS_STAT_INC(ar, c) (ar->debug.dfs_stats.c++)
1059702c686SJanusz Dziedzic 
1066cddcc7aSBen Greear void ath10k_debug_get_et_strings(struct ieee80211_hw *hw,
1076cddcc7aSBen Greear 				 struct ieee80211_vif *vif,
1086cddcc7aSBen Greear 				 u32 sset, u8 *data);
1096cddcc7aSBen Greear int ath10k_debug_get_et_sset_count(struct ieee80211_hw *hw,
1106cddcc7aSBen Greear 				   struct ieee80211_vif *vif, int sset);
1116cddcc7aSBen Greear void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
1126cddcc7aSBen Greear 			       struct ieee80211_vif *vif,
1136cddcc7aSBen Greear 			       struct ethtool_stats *stats, u64 *data);
114ebee76f7SBenjamin Berg 
ath10k_debug_get_fw_dbglog_mask(struct ath10k * ar)115ebee76f7SBenjamin Berg static inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar)
116ebee76f7SBenjamin Berg {
117ebee76f7SBenjamin Berg 	return ar->debug.fw_dbglog_mask;
118ebee76f7SBenjamin Berg }
119ebee76f7SBenjamin Berg 
ath10k_debug_get_fw_dbglog_level(struct ath10k * ar)120ebee76f7SBenjamin Berg static inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar)
121ebee76f7SBenjamin Berg {
122ebee76f7SBenjamin Berg 	return ar->debug.fw_dbglog_level;
123ebee76f7SBenjamin Berg }
124ebee76f7SBenjamin Berg 
ath10k_debug_is_extd_tx_stats_enabled(struct ath10k * ar)125348cd95cSAnilkumar Kolli static inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar)
126348cd95cSAnilkumar Kolli {
127348cd95cSAnilkumar Kolli 	return ar->debug.enable_extd_tx_stats;
128348cd95cSAnilkumar Kolli }
1294913e675SWen Gong 
1304913e675SWen Gong int ath10k_debug_fw_stats_request(struct ath10k *ar);
1314913e675SWen Gong 
1325e3dd157SKalle Valo #else
133ebee76f7SBenjamin Berg 
ath10k_debug_start(struct ath10k * ar)1344ed998dcSBartosz Markowski static inline int ath10k_debug_start(struct ath10k *ar)
135db66ea04SKalle Valo {
136db66ea04SKalle Valo 	return 0;
137db66ea04SKalle Valo }
138db66ea04SKalle Valo 
ath10k_debug_stop(struct ath10k * ar)1394ed998dcSBartosz Markowski static inline void ath10k_debug_stop(struct ath10k *ar)
140db66ea04SKalle Valo {
141db66ea04SKalle Valo }
142db66ea04SKalle Valo 
ath10k_debug_create(struct ath10k * ar)1435e3dd157SKalle Valo static inline int ath10k_debug_create(struct ath10k *ar)
1445e3dd157SKalle Valo {
1455e3dd157SKalle Valo 	return 0;
1465e3dd157SKalle Valo }
1475e3dd157SKalle Valo 
ath10k_debug_destroy(struct ath10k * ar)14860631c5cSKalle Valo static inline void ath10k_debug_destroy(struct ath10k *ar)
14960631c5cSKalle Valo {
15060631c5cSKalle Valo }
15160631c5cSKalle Valo 
ath10k_debug_register(struct ath10k * ar)152e13cf7a3SMichal Kazior static inline int ath10k_debug_register(struct ath10k *ar)
153e13cf7a3SMichal Kazior {
154e13cf7a3SMichal Kazior 	return 0;
155e13cf7a3SMichal Kazior }
156e13cf7a3SMichal Kazior 
ath10k_debug_unregister(struct ath10k * ar)157e13cf7a3SMichal Kazior static inline void ath10k_debug_unregister(struct ath10k *ar)
158e13cf7a3SMichal Kazior {
159e13cf7a3SMichal Kazior }
160e13cf7a3SMichal Kazior 
ath10k_debug_fw_stats_process(struct ath10k * ar,struct sk_buff * skb)16160ef401aSMichal Kazior static inline void ath10k_debug_fw_stats_process(struct ath10k *ar,
162d15fb520SMichal Kazior 						 struct sk_buff *skb)
1635e3dd157SKalle Valo {
1645e3dd157SKalle Valo }
1659702c686SJanusz Dziedzic 
ath10k_debug_tpc_stats_process(struct ath10k * ar,struct ath10k_tpc_stats * tpc_stats)16629542666SMaharaja Kennadyrajan static inline void ath10k_debug_tpc_stats_process(struct ath10k *ar,
16729542666SMaharaja Kennadyrajan 						  struct ath10k_tpc_stats *tpc_stats)
16829542666SMaharaja Kennadyrajan {
16929542666SMaharaja Kennadyrajan 	kfree(tpc_stats);
17029542666SMaharaja Kennadyrajan }
17129542666SMaharaja Kennadyrajan 
172bc64d052SMaharaja Kennadyrajan static inline void
ath10k_debug_tpc_stats_final_process(struct ath10k * ar,struct ath10k_tpc_stats_final * tpc_stats)173bc64d052SMaharaja Kennadyrajan ath10k_debug_tpc_stats_final_process(struct ath10k *ar,
174bc64d052SMaharaja Kennadyrajan 				     struct ath10k_tpc_stats_final *tpc_stats)
175bc64d052SMaharaja Kennadyrajan {
176bc64d052SMaharaja Kennadyrajan 	kfree(tpc_stats);
177bc64d052SMaharaja Kennadyrajan }
178bc64d052SMaharaja Kennadyrajan 
ath10k_debug_dbglog_add(struct ath10k * ar,u8 * buffer,int len)179384914b2SBen Greear static inline void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer,
180384914b2SBen Greear 					   int len)
181384914b2SBen Greear {
182384914b2SBen Greear }
183384914b2SBen Greear 
ath10k_debug_get_fw_dbglog_mask(struct ath10k * ar)184ebee76f7SBenjamin Berg static inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar)
185ebee76f7SBenjamin Berg {
186ebee76f7SBenjamin Berg 	return 0;
187ebee76f7SBenjamin Berg }
188ebee76f7SBenjamin Berg 
ath10k_debug_get_fw_dbglog_level(struct ath10k * ar)189ebee76f7SBenjamin Berg static inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar)
190ebee76f7SBenjamin Berg {
191ebee76f7SBenjamin Berg 	return 0;
192ebee76f7SBenjamin Berg }
193ebee76f7SBenjamin Berg 
ath10k_debug_is_extd_tx_stats_enabled(struct ath10k * ar)194348cd95cSAnilkumar Kolli static inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar)
195348cd95cSAnilkumar Kolli {
196348cd95cSAnilkumar Kolli 	return 0;
197348cd95cSAnilkumar Kolli }
198348cd95cSAnilkumar Kolli 
ath10k_debug_fw_stats_request(struct ath10k * ar)1994913e675SWen Gong static inline int ath10k_debug_fw_stats_request(struct ath10k *ar)
2004913e675SWen Gong {
2014913e675SWen Gong 	return 0;
2024913e675SWen Gong }
2034913e675SWen Gong 
2049702c686SJanusz Dziedzic #define ATH10K_DFS_STAT_INC(ar, c) do { } while (0)
2059702c686SJanusz Dziedzic 
2066cddcc7aSBen Greear #define ath10k_debug_get_et_strings NULL
2076cddcc7aSBen Greear #define ath10k_debug_get_et_sset_count NULL
2086cddcc7aSBen Greear #define ath10k_debug_get_et_stats NULL
2096cddcc7aSBen Greear 
2105e3dd157SKalle Valo #endif /* CONFIG_ATH10K_DEBUGFS */
211f5045988SRajkumar Manoharan #ifdef CONFIG_MAC80211_DEBUGFS
212f5045988SRajkumar Manoharan void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
213f5045988SRajkumar Manoharan 			    struct ieee80211_sta *sta, struct dentry *dir);
2144a49ae94SMohammed Shafi Shajakhan void ath10k_sta_update_rx_duration(struct ath10k *ar,
2154a49ae94SMohammed Shafi Shajakhan 				   struct ath10k_fw_stats *stats);
216caee728aSVasanthakumar Thiagarajan void ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr,
21728bbe237SKalle Valo 				    unsigned long num_msdus,
218caee728aSVasanthakumar Thiagarajan 				    enum ath10k_pkt_rx_err err,
21928bbe237SKalle Valo 				    unsigned long unchain_cnt,
22028bbe237SKalle Valo 				    unsigned long drop_cnt,
22128bbe237SKalle Valo 				    unsigned long drop_cnt_filter,
22228bbe237SKalle Valo 				    unsigned long queued_msdus);
223caee728aSVasanthakumar Thiagarajan void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar,
224caee728aSVasanthakumar Thiagarajan 					  u16 peer_id, u8 tid,
225caee728aSVasanthakumar Thiagarajan 					  struct htt_rx_indication_mpdu_range *ranges,
226caee728aSVasanthakumar Thiagarajan 					  int num_ranges);
227856e7c30SMohammed Shafi Shajakhan #else
2284a49ae94SMohammed Shafi Shajakhan static inline
ath10k_sta_update_rx_duration(struct ath10k * ar,struct ath10k_fw_stats * stats)2294a49ae94SMohammed Shafi Shajakhan void ath10k_sta_update_rx_duration(struct ath10k *ar,
2304a49ae94SMohammed Shafi Shajakhan 				   struct ath10k_fw_stats *stats)
231856e7c30SMohammed Shafi Shajakhan {
232856e7c30SMohammed Shafi Shajakhan }
233caee728aSVasanthakumar Thiagarajan 
234caee728aSVasanthakumar Thiagarajan static inline
ath10k_sta_update_rx_tid_stats(struct ath10k * ar,u8 * first_hdr,unsigned long num_msdus,enum ath10k_pkt_rx_err err,unsigned long unchain_cnt,unsigned long drop_cnt,unsigned long drop_cnt_filter,unsigned long queued_msdus)235caee728aSVasanthakumar Thiagarajan void ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr,
23628bbe237SKalle Valo 				    unsigned long num_msdus,
237caee728aSVasanthakumar Thiagarajan 				    enum ath10k_pkt_rx_err err,
23828bbe237SKalle Valo 				    unsigned long unchain_cnt,
23928bbe237SKalle Valo 				    unsigned long drop_cnt,
24028bbe237SKalle Valo 				    unsigned long drop_cnt_filter,
24128bbe237SKalle Valo 				    unsigned long queued_msdus)
242caee728aSVasanthakumar Thiagarajan {
243caee728aSVasanthakumar Thiagarajan }
244caee728aSVasanthakumar Thiagarajan 
245caee728aSVasanthakumar Thiagarajan static inline
ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k * ar,u16 peer_id,u8 tid,struct htt_rx_indication_mpdu_range * ranges,int num_ranges)246caee728aSVasanthakumar Thiagarajan void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar,
247caee728aSVasanthakumar Thiagarajan 					  u16 peer_id, u8 tid,
248caee728aSVasanthakumar Thiagarajan 					  struct htt_rx_indication_mpdu_range *ranges,
249caee728aSVasanthakumar Thiagarajan 					  int num_ranges)
250caee728aSVasanthakumar Thiagarajan {
251caee728aSVasanthakumar Thiagarajan }
252f5045988SRajkumar Manoharan #endif /* CONFIG_MAC80211_DEBUGFS */
2535e3dd157SKalle Valo 
2545e3dd157SKalle Valo #ifdef CONFIG_ATH10K_DEBUG
2559d740d63SVenkateswara Naralasetty __printf(3, 4) void __ath10k_dbg(struct ath10k *ar,
2567aa7a72aSMichal Kazior 				 enum ath10k_debug_mask mask,
2575e3dd157SKalle Valo 				 const char *fmt, ...);
2587aa7a72aSMichal Kazior void ath10k_dbg_dump(struct ath10k *ar,
2597aa7a72aSMichal Kazior 		     enum ath10k_debug_mask mask,
2605e3dd157SKalle Valo 		     const char *msg, const char *prefix,
2615e3dd157SKalle Valo 		     const void *buf, size_t len);
2625e3dd157SKalle Valo #else /* CONFIG_ATH10K_DEBUG */
2635e3dd157SKalle Valo 
__ath10k_dbg(struct ath10k * ar,enum ath10k_debug_mask dbg_mask,const char * fmt,...)2649d740d63SVenkateswara Naralasetty static inline int __ath10k_dbg(struct ath10k *ar,
2657aa7a72aSMichal Kazior 			       enum ath10k_debug_mask dbg_mask,
2665e3dd157SKalle Valo 			       const char *fmt, ...)
2675e3dd157SKalle Valo {
2685e3dd157SKalle Valo 	return 0;
2695e3dd157SKalle Valo }
2705e3dd157SKalle Valo 
ath10k_dbg_dump(struct ath10k * ar,enum ath10k_debug_mask mask,const char * msg,const char * prefix,const void * buf,size_t len)2717aa7a72aSMichal Kazior static inline void ath10k_dbg_dump(struct ath10k *ar,
2727aa7a72aSMichal Kazior 				   enum ath10k_debug_mask mask,
2735e3dd157SKalle Valo 				   const char *msg, const char *prefix,
2745e3dd157SKalle Valo 				   const void *buf, size_t len)
2755e3dd157SKalle Valo {
2765e3dd157SKalle Valo }
2775e3dd157SKalle Valo #endif /* CONFIG_ATH10K_DEBUG */
2789d740d63SVenkateswara Naralasetty 
2799d740d63SVenkateswara Naralasetty /* Avoid calling __ath10k_dbg() if debug_mask is not set and tracing
2809d740d63SVenkateswara Naralasetty  * disabled.
2819d740d63SVenkateswara Naralasetty  */
2829d740d63SVenkateswara Naralasetty #define ath10k_dbg(ar, dbg_mask, fmt, ...)			\
2839d740d63SVenkateswara Naralasetty do {								\
2849d740d63SVenkateswara Naralasetty 	if ((ath10k_debug_mask & dbg_mask) ||			\
2859d740d63SVenkateswara Naralasetty 	    trace_ath10k_log_dbg_enabled())			\
2869d740d63SVenkateswara Naralasetty 		__ath10k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \
2879d740d63SVenkateswara Naralasetty } while (0)
2885e3dd157SKalle Valo #endif /* _DEBUG_H_ */
289