xref: /linux/drivers/net/wireless/ath/ath12k/debug.h (revision 1a9239bb4253f9076b5b4b2a1a4e8d7defd77a95)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4  * Copyright (c) 2021-2022, 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
5  */
6 
7 #ifndef _ATH12K_DEBUG_H_
8 #define _ATH12K_DEBUG_H_
9 
10 #include "trace.h"
11 
12 enum ath12k_debug_mask {
13 	ATH12K_DBG_AHB		= 0x00000001,
14 	ATH12K_DBG_WMI		= 0x00000002,
15 	ATH12K_DBG_HTC		= 0x00000004,
16 	ATH12K_DBG_DP_HTT	= 0x00000008,
17 	ATH12K_DBG_MAC		= 0x00000010,
18 	ATH12K_DBG_BOOT		= 0x00000020,
19 	ATH12K_DBG_QMI		= 0x00000040,
20 	ATH12K_DBG_DATA		= 0x00000080,
21 	ATH12K_DBG_MGMT		= 0x00000100,
22 	ATH12K_DBG_REG		= 0x00000200,
23 	ATH12K_DBG_TESTMODE	= 0x00000400,
24 	ATH12K_DBG_HAL		= 0x00000800,
25 	ATH12K_DBG_PCI		= 0x00001000,
26 	ATH12K_DBG_DP_TX	= 0x00002000,
27 	ATH12K_DBG_DP_RX	= 0x00004000,
28 	ATH12K_DBG_WOW		= 0x00008000,
29 	ATH12K_DBG_ANY		= 0xffffffff,
30 };
31 
32 __printf(2, 3) void ath12k_info(struct ath12k_base *ab, const char *fmt, ...);
33 __printf(2, 3) void ath12k_err(struct ath12k_base *ab, const char *fmt, ...);
34 __printf(2, 3) void __ath12k_warn(struct device *dev, const char *fmt, ...);
35 
36 #define ath12k_warn(ab, fmt, ...) __ath12k_warn((ab)->dev, fmt, ##__VA_ARGS__)
37 #define ath12k_hw_warn(ah, fmt, ...) __ath12k_warn((ah)->dev, fmt, ##__VA_ARGS__)
38 
39 extern unsigned int ath12k_debug_mask;
40 extern bool ath12k_ftm_mode;
41 
42 #ifdef CONFIG_ATH12K_DEBUG
43 __printf(3, 4) void __ath12k_dbg(struct ath12k_base *ab,
44 				 enum ath12k_debug_mask mask,
45 				 const char *fmt, ...);
46 void ath12k_dbg_dump(struct ath12k_base *ab,
47 		     enum ath12k_debug_mask mask,
48 		     const char *msg, const char *prefix,
49 		     const void *buf, size_t len);
50 #else /* CONFIG_ATH12K_DEBUG */
__ath12k_dbg(struct ath12k_base * ab,enum ath12k_debug_mask dbg_mask,const char * fmt,...)51 static inline void __ath12k_dbg(struct ath12k_base *ab,
52 				enum ath12k_debug_mask dbg_mask,
53 				const char *fmt, ...)
54 {
55 }
56 
ath12k_dbg_dump(struct ath12k_base * ab,enum ath12k_debug_mask mask,const char * msg,const char * prefix,const void * buf,size_t len)57 static inline void ath12k_dbg_dump(struct ath12k_base *ab,
58 				   enum ath12k_debug_mask mask,
59 				   const char *msg, const char *prefix,
60 				   const void *buf, size_t len)
61 {
62 }
63 #endif /* CONFIG_ATH12K_DEBUG */
64 
65 #define ath12k_dbg(ab, dbg_mask, fmt, ...)			\
66 do {								\
67 	typeof(dbg_mask) mask = (dbg_mask);			\
68 	if (ath12k_debug_mask & mask)				\
69 		__ath12k_dbg(ab, mask, fmt, ##__VA_ARGS__);	\
70 } while (0)
71 
72 #define ath12k_generic_dbg(dbg_mask, fmt, ...)			\
73 	ath12k_dbg(NULL, dbg_mask, fmt, ##__VA_ARGS__)
74 
75 #endif /* _ATH12K_DEBUG_H_ */
76