xref: /linux/drivers/net/wireless/ath/ath11k/debug.h (revision 99cf756831d203fcdd3f9a8833355fb86611a1f2)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4  * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5  */
6 
7 #ifndef _ATH11K_DEBUG_H_
8 #define _ATH11K_DEBUG_H_
9 
10 #include "trace.h"
11 #include "debugfs.h"
12 
13 enum ath11k_debug_mask {
14 	ATH11K_DBG_AHB		= 0x00000001,
15 	ATH11K_DBG_WMI		= 0x00000002,
16 	ATH11K_DBG_HTC		= 0x00000004,
17 	ATH11K_DBG_DP_HTT	= 0x00000008,
18 	ATH11K_DBG_MAC		= 0x00000010,
19 	ATH11K_DBG_BOOT		= 0x00000020,
20 	ATH11K_DBG_QMI		= 0x00000040,
21 	ATH11K_DBG_DATA		= 0x00000080,
22 	ATH11K_DBG_MGMT		= 0x00000100,
23 	ATH11K_DBG_REG		= 0x00000200,
24 	ATH11K_DBG_TESTMODE	= 0x00000400,
25 	ATH11K_DBG_HAL		= 0x00000800,
26 	ATH11K_DBG_PCI		= 0x00001000,
27 	ATH11K_DBG_DP_TX	= 0x00002000,
28 	ATH11K_DBG_DP_RX	= 0x00004000,
29 	ATH11K_DBG_CE		= 0x00008000,
30 	ATH11K_DBG_CFR		= 0x00010000,
31 	ATH11K_DBG_CFR_DUMP	= 0x00020000,
32 };
33 
34 static inline const char *ath11k_dbg_str(enum ath11k_debug_mask mask)
35 {
36 	switch (mask) {
37 	case ATH11K_DBG_AHB:
38 		return "ahb";
39 	case ATH11K_DBG_WMI:
40 		return "wmi";
41 	case ATH11K_DBG_HTC:
42 		return "htc";
43 	case ATH11K_DBG_DP_HTT:
44 		return "dp_htt";
45 	case ATH11K_DBG_MAC:
46 		return "mac";
47 	case ATH11K_DBG_BOOT:
48 		return "boot";
49 	case ATH11K_DBG_QMI:
50 		return "qmi";
51 	case ATH11K_DBG_DATA:
52 		return "data";
53 	case ATH11K_DBG_MGMT:
54 		return "mgmt";
55 	case ATH11K_DBG_REG:
56 		return "reg";
57 	case ATH11K_DBG_TESTMODE:
58 		return "testmode";
59 	case ATH11K_DBG_HAL:
60 		return "hal";
61 	case ATH11K_DBG_PCI:
62 		return "pci";
63 	case ATH11K_DBG_DP_TX:
64 		return "dp_tx";
65 	case ATH11K_DBG_DP_RX:
66 		return "dp_rx";
67 	case ATH11K_DBG_CE:
68 		return "ce";
69 	case ATH11K_DBG_CFR:
70 		return "cfr";
71 	case ATH11K_DBG_CFR_DUMP:
72 		return "cfr_dump";
73 
74 	/* no default handler to allow compiler to check that the
75 	 * enum is fully handled
76 	 */
77 	}
78 
79 	return "<?>";
80 }
81 
82 __printf(2, 3) void ath11k_info(struct ath11k_base *ab, const char *fmt, ...);
83 __printf(2, 3) void ath11k_err(struct ath11k_base *ab, const char *fmt, ...);
84 __printf(2, 3) void ath11k_warn(struct ath11k_base *ab, const char *fmt, ...);
85 
86 extern unsigned int ath11k_debug_mask;
87 
88 #ifdef CONFIG_ATH11K_DEBUG
89 __printf(3, 4) void __ath11k_dbg(struct ath11k_base *ab,
90 				 enum ath11k_debug_mask mask,
91 				 const char *fmt, ...);
92 void ath11k_dbg_dump(struct ath11k_base *ab,
93 		     enum ath11k_debug_mask mask,
94 		     const char *msg, const char *prefix,
95 		     const void *buf, size_t len);
96 #else /* CONFIG_ATH11K_DEBUG */
97 static inline int __ath11k_dbg(struct ath11k_base *ab,
98 			       enum ath11k_debug_mask dbg_mask,
99 			       const char *fmt, ...)
100 {
101 	return 0;
102 }
103 
104 static inline void ath11k_dbg_dump(struct ath11k_base *ab,
105 				   enum ath11k_debug_mask mask,
106 				   const char *msg, const char *prefix,
107 				   const void *buf, size_t len)
108 {
109 }
110 #endif /* CONFIG_ATH11K_DEBUG */
111 
112 #define ath11k_dbg(ar, dbg_mask, fmt, ...)			\
113 do {								\
114 	if ((ath11k_debug_mask & dbg_mask) ||			\
115 	    trace_ath11k_log_dbg_enabled())			\
116 		__ath11k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__);	\
117 } while (0)
118 
119 #endif /* _ATH11K_DEBUG_H_ */
120