Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ISC */
0002 /*
0003  * Copyright (c) 2005-2011 Atheros Communications Inc.
0004  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
0005  * Copyright (c) 2018, The Linux Foundation. All rights reserved.
0006  */
0007 
0008 #ifndef _DEBUG_H_
0009 #define _DEBUG_H_
0010 
0011 #include <linux/types.h>
0012 #include "trace.h"
0013 
0014 enum ath10k_debug_mask {
0015     ATH10K_DBG_PCI      = 0x00000001,
0016     ATH10K_DBG_WMI      = 0x00000002,
0017     ATH10K_DBG_HTC      = 0x00000004,
0018     ATH10K_DBG_HTT      = 0x00000008,
0019     ATH10K_DBG_MAC      = 0x00000010,
0020     ATH10K_DBG_BOOT     = 0x00000020,
0021     ATH10K_DBG_PCI_DUMP = 0x00000040,
0022     ATH10K_DBG_HTT_DUMP = 0x00000080,
0023     ATH10K_DBG_MGMT     = 0x00000100,
0024     ATH10K_DBG_DATA     = 0x00000200,
0025     ATH10K_DBG_BMI      = 0x00000400,
0026     ATH10K_DBG_REGULATORY   = 0x00000800,
0027     ATH10K_DBG_TESTMODE = 0x00001000,
0028     ATH10K_DBG_WMI_PRINT    = 0x00002000,
0029     ATH10K_DBG_PCI_PS   = 0x00004000,
0030     ATH10K_DBG_AHB      = 0x00008000,
0031     ATH10K_DBG_SDIO     = 0x00010000,
0032     ATH10K_DBG_SDIO_DUMP    = 0x00020000,
0033     ATH10K_DBG_USB      = 0x00040000,
0034     ATH10K_DBG_USB_BULK = 0x00080000,
0035     ATH10K_DBG_SNOC     = 0x00100000,
0036     ATH10K_DBG_QMI      = 0x00200000,
0037     ATH10K_DBG_STA      = 0x00400000,
0038     ATH10K_DBG_ANY      = 0xffffffff,
0039 };
0040 
0041 enum ath10k_pktlog_filter {
0042     ATH10K_PKTLOG_RX         = 0x000000001,
0043     ATH10K_PKTLOG_TX         = 0x000000002,
0044     ATH10K_PKTLOG_RCFIND     = 0x000000004,
0045     ATH10K_PKTLOG_RCUPDATE   = 0x000000008,
0046     ATH10K_PKTLOG_DBG_PRINT  = 0x000000010,
0047     ATH10K_PKTLOG_PEER_STATS = 0x000000040,
0048     ATH10K_PKTLOG_ANY        = 0x00000005f,
0049 };
0050 
0051 enum ath10k_dbg_aggr_mode {
0052     ATH10K_DBG_AGGR_MODE_AUTO,
0053     ATH10K_DBG_AGGR_MODE_MANUAL,
0054     ATH10K_DBG_AGGR_MODE_MAX,
0055 };
0056 
0057 /* Types of packet log events */
0058 enum ath_pktlog_type {
0059     ATH_PKTLOG_TYPE_TX_CTRL = 1,
0060     ATH_PKTLOG_TYPE_TX_STAT,
0061 };
0062 
0063 struct ath10k_pktlog_hdr {
0064     __le16 flags;
0065     __le16 missed_cnt;
0066     __le16 log_type; /* Type of log information foll this header */
0067     __le16 size; /* Size of variable length log information in bytes */
0068     __le32 timestamp;
0069     u8 payload[];
0070 } __packed;
0071 
0072 /* FIXME: How to calculate the buffer size sanely? */
0073 #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024)
0074 
0075 #define ATH10K_TX_POWER_MAX_VAL 70
0076 #define ATH10K_TX_POWER_MIN_VAL 0
0077 
0078 extern unsigned int ath10k_debug_mask;
0079 
0080 __printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...);
0081 __printf(2, 3) void ath10k_err(struct ath10k *ar, const char *fmt, ...);
0082 __printf(2, 3) void ath10k_warn(struct ath10k *ar, const char *fmt, ...);
0083 
0084 void ath10k_debug_print_hwfw_info(struct ath10k *ar);
0085 void ath10k_debug_print_board_info(struct ath10k *ar);
0086 void ath10k_debug_print_boot_info(struct ath10k *ar);
0087 void ath10k_print_driver_info(struct ath10k *ar);
0088 
0089 #ifdef CONFIG_ATH10K_DEBUGFS
0090 int ath10k_debug_start(struct ath10k *ar);
0091 void ath10k_debug_stop(struct ath10k *ar);
0092 int ath10k_debug_create(struct ath10k *ar);
0093 void ath10k_debug_destroy(struct ath10k *ar);
0094 int ath10k_debug_register(struct ath10k *ar);
0095 void ath10k_debug_unregister(struct ath10k *ar);
0096 void ath10k_debug_fw_stats_process(struct ath10k *ar, struct sk_buff *skb);
0097 void ath10k_debug_tpc_stats_process(struct ath10k *ar,
0098                     struct ath10k_tpc_stats *tpc_stats);
0099 void
0100 ath10k_debug_tpc_stats_final_process(struct ath10k *ar,
0101                      struct ath10k_tpc_stats_final *tpc_stats);
0102 void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer, int len);
0103 
0104 #define ATH10K_DFS_STAT_INC(ar, c) (ar->debug.dfs_stats.c++)
0105 
0106 void ath10k_debug_get_et_strings(struct ieee80211_hw *hw,
0107                  struct ieee80211_vif *vif,
0108                  u32 sset, u8 *data);
0109 int ath10k_debug_get_et_sset_count(struct ieee80211_hw *hw,
0110                    struct ieee80211_vif *vif, int sset);
0111 void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
0112                    struct ieee80211_vif *vif,
0113                    struct ethtool_stats *stats, u64 *data);
0114 
0115 static inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar)
0116 {
0117     return ar->debug.fw_dbglog_mask;
0118 }
0119 
0120 static inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar)
0121 {
0122     return ar->debug.fw_dbglog_level;
0123 }
0124 
0125 static inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar)
0126 {
0127     return ar->debug.enable_extd_tx_stats;
0128 }
0129 
0130 int ath10k_debug_fw_stats_request(struct ath10k *ar);
0131 
0132 #else
0133 
0134 static inline int ath10k_debug_start(struct ath10k *ar)
0135 {
0136     return 0;
0137 }
0138 
0139 static inline void ath10k_debug_stop(struct ath10k *ar)
0140 {
0141 }
0142 
0143 static inline int ath10k_debug_create(struct ath10k *ar)
0144 {
0145     return 0;
0146 }
0147 
0148 static inline void ath10k_debug_destroy(struct ath10k *ar)
0149 {
0150 }
0151 
0152 static inline int ath10k_debug_register(struct ath10k *ar)
0153 {
0154     return 0;
0155 }
0156 
0157 static inline void ath10k_debug_unregister(struct ath10k *ar)
0158 {
0159 }
0160 
0161 static inline void ath10k_debug_fw_stats_process(struct ath10k *ar,
0162                          struct sk_buff *skb)
0163 {
0164 }
0165 
0166 static inline void ath10k_debug_tpc_stats_process(struct ath10k *ar,
0167                           struct ath10k_tpc_stats *tpc_stats)
0168 {
0169     kfree(tpc_stats);
0170 }
0171 
0172 static inline void
0173 ath10k_debug_tpc_stats_final_process(struct ath10k *ar,
0174                      struct ath10k_tpc_stats_final *tpc_stats)
0175 {
0176     kfree(tpc_stats);
0177 }
0178 
0179 static inline void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer,
0180                        int len)
0181 {
0182 }
0183 
0184 static inline u64 ath10k_debug_get_fw_dbglog_mask(struct ath10k *ar)
0185 {
0186     return 0;
0187 }
0188 
0189 static inline u32 ath10k_debug_get_fw_dbglog_level(struct ath10k *ar)
0190 {
0191     return 0;
0192 }
0193 
0194 static inline int ath10k_debug_is_extd_tx_stats_enabled(struct ath10k *ar)
0195 {
0196     return 0;
0197 }
0198 
0199 static inline int ath10k_debug_fw_stats_request(struct ath10k *ar)
0200 {
0201     return 0;
0202 }
0203 
0204 #define ATH10K_DFS_STAT_INC(ar, c) do { } while (0)
0205 
0206 #define ath10k_debug_get_et_strings NULL
0207 #define ath10k_debug_get_et_sset_count NULL
0208 #define ath10k_debug_get_et_stats NULL
0209 
0210 #endif /* CONFIG_ATH10K_DEBUGFS */
0211 #ifdef CONFIG_MAC80211_DEBUGFS
0212 void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
0213                 struct ieee80211_sta *sta, struct dentry *dir);
0214 void ath10k_sta_update_rx_duration(struct ath10k *ar,
0215                    struct ath10k_fw_stats *stats);
0216 void ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr,
0217                     unsigned long num_msdus,
0218                     enum ath10k_pkt_rx_err err,
0219                     unsigned long unchain_cnt,
0220                     unsigned long drop_cnt,
0221                     unsigned long drop_cnt_filter,
0222                     unsigned long queued_msdus);
0223 void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar,
0224                       u16 peer_id, u8 tid,
0225                       struct htt_rx_indication_mpdu_range *ranges,
0226                       int num_ranges);
0227 #else
0228 static inline
0229 void ath10k_sta_update_rx_duration(struct ath10k *ar,
0230                    struct ath10k_fw_stats *stats)
0231 {
0232 }
0233 
0234 static inline
0235 void ath10k_sta_update_rx_tid_stats(struct ath10k *ar, u8 *first_hdr,
0236                     unsigned long num_msdus,
0237                     enum ath10k_pkt_rx_err err,
0238                     unsigned long unchain_cnt,
0239                     unsigned long drop_cnt,
0240                     unsigned long drop_cnt_filter,
0241                     unsigned long queued_msdus)
0242 {
0243 }
0244 
0245 static inline
0246 void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar,
0247                       u16 peer_id, u8 tid,
0248                       struct htt_rx_indication_mpdu_range *ranges,
0249                       int num_ranges)
0250 {
0251 }
0252 #endif /* CONFIG_MAC80211_DEBUGFS */
0253 
0254 #ifdef CONFIG_ATH10K_DEBUG
0255 __printf(3, 4) void __ath10k_dbg(struct ath10k *ar,
0256                  enum ath10k_debug_mask mask,
0257                  const char *fmt, ...);
0258 void ath10k_dbg_dump(struct ath10k *ar,
0259              enum ath10k_debug_mask mask,
0260              const char *msg, const char *prefix,
0261              const void *buf, size_t len);
0262 #else /* CONFIG_ATH10K_DEBUG */
0263 
0264 static inline int __ath10k_dbg(struct ath10k *ar,
0265                    enum ath10k_debug_mask dbg_mask,
0266                    const char *fmt, ...)
0267 {
0268     return 0;
0269 }
0270 
0271 static inline void ath10k_dbg_dump(struct ath10k *ar,
0272                    enum ath10k_debug_mask mask,
0273                    const char *msg, const char *prefix,
0274                    const void *buf, size_t len)
0275 {
0276 }
0277 #endif /* CONFIG_ATH10K_DEBUG */
0278 
0279 /* Avoid calling __ath10k_dbg() if debug_mask is not set and tracing
0280  * disabled.
0281  */
0282 #define ath10k_dbg(ar, dbg_mask, fmt, ...)          \
0283 do {                                \
0284     if ((ath10k_debug_mask & dbg_mask) ||           \
0285         trace_ath10k_log_dbg_enabled())         \
0286         __ath10k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \
0287 } while (0)
0288 #endif /* _DEBUG_H_ */