summaryrefslogtreecommitdiffstats
path: root/package/bcm43xx-mac80211/src/bcm43xx/bcm43xx_debugfs.h
blob: 892299d550d962cd7282cbb338ca298bcb218ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef BCM43xx_DEBUGFS_H_
#define BCM43xx_DEBUGFS_H_

struct bcm43xx_wldev;
struct bcm43xx_txstatus;

enum bcm43xx_dyndbg { /* Dynamic debugging features */
	BCM43xx_DBG_XMITPOWER,
	BCM43xx_DBG_DMAOVERFLOW,
	BCM43xx_DBG_PWORK_FAST,
	BCM43xx_DBG_PWORK_STOP,
	__BCM43xx_NR_DYNDBG,
};


#ifdef CONFIG_BCM43XX_MAC80211_DEBUG

struct dentry;

#define BCM43xx_NR_LOGGED_TXSTATUS	100

struct bcm43xx_txstatus_log {
	struct bcm43xx_txstatus *log;
	int end;
	int printing;
	char printbuf[(BCM43xx_NR_LOGGED_TXSTATUS * 70) + 200];
	size_t buf_avail;
	spinlock_t lock;
};

struct bcm43xx_dfsentry {
	struct dentry *subdir;
	struct dentry *dentry_tsf;
	struct dentry *dentry_txstat;
	struct dentry *dentry_txpower_g;
	struct dentry *dentry_restart;

	struct bcm43xx_wldev *dev;

	struct bcm43xx_txstatus_log txstatlog;

	/* Enabled/Disabled list for the dynamic debugging features. */
	u32 dyn_debug[__BCM43xx_NR_DYNDBG];
	/* Dentries for the dynamic debugging entries. */
	struct dentry *dyn_debug_dentries[__BCM43xx_NR_DYNDBG];
};

struct bcm43xx_debugfs {
	struct dentry *root;
	struct dentry *dentry_driverinfo;
};

int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature);

void bcm43xx_debugfs_init(void);
void bcm43xx_debugfs_exit(void);
void bcm43xx_debugfs_add_device(struct bcm43xx_wldev *dev);
void bcm43xx_debugfs_remove_device(struct bcm43xx_wldev *dev);
void bcm43xx_debugfs_log_txstat(struct bcm43xx_wldev *dev,
				const struct bcm43xx_txstatus *status);

/* Debug helper: Dump binary data through printk. */
void bcm43xx_printk_dump(const char *data,
			 size_t size,
			 const char *description);
/* Debug helper: Dump bitwise binary data through printk. */
void bcm43xx_printk_bitdump(const unsigned char *data,
			    size_t bytes, int msb_to_lsb,
			    const char *description);
#define bcm43xx_printk_bitdumpt(pointer, msb_to_lsb, description) \
	do {									\
		bcm43xx_printk_bitdump((const unsigned char *)(pointer),	\
				       sizeof(*(pointer)),			\
				       (msb_to_lsb),				\
				       (description));				\
	} while (0)

#else /* CONFIG_BCM43XX_MAC80211_DEBUG*/

static inline
int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature)
{
	return 0;
}

static inline
void bcm43xx_debugfs_init(void) { }
static inline
void bcm43xx_debugfs_exit(void) { }
static inline
void bcm43xx_debugfs_add_device(struct bcm43xx_wldev *dev) { }
static inline
void bcm43xx_debugfs_remove_device(struct bcm43xx_wldev *dev) { }
static inline
void bcm43xx_debugfs_log_txstat(struct bcm43xx_wldev *dev,
				const struct bcm43xx_txstatus *status) { }

static inline
void bcm43xx_printk_dump(const char *data,
			 size_t size,
			 const char *description)
{
}
static inline
void bcm43xx_printk_bitdump(const unsigned char *data,
			    size_t bytes, int msb_to_lsb,
			    const char *description)
{
}
#define bcm43xx_printk_bitdumpt(pointer, msb_to_lsb, description)  do { /* nothing */ } while (0)

#endif /* CONFIG_BCM43XX_MAC80211_DEBUG*/

/* Ugly helper macros to make incomplete code more verbose on runtime */
#ifdef TODO
# undef TODO
#endif
#define TODO()  \
	do {										\
		printk(KERN_INFO PFX "TODO: Incomplete code in %s() at %s:%d\n",	\
		       __FUNCTION__, __FILE__, __LINE__);				\
	} while (0)

#ifdef FIXME
# undef FIXME
#endif
#define FIXME()  \
	do {										\
		printk(KERN_INFO PFX "FIXME: Possibly broken code in %s() at %s:%d\n",	\
		       __FUNCTION__, __FILE__, __LINE__);				\
	} while (0)

#endif /* BCM43xx_DEBUGFS_H_ */