Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / net / wireless / intel / iwlwifi / iwl-debug.h
blobc023fcf5d4526b5e6482d3404ddf9d6422cc4db2
1 /******************************************************************************
3 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
5 * Portions of this file are derived from the ipw3945 project.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 * The full GNU General Public License is included in this distribution in the
21 * file called LICENSE.
23 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
29 #ifndef __iwl_debug_h__
30 #define __iwl_debug_h__
32 #include "iwl-modparams.h"
35 static inline bool iwl_have_debug_level(u32 level)
37 #ifdef CONFIG_IWLWIFI_DEBUG
38 return iwlwifi_mod_params.debug_level & level;
39 #else
40 return false;
41 #endif
44 struct device;
45 void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
46 const char *fmt, ...) __printf(4, 5);
47 void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
48 void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
49 void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);
51 /* not all compilers can evaluate strlen() at compile time, so use sizeof() */
52 #define CHECK_FOR_NEWLINE(f) BUILD_BUG_ON(f[sizeof(f) - 2] != '\n')
54 /* No matter what is m (priv, bus, trans), this will work */
55 #define IWL_ERR_DEV(d, f, a...) \
56 do { \
57 CHECK_FOR_NEWLINE(f); \
58 __iwl_err((d), false, false, f, ## a); \
59 } while (0)
60 #define IWL_ERR(m, f, a...) \
61 IWL_ERR_DEV((m)->dev, f, ## a)
62 #define IWL_WARN(m, f, a...) \
63 do { \
64 CHECK_FOR_NEWLINE(f); \
65 __iwl_warn((m)->dev, f, ## a); \
66 } while (0)
67 #define IWL_INFO(m, f, a...) \
68 do { \
69 CHECK_FOR_NEWLINE(f); \
70 __iwl_info((m)->dev, f, ## a); \
71 } while (0)
72 #define IWL_CRIT(m, f, a...) \
73 do { \
74 CHECK_FOR_NEWLINE(f); \
75 __iwl_crit((m)->dev, f, ## a); \
76 } while (0)
78 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
79 void __iwl_dbg(struct device *dev,
80 u32 level, bool limit, const char *function,
81 const char *fmt, ...) __printf(5, 6);
82 #else
83 __printf(5, 6) static inline void
84 __iwl_dbg(struct device *dev,
85 u32 level, bool limit, const char *function,
86 const char *fmt, ...)
88 #endif
90 #define iwl_print_hex_error(m, p, len) \
91 do { \
92 print_hex_dump(KERN_ERR, "iwl data: ", \
93 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
94 } while (0)
96 #define __IWL_DEBUG_DEV(dev, level, limit, fmt, args...) \
97 do { \
98 CHECK_FOR_NEWLINE(fmt); \
99 __iwl_dbg(dev, level, limit, __func__, fmt, ##args); \
100 } while (0)
101 #define IWL_DEBUG(m, level, fmt, args...) \
102 __IWL_DEBUG_DEV((m)->dev, level, false, fmt, ##args)
103 #define IWL_DEBUG_DEV(dev, level, fmt, args...) \
104 __IWL_DEBUG_DEV(dev, level, false, fmt, ##args)
105 #define IWL_DEBUG_LIMIT(m, level, fmt, args...) \
106 __IWL_DEBUG_DEV((m)->dev, level, true, fmt, ##args)
108 #ifdef CONFIG_IWLWIFI_DEBUG
109 #define iwl_print_hex_dump(m, level, p, len) \
110 do { \
111 if (iwl_have_debug_level(level)) \
112 print_hex_dump(KERN_DEBUG, "iwl data: ", \
113 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
114 } while (0)
115 #else
116 #define iwl_print_hex_dump(m, level, p, len)
117 #endif /* CONFIG_IWLWIFI_DEBUG */
120 * To use the debug system:
122 * If you are defining a new debug classification, simply add it to the #define
123 * list here in the form of
125 * #define IWL_DL_xxxx VALUE
127 * where xxxx should be the name of the classification (for example, WEP).
129 * You then need to either add a IWL_xxxx_DEBUG() macro definition for your
130 * classification, or use IWL_DEBUG(IWL_DL_xxxx, ...) whenever you want
131 * to send output to that classification.
133 * The active debug levels can be accessed via files
135 * /sys/module/iwlwifi/parameters/debug
136 * when CONFIG_IWLWIFI_DEBUG=y.
138 * /sys/kernel/debug/phy0/iwlwifi/debug/debug_level
139 * when CONFIG_IWLWIFI_DEBUGFS=y.
143 /* 0x0000000F - 0x00000001 */
144 #define IWL_DL_INFO 0x00000001
145 #define IWL_DL_MAC80211 0x00000002
146 #define IWL_DL_HCMD 0x00000004
147 #define IWL_DL_TDLS 0x00000008
148 /* 0x000000F0 - 0x00000010 */
149 #define IWL_DL_QUOTA 0x00000010
150 #define IWL_DL_TE 0x00000020
151 #define IWL_DL_EEPROM 0x00000040
152 #define IWL_DL_RADIO 0x00000080
153 /* 0x00000F00 - 0x00000100 */
154 #define IWL_DL_POWER 0x00000100
155 #define IWL_DL_TEMP 0x00000200
156 #define IWL_DL_RPM 0x00000400
157 #define IWL_DL_SCAN 0x00000800
158 /* 0x0000F000 - 0x00001000 */
159 #define IWL_DL_ASSOC 0x00001000
160 #define IWL_DL_DROP 0x00002000
161 #define IWL_DL_LAR 0x00004000
162 #define IWL_DL_COEX 0x00008000
163 /* 0x000F0000 - 0x00010000 */
164 #define IWL_DL_FW 0x00010000
165 #define IWL_DL_RF_KILL 0x00020000
166 #define IWL_DL_FW_ERRORS 0x00040000
167 /* 0x00F00000 - 0x00100000 */
168 #define IWL_DL_RATE 0x00100000
169 #define IWL_DL_CALIB 0x00200000
170 #define IWL_DL_WEP 0x00400000
171 #define IWL_DL_TX 0x00800000
172 /* 0x0F000000 - 0x01000000 */
173 #define IWL_DL_RX 0x01000000
174 #define IWL_DL_ISR 0x02000000
175 #define IWL_DL_HT 0x04000000
176 #define IWL_DL_EXTERNAL 0x08000000
177 /* 0xF0000000 - 0x10000000 */
178 #define IWL_DL_11H 0x10000000
179 #define IWL_DL_STATS 0x20000000
180 #define IWL_DL_TX_REPLY 0x40000000
181 #define IWL_DL_TX_QUEUES 0x80000000
183 #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a)
184 #define IWL_DEBUG_TDLS(p, f, a...) IWL_DEBUG(p, IWL_DL_TDLS, f, ## a)
185 #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a)
186 #define IWL_DEBUG_EXTERNAL(p, f, a...) IWL_DEBUG(p, IWL_DL_EXTERNAL, f, ## a)
187 #define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a)
188 #define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a)
189 #define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a)
190 #define IWL_DEBUG_TX(p, f, a...) IWL_DEBUG(p, IWL_DL_TX, f, ## a)
191 #define IWL_DEBUG_ISR(p, f, a...) IWL_DEBUG(p, IWL_DL_ISR, f, ## a)
192 #define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a)
193 #define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a)
194 #define IWL_DEBUG_QUOTA(p, f, a...) IWL_DEBUG(p, IWL_DL_QUOTA, f, ## a)
195 #define IWL_DEBUG_TE(p, f, a...) IWL_DEBUG(p, IWL_DL_TE, f, ## a)
196 #define IWL_DEBUG_EEPROM(d, f, a...) IWL_DEBUG_DEV(d, IWL_DL_EEPROM, f, ## a)
197 #define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a)
198 #define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a)
199 #define IWL_DEBUG_RF_KILL(p, f, a...) IWL_DEBUG(p, IWL_DL_RF_KILL, f, ## a)
200 #define IWL_DEBUG_FW_ERRORS(p, f, a...) IWL_DEBUG(p, IWL_DL_FW_ERRORS, f, ## a)
201 #define IWL_DEBUG_DROP(p, f, a...) IWL_DEBUG(p, IWL_DL_DROP, f, ## a)
202 #define IWL_DEBUG_DROP_LIMIT(p, f, a...) \
203 IWL_DEBUG_LIMIT(p, IWL_DL_DROP, f, ## a)
204 #define IWL_DEBUG_COEX(p, f, a...) IWL_DEBUG(p, IWL_DL_COEX, f, ## a)
205 #define IWL_DEBUG_RATE(p, f, a...) IWL_DEBUG(p, IWL_DL_RATE, f, ## a)
206 #define IWL_DEBUG_RATE_LIMIT(p, f, a...) \
207 IWL_DEBUG_LIMIT(p, IWL_DL_RATE, f, ## a)
208 #define IWL_DEBUG_ASSOC(p, f, a...) \
209 IWL_DEBUG(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
210 #define IWL_DEBUG_ASSOC_LIMIT(p, f, a...) \
211 IWL_DEBUG_LIMIT(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
212 #define IWL_DEBUG_HT(p, f, a...) IWL_DEBUG(p, IWL_DL_HT, f, ## a)
213 #define IWL_DEBUG_STATS(p, f, a...) IWL_DEBUG(p, IWL_DL_STATS, f, ## a)
214 #define IWL_DEBUG_STATS_LIMIT(p, f, a...) \
215 IWL_DEBUG_LIMIT(p, IWL_DL_STATS, f, ## a)
216 #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a)
217 #define IWL_DEBUG_TX_QUEUES(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_QUEUES, f, ## a)
218 #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a)
219 #define IWL_DEBUG_DEV_RADIO(p, f, a...) IWL_DEBUG_DEV(p, IWL_DL_RADIO, f, ## a)
220 #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a)
221 #define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a)
222 #define IWL_DEBUG_RPM(p, f, a...) IWL_DEBUG(p, IWL_DL_RPM, f, ## a)
223 #define IWL_DEBUG_LAR(p, f, a...) IWL_DEBUG(p, IWL_DL_LAR, f, ## a)
225 #endif