]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/net/wireless/brcm80211/brcmfmac/debug.h
Merge remote-tracking branch 'sound-current/for-linus'
[karo-tx-linux.git] / drivers / net / wireless / brcm80211 / brcmfmac / debug.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef BRCMFMAC_DEBUG_H
18 #define BRCMFMAC_DEBUG_H
19
20 /* message levels */
21 #define BRCMF_TRACE_VAL         0x00000002
22 #define BRCMF_INFO_VAL          0x00000004
23 #define BRCMF_DATA_VAL          0x00000008
24 #define BRCMF_CTL_VAL           0x00000010
25 #define BRCMF_TIMER_VAL         0x00000020
26 #define BRCMF_HDRS_VAL          0x00000040
27 #define BRCMF_BYTES_VAL         0x00000080
28 #define BRCMF_INTR_VAL          0x00000100
29 #define BRCMF_GLOM_VAL          0x00000200
30 #define BRCMF_EVENT_VAL         0x00000400
31 #define BRCMF_BTA_VAL           0x00000800
32 #define BRCMF_FIL_VAL           0x00001000
33 #define BRCMF_USB_VAL           0x00002000
34 #define BRCMF_SCAN_VAL          0x00004000
35 #define BRCMF_CONN_VAL          0x00008000
36 #define BRCMF_BCDC_VAL          0x00010000
37 #define BRCMF_SDIO_VAL          0x00020000
38 #define BRCMF_MSGBUF_VAL        0x00040000
39 #define BRCMF_PCIE_VAL          0x00080000
40 #define BRCMF_FWCON_VAL         0x00100000
41
42 /* set default print format */
43 #undef pr_fmt
44 #define pr_fmt(fmt)             KBUILD_MODNAME ": " fmt
45
46 /* Macro for error messages. net_ratelimit() is used when driver
47  * debugging is not selected. When debugging the driver error
48  * messages are as important as other tracing or even more so.
49  */
50 #ifndef CONFIG_BRCM_TRACING
51 #ifdef CONFIG_BRCMDBG
52 #define brcmf_err(fmt, ...)     pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
53 #else
54 #define brcmf_err(fmt, ...)                                             \
55         do {                                                            \
56                 if (net_ratelimit())                                    \
57                         pr_err("%s: " fmt, __func__, ##__VA_ARGS__);    \
58         } while (0)
59 #endif
60 #else
61 __printf(2, 3)
62 void __brcmf_err(const char *func, const char *fmt, ...);
63 #define brcmf_err(fmt, ...) \
64         __brcmf_err(__func__, fmt, ##__VA_ARGS__)
65 #endif
66
67 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
68 __printf(3, 4)
69 void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...);
70 #define brcmf_dbg(level, fmt, ...)                              \
71 do {                                                            \
72         __brcmf_dbg(BRCMF_##level##_VAL, __func__,              \
73                     fmt, ##__VA_ARGS__);                        \
74 } while (0)
75 #define BRCMF_DATA_ON()         (brcmf_msg_level & BRCMF_DATA_VAL)
76 #define BRCMF_CTL_ON()          (brcmf_msg_level & BRCMF_CTL_VAL)
77 #define BRCMF_HDRS_ON()         (brcmf_msg_level & BRCMF_HDRS_VAL)
78 #define BRCMF_BYTES_ON()        (brcmf_msg_level & BRCMF_BYTES_VAL)
79 #define BRCMF_GLOM_ON()         (brcmf_msg_level & BRCMF_GLOM_VAL)
80 #define BRCMF_EVENT_ON()        (brcmf_msg_level & BRCMF_EVENT_VAL)
81 #define BRCMF_FIL_ON()          (brcmf_msg_level & BRCMF_FIL_VAL)
82 #define BRCMF_FWCON_ON()        (brcmf_msg_level & BRCMF_FWCON_VAL)
83
84 #else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
85
86 #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
87
88 #define BRCMF_DATA_ON()         0
89 #define BRCMF_CTL_ON()          0
90 #define BRCMF_HDRS_ON()         0
91 #define BRCMF_BYTES_ON()        0
92 #define BRCMF_GLOM_ON()         0
93 #define BRCMF_EVENT_ON()        0
94 #define BRCMF_FIL_ON()          0
95 #define BRCMF_FWCON_ON()        0
96
97 #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
98
99 #define brcmf_dbg_hex_dump(test, data, len, fmt, ...)                   \
100 do {                                                                    \
101         trace_brcmf_hexdump((void *)data, len);                         \
102         if (test)                                                       \
103                 brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__);      \
104 } while (0)
105
106 extern int brcmf_msg_level;
107
108 struct brcmf_pub;
109 #ifdef DEBUG
110 void brcmf_debugfs_init(void);
111 void brcmf_debugfs_exit(void);
112 int brcmf_debug_attach(struct brcmf_pub *drvr);
113 void brcmf_debug_detach(struct brcmf_pub *drvr);
114 struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
115 int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
116                             int (*read_fn)(struct seq_file *seq, void *data));
117 #else
118 static inline void brcmf_debugfs_init(void)
119 {
120 }
121 static inline void brcmf_debugfs_exit(void)
122 {
123 }
124 static inline int brcmf_debug_attach(struct brcmf_pub *drvr)
125 {
126         return 0;
127 }
128 static inline void brcmf_debug_detach(struct brcmf_pub *drvr)
129 {
130 }
131 static inline
132 int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
133                             int (*read_fn)(struct seq_file *seq, void *data))
134 {
135         return 0;
136 }
137 #endif
138
139 #endif /* BRCMFMAC_DEBUG_H */