Change to DPRINTF/DPRINTFN for debug output.

This commit is contained in:
jmc 2001-05-03 04:42:11 +00:00
parent 3aa56ffc5a
commit f29b37329e

View File

@ -1,4 +1,4 @@
/* $NetBSD: fwohci.c,v 1.27 2001/05/01 06:17:23 enami Exp $ */
/* $NetBSD: fwohci.c,v 1.28 2001/05/03 04:42:11 jmc Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -75,7 +75,7 @@ static const char * const ieee1394_speeds[] = { IEEE1394_SPD_STRINGS };
#if 0
static int fwohci_dnamem_alloc(struct fwohci_softc *sc, int size,
int alignment, bus_dmamap_t *mapp, caddr_t *kvap, int flags);
int alignment, bus_dmamap_t *mapp, caddr_t *kvap, int flags);
#endif
static void fwohci_create_event_thread(void *);
static void fwohci_thread_init(void *);
@ -90,7 +90,7 @@ static struct fwohci_desc *fwohci_desc_get(struct fwohci_softc *, int);
static void fwohci_desc_put(struct fwohci_softc *, struct fwohci_desc *, int);
static int fwohci_ctx_alloc(struct fwohci_softc *, struct fwohci_ctx **,
int, int);
int, int);
static void fwohci_ctx_free(struct fwohci_softc *, struct fwohci_ctx *);
static void fwohci_ctx_init(struct fwohci_softc *, struct fwohci_ctx *);
@ -101,9 +101,9 @@ static void fwohci_buf_start(struct fwohci_softc *);
static void fwohci_buf_stop(struct fwohci_softc *);
static void fwohci_buf_next(struct fwohci_softc *, struct fwohci_ctx *);
static int fwohci_buf_pktget(struct fwohci_softc *, struct fwohci_ctx *,
caddr_t *, int);
caddr_t *, int);
static int fwohci_buf_input(struct fwohci_softc *, struct fwohci_ctx *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static u_int8_t fwohci_phy_read(struct fwohci_softc *, u_int8_t);
static void fwohci_phy_write(struct fwohci_softc *, u_int8_t, u_int8_t);
@ -111,54 +111,60 @@ static void fwohci_phy_busreset(struct fwohci_softc *);
static void fwohci_phy_input(struct fwohci_softc *, struct fwohci_pkt *);
static int fwohci_handler_set(struct fwohci_softc *, int, u_int32_t, u_int32_t,
int (*)(struct fwohci_softc *, void *, struct fwohci_pkt *),
void *);
int (*)(struct fwohci_softc *, void *, struct fwohci_pkt *), void *);
static void fwohci_arrq_input(struct fwohci_softc *, struct fwohci_ctx *);
static void fwohci_arrs_input(struct fwohci_softc *, struct fwohci_ctx *);
static void fwohci_ir_input(struct fwohci_softc *, struct fwohci_ctx *);
static int fwohci_at_output(struct fwohci_softc *, struct fwohci_ctx *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static void fwohci_at_done(struct fwohci_softc *, struct fwohci_ctx *, int);
static void fwohci_atrs_output(struct fwohci_softc *, int, struct fwohci_pkt *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static int fwohci_guidrom_init(struct fwohci_softc *);
static void fwohci_configrom_init(struct fwohci_softc *);
static int fwohci_configrom_input(struct fwohci_softc *, void *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static void fwohci_selfid_init(struct fwohci_softc *);
static int fwohci_selfid_input(struct fwohci_softc *);
static void fwohci_csr_init(struct fwohci_softc *);
static int fwohci_csr_input(struct fwohci_softc *, void *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static void fwohci_uid_collect(struct fwohci_softc *);
static int fwohci_uid_input(struct fwohci_softc *, void *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static int fwohci_uid_lookup(struct fwohci_softc *, const u_int8_t *);
static void fwohci_check_nodes(struct fwohci_softc *);
static int fwohci_if_inreg(struct device *, u_int32_t, u_int32_t,
void (*)(struct device *, struct mbuf *));
void (*)(struct device *, struct mbuf *));
static int fwohci_if_input(struct fwohci_softc *, void *, struct fwohci_pkt *);
static int fwohci_if_output(struct device *, struct mbuf *,
void (*)(struct device *, struct mbuf *));
void (*)(struct device *, struct mbuf *));
static int fwohci_input(struct ieee1394_abuf *);
static int fwohci_output(struct ieee1394_abuf *);
static int fwohci_extract_resp(struct fwohci_softc *, void *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static int fwohci_multi_resp(struct fwohci_softc *, void *,
struct fwohci_pkt *);
struct fwohci_pkt *);
static int fwohci_inreg(struct ieee1394_abuf *, int);
static int fwohci_parse_input(struct fwohci_softc *, void *,
struct fwohci_pkt *);
struct fwohci_pkt *);
#ifdef FW_DEBUG
int fw_verbose = 1;
int fw_dump = 1;
/* 1 is normal debug, 2 is verbose debug, 3 is complete (packet dumps). */
#define DPRINTF(x) if (fwdebug) printf x
#define DPRINTFN(n,x) if (fwdebug>(n)) printf x
int fwdebug = 2;
#else
#define DPRINTF(x)
#define DPRINTFN(n,x)
#endif
int
@ -213,7 +219,7 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
} else {
printf(", unknown speed %u", sc->sc_sc1394.sc1394_link_speed);
}
/* MaxRec is encoded as log2(max_rec_octets)-1
*/
sc->sc_sc1394.sc1394_max_receive =
@ -232,7 +238,7 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
}
sc->sc_isoctx = i;
printf(", %d iso_ctx", sc->sc_isoctx);
printf("\n");
#if 0
@ -277,64 +283,55 @@ fwohci_intr(void *arg)
OHCI_CSR_WRITE(sc, OHCI_REG_IntEventClear,
intmask & ~OHCI_Int_BusReset);
#ifdef FW_DEBUG
if (fw_verbose > 1) {
printf("%s: intmask=0x%08x:",
sc->sc_sc1394.sc1394_dev.dv_xname, intmask);
if (intmask & OHCI_Int_CycleTooLong)
printf(" CycleTooLong");
if (intmask & OHCI_Int_UnrecoverableError)
printf(" UnrecoverableError");
if (intmask & OHCI_Int_CycleInconsistent)
printf(" CycleInconsistent");
if (intmask & OHCI_Int_BusReset)
printf(" BusReset");
if (intmask & OHCI_Int_SelfIDComplete)
printf(" SelfIDComplete");
if (intmask & OHCI_Int_LockRespErr)
printf(" LockRespErr");
if (intmask & OHCI_Int_PostedWriteErr)
printf(" PostedWriteErr");
if (intmask & OHCI_Int_ReqTxComplete)
printf(" ReqTxComplete(0x%04x)",
OHCI_ASYNC_DMA_READ(sc,
OHCI_CTX_ASYNC_TX_REQUEST,
OHCI_SUBREG_ContextControlClear));
if (intmask & OHCI_Int_RespTxComplete)
printf(" RespTxComplete(0x%04x)",
OHCI_ASYNC_DMA_READ(sc,
OHCI_CTX_ASYNC_TX_RESPONSE,
OHCI_SUBREG_ContextControlClear));
if (intmask & OHCI_Int_ARRS)
printf(" ARRS(0x%04x)",
OHCI_ASYNC_DMA_READ(sc,
OHCI_CTX_ASYNC_RX_RESPONSE,
OHCI_SUBREG_ContextControlClear));
if (intmask & OHCI_Int_ARRQ)
printf(" ARRQ(0x%04x)",
OHCI_ASYNC_DMA_READ(sc,
OHCI_CTX_ASYNC_RX_REQUEST,
OHCI_SUBREG_ContextControlClear));
if (intmask & OHCI_Int_IsochRx)
printf(" IsochRx(0x%08x)",
OHCI_CSR_READ(sc,
OHCI_REG_IsoRecvIntEventClear));
if (intmask & OHCI_Int_IsochTx)
printf(" IsochTx(0x%08x)",
OHCI_CSR_READ(sc,
OHCI_REG_IsoXmitIntEventClear));
if (intmask & OHCI_Int_RQPkt)
printf(" RQPkt(0x%04x)",
OHCI_ASYNC_DMA_READ(sc,
OHCI_CTX_ASYNC_RX_REQUEST,
OHCI_SUBREG_ContextControlClear));
if (intmask & OHCI_Int_RSPkt)
printf(" RSPkt(0x%04x)",
OHCI_ASYNC_DMA_READ(sc,
OHCI_CTX_ASYNC_RX_RESPONSE,
OHCI_SUBREG_ContextControlClear));
printf("\n");
}
DPRINTFN(1, ("%s: intmask=0x%08x:",
sc->sc_sc1394.sc1394_dev.dv_xname, intmask));
if (intmask & OHCI_Int_CycleTooLong)
DPRINTFN(1, (" CycleTooLong"));
if (intmask & OHCI_Int_UnrecoverableError)
DPRINTFN(1, (" UnrecoverableError"));
if (intmask & OHCI_Int_CycleInconsistent)
DPRINTFN(1, (" CycleInconsistent"));
if (intmask & OHCI_Int_BusReset)
DPRINTFN(1, (" BusReset"));
if (intmask & OHCI_Int_SelfIDComplete)
DPRINTFN(1, (" SelfIDComplete"));
if (intmask & OHCI_Int_LockRespErr)
DPRINTFN(1, (" LockRespErr"));
if (intmask & OHCI_Int_PostedWriteErr)
DPRINTFN(1, (" PostedWriteErr"));
if (intmask & OHCI_Int_ReqTxComplete)
DPRINTFN(1, (" ReqTxComplete(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_TX_REQUEST,
OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_RespTxComplete)
DPRINTFN(1, (" RespTxComplete(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_TX_RESPONSE,
OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_ARRS)
DPRINTFN(1, (" ARRS(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_RESPONSE,
OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_ARRQ)
DPRINTFN(1, (" ARRQ(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_REQUEST,
OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_IsochRx)
DPRINTFN(1, (" IsochRx(0x%08x)",
OHCI_CSR_READ(sc, OHCI_REG_IsoRecvIntEventClear)));
if (intmask & OHCI_Int_IsochTx)
DPRINTFN(1, (" IsochTx(0x%08x)",
OHCI_CSR_READ(sc, OHCI_REG_IsoXmitIntEventClear)));
if (intmask & OHCI_Int_RQPkt)
DPRINTFN(1, (" RQPkt(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_REQUEST,
OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_RSPkt)
DPRINTFN(1, (" RSPkt(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_RESPONSE,
OHCI_SUBREG_ContextControlClear)));
DPRINTFN(1, ("\n"));
#endif /* FW_DEBUG */
if (intmask & OHCI_Int_BusReset) {
/*
* According to OHCI spec 6.1.1 "busReset",
@ -823,11 +820,8 @@ fwohci_phy_input(struct fwohci_softc *sc, struct fwohci_pkt *pkt)
if (val != ~pkt->fp_hdr[2]) {
if (val == 0 && ((*pkt->fp_trail & 0x001f0000) >> 16) ==
OHCI_CTXCTL_EVENT_BUS_RESET) {
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_phy_input: BusReset: 0x%08x\n",
pkt->fp_hdr[2]);
#endif
DPRINTFN(1, ("fwohci_phy_input: BusReset: 0x%08x\n",
pkt->fp_hdr[2]));
} else {
printf("%s: phy packet corrupted (0x%08x, 0x%08x)\n",
sc->sc_sc1394.sc1394_dev.dv_xname, val,
@ -840,43 +834,36 @@ fwohci_phy_input(struct fwohci_softc *sc, struct fwohci_pkt *pkt)
switch (key) {
case 0:
#ifdef FW_DEBUG
if (fw_verbose > 1) {
printf("fwohci_phy_input: PHY Config from %d:", phyid);
if (val & 0x00800000)
printf(" ForceRoot");
if (val & 0x00400000)
printf(" Gap=%x", (val & 0x003f0000) >> 16);
printf("\n");
}
DPRINTFN(1, ("fwohci_phy_input: PHY Config from %d:", phyid));
if (val & 0x00800000)
DPRINTFN(1, (" ForceRoot"));
if (val & 0x00400000)
DPRINTFN(1, (" Gap=%x", (val & 0x003f0000) >> 16));
printf("\n");
#endif
break;
case 1:
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_phy_input: Link-on from %d\n", phyid);
#endif
DPRINTFN(1, ("fwohci_phy_input: Link-on from %d\n", phyid));
break;
case 2:
#ifdef FW_DEBUG
if (fw_verbose > 1) {
printf("fwohci_phy_input: SelfID from %d:", phyid);
if (val & 0x00800000) {
printf(" #%d", (val & 0x00700000) >> 20);
} else {
if (val & 0x00400000)
printf(" LinkActive");
printf(" Gap=%x", (val & 0x003f0000) >> 16);
printf(" Spd=S%d",
100 << ((val & 0x0000c000) >> 14));
if (val & 0x00000800)
printf(" Cont");
if (val & 0x00000002)
printf(" InitiateBusReset");
}
if (val & 0x00000001)
printf(" +");
printf("\n");
DPRINTFN(1, ("fwohci_phy_input: SelfID from %d:", phyid));
if (val & 0x00800000) {
DPRINTFN(1, (" #%d", (val & 0x00700000) >> 20));
} else {
if (val & 0x00400000)
DPRINTFN(1, (" LinkActive"));
DPRINTFN(1, (" Gap=%x", (val & 0x003f0000) >> 16));
DPRINTFN(1, (" Spd=S%d",
100 << ((val & 0x0000c000) >> 14)));
if (val & 0x00000800)
DPRINTFN(1, (" Cont"));
if (val & 0x00000002)
DPRINTFN(1, (" InitiateBusReset"));
}
if (val & 0x00000001)
DPRINTFN(1, (" +"));
DPRINTFN(1, ("\n"));
#endif
break;
default:
@ -973,7 +960,7 @@ fwohci_desc_put(struct fwohci_softc *sc, struct fwohci_desc *fd, int ndesc)
n = fd - sc->sc_desc;
for (i = 0; i < ndesc; i++, n++) {
#ifdef DIAGNOSTICS
#ifdef DIAGNOSTIC
if (isclr(sc->sc_descmap, n))
panic("fwohci_desc_put: duplicated free");
#endif
@ -1246,14 +1233,10 @@ fwohci_buf_pktget(struct fwohci_softc *sc, struct fwohci_ctx *fc, caddr_t *pp,
fb = TAILQ_FIRST(&fc->fc_buf);
again:
fd = fb->fb_desc;
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_buf_pktget: desc %ld, off %d, req %d, res %d,"
" len %d, avail %d\n",
(long)(fd - sc->sc_desc), fb->fb_off, fd->fd_reqcount,
fd->fd_rescount, len,
fd->fd_reqcount - fd->fd_rescount - fb->fb_off);
#endif
DPRINTFN(1, ("fwohci_buf_pktget: desc %ld, off %d, req %d, res %d,"
" len %d, avail %d\n", (long)(fd - sc->sc_desc), fb->fb_off,
fd->fd_reqcount, fd->fd_rescount, len,
fd->fd_reqcount - fd->fd_rescount - fb->fb_off));
bufend = fd->fd_reqcount - fd->fd_rescount;
if (fb->fb_off >= bufend) {
if (fc->fc_isoch && fb->fb_off > 0) {
@ -1297,11 +1280,8 @@ fwohci_buf_input(struct fwohci_softc *sc, struct fwohci_ctx *fc,
len = fwohci_buf_pktget(sc, fc, (caddr_t *)&pkt->fp_trail,
sizeof(*pkt->fp_trail));
if (len <= 0) {
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_buf_input: no input for is#%d\n",
fc->fc_ctx);
#endif
DPRINTFN(1, ("fwohci_buf_input: no input for is#%d\n",
fc->fc_ctx));
return 0;
}
*pkt->fp_trail = (*pkt->fp_trail & 0xffff) |
@ -1309,11 +1289,8 @@ fwohci_buf_input(struct fwohci_softc *sc, struct fwohci_ctx *fc,
}
len = fwohci_buf_pktget(sc, fc, &p, count);
if (len <= 0) {
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_buf_input: no input for %d\n",
fc->fc_ctx);
#endif
DPRINTFN(1, ("fwohci_buf_input: no input for %d\n",
fc->fc_ctx));
return 0;
}
pkt->fp_hdr[0] = *(u_int32_t *)p;
@ -1358,11 +1335,8 @@ fwohci_buf_input(struct fwohci_softc *sc, struct fwohci_ctx *fc,
if ((pkt->fp_hlen == 16) &&
pkt->fp_tcode != IEEE1394_TCODE_READ_REQ_BLOCK)
pkt->fp_dlen = pkt->fp_hdr[3] >> 16;
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_buf_input: tcode=0x%x, hlen=%d, dlen=%d\n",
pkt->fp_tcode, pkt->fp_hlen, pkt->fp_dlen);
#endif
DPRINTFN(1, ("fwohci_buf_input: tcode=0x%x, hlen=%d, dlen=%d\n",
pkt->fp_tcode, pkt->fp_hlen, pkt->fp_dlen));
/* get data */
count = 0;
@ -1428,11 +1402,8 @@ fwohci_handler_set(struct fwohci_softc *sc,
if (handler == NULL)
return 0;
if (j == sc->sc_isoctx) {
#ifdef FW_DEBUG
if (fw_verbose)
printf("fwohci_handler_set: "
"no more free context\n");
#endif
DPRINTF(("fwohci_handler_set: no more free "
"context\n"));
return ENOMEM;
}
if ((fc = sc->sc_ctx_ir[j]) == NULL) {
@ -1486,20 +1457,13 @@ fwohci_handler_set(struct fwohci_softc *sc,
fh->fh_key2 = key2;
fh->fh_handler = handler;
fh->fh_handarg = arg;
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_handler_set: ctx %d, tcode %x, key 0x%x, 0x%x\n",
fc->fc_ctx, tcode, key1, key2);
#endif
DPRINTFN(1, ("fwohci_handler_set: ctx %d, tcode %x, key 0x%x, 0x%x\n",
fc->fc_ctx, tcode, key1, key2));
if (tcode == IEEE1394_TCODE_STREAM_DATA) {
fwohci_ctx_init(sc, fc);
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_handler_set: SYNC desc %ld\n",
(long)(TAILQ_FIRST(&fc->fc_buf)->fb_desc -
sc->sc_desc));
#endif
DPRINTFN(1, ("fwohci_handler_set: SYNC desc %ld\n",
(long)(TAILQ_FIRST(&fc->fc_buf)->fb_desc - sc->sc_desc)));
OHCI_SYNC_RX_DMA_WRITE(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlSet, OHCI_CTXCTL_RUN);
}
@ -1539,12 +1503,9 @@ fwohci_arrq_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
}
if (fh == NULL) {
rcode = IEEE1394_RCODE_ADDRESS_ERROR;
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_arrq_input: no listener:"
" tcode 0x%x, addr=0x%04x %08x\n",
pkt.fp_tcode, key1, key2);
#endif
DPRINTFN(1, ("fwohci_arrq_input: no listener: tcode "
"0x%x, addr=0x%04x %08x\n", pkt.fp_tcode, key1,
key2));
}
if (((*pkt.fp_trail & 0x001f0000) >> 16) !=
OHCI_CTXCTL_EVENT_ACK_PENDING)
@ -1573,13 +1534,10 @@ fwohci_arrs_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
srcid = pkt.fp_hdr[1] >> 16;
rcode = (pkt.fp_hdr[1] & 0x0000f000) >> 12;
tlabel = (pkt.fp_hdr[0] & 0x0000fc00) >> 10;
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_arrs_input: tcode 0x%x, from 0x%04x,"
" tlabel 0x%x, rcode 0x%x, hlen %d, dlen %d\n",
pkt.fp_tcode, srcid, tlabel, rcode, pkt.fp_hlen,
pkt.fp_dlen);
#endif
DPRINTFN(1, ("fwohci_arrs_input: tcode 0x%x, from 0x%04x,"
" tlabel 0x%x, rcode 0x%x, hlen %d, dlen %d\n",
pkt.fp_tcode, srcid, tlabel, rcode, pkt.fp_hlen,
pkt.fp_dlen));
for (fh = LIST_FIRST(&fc->fc_handler); fh != NULL;
fh = LIST_NEXT(fh, fh_list)) {
if (pkt.fp_tcode == fh->fh_tcode &&
@ -1592,14 +1550,13 @@ fwohci_arrs_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
}
}
#ifdef FW_DEBUG
if (fw_verbose > 1)
if (fh == NULL) {
printf("fwohci_arrs_input: no listner\n");
printf("src: %d, rcode: %d, tlabel: %d, tcode: "
"%d hdr[3]: 0x%08x, data: 0x%08lx\n", srcid,
rcode, tlabel, pkt.fp_tcode, pkt.fp_hdr[3],
(unsigned long)(*((int *)pkt.fp_iov[0].iov_base)));
}
if (fh == NULL) {
DPRINTFN(1, ("fwohci_arrs_input: no listner\n"));
DPRINTFN(1, ("src: %d, rcode: %d, tlabel: %d, tcode: "
"%d hdr[3]: 0x%08x, data: 0x%08lx\n", srcid, rcode,
tlabel, pkt.fp_tcode, pkt.fp_hdr[3],
(unsigned long)(*((int *)pkt.fp_iov[0].iov_base))));
}
#endif
}
fwohci_buf_next(sc, fc);
@ -1621,12 +1578,9 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
while (fwohci_buf_input(sc, fc, &pkt)) {
chan = (pkt.fp_hdr[0] & 0x00003f00) >> 8;
tag = (pkt.fp_hdr[0] & 0x0000c000) >> 14;
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_ir_input: hdr 0x%08x, tcode %d,"
" hlen %d, dlen %d\n", pkt.fp_hdr[0],
pkt.fp_tcode, pkt.fp_hlen, pkt.fp_dlen);
#endif
DPRINTFN(1, ("fwohci_ir_input: hdr 0x%08x, tcode %d, hlen %d, "
"dlen %d\n", pkt.fp_hdr[0], pkt.fp_tcode, pkt.fp_hlen,
pkt.fp_dlen));
if (tag == IEEE1394_TAG_GASP) {
/*
* The pkt with tag=3 is GASP format.
@ -1653,11 +1607,10 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
}
}
#ifdef FW_DEBUG
if (fw_verbose > 1) {
if (fh == NULL)
printf("fwohci_ir_input: no handler\n");
else
printf("fwohci_ir_input: rcode %d\n", rcode);
if (fh == NULL) {
DPRINTFN(1, ("fwohci_ir_input: no handler\n"));
} else {
DPRINTFN(1, ("fwohci_ir_input: rcode %d\n", rcode));
}
#endif
}
@ -1678,31 +1631,28 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
struct mbuf *m, *m0;
int i, ndesc, error, off, len;
u_int32_t val;
#ifdef FW_DEBUG
struct iovec *iov;
#endif
if ((sc->sc_nodeid & OHCI_NodeId_NodeNumber) > sc->sc_rootid)
/* We can't send anything during selfid duration */
return EAGAIN;
#ifdef FW_DEBUG
if (fw_verbose > 1) {
struct iovec *iov;
printf("fwohci_at_output: tcode 0x%x, hlen %d, dlen %d",
pkt->fp_tcode, pkt->fp_hlen, pkt->fp_dlen);
if (fw_dump) {
for (i = 0; i < pkt->fp_hlen/4; i++)
printf("%s%08x", i?" ":"\n\t", pkt->fp_hdr[i]);
printf("$");
for (ndesc = 0, iov = pkt->fp_iov;
ndesc < pkt->fp_uio.uio_iovcnt; ndesc++, iov++) {
for (i = 0; i < iov->iov_len; i++)
printf("%s%02x",
(i%32)?((i%4)?"":" "):"\n\t",
((u_int8_t *)iov->iov_base)[i]);
printf("$");
}
}
printf("\n");
DPRINTFN(1, ("fwohci_at_output: tcode 0x%x, hlen %d, dlen %d",
pkt->fp_tcode, pkt->fp_hlen, pkt->fp_dlen));
for (i = 0; i < pkt->fp_hlen/4; i++)
DPRINTFN(2, ("%s%08x", i?" ":"\n\t", pkt->fp_hdr[i]));
DPRINTFN(2, ("$"));
for (ndesc = 0, iov = pkt->fp_iov;
ndesc < pkt->fp_uio.uio_iovcnt; ndesc++, iov++) {
for (i = 0; i < iov->iov_len; i++)
DPRINTFN(2, ("%s%02x", (i%32)?((i%4)?"":" "):"\n\t",
((u_int8_t *)iov->iov_base)[i]));
DPRINTFN(2, ("$"));
}
DPRINTFN(1, ("\n"));
#endif
if ((m = pkt->fp_m) != NULL) {
@ -1809,14 +1759,12 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
fd->fd_flags |= OHCI_DESC_INTR_ALWAYS;
#ifdef FW_DEBUG
if (fw_verbose > 1) {
printf("fwohci_at_output: desc %ld",
(long)(fb->fb_desc - sc->sc_desc));
for (i = 0; i < ndesc * 4; i++)
printf("%s%08x", i&7?" ":"\n\t",
((u_int32_t *)fb->fb_desc)[i]);
printf("\n");
}
DPRINTFN(1, ("fwohci_at_output: desc %ld",
(long)(fb->fb_desc - sc->sc_desc)));
for (i = 0; i < ndesc * 4; i++)
DPRINTFN(1, ("%s%08x", i&7?" ":"\n\t",
((u_int32_t *)fb->fb_desc)[i]));
DPRINTFN(1, ("\n"));
#endif
val = OHCI_ASYNC_DMA_READ(sc, fc->fc_ctx,
@ -1856,15 +1804,13 @@ fwohci_at_done(struct fwohci_softc *sc, struct fwohci_ctx *fc, int force)
while ((fb = TAILQ_FIRST(&fc->fc_buf)) != NULL) {
fd = fb->fb_desc;
#ifdef FW_DEBUG
if (fw_verbose > 1) {
printf("fwohci_at_done: %sdesc %ld (%d)",
force ? "force " : "",
(long)(fd - sc->sc_desc), fb->fb_nseg);
for (i = 0; i < fb->fb_nseg * 4; i++)
printf("%s%08x", i&7?" ":"\n ",
((u_int32_t *)fd)[i]);
printf("\n");
}
DPRINTFN(1, ("fwohci_at_done: %sdesc %ld (%d)",
force ? "force " : "", (long)(fd - sc->sc_desc),
fb->fb_nseg));
for (i = 0; i < fb->fb_nseg * 4; i++)
DPRINTFN(1, ("%s%08x", i&7?" ":"\n ",
((u_int32_t *)fd)[i]));
DPRINTFN(1, ("\n"));
#endif
if (fb->fb_nseg > 2)
fd += fb->fb_nseg - 1;
@ -2160,12 +2106,10 @@ fwohci_configrom_init(struct fwohci_softc *sc)
fb->fb_off = cfr.ptr - hdr;
#ifdef FW_DEBUG
if (fw_dump) {
printf("%s: Config ROM:", sc->sc_sc1394.sc1394_dev.dv_xname);
for (i = 0; i < fb->fb_off; i++)
printf("%s%08x", i&7?" ":"\n ", hdr[i]);
printf("\n");
}
DPRINTFN(2, ("%s: Config ROM:", sc->sc_sc1394.sc1394_dev.dv_xname));
for (i = 0; i < fb->fb_off; i++)
DPRINTFN(2, ("%s%08x", i&7?" ":"\n ", hdr[i]));
DPRINTFN(2, ("\n"));
#endif /* FW_DEBUG */
/*
@ -2204,11 +2148,8 @@ fwohci_configrom_input(struct fwohci_softc *sc, void *arg,
loc /= 4;
rom = (u_int32_t *)sc->sc_buf_cnfrom.fb_buf;
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_configrom_input: ConfigRom[0x%04x]: 0x%08x\n",
loc, ntohl(rom[loc]));
#endif
DPRINTFN(1, ("fwohci_configrom_input: ConfigRom[0x%04x]: 0x%08x\n", loc,
ntohl(rom[loc])));
memset(&res, 0, sizeof(res));
res.fp_hdr[3] = rom[loc];
@ -2225,11 +2166,11 @@ fwohci_selfid_init(struct fwohci_softc *sc)
struct fwohci_buf *fb;
fb = &sc->sc_buf_selfid;
#ifdef DIAGNOSTICS
#ifdef DIAGNOSTIC
if ((fb->fb_dmamap->dm_segs[0].ds_addr & 0x7ff) != 0)
panic("fwohci_selfid_init: not aligned: %p (%ld) %p",
(caddr_t)fb->fb_dmamap->dm_segs[0].ds_addr,
fb->fb_dmamap->dm_segs[0].ds_len, fb->fb_buf);
(unsigned long)fb->fb_dmamap->dm_segs[0].ds_len, fb->fb_buf);
#endif
memset(fb->fb_buf, 0, fb->fb_dmamap->dm_segs[0].ds_len);
bus_dmamap_sync(sc->sc_dmat, fb->fb_dmamap, 0,
@ -2260,13 +2201,11 @@ fwohci_selfid_input(struct fwohci_softc *sc)
gen = OHCI_BITVAL(buf[0], OHCI_SelfID_Gen);
#ifdef FW_DEBUG
if (fw_verbose > 1) {
printf("%s: SelfID: 0x%08x", sc->sc_sc1394.sc1394_dev.dv_xname,
val);
for (i = 0; i < count; i++)
printf("%s%08x", i&7?" ":"\n ", buf[i]);
printf("\n");
}
DPRINTFN(1, ("%s: SelfID: 0x%08x", sc->sc_sc1394.sc1394_dev.dv_xname,
val));
for (i = 0; i < count; i++)
DPRINTFN(1, ("%s%08x", i&7?" ":"\n ", buf[i]));
DPRINTFN(1, ("\n"));
#endif /* FW_DEBUG */
for (i = 1; i < count; i += 2) {
@ -2286,12 +2225,9 @@ fwohci_selfid_input(struct fwohci_softc *sc)
if (OHCI_BITVAL(val, OHCI_SelfID_Gen) !=
OHCI_BITVAL(buf[0], OHCI_SelfID_Gen))
goto again;
#ifdef FW_DEBUG
if (fw_verbose)
printf("%s: SelfID Gen mismatch (%d, %d)\n",
sc->sc_sc1394.sc1394_dev.dv_xname, gen,
OHCI_BITVAL(val, OHCI_SelfID_Gen));
#endif
DPRINTF(("%s: SelfID Gen mismatch (%d, %d)\n",
sc->sc_sc1394.sc1394_dev.dv_xname, gen,
OHCI_BITVAL(val, OHCI_SelfID_Gen)));
return -1;
}
if (i != count) {
@ -2318,14 +2254,11 @@ fwohci_selfid_input(struct fwohci_softc *sc)
return -1;
}
sc->sc_nodeid = val & 0xffff;
#ifdef FW_DEBUG
if (fw_verbose)
printf("%s: nodeid=0x%04x(%d), rootid=%d, irmid=%d\n",
sc->sc_sc1394.sc1394_dev.dv_xname,
sc->sc_nodeid, sc->sc_nodeid & OHCI_NodeId_NodeNumber,
sc->sc_rootid, sc->sc_irmid);
#endif
DPRINTF(("%s: nodeid=0x%04x(%d), rootid=%d, irmid=%d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, sc->sc_nodeid,
sc->sc_nodeid & OHCI_NodeId_NodeNumber, sc->sc_rootid,
sc->sc_irmid));
if ((sc->sc_nodeid & OHCI_NodeId_NodeNumber) > sc->sc_rootid)
return -1;
@ -2377,24 +2310,15 @@ fwohci_csr_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
/* alignment error */
return IEEE1394_RCODE_ADDRESS_ERROR;
}
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("fwohci_csr_input: CSR[0x%04x]: 0x%08x",
reg, *(u_int32_t *)(&sc->sc_csr[reg]));
#endif
DPRINTFN(1, ("fwohci_csr_input: CSR[0x%04x]: 0x%08x", reg,
*(u_int32_t *)(&sc->sc_csr[reg])));
if (pkt->fp_tcode == IEEE1394_TCODE_WRITE_REQ_QUAD) {
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf(" -> 0x%08x\n",
ntohl(*(u_int32_t *)pkt->fp_iov[0].iov_base));
#endif
DPRINTFN(1, (" -> 0x%08x\n",
ntohl(*(u_int32_t *)pkt->fp_iov[0].iov_base)));
*(u_int32_t *)&sc->sc_csr[reg] =
ntohl(*(u_int32_t *)pkt->fp_iov[0].iov_base);
} else {
#ifdef FW_DEBUG
if (fw_verbose > 1)
printf("\n");
#endif
DPRINTFN(1, ("\n"));
res.fp_hdr[3] = htonl(*(u_int32_t *)&sc->sc_csr[reg]);
res.fp_iov[0].iov_base = &res.fp_hdr[3];
res.fp_iov[0].iov_len = 4;
@ -2438,12 +2362,9 @@ fwohci_uid_collect(struct fwohci_softc *sc)
iea = (struct ieee1394_softc *)sc->sc_sc1394.sc1394_if;
if (iea) {
iea->sc1394_node_id = i;
#ifdef FW_DEBUG
if (fw_verbose)
printf("%s: Updating nodeid to %d\n",
iea->sc1394_dev.dv_xname,
iea->sc1394_node_id);
#endif
DPRINTF(("%s: Updating nodeid to %d\n",
iea->sc1394_dev.dv_xname,
iea->sc1394_node_id));
}
continue;
}
@ -2498,23 +2419,20 @@ fwohci_uid_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *res)
fu->fu_valid |= 0x2;
}
#ifdef FW_DEBUG
if ((fw_verbose > 1) && fu->fu_valid == 0x3)
printf("fwohci_uid_input: "
if (fu->fu_valid == 0x3)
DPRINTFN(1, ("fwohci_uid_input: "
"Node %d, UID %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", n,
fu->fu_uid[0], fu->fu_uid[1], fu->fu_uid[2], fu->fu_uid[3],
fu->fu_uid[4], fu->fu_uid[5], fu->fu_uid[6], fu->fu_uid[7]);
fu->fu_uid[4], fu->fu_uid[5], fu->fu_uid[6], fu->fu_uid[7]));
#endif
if (fu->fu_valid == 0x3) {
LIST_FOREACH(iea, &sc->sc_nodelist, sc1394_node)
if (memcmp(iea->sc1394_guid, fu->fu_uid, 8) == 0) {
found = 1;
iea->sc1394_node_id = n;
#ifdef FW_DEBUG
if (fw_verbose)
printf("%s: Updating nodeid to %d\n",
iea->sc1394_dev.dv_xname,
iea->sc1394_node_id);
#endif
DPRINTF(("%s: Updating nodeid to %d\n",
iea->sc1394_dev.dv_xname,
iea->sc1394_node_id));
break;
}
if (!found) {
@ -2554,6 +2472,7 @@ fwohci_check_nodes(struct fwohci_softc *sc)
struct ieee1394_softc *iea;
LIST_FOREACH(iea, &sc->sc_nodelist, sc1394_node) {
/*
* Have to defer detachment until the next
* loop iteration since config_detach
@ -2626,25 +2545,20 @@ fwohci_if_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
void (*handler)(struct device *, struct mbuf *) = arg;
#ifdef FW_DEBUG
if (fw_verbose > 1) {
int i;
printf("fwohci_if_input: tcode=0x%x, dlen=%d",
pkt->fp_tcode, pkt->fp_dlen);
if (fw_dump) {
for (i = 0; i < pkt->fp_hlen/4; i++)
printf("%s%08x", i?" ":"\n\t", pkt->fp_hdr[i]);
printf("$");
for (n = 0, len = pkt->fp_dlen; len > 0; len -= i, n++){
iov = &pkt->fp_iov[n];
for (i = 0; i < iov->iov_len; i++)
printf("%s%02x",
(i%32)?((i%4)?"":" "):"\n\t",
((u_int8_t *)iov->iov_base)[i]);
printf("$");
}
}
printf("\n");
int i;
DPRINTFN(1, ("fwohci_if_input: tcode=0x%x, dlen=%d", pkt->fp_tcode,
pkt->fp_dlen));
for (i = 0; i < pkt->fp_hlen/4; i++)
DPRINTFN(2, ("%s%08x", i?" ":"\n\t", pkt->fp_hdr[i]));
DPRINTFN(2, ("$"));
for (n = 0, len = pkt->fp_dlen; len > 0; len -= i, n++){
iov = &pkt->fp_iov[n];
for (i = 0; i < iov->iov_len; i++)
DPRINTFN(2, ("%s%02x", (i%32)?((i%4)?"":" "):"\n\t",
((u_int8_t *)iov->iov_base)[i]));
DPRINTFN(2, ("$"));
}
DPRINTFN(1, ("\n"));
#endif /* FW_DEBUG */
len = pkt->fp_dlen;
MGETHDR(m, M_DONTWAIT, MT_DATA);
@ -2716,6 +2630,9 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
struct fwohci_pkt pkt;
u_int8_t *p;
int n, error, spd, hdrlen, maxrec;
#ifdef FW_DEBUG
struct mbuf *m;
#endif
p = mtod(m0, u_int8_t *);
if (m0->m_flags & (M_BCAST | M_MCAST)) {
@ -2736,18 +2653,15 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
printf("%s: broadcast with !M_MCAST\n",
sc->sc_sc1394.sc1394_dev.dv_xname);
#ifdef FW_DEBUG
if (fw_dump) {
struct mbuf *m;
printf("packet:");
for (m = m0; m != NULL; m = m->m_next) {
for (n = 0; n < m->m_len; n++)
printf("%s%02x", (n%32)?
((n%4)?"":" "):"\n\t",
mtod(m, u_int8_t *)[n]);
printf("$");
}
printf("\n");
DPRINTFN(2, ("packet:"));
for (m = m0; m != NULL; m = m->m_next) {
for (n = 0; n < m->m_len; n++)
DPRINTFN(2, ("%s%02x", (n%32)?
((n%4)?"":" "):"\n\t",
mtod(m, u_int8_t *)[n]));
DPRINTFN(2, ("$"));
}
DPRINTFN(2, ("\n"));
#endif
error = EHOSTUNREACH;
goto end;
@ -2757,46 +2671,30 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
hdrlen = 0;
}
if (spd > sc->sc_sc1394.sc1394_link_speed) {
#ifdef FW_DEBUG
if (fw_verbose)
printf("fwohci_if_output: spd (%d) is faster than %d\n",
spd, sc->sc_sc1394.sc1394_link_speed);
#endif
DPRINTF(("fwohci_if_output: spd (%d) is faster than %d\n",
spd, sc->sc_sc1394.sc1394_link_speed));
spd = sc->sc_sc1394.sc1394_link_speed;
}
if (maxrec > (512 << spd)) {
#ifdef FW_DEBUG
if (fw_verbose)
printf("fwohci_if_output: maxrec (%d) is larger for"
" spd (%d)\n", maxrec, spd);
#endif
DPRINTF(("fwohci_if_output: maxrec (%d) is larger for spd (%d)"
"\n", maxrec, spd));
maxrec = 512 << spd;
}
while (maxrec > sc->sc_sc1394.sc1394_max_receive) {
#ifdef FW_DEBUG
if (fw_verbose)
printf("fwohci_if_output: maxrec (%d) is larger than"
" %d\n", maxrec, sc->sc_sc1394.sc1394_max_receive);
#endif
DPRINTF(("fwohci_if_output: maxrec (%d) is larger than"
" %d\n", maxrec, sc->sc_sc1394.sc1394_max_receive));
maxrec >>= 1;
}
if (maxrec < 512) {
#ifdef FW_DEBUG
if (fw_verbose)
printf("fwohci_if_output: maxrec (%d) is smaller"
" than minimum\n", maxrec);
#endif
DPRINTF(("fwohci_if_output: maxrec (%d) is smaller than "
"minimum\n", maxrec));
maxrec = 512;
}
m_adj(m0, 16 - hdrlen);
if (m0->m_pkthdr.len > maxrec) {
#ifdef FW_DEBUG
if (fw_verbose)
printf("fwohci_if_output: packet too big:"
" hdr %d, pktlen %d, maxrec %d\n",
hdrlen, m0->m_pkthdr.len, maxrec);
#endif
DPRINTF(("fwohci_if_output: packet too big: hdr %d, pktlen "
"%d, maxrec %d\n", hdrlen, m0->m_pkthdr.len, maxrec));
error = E2BIG; /*XXX*/
goto end;
}
@ -2902,10 +2800,7 @@ fwohci_output(struct ieee1394_abuf *ab)
int rv;
if (ab->ab_length > sc->sc1394_max_receive) {
#ifdef FW_DEBUG
if (fw_verbose)
printf("Packet too large: %d\n", ab->ab_length);
#endif
DPRINTF(("Packet too large: %d\n", ab->ab_length));
return E2BIG;
}
@ -3153,11 +3048,7 @@ fwohci_inreg(struct ieee1394_abuf *ab, int allow)
fwohci_parse_input, ab);
break;
default:
#ifdef FW_DEBUG
if (fw_verbose)
printf("Invalid registration tcode: %d\n",
ab->ab_tcode);
#endif
DPRINTF(("Invalid registration tcode: %d\n", ab->ab_tcode));
return -1;
break;
}