xref: /linux/net/mac80211/debug.h (revision 5c8013ae2e86ec36b07500ba4cacb14ab4d6f728)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Portions
4  * Copyright (C) 2022 - 2025 Intel Corporation
5  */
6 #ifndef __MAC80211_DEBUG_H
7 #define __MAC80211_DEBUG_H
8 #include <linux/once_lite.h>
9 #include <net/cfg80211.h>
10 
11 #ifdef CONFIG_MAC80211_OCB_DEBUG
12 #define MAC80211_OCB_DEBUG 1
13 #else
14 #define MAC80211_OCB_DEBUG 0
15 #endif
16 
17 #ifdef CONFIG_MAC80211_IBSS_DEBUG
18 #define MAC80211_IBSS_DEBUG 1
19 #else
20 #define MAC80211_IBSS_DEBUG 0
21 #endif
22 
23 #ifdef CONFIG_MAC80211_PS_DEBUG
24 #define MAC80211_PS_DEBUG 1
25 #else
26 #define MAC80211_PS_DEBUG 0
27 #endif
28 
29 #ifdef CONFIG_MAC80211_HT_DEBUG
30 #define MAC80211_HT_DEBUG 1
31 #else
32 #define MAC80211_HT_DEBUG 0
33 #endif
34 
35 #ifdef CONFIG_MAC80211_MPL_DEBUG
36 #define MAC80211_MPL_DEBUG 1
37 #else
38 #define MAC80211_MPL_DEBUG 0
39 #endif
40 
41 #ifdef CONFIG_MAC80211_MPATH_DEBUG
42 #define MAC80211_MPATH_DEBUG 1
43 #else
44 #define MAC80211_MPATH_DEBUG 0
45 #endif
46 
47 #ifdef CONFIG_MAC80211_MHWMP_DEBUG
48 #define MAC80211_MHWMP_DEBUG 1
49 #else
50 #define MAC80211_MHWMP_DEBUG 0
51 #endif
52 
53 #ifdef CONFIG_MAC80211_MESH_SYNC_DEBUG
54 #define MAC80211_MESH_SYNC_DEBUG 1
55 #else
56 #define MAC80211_MESH_SYNC_DEBUG 0
57 #endif
58 
59 #ifdef CONFIG_MAC80211_MESH_CSA_DEBUG
60 #define MAC80211_MESH_CSA_DEBUG 1
61 #else
62 #define MAC80211_MESH_CSA_DEBUG 0
63 #endif
64 
65 #ifdef CONFIG_MAC80211_MESH_PS_DEBUG
66 #define MAC80211_MESH_PS_DEBUG 1
67 #else
68 #define MAC80211_MESH_PS_DEBUG 0
69 #endif
70 
71 #ifdef CONFIG_MAC80211_TDLS_DEBUG
72 #define MAC80211_TDLS_DEBUG 1
73 #else
74 #define MAC80211_TDLS_DEBUG 0
75 #endif
76 
77 #ifdef CONFIG_MAC80211_STA_DEBUG
78 #define MAC80211_STA_DEBUG 1
79 #else
80 #define MAC80211_STA_DEBUG 0
81 #endif
82 
83 #ifdef CONFIG_MAC80211_MLME_DEBUG
84 #define MAC80211_MLME_DEBUG 1
85 #else
86 #define MAC80211_MLME_DEBUG 0
87 #endif
88 
89 #ifdef CONFIG_MAC80211_MESSAGE_TRACING
90 void __sdata_info(const char *fmt, ...) __printf(1, 2);
91 void __sdata_dbg(bool print, const char *fmt, ...) __printf(2, 3);
92 void __sdata_err(const char *fmt, ...) __printf(1, 2);
93 void __wiphy_dbg(struct wiphy *wiphy, bool print, const char *fmt, ...)
94 	__printf(3, 4);
95 
96 #define _sdata_info(sdata, fmt, ...)					\
97 	__sdata_info("%s: " fmt, (sdata)->name, ##__VA_ARGS__)
98 #define _sdata_dbg(print, sdata, fmt, ...)				\
99 	__sdata_dbg(print, "%s: " fmt, (sdata)->name, ##__VA_ARGS__)
100 #define _sdata_err(sdata, fmt, ...)					\
101 	__sdata_err("%s: " fmt, (sdata)->name, ##__VA_ARGS__)
102 #define _wiphy_dbg(print, wiphy, fmt, ...)				\
103 	__wiphy_dbg(wiphy, print, fmt, ##__VA_ARGS__)
104 #else
105 #define _sdata_info(sdata, fmt, ...)					\
106 do {									\
107 	pr_info("%s: " fmt,						\
108 		(sdata)->name, ##__VA_ARGS__);				\
109 } while (0)
110 
111 #define _sdata_dbg(print, sdata, fmt, ...)				\
112 do {									\
113 	if (print)							\
114 		pr_debug("%s: " fmt,					\
115 			 (sdata)->name, ##__VA_ARGS__);			\
116 } while (0)
117 
118 #define _sdata_err(sdata, fmt, ...)					\
119 do {									\
120 	pr_err("%s: " fmt,						\
121 	       (sdata)->name, ##__VA_ARGS__);				\
122 } while (0)
123 
124 #define _wiphy_dbg(print, wiphy, fmt, ...)				\
125 do {									\
126 	if (print)							\
127 		wiphy_dbg((wiphy), fmt, ##__VA_ARGS__);			\
128 } while (0)
129 #endif
130 
131 #define sdata_info(sdata, fmt, ...)					\
132 	_sdata_info(sdata, fmt, ##__VA_ARGS__)
133 #define sdata_err(sdata, fmt, ...)					\
134 	_sdata_err(sdata, fmt, ##__VA_ARGS__)
135 #define sdata_dbg(sdata, fmt, ...)					\
136 	_sdata_dbg(1, sdata, fmt, ##__VA_ARGS__)
137 
138 #define link_info(link, fmt, ...)					\
139 	do {								\
140 		if (ieee80211_vif_is_mld(&(link)->sdata->vif))          \
141 			_sdata_info((link)->sdata, "[link %d] " fmt,	\
142 				    (link)->link_id,			\
143 				    ##__VA_ARGS__);			\
144 		else							\
145 			_sdata_info((link)->sdata, fmt, ##__VA_ARGS__);	\
146 	} while (0)
147 #define link_err(link, fmt, ...)					\
148 	do {								\
149 		if (ieee80211_vif_is_mld(&(link)->sdata->vif))          \
150 			_sdata_err((link)->sdata, "[link %d] " fmt,	\
151 				   (link)->link_id,			\
152 				   ##__VA_ARGS__);			\
153 		else							\
154 			_sdata_err((link)->sdata, fmt, ##__VA_ARGS__);	\
155 	} while (0)
156 #define link_err_once(link, fmt, ...)					\
157 	DO_ONCE_LITE(link_err, link, fmt, ##__VA_ARGS__)
158 #define link_id_info(sdata, link_id, fmt, ...)				\
159 	do {								\
160 		if (ieee80211_vif_is_mld(&sdata->vif))			\
161 			_sdata_info(sdata, "[link %d] " fmt, link_id,	\
162 				    ##__VA_ARGS__);			\
163 		else							\
164 			_sdata_info(sdata, fmt, ##__VA_ARGS__);		\
165 	} while (0)
166 #define _link_id_dbg(print, sdata, link_id, fmt, ...)			\
167 	do {								\
168 		if (ieee80211_vif_is_mld(&(sdata)->vif))		\
169 			_sdata_dbg(print, sdata, "[link %d] " fmt,	\
170 				   link_id, ##__VA_ARGS__);		\
171 		else							\
172 			_sdata_dbg(print, sdata, fmt, ##__VA_ARGS__);	\
173 	} while (0)
174 #define link_dbg(link, fmt, ...)					\
175 	_link_id_dbg(1, (link)->sdata, (link)->link_id,			\
176 		     fmt, ##__VA_ARGS__)
177 
178 #define ht_dbg(sdata, fmt, ...)						\
179 	_sdata_dbg(MAC80211_HT_DEBUG,					\
180 		   sdata, fmt, ##__VA_ARGS__)
181 
182 #define ht_dbg_ratelimited(sdata, fmt, ...)				\
183 	_sdata_dbg(MAC80211_HT_DEBUG && net_ratelimit(),		\
184 		   sdata, fmt, ##__VA_ARGS__)
185 
186 #define ocb_dbg(sdata, fmt, ...)					\
187 	_sdata_dbg(MAC80211_OCB_DEBUG,					\
188 		   sdata, fmt, ##__VA_ARGS__)
189 
190 #define ibss_dbg(sdata, fmt, ...)					\
191 	_sdata_dbg(MAC80211_IBSS_DEBUG,					\
192 		   sdata, fmt, ##__VA_ARGS__)
193 
194 #define ps_dbg(sdata, fmt, ...)						\
195 	_sdata_dbg(MAC80211_PS_DEBUG,					\
196 		   sdata, fmt, ##__VA_ARGS__)
197 
198 #define ps_dbg_hw(hw, fmt, ...)						\
199 	_wiphy_dbg(MAC80211_PS_DEBUG,					\
200 		   (hw)->wiphy, fmt, ##__VA_ARGS__)
201 
202 #define ps_dbg_ratelimited(sdata, fmt, ...)				\
203 	_sdata_dbg(MAC80211_PS_DEBUG && net_ratelimit(),		\
204 		   sdata, fmt, ##__VA_ARGS__)
205 
206 #define mpl_dbg(sdata, fmt, ...)					\
207 	_sdata_dbg(MAC80211_MPL_DEBUG,					\
208 		   sdata, fmt, ##__VA_ARGS__)
209 
210 #define mpath_dbg(sdata, fmt, ...)					\
211 	_sdata_dbg(MAC80211_MPATH_DEBUG,				\
212 		   sdata, fmt, ##__VA_ARGS__)
213 
214 #define mhwmp_dbg(sdata, fmt, ...)					\
215 	_sdata_dbg(MAC80211_MHWMP_DEBUG,				\
216 		   sdata, fmt, ##__VA_ARGS__)
217 
218 #define msync_dbg(sdata, fmt, ...)					\
219 	_sdata_dbg(MAC80211_MESH_SYNC_DEBUG,				\
220 		   sdata, fmt, ##__VA_ARGS__)
221 
222 #define mcsa_dbg(sdata, fmt, ...)					\
223 	_sdata_dbg(MAC80211_MESH_CSA_DEBUG,				\
224 		   sdata, fmt, ##__VA_ARGS__)
225 
226 #define mps_dbg(sdata, fmt, ...)					\
227 	_sdata_dbg(MAC80211_MESH_PS_DEBUG,				\
228 		   sdata, fmt, ##__VA_ARGS__)
229 
230 #define tdls_dbg(sdata, fmt, ...)					\
231 	_sdata_dbg(MAC80211_TDLS_DEBUG,					\
232 		   sdata, fmt, ##__VA_ARGS__)
233 
234 #define sta_dbg(sdata, fmt, ...)					\
235 	_sdata_dbg(MAC80211_STA_DEBUG,					\
236 		   sdata, fmt, ##__VA_ARGS__)
237 
238 #define mlme_dbg(sdata, fmt, ...)					\
239 	_sdata_dbg(MAC80211_MLME_DEBUG,					\
240 		   sdata, fmt, ##__VA_ARGS__)
241 #define mlme_link_id_dbg(sdata, link_id, fmt, ...)			\
242 	_link_id_dbg(MAC80211_MLME_DEBUG, sdata, link_id,		\
243 		     fmt, ##__VA_ARGS__)
244 
245 #define mlme_dbg_ratelimited(sdata, fmt, ...)				\
246 	_sdata_dbg(MAC80211_MLME_DEBUG && net_ratelimit(),		\
247 		   sdata, fmt, ##__VA_ARGS__)
248 
249 #endif /* __MAC80211_DEBUG_H */
250