162306a36Sopenharmony_ci/* SPDX-License-Identifier: ISC */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2005-2011 Atheros Communications Inc. 462306a36Sopenharmony_ci * Copyright (c) 2011-2017 Qualcomm Atheros, Inc. 562306a36Sopenharmony_ci * Copyright (c) 2018, The Linux Foundation. All rights reserved. 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _DEBUG_H_ 962306a36Sopenharmony_ci#define _DEBUG_H_ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/types.h> 1262306a36Sopenharmony_ci#include "trace.h" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cienum ath10k_debug_mask { 1562306a36Sopenharmony_ci ATH10K_DBG_PCI = 0x00000001, 1662306a36Sopenharmony_ci ATH10K_DBG_WMI = 0x00000002, 1762306a36Sopenharmony_ci ATH10K_DBG_HTC = 0x00000004, 1862306a36Sopenharmony_ci ATH10K_DBG_HTT = 0x00000008, 1962306a36Sopenharmony_ci ATH10K_DBG_MAC = 0x00000010, 2062306a36Sopenharmony_ci ATH10K_DBG_BOOT = 0x00000020, 2162306a36Sopenharmony_ci ATH10K_DBG_PCI_DUMP = 0x00000040, 2262306a36Sopenharmony_ci ATH10K_DBG_HTT_DUMP = 0x00000080, 2362306a36Sopenharmony_ci ATH10K_DBG_MGMT = 0x00000100, 2462306a36Sopenharmony_ci ATH10K_DBG_DATA = 0x00000200, 2562306a36Sopenharmony_ci ATH10K_DBG_BMI = 0x00000400, 2662306a36Sopenharmony_ci ATH10K_DBG_REGULATORY = 0x00000800, 2762306a36Sopenharmony_ci ATH10K_DBG_TESTMODE = 0x00001000, 2862306a36Sopenharmony_ci ATH10K_DBG_WMI_PRINT = 0x00002000, 2962306a36Sopenharmony_ci ATH10K_DBG_PCI_PS = 0x00004000, 3062306a36Sopenharmony_ci ATH10K_DBG_AHB = 0x00008000, 3162306a36Sopenharmony_ci ATH10K_DBG_SDIO = 0x00010000, 3262306a36Sopenharmony_ci ATH10K_DBG_SDIO_DUMP = 0x00020000, 3362306a36Sopenharmony_ci ATH10K_DBG_USB = 0x00040000, 3462306a36Sopenharmony_ci ATH10K_DBG_USB_BULK = 0x00080000, 3562306a36Sopenharmony_ci ATH10K_DBG_SNOC = 0x00100000, 3662306a36Sopenharmony_ci ATH10K_DBG_QMI = 0x00200000, 3762306a36Sopenharmony_ci ATH10K_DBG_STA = 0x00400000, 3862306a36Sopenharmony_ci ATH10K_DBG_ANY = 0xffffffff, 3962306a36Sopenharmony_ci}; 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cienum ath10k_pktlog_filter { 4262306a36Sopenharmony_ci ATH10K_PKTLOG_RX = 0x000000001, 4362306a36Sopenharmony_ci ATH10K_PKTLOG_TX = 0x000000002, 4462306a36Sopenharmony_ci ATH10K_PKTLOG_RCFIND = 0x000000004, 4562306a36Sopenharmony_ci ATH10K_PKTLOG_RCUPDATE = 0x000000008, 4662306a36Sopenharmony_ci ATH10K_PKTLOG_DBG_PRINT = 0x000000010, 4762306a36Sopenharmony_ci ATH10K_PKTLOG_PEER_STATS = 0x000000040, 4862306a36Sopenharmony_ci ATH10K_PKTLOG_ANY = 0x00000005f, 4962306a36Sopenharmony_ci}; 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_cienum ath10k_dbg_aggr_mode { 5262306a36Sopenharmony_ci ATH10K_DBG_AGGR_MODE_AUTO, 5362306a36Sopenharmony_ci ATH10K_DBG_AGGR_MODE_MANUAL, 5462306a36Sopenharmony_ci ATH10K_DBG_AGGR_MODE_MAX, 5562306a36Sopenharmony_ci}; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* Types of packet log events */ 5862306a36Sopenharmony_cienum ath_pktlog_type { 5962306a36Sopenharmony_ci ATH_PKTLOG_TYPE_TX_CTRL = 1, 6062306a36Sopenharmony_ci ATH_PKTLOG_TYPE_TX_STAT, 6162306a36Sopenharmony_ci}; 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_cistruct ath10k_pktlog_hdr { 6462306a36Sopenharmony_ci __le16 flags; 6562306a36Sopenharmony_ci __le16 missed_cnt; 6662306a36Sopenharmony_ci __le16 log_type; /* Type of log information foll this header */ 6762306a36Sopenharmony_ci __le16 size; /* Size of variable length log information in bytes */ 6862306a36Sopenharmony_ci __le32 timestamp; 6962306a36Sopenharmony_ci u8 payload[]; 7062306a36Sopenharmony_ci} __packed; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* FIXME: How to calculate the buffer size sanely? */ 7362306a36Sopenharmony_ci#define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024) 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#define ATH10K_TX_POWER_MAX_VAL 70 7662306a36Sopenharmony_ci#define ATH10K_TX_POWER_MIN_VAL 0 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciextern unsigned int ath10k_debug_mask; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci__printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...); 8162306a36Sopenharmony_ci__printf(2, 3) void ath10k_err(struct ath10k *ar, const char *fmt, ...); 8262306a36Sopenharmony_ci__printf(2, 3) void ath10k_warn(struct ath10k *ar, const char *fmt, ...); 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_civoid ath10k_debug_print_hwfw_info(struct ath10k *ar); 8562306a36Sopenharmony_civoid ath10k_debug_print_board_info(struct ath10k *ar); 8662306a36Sopenharmony_civoid ath10k_debug_print_boot_info(struct ath10k *ar); 8762306a36Sopenharmony_civoid ath10k_print_driver_info(struct ath10k *ar); 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#ifdef CONFIG_ATH10K_DEBUGFS 9062306a36Sopenharmony_ciint ath10k_debug_start(struct ath10k *ar); 9162306a36Sopenharmony_civoid ath10k_debug_stop(struct ath10k *ar); 9262306a36Sopenharmony_ciint ath10k_debug_create(struct ath10k *ar); 9362306a36Sopenharmony_civoid ath10k_debug_destroy(struct ath10k *ar); 9462306a36Sopenharmony_ciint ath10k_debug_register(struct ath10k *ar); 9562306a36Sopenharmony_civoid ath10k_debug_unregister(struct ath10k *ar); 9662306a36Sopenharmony_civoid ath10k_debug_fw_stats_process(struct ath10k *ar, struct sk_buff *skb); 9762306a36Sopenharmony_civoid ath10k_debug_tpc_stats_process(struct ath10k *ar, 9862306a36Sopenharmony_ci struct ath10k_tpc_stats *tpc_stats); 9962306a36Sopenharmony_civoid 10062306a36Sopenharmony_ciath10k_debug_tpc_stats_final_process(struct ath10k *ar, 10162306a36Sopenharmony_ci struct ath10k_tpc_stats_final *tpc_stats); 10262306a36Sopenharmony_civoid ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer, int len); 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci#define ATH10K_DFS_STAT_INC(ar, c) (ar->debug.dfs_stats.c++) 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_civoid ath10k_debug_get_et_strings(struct ieee80211_hw *hw, 10762306a36Sopenharmony_ci struct ieee80211_vif *vif, 10862306a36Sopenharmony_ci u32 sset, u8 *data); 10962306a36Sopenharmony_ciint ath10k_debug_get_et_sset_count(struct ieee80211_hw *hw, 11062306a36Sopenharmony_ci struct ieee80211_vif *vif, int sset); 11162306a36Sopenharmony_civoid ath10k_debug_get_et_stats(struct ieee80211_hw *hw, 11262306a36Sopenharmony_ci struct ieee80211_vif *vif, 11362306a36Sopenharmony_ci struct ethtool_stats *stats, u64 *data); 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_cistatic inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar) 11662306a36Sopenharmony_ci{ 11762306a36Sopenharmony_ci return ar->debug.fw_dbglog_mask; 11862306a36Sopenharmony_ci} 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_cistatic inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar) 12162306a36Sopenharmony_ci{ 12262306a36Sopenharmony_ci return ar->debug.fw_dbglog_level; 12362306a36Sopenharmony_ci} 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_cistatic inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar) 12662306a36Sopenharmony_ci{ 12762306a36Sopenharmony_ci return ar->debug.enable_extd_tx_stats; 12862306a36Sopenharmony_ci} 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ciint ath10k_debug_fw_stats_request(struct ath10k *ar); 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#else 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_cistatic inline int ath10k_debug_start(struct ath10k *ar) 13562306a36Sopenharmony_ci{ 13662306a36Sopenharmony_ci return 0; 13762306a36Sopenharmony_ci} 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_cistatic inline void ath10k_debug_stop(struct ath10k *ar) 14062306a36Sopenharmony_ci{ 14162306a36Sopenharmony_ci} 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_cistatic inline int ath10k_debug_create(struct ath10k *ar) 14462306a36Sopenharmony_ci{ 14562306a36Sopenharmony_ci return 0; 14662306a36Sopenharmony_ci} 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_cistatic inline void ath10k_debug_destroy(struct ath10k *ar) 14962306a36Sopenharmony_ci{ 15062306a36Sopenharmony_ci} 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_cistatic inline int ath10k_debug_register(struct ath10k *ar) 15362306a36Sopenharmony_ci{ 15462306a36Sopenharmony_ci return 0; 15562306a36Sopenharmony_ci} 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_cistatic inline void ath10k_debug_unregister(struct ath10k *ar) 15862306a36Sopenharmony_ci{ 15962306a36Sopenharmony_ci} 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_cistatic inline void ath10k_debug_fw_stats_process(struct ath10k *ar, 16262306a36Sopenharmony_ci struct sk_buff *skb) 16362306a36Sopenharmony_ci{ 16462306a36Sopenharmony_ci} 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_cistatic inline void ath10k_debug_tpc_stats_process(struct ath10k *ar, 16762306a36Sopenharmony_ci struct ath10k_tpc_stats *tpc_stats) 16862306a36Sopenharmony_ci{ 16962306a36Sopenharmony_ci kfree(tpc_stats); 17062306a36Sopenharmony_ci} 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_cistatic inline void 17362306a36Sopenharmony_ciath10k_debug_tpc_stats_final_process(struct ath10k *ar, 17462306a36Sopenharmony_ci struct ath10k_tpc_stats_final *tpc_stats) 17562306a36Sopenharmony_ci{ 17662306a36Sopenharmony_ci kfree(tpc_stats); 17762306a36Sopenharmony_ci} 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_cistatic inline void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer, 18062306a36Sopenharmony_ci int len) 18162306a36Sopenharmony_ci{ 18262306a36Sopenharmony_ci} 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_cistatic inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar) 18562306a36Sopenharmony_ci{ 18662306a36Sopenharmony_ci return 0; 18762306a36Sopenharmony_ci} 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_cistatic inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar) 19062306a36Sopenharmony_ci{ 19162306a36Sopenharmony_ci return 0; 19262306a36Sopenharmony_ci} 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_cistatic inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar) 19562306a36Sopenharmony_ci{ 19662306a36Sopenharmony_ci return 0; 19762306a36Sopenharmony_ci} 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_cistatic inline int ath10k_debug_fw_stats_request(struct ath10k *ar) 20062306a36Sopenharmony_ci{ 20162306a36Sopenharmony_ci return 0; 20262306a36Sopenharmony_ci} 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci#define ATH10K_DFS_STAT_INC(ar, c) do { } while (0) 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci#define ath10k_debug_get_et_strings NULL 20762306a36Sopenharmony_ci#define ath10k_debug_get_et_sset_count NULL 20862306a36Sopenharmony_ci#define ath10k_debug_get_et_stats NULL 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci#endif /* CONFIG_ATH10K_DEBUGFS */ 21162306a36Sopenharmony_ci#ifdef CONFIG_MAC80211_DEBUGFS 21262306a36Sopenharmony_civoid ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 21362306a36Sopenharmony_ci struct ieee80211_sta *sta, struct dentry *dir); 21462306a36Sopenharmony_civoid ath10k_sta_update_rx_duration(struct ath10k *ar, 21562306a36Sopenharmony_ci struct ath10k_fw_stats *stats); 21662306a36Sopenharmony_civoid ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr, 21762306a36Sopenharmony_ci unsigned long num_msdus, 21862306a36Sopenharmony_ci enum ath10k_pkt_rx_err err, 21962306a36Sopenharmony_ci unsigned long unchain_cnt, 22062306a36Sopenharmony_ci unsigned long drop_cnt, 22162306a36Sopenharmony_ci unsigned long drop_cnt_filter, 22262306a36Sopenharmony_ci unsigned long queued_msdus); 22362306a36Sopenharmony_civoid ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar, 22462306a36Sopenharmony_ci u16 peer_id, u8 tid, 22562306a36Sopenharmony_ci struct htt_rx_indication_mpdu_range *ranges, 22662306a36Sopenharmony_ci int num_ranges); 22762306a36Sopenharmony_ci#else 22862306a36Sopenharmony_cistatic inline 22962306a36Sopenharmony_civoid ath10k_sta_update_rx_duration(struct ath10k *ar, 23062306a36Sopenharmony_ci struct ath10k_fw_stats *stats) 23162306a36Sopenharmony_ci{ 23262306a36Sopenharmony_ci} 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_cistatic inline 23562306a36Sopenharmony_civoid ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr, 23662306a36Sopenharmony_ci unsigned long num_msdus, 23762306a36Sopenharmony_ci enum ath10k_pkt_rx_err err, 23862306a36Sopenharmony_ci unsigned long unchain_cnt, 23962306a36Sopenharmony_ci unsigned long drop_cnt, 24062306a36Sopenharmony_ci unsigned long drop_cnt_filter, 24162306a36Sopenharmony_ci unsigned long queued_msdus) 24262306a36Sopenharmony_ci{ 24362306a36Sopenharmony_ci} 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_cistatic inline 24662306a36Sopenharmony_civoid ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar, 24762306a36Sopenharmony_ci u16 peer_id, u8 tid, 24862306a36Sopenharmony_ci struct htt_rx_indication_mpdu_range *ranges, 24962306a36Sopenharmony_ci int num_ranges) 25062306a36Sopenharmony_ci{ 25162306a36Sopenharmony_ci} 25262306a36Sopenharmony_ci#endif /* CONFIG_MAC80211_DEBUGFS */ 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci#ifdef CONFIG_ATH10K_DEBUG 25562306a36Sopenharmony_ci__printf(3, 4) void __ath10k_dbg(struct ath10k *ar, 25662306a36Sopenharmony_ci enum ath10k_debug_mask mask, 25762306a36Sopenharmony_ci const char *fmt, ...); 25862306a36Sopenharmony_civoid ath10k_dbg_dump(struct ath10k *ar, 25962306a36Sopenharmony_ci enum ath10k_debug_mask mask, 26062306a36Sopenharmony_ci const char *msg, const char *prefix, 26162306a36Sopenharmony_ci const void *buf, size_t len); 26262306a36Sopenharmony_ci#else /* CONFIG_ATH10K_DEBUG */ 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_cistatic inline int __ath10k_dbg(struct ath10k *ar, 26562306a36Sopenharmony_ci enum ath10k_debug_mask dbg_mask, 26662306a36Sopenharmony_ci const char *fmt, ...) 26762306a36Sopenharmony_ci{ 26862306a36Sopenharmony_ci return 0; 26962306a36Sopenharmony_ci} 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_cistatic inline void ath10k_dbg_dump(struct ath10k *ar, 27262306a36Sopenharmony_ci enum ath10k_debug_mask mask, 27362306a36Sopenharmony_ci const char *msg, const char *prefix, 27462306a36Sopenharmony_ci const void *buf, size_t len) 27562306a36Sopenharmony_ci{ 27662306a36Sopenharmony_ci} 27762306a36Sopenharmony_ci#endif /* CONFIG_ATH10K_DEBUG */ 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci/* Avoid calling __ath10k_dbg() if debug_mask is not set and tracing 28062306a36Sopenharmony_ci * disabled. 28162306a36Sopenharmony_ci */ 28262306a36Sopenharmony_ci#define ath10k_dbg(ar, dbg_mask, fmt, ...) \ 28362306a36Sopenharmony_cido { \ 28462306a36Sopenharmony_ci if ((ath10k_debug_mask & dbg_mask) || \ 28562306a36Sopenharmony_ci trace_ath10k_log_dbg_enabled()) \ 28662306a36Sopenharmony_ci __ath10k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \ 28762306a36Sopenharmony_ci} while (0) 28862306a36Sopenharmony_ci#endif /* _DEBUG_H_ */ 289