Home | History | Annotate | Download | only in ieee1394

Lines Matching defs:sdev

256 	struct sbp_dev	*sdev;
646 sbp_show_sdev_info(struct sbp_dev *sdev)
648 struct fw_device *fwdev = sdev->target->fwdev;
649 struct sbp_softc *sc = sdev->target->sbp;
653 (sdev->type & 0x40) >> 6,
654 (sdev->type & 0x1f),
661 sdev->bustgtlun, sdev->vendor, sdev->product, sdev->revision);
669 struct sbp_dev *sdev, **newluns;
699 sdev = target->luns[lun];
700 if (sdev == NULL)
702 sdev->flags &= ~VALID_LUN;
705 sbp_scsipi_detach_sdev(sdev);
706 sbp_free_sdev(sdev);
746 sdev = target->luns[lun];
747 if (sdev == NULL) {
748 sdev = malloc(sizeof(struct sbp_dev),
750 target->luns[lun] = sdev;
751 sdev->lun_id = lun;
752 sdev->target = target;
753 STAILQ_INIT(&sdev->ocbs);
754 callout_init(&sdev->login_callout, CALLOUT_MPSAFE);
755 callout_setfunc(&sdev->login_callout,
756 sbp_login_callout, sdev);
757 sdev->status = SBP_DEV_RESET;
759 snprintf(sdev->bustgtlun, 32, "%s:%d:%d",
761 sdev->target->target_id,
762 sdev->lun_id);
772 sdev->flags |= VALID_LUN;
773 sdev->type = (reg->val & 0xff0000) >> 16;
779 &sdev->dma, sizeof(uint32_t), BUS_DMA_NOWAIT);
780 if (sdev->dma.v_addr == NULL) {
781 free(sdev, M_SBP);
785 sdev->ocb = (struct sbp_ocb *)sdev->dma.v_addr;
786 sdev->login = (struct sbp_login_res *)&sdev->ocb[SBP_QUEUE_LEN];
787 memset((char *)sdev->ocb, 0,
790 STAILQ_INIT(&sdev->free_ocbs);
792 struct sbp_ocb *ocb = &sdev->ocb[i];
796 sdev->dma.bus_addr + sizeof(struct sbp_ocb) * i;
804 sbp_free_ocb(sdev, ocb); /* into free queue */
811 sdev = target->luns[lun];
812 if (sdev != NULL && (sdev->flags & VALID_LUN) == 0) {
813 sbp_scsipi_detach_sdev(sdev);
814 sbp_free_sdev(sdev);
864 sbp_probe_lun(struct sbp_dev *sdev)
870 memset(sdev->vendor, 0, sizeof(sdev->vendor));
871 memset(sdev->product, 0, sizeof(sdev->product));
873 fwdev = sdev->target->fwdev;
878 crom_parse_text(cc, sdev->vendor, sizeof(sdev->vendor));
888 snprintf(sdev->revision, sizeof(sdev->revision), "%06x",
893 crom_parse_text(cc, sdev->product, sizeof(sdev->product));
899 struct sbp_dev *sdev = (struct sbp_dev *)arg;
901 sbp_mgm_orb(sdev, ORB_FUN_LGI, NULL);
905 sbp_login(struct sbp_dev *sdev)
907 struct sbp_softc *sc = sdev->target->sbp;
923 callout_schedule(&sdev->login_callout, ticks);
930 struct sbp_dev *sdev;
941 sdev = target->luns[i];
942 if (sdev == NULL || sdev->status == SBP_DEV_DEAD)
945 if (sdev->periph != NULL) {
946 scsipi_periph_freeze(sdev->periph, 1);
947 sdev->freeze++;
949 sbp_probe_lun(sdev);
950 sbp_show_sdev_info(sdev);
952 sbp_abort_all_ocbs(sdev, XS_RESET);
953 switch (sdev->status) {
957 sbp_login(sdev);
964 sbp_mgm_orb(sdev, ORB_FUN_RCN, NULL);
1029 struct sbp_dev *sdev = (struct sbp_dev *)xfer->sc;
1030 struct sbp_softc *sc = sdev->target->sbp;
1046 struct sbp_dev *sdev = (struct sbp_dev *)xfer->sc;
1047 struct sbp_softc *sc = sdev->target->sbp;
1051 STAILQ_INSERT_TAIL(&sdev->target->xferlist, xfer, link);
1058 struct sbp_dev *tsdev, *sdev = (struct sbp_dev *)xfer->sc;
1059 struct sbp_target *target = sdev->target;
1064 sdev->bustgtlun, xfer->resp);
1074 sbp_reset_start(struct sbp_dev *sdev)
1081 device_xname(sdev->target->sbp->sc_fd.dev), sdev->bustgtlun);
1084 xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0);
1099 struct sbp_dev *sdev;
1101 sdev = (struct sbp_dev *)xfer->sc;
1105 device_xname(sdev->target->sbp->sc_fd.dev), sdev->bustgtlun);
1116 struct sbp_dev *sdev;
1128 sdev = target->luns[lun];
1129 if (sdev == NULL)
1131 if (sdev->status != SBP_DEV_PROBE) {
1136 if (sdev->periph == NULL) {
1141 sdev->lun_id);
1142 sdev->periph = scsipi_lookup_periph(chan,
1145 sdev->status = SBP_DEV_ATTACHED;
1156 sbp_scan_dev(struct sbp_dev *sdev)
1158 struct sbp_softc *sc = sdev->target->sbp;
1160 sdev->status = SBP_DEV_PROBE;
1162 cv_signal(&sdev->target->sbp->sc_cv);
1170 struct sbp_dev *sdev;
1174 sdev = (struct sbp_dev *)xfer->sc;
1175 target = sdev->target;
1180 sdev->bustgtlun);
1184 sbp_scan_dev(sdev);
1191 struct sbp_dev *sdev = (struct sbp_dev *)xfer->sc;
1192 struct sbp_softc *sc = sdev->target->sbp;
1196 sdev->bustgtlun);
1200 sdev->bustgtlun, xfer->resp);
1203 if (sdev->periph != NULL) {
1204 scsipi_periph_thaw(sdev->periph, sdev->freeze);
1206 sdev->freeze = 0;
1211 sbp_agent_reset(struct sbp_dev *sdev)
1217 printf("%s:%s:%s\n", device_xname(sdev->target->sbp->sc_fd.dev),
1218 __func__, sdev->bustgtlun);
1220 xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0x04);
1223 if (sdev->status == SBP_DEV_ATTACHED || sdev->status == SBP_DEV_PROBE)
1231 sbp_abort_all_ocbs(sdev, XS_RESET);
1237 struct sbp_dev *sdev = (struct sbp_dev *)xfer->sc;
1240 printf("%s:%s:%s\n", device_xname(sdev->target->sbp->sc_fd.dev),
1241 __func__, sdev->bustgtlun);
1244 sbp_agent_reset(sdev);
1248 sbp_busy_timeout(struct sbp_dev *sdev)
1254 printf("%s:%s:%s\n", device_xname(sdev->target->sbp->sc_fd.dev),
1255 __func__, sdev->bustgtlun);
1257 xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0);
1272 struct sbp_dev *sdev = (struct sbp_dev *)xfer->sc;
1273 struct sbp_softc *sc = sdev->target->sbp;
1277 sdev->bustgtlun);
1281 __func__, sdev->bustgtlun, xfer->resp);
1283 sdev->flags &= ~ORB_POINTER_ACTIVE;
1285 if ((sdev->flags & ORB_POINTER_NEED) != 0) {
1288 sdev->flags &= ~ORB_POINTER_NEED;
1289 ocb = STAILQ_FIRST(&sdev->ocbs);
1291 sbp_orb_pointer(sdev, ocb);
1297 sbp_orb_pointer(struct sbp_dev *sdev, struct sbp_ocb *ocb)
1299 struct sbp_softc *sc = sdev->target->sbp;
1305 sdev->bustgtlun, (uint32_t)ocb->bus_addr);
1308 if ((sdev->flags & ORB_POINTER_ACTIVE) != 0) {
1312 sdev->flags |= ORB_POINTER_NEED;
1316 sdev->flags |= ORB_POINTER_ACTIVE;
1317 xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0x08);
1339 struct sbp_dev *sdev = (struct sbp_dev *)xfer->sc;
1340 struct sbp_softc *sc = sdev->target->sbp;
1344 sdev->bustgtlun);
1351 sdev->flags &= ~ORB_DOORBELL_ACTIVE;
1352 if ((sdev->flags & ORB_DOORBELL_NEED) != 0) {
1353 sdev->flags &= ~ORB_DOORBELL_NEED;
1354 sbp_doorbell(sdev);
1360 sbp_doorbell(struct sbp_dev *sdev)
1366 printf("%s:%s:%s\n", device_xname(sdev->target->sbp->sc_fd.dev),
1367 __func__, sdev->bustgtlun);
1370 if ((sdev->flags & ORB_DOORBELL_ACTIVE) != 0) {
1371 sdev->flags |= ORB_DOORBELL_NEED;
1374 sdev->flags |= ORB_DOORBELL_ACTIVE;
1375 xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0x10);
1386 sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
1394 target = sdev->target;
1434 xfer->sc = (void *)sdev;
1436 fp->mode.wreqq.dest_hi = sdev->login->cmd_hi;
1437 fp->mode.wreqq.dest_lo = sdev->login->cmd_lo + offset;
1447 sbp_mgm_orb(struct sbp_dev *sdev, int func, struct sbp_ocb *aocb)
1455 target = sdev->target;
1470 if ((ocb = sbp_get_ocb(sdev)) == NULL) {
1477 ocb->sdev = sdev;
1481 ocb->orb[7] = htonl(SBP_DEV2ADDR(dv_unit, sdev->lun_id));
1484 printf("%s:%s:%s: %s\n", device_xname(sdev->target->sbp->sc_fd.dev),
1485 __func__, sdev->bustgtlun, orb_fun_name[(func>>16)&0xf]);
1495 ocb->orb[3] = htonl(sdev->dma.bus_addr + sbp_login_off);
1496 ocb->orb[4] = htonl(ORB_NOTIFY | sdev->lun_id);
1500 bus_dmamap_sync(sdev->dma.dma_tag, sdev->dma.dma_map,
1514 ocb->orb[4] = htonl(ORB_NOTIFY | func | sdev->login->id);
1521 STAILQ_INSERT_TAIL(&sdev->target->mgm_ocb_queue, ocb, ocb);
1529 xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0);
1535 fp->mode.wreqb.dest_hi = sdev->target->mgm_hi;
1536 fp->mode.wreqb.dest_lo = sdev->target->mgm_lo;
1544 SBP_ORB_DMA_SYNC(sdev->dma, ocb->index, BUS_DMASYNC_PREWRITE);
1557 device_xname(ocb->sdev->target->sbp->sc_fd.dev),
1583 ocb->sdev->bustgtlun,
1646 aprint_error_dev(ocb->sdev->target->sbp->sc_fd.dev,
1648 __func__, ocb->sdev->bustgtlun, sbp_cmd_status->status);
1656 struct sbp_dev *sdev;
1660 sdev = ocb->sdev;
1671 printf("%s:%s:%s\n", device_xname(sdev->target->sbp->sc_fd.dev),
1672 __func__, sdev->bustgtlun);
1692 memcpy(inq->vendor, sdev->vendor, sizeof(inq->vendor));
1693 memcpy(inq->product, sdev->product, sizeof(inq->product));
1694 memcpy(inq->revision + 2, sdev->revision,
1718 struct sbp_dev *sdev;
1764 sdev = target->luns[l];
1778 ocb = sbp_dequeue_ocb(sdev, sbp_status);
1782 sdev->bustgtlun, ntohl(sbp_status->orb_lo));
1788 __func__, sdev->bustgtlun);
1793 __func__, sdev->bustgtlun);
1806 device_xname(sc->sc_fd.dev), __func__, sdev->bustgtlun,
1811 printf("%s:%s\n", device_xname(sc->sc_fd.dev), sdev->bustgtlun);
1838 if (sdev->periph != NULL) {
1839 scsipi_periph_freeze(sdev->periph, 1);
1840 sdev->freeze++;
1861 const struct fwdma_alloc *dma = &sdev->dma;
1868 login_res = sdev->login;
1879 __func__, sdev->bustgtlun,
1885 sbp_busy_timeout(sdev);
1890 __func__, sdev->bustgtlun);
1891 sdev->status = SBP_DEV_RESET;
1896 login_res = sdev->login;
1902 __func__, sdev->bustgtlun,
1907 sbp_agent_reset(sdev);
1913 __func__, sdev->bustgtlun);
1915 sbp_login(sdev);
1919 sdev->status = SBP_DEV_RESET;
1922 sbp_busy_timeout(sdev);
1927 sbp_agent_reset(sdev);
1932 __func__, sdev->bustgtlun, orb_fun);
1935 sbp_mgm_orb(sdev, ORB_FUN_RUNQUEUE, NULL);
1938 sdev->timeout = 0;
1963 sbp_free_ocb(sdev, ocb);
1966 sbp_agent_reset(sdev);
1982 xfer->spd = uimin(sdev->target->fwdev->speed, max_speed);
2011 struct sbp_dev *sdev;
2020 sdev = target->luns[i];
2021 if (sdev == NULL)
2023 callout_stop(&sdev->login_callout);
2024 if (sdev->status >= SBP_DEV_TOATTACH &&
2025 sdev->status <= SBP_DEV_ATTACHED)
2026 sbp_mgm_orb(sdev, ORB_FUN_LGO, NULL);
2034 sbp_free_sdev(struct sbp_dev *sdev)
2036 struct sbp_softc *sc = sdev->target->sbp;
2039 if (sdev == NULL)
2042 bus_dmamap_destroy(sc->sc_dmat, sdev->ocb[i].dmamap);
2043 fwdma_free(sdev->dma.dma_tag, sdev->dma.dma_map, sdev->dma.v_addr);
2044 free(sdev, M_SBP);
2072 sbp_scsipi_detach_sdev(struct sbp_dev *sdev)
2077 if (sdev == NULL)
2080 target = sdev->target;
2086 if (sdev->status == SBP_DEV_DEAD)
2088 if (sdev->status == SBP_DEV_RESET)
2090 if (sdev->periph != NULL) {
2091 scsipi_periph_thaw(sdev->periph, sdev->freeze);
2093 sdev->freeze = 0;
2095 target->target_id, sdev->lun_id, DETACH_FORCE) != 0) {
2098 sdev->periph = NULL;
2100 sbp_abort_all_ocbs(sdev, XS_DRIVER_STUFFUP);
2123 sbp_target_reset(struct sbp_dev *sdev, int method)
2125 struct sbp_target *target = sdev->target;
2137 if (sdev->periph != NULL) {
2148 sbp_mgm_orb(sdev, ORB_FUN_RST, NULL);
2152 sbp_reset_start(sdev);
2161 struct sbp_dev *sdev = ocb->sdev;
2162 struct sbp_target *target = sdev->target;
2164 aprint_error_dev(sdev->target->sbp->sc_fd.dev,
2166 __func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
2168 sbp_free_ocb(sdev, ocb);
2172 sbp_mgm_orb(sdev, ORB_FUN_RUNQUEUE, NULL);
2174 aprint_error_dev(sdev->target->sbp->sc_fd.dev,
2175 "%s:%s: reset start\n", __func__, sdev->bustgtlun);
2176 sbp_reset_start(sdev);
2183 struct sbp_dev *sdev = ocb->sdev;
2185 aprint_error_dev(sdev->target->sbp->sc_fd.dev,
2187 __func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
2189 sdev->timeout++;
2190 switch (sdev->timeout) {
2193 if (sdev->periph != NULL) {
2194 scsipi_periph_freeze(sdev->periph, 1);
2195 sdev->freeze++;
2197 sbp_abort_all_ocbs(sdev, XS_TIMEOUT);
2198 sbp_agent_reset(sdev);
2202 sbp_target_reset(sdev, sdev->timeout - 1);
2222 struct sbp_dev *sdev = NULL;
2227 /* target:lun -> sdev mapping */
2230 sdev = target->luns[xs->xs_periph->periph_lun];
2231 if (sdev != NULL && sdev->status != SBP_DEV_ATTACHED &&
2232 sdev->status != SBP_DEV_PROBE)
2233 sdev = NULL;
2236 if (sdev == NULL) {
2266 ocb = sbp_get_ocb(sdev);
2270 if (sdev->freeze == 0) {
2271 scsipi_periph_freeze(sdev->periph, 1);
2272 sdev->freeze++;
2279 ocb->sdev = sdev;
2361 struct sbp_softc *sc = ocb->sdev->target->sbp;
2368 prev = sbp_enqueue_ocb(ocb->sdev, ocb);
2369 SBP_ORB_DMA_SYNC(ocb->sdev->dma, ocb->index, BUS_DMASYNC_PREWRITE);
2372 if (ocb->sdev->last_ocb != NULL)
2373 sbp_doorbell(ocb->sdev);
2375 sbp_orb_pointer(ocb->sdev, ocb);
2378 if (prev == NULL || (ocb->sdev->flags & ORB_LINK_DEAD) != 0) {
2379 ocb->sdev->flags &= ~ORB_LINK_DEAD;
2380 sbp_orb_pointer(ocb->sdev, ocb);
2385 sbp_dequeue_ocb(struct sbp_dev *sdev, struct sbp_status *sbp_status)
2387 struct sbp_softc *sc = sdev->target->sbp;
2394 __func__, sdev->bustgtlun, ntohl(sbp_status->orb_lo),
2398 for (ocb = STAILQ_FIRST(&sdev->ocbs); ocb != NULL; ocb = next) {
2402 SBP_ORB_DMA_SYNC(sdev->dma, ocb->index,
2404 STAILQ_REMOVE(&sdev->ocbs, ocb, sbp_ocb, ocb);
2421 sbp_orb_pointer(sdev, next);
2428 sdev->flags |= ORB_LINK_DEAD;
2442 if (sdev->last_ocb != NULL)
2443 sbp_free_ocb(sdev, sdev->last_ocb);
2444 sdev->last_ocb = ocb;
2447 sbp_doorbell(sdev);
2453 device_xname(sc->sc_fd.dev), __func__, sdev->bustgtlun,
2460 sbp_enqueue_ocb(struct sbp_dev *sdev, struct sbp_ocb *ocb)
2462 struct sbp_softc *sc = sdev->target->sbp;
2467 __func__, sdev->bustgtlun, (uintmax_t)ocb->bus_addr);
2471 STAILQ_FOREACH(tocb, &sdev->ocbs, ocb)
2474 STAILQ_INSERT_TAIL(&sdev->ocbs, ocb, ocb);
2481 prev2 = sdev->last_ocb;
2502 sbp_get_ocb(struct sbp_dev *sdev)
2504 struct sbp_softc *sc = sdev->target->sbp;
2509 ocb = STAILQ_FIRST(&sdev->free_ocbs);
2511 sdev->flags |= ORB_SHORTAGE;
2516 STAILQ_REMOVE_HEAD(&sdev
2522 sbp_free_ocb(struct sbp_dev *sdev, struct sbp_ocb *ocb)
2524 struct sbp_softc *sc = sdev->target->sbp;
2531 STAILQ_INSERT_TAIL(&sdev->free_ocbs, ocb, ocb);
2533 if (sdev->flags & ORB_SHORTAGE) {
2534 sdev->flags &= ~ORB_SHORTAGE;
2535 count = sdev->freeze;
2536 sdev->freeze = 0;
2537 if (sdev->periph)
2538 scsipi_periph_thaw(sdev->periph, count);
2547 struct sbp_dev *sdev;
2549 sdev = ocb->sdev;
2550 sc = sdev->target->sbp;
2553 __func__, sdev->bustgtlun, (uintmax_t)ocb->bus_addr);
2572 sbp_free_ocb(sdev, ocb);
2576 sbp_abort_all_ocbs(struct sbp_dev *sdev, int status)
2578 struct sbp_softc *sc = sdev->target->sbp;
2584 STAILQ_CONCAT(&temp, &sdev->ocbs);
2585 STAILQ_INIT(&sdev->ocbs);
2592 if (sdev->last_ocb != NULL) {
2593 sbp_free_ocb(sdev, sdev->last_ocb);
2594 sdev->last_ocb = NULL;