Lines Matching refs:fc

146 fw_noderesolve_nodeid(struct firewire_comm *fc, int dst)  in fw_noderesolve_nodeid()  argument
150 FW_GLOCK(fc); in fw_noderesolve_nodeid()
151 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_nodeid()
154 FW_GUNLOCK(fc); in fw_noderesolve_nodeid()
163 fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 *eui) in fw_noderesolve_eui64() argument
167 FW_GLOCK(fc); in fw_noderesolve_eui64()
168 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_eui64()
171 FW_GUNLOCK(fc); in fw_noderesolve_eui64()
184 fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) in fw_asyreq() argument
202 info = &fc->tcode[tcode]; in fw_asyreq()
209 if ((fc->status < FWBUSEXPLORE) && in fw_asyreq()
219 xferq = fc->atq; in fw_asyreq()
221 xferq = fc->ats; in fw_asyreq()
223 if (xfer->send.pay_len > MAXREC(fc->maxrec)) { in fw_asyreq()
244 device_printf(fc->bdev, "Discard a packet (queued=%d)\n", in fw_asyreq()
251 if (fw_get_tlabel(fc, xfer) < 0) in fw_asyreq()
256 xfer->fc = fc; in fw_asyreq()
269 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwake()
282 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwait()
299 struct firewire_comm *fc = xfer->fc; in fw_asystart() local
302 FW_GLOCK(fc); in fw_asystart()
308 FW_GUNLOCK(fc); in fw_asystart()
311 xfer->q->start(fc); in fw_asystart()
332 struct firewire_comm *fc = (struct firewire_comm *)arg; in firewire_xfer_timeout() local
346 mtx_lock(&fc->tlabel_lock); in firewire_xfer_timeout()
347 for (i = 0; i < nitems(fc->tlabels); i++) { in firewire_xfer_timeout()
348 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { in firewire_xfer_timeout()
355 device_printf(fc->bdev, in firewire_xfer_timeout()
361 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel); in firewire_xfer_timeout()
365 mtx_unlock(&fc->tlabel_lock); in firewire_xfer_timeout()
366 fc->timeout(fc); in firewire_xfer_timeout()
376 struct firewire_comm *fc; in firewire_watchdog() local
379 fc = arg; in firewire_watchdog()
387 taskqueue_enqueue(fc->taskqueue, &fc->task_timeout); in firewire_watchdog()
391 callout_reset(&fc->timeout_callout, hz / WATCHDOG_HZ, in firewire_watchdog()
392 firewire_watchdog, fc); in firewire_watchdog()
404 struct firewire_comm *fc; in firewire_attach() local
406 fc = device_get_softc(pa); in firewire_attach()
407 sc->fc = fc; in firewire_attach()
408 fc->status = FWBUSNOTREADY; in firewire_attach()
411 if (fc->nisodma > FWMAXNDMA) in firewire_attach()
412 fc->nisodma = FWMAXNDMA; in firewire_attach()
416 fc->crom_src_buf = malloc(sizeof(struct crom_src_buf), in firewire_attach()
418 if (fc->crom_src_buf == NULL) { in firewire_attach()
419 device_printf(fc->dev, in firewire_attach()
423 fc->topology_map = malloc(sizeof(struct fw_topology_map), in firewire_attach()
425 if (fc->topology_map == NULL) { in firewire_attach()
426 device_printf(fc->dev, "%s: unable to allocate topology map\n", in firewire_attach()
428 free(fc->crom_src_buf, M_FW); in firewire_attach()
431 fc->speed_map = malloc(sizeof(struct fw_speed_map), in firewire_attach()
433 if (fc->speed_map == NULL) { in firewire_attach()
434 device_printf(fc->dev, "%s: unable to allocate speed map\n", in firewire_attach()
436 free(fc->crom_src_buf, M_FW); in firewire_attach()
437 free(fc->topology_map, M_FW); in firewire_attach()
441 mtx_init(&fc->wait_lock, "fwwait", NULL, MTX_DEF); in firewire_attach()
442 mtx_init(&fc->tlabel_lock, "fwtlabel", NULL, MTX_DEF); in firewire_attach()
443 CALLOUT_INIT(&fc->timeout_callout); in firewire_attach()
444 CALLOUT_INIT(&fc->bmr_callout); in firewire_attach()
445 CALLOUT_INIT(&fc->busprobe_callout); in firewire_attach()
446 TASK_INIT(&fc->task_timeout, 0, firewire_xfer_timeout, fc); in firewire_attach()
448 callout_reset(&sc->fc->timeout_callout, hz, in firewire_attach()
449 firewire_watchdog, sc->fc); in firewire_attach()
452 kproc_create(fw_bus_probe_thread, fc, &fc->probe_thread, in firewire_attach()
462 FW_GLOCK(fc); in firewire_attach()
463 fw_busreset(fc, FWBUSNOTREADY); in firewire_attach()
464 FW_GUNLOCK(fc); in firewire_attach()
465 fc->ibr(fc); in firewire_attach()
482 device_set_ivars(child, sc->fc); in firewire_add_child()
495 sc->fc->status = FWBUSNOTREADY; in firewire_resume()
509 struct firewire_comm *fc; in firewire_detach() local
514 fc = sc->fc; in firewire_detach()
515 mtx_lock(&fc->wait_lock); in firewire_detach()
516 fc->status = FWBUSDETACH; in firewire_detach()
517 wakeup(fc); in firewire_detach()
518 if (msleep(fc->probe_thread, &fc->wait_lock, PWAIT, "fwthr", hz * 60)) in firewire_detach()
520 mtx_unlock(&fc->wait_lock); in firewire_detach()
522 if (fc->arq != 0 && fc->arq->maxq > 0) in firewire_detach()
523 fw_drain_txq(fc); in firewire_detach()
531 callout_stop(&fc->timeout_callout); in firewire_detach()
532 callout_stop(&fc->bmr_callout); in firewire_detach()
533 callout_stop(&fc->busprobe_callout); in firewire_detach()
536 for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; in firewire_detach()
541 free(fc->topology_map, M_FW); in firewire_detach()
542 free(fc->speed_map, M_FW); in firewire_detach()
543 free(fc->crom_src_buf, M_FW); in firewire_detach()
545 mtx_destroy(&fc->tlabel_lock); in firewire_detach()
546 mtx_destroy(&fc->wait_lock); in firewire_detach()
567 fw_drain_txq(struct firewire_comm *fc) in fw_drain_txq() argument
575 FW_GLOCK(fc); in fw_drain_txq()
576 fw_xferq_drain(fc->atq); in fw_drain_txq()
577 fw_xferq_drain(fc->ats); in fw_drain_txq()
578 for (i = 0; i < fc->nisodma; i++) in fw_drain_txq()
579 fw_xferq_drain(fc->it[i]); in fw_drain_txq()
580 FW_GUNLOCK(fc); in fw_drain_txq()
582 mtx_lock(&fc->tlabel_lock); in fw_drain_txq()
584 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { in fw_drain_txq()
589 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel); in fw_drain_txq()
592 mtx_unlock(&fc->tlabel_lock); in fw_drain_txq()
599 fw_reset_csr(struct firewire_comm *fc) in fw_reset_csr() argument
603 CSRARC(fc, STATE_CLEAR) in fw_reset_csr()
605 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
606 CSRARC(fc, NODE_IDS) = 0x3f; in fw_reset_csr()
608 CSRARC(fc, TOPO_MAP + 8) = 0; in fw_reset_csr()
609 fc->irm = -1; in fw_reset_csr()
611 fc->max_node = -1; in fw_reset_csr()
614 CSRARC(fc, SPED_MAP + i * 4) = 0; in fw_reset_csr()
616 CSRARC(fc, STATE_CLEAR) = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14; in fw_reset_csr()
617 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
618 CSRARC(fc, RESET_START) = 0; in fw_reset_csr()
619 CSRARC(fc, SPLIT_TIMEOUT_HI) = 0; in fw_reset_csr()
620 CSRARC(fc, SPLIT_TIMEOUT_LO) = 800 << 19; in fw_reset_csr()
621 CSRARC(fc, CYCLE_TIME) = 0x0; in fw_reset_csr()
622 CSRARC(fc, BUS_TIME) = 0x0; in fw_reset_csr()
623 CSRARC(fc, BUS_MGR_ID) = 0x3f; in fw_reset_csr()
624 CSRARC(fc, BANDWIDTH_AV) = 4915; in fw_reset_csr()
625 CSRARC(fc, CHANNELS_AV_HI) = 0xffffffff; in fw_reset_csr()
626 CSRARC(fc, CHANNELS_AV_LO) = 0xffffffff; in fw_reset_csr()
627 CSRARC(fc, IP_CHANNELS) = (1U << 31); in fw_reset_csr()
629 CSRARC(fc, CONF_ROM) = 0x04 << 24; in fw_reset_csr()
630 CSRARC(fc, CONF_ROM + 4) = 0x31333934; /* means strings 1394 */ in fw_reset_csr()
631 CSRARC(fc, CONF_ROM + 8) = 1 << 31 | 1 << 30 | 1 << 29 | in fw_reset_csr()
633 CSRARC(fc, CONF_ROM + 0xc) = 0; in fw_reset_csr()
636 CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON; in fw_reset_csr()
637 CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON; in fw_reset_csr()
639 CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14); in fw_reset_csr()
640 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
644 fw_init_crom(struct firewire_comm *fc) in fw_init_crom() argument
648 src = &fc->crom_src_buf->src; in fw_init_crom()
662 src->businfo.max_rec = fc->maxrec; in fw_init_crom()
666 src->businfo.link_spd = fc->speed; in fw_init_crom()
668 src->businfo.eui64.hi = fc->eui.hi; in fw_init_crom()
669 src->businfo.eui64.lo = fc->eui.lo; in fw_init_crom()
673 fc->crom_src = src; in fw_init_crom()
674 fc->crom_root = &fc->crom_src_buf->root; in fw_init_crom()
678 fw_reset_crom(struct firewire_comm *fc) in fw_reset_crom() argument
684 buf = fc->crom_src_buf; in fw_reset_crom()
685 src = fc->crom_src; in fw_reset_crom()
686 root = fc->crom_root; in fw_reset_crom()
706 fw_busreset(struct firewire_comm *fc, uint32_t new_status) in fw_busreset() argument
714 FW_GLOCK_ASSERT(fc); in fw_busreset()
715 if (fc->status == FWBUSMGRELECT) in fw_busreset()
716 callout_stop(&fc->bmr_callout); in fw_busreset()
718 fc->status = new_status; in fw_busreset()
719 fw_reset_csr(fc); in fw_busreset()
721 if (fc->status == FWBUSNOTREADY) in fw_busreset()
722 fw_init_crom(fc); in fw_busreset()
724 fw_reset_crom(fc); in fw_busreset()
726 if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { in fw_busreset()
736 src = &fc->crom_src_buf->src; in fw_busreset()
753 src = &fc->crom_src_buf->src; in fw_busreset()
755 if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) { in fw_busreset()
765 bcopy(newrom, fc->config_rom, CROMSIZE); in fw_busreset()
771 void fw_init(struct firewire_comm *fc) in fw_init() argument
779 fc->arq->queued = 0; in fw_init()
780 fc->ars->queued = 0; in fw_init()
781 fc->atq->queued = 0; in fw_init()
782 fc->ats->queued = 0; in fw_init()
784 fc->arq->buf = NULL; in fw_init()
785 fc->ars->buf = NULL; in fw_init()
786 fc->atq->buf = NULL; in fw_init()
787 fc->ats->buf = NULL; in fw_init()
789 fc->arq->flag = 0; in fw_init()
790 fc->ars->flag = 0; in fw_init()
791 fc->atq->flag = 0; in fw_init()
792 fc->ats->flag = 0; in fw_init()
794 STAILQ_INIT(&fc->atq->q); in fw_init()
795 STAILQ_INIT(&fc->ats->q); in fw_init()
797 for (i = 0; i < fc->nisodma; i++) { in fw_init()
798 fc->it[i]->queued = 0; in fw_init()
799 fc->ir[i]->queued = 0; in fw_init()
801 fc->it[i]->start = NULL; in fw_init()
802 fc->ir[i]->start = NULL; in fw_init()
804 fc->it[i]->buf = NULL; in fw_init()
805 fc->ir[i]->buf = NULL; in fw_init()
807 fc->it[i]->flag = FWXFERQ_STREAM; in fw_init()
808 fc->ir[i]->flag = FWXFERQ_STREAM; in fw_init()
810 STAILQ_INIT(&fc->it[i]->q); in fw_init()
811 STAILQ_INIT(&fc->ir[i]->q); in fw_init()
814 fc->arq->maxq = FWMAXQUEUE; in fw_init()
815 fc->ars->maxq = FWMAXQUEUE; in fw_init()
816 fc->atq->maxq = FWMAXQUEUE; in fw_init()
817 fc->ats->maxq = FWMAXQUEUE; in fw_init()
819 for (i = 0; i < fc->nisodma; i++) { in fw_init()
820 fc->ir[i]->maxq = FWMAXQUEUE; in fw_init()
821 fc->it[i]->maxq = FWMAXQUEUE; in fw_init()
824 CSRARC(fc, TOPO_MAP) = 0x3f1 << 16; in fw_init()
825 CSRARC(fc, TOPO_MAP + 4) = 1; in fw_init()
826 CSRARC(fc, SPED_MAP) = 0x3f1 << 16; in fw_init()
827 CSRARC(fc, SPED_MAP + 4) = 1; in fw_init()
829 STAILQ_INIT(&fc->devices); in fw_init()
832 STAILQ_INIT(&fc->binds); in fw_init()
834 STAILQ_INIT(&fc->tlabels[i]); in fw_init()
839 CSRARC(fc, oMPR) = 0x3fff0001; /* # output channel = 1 */ in fw_init()
840 CSRARC(fc, oPCR) = 0x8000007a; in fw_init()
842 CSRARC(fc, i + oPCR) = 0x8000007a; in fw_init()
845 CSRARC(fc, iMPR) = 0x00ff0001; /* # input channel = 1 */ in fw_init()
846 CSRARC(fc, iPCR) = 0x803f0000; in fw_init()
848 CSRARC(fc, i + iPCR) = 0x0; in fw_init()
852 fc->crom_src_buf = NULL; in fw_init()
865 xfer->fc = fc; in fw_init()
872 fw_bindadd(fc, fwb); in fw_init()
883 fw_bindlookup(struct firewire_comm *fc, uint16_t dest_hi, uint32_t dest_lo) in fw_bindlookup() argument
889 FW_GLOCK(fc); in fw_bindlookup()
890 STAILQ_FOREACH(tfw, &fc->binds, fclist) in fw_bindlookup()
895 FW_GUNLOCK(fc); in fw_bindlookup()
903 fw_bindadd(struct firewire_comm *fc, struct fw_bind *fwb) in fw_bindadd() argument
913 FW_GLOCK(fc); in fw_bindadd()
914 STAILQ_FOREACH(tfw, &fc->binds, fclist) { in fw_bindadd()
920 STAILQ_INSERT_HEAD(&fc->binds, fwb, fclist); in fw_bindadd()
922 STAILQ_INSERT_AFTER(&fc->binds, prev, fwb, fclist); in fw_bindadd()
927 FW_GUNLOCK(fc); in fw_bindadd()
935 fw_bindremove(struct firewire_comm *fc, struct fw_bind *fwb) in fw_bindremove() argument
944 FW_GLOCK(fc); in fw_bindremove()
945 STAILQ_FOREACH(tfw, &fc->binds, fclist) in fw_bindremove()
947 STAILQ_REMOVE(&fc->binds, fwb, fw_bind, fclist); in fw_bindremove()
952 FW_GUNLOCK(fc); in fw_bindremove()
964 FW_GUNLOCK(fc); in fw_bindremove()
973 struct firewire_comm *fc, void *sc, void (*hand)(struct fw_xfer *)) in fw_xferlist_add() argument
982 xfer->fc = fc; in fw_xferlist_add()
1021 fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer) in fw_tl_free() argument
1025 mtx_lock(&fc->tlabel_lock); in fw_tl_free()
1027 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1031 STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel) in fw_tl_free()
1041 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1045 STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel); in fw_tl_free()
1047 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1055 fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode) in fw_tl2xfer() argument
1061 mtx_lock(&fc->tlabel_lock); in fw_tl2xfer()
1062 STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel) in fw_tl2xfer()
1064 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1070 if (xfer->fc->tcode[req].valid_res != tcode) { in fw_tl2xfer()
1081 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1146 if (xfer->fc == NULL) in fw_xfer_done()
1149 fw_tl_free(xfer->fc, xfer); in fw_xfer_done()
1160 if (xfer->fc != NULL) { in fw_xfer_unload()
1161 FW_GLOCK(xfer->fc); in fw_xfer_unload()
1169 FW_GUNLOCK(xfer->fc); in fw_xfer_unload()
1175 fw_tl_free(xfer->fc, xfer); in fw_xfer_unload()
1233 fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) in fw_phy_config() argument
1238 fc->status = FWBUSPHYCONF; in fw_phy_config()
1243 xfer->fc = fc; in fw_phy_config()
1257 device_printf(fc->bdev, "%s: root_node=%d gap_count=%d\n", in fw_phy_config()
1259 fw_asyreq(fc, -1, xfer); in fw_phy_config()
1298 void fw_sidrcv(struct firewire_comm *fc, uint32_t *sid, u_int len) in fw_sidrcv() argument
1304 fc->sid_cnt = len / (sizeof(uint32_t) * 2); in fw_sidrcv()
1305 fc->max_node = fc->nodeid & 0x3f; in fw_sidrcv()
1306 CSRARC(fc, NODE_IDS) = ((uint32_t)fc->nodeid) << 16; in fw_sidrcv()
1307 fc->status = FWBUSCYMELECT; in fw_sidrcv()
1308 fc->topology_map->crc_len = 2; in fw_sidrcv()
1309 fc->topology_map->generation++; in fw_sidrcv()
1310 fc->topology_map->self_id_count = 0; in fw_sidrcv()
1311 fc->topology_map->node_count= 0; in fw_sidrcv()
1312 fc->speed_map->generation++; in fw_sidrcv()
1313 fc->speed_map->crc_len = 1 + (64 * 64 + 3) / 4; in fw_sidrcv()
1314 self_id = &fc->topology_map->self_id[0]; in fw_sidrcv()
1315 for (i = 0; i < fc->sid_cnt; i++) { in fw_sidrcv()
1317 device_printf(fc->bdev, in fw_sidrcv()
1323 fc->topology_map->crc_len++; in fw_sidrcv()
1325 fc->topology_map->node_count++; in fw_sidrcv()
1330 if (fc->max_node < node) in fw_sidrcv()
1331 fc->max_node = self_id->p0.phy_id; in fw_sidrcv()
1333 fc->speed_map->speed[node][node] = in fw_sidrcv()
1336 fc->speed_map->speed[j][node] = in fw_sidrcv()
1337 fc->speed_map->speed[node][j] = in fw_sidrcv()
1338 min(fc->speed_map->speed[j][j], in fw_sidrcv()
1341 if ((fc->irm == -1 || self_id->p0.phy_id > fc->irm) && in fw_sidrcv()
1343 fc->irm = self_id->p0.phy_id; in fw_sidrcv()
1355 fc->topology_map->self_id_count++; in fw_sidrcv()
1358 fc->topology_map->crc = fw_crc16( in fw_sidrcv()
1359 (uint32_t *)&fc->topology_map->generation, in fw_sidrcv()
1360 fc->topology_map->crc_len * 4); in fw_sidrcv()
1361 fc->speed_map->crc = fw_crc16( in fw_sidrcv()
1362 (uint32_t *)&fc->speed_map->generation, in fw_sidrcv()
1363 fc->speed_map->crc_len * 4); in fw_sidrcv()
1365 p = (uint32_t *)fc->topology_map; in fw_sidrcv()
1366 for (i = 0; i <= fc->topology_map->crc_len; i++) in fw_sidrcv()
1367 CSRARC(fc, TOPO_MAP + i * 4) = htonl(*p++); in fw_sidrcv()
1368 p = (uint32_t *)fc->speed_map; in fw_sidrcv()
1369 CSRARC(fc, SPED_MAP) = htonl(*p++); in fw_sidrcv()
1370 CSRARC(fc, SPED_MAP + 4) = htonl(*p++); in fw_sidrcv()
1372 bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1) * 4); in fw_sidrcv()
1374 fc->max_hop = fc->max_node - i_branch; in fw_sidrcv()
1375 device_printf(fc->bdev, "%d nodes, maxhop <= %d %s irm(%d) %s\n", in fw_sidrcv()
1376 fc->max_node + 1, fc->max_hop, in fw_sidrcv()
1377 (fc->irm == -1) ? "Not IRM capable" : "cable IRM", in fw_sidrcv()
1378 fc->irm, (fc->irm == fc->nodeid) ? " (me) " : ""); in fw_sidrcv()
1380 if (try_bmr && (fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) { in fw_sidrcv()
1381 if (fc->irm == fc->nodeid) { in fw_sidrcv()
1382 fc->status = FWBUSMGRDONE; in fw_sidrcv()
1383 CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, fc->irm); in fw_sidrcv()
1384 fw_bmr(fc); in fw_sidrcv()
1386 fc->status = FWBUSMGRELECT; in fw_sidrcv()
1387 callout_reset(&fc->bmr_callout, hz / 8, in fw_sidrcv()
1388 fw_try_bmr, fc); in fw_sidrcv()
1391 fc->status = FWBUSMGRDONE; in fw_sidrcv()
1393 callout_reset(&fc->busprobe_callout, hz / 4, fw_bus_probe, fc); in fw_sidrcv()
1402 struct firewire_comm *fc; in fw_bus_probe() local
1407 fc = arg; in fw_bus_probe()
1408 fc->status = FWBUSEXPLORE; in fw_bus_probe()
1412 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1415 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_bus_probe()
1420 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1425 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1431 wakeup(fc); in fw_bus_probe()
1513 struct firewire_comm *fc; in fw_explore_node() local
1521 fc = dfwdev->fc; in fw_explore_node()
1534 device_printf(fc->bdev, in fw_explore_node()
1554 device_printf(fc->bdev, "%s: node(%d) BUS INFO BLOCK:\n" in fw_explore_node()
1564 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_explore_node()
1572 device_printf(fc->bdev, "%s: node%d: no memory\n", in fw_explore_node()
1576 fwdev->fc = fc; in fw_explore_node()
1591 device_printf(fc->bdev, "%s: " in fw_explore_node()
1593 fwdev->speed = fc->speed_map->speed[fc->nodeid][node]; in fw_explore_node()
1604 device_printf(fc->bdev, in fw_explore_node()
1618 STAILQ_FOREACH(tfwdev, &fc->devices, link) { in fw_explore_node()
1626 STAILQ_INSERT_HEAD(&fc->devices, fwdev, link); in fw_explore_node()
1628 STAILQ_INSERT_AFTER(&fc->devices, pfwdev, fwdev, link); in fw_explore_node()
1635 device_printf(fc->dev, in fw_explore_node()
1651 device_printf(fc->dev, "%s: explore csrblock failed err(%d)\n", in fw_explore_node()
1664 fw_find_self_id(struct firewire_comm *fc, int node) in fw_find_self_id() argument
1669 for (i = 0; i < fc->topology_map->self_id_count; i++) { in fw_find_self_id()
1670 s = &fc->topology_map->self_id[i]; in fw_find_self_id()
1680 fw_explore(struct firewire_comm *fc) in fw_explore() argument
1689 dfwdev.fc = fc; in fw_explore()
1694 for (node = 0; node <= fc->max_node; node++) { in fw_explore()
1696 if (node == fc->nodeid) { in fw_explore()
1698 device_printf(fc->bdev, "%s:" in fw_explore()
1700 __func__, node, fc->nodeid, fc->max_node); in fw_explore()
1703 device_printf(fc->bdev, "%s:" in fw_explore()
1705 __func__, node, fc->max_node); in fw_explore()
1707 fwsid = fw_find_self_id(fc, node); in fw_explore()
1710 device_printf(fc->bdev, in fw_explore()
1727 device_printf(fc->bdev, in fw_explore()
1739 struct firewire_comm *fc; in fw_bus_probe_thread() local
1741 fc = arg; in fw_bus_probe_thread()
1743 mtx_lock(&fc->wait_lock); in fw_bus_probe_thread()
1744 while (fc->status != FWBUSDETACH) { in fw_bus_probe_thread()
1745 if (fc->status == FWBUSEXPLORE) { in fw_bus_probe_thread()
1746 mtx_unlock(&fc->wait_lock); in fw_bus_probe_thread()
1747 fw_explore(fc); in fw_bus_probe_thread()
1748 fc->status = FWBUSEXPDONE; in fw_bus_probe_thread()
1751 fw_attach_dev(fc); in fw_bus_probe_thread()
1752 mtx_lock(&fc->wait_lock); in fw_bus_probe_thread()
1754 msleep((void *)fc, &fc->wait_lock, PWAIT|PCATCH, "-", 0); in fw_bus_probe_thread()
1756 mtx_unlock(&fc->wait_lock); in fw_bus_probe_thread()
1764 fw_attach_dev(struct firewire_comm *fc) in fw_attach_dev() argument
1772 for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; fwdev = next) { in fw_attach_dev()
1779 device_printf(fc->bdev, "%s:" in fw_attach_dev()
1787 STAILQ_REMOVE(&fc->devices, fwdev, fw_device, in fw_attach_dev()
1794 err = device_get_children(fc->bdev, &devlistp, &devcnt); in fw_attach_dev()
1813 fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) in fw_get_tlabel() argument
1821 mtx_lock(&fc->tlabel_lock); in fw_get_tlabel()
1822 new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f; in fw_get_tlabel()
1823 STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel) in fw_get_tlabel()
1827 fc->last_tlabel[dst] = new_tlabel; in fw_get_tlabel()
1828 STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel); in fw_get_tlabel()
1829 mtx_unlock(&fc->tlabel_lock); in fw_get_tlabel()
1837 mtx_unlock(&fc->tlabel_lock); in fw_get_tlabel()
1856 tinfo = &rb->fc->tcode[pkt->mode.hdr.tcode]; in fw_rcv_copy()
1884 device_printf(rb->fc->bdev, "%s:" in fw_rcv_copy()
1930 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1933 device_printf(rb->fc->bdev, "%s: unknown response " in fw_rcv()
1943 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1972 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1982 bind = fw_bindlookup(rb->fc, fp->mode.rreqq.dest_hi, in fw_rcv()
1985 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1995 if (rb->fc->status == FWBUSINIT) { in fw_rcv()
1996 device_printf(rb->fc->bdev, in fw_rcv()
2033 if (fw_asyreq(rb->fc, -1, rb->xfer)) in fw_rcv()
2044 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
2057 xferq = rb->fc->ir[sub]; in fw_rcv()
2077 sc = device_get_softc(rb->fc->bdev); in fw_rcv()
2092 device_printf(rb->fc->bdev,"%s: unknown tcode %d\n", in fw_rcv()
2104 struct firewire_comm *fc; in fw_try_bmr_callback() local
2109 fc = xfer->fc; in fw_try_bmr_callback()
2119 bmr = fc->nodeid; in fw_try_bmr_callback()
2121 CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, bmr & 0x3f); in fw_try_bmr_callback()
2123 fw_bmr(fc); in fw_try_bmr_callback()
2127 device_printf(fc->bdev, "bus manager election failed\n"); in fw_try_bmr_callback()
2139 struct firewire_comm *fc = arg; in fw_try_bmr() local
2147 fc->status = FWBUSMGRELECT; in fw_try_bmr()
2157 fp->mode.lreq.dst = FWLOCALBUS | fc->irm; in fw_try_bmr()
2160 xfer->send.payload[1] = htonl(fc->nodeid); in fw_try_bmr()
2163 err = fw_asyreq(fc, -1, xfer); in fw_try_bmr()
2249 fw_asyreq(xfer->fc, -1, xfer); in fw_vmaccess()
2281 fw_bmr(struct firewire_comm *fc) in fw_bmr() argument
2289 self_id = fw_find_self_id(fc, fc->max_node); in fw_bmr()
2290 if (fc->max_node > 0) { in fw_bmr()
2293 cmstr = fc->max_node; in fw_bmr()
2295 device_printf(fc->bdev, in fw_bmr()
2298 cmstr = fc->nodeid; in fw_bmr()
2304 device_printf(fc->bdev, "bus manager %d %s\n", in fw_bmr()
2305 CSRARC(fc, BUS_MGR_ID), in fw_bmr()
2306 (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) ? "(me)" : ""); in fw_bmr()
2307 if (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) { in fw_bmr()
2313 if (fc->max_hop <= MAX_GAPHOP) in fw_bmr()
2314 fw_phy_config(fc, cmstr, gap_cnt[fc->max_hop]); in fw_bmr()
2316 if (cmstr == fc->nodeid || cmstr == -1) in fw_bmr()
2320 fwdev.fc = fc; in fw_bmr()
2334 fw_open_isodma(struct firewire_comm *fc, int tx) in fw_open_isodma() argument
2341 xferqa = &fc->it[0]; in fw_open_isodma()
2343 xferqa = &fc->ir[0]; in fw_open_isodma()
2345 FW_GLOCK(fc); in fw_open_isodma()
2346 for (i = 0; i < fc->nisodma; i++) { in fw_open_isodma()
2353 if (i == fc->nisodma) { in fw_open_isodma()
2357 FW_GUNLOCK(fc); in fw_open_isodma()