Lines Matching +full:s +full:- +full:mode
1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
5 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
130 /* IEEE-1394a Table C-2 Gap count as a function of hops*/
150 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_nodeid()
151 if (fwdev->dst == dst && fwdev->status != FWDEVINVAL) in fw_noderesolve_nodeid()
167 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_eui64()
168 if (FW_EUI64_EQUAL(fwdev->eui, *eui)) in fw_noderesolve_eui64()
174 if (fwdev->status == FWDEVINVAL) in fw_noderesolve_eui64()
194 if (xfer->hand == NULL) { in fw_asyreq()
198 fp = &xfer->send.hdr; in fw_asyreq()
200 tcode = fp->mode.common.tcode & 0xf; in fw_asyreq()
201 info = &fc->tcode[tcode]; in fw_asyreq()
202 if (info->flag == 0) { in fw_asyreq()
208 if ((fc->status < FWBUSEXPLORE) && in fw_asyreq()
209 ((tcode != FWTCODE_RREQQ) || (fp->mode.rreqq.dest_hi != 0xffff) || in fw_asyreq()
210 (fp->mode.rreqq.dest_lo < 0xf0000000) || in fw_asyreq()
211 (fp->mode.rreqq.dest_lo >= 0xf0001000))) { in fw_asyreq()
212 xfer->resp = EAGAIN; in fw_asyreq()
213 xfer->flag = FWXF_BUSY; in fw_asyreq()
217 if (info->flag & FWTI_REQ) in fw_asyreq()
218 xferq = fc->atq; in fw_asyreq()
220 xferq = fc->ats; in fw_asyreq()
221 len = info->hdr_len; in fw_asyreq()
222 if (xfer->send.pay_len > MAXREC(fc->maxrec)) { in fw_asyreq()
226 if (info->flag & FWTI_BLOCK_STR) in fw_asyreq()
227 len = fp->mode.stream.len; in fw_asyreq()
228 else if (info->flag & FWTI_BLOCK_ASY) in fw_asyreq()
229 len = fp->mode.rresb.len; in fw_asyreq()
232 if (len != xfer->send.pay_len) { in fw_asyreq()
233 printf("len(%d) != send.pay_len(%d) %s(%x)\n", in fw_asyreq()
234 len, xfer->send.pay_len, tcode_str[tcode], tcode); in fw_asyreq()
238 if (xferq->start == NULL) { in fw_asyreq()
239 printf("xferq->start == NULL\n"); in fw_asyreq()
242 if (!(xferq->queued < xferq->maxq)) { in fw_asyreq()
243 device_printf(fc->bdev, "Discard a packet (queued=%d)\n", in fw_asyreq()
244 xferq->queued); in fw_asyreq()
248 xfer->tl = -1; in fw_asyreq()
249 if (info->flag & FWTI_TLABEL) { in fw_asyreq()
254 xfer->resp = 0; in fw_asyreq()
255 xfer->fc = fc; in fw_asyreq()
256 xfer->q = xferq; in fw_asyreq()
268 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwake()
271 xfer->flag |= FWXF_WAKE; in fw_xferwake()
281 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwait()
285 while ((xfer->flag & FWXF_WAKE) == 0) in fw_xferwait()
298 struct firewire_comm *fc = xfer->fc; in fw_asystart()
302 xfer->flag = FWXF_INQ; in fw_asystart()
303 STAILQ_INSERT_TAIL(&xfer->q->q, xfer, link); in fw_asystart()
305 xfer->q->queued++; in fw_asystart()
309 if (xfer->mbuf == NULL) in fw_asystart()
310 xfer->q->start(fc); in fw_asystart()
327 /* Just use a per-packet callout? */
345 mtx_lock(&fc->tlabel_lock); in firewire_xfer_timeout()
346 for (i = 0; i < nitems(fc->tlabels); i++) { in firewire_xfer_timeout()
347 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { in firewire_xfer_timeout()
348 if ((xfer->flag & FWXF_SENT) == 0) in firewire_xfer_timeout()
351 if (timevalcmp(&xfer->tv, &tv, >)) in firewire_xfer_timeout()
354 device_printf(fc->bdev, in firewire_xfer_timeout()
356 i, xfer->flag); in firewire_xfer_timeout()
357 fw_dump_hdr(&xfer->send.hdr, "send"); in firewire_xfer_timeout()
358 xfer->resp = ETIMEDOUT; in firewire_xfer_timeout()
359 xfer->tl = -1; in firewire_xfer_timeout()
360 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel); in firewire_xfer_timeout()
364 mtx_unlock(&fc->tlabel_lock); in firewire_xfer_timeout()
365 fc->timeout(fc); in firewire_xfer_timeout()
368 xfer->hand(xfer); in firewire_xfer_timeout()
386 taskqueue_enqueue(fc->taskqueue, &fc->task_timeout); in firewire_watchdog()
390 callout_reset(&fc->timeout_callout, hz / WATCHDOG_HZ, in firewire_watchdog()
406 sc->fc = fc; in firewire_attach()
407 fc->status = FWBUSNOTREADY; in firewire_attach()
410 if (fc->nisodma > FWMAXNDMA) in firewire_attach()
411 fc->nisodma = FWMAXNDMA; in firewire_attach()
415 fc->crom_src_buf = malloc(sizeof(struct crom_src_buf), in firewire_attach()
417 if (fc->crom_src_buf == NULL) { in firewire_attach()
418 device_printf(fc->dev, in firewire_attach()
419 "%s: unable to allocate crom src buffer\n", __func__); in firewire_attach()
422 fc->topology_map = malloc(sizeof(struct fw_topology_map), in firewire_attach()
424 if (fc->topology_map == NULL) { in firewire_attach()
425 device_printf(fc->dev, "%s: unable to allocate topology map\n", in firewire_attach()
427 free(fc->crom_src_buf, M_FW); in firewire_attach()
430 fc->speed_map = malloc(sizeof(struct fw_speed_map), in firewire_attach()
432 if (fc->speed_map == NULL) { in firewire_attach()
433 device_printf(fc->dev, "%s: unable to allocate speed map\n", in firewire_attach()
435 free(fc->crom_src_buf, M_FW); in firewire_attach()
436 free(fc->topology_map, M_FW); in firewire_attach()
440 mtx_init(&fc->wait_lock, "fwwait", NULL, MTX_DEF); in firewire_attach()
441 mtx_init(&fc->tlabel_lock, "fwtlabel", NULL, MTX_DEF); in firewire_attach()
442 CALLOUT_INIT(&fc->timeout_callout); in firewire_attach()
443 CALLOUT_INIT(&fc->bmr_callout); in firewire_attach()
444 CALLOUT_INIT(&fc->busprobe_callout); in firewire_attach()
445 TASK_INIT(&fc->task_timeout, 0, firewire_xfer_timeout, fc); in firewire_attach()
447 callout_reset(&sc->fc->timeout_callout, hz, in firewire_attach()
448 firewire_watchdog, sc->fc); in firewire_attach()
451 kproc_create(fw_bus_probe_thread, fc, &fc->probe_thread, in firewire_attach()
464 fc->ibr(fc); in firewire_attach()
481 device_set_ivars(child, sc->fc); in firewire_add_child()
494 sc->fc->status = FWBUSNOTREADY; in firewire_resume()
513 fc = sc->fc; in firewire_detach()
514 mtx_lock(&fc->wait_lock); in firewire_detach()
515 fc->status = FWBUSDETACH; in firewire_detach()
517 if (msleep(fc->probe_thread, &fc->wait_lock, PWAIT, "fwthr", hz * 60)) in firewire_detach()
519 mtx_unlock(&fc->wait_lock); in firewire_detach()
521 if (fc->arq != 0 && fc->arq->maxq > 0) in firewire_detach()
530 callout_stop(&fc->timeout_callout); in firewire_detach()
531 callout_stop(&fc->bmr_callout); in firewire_detach()
532 callout_stop(&fc->busprobe_callout); in firewire_detach()
535 for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; in firewire_detach()
540 free(fc->topology_map, M_FW); in firewire_detach()
541 free(fc->speed_map, M_FW); in firewire_detach()
542 free(fc->crom_src_buf, M_FW); in firewire_detach()
544 mtx_destroy(&fc->tlabel_lock); in firewire_detach()
545 mtx_destroy(&fc->wait_lock); in firewire_detach()
554 while ((xfer = STAILQ_FIRST(&xferq->q)) != NULL) { in fw_xferq_drain()
555 STAILQ_REMOVE_HEAD(&xferq->q, link); in fw_xferq_drain()
557 xferq->queued--; in fw_xferq_drain()
559 xfer->resp = EAGAIN; in fw_xferq_drain()
560 xfer->flag = FWXF_SENTERR; in fw_xferq_drain()
575 fw_xferq_drain(fc->atq); in fw_drain_txq()
576 fw_xferq_drain(fc->ats); in fw_drain_txq()
577 for (i = 0; i < fc->nisodma; i++) in fw_drain_txq()
578 fw_xferq_drain(fc->it[i]); in fw_drain_txq()
581 mtx_lock(&fc->tlabel_lock); in fw_drain_txq()
583 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { in fw_drain_txq()
585 printf("tl=%d flag=%d\n", i, xfer->flag); in fw_drain_txq()
586 xfer->tl = -1; in fw_drain_txq()
587 xfer->resp = EAGAIN; in fw_drain_txq()
588 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel); in fw_drain_txq()
591 mtx_unlock(&fc->tlabel_lock); in fw_drain_txq()
594 xfer->hand(xfer); in fw_drain_txq()
608 fc->irm = -1; in fw_reset_csr()
610 fc->max_node = -1; in fw_reset_csr()
612 for (i = 2; i < 0x100 / 4 - 2; i++) { in fw_reset_csr()
647 src = &fc->crom_src_buf->src; in fw_init_crom()
651 src->hdr.info_len = 4; in fw_init_crom()
653 src->businfo.bus_name = CSR_BUS_NAME_IEEE1394; in fw_init_crom()
655 src->businfo.irmc = 1; in fw_init_crom()
656 src->businfo.cmc = 1; in fw_init_crom()
657 src->businfo.isc = 1; in fw_init_crom()
658 src->businfo.bmc = 1; in fw_init_crom()
659 src->businfo.pmc = 0; in fw_init_crom()
660 src->businfo.cyc_clk_acc = 100; in fw_init_crom()
661 src->businfo.max_rec = fc->maxrec; in fw_init_crom()
662 src->businfo.max_rom = MAXROM_4; in fw_init_crom()
664 src->businfo.generation = FW_GENERATION_CHANGEABLE; in fw_init_crom()
665 src->businfo.link_spd = fc->speed; in fw_init_crom()
667 src->businfo.eui64.hi = fc->eui.hi; in fw_init_crom()
668 src->businfo.eui64.lo = fc->eui.lo; in fw_init_crom()
670 STAILQ_INIT(&src->chunk_list); in fw_init_crom()
672 fc->crom_src = src; in fw_init_crom()
673 fc->crom_root = &fc->crom_src_buf->root; in fw_init_crom()
683 buf = fc->crom_src_buf; in fw_reset_crom()
684 src = fc->crom_src; in fw_reset_crom()
685 root = fc->crom_root; in fw_reset_crom()
687 STAILQ_INIT(&src->chunk_list); in fw_reset_crom()
694 crom_add_simple_text(src, root, &buf->vendor, "FreeBSD Project"); in fw_reset_crom()
697 crom_add_simple_text(src, root, &buf->hw, prison0.pr_hostname); in fw_reset_crom()
714 if (fc->status == FWBUSMGRELECT) in fw_busreset()
715 callout_stop(&fc->bmr_callout); in fw_busreset()
717 fc->status = new_status; in fw_busreset()
720 if (fc->status == FWBUSNOTREADY) in fw_busreset()
725 if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { in fw_busreset()
729 if (fdc->post_busreset != NULL) in fw_busreset()
730 fdc->post_busreset(fdc); in fw_busreset()
735 src = &fc->crom_src_buf->src; in fw_busreset()
740 * See 1394a-2000 8.3.2.5.4 for more details. in fw_busreset()
745 * that is not 1394a-2000 compliant. in fw_busreset()
747 * does not change it's Bus Info Block or in fw_busreset()
752 src = &fc->crom_src_buf->src; in fw_busreset()
754 if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) { in fw_busreset()
756 src->businfo.generation++; in fw_busreset()
759 if (src->businfo.generation < FW_GENERATION_CHANGEABLE) in fw_busreset()
760 src->businfo.generation = FW_GENERATION_CHANGEABLE; in fw_busreset()
764 bcopy(newrom, fc->config_rom, CROMSIZE); in fw_busreset()
778 fc->arq->queued = 0; in fw_init()
779 fc->ars->queued = 0; in fw_init()
780 fc->atq->queued = 0; in fw_init()
781 fc->ats->queued = 0; in fw_init()
783 fc->arq->buf = NULL; in fw_init()
784 fc->ars->buf = NULL; in fw_init()
785 fc->atq->buf = NULL; in fw_init()
786 fc->ats->buf = NULL; in fw_init()
788 fc->arq->flag = 0; in fw_init()
789 fc->ars->flag = 0; in fw_init()
790 fc->atq->flag = 0; in fw_init()
791 fc->ats->flag = 0; in fw_init()
793 STAILQ_INIT(&fc->atq->q); in fw_init()
794 STAILQ_INIT(&fc->ats->q); in fw_init()
796 for (i = 0; i < fc->nisodma; i++) { in fw_init()
797 fc->it[i]->queued = 0; in fw_init()
798 fc->ir[i]->queued = 0; in fw_init()
800 fc->it[i]->start = NULL; in fw_init()
801 fc->ir[i]->start = NULL; in fw_init()
803 fc->it[i]->buf = NULL; in fw_init()
804 fc->ir[i]->buf = NULL; in fw_init()
806 fc->it[i]->flag = FWXFERQ_STREAM; in fw_init()
807 fc->ir[i]->flag = FWXFERQ_STREAM; in fw_init()
809 STAILQ_INIT(&fc->it[i]->q); in fw_init()
810 STAILQ_INIT(&fc->ir[i]->q); in fw_init()
813 fc->arq->maxq = FWMAXQUEUE; in fw_init()
814 fc->ars->maxq = FWMAXQUEUE; in fw_init()
815 fc->atq->maxq = FWMAXQUEUE; in fw_init()
816 fc->ats->maxq = FWMAXQUEUE; in fw_init()
818 for (i = 0; i < fc->nisodma; i++) { in fw_init()
819 fc->ir[i]->maxq = FWMAXQUEUE; in fw_init()
820 fc->it[i]->maxq = FWMAXQUEUE; in fw_init()
828 STAILQ_INIT(&fc->devices); in fw_init()
831 STAILQ_INIT(&fc->binds); in fw_init()
833 STAILQ_INIT(&fc->tlabels[i]); in fw_init()
851 fc->crom_src_buf = NULL; in fw_init()
863 xfer->hand = fw_vmaccess; in fw_init()
864 xfer->fc = fc; in fw_init()
865 xfer->sc = NULL; in fw_init()
867 fwb->start_hi = 0x2; in fw_init()
868 fwb->start_lo = 0; in fw_init()
869 fwb->addrlen = 0xffffffff; in fw_init()
870 fwb->xfer = xfer; in fw_init()
875 #define BIND_CMP(addr, fwb) (((addr) < (fwb)->start)? -1 : \
876 ((fwb)->end < (addr)) ? 1 : 0)
889 STAILQ_FOREACH(tfw, &fc->binds, fclist) in fw_bindlookup()
907 if (fwb->start > fwb->end) { in fw_bindadd()
908 printf("%s: invalid range\n", __func__); in fw_bindadd()
913 STAILQ_FOREACH(tfw, &fc->binds, fclist) { in fw_bindadd()
914 if (fwb->end < tfw->start) in fw_bindadd()
919 STAILQ_INSERT_HEAD(&fc->binds, fwb, fclist); in fw_bindadd()
920 else if (prev->end < fwb->start) in fw_bindadd()
921 STAILQ_INSERT_AFTER(&fc->binds, prev, fwb, fclist); in fw_bindadd()
923 printf("%s: bind failed\n", __func__); in fw_bindadd()
940 int s; in fw_bindremove() local
942 s = splfw(); in fw_bindremove()
944 STAILQ_FOREACH(tfw, &fc->binds, fclist) in fw_bindremove()
946 STAILQ_REMOVE(&fc->binds, fwb, fw_bind, fclist); in fw_bindremove()
950 printf("%s: no such binding\n", __func__); in fw_bindremove()
952 splx(s); in fw_bindremove()
957 for (xfer = STAILQ_FIRST(&fwb->xferlist); xfer != NULL; xfer = next) { in fw_bindremove()
961 STAILQ_INIT(&fwb->xferlist); in fw_bindremove()
965 splx(s); in fw_bindremove()
974 int i, s; in fw_xferlist_add() local
981 xfer->fc = fc; in fw_xferlist_add()
982 xfer->sc = sc; in fw_xferlist_add()
983 xfer->hand = hand; in fw_xferlist_add()
984 s = splfw(); in fw_xferlist_add()
986 splx(s); in fw_xferlist_add()
1008 printf("%s: dst=0x%02x tl=0x%02x rt=%d tcode=0x%x pri=0x%x " in fw_dump_hdr()
1010 fp->mode.hdr.dst & 0x3f, in fw_dump_hdr()
1011 fp->mode.hdr.tlrt >> 2, fp->mode.hdr.tlrt & 3, in fw_dump_hdr()
1012 fp->mode.hdr.tcode, fp->mode.hdr.pri, in fw_dump_hdr()
1013 fp->mode.hdr.src); in fw_dump_hdr()
1024 mtx_lock(&fc->tlabel_lock); in fw_tl_free()
1025 if (xfer->tl < 0) { in fw_tl_free()
1026 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1030 STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel) in fw_tl_free()
1034 printf("%s: the xfer is not in the queue " in fw_tl_free()
1036 __FUNCTION__, xfer->tl, xfer->flag); in fw_tl_free()
1037 fw_dump_hdr(&xfer->send.hdr, "send"); in fw_tl_free()
1038 fw_dump_hdr(&xfer->recv.hdr, "recv"); in fw_tl_free()
1040 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1044 STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel); in fw_tl_free()
1045 xfer->tl = -1; in fw_tl_free()
1046 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1057 int s = splfw(); in fw_tl2xfer() local
1060 mtx_lock(&fc->tlabel_lock); in fw_tl2xfer()
1061 STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel) in fw_tl2xfer()
1062 if (xfer->send.hdr.mode.hdr.dst == node) { in fw_tl2xfer()
1063 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1064 splx(s); in fw_tl2xfer()
1065 KASSERT(xfer->tl == tlabel, in fw_tl2xfer()
1066 ("xfer->tl 0x%x != 0x%x", xfer->tl, tlabel)); in fw_tl2xfer()
1068 req = xfer->send.hdr.mode.hdr.tcode; in fw_tl2xfer()
1069 if (xfer->fc->tcode[req].valid_res != tcode) { in fw_tl2xfer()
1070 printf("%s: invalid response tcode " in fw_tl2xfer()
1080 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1083 splx(s); in fw_tl2xfer()
1099 xfer->malloc = type; in fw_xfer_alloc()
1100 xfer->tl = -1; in fw_xfer_alloc()
1113 xfer->send.pay_len = send_len; in fw_xfer_alloc_buf()
1114 xfer->recv.pay_len = recv_len; in fw_xfer_alloc_buf()
1116 xfer->send.payload = malloc(send_len, type, M_NOWAIT | M_ZERO); in fw_xfer_alloc_buf()
1117 if (xfer->send.payload == NULL) { in fw_xfer_alloc_buf()
1123 xfer->recv.payload = malloc(recv_len, type, M_NOWAIT); in fw_xfer_alloc_buf()
1124 if (xfer->recv.payload == NULL) { in fw_xfer_alloc_buf()
1125 if (xfer->send.payload != NULL) in fw_xfer_alloc_buf()
1126 free(xfer->send.payload, type); in fw_xfer_alloc_buf()
1140 if (xfer->hand == NULL) { in fw_xfer_done()
1145 if (xfer->fc == NULL) in fw_xfer_done()
1146 panic("fw_xfer_done: why xfer->fc is NULL?"); in fw_xfer_done()
1148 fw_tl_free(xfer->fc, xfer); in fw_xfer_done()
1149 xfer->hand(xfer); in fw_xfer_done()
1159 if (xfer->fc != NULL) { in fw_xfer_unload()
1160 FW_GLOCK(xfer->fc); in fw_xfer_unload()
1161 if (xfer->flag & FWXF_INQ) { in fw_xfer_unload()
1162 STAILQ_REMOVE(&xfer->q->q, xfer, fw_xfer, link); in fw_xfer_unload()
1163 xfer->flag &= ~FWXF_INQ; in fw_xfer_unload()
1165 xfer->q->queued--; in fw_xfer_unload()
1168 FW_GUNLOCK(xfer->fc); in fw_xfer_unload()
1172 * xfer after it's freed. in fw_xfer_unload()
1174 fw_tl_free(xfer->fc, xfer); in fw_xfer_unload()
1176 if (xfer->flag & FWXF_START) in fw_xfer_unload()
1185 xfer->flag = FWXF_INIT; in fw_xfer_unload()
1186 xfer->resp = 0; in fw_xfer_unload()
1196 printf("%s: xfer == NULL\n", __func__); in fw_xfer_free_buf()
1200 if (xfer->send.payload != NULL) in fw_xfer_free_buf()
1201 free(xfer->send.payload, xfer->malloc); in fw_xfer_free_buf()
1202 if (xfer->recv.payload != NULL) in fw_xfer_free_buf()
1203 free(xfer->recv.payload, xfer->malloc); in fw_xfer_free_buf()
1204 free(xfer, xfer->malloc); in fw_xfer_free_buf()
1211 printf("%s: xfer == NULL\n", __func__); in fw_xfer_free()
1215 free(xfer, xfer->malloc); in fw_xfer_free()
1223 xfer->flag, xfer->resp); in fw_asy_callback_free()
1237 fc->status = FWBUSPHYCONF; in fw_phy_config()
1242 xfer->fc = fc; in fw_phy_config()
1243 xfer->hand = fw_asy_callback_free; in fw_phy_config()
1245 fp = &xfer->send.hdr; in fw_phy_config()
1246 fp->mode.ld[1] = 0; in fw_phy_config()
1248 fp->mode.ld[1] |= (1 << 23) | (root_node & 0x3f) << 24; in fw_phy_config()
1250 fp->mode.ld[1] |= (1 << 22) | (gap_count & 0x3f) << 16; in fw_phy_config()
1251 fp->mode.ld[2] = ~fp->mode.ld[1]; in fw_phy_config()
1253 fp->mode.common.tcode |= FWTCODE_PHY; in fw_phy_config()
1256 device_printf(fc->bdev, "%s: root_node=%d gap_count=%d\n", in fw_phy_config()
1258 fw_asyreq(fc, -1, xfer); in fw_phy_config()
1267 union fw_self_id *s; in fw_print_sid() local
1268 s = (union fw_self_id *) &sid; in fw_print_sid()
1269 if (s->p0.sequel) { in fw_print_sid()
1270 if (s->p1.sequence_num == FW_SELF_ID_PAGE0) { in fw_print_sid()
1273 s->p1.phy_id, s->p1.port3, s->p1.port4, in fw_print_sid()
1274 s->p1.port5, s->p1.port6, s->p1.port7, in fw_print_sid()
1275 s->p1.port8, s->p1.port9, s->p1.port10); in fw_print_sid()
1276 } else if (s->p2.sequence_num == FW_SELF_ID_PAGE1) { in fw_print_sid()
1278 s->p2.phy_id, s->p2.port11, s->p2.port12, in fw_print_sid()
1279 s->p2.port13, s->p2.port14, s->p2.port15); in fw_print_sid()
1282 s->p1.phy_id, s->p1.sequence_num); in fw_print_sid()
1287 s->p0.phy_id, s->p0.link_active, s->p0.gap_count, in fw_print_sid()
1288 s->p0.phy_speed, s->p0.contender, in fw_print_sid()
1289 s->p0.power_class, s->p0.port0, s->p0.port1, in fw_print_sid()
1290 s->p0.port2, s->p0.initiated_reset, s->p0.more_packets); in fw_print_sid()
1303 fc->sid_cnt = len / (sizeof(uint32_t) * 2); in fw_sidrcv()
1304 fc->max_node = fc->nodeid & 0x3f; in fw_sidrcv()
1305 CSRARC(fc, NODE_IDS) = ((uint32_t)fc->nodeid) << 16; in fw_sidrcv()
1306 fc->status = FWBUSCYMELECT; in fw_sidrcv()
1307 fc->topology_map->crc_len = 2; in fw_sidrcv()
1308 fc->topology_map->generation++; in fw_sidrcv()
1309 fc->topology_map->self_id_count = 0; in fw_sidrcv()
1310 fc->topology_map->node_count= 0; in fw_sidrcv()
1311 fc->speed_map->generation++; in fw_sidrcv()
1312 fc->speed_map->crc_len = 1 + (64 * 64 + 3) / 4; in fw_sidrcv()
1313 self_id = &fc->topology_map->self_id[0]; in fw_sidrcv()
1314 for (i = 0; i < fc->sid_cnt; i++) { in fw_sidrcv()
1316 device_printf(fc->bdev, in fw_sidrcv()
1317 "%s: ERROR invalid self-id packet\n", __func__); in fw_sidrcv()
1322 fc->topology_map->crc_len++; in fw_sidrcv()
1323 if (self_id->p0.sequel == 0) { in fw_sidrcv()
1324 fc->topology_map->node_count++; in fw_sidrcv()
1328 node = self_id->p0.phy_id; in fw_sidrcv()
1329 if (fc->max_node < node) in fw_sidrcv()
1330 fc->max_node = self_id->p0.phy_id; in fw_sidrcv()
1332 fc->speed_map->speed[node][node] = in fw_sidrcv()
1333 self_id->p0.phy_speed; in fw_sidrcv()
1335 fc->speed_map->speed[j][node] = in fw_sidrcv()
1336 fc->speed_map->speed[node][j] = in fw_sidrcv()
1337 min(fc->speed_map->speed[j][j], in fw_sidrcv()
1338 self_id->p0.phy_speed); in fw_sidrcv()
1340 if ((fc->irm == -1 || self_id->p0.phy_id > fc->irm) && in fw_sidrcv()
1341 (self_id->p0.link_active && self_id->p0.contender)) in fw_sidrcv()
1342 fc->irm = self_id->p0.phy_id; in fw_sidrcv()
1343 if (self_id->p0.port0 >= 0x2) in fw_sidrcv()
1345 if (self_id->p0.port1 >= 0x2) in fw_sidrcv()
1347 if (self_id->p0.port2 >= 0x2) in fw_sidrcv()
1351 i_branch += (c_port - 2); in fw_sidrcv()
1354 fc->topology_map->self_id_count++; in fw_sidrcv()
1357 fc->topology_map->crc = fw_crc16( in fw_sidrcv()
1358 (uint32_t *)&fc->topology_map->generation, in fw_sidrcv()
1359 fc->topology_map->crc_len * 4); in fw_sidrcv()
1360 fc->speed_map->crc = fw_crc16( in fw_sidrcv()
1361 (uint32_t *)&fc->speed_map->generation, in fw_sidrcv()
1362 fc->speed_map->crc_len * 4); in fw_sidrcv()
1364 p = (uint32_t *)fc->topology_map; in fw_sidrcv()
1365 for (i = 0; i <= fc->topology_map->crc_len; i++) in fw_sidrcv()
1367 p = (uint32_t *)fc->speed_map; in fw_sidrcv()
1370 /* don't byte-swap uint8_t array */ in fw_sidrcv()
1371 bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1) * 4); in fw_sidrcv()
1373 fc->max_hop = fc->max_node - i_branch; in fw_sidrcv()
1374 device_printf(fc->bdev, "%d nodes, maxhop <= %d %s irm(%d) %s\n", in fw_sidrcv()
1375 fc->max_node + 1, fc->max_hop, in fw_sidrcv()
1376 (fc->irm == -1) ? "Not IRM capable" : "cable IRM", in fw_sidrcv()
1377 fc->irm, (fc->irm == fc->nodeid) ? " (me) " : ""); in fw_sidrcv()
1379 if (try_bmr && (fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) { in fw_sidrcv()
1380 if (fc->irm == fc->nodeid) { in fw_sidrcv()
1381 fc->status = FWBUSMGRDONE; in fw_sidrcv()
1382 CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, fc->irm); in fw_sidrcv()
1385 fc->status = FWBUSMGRELECT; in fw_sidrcv()
1386 callout_reset(&fc->bmr_callout, hz / 8, in fw_sidrcv()
1390 fc->status = FWBUSMGRDONE; in fw_sidrcv()
1392 callout_reset(&fc->busprobe_callout, hz / 4, fw_bus_probe, fc); in fw_sidrcv()
1403 int s; in fw_bus_probe() local
1405 s = splfw(); in fw_bus_probe()
1407 fc->status = FWBUSEXPLORE; in fw_bus_probe()
1411 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1414 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_bus_probe()
1415 if (fwdev->status != FWDEVINVAL) { in fw_bus_probe()
1416 fwdev->status = FWDEVINVAL; in fw_bus_probe()
1417 fwdev->rcnt = 0; in fw_bus_probe()
1419 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1421 __func__, fwdev->eui.hi, fwdev->eui.lo); in fw_bus_probe()
1424 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1426 __func__, fwdev->eui.hi, fwdev->eui.lo); in fw_bus_probe()
1428 splx(s); in fw_bus_probe()
1442 xfer = fwmem_read_quad(fwdev, NULL, -1, 0xffff, in fw_explore_read_quads()
1445 return (-1); in fw_explore_read_quads()
1448 if (xfer->resp == 0) in fw_explore_read_quads()
1451 error = xfer->resp; in fw_explore_read_quads()
1467 dir = (struct csrdirectory *)&fwdev->csrrom[offset / sizeof(uint32_t)]; in fw_explore_csrblock()
1471 return (-1); in fw_explore_csrblock()
1474 reg = (struct csrreg *)&fwdev->csrrom[offset / sizeof(uint32_t)]; in fw_explore_csrblock()
1476 (uint32_t *)reg, dir->crc_len); in fw_explore_csrblock()
1478 return (-1); in fw_explore_csrblock()
1482 off = CSRROMOFF + offset + sizeof(uint32_t) * (dir->crc_len - 1); in fw_explore_csrblock()
1483 if (fwdev->rommax < off) in fw_explore_csrblock()
1484 fwdev->rommax = off; in fw_explore_csrblock()
1489 for (i = 0; i < dir->crc_len; i++, offset += sizeof(uint32_t)) { in fw_explore_csrblock()
1499 printf("%s: invalid offset %d\n", __FUNCTION__, off); in fw_explore_csrblock()
1500 return (-1); in fw_explore_csrblock()
1504 return (-1); in fw_explore_csrblock()
1520 fc = dfwdev->fc; in fw_explore_node()
1521 csr = dfwdev->csrrom; in fw_explore_node()
1522 node = dfwdev->dst; in fw_explore_node()
1527 dfwdev->status = FWDEVINVAL; in fw_explore_node()
1528 return (-1); in fw_explore_node()
1531 if (hdr->info_len != 4) { in fw_explore_node()
1533 device_printf(fc->bdev, in fw_explore_node()
1534 "%s: node%d: wrong bus info len(%d)\n", in fw_explore_node()
1535 __func__, node, hdr->info_len); in fw_explore_node()
1536 dfwdev->status = FWDEVINVAL; in fw_explore_node()
1537 return (-1); in fw_explore_node()
1543 dfwdev->status = FWDEVINVAL; in fw_explore_node()
1544 return (-1); in fw_explore_node()
1547 if (binfo->bus_name != CSR_BUS_NAME_IEEE1394) { in fw_explore_node()
1548 dfwdev->status = FWDEVINVAL; in fw_explore_node()
1549 return (-1); in fw_explore_node()
1553 device_printf(fc->bdev, "%s: node(%d) BUS INFO BLOCK:\n" in fw_explore_node()
1558 binfo->irmc, binfo->cmc, binfo->isc, in fw_explore_node()
1559 binfo->bmc, binfo->pmc, binfo->cyc_clk_acc, in fw_explore_node()
1560 binfo->max_rec, binfo->max_rom, in fw_explore_node()
1561 binfo->generation, binfo->link_spd); in fw_explore_node()
1563 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_explore_node()
1564 if (FW_EUI64_EQUAL(fwdev->eui, binfo->eui64)) in fw_explore_node()
1571 device_printf(fc->bdev, "%s: node%d: no memory\n", in fw_explore_node()
1573 return (-1); in fw_explore_node()
1575 fwdev->fc = fc; in fw_explore_node()
1576 fwdev->eui = binfo->eui64; in fw_explore_node()
1577 fwdev->dst = dfwdev->dst; in fw_explore_node()
1578 fwdev->maxrec = dfwdev->maxrec; in fw_explore_node()
1579 fwdev->status = dfwdev->status; in fw_explore_node()
1582 * Pre-1394a-2000 didn't have link_spd in in fw_explore_node()
1585 * 1394a-2000 compliant devices only use in fw_explore_node()
1589 if (binfo->link_spd == FWSPD_S100 /* 0 */) { in fw_explore_node()
1590 device_printf(fc->bdev, "%s: " in fw_explore_node()
1591 "Pre 1394a-2000 detected\n", __func__); in fw_explore_node()
1592 fwdev->speed = fc->speed_map->speed[fc->nodeid][node]; in fw_explore_node()
1594 fwdev->speed = binfo->link_spd; in fw_explore_node()
1599 while (fwdev->speed > FWSPD_S100 /* 0 */) { in fw_explore_node()
1603 device_printf(fc->bdev, in fw_explore_node()
1604 "%s: fwdev->speed(%s) decremented due to negotiation\n", in fw_explore_node()
1605 __func__, linkspeed[fwdev->speed]); in fw_explore_node()
1606 fwdev->speed--; in fw_explore_node()
1614 * fc->devices TAILQ, then we will add it. in fw_explore_node()
1617 STAILQ_FOREACH(tfwdev, &fc->devices, link) { in fw_explore_node()
1618 if (tfwdev->eui.hi > fwdev->eui.hi || in fw_explore_node()
1619 (tfwdev->eui.hi == fwdev->eui.hi && in fw_explore_node()
1620 tfwdev->eui.lo > fwdev->eui.lo)) in fw_explore_node()
1625 STAILQ_INSERT_HEAD(&fc->devices, fwdev, link); in fw_explore_node()
1627 STAILQ_INSERT_AFTER(&fc->devices, pfwdev, fwdev, link); in fw_explore_node()
1629 fwdev->dst = node; in fw_explore_node()
1630 fwdev->status = FWDEVINIT; in fw_explore_node()
1632 if (bcmp(&csr[0], &fwdev->csrrom[0], sizeof(uint32_t) * 5) == 0) { in fw_explore_node()
1634 device_printf(fc->dev, in fw_explore_node()
1640 bzero(&fwdev->csrrom[0], CROMSIZE); in fw_explore_node()
1643 bcopy(&csr[0], &fwdev->csrrom[0], sizeof(uint32_t) * 5); in fw_explore_node()
1644 fwdev->rommax = CSRROMOFF + sizeof(uint32_t) * 4; in fw_explore_node()
1650 device_printf(fc->dev, "%s: explore csrblock failed err(%d)\n", in fw_explore_node()
1652 fwdev->status = FWDEVINVAL; in fw_explore_node()
1653 fwdev->csrrom[0] = 0; in fw_explore_node()
1666 union fw_self_id *s; in fw_find_self_id() local
1668 for (i = 0; i < fc->topology_map->self_id_count; i++) { in fw_find_self_id()
1669 s = &fc->topology_map->self_id[i]; in fw_find_self_id()
1670 if (s->p0.sequel) in fw_find_self_id()
1672 if (s->p0.phy_id == node) in fw_find_self_id()
1673 return s; in fw_find_self_id()
1681 int node, err, s, i, todo, todo2, trys; in fw_explore() local
1693 for (node = 0; node <= fc->max_node; node++) { in fw_explore()
1695 if (node == fc->nodeid) { in fw_explore()
1697 device_printf(fc->bdev, "%s:" in fw_explore()
1698 "found myself node(%d) fc->nodeid(%d) fc->max_node(%d)\n", in fw_explore()
1699 __func__, node, fc->nodeid, fc->max_node); in fw_explore()
1702 device_printf(fc->bdev, "%s:" in fw_explore()
1703 "node(%d) fc->max_node(%d) found\n", in fw_explore()
1704 __func__, node, fc->max_node); in fw_explore()
1707 if (!fwsid || !fwsid->p0.link_active) { in fw_explore()
1709 device_printf(fc->bdev, in fw_explore()
1710 "%s: node%d: link down\n", in fw_explore()
1717 s = splfw(); in fw_explore()
1726 device_printf(fc->bdev, in fw_explore()
1727 "%s: node %d, err = %d\n", in fw_explore()
1732 splx(s); in fw_explore()
1742 mtx_lock(&fc->wait_lock); in fw_bus_probe_thread()
1743 while (fc->status != FWBUSDETACH) { in fw_bus_probe_thread()
1744 if (fc->status == FWBUSEXPLORE) { in fw_bus_probe_thread()
1745 mtx_unlock(&fc->wait_lock); in fw_bus_probe_thread()
1747 fc->status = FWBUSEXPDONE; in fw_bus_probe_thread()
1751 mtx_lock(&fc->wait_lock); in fw_bus_probe_thread()
1753 msleep((void *)fc, &fc->wait_lock, PWAIT|PCATCH, "-", 0); in fw_bus_probe_thread()
1755 mtx_unlock(&fc->wait_lock); in fw_bus_probe_thread()
1760 * To attach sub-devices layer onto IEEE1394 bus.
1771 for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; fwdev = next) { in fw_attach_dev()
1773 if (fwdev->status == FWDEVINIT) { in fw_attach_dev()
1774 fwdev->status = FWDEVATTACHED; in fw_attach_dev()
1775 } else if (fwdev->status == FWDEVINVAL) { in fw_attach_dev()
1776 fwdev->rcnt++; in fw_attach_dev()
1778 device_printf(fc->bdev, "%s:" in fw_attach_dev()
1779 "fwdev->rcnt(%d), hold_count(%d)\n", in fw_attach_dev()
1780 __func__, fwdev->rcnt, hold_count); in fw_attach_dev()
1781 if (fwdev->rcnt > hold_count) { in fw_attach_dev()
1786 STAILQ_REMOVE(&fc->devices, fwdev, fw_device, in fw_attach_dev()
1793 err = device_get_children(fc->bdev, &devlistp, &devcnt); in fw_attach_dev()
1798 if (fdc->post_explore != NULL) in fw_attach_dev()
1799 fdc->post_explore(fdc); in fw_attach_dev()
1816 int s; in fw_get_tlabel() local
1818 dst = xfer->send.hdr.mode.hdr.dst & 0x3f; in fw_get_tlabel()
1819 s = splfw(); in fw_get_tlabel()
1820 mtx_lock(&fc->tlabel_lock); in fw_get_tlabel()
1821 new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f; in fw_get_tlabel()
1822 STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel) in fw_get_tlabel()
1823 if ((txfer->send.hdr.mode.hdr.dst & 0x3f) == dst) in fw_get_tlabel()
1826 fc->last_tlabel[dst] = new_tlabel; in fw_get_tlabel()
1827 STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel); in fw_get_tlabel()
1828 mtx_unlock(&fc->tlabel_lock); in fw_get_tlabel()
1829 splx(s); in fw_get_tlabel()
1830 xfer->tl = new_tlabel; in fw_get_tlabel()
1831 xfer->send.hdr.mode.hdr.tlrt = new_tlabel << 2; in fw_get_tlabel()
1836 mtx_unlock(&fc->tlabel_lock); in fw_get_tlabel()
1837 splx(s); in fw_get_tlabel()
1841 return (-1); in fw_get_tlabel()
1852 rb->xfer->recv.spd = rb->spd; in fw_rcv_copy()
1854 pkt = (struct fw_pkt *)rb->vec->iov_base; in fw_rcv_copy()
1855 tinfo = &rb->fc->tcode[pkt->mode.hdr.tcode]; in fw_rcv_copy()
1858 p = (u_char *)&rb->xfer->recv.hdr; in fw_rcv_copy()
1859 bcopy(rb->vec->iov_base, p, tinfo->hdr_len); in fw_rcv_copy()
1860 rb->vec->iov_base = (u_char *)rb->vec->iov_base + tinfo->hdr_len; in fw_rcv_copy()
1861 rb->vec->iov_len -= tinfo->hdr_len; in fw_rcv_copy()
1864 p = (u_char *)rb->xfer->recv.payload; in fw_rcv_copy()
1865 res = rb->xfer->recv.pay_len; in fw_rcv_copy()
1868 if (pkt->mode.hdr.tcode == FWTCODE_RRESQ && in fw_rcv_copy()
1870 *(uint32_t *)p = pkt->mode.rresq.data; in fw_rcv_copy()
1871 rb->xfer->recv.pay_len = sizeof(uint32_t); in fw_rcv_copy()
1875 if ((tinfo->flag & FWTI_BLOCK_ASY) == 0) in fw_rcv_copy()
1878 plen = pkt->mode.rresb.len; in fw_rcv_copy()
1880 for (i = 0; i < rb->nvec; i++, rb->vec++) { in fw_rcv_copy()
1881 len = MIN(rb->vec->iov_len, plen); in fw_rcv_copy()
1883 device_printf(rb->fc->bdev, "%s:" in fw_rcv_copy()
1885 __func__, rb->xfer->recv.pay_len, len - res); in fw_rcv_copy()
1888 bcopy(rb->vec->iov_base, p, len); in fw_rcv_copy()
1890 res -= len; in fw_rcv_copy()
1891 plen -= len; in fw_rcv_copy()
1895 rb->xfer->recv.pay_len -= res; in fw_rcv_copy()
1922 fp = (struct fw_pkt *)rb->vec[0].iov_base; in fw_rcv()
1923 tcode = fp->mode.common.tcode; in fw_rcv()
1929 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1930 fp->mode.hdr.tlrt >> 2, fp->mode.hdr.tcode); in fw_rcv()
1931 if (rb->xfer == NULL) { in fw_rcv()
1932 device_printf(rb->fc->bdev, "%s: unknown response " in fw_rcv()
1933 "%s(%x) src=0x%x tl=0x%x rt=%d data=0x%x\n", in fw_rcv()
1936 fp->mode.hdr.src, in fw_rcv()
1937 fp->mode.hdr.tlrt >> 2, in fw_rcv()
1938 fp->mode.hdr.tlrt & 3, in fw_rcv()
1939 fp->mode.rresq.data); in fw_rcv()
1941 printf("try ad-hoc work around!!\n"); in fw_rcv()
1942 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1943 (fp->mode.hdr.tlrt >> 2)^3); in fw_rcv()
1944 if (rb->xfer == NULL) { in fw_rcv()
1953 if (rb->xfer->recv.hdr.mode.wres.rtcode != RESP_CMP) in fw_rcv()
1954 rb->xfer->resp = EIO; in fw_rcv()
1956 rb->xfer->resp = 0; in fw_rcv()
1958 oldstate = rb->xfer->flag; in fw_rcv()
1959 rb->xfer->flag = FWXF_RCVD; in fw_rcv()
1962 fw_xfer_done(rb->xfer); in fw_rcv()
1967 printf("not sent yet tl=%x\n", rb->xfer->tl); in fw_rcv()
1971 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1973 rb->xfer->flag); in fw_rcv()
1981 bind = fw_bindlookup(rb->fc, fp->mode.rreqq.dest_hi, in fw_rcv()
1982 fp->mode.rreqq.dest_lo); in fw_rcv()
1984 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1985 "Unknown service addr 0x%04x:0x%08x %s(%x)" in fw_rcv()
1988 fp->mode.wreqq.dest_hi, in fw_rcv()
1989 fp->mode.wreqq.dest_lo, in fw_rcv()
1991 fp->mode.hdr.src, in fw_rcv()
1992 ntohl(fp->mode.wreqq.data)); in fw_rcv()
1994 if (rb->fc->status == FWBUSINIT) { in fw_rcv()
1995 device_printf(rb->fc->bdev, in fw_rcv()
1996 "%s: cannot respond(bus reset)!\n", in fw_rcv()
2000 rb->xfer = fw_xfer_alloc(M_FWXFER); in fw_rcv()
2001 if (rb->xfer == NULL) { in fw_rcv()
2004 rb->xfer->send.spd = rb->spd; in fw_rcv()
2005 rb->xfer->send.pay_len = 0; in fw_rcv()
2006 resfp = &rb->xfer->send.hdr; in fw_rcv()
2010 resfp->mode.hdr.tcode = FWTCODE_WRES; in fw_rcv()
2013 resfp->mode.hdr.tcode = FWTCODE_RRESQ; in fw_rcv()
2016 resfp->mode.hdr.tcode = FWTCODE_RRESB; in fw_rcv()
2019 resfp->mode.hdr.tcode = FWTCODE_LRES; in fw_rcv()
2022 resfp->mode.hdr.dst = fp->mode.hdr.src; in fw_rcv()
2023 resfp->mode.hdr.tlrt = fp->mode.hdr.tlrt; in fw_rcv()
2024 resfp->mode.hdr.pri = fp->mode.hdr.pri; in fw_rcv()
2025 resfp->mode.rresb.rtcode = RESP_ADDRESS_ERROR; in fw_rcv()
2026 resfp->mode.rresb.extcode = 0; in fw_rcv()
2027 resfp->mode.rresb.len = 0; in fw_rcv()
2029 rb->xfer->hand = fw_xferwake; in fw_rcv()
2031 rb->xfer->hand = fw_xfer_free; in fw_rcv()
2032 if (fw_asyreq(rb->fc, -1, rb->xfer)) in fw_rcv()
2033 fw_xfer_free(rb->xfer); in fw_rcv()
2038 for (i = 0; i < rb->nvec; i++) in fw_rcv()
2039 len += rb->vec[i].iov_len; in fw_rcv()
2041 rb->xfer = STAILQ_FIRST(&bind->xferlist); in fw_rcv()
2042 if (rb->xfer == NULL) { in fw_rcv()
2043 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
2047 STAILQ_REMOVE_HEAD(&bind->xferlist, link); in fw_rcv()
2049 rb->xfer->hand(rb->xfer); in fw_rcv()
2056 xferq = rb->fc->ir[sub]; in fw_rcv()
2061 if (xferq->queued >= xferq->maxq) { in fw_rcv()
2066 per packet mode */ in fw_rcv()
2067 rb->xfer = fw_xfer_alloc_buf(M_FWXFER, 0, /* XXX */ in fw_rcv()
2069 if (rb->xfer == NULL) in fw_rcv()
2072 s = splfw(); in fw_rcv()
2073 xferq->queued++; in fw_rcv()
2074 STAILQ_INSERT_TAIL(&xferq->q, rb->xfer, link); in fw_rcv()
2075 splx(s); in fw_rcv()
2076 sc = device_get_softc(rb->fc->bdev); in fw_rcv()
2077 if (SEL_WAITING(&xferq->rsel)) in fw_rcv()
2078 selwakeuppri(&xferq->rsel, FWPRI); in fw_rcv()
2079 if (xferq->flag & FWXFERQ_WAKEUP) { in fw_rcv()
2080 xferq->flag &= ~FWXFERQ_WAKEUP; in fw_rcv()
2083 if (xferq->flag & FWXFERQ_HANDLER) { in fw_rcv()
2084 xferq->hand(xferq); in fw_rcv()
2091 device_printf(rb->fc->bdev,"%s: unknown tcode %d\n", in fw_rcv()
2108 fc = xfer->fc; in fw_try_bmr_callback()
2109 if (xfer->resp != 0) in fw_try_bmr_callback()
2111 if (xfer->recv.payload == NULL) in fw_try_bmr_callback()
2113 if (xfer->recv.hdr.mode.lres.rtcode != FWRCODE_COMPLETE) in fw_try_bmr_callback()
2116 bmr = ntohl(xfer->recv.payload[0]); in fw_try_bmr_callback()
2118 bmr = fc->nodeid; in fw_try_bmr_callback()
2120 CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, bmr & 0x3f); in fw_try_bmr_callback()
2126 device_printf(fc->bdev, "bus manager election failed\n"); in fw_try_bmr_callback()
2145 xfer->send.spd = 0; in fw_try_bmr()
2146 fc->status = FWBUSMGRELECT; in fw_try_bmr()
2148 fp = &xfer->send.hdr; in fw_try_bmr()
2149 fp->mode.lreq.dest_hi = 0xffff; in fw_try_bmr()
2150 fp->mode.lreq.tlrt = 0; in fw_try_bmr()
2151 fp->mode.lreq.tcode = FWTCODE_LREQ; in fw_try_bmr()
2152 fp->mode.lreq.pri = 0; in fw_try_bmr()
2153 fp->mode.lreq.src = 0; in fw_try_bmr()
2154 fp->mode.lreq.len = 8; in fw_try_bmr()
2155 fp->mode.lreq.extcode = EXTCODE_CMP_SWAP; in fw_try_bmr()
2156 fp->mode.lreq.dst = FWLOCALBUS | fc->irm; in fw_try_bmr()
2157 fp->mode.lreq.dest_lo = 0xf0000000 | BUS_MGR_ID; in fw_try_bmr()
2158 xfer->send.payload[0] = htonl(0x3f); in fw_try_bmr()
2159 xfer->send.payload[1] = htonl(fc->nodeid); in fw_try_bmr()
2160 xfer->hand = fw_try_bmr_callback; in fw_try_bmr()
2162 err = fw_asyreq(fc, -1, xfer); in fw_try_bmr()
2179 uint32_t *ld = (uint32_t *)xfer->recv.buf; in fw_vmaccess()
2182 xfer->spd, xfer->recv.len, ntohl(ld[0]), ntohl(ld[1]), ntohl(ld[2]), in fw_vmaccess()
2186 if (xfer->resp != 0) { in fw_vmaccess()
2190 if (xfer->recv.buf == NULL) { in fw_vmaccess()
2194 rfp = (struct fw_pkt *)xfer->recv.buf; in fw_vmaccess()
2195 switch (rfp->mode.hdr.tcode) { in fw_vmaccess()
2198 xfer->send.buf = malloc(12, M_FW, M_NOWAIT); in fw_vmaccess()
2199 xfer->send.len = 12; in fw_vmaccess()
2200 sfp = (struct fw_pkt *)xfer->send.buf; in fw_vmaccess()
2201 bcopy(rfp->mode.wreqb.payload, in fw_vmaccess()
2202 (caddr_t)ntohl(rfp->mode.wreqb.dest_lo),s in fw_vmaccess()
2203 ntohs(rfp->mode.wreqb.len)); in fw_vmaccess()
2204 sfp->mode.wres.tcode = FWTCODE_WRES; in fw_vmaccess()
2205 sfp->mode.wres.rtcode = 0; in fw_vmaccess()
2208 xfer->send.buf = malloc(12, M_FW, M_NOWAIT); in fw_vmaccess()
2209 xfer->send.len = 12; in fw_vmaccess()
2210 sfp->mode.wres.tcode = FWTCODE_WRES; in fw_vmaccess()
2211 *((uint32_t *)(ntohl(rfp->mode.wreqb.dest_lo))) = in fw_vmaccess()
2212 rfp->mode.wreqq.data; in fw_vmaccess()
2213 sfp->mode.wres.rtcode = 0; in fw_vmaccess()
2216 xfer->send.buf = malloc(16 + rfp->mode.rreqb.len, in fw_vmaccess()
2218 xfer->send.len = 16 + ntohs(rfp->mode.rreqb.len); in fw_vmaccess()
2219 sfp = (struct fw_pkt *)xfer->send.buf; in fw_vmaccess()
2220 bcopy((caddr_t)ntohl(rfp->mode.rreqb.dest_lo), in fw_vmaccess()
2221 sfp->mode.rresb.payload, in fw_vmaccess()
2222 ntohs(rfp->mode.rreqb.len)); in fw_vmaccess()
2223 sfp->mode.rresb.tcode = FWTCODE_RRESB; in fw_vmaccess()
2224 sfp->mode.rresb.len = rfp->mode.rreqb.len; in fw_vmaccess()
2225 sfp->mode.rresb.rtcode = 0; in fw_vmaccess()
2226 sfp->mode.rresb.extcode = 0; in fw_vmaccess()
2229 xfer->send.buf = malloc(16, M_FW, M_NOWAIT); in fw_vmaccess()
2230 xfer->send.len = 16; in fw_vmaccess()
2231 sfp = (struct fw_pkt *)xfer->send.buf; in fw_vmaccess()
2232 sfp->mode.rresq.data = in fw_vmaccess()
2233 *(uint32_t *)(ntohl(rfp->mode.rreqq.dest_lo)); in fw_vmaccess()
2234 sfp->mode.wres.tcode = FWTCODE_RRESQ; in fw_vmaccess()
2235 sfp->mode.rresb.rtcode = 0; in fw_vmaccess()
2241 sfp->mode.hdr.dst = rfp->mode.hdr.src; in fw_vmaccess()
2242 xfer->dst = ntohs(rfp->mode.hdr.src); in fw_vmaccess()
2243 xfer->hand = fw_xfer_free; in fw_vmaccess()
2245 sfp->mode.hdr.tlrt = rfp->mode.hdr.tlrt; in fw_vmaccess()
2246 sfp->mode.hdr.pri = 0; in fw_vmaccess()
2248 fw_asyreq(xfer->fc, -1, xfer); in fw_vmaccess()
2255 * CRC16 check-sum for IEEE1394 register blocks.
2264 for (shift = 28; shift >= 0; shift -= 4) { in fw_crc16()
2288 self_id = fw_find_self_id(fc, fc->max_node); in fw_bmr()
2289 if (fc->max_node > 0) { in fw_bmr()
2291 if (self_id->p0.link_active && self_id->p0.contender) in fw_bmr()
2292 cmstr = fc->max_node; in fw_bmr()
2294 device_printf(fc->bdev, in fw_bmr()
2297 cmstr = fc->nodeid; in fw_bmr()
2301 cmstr = -1; in fw_bmr()
2303 device_printf(fc->bdev, "bus manager %d %s\n", in fw_bmr()
2305 (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) ? "(me)" : ""); in fw_bmr()
2306 if (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) { in fw_bmr()
2312 if (fc->max_hop <= MAX_GAPHOP) in fw_bmr()
2313 fw_phy_config(fc, cmstr, gap_cnt[fc->max_hop]); in fw_bmr()
2315 if (cmstr == fc->nodeid || cmstr == -1) in fw_bmr()
2340 xferqa = &fc->it[0]; in fw_open_isodma()
2342 xferqa = &fc->ir[0]; in fw_open_isodma()
2345 for (i = 0; i < fc->nisodma; i++) { in fw_open_isodma()
2347 if ((xferq->flag & FWXFERQ_OPEN) == 0) { in fw_open_isodma()
2348 xferq->flag |= FWXFERQ_OPEN; in fw_open_isodma()
2352 if (i == fc->nisodma) { in fw_open_isodma()
2354 i = -1; in fw_open_isodma()
2361 fw_modevent(module_t mode, int type, void *data) in fw_modevent() argument