Commit | Line | Data |
---|---|---|
5b435de0 AS |
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 _BRCMF_DBG_H_ | |
18 | #define _BRCMF_DBG_H_ | |
19 | ||
8763349b | 20 | /* message levels */ |
a6cfb147 HM |
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_CDC_VAL 0x00010000 | |
8763349b | 37 | |
79d7c4e8 AS |
38 | /* set default print format */ |
39 | #undef pr_fmt | |
40 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | |
41 | ||
5e8149f5 AS |
42 | /* Macro for error messages. net_ratelimit() is used when driver |
43 | * debugging is not selected. When debugging the driver error | |
44 | * messages are as important as other tracing or even more so. | |
45 | */ | |
e5483576 | 46 | #ifndef CONFIG_BRCM_TRACING |
5e8149f5 AS |
47 | #ifdef CONFIG_BRCMDBG |
48 | #define brcmf_err(fmt, ...) pr_err("%s: " fmt, __func__, ##__VA_ARGS__) | |
49 | #else | |
50 | #define brcmf_err(fmt, ...) \ | |
51 | do { \ | |
52 | if (net_ratelimit()) \ | |
53 | pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \ | |
54 | } while (0) | |
55 | #endif | |
e5483576 AS |
56 | #else |
57 | __printf(2, 3) | |
58 | void __brcmf_err(const char *func, const char *fmt, ...); | |
59 | #define brcmf_err(fmt, ...) \ | |
60 | __brcmf_err(__func__, fmt, ##__VA_ARGS__) | |
61 | #endif | |
5e8149f5 | 62 | |
e5483576 AS |
63 | #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING) |
64 | __printf(3, 4) | |
65 | void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...); | |
5e8149f5 AS |
66 | #define brcmf_dbg(level, fmt, ...) \ |
67 | do { \ | |
e5483576 AS |
68 | __brcmf_dbg(BRCMF_##level##_VAL, __func__, \ |
69 | fmt, ##__VA_ARGS__); \ | |
5b435de0 | 70 | } while (0) |
5b435de0 AS |
71 | #define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL) |
72 | #define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL) | |
73 | #define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL) | |
74 | #define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL) | |
75 | #define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL) | |
30c52bcf | 76 | #define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL) |
81f5dcb8 | 77 | #define BRCMF_FIL_ON() (brcmf_msg_level & BRCMF_FIL_VAL) |
5b435de0 | 78 | |
e5483576 | 79 | #else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */ |
5b435de0 AS |
80 | |
81 | #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__) | |
82 | ||
83 | #define BRCMF_DATA_ON() 0 | |
84 | #define BRCMF_CTL_ON() 0 | |
85 | #define BRCMF_HDRS_ON() 0 | |
86 | #define BRCMF_BYTES_ON() 0 | |
87 | #define BRCMF_GLOM_ON() 0 | |
30c52bcf | 88 | #define BRCMF_EVENT_ON() 0 |
81f5dcb8 | 89 | #define BRCMF_FIL_ON() 0 |
5b435de0 | 90 | |
e5483576 | 91 | #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */ |
5b435de0 | 92 | |
1e023829 JP |
93 | #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \ |
94 | do { \ | |
95 | if (test) \ | |
96 | brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \ | |
97 | } while (0) | |
98 | ||
5b435de0 AS |
99 | extern int brcmf_msg_level; |
100 | ||
80969836 AS |
101 | /* |
102 | * hold counter variables used in brcmfmac sdio driver. | |
103 | */ | |
104 | struct brcmf_sdio_count { | |
105 | uint intrcount; /* Count of device interrupt callbacks */ | |
106 | uint lastintrs; /* Count as of last watchdog timer */ | |
107 | uint pollcnt; /* Count of active polls */ | |
108 | uint regfails; /* Count of R_REG failures */ | |
109 | uint tx_sderrs; /* Count of tx attempts with sd errors */ | |
110 | uint fcqueued; /* Tx packets that got queued */ | |
111 | uint rxrtx; /* Count of rtx requests (NAK to dongle) */ | |
112 | uint rx_toolong; /* Receive frames too long to receive */ | |
113 | uint rxc_errors; /* SDIO errors when reading control frames */ | |
114 | uint rx_hdrfail; /* SDIO errors on header reads */ | |
115 | uint rx_badhdr; /* Bad received headers (roosync?) */ | |
116 | uint rx_badseq; /* Mismatched rx sequence number */ | |
117 | uint fc_rcvd; /* Number of flow-control events received */ | |
118 | uint fc_xoff; /* Number which turned on flow-control */ | |
119 | uint fc_xon; /* Number which turned off flow-control */ | |
120 | uint rxglomfail; /* Failed deglom attempts */ | |
121 | uint rxglomframes; /* Number of glom frames (superframes) */ | |
122 | uint rxglompkts; /* Number of packets from glom frames */ | |
123 | uint f2rxhdrs; /* Number of header reads */ | |
124 | uint f2rxdata; /* Number of frame data reads */ | |
125 | uint f2txdata; /* Number of f2 frame writes */ | |
126 | uint f1regdata; /* Number of f1 register accesses */ | |
127 | uint tickcnt; /* Number of watchdog been schedule */ | |
128 | ulong tx_ctlerrs; /* Err of sending ctrl frames */ | |
129 | ulong tx_ctlpkts; /* Ctrl frames sent to dongle */ | |
130 | ulong rx_ctlerrs; /* Err of processing rx ctrl frames */ | |
131 | ulong rx_ctlpkts; /* Ctrl frames processed from dongle */ | |
132 | ulong rx_readahead_cnt; /* packets where header read-ahead was used */ | |
133 | }; | |
134 | ||
349e7104 AS |
135 | struct brcmf_fws_stats { |
136 | u32 tlv_parse_failed; | |
137 | u32 tlv_invalid_type; | |
138 | u32 header_only_pkt; | |
139 | u32 header_pulls; | |
ce814c1b | 140 | u32 mac_update_failed; |
349e7104 AS |
141 | }; |
142 | ||
d319a7cf AS |
143 | struct brcmf_pub; |
144 | #ifdef DEBUG | |
145 | void brcmf_debugfs_init(void); | |
146 | void brcmf_debugfs_exit(void); | |
147 | int brcmf_debugfs_attach(struct brcmf_pub *drvr); | |
148 | void brcmf_debugfs_detach(struct brcmf_pub *drvr); | |
149 | struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr); | |
80969836 AS |
150 | void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr, |
151 | struct brcmf_sdio_count *sdcnt); | |
349e7104 AS |
152 | void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr, |
153 | struct brcmf_fws_stats *stats); | |
d319a7cf AS |
154 | #else |
155 | static inline void brcmf_debugfs_init(void) | |
156 | { | |
157 | } | |
158 | static inline void brcmf_debugfs_exit(void) | |
159 | { | |
160 | } | |
161 | static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr) | |
162 | { | |
163 | return 0; | |
164 | } | |
165 | static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr) | |
166 | { | |
167 | } | |
349e7104 AS |
168 | static inline void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr, |
169 | struct brcmf_fws_stats *stats) | |
170 | { | |
171 | } | |
d319a7cf AS |
172 | #endif |
173 | ||
5b435de0 | 174 | #endif /* _BRCMF_DBG_H_ */ |