Date: Sun, 8 Feb 2009 21:47:08 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r188338 - user/thompsa/usb/sys/dev/usb2/wlan Message-ID: <200902082147.n18Ll8kV035229@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Sun Feb 8 21:47:08 2009 New Revision: 188338 URL: http://svn.freebsd.org/changeset/base/188338 Log: Add hardware command debugging. Modified: user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c Modified: user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c ============================================================================== --- user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c Sun Feb 8 21:20:13 2009 (r188337) +++ user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c Sun Feb 8 21:47:08 2009 (r188338) @@ -60,11 +60,12 @@ enum { ZYD_DEBUG_STATE = 0x00000040, /* 802.11 state transitions */ ZYD_DEBUG_STAT = 0x00000080, /* statistic */ ZYD_DEBUG_FW = 0x00000100, /* firmware */ + ZYD_DEBUG_CMD = 0x00000200, /* fw commands */ ZYD_DEBUG_ANY = 0xffffffff }; #define DPRINTF(sc, m, fmt, ...) do { \ if (sc->sc_debug & (m)) \ - printf(fmt, __VA_ARGS__); \ + printf("%s: " fmt, __func__, ## __VA_ARGS__); \ } while (0) #else #define DPRINTF(sc, m, fmt, ...) do { \ @@ -746,26 +747,31 @@ zyd_intr_read_callback(struct usb2_xfer datalen -= 2; /* XXX: padding? */ STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { - int i; + int i, cnt; - if (sizeof(struct zyd_pair) * rqp->olen != datalen) + if (rqp->olen != datalen) continue; - for (i = 0; i < rqp->olen; i++) { + cnt = rqp->olen / sizeof(struct zyd_pair); + for (i = 0; i < cnt; i++) { if (*(((const uint16_t *)rqp->idata) + i) != (((struct zyd_pair *)cmd->data) + i)->reg) break; } - if (i != rqp->olen) + if (i != cnt) continue; /* copy answer into caller-supplied buffer */ - bcopy(cmd->data, rqp->odata, - sizeof(struct zyd_pair) * rqp->olen); + bcopy(cmd->data, rqp->odata, rqp->olen); + DPRINTF(sc, ZYD_DEBUG_CMD, + "command %p complete, data = %*D \n", + rqp, rqp->olen, rqp->odata, ":"); wakeup(rqp); /* wakeup caller */ - return; + break; + } + if (rqp == NULL) { + device_printf(sc->sc_dev, + "unexpected IORD notification %*D\n", + datalen, cmd->data, ":"); } - device_printf(sc->sc_dev, - "unexpected IORD notification %*D\n", - datalen, cmd->data, ":"); break; } default: @@ -784,7 +790,7 @@ zyd_intr_read_callback(struct usb2_xfer break; default: /* Error */ - DPRINTF(sc, ZYD_DEBUG_ANY, "error = %s\n", + DPRINTF(sc, ZYD_DEBUG_CMD, "error = %s\n", usb2_errstr(xfer->error)); if (xfer->error != USB_ERR_CANCELLED) { @@ -817,8 +823,8 @@ zyd_intr_write_callback(struct usb2_xfer switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - DPRINTF(sc, ZYD_DEBUG_ANY, "length=%d\n", xfer->actlen); rqp = xfer->priv_fifo; + DPRINTF(sc, ZYD_DEBUG_CMD, "command %p transferred\n", rqp); if ((rqp->flags & ZYD_CMD_FLAG_READ) == 0) wakeup(rqp); /* wakeup caller */ @@ -884,12 +890,14 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c cmd.code = htole16(code); bcopy(idata, cmd.data, ilen); + DPRINTF(sc, ZYD_DEBUG_CMD, "sending cmd %p = %*D\n", + &rq, ilen, idata, ":"); rq.cmd = &cmd; rq.idata = idata; rq.odata = odata; rq.ilen = sizeof(uint16_t) + ilen; - rq.olen = olen / sizeof(struct zyd_pair); + rq.olen = olen; rq.flags = flags; STAILQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq); usb2_transfer_start(sc->sc_xfer[ZYD_INTR_DT_RD]); @@ -900,6 +908,8 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c if (error) device_printf(sc->sc_dev, "command timeout\n"); STAILQ_REMOVE(&sc->sc_rqh, &rq, zyd_rq, rq); + DPRINTF(sc, ZYD_DEBUG_CMD, "finsihed cmd %p, error = %d \n", + &rq, error); return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902082147.n18Ll8kV035229>