• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/sys/cam/scsi/

Lines Matching refs:softc

73 	TARG_STATE_OPENED	= 0x01, /* Device opened, softc initialized */
130 static cam_status targenable(struct targ_softc *softc,
133 static cam_status targdisable(struct targ_softc *softc);
137 static int targusermerge(struct targ_softc *softc,
140 static int targsendccb(struct targ_softc *softc, union ccb *ccb,
144 static int targreturnccb(struct targ_softc *softc,
146 static union ccb * targgetccb(struct targ_softc *softc, xpt_opcode type,
148 static void targfreeccb(struct targ_softc *softc, union ccb *ccb);
150 targgetdescr(struct targ_softc *softc);
154 static void abort_all_pending(struct targ_softc *softc);
155 static void notify_user(struct targ_softc *softc);
168 /* Disable LUN if enabled and teardown softc */
172 struct targ_softc *softc;
175 softc = data;
176 if (softc->periph == NULL) {
178 free(softc, M_TARG);
186 periph = softc->periph;
189 (void)targdisable(softc);
190 if (softc->periph != NULL) {
191 cam_periph_invalidate(softc->periph);
192 softc->periph = NULL;
196 free(softc, M_TARG);
200 * Create softc and initialize it. There is no locking here because a
207 struct targ_softc *softc;
209 /* Allocate its softc, initialize it */
210 softc = malloc(sizeof(*softc), M_TARG,
212 softc->state = TARG_STATE_OPENED;
213 softc->periph = NULL;
214 softc->path = NULL;
216 TAILQ_INIT(&softc->pending_ccb_queue);
217 TAILQ_INIT(&softc->work_queue);
218 TAILQ_INIT(&softc->abort_queue);
219 TAILQ_INIT(&softc->user_ccb_queue);
220 knlist_init_mtx(&softc->read_select.si_note, NULL);
222 devfs_set_cdevpriv(softc, targcdevdtor);
230 struct targ_softc *softc;
233 devfs_get_cdevpriv((void **)&softc);
251 status = targenable(softc, path, new_lun->grp6_len,
258 if (softc->periph == NULL) {
262 cam_periph_lock(softc->periph);
263 status = targdisable(softc);
264 cam_periph_unlock(softc->periph);
271 if ((softc->state & TARG_STATE_LUN_ENABLED) == 0) {
280 xpt_setup_ccb(&cdbg.ccb_h, softc->path, CAM_PRIORITY_NORMAL);
299 struct targ_softc *softc;
302 devfs_get_cdevpriv((void **)&softc);
308 cam_periph_lock(softc->periph);
309 if (!TAILQ_EMPTY(&softc->user_ccb_queue) ||
310 !TAILQ_EMPTY(&softc->abort_queue)) {
313 cam_periph_unlock(softc->periph);
316 selrecord(td, &softc->read_select);
325 struct targ_softc *softc;
327 devfs_get_cdevpriv((void **)&softc);
328 kn->kn_hook = (caddr_t)softc;
330 knlist_add(&softc->read_select.si_note, kn, 0);
337 struct targ_softc *softc;
339 softc = (struct targ_softc *)kn->kn_hook;
340 knlist_remove(&softc->read_select.si_note, kn, 0);
347 struct targ_softc *softc;
350 softc = (struct targ_softc *)kn->kn_hook;
351 cam_periph_lock(softc->periph);
352 retval = !TAILQ_EMPTY(&softc->user_ccb_queue) ||
353 !TAILQ_EMPTY(&softc->abort_queue);
354 cam_periph_unlock(softc->periph);
383 targenable(struct targ_softc *softc, struct cam_path *path, int grp6_len,
390 if ((softc->state & TARG_STATE_LUN_ENABLED) != 0)
406 softc->maxio = DFLTPHYS; /* traditional default */
408 softc->maxio = maxphys; /* for safety */
410 softc->maxio = cpi.maxio; /* real value */
417 del_softc = (struct targ_softc *)periph->softc;
431 "targ", CAM_PERIPH_BIO, path, targasync, 0, softc);
449 softc->state |= TARG_STATE_LUN_ENABLED;
455 /* Disable this softc's target instance if enabled */
457 targdisable(struct targ_softc *softc)
461 if ((softc->state & TARG_STATE_LUN_ENABLED) == 0)
464 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("targdisable\n"));
467 abort_all_pending(softc);
470 status = targendislun(softc->path, /*enable*/0,
473 softc->state &= ~TARG_STATE_LUN_ENABLED;
484 struct targ_softc *softc;
486 /* Store pointer to softc for periph-driven routines */
487 softc = (struct targ_softc *)arg;
488 periph->softc = softc;
489 softc->periph = periph;
490 softc->path = periph->path;
497 struct targ_softc *softc;
501 softc = (struct targ_softc *)periph->softc;
508 while ((ccb_h = TAILQ_FIRST(&softc->user_ccb_queue)) != NULL) {
509 TAILQ_REMOVE(&softc->user_ccb_queue, ccb_h, periph_links.tqe);
510 targfreeccb(softc, (union ccb *)ccb_h);
512 while ((descr = TAILQ_FIRST(&softc->abort_queue)) != NULL) {
513 TAILQ_REMOVE(&softc->abort_queue, descr, tqe);
517 softc->periph = NULL;
518 softc->path = NULL;
519 periph->softc = NULL;
527 struct targ_softc *softc;
532 devfs_get_cdevpriv((void **)&softc);
534 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
541 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
555 cam_periph_lock(softc->periph);
556 ccb = targgetccb(softc, func_code, priority);
560 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
563 TAILQ_INSERT_TAIL(&softc->pending_ccb_queue,
566 cam_periph_unlock(softc->periph);
569 cam_periph_lock(softc->periph);
571 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
574 descr = targgetdescr(softc);
578 TAILQ_INSERT_TAIL(&softc->work_queue,
580 xpt_schedule(softc->periph, priority);
582 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
585 ccb = targgetccb(softc, func_code, priority);
591 if (targusermerge(softc, descr, ccb) != EFAULT)
592 targsendccb(softc, ccb, descr);
593 targreturnccb(softc, ccb);
595 cam_periph_unlock(softc->periph);
618 struct targ_softc *softc;
622 softc = (struct targ_softc *)periph->softc;
623 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("targstart %p\n", start_ccb));
625 descr = TAILQ_FIRST(&softc->work_queue);
629 TAILQ_REMOVE(&softc->work_queue, descr, tqe);
630 next_descr = TAILQ_FIRST(&softc->work_queue);
633 error = targusermerge(softc, descr, start_ccb);
635 error = targsendccb(softc, start_ccb, descr);
642 TAILQ_INSERT_TAIL(&softc->abort_queue, descr, tqe);
643 notify_user(softc);
653 targusermerge(struct targ_softc *softc, struct targ_cmd_descr *descr,
667 xpt_setup_ccb(k_ccbh, softc->path, descr->priority);
685 TAILQ_FOREACH(ccb_h, &softc->pending_ccb_queue,
691 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
710 targsendccb(struct targ_softc *softc, union ccb *ccb,
732 error = cam_periph_mapmem(ccb, mapinfo, softc->maxio);
749 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("sendccb %p\n", ccb));
751 TAILQ_INSERT_TAIL(&softc->pending_ccb_queue, ccb_h,
763 struct targ_softc *softc;
767 softc = (struct targ_softc *)periph->softc;
768 TAILQ_REMOVE(&softc->pending_ccb_queue, &done_ccb->ccb_h,
773 if ((softc->state & TARG_STATE_LUN_ENABLED) == 0) {
774 targfreeccb(softc, done_ccb);
778 if (TAILQ_EMPTY(&softc->pending_ccb_queue))
779 wakeup(&softc->pending_ccb_queue);
787 TAILQ_INSERT_TAIL(&softc->user_ccb_queue, &done_ccb->ccb_h,
789 cam_periph_unlock(softc->periph);
790 notify_user(softc);
791 cam_periph_lock(softc->periph);
806 struct targ_softc *softc;
814 devfs_get_cdevpriv((void **)&softc);
815 user_queue = &softc->user_ccb_queue;
816 abort_queue = &softc->abort_queue;
817 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("targread\n"));
820 cam_periph_lock(softc->periph);
825 error = cam_periph_sleep(softc->periph, user_queue,
837 cam_periph_unlock(softc->periph);
851 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
853 error = targreturnccb(softc, (union ccb *)ccb_h);
856 cam_periph_unlock(softc->periph);
858 cam_periph_lock(softc->periph);
872 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
876 cam_periph_unlock(softc->periph);
878 cam_periph_lock(softc->periph);
895 cam_periph_unlock(softc->periph);
901 targreturnccb(struct targ_softc *softc, union ccb *ccb)
908 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("targreturnccb %p\n", ccb));
923 xpt_print(softc->path,
927 targfreeccb(softc, ccb);
933 targgetccb(struct targ_softc *softc, xpt_opcode type, int priority)
940 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("getccb %p\n", ccb));
944 xpt_setup_ccb(&ccb->ccb_h, softc->path, priority);
947 ccb->ccb_h.targ_descr = targgetdescr(softc);
956 targfreeccb(struct targ_softc *softc, union ccb *ccb)
985 targgetdescr(struct targ_softc *softc)
1016 abort_all_pending(struct targ_softc *softc)
1022 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("abort_all_pending\n"));
1025 while ((descr = TAILQ_FIRST(&softc->work_queue)) != NULL) {
1026 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
1028 TAILQ_REMOVE(&softc->work_queue, descr, tqe);
1029 TAILQ_INSERT_TAIL(&softc->abort_queue, descr, tqe);
1036 xpt_setup_ccb(&cab.ccb_h, softc->path, CAM_PRIORITY_NORMAL);
1039 TAILQ_FOREACH(ccb_h, &softc->pending_ccb_queue, periph_links.tqe) {
1040 CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
1053 cam_periph_sleep(softc->periph, &softc->pending_ccb_queue,
1058 if (!TAILQ_EMPTY(&softc->user_ccb_queue)
1059 || !TAILQ_EMPTY(&softc->abort_queue)) {
1060 cam_periph_unlock(softc->periph);
1061 notify_user(softc);
1062 cam_periph_lock(softc->periph);
1068 notify_user(struct targ_softc *softc)
1074 selwakeuppri(&softc->read_select, PRIBIO);
1075 KNOTE_UNLOCKED(&softc->read_select.si_note, 0);
1076 wakeup(&softc->user_ccb_queue);