18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2007 Bruno Randolf <bruno@thinktube.com> 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This file is free software: you may copy, redistribute and/or modify it 58c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License as published by the 68c2ecf20Sopenharmony_ci * Free Software Foundation, either version 2 of the License, or (at your 78c2ecf20Sopenharmony_ci * option) any later version. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This file is distributed in the hope that it will be useful, but 108c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 118c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 128c2ecf20Sopenharmony_ci * General Public License for more details. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 158c2ecf20Sopenharmony_ci * along with this program. If not, see <http://www.gnu.org/licenses/>. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * This file incorporates work covered by the following copyright and 198c2ecf20Sopenharmony_ci * permission notice: 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 228c2ecf20Sopenharmony_ci * Copyright (c) 2004-2005 Atheros Communications, Inc. 238c2ecf20Sopenharmony_ci * Copyright (c) 2006 Devicescape Software, Inc. 248c2ecf20Sopenharmony_ci * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com> 258c2ecf20Sopenharmony_ci * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu> 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * All rights reserved. 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 308c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 318c2ecf20Sopenharmony_ci * are met: 328c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 338c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer, 348c2ecf20Sopenharmony_ci * without modification. 358c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer 368c2ecf20Sopenharmony_ci * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 378c2ecf20Sopenharmony_ci * redistribution must be conditioned upon including a substantially 388c2ecf20Sopenharmony_ci * similar Disclaimer requirement for further binary redistribution. 398c2ecf20Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names 408c2ecf20Sopenharmony_ci * of any contributors may be used to endorse or promote products derived 418c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 428c2ecf20Sopenharmony_ci * 438c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 448c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 458c2ecf20Sopenharmony_ci * Software Foundation. 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * NO WARRANTY 488c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 498c2ecf20Sopenharmony_ci * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 508c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 518c2ecf20Sopenharmony_ci * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 528c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 538c2ecf20Sopenharmony_ci * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 548c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 558c2ecf20Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 568c2ecf20Sopenharmony_ci * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 578c2ecf20Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 588c2ecf20Sopenharmony_ci * THE POSSIBILITY OF SUCH DAMAGES. 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#ifndef _ATH5K_DEBUG_H 628c2ecf20Sopenharmony_ci#define _ATH5K_DEBUG_H 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct ath5k_hw; 658c2ecf20Sopenharmony_cistruct sk_buff; 668c2ecf20Sopenharmony_cistruct ath5k_buf; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct ath5k_dbg_info { 698c2ecf20Sopenharmony_ci unsigned int level; /* debug level */ 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/** 738c2ecf20Sopenharmony_ci * enum ath5k_debug_level - ath5k debug level 748c2ecf20Sopenharmony_ci * 758c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_RESET: reset processing 768c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_INTR: interrupt handling 778c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_MODE: mode init/setup 788c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_XMIT: basic xmit operation 798c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_BEACON: beacon handling 808c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_CALIBRATE: periodic calibration 818c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_TXPOWER: transmit power setting 828c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_LED: led management 838c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_DUMP_RX: print received skb content 848c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_DUMP_TX: print transmit skb content 858c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_DUMPBANDS: dump bands 868c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_DMA: debug dma start/stop 878c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_TRACE: trace function calls 888c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_DESC: descriptor setup 898c2ecf20Sopenharmony_ci * @ATH5K_DEBUG_ANY: show at any debug level 908c2ecf20Sopenharmony_ci * 918c2ecf20Sopenharmony_ci * The debug level is used to control the amount and type of debugging output 928c2ecf20Sopenharmony_ci * we want to see. The debug level is given in calls to ATH5K_DBG to specify 938c2ecf20Sopenharmony_ci * where the message should appear, and the user can control the debugging 948c2ecf20Sopenharmony_ci * messages he wants to see, either by the module parameter 'debug' on module 958c2ecf20Sopenharmony_ci * load, or dynamically by using debugfs 'ath5k/phyX/debug'. these levels can 968c2ecf20Sopenharmony_ci * be combined together by bitwise OR. 978c2ecf20Sopenharmony_ci */ 988c2ecf20Sopenharmony_cienum ath5k_debug_level { 998c2ecf20Sopenharmony_ci ATH5K_DEBUG_RESET = 0x00000001, 1008c2ecf20Sopenharmony_ci ATH5K_DEBUG_INTR = 0x00000002, 1018c2ecf20Sopenharmony_ci ATH5K_DEBUG_MODE = 0x00000004, 1028c2ecf20Sopenharmony_ci ATH5K_DEBUG_XMIT = 0x00000008, 1038c2ecf20Sopenharmony_ci ATH5K_DEBUG_BEACON = 0x00000010, 1048c2ecf20Sopenharmony_ci ATH5K_DEBUG_CALIBRATE = 0x00000020, 1058c2ecf20Sopenharmony_ci ATH5K_DEBUG_TXPOWER = 0x00000040, 1068c2ecf20Sopenharmony_ci ATH5K_DEBUG_LED = 0x00000080, 1078c2ecf20Sopenharmony_ci ATH5K_DEBUG_DUMPBANDS = 0x00000400, 1088c2ecf20Sopenharmony_ci ATH5K_DEBUG_DMA = 0x00000800, 1098c2ecf20Sopenharmony_ci ATH5K_DEBUG_ANI = 0x00002000, 1108c2ecf20Sopenharmony_ci ATH5K_DEBUG_DESC = 0x00004000, 1118c2ecf20Sopenharmony_ci ATH5K_DEBUG_ANY = 0xffffffff 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH5K_DEBUG 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define ATH5K_DBG(_sc, _m, _fmt, ...) do { \ 1178c2ecf20Sopenharmony_ci if (unlikely((_sc)->debug.level & (_m) && net_ratelimit())) \ 1188c2ecf20Sopenharmony_ci ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \ 1198c2ecf20Sopenharmony_ci __func__, __LINE__, ##__VA_ARGS__); \ 1208c2ecf20Sopenharmony_ci } while (0) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define ATH5K_DBG_UNLIMIT(_sc, _m, _fmt, ...) do { \ 1238c2ecf20Sopenharmony_ci if (unlikely((_sc)->debug.level & (_m))) \ 1248c2ecf20Sopenharmony_ci ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \ 1258c2ecf20Sopenharmony_ci __func__, __LINE__, ##__VA_ARGS__); \ 1268c2ecf20Sopenharmony_ci } while (0) 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_civoid 1298c2ecf20Sopenharmony_ciath5k_debug_init_device(struct ath5k_hw *ah); 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_civoid 1328c2ecf20Sopenharmony_ciath5k_debug_printrxbuffs(struct ath5k_hw *ah); 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_civoid 1358c2ecf20Sopenharmony_ciath5k_debug_dump_bands(struct ath5k_hw *ah); 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_civoid 1388c2ecf20Sopenharmony_ciath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf); 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#else /* no debugging */ 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci#include <linux/compiler.h> 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistatic inline __printf(3, 4) void 1458c2ecf20Sopenharmony_ciATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistatic inline __printf(3, 4) void 1488c2ecf20Sopenharmony_ciATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) 1498c2ecf20Sopenharmony_ci{} 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistatic inline void 1528c2ecf20Sopenharmony_ciath5k_debug_init_device(struct ath5k_hw *ah) {} 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistatic inline void 1558c2ecf20Sopenharmony_ciath5k_debug_printrxbuffs(struct ath5k_hw *ah) {} 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistatic inline void 1588c2ecf20Sopenharmony_ciath5k_debug_dump_bands(struct ath5k_hw *ah) {} 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistatic inline void 1618c2ecf20Sopenharmony_ciath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf) {} 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci#endif /* ifdef CONFIG_ATH5K_DEBUG */ 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci#endif /* ifndef _ATH5K_DEBUG_H */ 166