diff options
author | simokawa <simokawa@FreeBSD.org> | 2003-01-17 15:03:25 +0000 |
---|---|---|
committer | simokawa <simokawa@FreeBSD.org> | 2003-01-17 15:03:25 +0000 |
commit | ccf87bc3ad9fe8c73c31d077050bd258d95cd791 (patch) | |
tree | 78e93d7d403bc3ed933cc137ea720367f0b7cf8f /sys/dev/firewire/firewire.c | |
parent | 62c9659f0c00ec3a90305516c948342e3d5e8439 (diff) | |
download | FreeBSD-src-ccf87bc3ad9fe8c73c31d077050bd258d95cd791.zip FreeBSD-src-ccf87bc3ad9fe8c73c31d077050bd258d95cd791.tar.gz |
Fix bus manager election process.
- Lock response 0x3f means that the host becomes the bus manager.
- Add missing htonl().
Diffstat (limited to 'sys/dev/firewire/firewire.c')
-rw-r--r-- | sys/dev/firewire/firewire.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c index e0dbad1..2e925f6 100644 --- a/sys/dev/firewire/firewire.c +++ b/sys/dev/firewire/firewire.c @@ -1999,29 +1999,31 @@ err: static void fw_try_bmr_callback(struct fw_xfer *xfer) { - struct fw_pkt *sfp,*rfp; + struct fw_pkt *rfp; struct firewire_comm *fc; + int bmr; - if(xfer == NULL) return; + if (xfer == NULL) + return; fc = xfer->fc; - if(xfer->resp != 0){ + if (xfer->resp != 0) goto error; - } - - if(xfer->send.buf == NULL){ + if (xfer->send.buf == NULL) goto error; - } - sfp = (struct fw_pkt *)xfer->send.buf; - - if(xfer->recv.buf == NULL){ + if (xfer->recv.buf == NULL) goto error; - } rfp = (struct fw_pkt *)xfer->recv.buf; - CSRARC(fc, BUS_MGR_ID) - = fc->set_bmr(fc, ntohl(rfp->mode.lres.payload[0]) & 0x3f); + if (rfp->mode.lres.rtcode != FWRCODE_COMPLETE) + goto error; + + bmr = ntohl(rfp->mode.lres.payload[0]); + if (bmr == 0x3f) + bmr = fc->nodeid; + + CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, bmr & 0x3f); device_printf(fc->bdev, "new bus manager %d ", CSRARC(fc, BUS_MGR_ID)); - if((htonl(rfp->mode.lres.payload[0]) & 0x3f) == fc->nodeid){ + if(bmr == fc->nodeid){ printf("(me)\n"); /* If I am bus manager, optimize gapcount */ if(fc->max_hop <= MAX_GAPHOP ){ @@ -2071,8 +2073,8 @@ fw_try_bmr(void *arg) xfer->dst = FWLOCALBUS | fc->irm; fp->mode.lreq.dst = htons(xfer->dst); fp->mode.lreq.dest_lo = htonl(0xf0000000 | BUS_MGR_ID); - fp->mode.lreq.payload[0] = 0x3f; - fp->mode.lreq.payload[1] = fc->nodeid; + fp->mode.lreq.payload[0] = htonl(0x3f); + fp->mode.lreq.payload[1] = htonl(fc->nodeid); xfer->act_type = FWACT_XFER; xfer->act.hand = fw_try_bmr_callback; |