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