PERFORCE change 156275 for review
Weongyo Jeong
weongyo at FreeBSD.org
Fri Jan 16 21:30:42 PST 2009
http://perforce.freebsd.org/chv.cgi?CH=156275
Change 156275 by weongyo at weongyo_ws on 2009/01/17 05:30:36
change the style of printing the debug messages like other wireless
drivers.
Affected files ...
.. //depot/projects/vap/sys/dev/usb/if_uath.c#3 edit
.. //depot/projects/vap/sys/dev/usb/if_uathvar.h#2 edit
Differences ...
==== //depot/projects/vap/sys/dev/usb/if_uath.c#3 (text+ko) ====
@@ -113,16 +113,37 @@
#include <dev/usb/if_uathvar.h>
#ifdef UATH_DEBUG
-#define DPRINTF(x) do { if (uath_debug) printf x; } while (0)
-#define DPRINTFN(n, x) do { if (uath_debug >= (n)) printf x; } while (0)
int uath_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, uath, CTLFLAG_RW, 0, "USB Atheros");
SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RW, &uath_debug, 0,
"uath debug level");
TUNABLE_INT("hw.usb.uath.debug", &uath_debug);
+enum {
+ UATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */
+ UATH_DEBUG_RECV = 0x00000002, /* basic recv operation */
+ UATH_DEBUG_TX_PROC = 0x00000004, /* tx ISR proc */
+ UATH_DEBUG_RX_PROC = 0x00000008, /* rx ISR proc */
+ UATH_DEBUG_RECV_ALL = 0x00000010, /* trace all frames (beacons) */
+ UATH_DEBUG_INIT = 0x00000020, /* initialization of dev */
+ UATH_DEBUG_DEVCAP = 0x00000040, /* dev caps */
+ UATH_DEBUG_RESET = 0x00000080, /* reset processing */
+ UATH_DEBUG_STATE = 0x00000100, /* 802.11 state transitions */
+ UATH_DEBUG_MULTICAST = 0x00000200, /* multicast */
+ UATH_DEBUG_WME = 0x00000400, /* WME */
+ UATH_DEBUG_CHANNEL = 0x00000800, /* channel */
+ UATH_DEBUG_RATES = 0x00001000, /* rates */
+ UATH_DEBUG_CRYPTO = 0x00002000, /* crypto */
+ UATH_DEBUG_LED = 0x00004000, /* LED */
+ UATH_DEBUG_ANY = 0xffffffff
+};
+#define DPRINTF(sc, m, fmt, ...) do { \
+ if (sc->sc_debug & (m)) \
+ printf(fmt, __VA_ARGS__); \
+} while (0)
#else
-#define DPRINTF(x)
-#define DPRINTFN(n, x)
+#define DPRINTF(sc, m, fmt, ...) do { \
+ (void) sc; \
+} while (0)
#endif
/* unaligned little endian access */
@@ -259,6 +280,9 @@
sc->sc_dev = dev;
sc->sc_udev = uaa->device;
+#ifdef UATH_DEBUG
+ sc->sc_debug = uath_debug;
+#endif
error = usbd_set_config_no(sc->sc_udev, UATH_CONFIG_NO, 0);
if (error != 0) {
@@ -793,7 +817,8 @@
} else
mfilt[0] = mfilt[1] = ~0;
- DPRINTFN(5, ("%s: MC filter %08x:%08x\n", __func__, mfilt[0], mfilt[1]));
+ DPRINTF(sc, UATH_DEBUG_MULTICAST,
+ "%s: MC filter %08x:%08x\n", __func__, mfilt[0], mfilt[1]);
mcast.filter0 = htobe32(mfilt[0]);
mcast.filter1 = htobe32(mfilt[1]);
@@ -1013,9 +1038,9 @@
struct ieee80211com *ic = vap->iv_ic;
struct uath_softc *sc = ic->ic_ifp->if_softc;
- DPRINTF(("%s: %s -> %s\n", __func__,
- ieee80211_state_name[vap->iv_state],
- ieee80211_state_name[nstate]));
+ DPRINTF(sc, UATH_DEBUG_STATE,
+ "%s: %s -> %s\n", __func__, ieee80211_state_name[vap->iv_state],
+ ieee80211_state_name[nstate]);
usb_rem_task(sc->sc_udev, &sc->sc_ctxtask);
usb_rem_task(sc->sc_udev, &sc->sc_task);
@@ -1347,8 +1372,9 @@
/* reply to a read command */
default:
dlen = hdr->len - sizeof(*hdr);
- DPRINTFN(3, ("%s: code %d data len %u\n",
- __func__, hdr->code & 0xff, dlen));
+ DPRINTF(sc, UATH_DEBUG_RX_PROC | UATH_DEBUG_RECV_ALL,
+ "%s: code %d data len %u\n",
+ __func__, hdr->code & 0xff, dlen);
/*
* The first response from the target after the
* HOST_AVAILABLE has an invalid msgid so we must
@@ -1431,11 +1457,13 @@
case WDCMSG_SEND_COMPLETE:
/* this notification is sent when UATH_TX_NOTIFY is set */
- DPRINTF(("received Tx notification\n"));
+ DPRINTF(sc, UATH_DEBUG_RX_PROC | UATH_DEBUG_RECV_ALL,
+ "%s: received Tx notification\n", __func__);
break;
case WDCMSG_TARGET_GET_STATS:
- DPRINTFN(2, ("received device statistics\n"));
+ DPRINTF(sc, UATH_DEBUG_RX_PROC | UATH_DEBUG_RECV_ALL,
+ "%s: received device statistics\n", __func__);
callout_reset(&sc->stat_ch, hz, uath_stat, sc);
break;
}
@@ -1504,7 +1532,8 @@
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
return;
- DPRINTF(("%s: status %u\n", __func__, status));
+ DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
+ "%s: status %u\n", __func__, status);
if (status == USBD_STALLED)
usbd_clear_endpoint_stall_async(sc->sc_data_rxpipe);
ifp->if_ierrors++;
@@ -1513,7 +1542,8 @@
usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
if (len < UATH_MIN_RXBUFSZ) {
- DPRINTF(("%s: wrong xfer size (len=%d)\n", __func__, len));
+ DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
+ "%s: wrong xfer size (len=%d)\n", __func__, len);
ifp->if_ierrors++;
goto skip;
}
@@ -1572,7 +1602,8 @@
mnew = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
if (mnew == NULL) {
- DPRINTF(("%s: can't get new mbuf, drop frame\n", __func__));
+ DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
+ "%s: can't get new mbuf, drop frame\n", __func__);
ifp->if_ierrors++;
needreset = 1;
goto skip;
@@ -1597,17 +1628,19 @@
sizeof(struct uath_chunk) + be16toh(chunk->length) -
sizeof(struct uath_rx_desc));
- DPRINTF(("%s: frame len %u code %u status %u rate %u antenna %u "
+ DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
+ "%s: frame len %u code %u status %u rate %u antenna %u "
"rssi %d channel %u phyerror %u connix %u decrypterror %u "
"keycachemiss %u\n", __func__, be32toh(desc->framelen)
, be32toh(desc->code), be32toh(desc->status), be32toh(desc->rate)
, be32toh(desc->antenna), be32toh(desc->rssi), be32toh(desc->channel)
, be32toh(desc->phyerror), be32toh(desc->connix)
- , be32toh(desc->decrypterror), be32toh(desc->keycachemiss)));
+ , be32toh(desc->decrypterror), be32toh(desc->keycachemiss));
if (be32toh(desc->len) > MCLBYTES) {
- DPRINTF(("%s: bad descriptor (len=%d)\n", __func__,
- be32toh(desc->len)));
+ DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
+ "%s: bad descriptor (len=%d)\n", __func__,
+ be32toh(desc->len));
ifp->if_iqdrops++;
UATH_STAT_INC(sc, st_toobigrxpkt);
needreset = 1;
@@ -2001,7 +2034,8 @@
error = uath_get_capability(sc, x, &v); \
if (error != 0) \
return (error); \
- DPRINTF(("%s: %s=0x%08x\n", __func__, #x, v)); \
+ DPRINTF(sc, UATH_DEBUG_DEVCAP, \
+ "%s: %s=0x%08x\n", __func__, #x, v); \
} while (0)
struct uath_devcap *cap = &sc->sc_devcap;
int error;
@@ -2079,7 +2113,7 @@
{
int ac, error;
- DPRINTF(("reset Tx queues\n"));
+ DPRINTF(sc, UATH_DEBUG_RESET, "%s: reset Tx queues\n", __func__);
for (ac = 0; ac < 4; ac++) {
const uint32_t qid = htobe32(ac);
@@ -2104,7 +2138,7 @@
struct uath_cmd_txq_setup qinfo;
int ac, error;
- DPRINTF(("setup Tx queues\n"));
+ DPRINTF(sc, UATH_DEBUG_WME, "%s: setup Tx queues\n", __func__);
for (ac = 0; ac < 4; ac++) {
qinfo.qid = htobe32(ac);
qinfo.len = htobe32(sizeof(qinfo.attr));
@@ -2152,9 +2186,9 @@
reset.channelchange = htobe32(1);
reset.keeprccontent = htobe32(0);
- DPRINTF(("set channel %d, flags 0x%x freq %u\n",
+ DPRINTF(sc, UATH_DEBUG_CHANNEL, "set channel %d, flags 0x%x freq %u\n",
ieee80211_chan2ieee(ic, c),
- be32toh(reset.flags), be32toh(reset.freq)));
+ be32toh(reset.flags), be32toh(reset.freq));
return uath_cmd_write(sc, WDCMSG_RESET, &reset, sizeof reset, 0);
}
@@ -2183,7 +2217,8 @@
for (i = 0; i < wk->wk_keylen; i++)
crypto.key[i] = wk->wk_key[i] ^ 0xaa;
- DPRINTF(("setting crypto key index=%d len=%d\n", index, wk->wk_keylen));
+ DPRINTF(sc, UATH_DEBUG_CRYPTO,
+ "setting crypto key index=%d len=%d\n", index, wk->wk_keylen);
return uath_cmd_write(sc, WDCMSG_SET_KEY_CACHE_ENTRY, &crypto,
sizeof crypto, 0);
#else
@@ -2226,7 +2261,8 @@
rates.rateset.length = rs->rs_nrates;
bcopy(rs->rs_rates, &rates.rateset.set[0], rs->rs_nrates);
- DPRINTF(("setting supported rates nrates=%d\n", rs->rs_nrates));
+ DPRINTF(sc, UATH_DEBUG_RATES,
+ "setting supported rates nrates=%d\n", rs->rs_nrates);
return uath_cmd_write(sc, WDCMSG_SET_BASIC_RATE,
&rates, sizeof rates, 0);
}
@@ -2239,7 +2275,8 @@
rxfilter.bits = htobe32(bits);
rxfilter.op = htobe32(op);
- DPRINTF(("setting Rx filter=0x%x flags=0x%x\n", bits, op));
+ DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
+ "setting Rx filter=0x%x flags=0x%x\n", bits, op);
return uath_cmd_write(sc, WDCMSG_RX_FILTER, &rxfilter,
sizeof rxfilter, 0);
}
@@ -2248,7 +2285,8 @@
uath_set_ledstate(struct uath_softc *sc, int connected)
{
- DPRINTFN(2, ("set led state %sconnected\n", connected ? "" : "!"));
+ DPRINTF(sc, UATH_DEBUG_LED,
+ "set led state %sconnected\n", connected ? "" : "!");
connected = htobe32(connected);
return uath_cmd_write(sc, WDCMSG_SET_LED_STATE,
&connected, sizeof connected, 0);
@@ -2262,9 +2300,9 @@
led.lednum = htobe32(lednum);
led.ledmode = htobe32(ledmode);
- DPRINTFN(2, ("set %s led %s (steady)\n",
+ DPRINTF(sc, UATH_DEBUG_LED, "set %s led %s (steady)\n",
(lednum == UATH_LED_LINK) ? "link" : "activity",
- ledmode ? "on" : "off"));
+ ledmode ? "on" : "off");
return uath_cmd_write(sc, WDCMSG_SET_LED_STEADY, &led, sizeof led, 0);
}
@@ -2279,9 +2317,9 @@
led.blinkrate = htobe32(blinkrate);
led.slowmode = htobe32(slowmode);
- DPRINTFN(2, ("set %s led %s (blink)\n",
+ DPRINTF(sc, UATH_DEBUG_LED, "set %s led %s (blink)\n",
(lednum == UATH_LED_LINK) ? "link" : "activity",
- ledmode ? "on" : "off"));
+ ledmode ? "on" : "off");
return uath_cmd_write(sc, WDCMSG_SET_LED_BLINK, &led, sizeof led, 0);
}
@@ -2398,8 +2436,8 @@
UATH_LOCK(sc);
goto fail;
}
- DPRINTF(("%s returns handle: 0x%x\n",
- uath_codename(WDCMSG_TARGET_START), be32toh(val)));
+ DPRINTF(sc, UATH_DEBUG_INIT, "%s returns handle: 0x%x\n",
+ uath_codename(WDCMSG_TARGET_START), be32toh(val));
UATH_LOCK(sc);
error = uath_wme_init(sc);
==== //depot/projects/vap/sys/dev/usb/if_uathvar.h#2 (text+ko) ====
@@ -150,6 +150,7 @@
usbd_device_handle sc_udev;
usbd_interface_handle sc_iface;
struct mtx sc_mtx;
+ uint32_t sc_debug;
struct uath_stat sc_stat;
int (*sc_newstate)(struct ieee80211com *,
More information about the p4-projects
mailing list