Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dhd_dbg.h
Go to the documentation of this file.
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_ERROR_VAL 0x0001
22 #define BRCMF_TRACE_VAL 0x0002
23 #define BRCMF_INFO_VAL 0x0004
24 #define BRCMF_DATA_VAL 0x0008
25 #define BRCMF_CTL_VAL 0x0010
26 #define BRCMF_TIMER_VAL 0x0020
27 #define BRCMF_HDRS_VAL 0x0040
28 #define BRCMF_BYTES_VAL 0x0080
29 #define BRCMF_INTR_VAL 0x0100
30 #define BRCMF_GLOM_VAL 0x0400
31 #define BRCMF_EVENT_VAL 0x0800
32 #define BRCMF_BTA_VAL 0x1000
33 #define BRCMF_ISCAN_VAL 0x2000
34 
35 #if defined(DEBUG)
36 
37 #define brcmf_dbg(level, fmt, ...) \
38 do { \
39  if (BRCMF_ERROR_VAL == BRCMF_##level##_VAL) { \
40  if (brcmf_msg_level & BRCMF_##level##_VAL) { \
41  if (net_ratelimit()) \
42  pr_debug("%s: " fmt, \
43  __func__, ##__VA_ARGS__); \
44  } \
45  } else { \
46  if (brcmf_msg_level & BRCMF_##level##_VAL) { \
47  pr_debug("%s: " fmt, \
48  __func__, ##__VA_ARGS__); \
49  } \
50  } \
51 } while (0)
52 
53 #define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL)
54 #define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL)
55 #define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL)
56 #define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL)
57 #define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL)
58 #define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL)
59 
60 #else /* (defined DEBUG) || (defined DEBUG) */
61 
62 #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
63 
64 #define BRCMF_DATA_ON() 0
65 #define BRCMF_CTL_ON() 0
66 #define BRCMF_HDRS_ON() 0
67 #define BRCMF_BYTES_ON() 0
68 #define BRCMF_GLOM_ON() 0
69 #define BRCMF_EVENT_ON() 0
70 
71 #endif /* defined(DEBUG) */
72 
73 #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
74 do { \
75  if (test) \
76  brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
77 } while (0)
78 
79 extern int brcmf_msg_level;
80 
81 /*
82  * hold counter variables used in brcmfmac sdio driver.
83  */
85  uint intrcount; /* Count of device interrupt callbacks */
86  uint lastintrs; /* Count as of last watchdog timer */
87  uint pollcnt; /* Count of active polls */
88  uint regfails; /* Count of R_REG failures */
89  uint tx_sderrs; /* Count of tx attempts with sd errors */
90  uint fcqueued; /* Tx packets that got queued */
91  uint rxrtx; /* Count of rtx requests (NAK to dongle) */
92  uint rx_toolong; /* Receive frames too long to receive */
93  uint rxc_errors; /* SDIO errors when reading control frames */
94  uint rx_hdrfail; /* SDIO errors on header reads */
95  uint rx_badhdr; /* Bad received headers (roosync?) */
96  uint rx_badseq; /* Mismatched rx sequence number */
97  uint fc_rcvd; /* Number of flow-control events received */
98  uint fc_xoff; /* Number which turned on flow-control */
99  uint fc_xon; /* Number which turned off flow-control */
100  uint rxglomfail; /* Failed deglom attempts */
101  uint rxglomframes; /* Number of glom frames (superframes) */
102  uint rxglompkts; /* Number of packets from glom frames */
103  uint f2rxhdrs; /* Number of header reads */
104  uint f2rxdata; /* Number of frame data reads */
105  uint f2txdata; /* Number of f2 frame writes */
106  uint f1regdata; /* Number of f1 register accesses */
107  uint tickcnt; /* Number of watchdog been schedule */
108  ulong tx_ctlerrs; /* Err of sending ctrl frames */
109  ulong tx_ctlpkts; /* Ctrl frames sent to dongle */
110  ulong rx_ctlerrs; /* Err of processing rx ctrl frames */
111  ulong rx_ctlpkts; /* Ctrl frames processed from dongle */
112  ulong rx_readahead_cnt; /* packets where header read-ahead was used */
113 };
114 
115 struct brcmf_pub;
116 #ifdef DEBUG
117 void brcmf_debugfs_init(void);
118 void brcmf_debugfs_exit(void);
119 int brcmf_debugfs_attach(struct brcmf_pub *drvr);
120 void brcmf_debugfs_detach(struct brcmf_pub *drvr);
121 struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
123  struct brcmf_sdio_count *sdcnt);
124 #else
125 static inline void brcmf_debugfs_init(void)
126 {
127 }
128 static inline void brcmf_debugfs_exit(void)
129 {
130 }
131 static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
132 {
133  return 0;
134 }
135 static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
136 {
137 }
138 #endif
139 
140 #endif /* _BRCMF_DBG_H_ */