Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
Show First 20 Lines • Show All 2,148 Lines • ▼ Show 20 Lines | if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) { | ||||
callout_drain(&reqp->callout); | callout_drain(&reqp->callout); | ||||
} | } | ||||
#endif | #endif | ||||
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; | ||||
if (vm_srb->scsi_status == SCSI_STATUS_OK) { | if (vm_srb->scsi_status == SCSI_STATUS_OK) { | ||||
const struct scsi_generic *cmd; | 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 (vm_srb->srb_status != SRB_STATUS_SUCCESS) { | if (vm_srb->srb_status != SRB_STATUS_SUCCESS) { | ||||
/* | |||||
* If there are errors, for example, invalid LUN, | |||||
* host will inform VM through SRB status. | |||||
*/ | |||||
if (bootverbose) { | |||||
mtx_lock(&sc->hs_lock); | |||||
if (vm_srb->srb_status == SRB_STATUS_INVALID_LUN) { | if (vm_srb->srb_status == SRB_STATUS_INVALID_LUN) { | ||||
xpt_print(ccb->ccb_h.path, "invalid LUN %d\n", | xpt_print(ccb->ccb_h.path, | ||||
vm_srb->lun); | "invalid LUN %d for op: %s\n", | ||||
vm_srb->lun, scsi_op_desc(cmd->opcode, NULL)); | |||||
} else { | } else { | ||||
xpt_print(ccb->ccb_h.path, "Unknown SRB flag: %d\n", | xpt_print(ccb->ccb_h.path, | ||||
vm_srb->srb_status); | "Unknown SRB flag: %d for op: %s\n", | ||||
vm_srb->srb_status, scsi_op_desc(cmd->opcode, NULL)); | |||||
} | } | ||||
mtx_unlock(&sc->hs_lock); | |||||
} | |||||
if (storvsc_get_storage_type(sc->hs_dev) == | |||||
DRIVER_STORVSC) { | |||||
/* | /* | ||||
* If there are errors, for example, invalid LUN, | * For a selection timeout, all of the LUNs on | ||||
* host will inform VM through SRB status. | * the target will be gone. It works for SCSI | ||||
* disks, but does not work for IDE disks. | |||||
*/ | */ | ||||
ccb->ccb_h.status |= CAM_SEL_TIMEOUT; | ccb->ccb_h.status |= CAM_SEL_TIMEOUT; | ||||
} else { | } else { | ||||
/* | |||||
* For CAM_DEV_NOT_THERE, CAM will only get | |||||
* rid of the device(s) specified by the path. | |||||
*/ | |||||
ccb->ccb_h.status |= CAM_DEV_NOT_THERE; | |||||
} | |||||
} else { | |||||
ccb->ccb_h.status |= CAM_REQ_CMP; | ccb->ccb_h.status |= CAM_REQ_CMP; | ||||
} | } | ||||
cmd = (const struct scsi_generic *) | if (cmd->opcode == INQUIRY) { | ||||
const struct scsi_inquiry * inq = | |||||
(const struct scsi_inquiry *) | |||||
((ccb->ccb_h.flags & CAM_CDB_POINTER) ? | ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? | ||||
csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); | csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); | ||||
if (cmd->opcode == INQUIRY) { | mtx_lock(&sc->hs_lock); | ||||
xpt_print(ccb->ccb_h.path, "storvsc inquiry cmd" | |||||
" [%x %x %x %x %x %x]\n", inq->opcode, | |||||
inq->byte2, inq->page_code, inq->length[0], | |||||
inq->length[1], inq->control); | |||||
mtx_unlock(&sc->hs_lock); | |||||
struct scsi_inquiry_data *inq_data = | struct scsi_inquiry_data *inq_data = | ||||
(struct scsi_inquiry_data *)csio->data_ptr; | (struct scsi_inquiry_data *)csio->data_ptr; | ||||
uint8_t *resp_buf = (uint8_t *)csio->data_ptr; | uint8_t *resp_buf = (uint8_t *)csio->data_ptr; | ||||
int resp_xfer_len, resp_buf_len, data_len; | int resp_xfer_len, resp_buf_len, data_len; | ||||
/* Get the buffer length reported by host */ | /* Get the buffer length reported by host */ | ||||
resp_xfer_len = vm_srb->transfer_len; | resp_xfer_len = vm_srb->transfer_len; | ||||
/* Get the available buffer length */ | /* Get the available buffer length */ | ||||
resp_buf_len = resp_xfer_len >= 5 ? resp_buf[4] + 5 : 0; | resp_buf_len = resp_xfer_len >= 5 ? resp_buf[4] + 5 : 0; | ||||
data_len = (resp_buf_len < resp_xfer_len) ? | data_len = (resp_buf_len < resp_xfer_len) ? | ||||
resp_buf_len : resp_xfer_len; | resp_buf_len : resp_xfer_len; | ||||
if (bootverbose && data_len >= 5) { | if (bootverbose && data_len >= 5) { | ||||
mtx_lock(&sc->hs_lock); | |||||
sepherosa_gmail.com: This lock is actually not useful for xpt_print() | |||||
xpt_print(ccb->ccb_h.path, "storvsc inquiry " | xpt_print(ccb->ccb_h.path, "storvsc inquiry " | ||||
"(%d) [%x %x %x %x %x ... ]\n", data_len, | "(%d) [%x %x %x %x %x ... ]\n", data_len, | ||||
resp_buf[0], resp_buf[1], resp_buf[2], | resp_buf[0], resp_buf[1], resp_buf[2], | ||||
resp_buf[3], resp_buf[4]); | resp_buf[3], resp_buf[4]); | ||||
mtx_unlock(&sc->hs_lock); | |||||
} | } | ||||
if (vm_srb->srb_status == SRB_STATUS_SUCCESS && | if (vm_srb->srb_status == SRB_STATUS_SUCCESS && | ||||
data_len > SHORT_INQUIRY_LENGTH) { | data_len > SHORT_INQUIRY_LENGTH) { | ||||
char vendor[16]; | char vendor[16]; | ||||
cam_strvis(vendor, inq_data->vendor, | cam_strvis(vendor, inq_data->vendor, | ||||
sizeof(inq_data->vendor), sizeof(vendor)); | sizeof(inq_data->vendor), sizeof(vendor)); | ||||
/* | /* | ||||
* XXX: Upgrade SPC2 to SPC3 if host is WIN8 or | * XXX: Upgrade SPC2 to SPC3 if host is WIN8 or | ||||
* WIN2012 R2 in order to support UNMAP feature. | * WIN2012 R2 in order to support UNMAP feature. | ||||
*/ | */ | ||||
if (!strncmp(vendor, "Msft", 4) && | if (!strncmp(vendor, "Msft", 4) && | ||||
SID_ANSI_REV(inq_data) == SCSI_REV_SPC2 && | SID_ANSI_REV(inq_data) == SCSI_REV_SPC2 && | ||||
(vmstor_proto_version == | (vmstor_proto_version == | ||||
VMSTOR_PROTOCOL_VERSION_WIN8_1 || | VMSTOR_PROTOCOL_VERSION_WIN8_1 || | ||||
vmstor_proto_version == | vmstor_proto_version == | ||||
VMSTOR_PROTOCOL_VERSION_WIN8)) { | VMSTOR_PROTOCOL_VERSION_WIN8)) { | ||||
inq_data->version = SCSI_REV_SPC3; | inq_data->version = SCSI_REV_SPC3; | ||||
if (bootverbose) { | if (bootverbose) { | ||||
mtx_lock(&sc->hs_lock); | |||||
xpt_print(ccb->ccb_h.path, | xpt_print(ccb->ccb_h.path, | ||||
"storvsc upgrades " | "storvsc upgrades " | ||||
"SPC2 to SPC3\n"); | "SPC2 to SPC3\n"); | ||||
mtx_unlock(&sc->hs_lock); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
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\n", | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |
This lock is actually not useful for xpt_print()