int ret, t;
stor_device = get_stor_device(device);
- if (!stor_device) {
- DPRINT_ERR(STORVSC, "unable to get stor device..."
- "device being destroyed?");
+ if (!stor_device)
return -1;
- }
request = &stor_device->init_request;
vstor_packet = &request->vstor_packet;
(unsigned long)request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
- if (ret != 0) {
- DPRINT_ERR(STORVSC,
- "unable to send BEGIN_INITIALIZATION_OPERATION");
+ if (ret != 0)
goto cleanup;
- }
t = wait_for_completion_timeout(&request->wait_event, HZ);
if (t == 0) {
}
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstor_packet->status != 0) {
- DPRINT_ERR(STORVSC, "BEGIN_INITIALIZATION_OPERATION failed "
- "(op %d status 0x%x)",
- vstor_packet->operation, vstor_packet->status);
+ vstor_packet->status != 0)
goto cleanup;
- }
DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
(unsigned long)request,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
- if (ret != 0) {
- DPRINT_ERR(STORVSC,
- "unable to send BEGIN_INITIALIZATION_OPERATION");
+ if (ret != 0)
goto cleanup;
- }
t = wait_for_completion_timeout(&request->wait_event, HZ);
if (t == 0) {
/* TODO: Check returned version */
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstor_packet->status != 0) {
- DPRINT_ERR(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION failed "
- "(op %d status 0x%x)",
- vstor_packet->operation, vstor_packet->status);
+ vstor_packet->status != 0)
goto cleanup;
- }
/* Query channel properties */
DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
- if (ret != 0) {
- DPRINT_ERR(STORVSC,
- "unable to send QUERY_PROPERTIES_OPERATION");
+ if (ret != 0)
goto cleanup;
- }
t = wait_for_completion_timeout(&request->wait_event, HZ);
if (t == 0) {
/* TODO: Check returned version */
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstor_packet->status != 0) {
- DPRINT_ERR(STORVSC, "QUERY_PROPERTIES_OPERATION failed "
- "(op %d status 0x%x)",
- vstor_packet->operation, vstor_packet->status);
+ vstor_packet->status != 0)
goto cleanup;
- }
stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
stor_device->target_id
= vstor_packet->storage_channel_properties.target_id;
- DPRINT_DBG(STORVSC, "channel flag 0x%x, max xfer len 0x%x",
- vstor_packet->storage_channel_properties.flags,
- vstor_packet->storage_channel_properties.max_transfer_bytes);
-
DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
memset(vstor_packet, 0, sizeof(struct vstor_packet));
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
- if (ret != 0) {
- DPRINT_ERR(STORVSC,
- "unable to send END_INITIALIZATION_OPERATION");
+ if (ret != 0)
goto cleanup;
- }
t = wait_for_completion_timeout(&request->wait_event, HZ);
if (t == 0) {
}
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstor_packet->status != 0) {
- DPRINT_ERR(STORVSC, "END_INITIALIZATION_OPERATION failed "
- "(op %d status 0x%x)",
- vstor_packet->operation, vstor_packet->status);
+ vstor_packet->status != 0)
goto cleanup;
- }
DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
struct vstor_packet *stor_pkt;
stor_device = must_get_stor_device(device);
- if (!stor_device) {
- DPRINT_ERR(STORVSC, "unable to get stor device..."
- "device being destroyed?");
+ if (!stor_device)
return;
- }
-
- DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request %p "
- "completed bytes xfer %u", request,
- vstor_packet->vm_srb.data_transfer_length);
stor_pkt = &request->vstor_packet;
vstor_packet->vm_srb.sense_info_length;
if (vstor_packet->vm_srb.scsi_status != 0 ||
- vstor_packet->vm_srb.srb_status != 1) {
+ vstor_packet->vm_srb.srb_status != 1){
DPRINT_WARN(STORVSC,
"cmd 0x%x scsi status 0x%x srb status 0x%x\n",
stor_pkt->vm_srb.cdb[0],
{
switch (vstor_packet->operation) {
case VSTOR_OPERATION_COMPLETE_IO:
- DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION");
storvsc_on_io_completion(device, vstor_packet, request);
break;
case VSTOR_OPERATION_REMOVE_DEVICE:
stor_device = must_get_stor_device(device);
- if (!stor_device) {
- DPRINT_ERR(STORVSC, "unable to get stor device..."
- "device being destroyed?");
+ if (!stor_device)
return;
- }
do {
ret = vmbus_recvpacket(device->channel, packet,
ALIGN(sizeof(struct vstor_packet), 8),
&bytes_recvd, &request_id);
if (ret == 0 && bytes_recvd > 0) {
- DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx",
- bytes_recvd, request_id);
-
request = (struct hv_storvsc_request *)
(unsigned long)request_id;
sizeof(struct vmstorage_channel_properties),
storvsc_on_channel_callback, device);
- DPRINT_DBG(STORVSC, "storage props: path id %d, tgt id %d, max xfer %d",
- props.path_id, props.target_id, props.max_transfer_bytes);
-
- if (ret != 0) {
- DPRINT_ERR(STORVSC, "unable to open channel: %d", ret);
+ if (ret != 0)
return -1;
- }
ret = storvsc_channel_init(device);
device_info->path_id = stor_device->path_id;
device_info->target_id = stor_device->target_id;
- DPRINT_DBG(STORVSC, "assigned port %u, path %u target %u\n",
- stor_device->port_number, stor_device->path_id,
- stor_device->target_id);
-
cleanup:
return ret;
}
storvsc_wait_to_drain(stor_device);
- DPRINT_INFO(STORVSC, "removing storage device (%p)...",
- device->ext);
-
stor_device = final_release_stor_device(device);
- DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", stor_device);
-
/* Close the channel */
vmbus_close(device->channel);
vstor_packet = &request->vstor_packet;
stor_device = get_stor_device(device);
- DPRINT_DBG(STORVSC, "enter - Device %p, DeviceExt %p, Request %p, "
- , device, stor_device, request);
-
- DPRINT_DBG(STORVSC, "req %p len %d",
- request, request->data_buffer.len);
-
- if (!stor_device) {
- DPRINT_ERR(STORVSC, "unable to get stor device..."
- "device being destroyed?");
+ if (!stor_device)
return -2;
- }
request->device = device;
vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
- DPRINT_DBG(STORVSC, "srb - len %d port %d, path %d, target %d, "
- "lun %d senselen %d cdblen %d",
- vstor_packet->vm_srb.length,
- vstor_packet->vm_srb.port_number,
- vstor_packet->vm_srb.path_id,
- vstor_packet->vm_srb.target_id,
- vstor_packet->vm_srb.lun,
- vstor_packet->vm_srb.sense_info_length,
- vstor_packet->vm_srb.cdb_length);
-
if (request->data_buffer.len) {
ret = vmbus_sendpacket_multipagebuffer(device->channel,
&request->data_buffer,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
}
- if (ret != 0) {
- DPRINT_DBG(STORVSC, "Unable to send packet %p ret %d",
- vstor_packet, ret);
- }
+ if (ret != 0)
+ return ret;
atomic_inc(&stor_device->num_outstanding_req);