Lines Matching refs:fc
148 fw_noderesolve_nodeid(struct firewire_comm *fc, int dst) in fw_noderesolve_nodeid() argument
152 FW_GLOCK(fc); in fw_noderesolve_nodeid()
153 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_nodeid()
156 FW_GUNLOCK(fc); in fw_noderesolve_nodeid()
165 fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 *eui) in fw_noderesolve_eui64() argument
169 FW_GLOCK(fc); in fw_noderesolve_eui64()
170 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_noderesolve_eui64()
173 FW_GUNLOCK(fc); in fw_noderesolve_eui64()
186 fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) in fw_asyreq() argument
204 info = &fc->tcode[tcode]; in fw_asyreq()
211 if ((fc->status < FWBUSEXPLORE) && in fw_asyreq()
221 xferq = fc->atq; in fw_asyreq()
223 xferq = fc->ats; in fw_asyreq()
225 if (xfer->send.pay_len > MAXREC(fc->maxrec)) { in fw_asyreq()
246 device_printf(fc->bdev, "Discard a packet (queued=%d)\n", in fw_asyreq()
253 if (fw_get_tlabel(fc, xfer) < 0) in fw_asyreq()
258 xfer->fc = fc; in fw_asyreq()
271 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwake()
284 struct mtx *lock = &xfer->fc->wait_lock; in fw_xferwait()
301 struct firewire_comm *fc = xfer->fc; in fw_asystart() local
304 FW_GLOCK(fc); in fw_asystart()
310 FW_GUNLOCK(fc); in fw_asystart()
313 xfer->q->start(fc); in fw_asystart()
334 struct firewire_comm *fc = (struct firewire_comm *)arg; in firewire_xfer_timeout() local
348 mtx_lock(&fc->tlabel_lock); in firewire_xfer_timeout()
349 for (i = 0; i < nitems(fc->tlabels); i++) { in firewire_xfer_timeout()
350 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { in firewire_xfer_timeout()
357 device_printf(fc->bdev, in firewire_xfer_timeout()
363 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel); in firewire_xfer_timeout()
367 mtx_unlock(&fc->tlabel_lock); in firewire_xfer_timeout()
368 fc->timeout(fc); in firewire_xfer_timeout()
378 struct firewire_comm *fc; in firewire_watchdog() local
381 fc = arg; in firewire_watchdog()
389 taskqueue_enqueue(fc->taskqueue, &fc->task_timeout); in firewire_watchdog()
393 callout_reset(&fc->timeout_callout, hz / WATCHDOG_HZ, in firewire_watchdog()
394 firewire_watchdog, fc); in firewire_watchdog()
406 struct firewire_comm *fc; in firewire_attach() local
408 fc = device_get_softc(pa); in firewire_attach()
409 sc->fc = fc; in firewire_attach()
410 fc->status = FWBUSNOTREADY; in firewire_attach()
413 if (fc->nisodma > FWMAXNDMA) in firewire_attach()
414 fc->nisodma = FWMAXNDMA; in firewire_attach()
418 fc->crom_src_buf = malloc(sizeof(struct crom_src_buf), in firewire_attach()
420 if (fc->crom_src_buf == NULL) { in firewire_attach()
421 device_printf(fc->dev, in firewire_attach()
425 fc->topology_map = malloc(sizeof(struct fw_topology_map), in firewire_attach()
427 if (fc->topology_map == NULL) { in firewire_attach()
428 device_printf(fc->dev, "%s: unable to allocate topology map\n", in firewire_attach()
430 free(fc->crom_src_buf, M_FW); in firewire_attach()
433 fc->speed_map = malloc(sizeof(struct fw_speed_map), in firewire_attach()
435 if (fc->speed_map == NULL) { in firewire_attach()
436 device_printf(fc->dev, "%s: unable to allocate speed map\n", in firewire_attach()
438 free(fc->crom_src_buf, M_FW); in firewire_attach()
439 free(fc->topology_map, M_FW); in firewire_attach()
443 mtx_init(&fc->wait_lock, "fwwait", NULL, MTX_DEF); in firewire_attach()
444 mtx_init(&fc->tlabel_lock, "fwtlabel", NULL, MTX_DEF); in firewire_attach()
445 CALLOUT_INIT(&fc->timeout_callout); in firewire_attach()
446 CALLOUT_INIT(&fc->bmr_callout); in firewire_attach()
447 CALLOUT_INIT(&fc->busprobe_callout); in firewire_attach()
448 TASK_INIT(&fc->task_timeout, 0, firewire_xfer_timeout, fc); in firewire_attach()
450 callout_reset(&sc->fc->timeout_callout, hz, in firewire_attach()
451 firewire_watchdog, sc->fc); in firewire_attach()
454 kproc_create(fw_bus_probe_thread, fc, &fc->probe_thread, in firewire_attach()
464 FW_GLOCK(fc); in firewire_attach()
465 fw_busreset(fc, FWBUSNOTREADY); in firewire_attach()
466 FW_GUNLOCK(fc); in firewire_attach()
467 fc->ibr(fc); in firewire_attach()
484 device_set_ivars(child, sc->fc); in firewire_add_child()
497 sc->fc->status = FWBUSNOTREADY; in firewire_resume()
511 struct firewire_comm *fc; in firewire_detach() local
516 fc = sc->fc; in firewire_detach()
517 mtx_lock(&fc->wait_lock); in firewire_detach()
518 fc->status = FWBUSDETACH; in firewire_detach()
519 wakeup(fc); in firewire_detach()
520 if (msleep(fc->probe_thread, &fc->wait_lock, PWAIT, "fwthr", hz * 60)) in firewire_detach()
522 mtx_unlock(&fc->wait_lock); in firewire_detach()
524 if (fc->arq != 0 && fc->arq->maxq > 0) in firewire_detach()
525 fw_drain_txq(fc); in firewire_detach()
533 callout_stop(&fc->timeout_callout); in firewire_detach()
534 callout_stop(&fc->bmr_callout); in firewire_detach()
535 callout_stop(&fc->busprobe_callout); in firewire_detach()
538 for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; in firewire_detach()
543 free(fc->topology_map, M_FW); in firewire_detach()
544 free(fc->speed_map, M_FW); in firewire_detach()
545 free(fc->crom_src_buf, M_FW); in firewire_detach()
547 mtx_destroy(&fc->tlabel_lock); in firewire_detach()
548 mtx_destroy(&fc->wait_lock); in firewire_detach()
569 fw_drain_txq(struct firewire_comm *fc) in fw_drain_txq() argument
577 FW_GLOCK(fc); in fw_drain_txq()
578 fw_xferq_drain(fc->atq); in fw_drain_txq()
579 fw_xferq_drain(fc->ats); in fw_drain_txq()
580 for (i = 0; i < fc->nisodma; i++) in fw_drain_txq()
581 fw_xferq_drain(fc->it[i]); in fw_drain_txq()
582 FW_GUNLOCK(fc); in fw_drain_txq()
584 mtx_lock(&fc->tlabel_lock); in fw_drain_txq()
586 while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { in fw_drain_txq()
591 STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel); in fw_drain_txq()
594 mtx_unlock(&fc->tlabel_lock); in fw_drain_txq()
601 fw_reset_csr(struct firewire_comm *fc) in fw_reset_csr() argument
605 CSRARC(fc, STATE_CLEAR) in fw_reset_csr()
607 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
608 CSRARC(fc, NODE_IDS) = 0x3f; in fw_reset_csr()
610 CSRARC(fc, TOPO_MAP + 8) = 0; in fw_reset_csr()
611 fc->irm = -1; in fw_reset_csr()
613 fc->max_node = -1; in fw_reset_csr()
616 CSRARC(fc, SPED_MAP + i * 4) = 0; in fw_reset_csr()
618 CSRARC(fc, STATE_CLEAR) = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14; in fw_reset_csr()
619 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
620 CSRARC(fc, RESET_START) = 0; in fw_reset_csr()
621 CSRARC(fc, SPLIT_TIMEOUT_HI) = 0; in fw_reset_csr()
622 CSRARC(fc, SPLIT_TIMEOUT_LO) = 800 << 19; in fw_reset_csr()
623 CSRARC(fc, CYCLE_TIME) = 0x0; in fw_reset_csr()
624 CSRARC(fc, BUS_TIME) = 0x0; in fw_reset_csr()
625 CSRARC(fc, BUS_MGR_ID) = 0x3f; in fw_reset_csr()
626 CSRARC(fc, BANDWIDTH_AV) = 4915; in fw_reset_csr()
627 CSRARC(fc, CHANNELS_AV_HI) = 0xffffffff; in fw_reset_csr()
628 CSRARC(fc, CHANNELS_AV_LO) = 0xffffffff; in fw_reset_csr()
629 CSRARC(fc, IP_CHANNELS) = (1U << 31); in fw_reset_csr()
631 CSRARC(fc, CONF_ROM) = 0x04 << 24; in fw_reset_csr()
632 CSRARC(fc, CONF_ROM + 4) = 0x31333934; /* means strings 1394 */ in fw_reset_csr()
633 CSRARC(fc, CONF_ROM + 8) = 1 << 31 | 1 << 30 | 1 << 29 | in fw_reset_csr()
635 CSRARC(fc, CONF_ROM + 0xc) = 0; in fw_reset_csr()
638 CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON; in fw_reset_csr()
639 CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON; in fw_reset_csr()
641 CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14); in fw_reset_csr()
642 CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); in fw_reset_csr()
646 fw_init_crom(struct firewire_comm *fc) in fw_init_crom() argument
650 src = &fc->crom_src_buf->src; in fw_init_crom()
664 src->businfo.max_rec = fc->maxrec; in fw_init_crom()
668 src->businfo.link_spd = fc->speed; in fw_init_crom()
670 src->businfo.eui64.hi = fc->eui.hi; in fw_init_crom()
671 src->businfo.eui64.lo = fc->eui.lo; in fw_init_crom()
675 fc->crom_src = src; in fw_init_crom()
676 fc->crom_root = &fc->crom_src_buf->root; in fw_init_crom()
680 fw_reset_crom(struct firewire_comm *fc) in fw_reset_crom() argument
686 buf = fc->crom_src_buf; in fw_reset_crom()
687 src = fc->crom_src; in fw_reset_crom()
688 root = fc->crom_root; in fw_reset_crom()
708 fw_busreset(struct firewire_comm *fc, uint32_t new_status) in fw_busreset() argument
716 FW_GLOCK_ASSERT(fc); in fw_busreset()
717 if (fc->status == FWBUSMGRELECT) in fw_busreset()
718 callout_stop(&fc->bmr_callout); in fw_busreset()
720 fc->status = new_status; in fw_busreset()
721 fw_reset_csr(fc); in fw_busreset()
723 if (fc->status == FWBUSNOTREADY) in fw_busreset()
724 fw_init_crom(fc); in fw_busreset()
726 fw_reset_crom(fc); in fw_busreset()
728 if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { in fw_busreset()
738 src = &fc->crom_src_buf->src; in fw_busreset()
755 src = &fc->crom_src_buf->src; in fw_busreset()
757 if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) { in fw_busreset()
767 bcopy(newrom, fc->config_rom, CROMSIZE); in fw_busreset()
773 void fw_init(struct firewire_comm *fc) in fw_init() argument
781 fc->arq->queued = 0; in fw_init()
782 fc->ars->queued = 0; in fw_init()
783 fc->atq->queued = 0; in fw_init()
784 fc->ats->queued = 0; in fw_init()
786 fc->arq->buf = NULL; in fw_init()
787 fc->ars->buf = NULL; in fw_init()
788 fc->atq->buf = NULL; in fw_init()
789 fc->ats->buf = NULL; in fw_init()
791 fc->arq->flag = 0; in fw_init()
792 fc->ars->flag = 0; in fw_init()
793 fc->atq->flag = 0; in fw_init()
794 fc->ats->flag = 0; in fw_init()
796 STAILQ_INIT(&fc->atq->q); in fw_init()
797 STAILQ_INIT(&fc->ats->q); in fw_init()
799 for (i = 0; i < fc->nisodma; i++) { in fw_init()
800 fc->it[i]->queued = 0; in fw_init()
801 fc->ir[i]->queued = 0; in fw_init()
803 fc->it[i]->start = NULL; in fw_init()
804 fc->ir[i]->start = NULL; in fw_init()
806 fc->it[i]->buf = NULL; in fw_init()
807 fc->ir[i]->buf = NULL; in fw_init()
809 fc->it[i]->flag = FWXFERQ_STREAM; in fw_init()
810 fc->ir[i]->flag = FWXFERQ_STREAM; in fw_init()
812 STAILQ_INIT(&fc->it[i]->q); in fw_init()
813 STAILQ_INIT(&fc->ir[i]->q); in fw_init()
816 fc->arq->maxq = FWMAXQUEUE; in fw_init()
817 fc->ars->maxq = FWMAXQUEUE; in fw_init()
818 fc->atq->maxq = FWMAXQUEUE; in fw_init()
819 fc->ats->maxq = FWMAXQUEUE; in fw_init()
821 for (i = 0; i < fc->nisodma; i++) { in fw_init()
822 fc->ir[i]->maxq = FWMAXQUEUE; in fw_init()
823 fc->it[i]->maxq = FWMAXQUEUE; in fw_init()
826 CSRARC(fc, TOPO_MAP) = 0x3f1 << 16; in fw_init()
827 CSRARC(fc, TOPO_MAP + 4) = 1; in fw_init()
828 CSRARC(fc, SPED_MAP) = 0x3f1 << 16; in fw_init()
829 CSRARC(fc, SPED_MAP + 4) = 1; in fw_init()
831 STAILQ_INIT(&fc->devices); in fw_init()
834 STAILQ_INIT(&fc->binds); in fw_init()
836 STAILQ_INIT(&fc->tlabels[i]); in fw_init()
841 CSRARC(fc, oMPR) = 0x3fff0001; /* # output channel = 1 */ in fw_init()
842 CSRARC(fc, oPCR) = 0x8000007a; in fw_init()
844 CSRARC(fc, i + oPCR) = 0x8000007a; in fw_init()
847 CSRARC(fc, iMPR) = 0x00ff0001; /* # input channel = 1 */ in fw_init()
848 CSRARC(fc, iPCR) = 0x803f0000; in fw_init()
850 CSRARC(fc, i + iPCR) = 0x0; in fw_init()
854 fc->crom_src_buf = NULL; in fw_init()
867 xfer->fc = fc; in fw_init()
874 fw_bindadd(fc, fwb); in fw_init()
885 fw_bindlookup(struct firewire_comm *fc, uint16_t dest_hi, uint32_t dest_lo) in fw_bindlookup() argument
891 FW_GLOCK(fc); in fw_bindlookup()
892 STAILQ_FOREACH(tfw, &fc->binds, fclist) in fw_bindlookup()
897 FW_GUNLOCK(fc); in fw_bindlookup()
905 fw_bindadd(struct firewire_comm *fc, struct fw_bind *fwb) in fw_bindadd() argument
915 FW_GLOCK(fc); in fw_bindadd()
916 STAILQ_FOREACH(tfw, &fc->binds, fclist) { in fw_bindadd()
922 STAILQ_INSERT_HEAD(&fc->binds, fwb, fclist); in fw_bindadd()
924 STAILQ_INSERT_AFTER(&fc->binds, prev, fwb, fclist); in fw_bindadd()
929 FW_GUNLOCK(fc); in fw_bindadd()
937 fw_bindremove(struct firewire_comm *fc, struct fw_bind *fwb) in fw_bindremove() argument
946 FW_GLOCK(fc); in fw_bindremove()
947 STAILQ_FOREACH(tfw, &fc->binds, fclist) in fw_bindremove()
949 STAILQ_REMOVE(&fc->binds, fwb, fw_bind, fclist); in fw_bindremove()
954 FW_GUNLOCK(fc); in fw_bindremove()
966 FW_GUNLOCK(fc); in fw_bindremove()
975 struct firewire_comm *fc, void *sc, void (*hand)(struct fw_xfer *)) in fw_xferlist_add() argument
984 xfer->fc = fc; in fw_xferlist_add()
1023 fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer) in fw_tl_free() argument
1027 mtx_lock(&fc->tlabel_lock); in fw_tl_free()
1029 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1033 STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel) in fw_tl_free()
1043 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1047 STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel); in fw_tl_free()
1049 mtx_unlock(&fc->tlabel_lock); in fw_tl_free()
1057 fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode) in fw_tl2xfer() argument
1063 mtx_lock(&fc->tlabel_lock); in fw_tl2xfer()
1064 STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel) in fw_tl2xfer()
1066 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1072 if (xfer->fc->tcode[req].valid_res != tcode) { in fw_tl2xfer()
1083 mtx_unlock(&fc->tlabel_lock); in fw_tl2xfer()
1148 if (xfer->fc == NULL) in fw_xfer_done()
1151 fw_tl_free(xfer->fc, xfer); in fw_xfer_done()
1162 if (xfer->fc != NULL) { in fw_xfer_unload()
1163 FW_GLOCK(xfer->fc); in fw_xfer_unload()
1171 FW_GUNLOCK(xfer->fc); in fw_xfer_unload()
1177 fw_tl_free(xfer->fc, xfer); in fw_xfer_unload()
1235 fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) in fw_phy_config() argument
1240 fc->status = FWBUSPHYCONF; in fw_phy_config()
1245 xfer->fc = fc; in fw_phy_config()
1259 device_printf(fc->bdev, "%s: root_node=%d gap_count=%d\n", in fw_phy_config()
1261 fw_asyreq(fc, -1, xfer); in fw_phy_config()
1300 void fw_sidrcv(struct firewire_comm *fc, uint32_t *sid, u_int len) in fw_sidrcv() argument
1306 fc->sid_cnt = len / (sizeof(uint32_t) * 2); in fw_sidrcv()
1307 fc->max_node = fc->nodeid & 0x3f; in fw_sidrcv()
1308 CSRARC(fc, NODE_IDS) = ((uint32_t)fc->nodeid) << 16; in fw_sidrcv()
1309 fc->status = FWBUSCYMELECT; in fw_sidrcv()
1310 fc->topology_map->crc_len = 2; in fw_sidrcv()
1311 fc->topology_map->generation++; in fw_sidrcv()
1312 fc->topology_map->self_id_count = 0; in fw_sidrcv()
1313 fc->topology_map->node_count= 0; in fw_sidrcv()
1314 fc->speed_map->generation++; in fw_sidrcv()
1315 fc->speed_map->crc_len = 1 + (64 * 64 + 3) / 4; in fw_sidrcv()
1316 self_id = &fc->topology_map->self_id[0]; in fw_sidrcv()
1317 for (i = 0; i < fc->sid_cnt; i++) { in fw_sidrcv()
1319 device_printf(fc->bdev, in fw_sidrcv()
1325 fc->topology_map->crc_len++; in fw_sidrcv()
1327 fc->topology_map->node_count++; in fw_sidrcv()
1332 if (fc->max_node < node) in fw_sidrcv()
1333 fc->max_node = self_id->p0.phy_id; in fw_sidrcv()
1335 fc->speed_map->speed[node][node] = in fw_sidrcv()
1338 fc->speed_map->speed[j][node] = in fw_sidrcv()
1339 fc->speed_map->speed[node][j] = in fw_sidrcv()
1340 min(fc->speed_map->speed[j][j], in fw_sidrcv()
1343 if ((fc->irm == -1 || self_id->p0.phy_id > fc->irm) && in fw_sidrcv()
1345 fc->irm = self_id->p0.phy_id; in fw_sidrcv()
1357 fc->topology_map->self_id_count++; in fw_sidrcv()
1360 fc->topology_map->crc = fw_crc16( in fw_sidrcv()
1361 (uint32_t *)&fc->topology_map->generation, in fw_sidrcv()
1362 fc->topology_map->crc_len * 4); in fw_sidrcv()
1363 fc->speed_map->crc = fw_crc16( in fw_sidrcv()
1364 (uint32_t *)&fc->speed_map->generation, in fw_sidrcv()
1365 fc->speed_map->crc_len * 4); in fw_sidrcv()
1367 p = (uint32_t *)fc->topology_map; in fw_sidrcv()
1368 for (i = 0; i <= fc->topology_map->crc_len; i++) in fw_sidrcv()
1369 CSRARC(fc, TOPO_MAP + i * 4) = htonl(*p++); in fw_sidrcv()
1370 p = (uint32_t *)fc->speed_map; in fw_sidrcv()
1371 CSRARC(fc, SPED_MAP) = htonl(*p++); in fw_sidrcv()
1372 CSRARC(fc, SPED_MAP + 4) = htonl(*p++); in fw_sidrcv()
1374 bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1) * 4); in fw_sidrcv()
1376 fc->max_hop = fc->max_node - i_branch; in fw_sidrcv()
1377 device_printf(fc->bdev, "%d nodes, maxhop <= %d %s irm(%d) %s\n", in fw_sidrcv()
1378 fc->max_node + 1, fc->max_hop, in fw_sidrcv()
1379 (fc->irm == -1) ? "Not IRM capable" : "cable IRM", in fw_sidrcv()
1380 fc->irm, (fc->irm == fc->nodeid) ? " (me) " : ""); in fw_sidrcv()
1382 if (try_bmr && (fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) { in fw_sidrcv()
1383 if (fc->irm == fc->nodeid) { in fw_sidrcv()
1384 fc->status = FWBUSMGRDONE; in fw_sidrcv()
1385 CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, fc->irm); in fw_sidrcv()
1386 fw_bmr(fc); in fw_sidrcv()
1388 fc->status = FWBUSMGRELECT; in fw_sidrcv()
1389 callout_reset(&fc->bmr_callout, hz / 8, in fw_sidrcv()
1390 fw_try_bmr, fc); in fw_sidrcv()
1393 fc->status = FWBUSMGRDONE; in fw_sidrcv()
1395 callout_reset(&fc->busprobe_callout, hz / 4, fw_bus_probe, fc); in fw_sidrcv()
1404 struct firewire_comm *fc; in fw_bus_probe() local
1409 fc = arg; in fw_bus_probe()
1410 fc->status = FWBUSEXPLORE; in fw_bus_probe()
1414 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1417 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_bus_probe()
1422 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1427 device_printf(fc->bdev, "%s:" in fw_bus_probe()
1433 wakeup(fc); in fw_bus_probe()
1515 struct firewire_comm *fc; in fw_explore_node() local
1523 fc = dfwdev->fc; in fw_explore_node()
1536 device_printf(fc->bdev, in fw_explore_node()
1556 device_printf(fc->bdev, "%s: node(%d) BUS INFO BLOCK:\n" in fw_explore_node()
1566 STAILQ_FOREACH(fwdev, &fc->devices, link) in fw_explore_node()
1574 device_printf(fc->bdev, "%s: node%d: no memory\n", in fw_explore_node()
1578 fwdev->fc = fc; in fw_explore_node()
1593 device_printf(fc->bdev, "%s: " in fw_explore_node()
1595 fwdev->speed = fc->speed_map->speed[fc->nodeid][node]; in fw_explore_node()
1606 device_printf(fc->bdev, in fw_explore_node()
1620 STAILQ_FOREACH(tfwdev, &fc->devices, link) { in fw_explore_node()
1628 STAILQ_INSERT_HEAD(&fc->devices, fwdev, link); in fw_explore_node()
1630 STAILQ_INSERT_AFTER(&fc->devices, pfwdev, fwdev, link); in fw_explore_node()
1637 device_printf(fc->dev, in fw_explore_node()
1653 device_printf(fc->dev, "%s: explore csrblock failed err(%d)\n", in fw_explore_node()
1666 fw_find_self_id(struct firewire_comm *fc, int node) in fw_find_self_id() argument
1671 for (i = 0; i < fc->topology_map->self_id_count; i++) { in fw_find_self_id()
1672 s = &fc->topology_map->self_id[i]; in fw_find_self_id()
1682 fw_explore(struct firewire_comm *fc) in fw_explore() argument
1691 dfwdev.fc = fc; in fw_explore()
1696 for (node = 0; node <= fc->max_node; node++) { in fw_explore()
1698 if (node == fc->nodeid) { in fw_explore()
1700 device_printf(fc->bdev, "%s:" in fw_explore()
1702 __func__, node, fc->nodeid, fc->max_node); in fw_explore()
1705 device_printf(fc->bdev, "%s:" in fw_explore()
1707 __func__, node, fc->max_node); in fw_explore()
1709 fwsid = fw_find_self_id(fc, node); in fw_explore()
1712 device_printf(fc->bdev, in fw_explore()
1729 device_printf(fc->bdev, in fw_explore()
1741 struct firewire_comm *fc; in fw_bus_probe_thread() local
1743 fc = arg; in fw_bus_probe_thread()
1745 mtx_lock(&fc->wait_lock); in fw_bus_probe_thread()
1746 while (fc->status != FWBUSDETACH) { in fw_bus_probe_thread()
1747 if (fc->status == FWBUSEXPLORE) { in fw_bus_probe_thread()
1748 mtx_unlock(&fc->wait_lock); in fw_bus_probe_thread()
1749 fw_explore(fc); in fw_bus_probe_thread()
1750 fc->status = FWBUSEXPDONE; in fw_bus_probe_thread()
1753 fw_attach_dev(fc); in fw_bus_probe_thread()
1754 mtx_lock(&fc->wait_lock); in fw_bus_probe_thread()
1756 msleep((void *)fc, &fc->wait_lock, PWAIT|PCATCH, "-", 0); in fw_bus_probe_thread()
1758 mtx_unlock(&fc->wait_lock); in fw_bus_probe_thread()
1766 fw_attach_dev(struct firewire_comm *fc) in fw_attach_dev() argument
1774 for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; fwdev = next) { in fw_attach_dev()
1781 device_printf(fc->bdev, "%s:" in fw_attach_dev()
1789 STAILQ_REMOVE(&fc->devices, fwdev, fw_device, in fw_attach_dev()
1796 err = device_get_children(fc->bdev, &devlistp, &devcnt); in fw_attach_dev()
1815 fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) in fw_get_tlabel() argument
1823 mtx_lock(&fc->tlabel_lock); in fw_get_tlabel()
1824 new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f; in fw_get_tlabel()
1825 STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel) in fw_get_tlabel()
1829 fc->last_tlabel[dst] = new_tlabel; in fw_get_tlabel()
1830 STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel); in fw_get_tlabel()
1831 mtx_unlock(&fc->tlabel_lock); in fw_get_tlabel()
1839 mtx_unlock(&fc->tlabel_lock); in fw_get_tlabel()
1858 tinfo = &rb->fc->tcode[pkt->mode.hdr.tcode]; in fw_rcv_copy()
1886 device_printf(rb->fc->bdev, "%s:" in fw_rcv_copy()
1931 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1934 device_printf(rb->fc->bdev, "%s: unknown response " in fw_rcv()
1944 rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, in fw_rcv()
1973 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1983 bind = fw_bindlookup(rb->fc, fp->mode.rreqq.dest_hi, in fw_rcv()
1986 device_printf(rb->fc->bdev, "%s: " in fw_rcv()
1996 if (rb->fc->status == FWBUSINIT) { in fw_rcv()
1997 device_printf(rb->fc->bdev, in fw_rcv()
2034 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()