FreeBSD/sys/cam/ctl/ctl.c
/*
 * Front end should call this if it doesn't do autosense.  When the request
 * sense comes back in from the initiator, we'll dequeue this and send it.
 */
Front end should call this if it doesn't do autosense.  When the request
sense comes back in from the initiator, we'll dequeue this and send it.
Front end should call this if it doesn ' t do autosense . When the request sense comes back in from the initiator we ' ll dequeue this and send it .
int
ctl_queue_sense(union ctl_io *io)
{
	struct ctl_lun *lun;
	struct ctl_port *port;
	struct ctl_softc *softc;
	uint32_t initidx, targ_lun;
	softc = control_softc;
	CTL_DEBUG_PRINT(("ctl_queue_sense\n"));
	mtx_lock(&softc->ctl_lock);
	port = ctl_io_port(&ctsio->io_hdr);
	targ_lun = ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun);
	if ((targ_lun < CTL_MAX_LUNS)
	 && (softc->ctl_luns[targ_lun] != NULL))
		lun = softc->ctl_luns[targ_lun];
	else
		goto bailout;
	initidx = ctl_get_initindex(&io->io_hdr.nexus);
	mtx_lock(&lun->lun_lock);
	if (ctl_is_set(lun->have_ca, initidx)) {
		mtx_unlock(&lun->lun_lock);
		goto bailout;
	}
	memcpy(&lun->pending_sense[initidx], &io->scsiio.sense_data,
	       MIN(sizeof(lun->pending_sense[initidx]),
	       sizeof(io->scsiio.sense_data)));
	ctl_set_mask(lun->have_ca, initidx);
	mtx_unlock(&lun->lun_lock);
bailout:
	mtx_unlock(&softc->ctl_lock);
	ctl_free_io(io);
	return (CTL_RETVAL_COMPLETE);
}
int ctl_queue_sense ( union ctl_io * io ) { struct ctl_lun * lun ; struct ctl_port * port ; struct ctl_softc * softc ; uint32_t initidx , targ_lun ; softc = control_softc ; CTL_DEBUG_PRINT ( ( " \n " ) ) ; mtx_lock ( & softc -> ctl_lock ) ; port = ctl_io_port ( & ctsio -> io_hdr ) ; targ_lun = ctl_lun_map_from_port ( port , io -> io_hdr . nexus . targ_lun ) ; if ( ( targ_lun < CTL_MAX_LUNS ) && ( softc -> ctl_luns [ targ_lun ] != NULL ) ) lun = softc -> ctl_luns [ targ_lun ] ; else goto bailout ; initidx = ctl_get_initindex ( & io -> io_hdr . nexus ) ; mtx_lock ( & lun -> lun_lock ) ; if ( ctl_is_set ( lun -> have_ca , initidx ) ) { mtx_unlock ( & lun -> lun_lock ) ; goto bailout ; } memcpy ( & lun -> pending_sense [ initidx ] , & io -> scsiio . sense_data , MIN ( sizeof ( lun -> pending_sense [ initidx ] ) , sizeof ( io -> scsiio . sense_data ) ) ) ; ctl_set_mask ( lun -> have_ca , initidx ) ; mtx_unlock ( & lun -> lun_lock ) ; bailout : mtx_unlock ( & softc -> ctl_lock ) ; ctl_free_io ( io ) ; return ( CTL_RETVAL_COMPLETE ) ; }
Front end should call this if it doesn't do autosense.
Front end should call this if it doesn ' t do autosense .
/*
	 * LUN lookup will likely move to the ctl_work_thread() once we
	 * have our new queueing infrastructure (that doesn't put things on
	 * a per-LUN queue initially).  That is so that we can handle
	 * things like an INQUIRY to a LUN that we don't have enabled.  We
	 * can't deal with that right now.
	 */ /*
	 * If we don't have a LUN for this, just toss the sense
	 * information.
	 */ /*
	 * Already have CA set for this LUN...toss the sense information.
	 */