1/*-
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer,
10 *    without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 *    redistribution must be conditioned upon including a substantially
14 *    similar Disclaimer requirement for further binary redistribution.
15 *
16 * NO WARRANTY
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 *
29 * $FreeBSD$
30 */
31#ifndef	__IF_ATH_DEBUG_H__
32#define	__IF_ATH_DEBUG_H__
33
34#ifdef	ATH_DEBUG
35
36enum {
37	ATH_DEBUG_XMIT		= 0x00000001,	/* basic xmit operation */
38	ATH_DEBUG_XMIT_DESC	= 0x00000002,	/* xmit descriptors */
39	ATH_DEBUG_RECV		= 0x00000004,	/* basic recv operation */
40	ATH_DEBUG_RECV_DESC	= 0x00000008,	/* recv descriptors */
41	ATH_DEBUG_RATE		= 0x00000010,	/* rate control */
42	ATH_DEBUG_RESET		= 0x00000020,	/* reset processing */
43	ATH_DEBUG_MODE		= 0x00000040,	/* mode init/setup */
44	ATH_DEBUG_BEACON	= 0x00000080,	/* beacon handling */
45	ATH_DEBUG_WATCHDOG	= 0x00000100,	/* watchdog timeout */
46	ATH_DEBUG_INTR		= 0x00001000,	/* ISR */
47	ATH_DEBUG_TX_PROC	= 0x00002000,	/* tx ISR proc */
48	ATH_DEBUG_RX_PROC	= 0x00004000,	/* rx ISR proc */
49	ATH_DEBUG_BEACON_PROC	= 0x00008000,	/* beacon ISR proc */
50	ATH_DEBUG_CALIBRATE	= 0x00010000,	/* periodic calibration */
51	ATH_DEBUG_KEYCACHE	= 0x00020000,	/* key cache management */
52	ATH_DEBUG_STATE		= 0x00040000,	/* 802.11 state transitions */
53	ATH_DEBUG_NODE		= 0x00080000,	/* node management */
54	ATH_DEBUG_LED		= 0x00100000,	/* led management */
55	ATH_DEBUG_FF		= 0x00200000,	/* fast frames */
56	ATH_DEBUG_DFS		= 0x00400000,	/* DFS processing */
57	ATH_DEBUG_TDMA		= 0x00800000,	/* TDMA processing */
58	ATH_DEBUG_TDMA_TIMER	= 0x01000000,	/* TDMA timer processing */
59	ATH_DEBUG_REGDOMAIN	= 0x02000000,	/* regulatory processing */
60	ATH_DEBUG_FATAL		= 0x80000000,	/* fatal errors */
61	ATH_DEBUG_ANY		= 0xffffffff
62};
63
64extern int	ath_debug;
65
66#define	IFF_DUMPPKTS(sc, m) \
67	((sc->sc_debug & (m)) || \
68	    (sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
69#define	DPRINTF(sc, m, fmt, ...) do {				\
70	if (sc->sc_debug & (m))					\
71		device_printf(sc->sc_dev, fmt, __VA_ARGS__);		\
72} while (0)
73#define	KEYPRINTF(sc, ix, hk, mac) do {				\
74	if (sc->sc_debug & ATH_DEBUG_KEYCACHE)			\
75		ath_keyprint(sc, __func__, ix, hk, mac);	\
76} while (0)
77
78extern	void ath_printrxbuf(struct ath_softc *, const struct ath_buf *bf,
79	u_int ix, int);
80extern	void ath_printtxbuf(struct ath_softc *, const struct ath_buf *bf,
81	u_int qnum, u_int ix, int done);
82#else	/* ATH_DEBUG */
83#define	IFF_DUMPPKTS(sc, m) \
84	((sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
85#define	DPRINTF(sc, m, fmt, ...) do {				\
86	(void) sc;						\
87} while (0)
88#define	KEYPRINTF(sc, k, ix, mac) do {				\
89	(void) sc;						\
90} while (0)
91#endif	/* ATH_DEBUG */
92
93#endif
94