0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __iwl_debug_h__
0011 #define __iwl_debug_h__
0012
0013 #include "iwl-modparams.h"
0014
0015
0016 static inline bool iwl_have_debug_level(u32 level)
0017 {
0018 #ifdef CONFIG_IWLWIFI_DEBUG
0019 return iwlwifi_mod_params.debug_level & level;
0020 #else
0021 return false;
0022 #endif
0023 }
0024
0025 enum iwl_err_mode {
0026 IWL_ERR_MODE_REGULAR,
0027 IWL_ERR_MODE_RFKILL,
0028 IWL_ERR_MODE_TRACE_ONLY,
0029 IWL_ERR_MODE_RATELIMIT,
0030 };
0031
0032 struct device;
0033 void __iwl_err(struct device *dev, enum iwl_err_mode mode, const char *fmt, ...)
0034 __printf(3, 4);
0035 void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
0036 void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
0037 void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);
0038
0039
0040 #define CHECK_FOR_NEWLINE(f) BUILD_BUG_ON(f[sizeof(f) - 2] != '\n')
0041
0042
0043 #define __IWL_ERR_DEV(d, mode, f, a...) \
0044 do { \
0045 CHECK_FOR_NEWLINE(f); \
0046 __iwl_err((d), mode, f, ## a); \
0047 } while (0)
0048 #define IWL_ERR_DEV(d, f, a...) \
0049 __IWL_ERR_DEV(d, IWL_ERR_MODE_REGULAR, f, ## a)
0050 #define IWL_ERR(m, f, a...) \
0051 IWL_ERR_DEV((m)->dev, f, ## a)
0052 #define IWL_ERR_LIMIT(m, f, a...) \
0053 __IWL_ERR_DEV((m)->dev, IWL_ERR_MODE_RATELIMIT, f, ## a)
0054 #define IWL_WARN(m, f, a...) \
0055 do { \
0056 CHECK_FOR_NEWLINE(f); \
0057 __iwl_warn((m)->dev, f, ## a); \
0058 } while (0)
0059 #define IWL_INFO(m, f, a...) \
0060 do { \
0061 CHECK_FOR_NEWLINE(f); \
0062 __iwl_info((m)->dev, f, ## a); \
0063 } while (0)
0064 #define IWL_CRIT(m, f, a...) \
0065 do { \
0066 CHECK_FOR_NEWLINE(f); \
0067 __iwl_crit((m)->dev, f, ## a); \
0068 } while (0)
0069
0070 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
0071 void __iwl_dbg(struct device *dev,
0072 u32 level, bool limit, const char *function,
0073 const char *fmt, ...) __printf(5, 6);
0074 #else
0075 __printf(5, 6) static inline void
0076 __iwl_dbg(struct device *dev,
0077 u32 level, bool limit, const char *function,
0078 const char *fmt, ...)
0079 {}
0080 #endif
0081
0082 #define iwl_print_hex_error(m, p, len) \
0083 do { \
0084 print_hex_dump(KERN_ERR, "iwl data: ", \
0085 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
0086 } while (0)
0087
0088 #define __IWL_DEBUG_DEV(dev, level, limit, fmt, args...) \
0089 do { \
0090 CHECK_FOR_NEWLINE(fmt); \
0091 __iwl_dbg(dev, level, limit, __func__, fmt, ##args); \
0092 } while (0)
0093 #define IWL_DEBUG(m, level, fmt, args...) \
0094 __IWL_DEBUG_DEV((m)->dev, level, false, fmt, ##args)
0095 #define IWL_DEBUG_DEV(dev, level, fmt, args...) \
0096 __IWL_DEBUG_DEV(dev, level, false, fmt, ##args)
0097 #define IWL_DEBUG_LIMIT(m, level, fmt, args...) \
0098 __IWL_DEBUG_DEV((m)->dev, level, true, fmt, ##args)
0099
0100 #ifdef CONFIG_IWLWIFI_DEBUG
0101 #define iwl_print_hex_dump(m, level, p, len) \
0102 do { \
0103 if (iwl_have_debug_level(level)) \
0104 print_hex_dump(KERN_DEBUG, "iwl data: ", \
0105 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
0106 } while (0)
0107 #else
0108 #define iwl_print_hex_dump(m, level, p, len)
0109 #endif
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 #define IWL_DL_INFO 0x00000001
0137 #define IWL_DL_MAC80211 0x00000002
0138 #define IWL_DL_HCMD 0x00000004
0139 #define IWL_DL_TDLS 0x00000008
0140
0141 #define IWL_DL_QUOTA 0x00000010
0142 #define IWL_DL_TE 0x00000020
0143 #define IWL_DL_EEPROM 0x00000040
0144 #define IWL_DL_RADIO 0x00000080
0145
0146 #define IWL_DL_POWER 0x00000100
0147 #define IWL_DL_TEMP 0x00000200
0148 #define IWL_DL_WOWLAN 0x00000400
0149 #define IWL_DL_SCAN 0x00000800
0150
0151 #define IWL_DL_ASSOC 0x00001000
0152 #define IWL_DL_DROP 0x00002000
0153 #define IWL_DL_LAR 0x00004000
0154 #define IWL_DL_COEX 0x00008000
0155
0156 #define IWL_DL_FW 0x00010000
0157 #define IWL_DL_RF_KILL 0x00020000
0158 #define IWL_DL_TPT 0x00040000
0159
0160 #define IWL_DL_RATE 0x00100000
0161 #define IWL_DL_CALIB 0x00200000
0162 #define IWL_DL_WEP 0x00400000
0163 #define IWL_DL_TX 0x00800000
0164
0165 #define IWL_DL_RX 0x01000000
0166 #define IWL_DL_ISR 0x02000000
0167 #define IWL_DL_HT 0x04000000
0168 #define IWL_DL_EXTERNAL 0x08000000
0169
0170 #define IWL_DL_11H 0x10000000
0171 #define IWL_DL_STATS 0x20000000
0172 #define IWL_DL_TX_REPLY 0x40000000
0173 #define IWL_DL_TX_QUEUES 0x80000000
0174
0175 #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a)
0176 #define IWL_DEBUG_TDLS(p, f, a...) IWL_DEBUG(p, IWL_DL_TDLS, f, ## a)
0177 #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a)
0178 #define IWL_DEBUG_EXTERNAL(p, f, a...) IWL_DEBUG(p, IWL_DL_EXTERNAL, f, ## a)
0179 #define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a)
0180 #define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a)
0181 #define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a)
0182 #define IWL_DEBUG_TX(p, f, a...) IWL_DEBUG(p, IWL_DL_TX, f, ## a)
0183 #define IWL_DEBUG_ISR(p, f, a...) IWL_DEBUG(p, IWL_DL_ISR, f, ## a)
0184 #define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a)
0185 #define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a)
0186 #define IWL_DEBUG_QUOTA(p, f, a...) IWL_DEBUG(p, IWL_DL_QUOTA, f, ## a)
0187 #define IWL_DEBUG_TE(p, f, a...) IWL_DEBUG(p, IWL_DL_TE, f, ## a)
0188 #define IWL_DEBUG_EEPROM(d, f, a...) IWL_DEBUG_DEV(d, IWL_DL_EEPROM, f, ## a)
0189 #define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a)
0190 #define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a)
0191 #define IWL_DEBUG_RF_KILL(p, f, a...) IWL_DEBUG(p, IWL_DL_RF_KILL, f, ## a)
0192 #define IWL_DEBUG_DROP(p, f, a...) IWL_DEBUG(p, IWL_DL_DROP, f, ## a)
0193 #define IWL_DEBUG_DROP_LIMIT(p, f, a...) \
0194 IWL_DEBUG_LIMIT(p, IWL_DL_DROP, f, ## a)
0195 #define IWL_DEBUG_COEX(p, f, a...) IWL_DEBUG(p, IWL_DL_COEX, f, ## a)
0196 #define IWL_DEBUG_RATE(p, f, a...) IWL_DEBUG(p, IWL_DL_RATE, f, ## a)
0197 #define IWL_DEBUG_RATE_LIMIT(p, f, a...) \
0198 IWL_DEBUG_LIMIT(p, IWL_DL_RATE, f, ## a)
0199 #define IWL_DEBUG_ASSOC(p, f, a...) \
0200 IWL_DEBUG(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
0201 #define IWL_DEBUG_ASSOC_LIMIT(p, f, a...) \
0202 IWL_DEBUG_LIMIT(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
0203 #define IWL_DEBUG_HT(p, f, a...) IWL_DEBUG(p, IWL_DL_HT, f, ## a)
0204 #define IWL_DEBUG_STATS(p, f, a...) IWL_DEBUG(p, IWL_DL_STATS, f, ## a)
0205 #define IWL_DEBUG_STATS_LIMIT(p, f, a...) \
0206 IWL_DEBUG_LIMIT(p, IWL_DL_STATS, f, ## a)
0207 #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a)
0208 #define IWL_DEBUG_TX_QUEUES(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_QUEUES, f, ## a)
0209 #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a)
0210 #define IWL_DEBUG_DEV_RADIO(p, f, a...) IWL_DEBUG_DEV(p, IWL_DL_RADIO, f, ## a)
0211 #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a)
0212 #define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a)
0213 #define IWL_DEBUG_TPT(p, f, a...) IWL_DEBUG(p, IWL_DL_TPT, f, ## a)
0214 #define IWL_DEBUG_WOWLAN(p, f, a...) IWL_DEBUG(p, IWL_DL_WOWLAN, f, ## a)
0215 #define IWL_DEBUG_LAR(p, f, a...) IWL_DEBUG(p, IWL_DL_LAR, f, ## a)
0216 #define IWL_DEBUG_FW_INFO(p, f, a...) \
0217 IWL_DEBUG(p, IWL_DL_INFO | IWL_DL_FW, f, ## a)
0218
0219 #endif