1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef BRCMFMAC_DEBUG_H
18#define BRCMFMAC_DEBUG_H
19
20#include <linux/net.h>
21
22
23#define BRCMF_TRACE_VAL 0x00000002
24#define BRCMF_INFO_VAL 0x00000004
25#define BRCMF_DATA_VAL 0x00000008
26#define BRCMF_CTL_VAL 0x00000010
27#define BRCMF_TIMER_VAL 0x00000020
28#define BRCMF_HDRS_VAL 0x00000040
29#define BRCMF_BYTES_VAL 0x00000080
30#define BRCMF_INTR_VAL 0x00000100
31#define BRCMF_GLOM_VAL 0x00000200
32#define BRCMF_EVENT_VAL 0x00000400
33#define BRCMF_BTA_VAL 0x00000800
34#define BRCMF_FIL_VAL 0x00001000
35#define BRCMF_USB_VAL 0x00002000
36#define BRCMF_SCAN_VAL 0x00004000
37#define BRCMF_CONN_VAL 0x00008000
38#define BRCMF_BCDC_VAL 0x00010000
39#define BRCMF_SDIO_VAL 0x00020000
40#define BRCMF_MSGBUF_VAL 0x00040000
41#define BRCMF_PCIE_VAL 0x00080000
42#define BRCMF_FWCON_VAL 0x00100000
43
44
45#undef pr_fmt
46#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
47
48__printf(2, 3)
49void __brcmf_err(const char *func, const char *fmt, ...);
50
51
52
53#define brcmf_err(fmt, ...) \
54 do { \
55 if (IS_ENABLED(CONFIG_BRCMDBG) || \
56 IS_ENABLED(CONFIG_BRCM_TRACING) || \
57 net_ratelimit()) \
58 __brcmf_err(__func__, fmt, ##__VA_ARGS__); \
59 } while (0)
60
61#if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
62
63
64#define brcmf_info brcmf_err
65
66__printf(3, 4)
67void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...);
68#define brcmf_dbg(level, fmt, ...) \
69do { \
70 __brcmf_dbg(BRCMF_##level##_VAL, __func__, \
71 fmt, ##__VA_ARGS__); \
72} while (0)
73#define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL)
74#define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL)
75#define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL)
76#define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL)
77#define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL)
78#define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL)
79#define BRCMF_FIL_ON() (brcmf_msg_level & BRCMF_FIL_VAL)
80#define BRCMF_FWCON_ON() (brcmf_msg_level & BRCMF_FWCON_VAL)
81#define BRCMF_SCAN_ON() (brcmf_msg_level & BRCMF_SCAN_VAL)
82
83#else
84
85#define brcmf_info(fmt, ...) \
86 do { \
87 pr_info("%s: " fmt, __func__, ##__VA_ARGS__); \
88 } while (0)
89
90#define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
91
92#define BRCMF_DATA_ON() 0
93#define BRCMF_CTL_ON() 0
94#define BRCMF_HDRS_ON() 0
95#define BRCMF_BYTES_ON() 0
96#define BRCMF_GLOM_ON() 0
97#define BRCMF_EVENT_ON() 0
98#define BRCMF_FIL_ON() 0
99#define BRCMF_FWCON_ON() 0
100#define BRCMF_SCAN_ON() 0
101
102#endif
103
104#define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
105do { \
106 trace_brcmf_hexdump((void *)data, len); \
107 if (test) \
108 brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
109} while (0)
110
111extern int brcmf_msg_level;
112
113struct brcmf_bus;
114struct brcmf_pub;
115#ifdef DEBUG
116void brcmf_debugfs_init(void);
117void brcmf_debugfs_exit(void);
118int brcmf_debug_attach(struct brcmf_pub *drvr);
119void brcmf_debug_detach(struct brcmf_pub *drvr);
120struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
121int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
122 int (*read_fn)(struct seq_file *seq, void *data));
123int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
124 size_t len);
125#else
126static inline void brcmf_debugfs_init(void)
127{
128}
129static inline void brcmf_debugfs_exit(void)
130{
131}
132static inline int brcmf_debug_attach(struct brcmf_pub *drvr)
133{
134 return 0;
135}
136static inline void brcmf_debug_detach(struct brcmf_pub *drvr)
137{
138}
139static inline
140int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
141 int (*read_fn)(struct seq_file *seq, void *data))
142{
143 return 0;
144}
145static inline
146int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
147 size_t len)
148{
149 return 0;
150}
151#endif
152
153#endif
154