Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
Show First 20 Lines • Show All 2,089 Lines • ▼ Show 20 Lines | |||||
storvsc_io_done(struct hv_storvsc_request *reqp) | storvsc_io_done(struct hv_storvsc_request *reqp) | ||||
{ | { | ||||
union ccb *ccb = reqp->ccb; | union ccb *ccb = reqp->ccb; | ||||
struct ccb_scsiio *csio = &ccb->csio; | struct ccb_scsiio *csio = &ccb->csio; | ||||
struct storvsc_softc *sc = reqp->softc; | struct storvsc_softc *sc = reqp->softc; | ||||
struct vmscsi_req *vm_srb = &reqp->vstor_packet.u.vm_srb; | struct vmscsi_req *vm_srb = &reqp->vstor_packet.u.vm_srb; | ||||
bus_dma_segment_t *ori_sglist = NULL; | bus_dma_segment_t *ori_sglist = NULL; | ||||
int ori_sg_count = 0; | int ori_sg_count = 0; | ||||
const struct scsi_generic *cmd; | |||||
/* destroy bounce buffer if it is used */ | /* destroy bounce buffer if it is used */ | ||||
if (reqp->bounce_sgl_count) { | if (reqp->bounce_sgl_count) { | ||||
ori_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr; | ori_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr; | ||||
ori_sg_count = ccb->csio.sglist_cnt; | ori_sg_count = ccb->csio.sglist_cnt; | ||||
/* | /* | ||||
* If it is READ operation, we should copy back the data | * If it is READ operation, we should copy back the data | ||||
Show All 34 Lines | #ifdef notyet | ||||
* between this routine and the timer handler. | * between this routine and the timer handler. | ||||
* Note that we need to make sure reqp is not freed when timer | * Note that we need to make sure reqp is not freed when timer | ||||
* handler is using or will use it. | * handler is using or will use it. | ||||
*/ | */ | ||||
if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) { | if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) { | ||||
callout_drain(&reqp->callout); | callout_drain(&reqp->callout); | ||||
} | } | ||||
#endif | #endif | ||||
cmd = (const struct scsi_generic *) | |||||
((ccb->ccb_h.flags & CAM_CDB_POINTER) ? | |||||
csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); | |||||
ccb->ccb_h.status &= ~CAM_SIM_QUEUED; | ccb->ccb_h.status &= ~CAM_SIM_QUEUED; | ||||
ccb->ccb_h.status &= ~CAM_STATUS_MASK; | ccb->ccb_h.status &= ~CAM_STATUS_MASK; | ||||
int srb_status = SRB_STATUS(vm_srb->srb_status); | int srb_status = SRB_STATUS(vm_srb->srb_status); | ||||
if (vm_srb->scsi_status == SCSI_STATUS_OK) { | if (vm_srb->scsi_status == SCSI_STATUS_OK) { | ||||
const struct scsi_generic *cmd; | |||||
cmd = (const struct scsi_generic *) | |||||
((ccb->ccb_h.flags & CAM_CDB_POINTER) ? | |||||
csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); | |||||
if (srb_status != SRB_STATUS_SUCCESS) { | if (srb_status != SRB_STATUS_SUCCESS) { | ||||
/* | /* | ||||
* If there are errors, for example, invalid LUN, | * If there are errors, for example, invalid LUN, | ||||
* host will inform VM through SRB status. | * host will inform VM through SRB status. | ||||
*/ | */ | ||||
if (bootverbose) { | if (bootverbose) { | ||||
if (srb_status == SRB_STATUS_INVALID_LUN) { | if (srb_status == SRB_STATUS_INVALID_LUN) { | ||||
xpt_print(ccb->ccb_h.path, | xpt_print(ccb->ccb_h.path, | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | if (cmd->opcode == INQUIRY && | ||||
xpt_print(ccb->ccb_h.path, | xpt_print(ccb->ccb_h.path, | ||||
"storvsc upgrades " | "storvsc upgrades " | ||||
"SPC2 to SPC3\n"); | "SPC2 to SPC3\n"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
/** | |||||
* On Some Windows hosts TEST_UNIT_READY command can return | |||||
* SRB_STATUS_ERROR and sense data, for example, asc=0x3a,1 | |||||
* "(Medium not present - tray closed)". This error can be | |||||
* ignored since it will be sent to host periodically. | |||||
*/ | |||||
boolean_t unit_not_ready = \ | |||||
vm_srb->scsi_status == SCSI_STATUS_CHECK_COND && | |||||
cmd->opcode == TEST_UNIT_READY && | |||||
srb_status == SRB_STATUS_ERROR; | |||||
if (!unit_not_ready && bootverbose) { | |||||
mtx_lock(&sc->hs_lock); | mtx_lock(&sc->hs_lock); | ||||
xpt_print(ccb->ccb_h.path, | xpt_print(ccb->ccb_h.path, | ||||
"storvsc scsi_status = %d\n", | "storvsc scsi_status = %d, srb_status = %d\n", | ||||
vm_srb->scsi_status); | vm_srb->scsi_status, srb_status); | ||||
mtx_unlock(&sc->hs_lock); | mtx_unlock(&sc->hs_lock); | ||||
} | |||||
ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR; | ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR; | ||||
} | } | ||||
ccb->csio.scsi_status = (vm_srb->scsi_status & 0xFF); | ccb->csio.scsi_status = (vm_srb->scsi_status & 0xFF); | ||||
ccb->csio.resid = ccb->csio.dxfer_len - vm_srb->transfer_len; | ccb->csio.resid = ccb->csio.dxfer_len - vm_srb->transfer_len; | ||||
if (reqp->sense_info_len != 0) { | if (reqp->sense_info_len != 0) { | ||||
csio->sense_resid = csio->sense_len - reqp->sense_info_len; | csio->sense_resid = csio->sense_len - reqp->sense_info_len; | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |