1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2022, 2025 Qualcomm Innovation Center, Inc. All rights reserved.
5 */
6
7 #ifndef _ATH11K_DEBUGFS_H_
8 #define _ATH11K_DEBUGFS_H_
9
10 #include "hal_tx.h"
11
12 #define ATH11K_TX_POWER_MAX_VAL 70
13 #define ATH11K_TX_POWER_MIN_VAL 0
14
15 /* htt_dbg_ext_stats_type */
16 enum ath11k_dbg_htt_ext_stats_type {
17 ATH11K_DBG_HTT_EXT_STATS_RESET = 0,
18 ATH11K_DBG_HTT_EXT_STATS_PDEV_TX = 1,
19 ATH11K_DBG_HTT_EXT_STATS_PDEV_RX = 2,
20 ATH11K_DBG_HTT_EXT_STATS_PDEV_TX_HWQ = 3,
21 ATH11K_DBG_HTT_EXT_STATS_PDEV_TX_SCHED = 4,
22 ATH11K_DBG_HTT_EXT_STATS_PDEV_ERROR = 5,
23 ATH11K_DBG_HTT_EXT_STATS_PDEV_TQM = 6,
24 ATH11K_DBG_HTT_EXT_STATS_TQM_CMDQ = 7,
25 ATH11K_DBG_HTT_EXT_STATS_TX_DE_INFO = 8,
26 ATH11K_DBG_HTT_EXT_STATS_PDEV_TX_RATE = 9,
27 ATH11K_DBG_HTT_EXT_STATS_PDEV_RX_RATE = 10,
28 ATH11K_DBG_HTT_EXT_STATS_PEER_INFO = 11,
29 ATH11K_DBG_HTT_EXT_STATS_TX_SELFGEN_INFO = 12,
30 ATH11K_DBG_HTT_EXT_STATS_TX_MU_HWQ = 13,
31 ATH11K_DBG_HTT_EXT_STATS_RING_IF_INFO = 14,
32 ATH11K_DBG_HTT_EXT_STATS_SRNG_INFO = 15,
33 ATH11K_DBG_HTT_EXT_STATS_SFM_INFO = 16,
34 ATH11K_DBG_HTT_EXT_STATS_PDEV_TX_MU = 17,
35 ATH11K_DBG_HTT_EXT_STATS_ACTIVE_PEERS_LIST = 18,
36 ATH11K_DBG_HTT_EXT_STATS_PDEV_CCA_STATS = 19,
37 ATH11K_DBG_HTT_EXT_STATS_TWT_SESSIONS = 20,
38 ATH11K_DBG_HTT_EXT_STATS_REO_RESOURCE_STATS = 21,
39 ATH11K_DBG_HTT_EXT_STATS_TX_SOUNDING_INFO = 22,
40 ATH11K_DBG_HTT_EXT_STATS_PDEV_OBSS_PD_STATS = 23,
41 ATH11K_DBG_HTT_EXT_STATS_RING_BACKPRESSURE_STATS = 24,
42 ATH11K_DBG_HTT_EXT_STATS_PEER_CTRL_PATH_TXRX_STATS = 29,
43 ATH11K_DBG_HTT_EXT_STATS_PDEV_TX_RATE_TXBF_STATS = 31,
44 ATH11K_DBG_HTT_EXT_STATS_TXBF_OFDMA = 32,
45 ATH11K_DBG_HTT_EXT_PHY_COUNTERS_AND_PHY_STATS = 37,
46
47 /* keep this last */
48 ATH11K_DBG_HTT_NUM_EXT_STATS,
49 };
50
51 #define ATH11K_DEBUG_DBR_ENTRIES_MAX 512
52
53 enum ath11k_dbg_dbr_event {
54 ATH11K_DBG_DBR_EVENT_INVALID,
55 ATH11K_DBG_DBR_EVENT_RX,
56 ATH11K_DBG_DBR_EVENT_REPLENISH,
57 ATH11K_DBG_DBR_EVENT_MAX,
58 };
59
60 struct ath11k_dbg_dbr_entry {
61 u32 hp;
62 u32 tp;
63 u64 timestamp;
64 enum ath11k_dbg_dbr_event event;
65 };
66
67 struct ath11k_dbg_dbr_data {
68 /* protects ath11k_db_ring_debug data */
69 spinlock_t lock;
70 struct ath11k_dbg_dbr_entry *entries;
71 u32 dbr_debug_idx;
72 u32 num_ring_debug_entries;
73 };
74
75 struct ath11k_debug_dbr {
76 struct ath11k_dbg_dbr_data dbr_dbg_data;
77 struct dentry *dbr_debugfs;
78 bool dbr_debug_enabled;
79 };
80
81 struct debug_htt_stats_req {
82 bool done;
83 u8 pdev_id;
84 u8 type;
85 u8 peer_addr[ETH_ALEN];
86 struct completion cmpln;
87 u32 buf_len;
88 u8 buf[];
89 };
90
91 struct ath_pktlog_hdr {
92 u16 flags;
93 u16 missed_cnt;
94 u16 log_type;
95 u16 size;
96 u32 timestamp;
97 u32 type_specific_data;
98 u8 payload[];
99 };
100
101 #define ATH11K_HTT_PEER_STATS_RESET BIT(16)
102
103 #define ATH11K_HTT_STATS_BUF_SIZE (1024 * 512)
104 #define ATH11K_FW_STATS_BUF_SIZE (1024 * 1024)
105
106 enum ath11k_pktlog_filter {
107 ATH11K_PKTLOG_RX = 0x000000001,
108 ATH11K_PKTLOG_TX = 0x000000002,
109 ATH11K_PKTLOG_RCFIND = 0x000000004,
110 ATH11K_PKTLOG_RCUPDATE = 0x000000008,
111 ATH11K_PKTLOG_EVENT_SMART_ANT = 0x000000020,
112 ATH11K_PKTLOG_EVENT_SW = 0x000000040,
113 ATH11K_PKTLOG_ANY = 0x00000006f,
114 };
115
116 enum ath11k_pktlog_mode {
117 ATH11K_PKTLOG_MODE_LITE = 1,
118 ATH11K_PKTLOG_MODE_FULL = 2,
119 };
120
121 enum ath11k_pktlog_enum {
122 ATH11K_PKTLOG_TYPE_INVALID = 0,
123 ATH11K_PKTLOG_TYPE_TX_CTRL = 1,
124 ATH11K_PKTLOG_TYPE_TX_STAT = 2,
125 ATH11K_PKTLOG_TYPE_TX_MSDU_ID = 3,
126 ATH11K_PKTLOG_TYPE_RX_STAT = 5,
127 ATH11K_PKTLOG_TYPE_RC_FIND = 6,
128 ATH11K_PKTLOG_TYPE_RC_UPDATE = 7,
129 ATH11K_PKTLOG_TYPE_TX_VIRT_ADDR = 8,
130 ATH11K_PKTLOG_TYPE_RX_CBF = 10,
131 ATH11K_PKTLOG_TYPE_RX_STATBUF = 22,
132 ATH11K_PKTLOG_TYPE_PPDU_STATS = 23,
133 ATH11K_PKTLOG_TYPE_LITE_RX = 24,
134 };
135
136 enum ath11k_dbg_aggr_mode {
137 ATH11K_DBG_AGGR_MODE_AUTO,
138 ATH11K_DBG_AGGR_MODE_MANUAL,
139 ATH11K_DBG_AGGR_MODE_MAX,
140 };
141
142 enum fw_dbglog_wlan_module_id {
143 WLAN_MODULE_ID_MIN = 0,
144 WLAN_MODULE_INF = WLAN_MODULE_ID_MIN,
145 WLAN_MODULE_WMI,
146 WLAN_MODULE_STA_PWRSAVE,
147 WLAN_MODULE_WHAL,
148 WLAN_MODULE_COEX,
149 WLAN_MODULE_ROAM,
150 WLAN_MODULE_RESMGR_CHAN_MANAGER,
151 WLAN_MODULE_RESMGR,
152 WLAN_MODULE_VDEV_MGR,
153 WLAN_MODULE_SCAN,
154 WLAN_MODULE_RATECTRL,
155 WLAN_MODULE_AP_PWRSAVE,
156 WLAN_MODULE_BLOCKACK,
157 WLAN_MODULE_MGMT_TXRX,
158 WLAN_MODULE_DATA_TXRX,
159 WLAN_MODULE_HTT,
160 WLAN_MODULE_HOST,
161 WLAN_MODULE_BEACON,
162 WLAN_MODULE_OFFLOAD,
163 WLAN_MODULE_WAL,
164 WLAN_WAL_MODULE_DE,
165 WLAN_MODULE_PCIELP,
166 WLAN_MODULE_RTT,
167 WLAN_MODULE_RESOURCE,
168 WLAN_MODULE_DCS,
169 WLAN_MODULE_CACHEMGR,
170 WLAN_MODULE_ANI,
171 WLAN_MODULE_P2P,
172 WLAN_MODULE_CSA,
173 WLAN_MODULE_NLO,
174 WLAN_MODULE_CHATTER,
175 WLAN_MODULE_WOW,
176 WLAN_MODULE_WAL_VDEV,
177 WLAN_MODULE_WAL_PDEV,
178 WLAN_MODULE_TEST,
179 WLAN_MODULE_STA_SMPS,
180 WLAN_MODULE_SWBMISS,
181 WLAN_MODULE_WMMAC,
182 WLAN_MODULE_TDLS,
183 WLAN_MODULE_HB,
184 WLAN_MODULE_TXBF,
185 WLAN_MODULE_BATCH_SCAN,
186 WLAN_MODULE_THERMAL_MGR,
187 WLAN_MODULE_PHYERR_DFS,
188 WLAN_MODULE_RMC,
189 WLAN_MODULE_STATS,
190 WLAN_MODULE_NAN,
191 WLAN_MODULE_IBSS_PWRSAVE,
192 WLAN_MODULE_HIF_UART,
193 WLAN_MODULE_LPI,
194 WLAN_MODULE_EXTSCAN,
195 WLAN_MODULE_UNIT_TEST,
196 WLAN_MODULE_MLME,
197 WLAN_MODULE_SUPPL,
198 WLAN_MODULE_ERE,
199 WLAN_MODULE_OCB,
200 WLAN_MODULE_RSSI_MONITOR,
201 WLAN_MODULE_WPM,
202 WLAN_MODULE_CSS,
203 WLAN_MODULE_PPS,
204 WLAN_MODULE_SCAN_CH_PREDICT,
205 WLAN_MODULE_MAWC,
206 WLAN_MODULE_CMC_QMIC,
207 WLAN_MODULE_EGAP,
208 WLAN_MODULE_NAN20,
209 WLAN_MODULE_QBOOST,
210 WLAN_MODULE_P2P_LISTEN_OFFLOAD,
211 WLAN_MODULE_HALPHY,
212 WLAN_WAL_MODULE_ENQ,
213 WLAN_MODULE_GNSS,
214 WLAN_MODULE_WAL_MEM,
215 WLAN_MODULE_SCHED_ALGO,
216 WLAN_MODULE_TX,
217 WLAN_MODULE_RX,
218 WLAN_MODULE_WLM,
219 WLAN_MODULE_RU_ALLOCATOR,
220 WLAN_MODULE_11K_OFFLOAD,
221 WLAN_MODULE_STA_TWT,
222 WLAN_MODULE_AP_TWT,
223 WLAN_MODULE_UL_OFDMA,
224 WLAN_MODULE_HPCS_PULSE,
225 WLAN_MODULE_DTF,
226 WLAN_MODULE_QUIET_IE,
227 WLAN_MODULE_SHMEM_MGR,
228 WLAN_MODULE_CFIR,
229 WLAN_MODULE_CODE_COVER,
230 WLAN_MODULE_SHO,
231 WLAN_MODULE_MLO_MGR,
232 WLAN_MODULE_PEER_INIT,
233 WLAN_MODULE_STA_MLO_PS,
234
235 WLAN_MODULE_ID_MAX,
236 WLAN_MODULE_ID_INVALID = WLAN_MODULE_ID_MAX,
237 };
238
239 enum fw_dbglog_log_level {
240 ATH11K_FW_DBGLOG_ML = 0,
241 ATH11K_FW_DBGLOG_VERBOSE = 0,
242 ATH11K_FW_DBGLOG_INFO,
243 ATH11K_FW_DBGLOG_INFO_LVL_1,
244 ATH11K_FW_DBGLOG_INFO_LVL_2,
245 ATH11K_FW_DBGLOG_WARN,
246 ATH11K_FW_DBGLOG_ERR,
247 ATH11K_FW_DBGLOG_LVL_MAX
248 };
249
250 struct ath11k_fw_dbglog {
251 enum wmi_debug_log_param param;
252 union {
253 struct {
254 /* log_level values are given in enum fw_dbglog_log_level */
255 u16 log_level;
256 /* module_id values are given in enum fw_dbglog_wlan_module_id */
257 u16 module_id;
258 };
259 /* value is either log_level&module_id/vdev_id/vdev_id_bitmap/log_level
260 * according to param
261 */
262 u32 value;
263 };
264 };
265
266 #ifdef CONFIG_ATH11K_DEBUGFS
267 int ath11k_debugfs_soc_create(struct ath11k_base *ab);
268 void ath11k_debugfs_soc_destroy(struct ath11k_base *ab);
269 int ath11k_debugfs_pdev_create(struct ath11k_base *ab);
270 void ath11k_debugfs_pdev_destroy(struct ath11k_base *ab);
271 int ath11k_debugfs_register(struct ath11k *ar);
272 void ath11k_debugfs_unregister(struct ath11k *ar);
273 void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats);
274
275 void ath11k_debugfs_fw_stats_init(struct ath11k *ar);
276
ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k * ar)277 static inline bool ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k *ar)
278 {
279 return (ar->debug.pktlog_mode == ATH11K_PKTLOG_MODE_LITE);
280 }
281
ath11k_debugfs_is_pktlog_rx_stats_enabled(struct ath11k * ar)282 static inline bool ath11k_debugfs_is_pktlog_rx_stats_enabled(struct ath11k *ar)
283 {
284 return (!ar->debug.pktlog_peer_valid && ar->debug.pktlog_mode);
285 }
286
ath11k_debugfs_is_pktlog_peer_valid(struct ath11k * ar,u8 * addr)287 static inline bool ath11k_debugfs_is_pktlog_peer_valid(struct ath11k *ar, u8 *addr)
288 {
289 return (ar->debug.pktlog_peer_valid && ar->debug.pktlog_mode &&
290 ether_addr_equal(addr, ar->debug.pktlog_peer_addr));
291 }
292
ath11k_debugfs_is_extd_tx_stats_enabled(struct ath11k * ar)293 static inline int ath11k_debugfs_is_extd_tx_stats_enabled(struct ath11k *ar)
294 {
295 return ar->debug.extd_tx_stats;
296 }
297
ath11k_debugfs_is_extd_rx_stats_enabled(struct ath11k * ar)298 static inline int ath11k_debugfs_is_extd_rx_stats_enabled(struct ath11k *ar)
299 {
300 return ar->debug.extd_rx_stats;
301 }
302
ath11k_debugfs_rx_filter(struct ath11k * ar)303 static inline int ath11k_debugfs_rx_filter(struct ath11k *ar)
304 {
305 return ar->debug.rx_filter;
306 }
307
308 void ath11k_debugfs_op_vif_add(struct ieee80211_hw *hw,
309 struct ieee80211_vif *vif);
310 void ath11k_debugfs_add_dbring_entry(struct ath11k *ar,
311 enum wmi_direct_buffer_module id,
312 enum ath11k_dbg_dbr_event event,
313 struct hal_srng *srng);
314
315 #else
ath11k_debugfs_soc_create(struct ath11k_base * ab)316 static inline int ath11k_debugfs_soc_create(struct ath11k_base *ab)
317 {
318 return 0;
319 }
320
ath11k_debugfs_soc_destroy(struct ath11k_base * ab)321 static inline void ath11k_debugfs_soc_destroy(struct ath11k_base *ab)
322 {
323 }
324
ath11k_debugfs_pdev_create(struct ath11k_base * ab)325 static inline int ath11k_debugfs_pdev_create(struct ath11k_base *ab)
326 {
327 return 0;
328 }
329
ath11k_debugfs_pdev_destroy(struct ath11k_base * ab)330 static inline void ath11k_debugfs_pdev_destroy(struct ath11k_base *ab)
331 {
332 }
333
ath11k_debugfs_register(struct ath11k * ar)334 static inline int ath11k_debugfs_register(struct ath11k *ar)
335 {
336 return 0;
337 }
338
ath11k_debugfs_unregister(struct ath11k * ar)339 static inline void ath11k_debugfs_unregister(struct ath11k *ar)
340 {
341 }
342
ath11k_debugfs_fw_stats_process(struct ath11k * ar,struct ath11k_fw_stats * stats)343 static inline void ath11k_debugfs_fw_stats_process(struct ath11k *ar,
344 struct ath11k_fw_stats *stats)
345 {
346 }
347
ath11k_debugfs_fw_stats_init(struct ath11k * ar)348 static inline void ath11k_debugfs_fw_stats_init(struct ath11k *ar)
349 {
350 }
351
ath11k_debugfs_is_extd_tx_stats_enabled(struct ath11k * ar)352 static inline int ath11k_debugfs_is_extd_tx_stats_enabled(struct ath11k *ar)
353 {
354 return 0;
355 }
356
ath11k_debugfs_is_extd_rx_stats_enabled(struct ath11k * ar)357 static inline int ath11k_debugfs_is_extd_rx_stats_enabled(struct ath11k *ar)
358 {
359 return 0;
360 }
361
ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k * ar)362 static inline bool ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k *ar)
363 {
364 return false;
365 }
366
ath11k_debugfs_is_pktlog_rx_stats_enabled(struct ath11k * ar)367 static inline bool ath11k_debugfs_is_pktlog_rx_stats_enabled(struct ath11k *ar)
368 {
369 return false;
370 }
371
ath11k_debugfs_is_pktlog_peer_valid(struct ath11k * ar,u8 * addr)372 static inline bool ath11k_debugfs_is_pktlog_peer_valid(struct ath11k *ar, u8 *addr)
373 {
374 return false;
375 }
376
ath11k_debugfs_rx_filter(struct ath11k * ar)377 static inline int ath11k_debugfs_rx_filter(struct ath11k *ar)
378 {
379 return 0;
380 }
381
382 static inline void
ath11k_debugfs_add_dbring_entry(struct ath11k * ar,enum wmi_direct_buffer_module id,enum ath11k_dbg_dbr_event event,struct hal_srng * srng)383 ath11k_debugfs_add_dbring_entry(struct ath11k *ar,
384 enum wmi_direct_buffer_module id,
385 enum ath11k_dbg_dbr_event event,
386 struct hal_srng *srng)
387 {
388 }
389 #endif /* CONFIG_ATH11K_DEBUGFS*/
390
391 #endif /* _ATH11K_DEBUGFS_H_ */
392