debug.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007-2008 Bruno Randolf <bruno@thinktube.com>
00003  *
00004  *  This file is free software: you may copy, redistribute and/or modify it
00005  *  under the terms of the GNU General Public License as published by the
00006  *  Free Software Foundation, either version 2 of the License, or (at your
00007  *  option) any later version.
00008  *
00009  *  This file is distributed in the hope that it will be useful, but
00010  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  *
00018  * This file incorporates work covered by the following copyright and
00019  * permission notice:
00020  *
00021  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
00022  * Copyright (c) 2004-2005 Atheros Communications, Inc.
00023  * Copyright (c) 2006 Devicescape Software, Inc.
00024  * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
00025  * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
00026  *
00027  * All rights reserved.
00028  *
00029  * Redistribution and use in source and binary forms, with or without
00030  * modification, are permitted provided that the following conditions
00031  * are met:
00032  * 1. Redistributions of source code must retain the above copyright
00033  *    notice, this list of conditions and the following disclaimer,
00034  *    without modification.
00035  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
00036  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
00037  *    redistribution must be conditioned upon including a substantially
00038  *    similar Disclaimer requirement for further binary redistribution.
00039  * 3. Neither the names of the above-listed copyright holders nor the names
00040  *    of any contributors may be used to endorse or promote products derived
00041  *    from this software without specific prior written permission.
00042  *
00043  * Alternatively, this software may be distributed under the terms of the
00044  * GNU General Public License ("GPL") version 2 as published by the Free
00045  * Software Foundation.
00046  *
00047  * NO WARRANTY
00048  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00049  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00050  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
00051  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
00052  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
00053  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00054  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00055  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
00056  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00057  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00058  * THE POSSIBILITY OF SUCH DAMAGES.
00059  */
00060 
00061 #include "base.h"
00062 #include "debug.h"
00063 
00064 static unsigned int ath5k_debug;
00065 //module_param_named(debug, ath5k_debug, uint, 0);
00066 
00067 #ifdef CONFIG_ATH5K_DEBUG
00068 
00069 /* functions used in other places */
00070 void ath5k_set_debug_level (struct ath5k_softc *sc)
00071 {
00072         sc->debug_level = ath5k_debug;
00073 }
00074 
00075 void
00076 ath5k_debug_dump_bands(struct ath5k_softc *sc)
00077 {
00078         unsigned int b, i;
00079 
00080         if (likely(!(sc->debug_level & ATH5K_DEBUG_DUMPBANDS)))
00081                 return;
00082 
00083         BUG_ON(!sc->sbands);
00084 
00085         for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
00086                 struct ieee80211_supported_band *band = &sc->sbands[b];
00087                 char bname[6];
00088                 switch (band->band) {
00089                 case IEEE80211_BAND_2GHZ:
00090                         strcpy(bname, "2 GHz");
00091                         break;
00092                 case IEEE80211_BAND_5GHZ:
00093                         strcpy(bname, "5 GHz");
00094                         break;
00095                 default:
00096                         printk(KERN_DEBUG "Band not supported: %d\n",
00097                                 band->band);
00098                         return;
00099                 }
00100                 printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
00101                                 band->n_channels, band->n_bitrates);
00102                 printk(KERN_DEBUG " channels:\n");
00103                 for (i = 0; i < band->n_channels; i++)
00104                         printk(KERN_DEBUG "  %3d %d %.4x\n",
00105                                         ath5k_frequency_to_channel(
00106                                                 band->channels[i].center_freq),
00107                                         band->channels[i].center_freq,
00108                                         band->channels[i].hw_value);
00109                 printk(KERN_DEBUG " rates:\n");
00110                 for (i = 0; i < band->n_bitrates; i++)
00111                         printk(KERN_DEBUG "  %4d %.4x %.4x %.4x\n",
00112                                         band->bitrates[i].bitrate,
00113                                         band->bitrates[i].hw_value,
00114                                         band->bitrates[i].flags,
00115                                         band->bitrates[i].hw_value_short);
00116         }
00117 }
00118 
00119 static inline void
00120 ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
00121                 struct ath5k_rx_status *rs)
00122 {
00123         struct ath5k_desc *ds = bf->desc;
00124         struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
00125 
00126         printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
00127                 ds, (unsigned long long)bf->daddr,
00128                 ds->ds_link, ds->ds_data,
00129                 rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
00130                 rd->u.rx_stat.rx_status_0, rd->u.rx_stat.rx_status_0,
00131                 !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
00132 }
00133 
00134 void
00135 ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah)
00136 {
00137         struct ath5k_desc *ds;
00138         struct ath5k_buf *bf;
00139         struct ath5k_rx_status rs = {};
00140         int status;
00141 
00142         if (likely(!(sc->debug_level & ATH5K_DEBUG_RESET)))
00143                 return;
00144 
00145         printk(KERN_DEBUG "rx queue %x, link %p\n",
00146                 ath5k_hw_get_rxdp(ah), sc->rxlink);
00147 
00148         spin_lock_bh(&sc->rxbuflock);
00149         list_for_each_entry(bf, &sc->rxbuf, list) {
00150                 ds = bf->desc;
00151                 status = ah->ah_proc_rx_desc(ah, ds, &rs);
00152                 if (!status)
00153                         ath5k_debug_printrxbuf(bf, status == 0, &rs);
00154         }
00155         spin_unlock_bh(&sc->rxbuflock);
00156 }
00157 
00158 void
00159 ath5k_debug_dump_skb(struct ath5k_softc *sc,
00160                         struct sk_buff *skb, const char *prefix, int tx)
00161 {
00162         char buf[16];
00163 
00164         if (likely(!((tx && (sc->debug_level & ATH5K_DEBUG_DUMP_TX)) ||
00165                      (!tx && (sc->debug_level & ATH5K_DEBUG_DUMP_RX)))))
00166                 return;
00167 
00168         snprintf(buf, sizeof(buf), "phyX %s", prefix);
00169 
00170         print_hex_dump_bytes(buf, DUMP_PREFIX_NONE, skb->data,
00171                 min(200U, skb->len));
00172 
00173         printk(KERN_DEBUG "\n");
00174 }
00175 
00176 void
00177 ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf)
00178 {
00179         struct ath5k_desc *ds = bf->desc;
00180         struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
00181         struct ath5k_tx_status ts = {};
00182         int done;
00183 
00184         if (likely(!(sc->debug_level & ATH5K_DEBUG_RESET)))
00185                 return;
00186 
00187         done = sc->ah->ah_proc_tx_desc(sc->ah, bf->desc, &ts);
00188 
00189         printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
00190                 "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
00191                 ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
00192                 td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
00193                 td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
00194                 done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
00195 }
00196 
00197 #endif /* ifdef CONFIG_ATH5K_DEBUG */


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:09