aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/wireless/iwmc3200wifi/debug.h
blob: f98bf125a8ae544f95d2416a8db45556172fe7cc (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
/*
 * Intel Wireless Multicomm 3200 WiFi driver
 *
 * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
 * Samuel Ortiz <samuel.ortiz@intel.com>
 * Zhu Yi <yi.zhu@intel.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 */

#ifndef __IWM_DEBUG_H__
#define __IWM_DEBUG_H__

#define IWM_ERR(p, f, a...) dev_err(iwm_to_dev(p), f, ## a)
#define IWM_WARN(p, f, a...) dev_warn(iwm_to_dev(p), f, ## a)
#define IWM_INFO(p, f, a...) dev_info(iwm_to_dev(p), f, ## a)
#define IWM_CRIT(p, f, a...) dev_crit(iwm_to_dev(p), f, ## a)

#ifdef CONFIG_IWM_DEBUG

#define IWM_DEBUG_MODULE(i, level, module, f, a...)			     \
do {									     \
	if (unlikely(i->dbg.dbg_module[IWM_DM_##module] >= (IWM_DL_##level)))\
		dev_printk(KERN_INFO, (iwm_to_dev(i)),	             \
			   "%s " f, __func__ , ## a);			     \
} while (0)

#define IWM_HEXDUMP(i, level, module, pref, buf, len)		             \
do {									     \
	if (unlikely(i->dbg.dbg_module[IWM_DM_##module] >= (IWM_DL_##level)))\
		print_hex_dump(KERN_INFO, pref, DUMP_PREFIX_OFFSET,	     \
			       16, 1, buf, len, 1);			     \
} while (0)

#else

#define IWM_DEBUG_MODULE(i, level, module, f, a...)
#define IWM_HEXDUMP(i, level, module, pref, buf, len)

#endif /* CONFIG_IWM_DEBUG */

/* Debug modules */
enum iwm_debug_module_id {
	IWM_DM_BOOT = 0,
	IWM_DM_FW,
	IWM_DM_SDIO,
	IWM_DM_NTF,
	IWM_DM_RX,
	IWM_DM_TX,
	IWM_DM_MLME,
	IWM_DM_CMD,
	IWM_DM_WEXT,
	__IWM_DM_NR,
};
#define IWM_DM_DEFAULT 0

#define IWM_DBG_BOOT(i, l, f, a...) IWM_DEBUG_MODULE(i, l, BOOT, f, ## a)
#define IWM_DBG_FW(i, l, f, a...)   IWM_DEBUG_MODULE(i, l, FW, f, ## a)
#define IWM_DBG_SDIO(i, l, f, a...) IWM_DEBUG_MODULE(i, l, SDIO, f, ## a)
#define IWM_DBG_NTF(i, l, f, a...)  IWM_DEBUG_MODULE(i, l, NTF, f, ## a)
#define IWM_DBG_RX(i, l, f, a...)   IWM_DEBUG_MODULE(i, l, RX, f, ## a)
#define IWM_DBG_TX(i, l, f, a...)   IWM_DEBUG_MODULE(i, l, TX, f, ## a)
#define IWM_DBG_MLME(i, l, f, a...) IWM_DEBUG_MODULE(i, l, MLME, f, ## a)
#define IWM_DBG_CMD(i, l, f, a...)  IWM_DEBUG_MODULE(i, l, CMD, f, ## a)
#define IWM_DBG_WEXT(i, l, f, a...) IWM_DEBUG_MODULE(i, l, WEXT, f, ## a)

/* Debug levels */
enum iwm_debug_level {
	IWM_DL_NONE = 0,
	IWM_DL_ERR,
	IWM_DL_WARN,
	IWM_DL_INFO,
	IWM_DL_DBG,
};
#define IWM_DL_DEFAULT IWM_DL_ERR

struct iwm_debugfs {
	struct iwm_priv *iwm;
	struct dentry *rootdir;
	struct dentry *devdir;
	struct dentry *dbgdir;
	struct dentry *txdir;
	struct dentry *rxdir;
	struct dentry *busdir;

	u32 dbg_level;
	struct dentry *dbg_level_dentry;

	unsigned long dbg_modules;
	struct dentry *dbg_modules_dentry;

	u8 dbg_module[__IWM_DM_NR];
	struct dentry *dbg_module_dentries[__IWM_DM_NR];

	struct dentry *txq_dentry;
	struct dentry *tx_credit_dentry;
	struct dentry *rx_ticket_dentry;

	struct dentry *fw_err_dentry;
};

#ifdef CONFIG_IWM_DEBUG
void iwm_debugfs_init(struct iwm_priv *iwm);
void iwm_debugfs_exit(struct iwm_priv *iwm);
#else
static inline void iwm_debugfs_init(struct iwm_priv *iwm)
{
	return 0;
}
static inline void iwm_debugfs_exit(struct iwm_priv *iwm) {}
#endif

#endif