bf31754b0cbed4e93191272e1faf720015aade31
[openwrt.git] / package / bcm43xx-mac80211 / src / bcm43xx / bcm43xx_debugfs.h
1 #ifndef BCM43xx_DEBUGFS_H_
2 #define BCM43xx_DEBUGFS_H_
3
4 struct bcm43xx_wldev;
5 struct bcm43xx_txstatus;
6
7 enum bcm43xx_dyndbg { /* Dynamic debugging features */
8         BCM43xx_DBG_XMITPOWER,
9         BCM43xx_DBG_DMAOVERFLOW,
10         BCM43xx_DBG_DMAVERBOSE,
11         BCM43xx_DBG_PWORK_FAST,
12         BCM43xx_DBG_PWORK_STOP,
13         __BCM43xx_NR_DYNDBG,
14 };
15
16
17 #ifdef CONFIG_BCM43XX_MAC80211_DEBUG
18
19 struct dentry;
20
21 #define BCM43xx_NR_LOGGED_TXSTATUS      100
22
23 struct bcm43xx_txstatus_log {
24         struct bcm43xx_txstatus *log;
25         int end;
26         int printing;
27         char printbuf[(BCM43xx_NR_LOGGED_TXSTATUS * 70) + 200];
28         size_t buf_avail;
29         spinlock_t lock;
30 };
31
32 struct bcm43xx_dfsentry {
33         struct dentry *subdir;
34         struct dentry *dentry_tsf;
35         struct dentry *dentry_txstat;
36         struct dentry *dentry_txpower_g;
37         struct dentry *dentry_restart;
38
39         struct bcm43xx_wldev *dev;
40
41         struct bcm43xx_txstatus_log txstatlog;
42
43         /* Enabled/Disabled list for the dynamic debugging features. */
44         u32 dyn_debug[__BCM43xx_NR_DYNDBG];
45         /* Dentries for the dynamic debugging entries. */
46         struct dentry *dyn_debug_dentries[__BCM43xx_NR_DYNDBG];
47 };
48
49 struct bcm43xx_debugfs {
50         struct dentry *root;
51         struct dentry *dentry_driverinfo;
52 };
53
54 int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature);
55
56 void bcm43xx_debugfs_init(void);
57 void bcm43xx_debugfs_exit(void);
58 void bcm43xx_debugfs_add_device(struct bcm43xx_wldev *dev);
59 void bcm43xx_debugfs_remove_device(struct bcm43xx_wldev *dev);
60 void bcm43xx_debugfs_log_txstat(struct bcm43xx_wldev *dev,
61                                 const struct bcm43xx_txstatus *status);
62
63 /* Debug helper: Dump binary data through printk. */
64 void bcm43xx_printk_dump(const char *data,
65                          size_t size,
66                          const char *description);
67 /* Debug helper: Dump bitwise binary data through printk. */
68 void bcm43xx_printk_bitdump(const unsigned char *data,
69                             size_t bytes, int msb_to_lsb,
70                             const char *description);
71 #define bcm43xx_printk_bitdumpt(pointer, msb_to_lsb, description) \
72         do {                                                                    \
73                 bcm43xx_printk_bitdump((const unsigned char *)(pointer),        \
74                                        sizeof(*(pointer)),                      \
75                                        (msb_to_lsb),                            \
76                                        (description));                          \
77         } while (0)
78
79 #else /* CONFIG_BCM43XX_MAC80211_DEBUG*/
80
81 static inline
82 int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature)
83 {
84         return 0;
85 }
86
87 static inline
88 void bcm43xx_debugfs_init(void) { }
89 static inline
90 void bcm43xx_debugfs_exit(void) { }
91 static inline
92 void bcm43xx_debugfs_add_device(struct bcm43xx_wldev *dev) { }
93 static inline
94 void bcm43xx_debugfs_remove_device(struct bcm43xx_wldev *dev) { }
95 static inline
96 void bcm43xx_debugfs_log_txstat(struct bcm43xx_wldev *dev,
97                                 const struct bcm43xx_txstatus *status) { }
98
99 static inline
100 void bcm43xx_printk_dump(const char *data,
101                          size_t size,
102                          const char *description)
103 {
104 }
105 static inline
106 void bcm43xx_printk_bitdump(const unsigned char *data,
107                             size_t bytes, int msb_to_lsb,
108                             const char *description)
109 {
110 }
111 #define bcm43xx_printk_bitdumpt(pointer, msb_to_lsb, description)  do { /* nothing */ } while (0)
112
113 #endif /* CONFIG_BCM43XX_MAC80211_DEBUG*/
114
115 /* Ugly helper macros to make incomplete code more verbose on runtime */
116 #ifdef TODO
117 # undef TODO
118 #endif
119 #define TODO()  \
120         do {                                                                            \
121                 printk(KERN_INFO PFX "TODO: Incomplete code in %s() at %s:%d\n",        \
122                        __FUNCTION__, __FILE__, __LINE__);                               \
123         } while (0)
124
125 #ifdef FIXME
126 # undef FIXME
127 #endif
128 #define FIXME()  \
129         do {                                                                            \
130                 printk(KERN_INFO PFX "FIXME: Possibly broken code in %s() at %s:%d\n",  \
131                        __FUNCTION__, __FILE__, __LINE__);                               \
132         } while (0)
133
134 #endif /* BCM43xx_DEBUGFS_H_ */