Lines Matching refs:fc

145 fw_noderesolve_nodeid(struct firewire_comm *fc, int dst)  in fw_noderesolve_nodeid()  argument
149 FW_GLOCK(fc); in fw_noderesolve_nodeid()
150 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_nodeid()
153 FW_GUNLOCK(fc); in fw_noderesolve_nodeid()
162 fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 *eui) in fw_noderesolve_eui64() argument
166 FW_GLOCK(fc); in fw_noderesolve_eui64()
167 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_eui64()
170 FW_GUNLOCK(fc); in fw_noderesolve_eui64()
183 fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) in fw_asyreq() argument
201 info = &fc->tcode[tcode]; in fw_asyreq()
208 if ((fc->status < FWBUSEXPLORE) && in fw_asyreq()
218 xferq = fc->atq; in fw_asyreq()
220 xferq = fc->ats; in fw_asyreq()
222 if (xfer->send.pay_len > MAXREC(fc->maxrec)) { in fw_asyreq()
243 device_printf(fc->bdev, "Discard a packet (queued=%d)\n", in fw_asyreq()
250 if (fw_get_tlabel(fc, xfer) < 0) in fw_asyreq()
255 xfer->fc = fc; in fw_asyreq()
268 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwake()
281 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwait()
298 struct firewire_comm *fc = xfer->fc; in fw_asystart() local
301 FW_GLOCK(fc); in fw_asystart()
307 FW_GUNLOCK(fc); in fw_asystart()
310 xfer->q->start(fc); in fw_asystart()
331 struct firewire_comm *fc = (struct firewire_comm *)arg; in firewire_xfer_timeout() local
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()
354 device_printf(fc->bdev, 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()
375 struct firewire_comm *fc; in firewire_watchdog() local
378 fc = arg; in firewire_watchdog()
386 taskqueue_enqueue(fc->taskqueue, &fc->task_timeout); in firewire_watchdog()
390 callout_reset(&fc->timeout_callout, hz / WATCHDOG_HZ, in firewire_watchdog()
391 firewire_watchdog, fc); in firewire_watchdog()
403 struct firewire_comm *fc; in firewire_attach() local
405 fc = device_get_softc(pa); in firewire_attach()
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()
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()
461 FW_GLOCK(fc); in firewire_attach()
462 fw_busreset(fc, FWBUSNOTREADY); in firewire_attach()
463 FW_GUNLOCK(fc); 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()
508 struct firewire_comm *fc; in firewire_detach() local
513 fc = sc->fc; in firewire_detach()
514 mtx_lock(&fc->wait_lock); in firewire_detach()
515 fc->status = FWBUSDETACH; in firewire_detach()
516 wakeup(fc); 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()
522 fw_drain_txq(fc); 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()
566 fw_drain_txq(struct firewire_comm *fc) in fw_drain_txq() argument
574 FW_GLOCK(fc); in fw_drain_txq()
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()
579 FW_GUNLOCK(fc); 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()
588 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel); in fw_drain_txq()
591 mtx_unlock(&fc->tlabel_lock); in fw_drain_txq()
598 fw_reset_csr(struct firewire_comm *fc) in fw_reset_csr() argument
602 CSRARC(fc, STATE_CLEAR) in fw_reset_csr()
604 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
605 CSRARC(fc, NODE_IDS) = 0x3f; in fw_reset_csr()
607 CSRARC(fc, TOPO_MAP + 8) = 0; in fw_reset_csr()
608 fc->irm = -1; in fw_reset_csr()
610 fc->max_node = -1; in fw_reset_csr()
613 CSRARC(fc, SPED_MAP + i * 4) = 0; in fw_reset_csr()
615 CSRARC(fc, STATE_CLEAR) = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14; in fw_reset_csr()
616 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
617 CSRARC(fc, RESET_START) = 0; in fw_reset_csr()
618 CSRARC(fc, SPLIT_TIMEOUT_HI) = 0; in fw_reset_csr()
619 CSRARC(fc, SPLIT_TIMEOUT_LO) = 800 << 19; in fw_reset_csr()
620 CSRARC(fc, CYCLE_TIME) = 0x0; in fw_reset_csr()
621 CSRARC(fc, BUS_TIME) = 0x0; in fw_reset_csr()
622 CSRARC(fc, BUS_MGR_ID) = 0x3f; in fw_reset_csr()
623 CSRARC(fc, BANDWIDTH_AV) = 4915; in fw_reset_csr()
624 CSRARC(fc, CHANNELS_AV_HI) = 0xffffffff; in fw_reset_csr()
625 CSRARC(fc, CHANNELS_AV_LO) = 0xffffffff; in fw_reset_csr()
626 CSRARC(fc, IP_CHANNELS) = (1U << 31); in fw_reset_csr()
628 CSRARC(fc, CONF_ROM) = 0x04 << 24; in fw_reset_csr()
629 CSRARC(fc, CONF_ROM + 4) = 0x31333934; /* means strings 1394 */ in fw_reset_csr()
630 CSRARC(fc, CONF_ROM + 8) = 1 << 31 | 1 << 30 | 1 << 29 | in fw_reset_csr()
632 CSRARC(fc, CONF_ROM + 0xc) = 0; in fw_reset_csr()
635 CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON; in fw_reset_csr()
636 CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON; in fw_reset_csr()
638 CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14); in fw_reset_csr()
639 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
643 fw_init_crom(struct firewire_comm *fc) in fw_init_crom() argument
647 src = &fc->crom_src_buf->src; in fw_init_crom()
661 src->businfo.max_rec = fc->maxrec; 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()
672 fc->crom_src = src; in fw_init_crom()
673 fc->crom_root = &fc->crom_src_buf->root; in fw_init_crom()
677 fw_reset_crom(struct firewire_comm *fc) in fw_reset_crom() argument
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()
705 fw_busreset(struct firewire_comm *fc, uint32_t new_status) in fw_busreset() argument
713 FW_GLOCK_ASSERT(fc); in fw_busreset()
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()
718 fw_reset_csr(fc); in fw_busreset()
720 if (fc->status == FWBUSNOTREADY) in fw_busreset()
721 fw_init_crom(fc); in fw_busreset()
723 fw_reset_crom(fc); in fw_busreset()
725 if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { in fw_busreset()
735 src = &fc->crom_src_buf->src; 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()
764 bcopy(newrom, fc->config_rom, CROMSIZE); in fw_busreset()
770 void fw_init(struct firewire_comm *fc) in fw_init() argument
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()
823 CSRARC(fc, TOPO_MAP) = 0x3f1 << 16; in fw_init()
824 CSRARC(fc, TOPO_MAP + 4) = 1; in fw_init()
825 CSRARC(fc, SPED_MAP) = 0x3f1 << 16; in fw_init()
826 CSRARC(fc, SPED_MAP + 4) = 1; 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()
838 CSRARC(fc, oMPR) = 0x3fff0001; /* # output channel = 1 */ in fw_init()
839 CSRARC(fc, oPCR) = 0x8000007a; in fw_init()
841 CSRARC(fc, i + oPCR) = 0x8000007a; in fw_init()
844 CSRARC(fc, iMPR) = 0x00ff0001; /* # input channel = 1 */ in fw_init()
845 CSRARC(fc, iPCR) = 0x803f0000; in fw_init()
847 CSRARC(fc, i + iPCR) = 0x0; in fw_init()
851 fc->crom_src_buf = NULL; in fw_init()
864 xfer->fc = fc; in fw_init()
871 fw_bindadd(fc, fwb); in fw_init()
882 fw_bindlookup(struct firewire_comm *fc, uint16_t dest_hi, uint32_t dest_lo) in fw_bindlookup() argument
888 FW_GLOCK(fc); in fw_bindlookup()
889 STAILQ_FOREACH(tfw, &fc->binds, fclist) in fw_bindlookup()
894 FW_GUNLOCK(fc); in fw_bindlookup()
902 fw_bindadd(struct firewire_comm *fc, struct fw_bind *fwb) in fw_bindadd() argument
912 FW_GLOCK(fc); in fw_bindadd()
913 STAILQ_FOREACH(tfw, &fc->binds, fclist) { in fw_bindadd()
919 STAILQ_INSERT_HEAD(&fc->binds, fwb, fclist); in fw_bindadd()
921 STAILQ_INSERT_AFTER(&fc->binds, prev, fwb, fclist); in fw_bindadd()
926 FW_GUNLOCK(fc); in fw_bindadd()
934 fw_bindremove(struct firewire_comm *fc, struct fw_bind *fwb) in fw_bindremove() argument
943 FW_GLOCK(fc); 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()
951 FW_GUNLOCK(fc); in fw_bindremove()
963 FW_GUNLOCK(fc); in fw_bindremove()
972 struct firewire_comm *fc, void *sc, void (*hand)(struct fw_xfer *)) in fw_xferlist_add() argument
981 xfer->fc = fc; in fw_xferlist_add()
1020 fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer) in fw_tl_free() argument
1024 mtx_lock(&fc->tlabel_lock); 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()
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()
1046 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1054 fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode) in fw_tl2xfer() argument
1060 mtx_lock(&fc->tlabel_lock); in fw_tl2xfer()
1061 STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel) in fw_tl2xfer()
1063 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1069 if (xfer->fc->tcode[req].valid_res != tcode) { in fw_tl2xfer()
1080 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1145 if (xfer->fc == NULL) in fw_xfer_done()
1148 fw_tl_free(xfer->fc, xfer); in fw_xfer_done()
1159 if (xfer->fc != NULL) { in fw_xfer_unload()
1160 FW_GLOCK(xfer->fc); in fw_xfer_unload()
1168 FW_GUNLOCK(xfer->fc); in fw_xfer_unload()
1174 fw_tl_free(xfer->fc, xfer); in fw_xfer_unload()
1232 fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) in fw_phy_config() argument
1237 fc->status = FWBUSPHYCONF; in fw_phy_config()
1242 xfer->fc = fc; 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()
1297 void fw_sidrcv(struct firewire_comm *fc, uint32_t *sid, u_int len) in fw_sidrcv() argument
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()
1322 fc->topology_map->crc_len++; in fw_sidrcv()
1324 fc->topology_map->node_count++; 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()
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()
1340 if ((fc->irm == -1 || self_id->p0.phy_id > fc->irm) && in fw_sidrcv()
1342 fc->irm = self_id->p0.phy_id; 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()
1366 CSRARC(fc, TOPO_MAP + i * 4) = htonl(*p++); in fw_sidrcv()
1367 p = (uint32_t *)fc->speed_map; in fw_sidrcv()
1368 CSRARC(fc, SPED_MAP) = htonl(*p++); in fw_sidrcv()
1369 CSRARC(fc, SPED_MAP + 4) = htonl(*p++); 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()
1383 fw_bmr(fc); in fw_sidrcv()
1385 fc->status = FWBUSMGRELECT; in fw_sidrcv()
1386 callout_reset(&fc->bmr_callout, hz / 8, in fw_sidrcv()
1387 fw_try_bmr, fc); 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()
1401 struct firewire_comm *fc; in fw_bus_probe() local
1406 fc = arg; 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()
1419 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1424 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1430 wakeup(fc); in fw_bus_probe()
1512 struct firewire_comm *fc; in fw_explore_node() local
1520 fc = dfwdev->fc; in fw_explore_node()
1533 device_printf(fc->bdev, in fw_explore_node()
1553 device_printf(fc->bdev, "%s: node(%d) BUS INFO BLOCK:\n" in fw_explore_node()
1563 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_explore_node()
1571 device_printf(fc->bdev, "%s: node%d: no memory\n", in fw_explore_node()
1575 fwdev->fc = fc; in fw_explore_node()
1590 device_printf(fc->bdev, "%s: " in fw_explore_node()
1592 fwdev->speed = fc->speed_map->speed[fc->nodeid][node]; in fw_explore_node()
1603 device_printf(fc->bdev, in fw_explore_node()
1617 STAILQ_FOREACH(tfwdev, &fc->devices, link) { 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()
1634 device_printf(fc->dev, in fw_explore_node()
1650 device_printf(fc->dev, "%s: explore csrblock failed err(%d)\n", in fw_explore_node()
1663 fw_find_self_id(struct firewire_comm *fc, int node) in fw_find_self_id() argument
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()
1679 fw_explore(struct firewire_comm *fc) in fw_explore() argument
1688 dfwdev.fc = fc; in fw_explore()
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()
1699 __func__, node, fc->nodeid, fc->max_node); in fw_explore()
1702 device_printf(fc->bdev, "%s:" in fw_explore()
1704 __func__, node, fc->max_node); in fw_explore()
1706 fwsid = fw_find_self_id(fc, node); in fw_explore()
1709 device_printf(fc->bdev, in fw_explore()
1726 device_printf(fc->bdev, in fw_explore()
1738 struct firewire_comm *fc; in fw_bus_probe_thread() local
1740 fc = arg; in fw_bus_probe_thread()
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()
1746 fw_explore(fc); in fw_bus_probe_thread()
1747 fc->status = FWBUSEXPDONE; in fw_bus_probe_thread()
1750 fw_attach_dev(fc); 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()
1763 fw_attach_dev(struct firewire_comm *fc) in fw_attach_dev() argument
1771 for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; fwdev = next) { in fw_attach_dev()
1778 device_printf(fc->bdev, "%s:" 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()
1812 fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) in fw_get_tlabel() argument
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()
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()
1836 mtx_unlock(&fc->tlabel_lock); in fw_get_tlabel()
1855 tinfo = &rb->fc->tcode[pkt->mode.hdr.tcode]; in fw_rcv_copy()
1883 device_printf(rb->fc->bdev, "%s:" in fw_rcv_copy()
1929 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1932 device_printf(rb->fc->bdev, "%s: unknown response " in fw_rcv()
1942 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1971 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1981 bind = fw_bindlookup(rb->fc, fp->mode.rreqq.dest_hi, in fw_rcv()
1984 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1994 if (rb->fc->status == FWBUSINIT) { in fw_rcv()
1995 device_printf(rb->fc->bdev, in fw_rcv()
2032 if (fw_asyreq(rb->fc, -1, rb->xfer)) in fw_rcv()
2043 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
2056 xferq = rb->fc->ir[sub]; in fw_rcv()
2076 sc = device_get_softc(rb->fc->bdev); in fw_rcv()
2091 device_printf(rb->fc->bdev,"%s: unknown tcode %d\n", in fw_rcv()
2103 struct firewire_comm *fc; in fw_try_bmr_callback() local
2108 fc = xfer->fc; 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()
2122 fw_bmr(fc); in fw_try_bmr_callback()
2126 device_printf(fc->bdev, "bus manager election failed\n"); in fw_try_bmr_callback()
2138 struct firewire_comm *fc = arg; in fw_try_bmr() local
2146 fc->status = FWBUSMGRELECT; in fw_try_bmr()
2156 fp->mode.lreq.dst = FWLOCALBUS | fc->irm; in fw_try_bmr()
2159 xfer->send.payload[1] = htonl(fc->nodeid); in fw_try_bmr()
2162 err = fw_asyreq(fc, -1, xfer); in fw_try_bmr()
2248 fw_asyreq(xfer->fc, -1, xfer); in fw_vmaccess()
2280 fw_bmr(struct firewire_comm *fc) in fw_bmr() argument
2288 self_id = fw_find_self_id(fc, fc->max_node); in fw_bmr()
2289 if (fc->max_node > 0) { 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()
2303 device_printf(fc->bdev, "bus manager %d %s\n", in fw_bmr()
2304 CSRARC(fc, BUS_MGR_ID), 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()
2319 fwdev.fc = fc; in fw_bmr()
2333 fw_open_isodma(struct firewire_comm *fc, int tx) in fw_open_isodma() argument
2340 xferqa = &fc->it[0]; in fw_open_isodma()
2342 xferqa = &fc->ir[0]; in fw_open_isodma()
2344 FW_GLOCK(fc); in fw_open_isodma()
2345 for (i = 0; i < fc->nisodma; i++) { in fw_open_isodma()
2352 if (i == fc->nisodma) { in fw_open_isodma()
2356 FW_GUNLOCK(fc); in fw_open_isodma()