From 11fe249262653b01645a46f938c98461bae1dc0a Mon Sep 17 00:00:00 2001 From: Hidetoshi Shimokawa Date: Thu, 8 Jan 2004 14:58:09 +0000 Subject: [PATCH] * firewire Add tcode_str[] and improve debug message. * sbp If max_speed is negative, use the maximum speed which the ohci chip supports. The default max_speed is -1. * if_fwe If tx_speed is negative, use the maximum speed which the ohci chip supports. The default tx_speed is 2. --- sys/dev/firewire/firewire.c | 43 ++++++++++++++++++++++--------------- sys/dev/firewire/if_fwe.c | 3 +++ sys/dev/firewire/sbp.c | 6 +++++- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c index 3f687e028902..f3f7b16e7a5f 100644 --- a/sys/dev/firewire/firewire.c +++ b/sys/dev/firewire/firewire.c @@ -118,7 +118,17 @@ static device_method_t firewire_methods[] = { { 0, 0 } }; -char linkspeed[7][0x10]={"S100","S200","S400","S800","S1600","S3200","Unknown"}; +char *linkspeed[] = { + "S100", "S200", "S400", "S800", + "S1600", "S3200", "undef", "undef" +}; + +static char *tcode_str[] = { + "WREQQ", "WREQB", "WRES", "undef", + "RREQQ", "RREQB", "RRESQ", "RRESB", + "CYCS", "LREQ", "STREAM", "LRES", + "undef", "undef", "PHY", "undef" +}; /* IEEE-1394a Table C-2 Gap count as a function of hops*/ #define MAX_GAPHOP 15 @@ -192,7 +202,7 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) tcode = fp->mode.common.tcode & 0xf; info = &fc->tcode[tcode]; if (info->flag == 0) { - printf("invalid tcode=%d\n", tcode); + printf("invalid tcode=%x\n", tcode); return EINVAL; } if (info->flag & FWTI_REQ) @@ -211,8 +221,8 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) else len = 0; if (len != xfer->send.pay_len){ - printf("len(%d) != send.pay_len(%d) (tcode=%d)\n", - len, xfer->send.pay_len, tcode); + printf("len(%d) != send.pay_len(%d) %s(%x)\n", + len, xfer->send.pay_len, tcode_str[tcode], tcode); return EINVAL; } @@ -1770,12 +1780,12 @@ fw_rcv(struct fw_rcv_buf *rb) fp->mode.hdr.tlrt >> 2); if(rb->xfer == NULL) { printf("fw_rcv: unknown response " - "tcode=%d src=0x%x tl=0x%x rt=%d data=0x%x\n", - tcode, - fp->mode.hdr.src, - fp->mode.hdr.tlrt >> 2, - fp->mode.hdr.tlrt & 3, - fp->mode.rresq.data); + "%s(%x) src=0x%x tl=0x%x rt=%d data=0x%x\n", + tcode_str[tcode], tcode, + fp->mode.hdr.src, + fp->mode.hdr.tlrt >> 2, + fp->mode.hdr.tlrt & 3, + fp->mode.rresq.data); #if 1 printf("try ad-hoc work around!!\n"); rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, @@ -1818,16 +1828,15 @@ fw_rcv(struct fw_rcv_buf *rb) bind = fw_bindlookup(rb->fc, fp->mode.rreqq.dest_hi, fp->mode.rreqq.dest_lo); if(bind == NULL){ + printf("Unknown service addr 0x%04x:0x%08x %s(%x)" #if __FreeBSD_version >= 500000 - printf("Unknown service addr 0x%04x:0x%08x tcode=%x src=0x%x data=%x\n", + " src=0x%x data=%x\n", #else - printf("Unknown service addr 0x%04x:0x%08x tcode=%x src=0x%x data=%lx\n", + " src=0x%x data=%lx\n", #endif - fp->mode.wreqq.dest_hi, - fp->mode.wreqq.dest_lo, - tcode, - fp->mode.hdr.src, - ntohl(fp->mode.wreqq.data)); + fp->mode.wreqq.dest_hi, fp->mode.wreqq.dest_lo, + tcode_str[tcode], tcode, + fp->mode.hdr.src, ntohl(fp->mode.wreqq.data)); if (rb->fc->status == FWBUSRESET) { printf("fw_rcv: cannot respond(bus reset)!\n"); goto err; diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index cd546df341e0..9764ec95a1e6 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -164,6 +164,9 @@ fwe_attach(device_t dev) fwe->dma_ch = -1; fwe->fd.fc = device_get_ivars(dev); + if (tx_speed < 0) + tx_speed = fwe->fd.fc->speed; + fwe->fd.dev = dev; fwe->fd.post_explore = NULL; fwe->eth_softc.fwe = fwe; diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index 12f7113a71f4..13b9aa12e79e 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -108,7 +108,7 @@ static char *orb_fun_name[] = { static int debug = 0; static int auto_login = 1; -static int max_speed = 2; +static int max_speed = -1; static int sbp_cold = 1; static int ex_login = 1; static int login_delay = 1000; /* msec */ @@ -1879,6 +1879,10 @@ END_DEBUG bzero(sbp, sizeof(struct sbp_softc)); sbp->fd.dev = dev; sbp->fd.fc = device_get_ivars(dev); + + if (max_speed < 0) + max_speed = sbp->fd.fc->speed; + error = bus_dma_tag_create(/*parent*/sbp->fd.fc->dmat, /* XXX shoud be 4 for sane backend? */ /*alignment*/1,