Lines Matching full:target

83  *  2- 7( 6): target
178 struct sbp_target *target; member
339 fwdev = sdev->target->fwdev; in sbp_show_sdev_info()
340 device_printf(sdev->target->sbp->fd.dev, in sbp_show_sdev_info()
353 device_printf(sdev->target->sbp->fd.dev, in sbp_show_sdev_info()
364 int target; member
367 /* Bus Target EUI64 */
379 int bus, i, target=-1; in sbp_new_target() local
389 w[wired[i].target] = 1; in sbp_new_target()
392 target = wired[i].target; in sbp_new_target()
395 if (target >= 0) { in sbp_new_target()
396 if (target < SBP_NUM_TARGETS && in sbp_new_target()
397 sbp->targets[target].fwdev == NULL) in sbp_new_target()
398 return (target); in sbp_new_target()
400 "target %d is not free for %08x:%08x\n", in sbp_new_target()
401 target, fwdev->eui.hi, fwdev->eui.lo); in sbp_new_target()
402 target = -1; in sbp_new_target()
404 /* non-wired target */ in sbp_new_target()
407 target = i; in sbp_new_target()
411 return target; in sbp_new_target()
415 sbp_alloc_lun(struct sbp_target *target) in sbp_alloc_lun() argument
423 sbp = target->sbp; in sbp_alloc_lun()
424 crom_init_context(&cc, target->fwdev->csrrom); in sbp_alloc_lun()
433 printf("target %d lun %d found\n", target->target_id, lun); in sbp_alloc_lun()
440 device_printf(target->sbp->fd.dev, "%d no LUN found\n", in sbp_alloc_lun()
441 target->target_id); in sbp_alloc_lun()
448 for (lun = 0; lun < target->num_lun; lun++) { in sbp_alloc_lun()
449 sdev = target->luns[lun]; in sbp_alloc_lun()
457 target->luns[lun] = NULL; in sbp_alloc_lun()
462 if (maxlun != target->num_lun) { in sbp_alloc_lun()
463 newluns = (struct sbp_dev **) realloc(target->luns, in sbp_alloc_lun()
469 newluns = target->luns; in sbp_alloc_lun()
470 maxlun = target->num_lun; in sbp_alloc_lun()
477 if (maxlun > target->num_lun) in sbp_alloc_lun()
478 bzero(&newluns[target->num_lun], in sbp_alloc_lun()
480 (maxlun - target->num_lun)); in sbp_alloc_lun()
482 target->luns = newluns; in sbp_alloc_lun()
483 target->num_lun = maxlun; in sbp_alloc_lun()
486 crom_init_context(&cc, target->fwdev->csrrom); in sbp_alloc_lun()
499 sdev = target->luns[lun]; in sbp_alloc_lun()
507 target->luns[lun] = sdev; in sbp_alloc_lun()
509 sdev->target = target; in sbp_alloc_lun()
515 device_get_nameunit(sdev->target->sbp->fd.dev), in sbp_alloc_lun()
516 sdev->target->target_id, in sbp_alloc_lun()
533 target->luns[lun] = NULL; in sbp_alloc_lun()
564 for (lun = 0; lun < target->num_lun; lun++) { in sbp_alloc_lun()
565 sdev = target->luns[lun]; in sbp_alloc_lun()
569 target->luns[lun] = NULL; in sbp_alloc_lun()
578 struct sbp_target *target; in sbp_alloc_target() local
590 /* new target */ in sbp_alloc_target()
591 target = &sbp->targets[i]; in sbp_alloc_target()
592 target->fwdev = fwdev; in sbp_alloc_target()
593 target->target_id = i; in sbp_alloc_target()
596 crom_init_context(&cc, target->fwdev->csrrom); in sbp_alloc_target()
600 target->fwdev = NULL; in sbp_alloc_target()
603 target->mgm_hi = 0xffff; in sbp_alloc_target()
604 target->mgm_lo = 0xf0000000 | (reg->val << 2); in sbp_alloc_target()
605 target->mgm_ocb_cur = NULL; in sbp_alloc_target()
607 printf("target:%d mgm_port: %x\n", i, target->mgm_lo); in sbp_alloc_target()
609 STAILQ_INIT(&target->xferlist); in sbp_alloc_target()
610 target->n_xfer = 0; in sbp_alloc_target()
611 STAILQ_INIT(&target->mgm_ocb_queue); in sbp_alloc_target()
612 callout_init_mtx(&target->mgm_ocb_timeout, &sbp->mtx, 0); in sbp_alloc_target()
613 callout_init_mtx(&target->scan_callout, &sbp->mtx, 0); in sbp_alloc_target()
615 target->luns = NULL; in sbp_alloc_target()
616 target->num_lun = 0; in sbp_alloc_target()
617 return target; in sbp_alloc_target()
630 fwdev = sdev->target->fwdev; in sbp_probe_lun()
657 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_login_callout()
669 timevalsub(&delta, &sdev->target->sbp->last_busreset); in sbp_login()
687 sbp_probe_target(struct sbp_target *target) in sbp_probe_target() argument
689 struct sbp_softc *sbp = target->sbp; in sbp_probe_target()
693 alive = SBP_FWDEV_ALIVE(target->fwdev); in sbp_probe_target()
696 __func__, target->target_id, in sbp_probe_target()
700 sbp_alloc_lun(target); in sbp_probe_target()
703 for (i=0; i < target->num_lun; i++) { in sbp_probe_target()
704 sdev = target->luns[i]; in sbp_probe_target()
720 /* new or revived target */ in sbp_probe_target()
737 device_printf(sbp->fd.dev, "%s: lost target\n", in sbp_probe_target()
747 target->luns[i] = NULL; in sbp_probe_target()
784 struct sbp_target *target; in sbp_post_explore() local
802 target = &sbp->targets[i]; in sbp_post_explore()
803 if (target->fwdev == NULL) in sbp_post_explore()
807 if (target->fwdev == fwdev) in sbp_post_explore()
811 sbp_cam_detach_target(target); in sbp_post_explore()
812 sbp_free_target(target); in sbp_post_explore()
826 target = &sbp->targets[i]; in sbp_post_explore()
827 if (target->fwdev == fwdev) { in sbp_post_explore()
828 /* known target */ in sbp_post_explore()
834 /* new target */ in sbp_post_explore()
835 target = sbp_alloc_target(sbp, fwdev); in sbp_post_explore()
836 if (target == NULL) in sbp_post_explore()
844 * It is safe to drop the lock here as the target is already in sbp_post_explore()
846 * And the target is not yet exposed, so there should not be in sbp_post_explore()
851 sbp_probe_target(target); in sbp_post_explore()
853 if (target->num_lun == 0) in sbp_post_explore()
854 sbp_free_target(target); in sbp_post_explore()
870 device_printf(sdev->target->sbp->fd.dev,"%s\n", __func__); in sbp_loginres_callback()
873 SBP_LOCK(sdev->target->sbp); in sbp_loginres_callback()
874 STAILQ_INSERT_TAIL(&sdev->target->sbp->fwb.xferlist, xfer, link); in sbp_loginres_callback()
875 SBP_UNLOCK(sdev->target->sbp); in sbp_loginres_callback()
887 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_xfer_free()
888 STAILQ_INSERT_TAIL(&sdev->target->xferlist, xfer, link); in sbp_xfer_free()
895 struct sbp_target *target = sdev->target; in sbp_reset_start_callback() local
899 device_printf(sdev->target->sbp->fd.dev, in sbp_reset_start_callback()
903 SBP_LOCK(target->sbp); in sbp_reset_start_callback()
904 for (i = 0; i < target->num_lun; i++) { in sbp_reset_start_callback()
905 tsdev = target->luns[i]; in sbp_reset_start_callback()
909 SBP_UNLOCK(target->sbp); in sbp_reset_start_callback()
919 device_printf(sdev->target->sbp->fd.dev, in sbp_reset_start()
940 device_printf(sdev->target->sbp->fd.dev, in sbp_mgm_callback()
943 SBP_LOCK(sdev->target->sbp); in sbp_mgm_callback()
945 SBP_UNLOCK(sdev->target->sbp); in sbp_mgm_callback()
949 sbp_next_dev(struct sbp_target *target, int lun) in sbp_next_dev() argument
954 for (i = lun, sdevp = &target->luns[lun]; i < target->num_lun; in sbp_next_dev()
966 struct sbp_target *target; in sbp_cam_scan_lun() local
970 target = sdev->target; in sbp_cam_scan_lun()
971 sbp = target->sbp; in sbp_cam_scan_lun()
983 sdev = sbp_next_dev(target, sdev->lun_id + 1); in sbp_cam_scan_lun()
1003 struct sbp_target *target = (struct sbp_target *)arg; in sbp_cam_scan_target() local
1007 SBP_LOCK_ASSERT(target->sbp); in sbp_cam_scan_target()
1008 sdev = sbp_next_dev(target, 0); in sbp_cam_scan_target()
1010 printf("sbp_cam_scan_target: nothing to do for target%d\n", in sbp_cam_scan_target()
1011 target->target_id); in sbp_cam_scan_target()
1015 device_printf(sdev->target->sbp->fd.dev, in sbp_cam_scan_target()
1023 SBP_UNLOCK(target->sbp); in sbp_cam_scan_target()
1035 SBP_LOCK(target->sbp); in sbp_cam_scan_target()
1044 callout_reset_sbt(&sdev->target->scan_callout, SBT_1MS * scan_delay, 0, in sbp_scan_dev()
1045 sbp_cam_scan_target, (void *)sdev->target, 0); in sbp_scan_dev()
1052 struct sbp_target *target; in sbp_do_attach() local
1056 target = sdev->target; in sbp_do_attach()
1057 sbp = target->sbp; in sbp_do_attach()
1060 device_printf(sdev->target->sbp->fd.dev, in sbp_do_attach()
1067 cam_sim_path(target->sbp->sim), in sbp_do_attach()
1068 target->target_id, sdev->lun_id); in sbp_do_attach()
1092 device_printf(sdev->target->sbp->fd.dev, in sbp_agent_reset_callback()
1096 device_printf(sdev->target->sbp->fd.dev, in sbp_agent_reset_callback()
1100 SBP_LOCK(sdev->target->sbp); in sbp_agent_reset_callback()
1106 SBP_UNLOCK(sdev->target->sbp); in sbp_agent_reset_callback()
1115 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_agent_reset()
1117 device_printf(sdev->target->sbp->fd.dev, in sbp_agent_reset()
1140 device_printf(sdev->target->sbp->fd.dev, in sbp_busy_timeout_callback()
1143 SBP_LOCK(sdev->target->sbp); in sbp_busy_timeout_callback()
1146 SBP_UNLOCK(sdev->target->sbp); in sbp_busy_timeout_callback()
1155 device_printf(sdev->target->sbp->fd.dev, in sbp_busy_timeout()
1175 device_printf(sdev->target->sbp->fd.dev, in sbp_orb_pointer_callback()
1182 SBP_LOCK(sdev->target->sbp); in sbp_orb_pointer_callback()
1195 SBP_UNLOCK(sdev->target->sbp); in sbp_orb_pointer_callback()
1205 device_printf(sdev->target->sbp->fd.dev, in sbp_orb_pointer()
1211 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_orb_pointer()
1231 htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS) << 16)); in sbp_orb_pointer()
1248 device_printf(sdev->target->sbp->fd.dev, in sbp_doorbell_callback()
1253 device_printf(sdev->target->sbp->fd.dev, in sbp_doorbell_callback()
1256 SBP_LOCK(sdev->target->sbp); in sbp_doorbell_callback()
1263 SBP_UNLOCK(sdev->target->sbp); in sbp_doorbell_callback()
1272 device_printf(sdev->target->sbp->fd.dev, in sbp_doorbell()
1295 struct sbp_target *target; in sbp_write_cmd() local
1298 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_write_cmd()
1300 target = sdev->target; in sbp_write_cmd()
1301 xfer = STAILQ_FIRST(&target->xferlist); in sbp_write_cmd()
1303 if (target->n_xfer > 5 /* XXX */) { in sbp_write_cmd()
1304 printf("sbp: no more xfer for this target\n"); in sbp_write_cmd()
1312 target->n_xfer++; in sbp_write_cmd()
1314 printf("sbp: alloc %d xfer\n", target->n_xfer); in sbp_write_cmd()
1317 STAILQ_REMOVE_HEAD(&target->xferlist, link); in sbp_write_cmd()
1322 xfer->send.spd = min(sdev->target->fwdev->speed, max_speed); in sbp_write_cmd()
1323 xfer->fc = sdev->target->sbp->fd.fc; in sbp_write_cmd()
1338 fp->mode.wreqq.dst = FWLOCALBUS | sdev->target->fwdev->dst; in sbp_write_cmd()
1349 struct sbp_target *target; in sbp_mgm_orb() local
1352 target = sdev->target; in sbp_mgm_orb()
1353 nid = target->sbp->fd.fc->nodeid | FWLOCALBUS; in sbp_mgm_orb()
1355 SBP_LOCK_ASSERT(target->sbp); in sbp_mgm_orb()
1357 ocb = STAILQ_FIRST(&target->mgm_ocb_queue); in sbp_mgm_orb()
1358 if (target->mgm_ocb_cur != NULL || ocb == NULL) { in sbp_mgm_orb()
1361 STAILQ_REMOVE_HEAD(&target->mgm_ocb_queue, ocb); in sbp_mgm_orb()
1373 ocb->orb[7] = htonl(SBP_DEV2ADDR(target->target_id, sdev->lun_id)); in sbp_mgm_orb()
1376 device_printf(sdev->target->sbp->fd.dev, in sbp_mgm_orb()
1405 if (target->mgm_ocb_cur != NULL) { in sbp_mgm_orb()
1407 STAILQ_INSERT_TAIL(&sdev->target->mgm_ocb_queue, ocb, ocb); in sbp_mgm_orb()
1411 target->mgm_ocb_cur = ocb; in sbp_mgm_orb()
1413 callout_reset(&target->mgm_ocb_timeout, 5 * hz, in sbp_mgm_orb()
1422 fp->mode.wreqb.dest_hi = sdev->target->mgm_hi; in sbp_mgm_orb()
1423 fp->mode.wreqb.dest_lo = sdev->target->mgm_lo; in sbp_mgm_orb()
1442 device_get_nameunit(ocb->sdev->target->sbp->fd.dev), in sbp_print_scsi_cmd()
1540 device_printf(ocb->sdev->target->sbp->fd.dev, in sbp_scsi_status()
1560 device_printf(sdev->target->sbp->fd.dev, in sbp_fix_inq_data()
1610 struct sbp_target *target; in sbp_recv1() local
1644 "sbp_recv1: invalid target %d\n", t); in sbp_recv1()
1647 target = &sbp->targets[t]; in sbp_recv1()
1649 if (l >= target->num_lun || target->luns[l] == NULL) { in sbp_recv1()
1651 "sbp_recv1: invalid lun %d (target=%d)\n", l, t); in sbp_recv1()
1654 sdev = target->luns[l]; in sbp_recv1()
1661 ocb = target->mgm_ocb_cur; in sbp_recv1()
1664 callout_stop(&target->mgm_ocb_timeout); in sbp_recv1()
1665 target->mgm_ocb_cur = NULL; in sbp_recv1()
1671 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1679 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1684 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1697 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1705 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1763 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1773 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1783 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1796 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1815 device_printf(sdev->target->sbp->fd.dev, in sbp_recv1()
1868 xfer->spd = min(sdev->target->fwdev->speed, max_speed); in sbp_recv1()
2010 struct sbp_target *target; in sbp_logout_all() local
2019 target = &sbp->targets[i]; in sbp_logout_all()
2020 if (target->luns == NULL) in sbp_logout_all()
2022 for (j = 0; j < target->num_lun; j++) { in sbp_logout_all()
2023 sdev = target->luns[j]; in sbp_logout_all()
2055 sbp = sdev->target->sbp; in sbp_free_sdev()
2068 sbp_free_target(struct sbp_target *target) in sbp_free_target() argument
2074 if (target->luns == NULL) in sbp_free_target()
2076 sbp = target->sbp; in sbp_free_target()
2079 callout_drain(&target->mgm_ocb_timeout); in sbp_free_target()
2080 callout_drain(&target->scan_callout); in sbp_free_target()
2082 for (i = 0; i < target->num_lun; i++) in sbp_free_target()
2083 sbp_free_sdev(target->luns[i]); in sbp_free_target()
2085 STAILQ_FOREACH_SAFE(xfer, &target->xferlist, link, next) { in sbp_free_target()
2088 STAILQ_INIT(&target->xferlist); in sbp_free_target()
2089 free(target->luns, M_SBP); in sbp_free_target()
2090 target->num_lun = 0; in sbp_free_target()
2091 target->luns = NULL; in sbp_free_target()
2092 target->fwdev = NULL; in sbp_free_target()
2144 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_cam_detach_sdev()
2157 sbp_cam_detach_target(struct sbp_target *target) in sbp_cam_detach_target() argument
2161 SBP_LOCK_ASSERT(target->sbp); in sbp_cam_detach_target()
2162 if (target->luns != NULL) { in sbp_cam_detach_target()
2164 printf("sbp_detach_target %d\n", target->target_id); in sbp_cam_detach_target()
2166 callout_stop(&target->scan_callout); in sbp_cam_detach_target()
2167 for (i = 0; i < target->num_lun; i++) in sbp_cam_detach_target()
2168 sbp_cam_detach_sdev(target->luns[i]); in sbp_cam_detach_target()
2176 struct sbp_target *target = sdev->target; in sbp_target_reset() local
2179 SBP_LOCK_ASSERT(target->sbp); in sbp_target_reset()
2180 for (i = 0; i < target->num_lun; i++) { in sbp_target_reset()
2181 tsdev = target->luns[i]; in sbp_target_reset()
2196 printf("target reset\n"); in sbp_target_reset()
2212 struct sbp_target *target = sdev->target; in sbp_mgm_timeout() local
2214 SBP_LOCK_ASSERT(target->sbp); in sbp_mgm_timeout()
2215 device_printf(sdev->target->sbp->fd.dev, in sbp_mgm_timeout()
2218 target->mgm_ocb_cur = NULL; in sbp_mgm_timeout()
2225 device_printf(sdev->target->sbp->fd.dev, in sbp_mgm_timeout()
2237 device_printf(sdev->target->sbp->fd.dev, in sbp_timeout()
2241 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_timeout()
2258 sbp_cam_detach_target(target); in sbp_timeout()
2259 if (target->luns != NULL) in sbp_timeout()
2260 free(target->luns, M_SBP); in sbp_timeout()
2261 target->num_lun = 0; in sbp_timeout()
2262 target->luns = NULL; in sbp_timeout()
2263 target->fwdev = NULL; in sbp_timeout()
2273 struct sbp_target *target = NULL; in sbp_action() local
2278 /* target:lun -> sdev mapping */ in sbp_action()
2282 target = &sbp->targets[ccb->ccb_h.target_id]; in sbp_action()
2283 if (target->fwdev != NULL in sbp_action()
2285 && ccb->ccb_h.target_lun < target->num_lun) { in sbp_action()
2286 sdev = target->luns[ccb->ccb_h.target_lun]; in sbp_action()
2295 printf("invalid target %d lun %jx\n", in sbp_action()
2308 "Invalid target (target needed)\n", in sbp_action()
2322 /* The opcodes sometimes aimed at a target (sc is valid), in sbp_action()
2323 * sometimes aimed at the SIM (sc is invalid and target is in sbp_action()
2330 "Invalid target (no wildcard)\n", in sbp_action()
2419 speed = min(target->fwdev->speed, max_speed); in sbp_action()
2605 bus_dmamap_sync(ocb->sdev->target->sbp->dmat, ocb->dmamap, in sbp_execute_ocb()
2647 device_printf(sdev->target->sbp->fd.dev, in sbp_dequeue_ocb()
2651 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_dequeue_ocb()
2659 bus_dmamap_sync(sdev->target->sbp->dmat, in sbp_dequeue_ocb()
2664 bus_dmamap_unload(sdev->target->sbp->dmat, in sbp_dequeue_ocb()
2699 device_printf(sdev->target->sbp->fd.dev, in sbp_dequeue_ocb()
2712 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_enqueue_ocb()
2714 device_printf(sdev->target->sbp->fd.dev, in sbp_enqueue_ocb()
2751 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_get_ocb()
2769 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_free_ocb()
2787 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_abort_ocb()
2789 device_printf(sdev->target->sbp->fd.dev, in sbp_abort_ocb()
2797 bus_dmamap_sync(sdev->target->sbp->dmat, ocb->dmamap, in sbp_abort_ocb()
2800 bus_dmamap_unload(sdev->target->sbp->dmat, ocb->dmamap); in sbp_abort_ocb()
2817 SBP_LOCK_ASSERT(sdev->target->sbp); in sbp_abort_all_ocbs()