162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) 2007 Bruno Randolf <bruno@thinktube.com>
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci *  This file is free software: you may copy, redistribute and/or modify it
562306a36Sopenharmony_ci *  under the terms of the GNU General Public License as published by the
662306a36Sopenharmony_ci *  Free Software Foundation, either version 2 of the License, or (at your
762306a36Sopenharmony_ci *  option) any later version.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci *  This file is distributed in the hope that it will be useful, but
1062306a36Sopenharmony_ci *  WITHOUT ANY WARRANTY; without even the implied warranty of
1162306a36Sopenharmony_ci *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1262306a36Sopenharmony_ci *  General Public License for more details.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci *  You should have received a copy of the GNU General Public License
1562306a36Sopenharmony_ci *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
1662306a36Sopenharmony_ci *
1762306a36Sopenharmony_ci *
1862306a36Sopenharmony_ci * This file incorporates work covered by the following copyright and
1962306a36Sopenharmony_ci * permission notice:
2062306a36Sopenharmony_ci *
2162306a36Sopenharmony_ci * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
2262306a36Sopenharmony_ci * Copyright (c) 2004-2005 Atheros Communications, Inc.
2362306a36Sopenharmony_ci * Copyright (c) 2006 Devicescape Software, Inc.
2462306a36Sopenharmony_ci * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
2562306a36Sopenharmony_ci * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * All rights reserved.
2862306a36Sopenharmony_ci *
2962306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
3062306a36Sopenharmony_ci * modification, are permitted provided that the following conditions
3162306a36Sopenharmony_ci * are met:
3262306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
3362306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer,
3462306a36Sopenharmony_ci *    without modification.
3562306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer
3662306a36Sopenharmony_ci *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
3762306a36Sopenharmony_ci *    redistribution must be conditioned upon including a substantially
3862306a36Sopenharmony_ci *    similar Disclaimer requirement for further binary redistribution.
3962306a36Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names
4062306a36Sopenharmony_ci *    of any contributors may be used to endorse or promote products derived
4162306a36Sopenharmony_ci *    from this software without specific prior written permission.
4262306a36Sopenharmony_ci *
4362306a36Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
4462306a36Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free
4562306a36Sopenharmony_ci * Software Foundation.
4662306a36Sopenharmony_ci *
4762306a36Sopenharmony_ci * NO WARRANTY
4862306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4962306a36Sopenharmony_ci * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5062306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
5162306a36Sopenharmony_ci * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
5262306a36Sopenharmony_ci * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
5362306a36Sopenharmony_ci * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5462306a36Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5562306a36Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
5662306a36Sopenharmony_ci * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5762306a36Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
5862306a36Sopenharmony_ci * THE POSSIBILITY OF SUCH DAMAGES.
5962306a36Sopenharmony_ci */
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#ifndef _ATH5K_DEBUG_H
6262306a36Sopenharmony_ci#define _ATH5K_DEBUG_H
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_cistruct ath5k_hw;
6562306a36Sopenharmony_cistruct sk_buff;
6662306a36Sopenharmony_cistruct ath5k_buf;
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_cistruct ath5k_dbg_info {
6962306a36Sopenharmony_ci	unsigned int		level;		/* debug level */
7062306a36Sopenharmony_ci};
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/**
7362306a36Sopenharmony_ci * enum ath5k_debug_level - ath5k debug level
7462306a36Sopenharmony_ci *
7562306a36Sopenharmony_ci * @ATH5K_DEBUG_RESET: reset processing
7662306a36Sopenharmony_ci * @ATH5K_DEBUG_INTR: interrupt handling
7762306a36Sopenharmony_ci * @ATH5K_DEBUG_MODE: mode init/setup
7862306a36Sopenharmony_ci * @ATH5K_DEBUG_XMIT: basic xmit operation
7962306a36Sopenharmony_ci * @ATH5K_DEBUG_BEACON: beacon handling
8062306a36Sopenharmony_ci * @ATH5K_DEBUG_CALIBRATE: periodic calibration
8162306a36Sopenharmony_ci * @ATH5K_DEBUG_TXPOWER: transmit power setting
8262306a36Sopenharmony_ci * @ATH5K_DEBUG_LED: led management
8362306a36Sopenharmony_ci * @ATH5K_DEBUG_DUMP_RX: print received skb content
8462306a36Sopenharmony_ci * @ATH5K_DEBUG_DUMP_TX: print transmit skb content
8562306a36Sopenharmony_ci * @ATH5K_DEBUG_DUMPBANDS: dump bands
8662306a36Sopenharmony_ci * @ATH5K_DEBUG_DMA: debug dma start/stop
8762306a36Sopenharmony_ci * @ATH5K_DEBUG_TRACE: trace function calls
8862306a36Sopenharmony_ci * @ATH5K_DEBUG_DESC: descriptor setup
8962306a36Sopenharmony_ci * @ATH5K_DEBUG_ANY: show at any debug level
9062306a36Sopenharmony_ci *
9162306a36Sopenharmony_ci * The debug level is used to control the amount and type of debugging output
9262306a36Sopenharmony_ci * we want to see. The debug level is given in calls to ATH5K_DBG to specify
9362306a36Sopenharmony_ci * where the message should appear, and the user can control the debugging
9462306a36Sopenharmony_ci * messages he wants to see, either by the module parameter 'debug' on module
9562306a36Sopenharmony_ci * load, or dynamically by using debugfs 'ath5k/phyX/debug'. these levels can
9662306a36Sopenharmony_ci * be combined together by bitwise OR.
9762306a36Sopenharmony_ci */
9862306a36Sopenharmony_cienum ath5k_debug_level {
9962306a36Sopenharmony_ci	ATH5K_DEBUG_RESET	= 0x00000001,
10062306a36Sopenharmony_ci	ATH5K_DEBUG_INTR	= 0x00000002,
10162306a36Sopenharmony_ci	ATH5K_DEBUG_MODE	= 0x00000004,
10262306a36Sopenharmony_ci	ATH5K_DEBUG_XMIT	= 0x00000008,
10362306a36Sopenharmony_ci	ATH5K_DEBUG_BEACON	= 0x00000010,
10462306a36Sopenharmony_ci	ATH5K_DEBUG_CALIBRATE	= 0x00000020,
10562306a36Sopenharmony_ci	ATH5K_DEBUG_TXPOWER	= 0x00000040,
10662306a36Sopenharmony_ci	ATH5K_DEBUG_LED		= 0x00000080,
10762306a36Sopenharmony_ci	ATH5K_DEBUG_DUMPBANDS	= 0x00000400,
10862306a36Sopenharmony_ci	ATH5K_DEBUG_DMA		= 0x00000800,
10962306a36Sopenharmony_ci	ATH5K_DEBUG_ANI		= 0x00002000,
11062306a36Sopenharmony_ci	ATH5K_DEBUG_DESC	= 0x00004000,
11162306a36Sopenharmony_ci	ATH5K_DEBUG_ANY		= 0xffffffff
11262306a36Sopenharmony_ci};
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#ifdef CONFIG_ATH5K_DEBUG
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define ATH5K_DBG(_sc, _m, _fmt, ...) do { \
11762306a36Sopenharmony_ci	if (unlikely((_sc)->debug.level & (_m) && net_ratelimit())) \
11862306a36Sopenharmony_ci		ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
11962306a36Sopenharmony_ci			__func__, __LINE__, ##__VA_ARGS__); \
12062306a36Sopenharmony_ci	} while (0)
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci#define ATH5K_DBG_UNLIMIT(_sc, _m, _fmt, ...) do { \
12362306a36Sopenharmony_ci	if (unlikely((_sc)->debug.level & (_m))) \
12462306a36Sopenharmony_ci		ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
12562306a36Sopenharmony_ci			__func__, __LINE__, ##__VA_ARGS__); \
12662306a36Sopenharmony_ci	} while (0)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_civoid
12962306a36Sopenharmony_ciath5k_debug_init_device(struct ath5k_hw *ah);
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_civoid
13262306a36Sopenharmony_ciath5k_debug_printrxbuffs(struct ath5k_hw *ah);
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_civoid
13562306a36Sopenharmony_ciath5k_debug_dump_bands(struct ath5k_hw *ah);
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_civoid
13862306a36Sopenharmony_ciath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf);
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci#else /* no debugging */
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#include <linux/compiler.h>
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_cistatic inline __printf(3, 4) void
14562306a36Sopenharmony_ciATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {}
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_cistatic inline __printf(3, 4) void
14862306a36Sopenharmony_ciATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...)
14962306a36Sopenharmony_ci{}
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_cistatic inline void
15262306a36Sopenharmony_ciath5k_debug_init_device(struct ath5k_hw *ah) {}
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_cistatic inline void
15562306a36Sopenharmony_ciath5k_debug_printrxbuffs(struct ath5k_hw *ah) {}
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_cistatic inline void
15862306a36Sopenharmony_ciath5k_debug_dump_bands(struct ath5k_hw *ah) {}
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_cistatic inline void
16162306a36Sopenharmony_ciath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf) {}
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci#endif /* ifdef CONFIG_ATH5K_DEBUG */
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#endif /* ifndef _ATH5K_DEBUG_H */
166