FreeBSD/sys/cam/scsi/scsi_target.c
/* Completion routine for CCBs (called at splsoftcam) */
Completion routine for CCBs (called at splsoftcam)
Completion routine for CCBs ( called at splsoftcam )
static void
targdone(struct cam_periph *periph, union ccb *done_ccb)
{
	struct targ_softc *softc;
	cam_status status;
	CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("targdone %p\n", done_ccb));
	softc = (struct targ_softc *)periph->softc;
	TAILQ_REMOVE(&softc->pending_ccb_queue, &done_ccb->ccb_h,
		     periph_links.tqe);
	status = done_ccb->ccb_h.status & CAM_STATUS_MASK;
	if ((softc->state & TARG_STATE_LUN_ENABLED) == 0) {
		targfreeccb(softc, done_ccb);
		return;
	}
	if (TAILQ_EMPTY(&softc->pending_ccb_queue))
		wakeup(&softc->pending_ccb_queue);
	switch (done_ccb->ccb_h.func_code) {
	case XPT_IMMED_NOTIFY:
	case XPT_IMMEDIATE_NOTIFY:
	case XPT_ACCEPT_TARGET_IO:
	case XPT_CONT_TARGET_IO:
		TAILQ_INSERT_TAIL(&softc->user_ccb_queue, &done_ccb->ccb_h,
				  periph_links.tqe);
 		cam_periph_unlock(softc->periph);
		notify_user(softc);
 		cam_periph_lock(softc->periph);
		break;
	default:
		panic("targdone: impossible xpt opcode %#x",
		      done_ccb->ccb_h.func_code);
	}
}
static void targdone ( struct cam_periph * periph , union ccb * done_ccb ) { struct targ_softc * softc ; cam_status status ; CAM_DEBUG ( periph -> path , CAM_DEBUG_PERIPH , ( " \n " , done_ccb ) ) ; softc = ( struct targ_softc * ) periph -> softc ; TAILQ_REMOVE ( & softc -> pending_ccb_queue , & done_ccb -> ccb_h , periph_links . tqe ) ; status = done_ccb -> ccb_h . status & CAM_STATUS_MASK ; if ( ( softc -> state & TARG_STATE_LUN_ENABLED ) == 0 ) { targfreeccb ( softc , done_ccb ) ; return ; } if ( TAILQ_EMPTY ( & softc -> pending_ccb_queue ) ) wakeup ( & softc -> pending_ccb_queue ) ; switch ( done_ccb -> ccb_h . func_code ) { case XPT_IMMED_NOTIFY : case XPT_IMMEDIATE_NOTIFY : case XPT_ACCEPT_TARGET_IO : case XPT_CONT_TARGET_IO : TAILQ_INSERT_TAIL ( & softc -> user_ccb_queue , & done_ccb -> ccb_h , periph_links . tqe ) ; cam_periph_unlock ( softc -> periph ) ; notify_user ( softc ) ; cam_periph_lock ( softc -> periph ) ; break ; default : panic ( " " , done_ccb -> ccb_h . func_code ) ; } }
Completion routine for CCBs (called at splsoftcam)
Completion routine for CCBs ( called at splsoftcam )
/* If we're no longer enabled, throw away CCB */ /* abort_all_pending() waits for pending queue to be empty */ /* All FC_*_QUEUED CCBs go back to userland */ /* NOTREACHED */