00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #include "base.h"
00062 #include "debug.h"
00063
00064 static unsigned int ath5k_debug;
00065
00066
00067 #ifdef CONFIG_ATH5K_DEBUG
00068
00069
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