PERFORCE change 43912 for review
Sam Leffler
sam at FreeBSD.org
Sat Dec 13 12:56:13 PST 2003
http://perforce.freebsd.org/chv.cgi?CH=43912
Change 43912 by sam at sam_ebb on 2003/12/13 12:55:56
convert ath_debug printf control to a bit vector to
improve the control over debugging msgs
Affected files ...
.. //depot/projects/netperf/sys/dev/ath/if_ath.c#51 edit
Differences ...
==== //depot/projects/netperf/sys/dev/ath/if_ath.c#51 (text+ko) ====
@@ -167,13 +167,25 @@
((_ifp)->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
static void ath_printrxbuf(struct ath_buf *bf, int);
static void ath_printtxbuf(struct ath_buf *bf, int);
-#define DPRINTF(X) if (ath_debug) printf X
-#define DPRINTF2(X) if (ath_debug > 1) printf X
+enum {
+ ATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */
+ ATH_DEBUG_RECV = 0x00000002, /* basic recv operation */
+ ATH_DEBUG_RATE = 0x00000004, /* rate control */
+ ATH_DEBUG_RESET = 0x00000008, /* device reset */
+ ATH_DEBUG_MODE = 0x00000010, /* mode init/setup */
+ ATH_DEBUG_BEACON = 0x00000020, /* beacon handling */
+ ATH_DEBUG_INTR = 0x00001000, /* ISR */
+ ATH_DEBUG_TX_PROC = 0x00002000, /* tx ISR proc */
+ ATH_DEBUG_RX_PROC = 0x00004000, /* rx ISR proc */
+ ATH_DEBUG_BEACON_PROC = 0x00008000, /* beacon ISR proc */
+ ATH_DEBUG_CALIBRATE = 0x00010000, /* periodic calibration */
+ ATH_DEBUG_ANY = 0xffffffff
+};
+#define DPRINTF(_m,X) if (ath_debug&_m) printf X
#else
#define IFF_DUMPPKTS(_ifp) \
(((_ifp)->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
-#define DPRINTF(X)
-#define DPRINTF2(X)
+#define DPRINTF(_m, X)
#endif
int
@@ -185,7 +197,7 @@
HAL_STATUS status;
int error = 0;
- DPRINTF(("ath_attach: devid 0x%x\n", devid));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_attach: devid 0x%x\n", devid));
/* set these up early for if_printf use */
if_initname(ifp, device_get_name(sc->sc_dev),
@@ -348,7 +360,7 @@
{
struct ifnet *ifp = &sc->sc_ic.ic_if;
- DPRINTF(("ath_detach: if_flags %x\n", ifp->if_flags));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_detach: if_flags %x\n", ifp->if_flags));
ath_stop(ifp);
bpfdetach(ifp);
@@ -367,7 +379,7 @@
{
struct ifnet *ifp = &sc->sc_ic.ic_if;
- DPRINTF(("ath_suspend: if_flags %x\n", ifp->if_flags));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_suspend: if_flags %x\n", ifp->if_flags));
ath_stop(ifp);
}
@@ -377,7 +389,7 @@
{
struct ifnet *ifp = &sc->sc_ic.ic_if;
- DPRINTF(("ath_resume: if_flags %x\n", ifp->if_flags));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_resume: if_flags %x\n", ifp->if_flags));
if (ifp->if_flags & IFF_UP) {
ath_init(ifp);
@@ -391,7 +403,7 @@
{
struct ifnet *ifp = &sc->sc_ic.ic_if;
- DPRINTF(("ath_shutdown: if_flags %x\n", ifp->if_flags));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_shutdown: if_flags %x\n", ifp->if_flags));
ath_stop(ifp);
}
@@ -410,17 +422,18 @@
* The hardware is not ready/present, don't touch anything.
* Note this can happen early on if the IRQ is shared.
*/
- DPRINTF(("ath_intr: invalid; ignored\n"));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_intr: invalid; ignored\n"));
return;
}
if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) != (IFF_RUNNING|IFF_UP)) {
- DPRINTF(("ath_intr: if_flags 0x%x\n", ifp->if_flags));
+ DPRINTF(ATH_DEBUG_ANY,
+ ("ath_intr: if_flags 0x%x\n", ifp->if_flags));
ath_hal_getisr(ah, &status); /* clear ISR */
ath_hal_intrset(ah, 0); /* disable further intr's */
return;
}
ath_hal_getisr(ah, &status); /* NB: clears ISR too */
- DPRINTF2(("ath_intr: status 0x%x\n", status));
+ DPRINTF(ATH_DEBUG_INTR, ("ath_intr: status 0x%x\n", status));
#ifdef AR_DEBUG
if (ath_debug &&
(status & (HAL_INT_FATAL|HAL_INT_RXORN|HAL_INT_BMISS))) {
@@ -489,7 +502,7 @@
struct ath_softc *sc = arg;
struct ieee80211com *ic = &sc->sc_ic;
- DPRINTF(("ath_bmiss_proc: pending %u\n", pending));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_bmiss_proc: pending %u\n", pending));
KASSERT(ic->ic_opmode == IEEE80211_M_STA,
("unexpect operating mode %u", ic->ic_opmode));
if (ic->ic_state == IEEE80211_S_RUN) {
@@ -528,7 +541,7 @@
HAL_STATUS status;
HAL_CHANNEL hchan;
- DPRINTF(("ath_init: if_flags 0x%x\n", ifp->if_flags));
+ DPRINTF(ATH_DEBUG_ANY, ("ath_init: if_flags 0x%x\n", ifp->if_flags));
ATH_LOCK(sc);
/*
@@ -602,7 +615,7 @@
struct ath_softc *sc = ifp->if_softc;
struct ath_hal *ah = sc->sc_ah;
- DPRINTF(("ath_stop: invalid %u if_flags 0x%x\n",
+ DPRINTF(ATH_DEBUG_ANY, ("ath_stop: invalid %u if_flags 0x%x\n",
sc->sc_invalid, ifp->if_flags));
ATH_LOCK(sc);
@@ -705,7 +718,8 @@
TAILQ_REMOVE(&sc->sc_txbuf, bf, bf_list);
ATH_TXBUF_UNLOCK(sc);
if (bf == NULL) {
- DPRINTF(("ath_start: out of xmit buffers\n"));
+ DPRINTF(ATH_DEBUG_ANY,
+ ("ath_start: out of xmit buffers\n"));
sc->sc_stats.ast_tx_qstop++;
ifp->if_flags |= IFF_OACTIVE;
break;
@@ -720,7 +734,8 @@
* No data frames go out unless we're associated.
*/
if (ic->ic_state != IEEE80211_S_RUN) {
- DPRINTF(("ath_start: ignore data packet, "
+ DPRINTF(ATH_DEBUG_ANY,
+ ("ath_start: ignore data packet, "
"state %u\n", ic->ic_state));
sc->sc_stats.ast_tx_discard++;
ATH_TXBUF_LOCK(sc);
@@ -742,7 +757,8 @@
*/
m = ieee80211_encap(ifp, m, &ni);
if (m == NULL) {
- DPRINTF(("ath_start: encapsulation failure\n"));
+ DPRINTF(ATH_DEBUG_ANY,
+ ("ath_start: encapsulation failure\n"));
sc->sc_stats.ast_tx_encap++;
goto bad;
}
@@ -1032,7 +1048,8 @@
mfilt[0] = mfilt[1] = ~0;
}
ath_hal_setmcastfilter(ah, mfilt[0], mfilt[1]);
- DPRINTF(("ath_mode_init: RX filter 0x%x, MC filter %08x:%08x\n",
+ DPRINTF(ATH_DEBUG_MODE,
+ ("ath_mode_init: RX filter 0x%x, MC filter %08x:%08x\n",
rfilt, mfilt[0], mfilt[1]));
}
@@ -1086,7 +1103,8 @@
else
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
if (m == NULL) {
- DPRINTF(("ath_beacon_alloc: cannot get mbuf/cluster; size %u\n",
+ DPRINTF(ATH_DEBUG_BEACON,
+ ("ath_beacon_alloc: cannot get mbuf/cluster; size %u\n",
pktlen));
sc->sc_stats.ast_be_nombuf++;
return ENOMEM;
@@ -1157,7 +1175,8 @@
("beacon bigger than expected, len %u calculated %u",
m->m_pkthdr.len, pktlen));
- DPRINTF2(("ath_beacon_alloc: m %p len %u\n", m, m->m_len));
+ DPRINTF(ATH_DEBUG_BEACON,
+ ("ath_beacon_alloc: m %p len %u\n", m, m->m_len));
error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m,
ath_mbuf_load_cb, bf,
BUS_DMA_NOWAIT);
@@ -1216,16 +1235,16 @@
struct ath_buf *bf = sc->sc_bcbuf;
struct ath_hal *ah = sc->sc_ah;
- DPRINTF2(("%s: pending %u\n", __func__, pending));
+ DPRINTF(ATH_DEBUG_BEACON_PROC, ("%s: pending %u\n", __func__, pending));
if (ic->ic_opmode == IEEE80211_M_STA ||
bf == NULL || bf->bf_m == NULL) {
- DPRINTF(("%s: ic_flags=%x bf=%p bf_m=%p\n",
+ DPRINTF(ATH_DEBUG_ANY, ("%s: ic_flags=%x bf=%p bf_m=%p\n",
__func__, ic->ic_flags, bf, bf ? bf->bf_m : NULL));
return;
}
/* TODO: update beacon to reflect PS poll state */
if (!ath_hal_stoptxdma(ah, sc->sc_bhalq)) {
- DPRINTF(("%s: beacon queue %u did not stop?",
+ DPRINTF(ATH_DEBUG_ANY, ("%s: beacon queue %u did not stop?\n",
__func__, sc->sc_bhalq));
/* NB: the HAL still stops DMA, so proceed */
}
@@ -1233,7 +1252,8 @@
ath_hal_puttxbuf(ah, sc->sc_bhalq, bf->bf_daddr);
ath_hal_txstart(ah, sc->sc_bhalq);
- DPRINTF2(("%s: TXDP%u = %p (%p)\n", __func__,
+ DPRINTF(ATH_DEBUG_BEACON_PROC,
+ ("%s: TXDP%u = %p (%p)\n", __func__,
sc->sc_bhalq, (caddr_t)bf->bf_daddr, bf->bf_desc));
}
@@ -1275,7 +1295,7 @@
nexttbtt = (LE_READ_4(ni->ni_tstamp + 4) << 22) |
(LE_READ_4(ni->ni_tstamp) >> 10);
- DPRINTF(("%s: nexttbtt=%u\n", __func__, nexttbtt));
+ DPRINTF(ATH_DEBUG_BEACON, ("%s: nexttbtt=%u\n", __func__, nexttbtt));
nexttbtt += ni->ni_intval;
if (ic->ic_opmode == IEEE80211_M_STA) {
HAL_BEACON_STATE bs;
@@ -1315,7 +1335,8 @@
if (bs.bs_sleepduration > bs.bs_dtimperiod)
bs.bs_sleepduration = roundup(bs.bs_sleepduration, bs.bs_dtimperiod);
- DPRINTF(("%s: intval %u nexttbtt %u dtim %u nextdtim %u bmiss %u sleep %u\n"
+ DPRINTF(ATH_DEBUG_BEACON,
+ ("%s: intval %u nexttbtt %u dtim %u nextdtim %u bmiss %u sleep %u\n"
, __func__
, bs.bs_intval
, bs.bs_nexttbtt
@@ -1335,7 +1356,7 @@
sc->sc_imask |= HAL_INT_BMISS;
ath_hal_intrset(ah, sc->sc_imask);
} else {
- DPRINTF(("%s: intval %u nexttbtt %u\n",
+ DPRINTF(ATH_DEBUG_BEACON, ("%s: intval %u nexttbtt %u\n",
__func__, ni->ni_intval, nexttbtt));
ath_hal_intrset(ah, 0);
ath_hal_beaconinit(ah, ic->ic_opmode,
@@ -1380,9 +1401,9 @@
goto fail1;
ds = sc->sc_desc;
- DPRINTF(("ath_desc_alloc: DMA map: %p (%d) -> %p (%lu)\n",
- ds, sc->sc_desc_len,
- (caddr_t) sc->sc_desc_paddr, /*XXX*/ (u_long) sc->sc_desc_len));
+ DPRINTF(ATH_DEBUG_ANY, ("%s: DMA map: %p (%d) -> %p (%lu)\n",
+ __func__, ds, sc->sc_desc_len, (caddr_t) sc->sc_desc_paddr,
+ /*XXX*/ (u_long) sc->sc_desc_len));
/* allocate buffers */
bsize = sizeof(struct ath_buf) * (ATH_TXBUF + ATH_RXBUF + 1);
@@ -1561,7 +1582,8 @@
*/
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
if (m == NULL) {
- DPRINTF(("ath_rxbuf_init: no mbuf/cluster\n"));
+ DPRINTF(ATH_DEBUG_ANY,
+ ("%s: no mbuf/cluster\n", __func__));
sc->sc_stats.ast_rx_nombuf++;
return ENOMEM;
}
@@ -1572,8 +1594,9 @@
ath_mbuf_load_cb, bf,
BUS_DMA_NOWAIT);
if (error != 0) {
- DPRINTF(("ath_rxbuf_init: bus_dmamap_load_mbuf failed;"
- " error %d\n", error));
+ DPRINTF(ATH_DEBUG_ANY,
+ ("%s: bus_dmamap_load_mbuf failed; error %d\n",
+ __func__, error));
sc->sc_stats.ast_rx_busdma++;
return error;
}
@@ -1633,7 +1656,7 @@
u_int phyerr;
HAL_STATUS status;
- DPRINTF2(("ath_rx_proc: pending %u\n", npending));
+ DPRINTF(ATH_DEBUG_RX_PROC, ("%s: pending %u\n", __func__, npending));
do {
bf = TAILQ_FIRST(&sc->sc_rxbuf);
if (bf == NULL) { /* NB: shouldn't happen */
@@ -1697,7 +1720,8 @@
len = ds->ds_rxstat.rs_datalen;
if (len < IEEE80211_MIN_LEN) {
- DPRINTF(("ath_rx_proc: short packet %d\n", len));
+ DPRINTF(ATH_DEBUG_RECV, ("%s: short packet %d\n",
+ __func__, len));
sc->sc_stats.ast_rx_tooshort++;
goto rx_next;
}
@@ -1917,7 +1941,7 @@
m_freem(m0);
return EIO;
}
- DPRINTF2(("ath_tx_start: m %p len %u\n", m0, pktlen));
+ DPRINTF(ATH_DEBUG_XMIT, ("%s: m %p len %u\n", __func__, m0, pktlen));
bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_PREWRITE);
bf->bf_m = m0;
bf->bf_node = ni; /* NB: held reference */
@@ -2123,9 +2147,10 @@
, i == 0 /* first segment */
, i == bf->bf_nseg - 1 /* last segment */
);
- DPRINTF2(("ath_tx_start: %d: %08x %08x %08x %08x %08x %08x\n",
- i, ds->ds_link, ds->ds_data, ds->ds_ctl0, ds->ds_ctl1,
- ds->ds_hw[0], ds->ds_hw[1]));
+ DPRINTF(ATH_DEBUG_XMIT,
+ ("%s: %d: %08x %08x %08x %08x %08x %08x\n",
+ __func__, i, ds->ds_link, ds->ds_data,
+ ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1]));
}
/*
@@ -2136,11 +2161,11 @@
TAILQ_INSERT_TAIL(&sc->sc_txq, bf, bf_list);
if (sc->sc_txlink == NULL) {
ath_hal_puttxbuf(ah, sc->sc_txhalq, bf->bf_daddr);
- DPRINTF2(("ath_tx_start: TXDP0 = %p (%p)\n",
+ DPRINTF(ATH_DEBUG_XMIT, ("%s: TXDP0 = %p (%p)\n", __func__,
(caddr_t)bf->bf_daddr, bf->bf_desc));
} else {
*sc->sc_txlink = bf->bf_daddr;
- DPRINTF2(("ath_tx_start: link(%p)=%p (%p)\n",
+ DPRINTF(ATH_DEBUG_XMIT, ("%s: link(%p)=%p (%p)\n", __func__,
sc->sc_txlink, (caddr_t)bf->bf_daddr, bf->bf_desc));
}
sc->sc_txlink = &bf->bf_desc[bf->bf_nseg - 1].ds_link;
@@ -2164,8 +2189,9 @@
int sr, lr;
HAL_STATUS status;
- DPRINTF2(("ath_tx_proc: pending %u tx queue %p, link %p\n",
- npending, (caddr_t) ath_hal_gettxbuf(sc->sc_ah, sc->sc_txhalq),
+ DPRINTF(ATH_DEBUG_TX_PROC, ("%s: pending %u tx queue %p, link %p\n",
+ __func__, npending,
+ (caddr_t) ath_hal_gettxbuf(sc->sc_ah, sc->sc_txhalq),
sc->sc_txlink));
for (;;) {
ATH_TXQ_LOCK(sc);
@@ -2255,11 +2281,13 @@
if (!sc->sc_invalid) {
/* don't touch the hardware if marked invalid */
(void) ath_hal_stoptxdma(ah, sc->sc_txhalq);
- DPRINTF(("ath_draintxq: tx queue %p, link %p\n",
+ DPRINTF(ATH_DEBUG_RESET,
+ ("%s: tx queue %p, link %p\n", __func__,
(caddr_t) ath_hal_gettxbuf(ah, sc->sc_txhalq),
sc->sc_txlink));
(void) ath_hal_stoptxdma(ah, sc->sc_bhalq);
- DPRINTF(("ath_draintxq: beacon queue %p\n",
+ DPRINTF(ATH_DEBUG_RESET,
+ ("%s: beacon queue %p\n", __func__,
(caddr_t) ath_hal_gettxbuf(ah, sc->sc_bhalq)));
}
for (;;) {
@@ -2315,8 +2343,9 @@
if (ath_debug) {
struct ath_buf *bf;
- DPRINTF(("ath_stoprecv: rx queue %p, link %p\n",
- (caddr_t) ath_hal_getrxbuf(ah), sc->sc_rxlink));
+ DPRINTF(ATH_DEBUG_RECV, ("%s: rx queue %p, link %p\n",
+ __func__,
+ (caddr_t) ath_hal_getrxbuf(ah), sc->sc_rxlink));
TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) {
struct ath_desc *ds = bf->bf_desc;
if (ath_hal_rxprocdesc(ah, ds, bf->bf_daddr,
@@ -2342,8 +2371,9 @@
TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) {
int error = ath_rxbuf_init(sc, bf);
if (error != 0) {
- DPRINTF(("ath_startrecv: ath_rxbuf_init failed %d\n",
- error));
+ DPRINTF(ATH_DEBUG_RECV,
+ ("%s: ath_rxbuf_init failed %d\n",
+ __func__, error));
return error;
}
}
@@ -2368,7 +2398,7 @@
struct ath_hal *ah = sc->sc_ah;
struct ieee80211com *ic = &sc->sc_ic;
- DPRINTF(("ath_chan_set: %u (%u MHz) -> %u (%u MHz)\n",
+ DPRINTF(ATH_DEBUG_ANY, ("%s: %u (%u MHz) -> %u (%u MHz)\n", __func__,
ieee80211_chan2ieee(ic, ic->ic_ibss_chan),
ic->ic_ibss_chan->ic_freq,
ieee80211_chan2ieee(ic, chan), chan->ic_freq));
@@ -2467,7 +2497,8 @@
hchan.channel = c->ic_freq;
hchan.channelFlags = ath_chan2flags(ic, c);
- DPRINTF(("%s: channel %u/%x\n", __func__, c->ic_freq, c->ic_flags));
+ DPRINTF(ATH_DEBUG_CALIBRATE,
+ ("%s: channel %u/%x\n", __func__, c->ic_freq, c->ic_flags));
if (ath_hal_getrfgain(ah) == HAL_RFGAIN_NEED_CHANGE) {
/*
@@ -2478,7 +2509,8 @@
ath_reset(sc, 0);
}
if (!ath_hal_calibrate(ah, &hchan)) {
- DPRINTF(("%s: calibration of channel %u failed\n",
+ DPRINTF(ATH_DEBUG_ANY,
+ ("%s: calibration of channel %u failed\n",
__func__, c->ic_freq));
sc->sc_stats.ast_per_calfail++;
}
@@ -2503,7 +2535,7 @@
HAL_LED_RUN, /* IEEE80211_S_RUN */
};
- DPRINTF(("%s: %s -> %s\n", __func__,
+ DPRINTF(ATH_DEBUG_ANY, ("%s: %s -> %s\n", __func__,
ieee80211_state_name[ic->ic_state],
ieee80211_state_name[nstate]));
@@ -2530,7 +2562,7 @@
bssid = ni->ni_bssid;
}
ath_hal_setrxfilter(ah, rfilt);
- DPRINTF(("%s: RX filter 0x%x bssid %s\n",
+ DPRINTF(ATH_DEBUG_ANY, ("%s: RX filter 0x%x bssid %s\n",
__func__, rfilt, ether_sprintf(bssid)));
if (nstate == IEEE80211_S_RUN && ic->ic_opmode == IEEE80211_M_STA)
@@ -2544,7 +2576,7 @@
}
if (nstate == IEEE80211_S_RUN) {
- DPRINTF(("%s(RUN): ic_flags=0x%08x iv=%d bssid=%s "
+ DPRINTF(ATH_DEBUG_ANY, ("%s(RUN): ic_flags=0x%08x iv=%d bssid=%s "
"capinfo=0x%04x chan=%d\n"
, __func__
, ic->ic_flags
@@ -2682,14 +2714,16 @@
sc->sc_rates[mode] = ath_hal_getratetable(ah, HAL_MODE_TURBO);
break;
default:
- DPRINTF(("%s: invalid mode %u\n", __func__, mode));
+ DPRINTF(ATH_DEBUG_ANY,
+ ("%s: invalid mode %u\n", __func__, mode));
return 0;
}
rt = sc->sc_rates[mode];
if (rt == NULL)
return 0;
if (rt->rateCount > IEEE80211_RATE_MAXSIZE) {
- DPRINTF(("%s: rate table too small (%u > %u)\n",
+ DPRINTF(ATH_DEBUG_ANY,
+ ("%s: rate table too small (%u > %u)\n",
__func__, rt->rateCount, IEEE80211_RATE_MAXSIZE));
maxrates = IEEE80211_RATE_MAXSIZE;
} else
@@ -2866,7 +2900,8 @@
}
if (nrate != ni->ni_txrate) {
- DPRINTF(("%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
+ DPRINTF(ATH_DEBUG_RATE,
+ ("%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
__func__,
(rs->rs_rates[ni->ni_txrate] & IEEE80211_RATE_VAL) / 2,
(rs->rs_rates[nrate] & IEEE80211_RATE_VAL) / 2,
More information about the p4-projects
mailing list