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