aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-02-01 00:08:37 -0500
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2012-02-17 12:49:27 -0500
commit2655e314c4b204966008689eaf3e87ba1f38d55c (patch)
tree2d0dc33216e97e764133c7165b7ebcf4b5f16347 /drivers/net
parentcdfef6c224f9490215cadd91b34c579757a6e59d (diff)
iwlwifi: trace debug messages
Make iwlwifi record all debug messages into tracing, even if debug_level is not enabled. Due to the lack of APIs, the debug messages are now recorded up to a max length of 100, the only one above that is the RXON which is not needed if you trace the commands as well as it only dumps the command contents. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Wey-Yi W Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.c127
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h83
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-devtrace.h65
4 files changed, 235 insertions, 42 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 9dc84a7354db..46622a0f017b 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -1,7 +1,7 @@
1# WIFI 1# WIFI
2obj-$(CONFIG_IWLWIFI) += iwlwifi.o 2obj-$(CONFIG_IWLWIFI) += iwlwifi.o
3iwlwifi-objs := iwl-agn.o iwl-agn-rs.o iwl-mac80211.o 3iwlwifi-objs := iwl-agn.o iwl-agn-rs.o iwl-mac80211.o
4iwlwifi-objs += iwl-ucode.o iwl-agn-tx.o 4iwlwifi-objs += iwl-ucode.o iwl-agn-tx.o iwl-debug.o
5iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o 5iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o
6iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o 6iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o
7 7
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.c b/drivers/net/wireless/iwlwifi/iwl-debug.c
new file mode 100644
index 000000000000..4bc2e70051d6
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.c
@@ -0,0 +1,127 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63
64#include <linux/interrupt.h>
65#include "iwl-debug.h"
66
67#define __iwl_fn(fn) \
68void __iwl_ ##fn(struct device *dev, const char *fmt, ...) \
69{ \
70 struct va_format vaf = { \
71 .fmt = fmt, \
72 }; \
73 va_list args; \
74 \
75 va_start(args, fmt); \
76 vaf.va = &args; \
77 dev_ ##fn(dev, "%pV", &vaf); \
78 trace_iwlwifi_ ##fn(&vaf); \
79 va_end(args); \
80}
81
82__iwl_fn(warn)
83__iwl_fn(info)
84__iwl_fn(crit)
85
86void __iwl_err(struct device *dev, bool rfkill_prefix, bool trace_only,
87 const char *fmt, ...)
88{
89 struct va_format vaf = {
90 .fmt = fmt,
91 };
92 va_list args;
93
94 va_start(args, fmt);
95 vaf.va = &args;
96 if (!trace_only) {
97 if (rfkill_prefix)
98 dev_err(dev, "(RFKILL) %pV", &vaf);
99 else
100 dev_err(dev, "%pV", &vaf);
101 }
102 trace_iwlwifi_err(&vaf);
103 va_end(args);
104}
105
106#if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
107void __iwl_dbg(struct iwl_shared *shared, struct device *dev,
108 u32 level, bool limit, const char *function,
109 const char *fmt, ...)
110{
111 struct va_format vaf = {
112 .fmt = fmt,
113 };
114 va_list args;
115
116 va_start(args, fmt);
117 vaf.va = &args;
118#ifdef CONFIG_IWLWIFI_DEBUG
119 if (iwl_get_debug_level(shared) & level &&
120 (!limit || net_ratelimit()))
121 dev_err(dev, "%c %s %pV", in_interrupt() ? 'I' : 'U',
122 function, &vaf);
123#endif
124 trace_iwlwifi_dbg(level, in_interrupt(), function, &vaf);
125 va_end(args);
126}
127#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 351b41d7f4fd..bfc08494ed22 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -31,14 +31,33 @@
31 31
32#include "iwl-bus.h" 32#include "iwl-bus.h"
33#include "iwl-shared.h" 33#include "iwl-shared.h"
34#include "iwl-devtrace.h"
34 35
35struct iwl_priv; 36struct iwl_priv;
36 37
37/*No matter what is m (priv, bus, trans), this will work */ 38void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
38#define IWL_ERR(m, f, a...) dev_err(trans(m)->dev, f, ## a) 39 const char *fmt, ...);
39#define IWL_WARN(m, f, a...) dev_warn(trans(m)->dev, f, ## a) 40void __iwl_warn(struct device *dev, const char *fmt, ...);
40#define IWL_INFO(m, f, a...) dev_info(trans(m)->dev, f, ## a) 41void __iwl_info(struct device *dev, const char *fmt, ...);
41#define IWL_CRIT(m, f, a...) dev_crit(trans(m)->dev, f, ## a) 42void __iwl_crit(struct device *dev, const char *fmt, ...);
43
44/* No matter what is m (priv, bus, trans), this will work */
45#define IWL_ERR(m, f, a...) __iwl_err(trans(m)->dev, false, false, f, ## a)
46#define IWL_WARN(m, f, a...) __iwl_warn(trans(m)->dev, f, ## a)
47#define IWL_INFO(m, f, a...) __iwl_info(trans(m)->dev, f, ## a)
48#define IWL_CRIT(m, f, a...) __iwl_crit(trans(m)->dev, f, ## a)
49
50#if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
51void __iwl_dbg(struct iwl_shared *shared, struct device *dev,
52 u32 level, bool limit, const char *function,
53 const char *fmt, ...);
54#else
55static inline void
56__iwl_dbg(struct iwl_shared *shared, struct device *dev,
57 u32 level, bool limit, const char *function,
58 const char *fmt, ...)
59{}
60#endif
42 61
43#define iwl_print_hex_error(m, p, len) \ 62#define iwl_print_hex_error(m, p, len) \
44do { \ 63do { \
@@ -46,53 +65,35 @@ do { \
46 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ 65 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
47} while (0) 66} while (0)
48 67
49#ifdef CONFIG_IWLWIFI_DEBUG 68#define IWL_DEBUG(m, level, fmt, args...) \
50#define IWL_DEBUG(m, level, fmt, ...) \ 69 __iwl_dbg((m)->shrd, trans(m)->dev, level, false, __func__, fmt, ##args)
51do { \ 70#define IWL_DEBUG_LIMIT(m, level, fmt, args...) \
52 if (iwl_get_debug_level((m)->shrd) & (level)) \ 71 __iwl_dbg((m)->shrd, trans(m)->dev, level, true, __func__, fmt, ##args)
53 dev_err(trans(m)->dev, "%c %s " fmt, \
54 in_interrupt() ? 'I' : 'U', __func__, \
55 ##__VA_ARGS__); \
56} while (0)
57
58#define IWL_DEBUG_LIMIT(m, level, fmt, ...) \
59do { \
60 if (iwl_get_debug_level((m)->shrd) & (level) && \
61 net_ratelimit()) \
62 dev_err(trans(m)->dev, "%c %s " fmt, \
63 in_interrupt() ? 'I' : 'U', __func__, \
64 ##__VA_ARGS__); \
65} while (0)
66 72
73#ifdef CONFIG_IWLWIFI_DEBUG
67#define iwl_print_hex_dump(m, level, p, len) \ 74#define iwl_print_hex_dump(m, level, p, len) \
68do { \ 75do { \
69 if (iwl_get_debug_level((m)->shrd) & level) \ 76 if (iwl_get_debug_level((m)->shrd) & level) \
70 print_hex_dump(KERN_DEBUG, "iwl data: ", \ 77 print_hex_dump(KERN_DEBUG, "iwl data: ", \
71 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ 78 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
72} while (0) 79} while (0)
73 80#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \
74#define IWL_DEBUG_QUIET_RFKILL(p, fmt, ...) \
75do { \ 81do { \
76 if (!iwl_is_rfkill(p->shrd)) \ 82 if (!iwl_is_rfkill((m)->shrd)) \
77 dev_err(trans(p)->dev, "%s%c %s " fmt, \ 83 IWL_ERR(m, fmt, ##args); \
78 "", \ 84 else \
79 in_interrupt() ? 'I' : 'U', __func__, \ 85 __iwl_err(trans(m)->dev, true, \
80 ##__VA_ARGS__); \ 86 !(iwl_get_debug_level((m)->shrd) & IWL_DL_RADIO),\
81 else if (iwl_get_debug_level(p->shrd) & IWL_DL_RADIO) \ 87 fmt, ##args); \
82 dev_err(trans(p)->dev, "%s%c %s " fmt, \
83 "(RFKILL) ", \
84 in_interrupt() ? 'I' : 'U', __func__, \
85 ##__VA_ARGS__); \
86} while (0) 88} while (0)
87
88#else 89#else
89#define IWL_DEBUG(m, level, fmt, args...)
90#define IWL_DEBUG_LIMIT(m, level, fmt, args...)
91#define iwl_print_hex_dump(m, level, p, len) 90#define iwl_print_hex_dump(m, level, p, len)
92#define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ 91#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \
93do { \ 92do { \
94 if (!iwl_is_rfkill(p->shrd)) \ 93 if (!iwl_is_rfkill((m)->shrd)) \
95 IWL_ERR(p, fmt, ##args); \ 94 IWL_ERR(m, fmt, ##args); \
95 else \
96 __iwl_err(trans(m)->dev, true, true, fmt, ##args); \
96} while (0) 97} while (0)
97#endif /* CONFIG_IWLWIFI_DEBUG */ 98#endif /* CONFIG_IWLWIFI_DEBUG */
98 99
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
index 4d892211ce4c..96e62338cec0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h
+++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
@@ -34,6 +34,11 @@
34#undef TRACE_EVENT 34#undef TRACE_EVENT
35#define TRACE_EVENT(name, proto, ...) \ 35#define TRACE_EVENT(name, proto, ...) \
36static inline void trace_ ## name(proto) {} 36static inline void trace_ ## name(proto) {}
37#undef DECLARE_EVENT_CLASS
38#define DECLARE_EVENT_CLASS(...)
39#undef DEFINE_EVENT
40#define DEFINE_EVENT(evt_class, name, proto, ...) \
41static inline void trace_ ## name(proto) {}
37#endif 42#endif
38 43
39#define PRIV_ENTRY __field(void *, priv) 44#define PRIV_ENTRY __field(void *, priv)
@@ -164,6 +169,66 @@ TRACE_EVENT(iwlwifi_dev_ucode_wrap_event,
164); 169);
165 170
166#undef TRACE_SYSTEM 171#undef TRACE_SYSTEM
172#define TRACE_SYSTEM iwlwifi_msg
173
174#define MAX_MSG_LEN 100
175
176DECLARE_EVENT_CLASS(iwlwifi_msg_event,
177 TP_PROTO(struct va_format *vaf),
178 TP_ARGS(vaf),
179 TP_STRUCT__entry(
180 __dynamic_array(char, msg, MAX_MSG_LEN)
181 ),
182 TP_fast_assign(
183 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
184 MAX_MSG_LEN, vaf->fmt,
185 *vaf->va) >= MAX_MSG_LEN);
186 ),
187 TP_printk("%s", (char *)__get_dynamic_array(msg))
188);
189
190DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_err,
191 TP_PROTO(struct va_format *vaf),
192 TP_ARGS(vaf)
193);
194
195DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_warn,
196 TP_PROTO(struct va_format *vaf),
197 TP_ARGS(vaf)
198);
199
200DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_info,
201 TP_PROTO(struct va_format *vaf),
202 TP_ARGS(vaf)
203);
204
205DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_crit,
206 TP_PROTO(struct va_format *vaf),
207 TP_ARGS(vaf)
208);
209
210TRACE_EVENT(iwlwifi_dbg,
211 TP_PROTO(u32 level, bool in_interrupt, const char *function,
212 struct va_format *vaf),
213 TP_ARGS(level, in_interrupt, function, vaf),
214 TP_STRUCT__entry(
215 __field(u32, level)
216 __field(u8, in_interrupt)
217 __string(function, function)
218 __dynamic_array(char, msg, MAX_MSG_LEN)
219 ),
220 TP_fast_assign(
221 __entry->level = level;
222 __entry->in_interrupt = in_interrupt;
223 __assign_str(function, function);
224 WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
225 MAX_MSG_LEN, vaf->fmt,
226 *vaf->va) >= MAX_MSG_LEN);
227 ),
228 TP_printk("%s", (char *)__get_dynamic_array(msg))
229);
230
231#undef TRACE_SYSTEM
167#define TRACE_SYSTEM iwlwifi 232#define TRACE_SYSTEM iwlwifi
168 233
169TRACE_EVENT(iwlwifi_dev_hcmd, 234TRACE_EVENT(iwlwifi_dev_hcmd,