]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/blob - drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h
Merge branch 'akpm' (Andrew's patch-bomb)
[can-eth-gw-linux.git] / drivers / net / wireless / brcm80211 / brcmfmac / dhd_dbg.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 _BRCMF_DBG_H_
18 #define _BRCMF_DBG_H_
19
20 /* message levels */
21 #define BRCMF_TRACE_VAL 0x0002
22 #define BRCMF_INFO_VAL  0x0004
23 #define BRCMF_DATA_VAL  0x0008
24 #define BRCMF_CTL_VAL   0x0010
25 #define BRCMF_TIMER_VAL 0x0020
26 #define BRCMF_HDRS_VAL  0x0040
27 #define BRCMF_BYTES_VAL 0x0080
28 #define BRCMF_INTR_VAL  0x0100
29 #define BRCMF_GLOM_VAL  0x0200
30 #define BRCMF_EVENT_VAL 0x0400
31 #define BRCMF_BTA_VAL   0x0800
32 #define BRCMF_FIL_VAL   0x1000
33 #define BRCMF_USB_VAL   0x2000
34 #define BRCMF_SCAN_VAL  0x4000
35 #define BRCMF_CONN_VAL  0x8000
36
37 /* Macro for error messages. net_ratelimit() is used when driver
38  * debugging is not selected. When debugging the driver error
39  * messages are as important as other tracing or even more so.
40  */
41 #ifdef CONFIG_BRCMDBG
42 #define brcmf_err(fmt, ...)     pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
43 #else
44 #define brcmf_err(fmt, ...)                                             \
45         do {                                                            \
46                 if (net_ratelimit())                                    \
47                         pr_err("%s: " fmt, __func__, ##__VA_ARGS__);    \
48         } while (0)
49 #endif
50
51 #if defined(DEBUG)
52
53 #define brcmf_dbg(level, fmt, ...)                              \
54 do {                                                            \
55         if (brcmf_msg_level & BRCMF_##level##_VAL)              \
56                 pr_debug("%s: " fmt, __func__, ##__VA_ARGS__);  \
57 } while (0)
58
59 #define BRCMF_DATA_ON()         (brcmf_msg_level & BRCMF_DATA_VAL)
60 #define BRCMF_CTL_ON()          (brcmf_msg_level & BRCMF_CTL_VAL)
61 #define BRCMF_HDRS_ON()         (brcmf_msg_level & BRCMF_HDRS_VAL)
62 #define BRCMF_BYTES_ON()        (brcmf_msg_level & BRCMF_BYTES_VAL)
63 #define BRCMF_GLOM_ON()         (brcmf_msg_level & BRCMF_GLOM_VAL)
64 #define BRCMF_EVENT_ON()        (brcmf_msg_level & BRCMF_EVENT_VAL)
65 #define BRCMF_FIL_ON()          (brcmf_msg_level & BRCMF_FIL_VAL)
66
67 #else   /* (defined DEBUG) || (defined DEBUG) */
68
69 #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
70
71 #define BRCMF_DATA_ON()         0
72 #define BRCMF_CTL_ON()          0
73 #define BRCMF_HDRS_ON()         0
74 #define BRCMF_BYTES_ON()        0
75 #define BRCMF_GLOM_ON()         0
76 #define BRCMF_EVENT_ON()        0
77 #define BRCMF_FIL_ON()          0
78
79 #endif                          /* defined(DEBUG) */
80
81 #define brcmf_dbg_hex_dump(test, data, len, fmt, ...)                   \
82 do {                                                                    \
83         if (test)                                                       \
84                 brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__);      \
85 } while (0)
86
87 extern int brcmf_msg_level;
88
89 /*
90  * hold counter variables used in brcmfmac sdio driver.
91  */
92 struct brcmf_sdio_count {
93         uint intrcount;         /* Count of device interrupt callbacks */
94         uint lastintrs;         /* Count as of last watchdog timer */
95         uint pollcnt;           /* Count of active polls */
96         uint regfails;          /* Count of R_REG failures */
97         uint tx_sderrs;         /* Count of tx attempts with sd errors */
98         uint fcqueued;          /* Tx packets that got queued */
99         uint rxrtx;             /* Count of rtx requests (NAK to dongle) */
100         uint rx_toolong;        /* Receive frames too long to receive */
101         uint rxc_errors;        /* SDIO errors when reading control frames */
102         uint rx_hdrfail;        /* SDIO errors on header reads */
103         uint rx_badhdr;         /* Bad received headers (roosync?) */
104         uint rx_badseq;         /* Mismatched rx sequence number */
105         uint fc_rcvd;           /* Number of flow-control events received */
106         uint fc_xoff;           /* Number which turned on flow-control */
107         uint fc_xon;            /* Number which turned off flow-control */
108         uint rxglomfail;        /* Failed deglom attempts */
109         uint rxglomframes;      /* Number of glom frames (superframes) */
110         uint rxglompkts;        /* Number of packets from glom frames */
111         uint f2rxhdrs;          /* Number of header reads */
112         uint f2rxdata;          /* Number of frame data reads */
113         uint f2txdata;          /* Number of f2 frame writes */
114         uint f1regdata;         /* Number of f1 register accesses */
115         uint tickcnt;           /* Number of watchdog been schedule */
116         ulong tx_ctlerrs;       /* Err of sending ctrl frames */
117         ulong tx_ctlpkts;       /* Ctrl frames sent to dongle */
118         ulong rx_ctlerrs;       /* Err of processing rx ctrl frames */
119         ulong rx_ctlpkts;       /* Ctrl frames processed from dongle */
120         ulong rx_readahead_cnt; /* packets where header read-ahead was used */
121 };
122
123 struct brcmf_pub;
124 #ifdef DEBUG
125 void brcmf_debugfs_init(void);
126 void brcmf_debugfs_exit(void);
127 int brcmf_debugfs_attach(struct brcmf_pub *drvr);
128 void brcmf_debugfs_detach(struct brcmf_pub *drvr);
129 struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
130 void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr,
131                                      struct brcmf_sdio_count *sdcnt);
132 #else
133 static inline void brcmf_debugfs_init(void)
134 {
135 }
136 static inline void brcmf_debugfs_exit(void)
137 {
138 }
139 static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
140 {
141         return 0;
142 }
143 static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
144 {
145 }
146 #endif
147
148 #endif                          /* _BRCMF_DBG_H_ */