blob: 2e6058856a6a34f375f8b33020aa88b6231bcdd5 [file] [log] [blame]
Kalle Valobdcd8172011-07-18 00:22:30 +03001/*
2 * Copyright (c) 2011 Atheros Communications Inc.
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
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef DEBUG_H
18#define DEBUG_H
19
20#include "htc_hif.h"
21
22enum ATH6K_DEBUG_MASK {
23 ATH6KL_DBG_WLAN_CONNECT = BIT(0), /* wlan connect */
24 ATH6KL_DBG_WLAN_SCAN = BIT(1), /* wlan scan */
25 ATH6KL_DBG_WLAN_TX = BIT(2), /* wlan tx */
26 ATH6KL_DBG_WLAN_RX = BIT(3), /* wlan rx */
27 ATH6KL_DBG_BMI = BIT(4), /* bmi tracing */
28 ATH6KL_DBG_HTC_SEND = BIT(5), /* htc send */
29 ATH6KL_DBG_HTC_RECV = BIT(6), /* htc recv */
30 ATH6KL_DBG_IRQ = BIT(7), /* interrupt processing */
31 ATH6KL_DBG_PM = BIT(8), /* power management */
32 ATH6KL_DBG_WLAN_NODE = BIT(9), /* general wlan node tracing */
33 ATH6KL_DBG_WMI = BIT(10), /* wmi tracing */
34 ATH6KL_DBG_TRC = BIT(11), /* generic func tracing */
35 ATH6KL_DBG_SCATTER = BIT(12), /* hif scatter tracing */
36 ATH6KL_DBG_WLAN_CFG = BIT(13), /* cfg80211 i/f file tracing */
37 ATH6KL_DBG_RAW_BYTES = BIT(14), /* dump tx/rx and wmi frames */
38 ATH6KL_DBG_ANY = 0xffffffff /* enable all logs */
39};
40
41extern unsigned int debug_mask;
42extern int ath6kl_printk(const char *level, const char *fmt, ...)
43 __attribute__ ((format (printf, 2, 3)));
44
45#define ath6kl_info(fmt, ...) \
46 ath6kl_printk(KERN_INFO, fmt, ##__VA_ARGS__)
47#define ath6kl_err(fmt, ...) \
48 ath6kl_printk(KERN_ERR, fmt, ##__VA_ARGS__)
49#define ath6kl_warn(fmt, ...) \
50 ath6kl_printk(KERN_WARNING, fmt, ##__VA_ARGS__)
51
52#define AR_DBG_LVL_CHECK(mask) (debug_mask & mask)
53
54#ifdef CONFIG_ATH6KL_DEBUG
55#define ath6kl_dbg(mask, fmt, ...) \
56 ({ \
57 int rtn; \
58 if (debug_mask & mask) \
59 rtn = ath6kl_printk(KERN_DEBUG, fmt, ##__VA_ARGS__); \
60 else \
61 rtn = 0; \
62 \
63 rtn; \
64 })
65
66static inline void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
67 const char *msg, const void *buf,
68 size_t len)
69{
70 if (debug_mask & mask) {
71 ath6kl_dbg(mask, "%s\n", msg);
72 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len);
73 }
74}
75
76void ath6kl_dump_registers(struct ath6kl_device *dev,
77 struct ath6kl_irq_proc_registers *irq_proc_reg,
78 struct ath6kl_irq_enable_reg *irq_en_reg);
79void dump_cred_dist_stats(struct htc_target *target);
80#else
81static inline int ath6kl_dbg(enum ATH6K_DEBUG_MASK dbg_mask,
82 const char *fmt, ...)
83{
84 return 0;
85}
86
87static inline void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
88 const char *msg, const void *buf,
89 size_t len)
90{
91}
92
93static inline void ath6kl_dump_registers(struct ath6kl_device *dev,
94 struct ath6kl_irq_proc_registers *irq_proc_reg,
95 struct ath6kl_irq_enable_reg *irq_en_reg)
96{
97
98}
99static inline void dump_cred_dist_stats(struct htc_target *target)
100{
101}
102#endif
103
104#endif