Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2007 Bruno Randolf <bruno@thinktube.com> |
| 3 | * |
| 4 | * This file is free software: you may copy, redistribute and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation, either version 2 of the License, or (at your |
| 7 | * option) any later version. |
| 8 | * |
| 9 | * This file is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * |
| 18 | * This file incorporates work covered by the following copyright and |
| 19 | * permission notice: |
| 20 | * |
| 21 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting |
| 22 | * Copyright (c) 2004-2005 Atheros Communications, Inc. |
| 23 | * Copyright (c) 2006 Devicescape Software, Inc. |
| 24 | * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com> |
| 25 | * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu> |
| 26 | * |
| 27 | * All rights reserved. |
| 28 | * |
| 29 | * Redistribution and use in source and binary forms, with or without |
| 30 | * modification, are permitted provided that the following conditions |
| 31 | * are met: |
| 32 | * 1. Redistributions of source code must retain the above copyright |
| 33 | * notice, this list of conditions and the following disclaimer, |
| 34 | * without modification. |
| 35 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 36 | * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any |
| 37 | * redistribution must be conditioned upon including a substantially |
| 38 | * similar Disclaimer requirement for further binary redistribution. |
| 39 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 40 | * of any contributors may be used to endorse or promote products derived |
| 41 | * from this software without specific prior written permission. |
| 42 | * |
| 43 | * Alternatively, this software may be distributed under the terms of the |
| 44 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 45 | * Software Foundation. |
| 46 | * |
| 47 | * NO WARRANTY |
| 48 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 49 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 50 | * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY |
| 51 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 52 | * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, |
| 53 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 54 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 55 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 56 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 57 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 58 | * THE POSSIBILITY OF SUCH DAMAGES. |
| 59 | */ |
| 60 | |
| 61 | #ifndef _ATH5K_DEBUG_H |
| 62 | #define _ATH5K_DEBUG_H |
| 63 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 64 | struct ath5k_hw; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 65 | struct sk_buff; |
| 66 | struct ath5k_buf; |
| 67 | |
| 68 | struct ath5k_dbg_info { |
| 69 | unsigned int level; /* debug level */ |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | /** |
| 73 | * enum ath5k_debug_level - ath5k debug level |
| 74 | * |
| 75 | * @ATH5K_DEBUG_RESET: reset processing |
| 76 | * @ATH5K_DEBUG_INTR: interrupt handling |
| 77 | * @ATH5K_DEBUG_MODE: mode init/setup |
| 78 | * @ATH5K_DEBUG_XMIT: basic xmit operation |
| 79 | * @ATH5K_DEBUG_BEACON: beacon handling |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 80 | * @ATH5K_DEBUG_CALIBRATE: periodic calibration |
| 81 | * @ATH5K_DEBUG_TXPOWER: transmit power setting |
| 82 | * @ATH5K_DEBUG_LED: led management |
| 83 | * @ATH5K_DEBUG_DUMP_RX: print received skb content |
| 84 | * @ATH5K_DEBUG_DUMP_TX: print transmit skb content |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 85 | * @ATH5K_DEBUG_DUMPBANDS: dump bands |
Nick Kossifidis | b3a28e6 | 2010-11-23 20:47:31 +0200 | [diff] [blame] | 86 | * @ATH5K_DEBUG_DMA: debug dma start/stop |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 87 | * @ATH5K_DEBUG_TRACE: trace function calls |
Bob Copeland | b4c5261 | 2010-08-21 16:39:03 -0400 | [diff] [blame] | 88 | * @ATH5K_DEBUG_DESC: descriptor setup |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 89 | * @ATH5K_DEBUG_ANY: show at any debug level |
| 90 | * |
| 91 | * The debug level is used to control the amount and type of debugging output |
| 92 | * we want to see. The debug level is given in calls to ATH5K_DBG to specify |
| 93 | * where the message should appear, and the user can control the debugging |
| 94 | * messages he wants to see, either by the module parameter 'debug' on module |
| 95 | * load, or dynamically by using debugfs 'ath5k/phyX/debug'. these levels can |
| 96 | * be combined together by bitwise OR. |
| 97 | */ |
| 98 | enum ath5k_debug_level { |
| 99 | ATH5K_DEBUG_RESET = 0x00000001, |
| 100 | ATH5K_DEBUG_INTR = 0x00000002, |
| 101 | ATH5K_DEBUG_MODE = 0x00000004, |
| 102 | ATH5K_DEBUG_XMIT = 0x00000008, |
| 103 | ATH5K_DEBUG_BEACON = 0x00000010, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 104 | ATH5K_DEBUG_CALIBRATE = 0x00000020, |
| 105 | ATH5K_DEBUG_TXPOWER = 0x00000040, |
| 106 | ATH5K_DEBUG_LED = 0x00000080, |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 107 | ATH5K_DEBUG_DUMPBANDS = 0x00000400, |
Nick Kossifidis | b3a28e6 | 2010-11-23 20:47:31 +0200 | [diff] [blame] | 108 | ATH5K_DEBUG_DMA = 0x00000800, |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 109 | ATH5K_DEBUG_ANI = 0x00002000, |
Bob Copeland | b4c5261 | 2010-08-21 16:39:03 -0400 | [diff] [blame] | 110 | ATH5K_DEBUG_DESC = 0x00004000, |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 111 | ATH5K_DEBUG_ANY = 0xffffffff |
| 112 | }; |
| 113 | |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 114 | #ifdef CONFIG_ATH5K_DEBUG |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 115 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 116 | #define ATH5K_DBG(_sc, _m, _fmt, ...) do { \ |
| 117 | if (unlikely((_sc)->debug.level & (_m) && net_ratelimit())) \ |
| 118 | ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \ |
| 119 | __func__, __LINE__, ##__VA_ARGS__); \ |
| 120 | } while (0) |
| 121 | |
| 122 | #define ATH5K_DBG_UNLIMIT(_sc, _m, _fmt, ...) do { \ |
| 123 | if (unlikely((_sc)->debug.level & (_m))) \ |
| 124 | ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \ |
| 125 | __func__, __LINE__, ##__VA_ARGS__); \ |
| 126 | } while (0) |
| 127 | |
| 128 | void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 129 | ath5k_debug_init_device(struct ath5k_hw *ah); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 130 | |
| 131 | void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 132 | ath5k_debug_printrxbuffs(struct ath5k_hw *ah); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 133 | |
| 134 | void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 135 | ath5k_debug_dump_bands(struct ath5k_hw *ah); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 136 | |
| 137 | void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 138 | ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 139 | |
| 140 | #else /* no debugging */ |
| 141 | |
Jiri Slaby | 6cd74e3 | 2008-02-15 21:58:53 +0100 | [diff] [blame] | 142 | #include <linux/compiler.h> |
| 143 | |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame^] | 144 | static inline __printf(3, 4) void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 145 | ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {} |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 146 | |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame^] | 147 | static inline __printf(3, 4) void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 148 | ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 149 | {} |
| 150 | |
| 151 | static inline void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 152 | ath5k_debug_init_device(struct ath5k_hw *ah) {} |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 153 | |
| 154 | static inline void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 155 | ath5k_debug_printrxbuffs(struct ath5k_hw *ah) {} |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 156 | |
| 157 | static inline void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 158 | ath5k_debug_dump_bands(struct ath5k_hw *ah) {} |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 159 | |
| 160 | static inline void |
Pavel Roskin | e0d687b | 2011-07-14 20:21:55 -0400 | [diff] [blame] | 161 | ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf) {} |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 162 | |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 163 | #endif /* ifdef CONFIG_ATH5K_DEBUG */ |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 164 | |
| 165 | #endif /* ifndef _ATH5K_DEBUG_H */ |