summaryrefslogtreecommitdiffstats
path: root/drivers/staging/hv/storvsc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/hv/storvsc.c')
-rw-r--r--drivers/staging/hv/storvsc.c129
1 files changed, 42 insertions, 87 deletions
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 27a276e08ee9..19e87f689fa0 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -28,6 +28,7 @@
#include "storvsc_api.h"
#include "vmbus_packet_format.h"
#include "vstorage.h"
+#include "channel.h"
struct storvsc_request_extension {
@@ -186,7 +187,6 @@ static int StorVscChannelInit(struct hv_device *Device)
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
- DPRINT_EXIT(STORVSC);
return -1;
}
@@ -213,12 +213,11 @@ static int StorVscChannelInit(struct hv_device *Device)
DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION...");
- ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
- vstorPacket,
- sizeof(struct vstor_packet),
- (unsigned long)request,
- VmbusPacketTypeDataInBand,
- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+ ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ sizeof(struct vstor_packet),
+ (unsigned long)request,
+ VmbusPacketTypeDataInBand,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC,
"unable to send BEGIN_INITIALIZATION_OPERATION");
@@ -245,12 +244,11 @@ static int StorVscChannelInit(struct hv_device *Device)
vstorPacket->Version.MajorMinor = VMSTOR_PROTOCOL_VERSION_CURRENT;
FILL_VMSTOR_REVISION(vstorPacket->Version.Revision);
- ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
- vstorPacket,
- sizeof(struct vstor_packet),
- (unsigned long)request,
- VmbusPacketTypeDataInBand,
- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+ ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ sizeof(struct vstor_packet),
+ (unsigned long)request,
+ VmbusPacketTypeDataInBand,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC,
"unable to send BEGIN_INITIALIZATION_OPERATION");
@@ -277,12 +275,11 @@ static int StorVscChannelInit(struct hv_device *Device)
vstorPacket->StorageChannelProperties.PortNumber =
storDevice->PortNumber;
- ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
- vstorPacket,
- sizeof(struct vstor_packet),
- (unsigned long)request,
- VmbusPacketTypeDataInBand,
- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+ ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ sizeof(struct vstor_packet),
+ (unsigned long)request,
+ VmbusPacketTypeDataInBand,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC,
@@ -314,12 +311,11 @@ static int StorVscChannelInit(struct hv_device *Device)
vstorPacket->Operation = VStorOperationEndInitialization;
vstorPacket->Flags = REQUEST_COMPLETION_FLAG;
- ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
- vstorPacket,
- sizeof(struct vstor_packet),
- (unsigned long)request,
- VmbusPacketTypeDataInBand,
- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+ ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ sizeof(struct vstor_packet),
+ (unsigned long)request,
+ VmbusPacketTypeDataInBand,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC,
@@ -344,8 +340,6 @@ Cleanup:
request->WaitEvent = NULL;
nomem:
PutStorDevice(Device);
-
- DPRINT_EXIT(STORVSC);
return ret;
}
@@ -356,13 +350,10 @@ static void StorVscOnIOCompletion(struct hv_device *Device,
struct hv_storvsc_request *request;
struct storvsc_device *storDevice;
- DPRINT_ENTER(STORVSC);
-
storDevice = MustGetStorDevice(Device);
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
- DPRINT_EXIT(STORVSC);
return;
}
@@ -414,8 +405,6 @@ static void StorVscOnIOCompletion(struct hv_device *Device,
atomic_dec(&storDevice->NumOutstandingRequests);
PutStorDevice(Device);
-
- DPRINT_EXIT(STORVSC);
}
static void StorVscOnReceive(struct hv_device *Device,
@@ -449,23 +438,19 @@ static void StorVscOnChannelCallback(void *context)
struct storvsc_request_extension *request;
int ret;
- DPRINT_ENTER(STORVSC);
-
/* ASSERT(device); */
storDevice = MustGetStorDevice(device);
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
- DPRINT_EXIT(STORVSC);
return;
}
do {
- ret = device->Driver->VmbusChannelInterface.RecvPacket(device,
- packet,
- ALIGN_UP(sizeof(struct vstor_packet), 8),
- &bytesRecvd, &requestId);
+ ret = vmbus_recvpacket(device->channel, packet,
+ ALIGN_UP(sizeof(struct vstor_packet), 8),
+ &bytesRecvd, &requestId);
if (ret == 0 && bytesRecvd > 0) {
DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx",
bytesRecvd, requestId);
@@ -501,8 +486,6 @@ static void StorVscOnChannelCallback(void *context)
} while (1);
PutStorDevice(device);
-
- DPRINT_EXIT(STORVSC);
return;
}
@@ -516,13 +499,11 @@ static int StorVscConnectToVsp(struct hv_device *Device)
memset(&props, 0, sizeof(struct vmstorage_channel_properties));
/* Open the channel */
- ret = Device->Driver->VmbusChannelInterface.Open(Device,
- storDriver->RingBufferSize,
- storDriver->RingBufferSize,
- (void *)&props,
- sizeof(struct vmstorage_channel_properties),
- StorVscOnChannelCallback,
- Device);
+ ret = vmbus_open(Device->channel,
+ storDriver->RingBufferSize, storDriver->RingBufferSize,
+ (void *)&props,
+ sizeof(struct vmstorage_channel_properties),
+ StorVscOnChannelCallback, Device);
DPRINT_DBG(STORVSC, "storage props: path id %d, tgt id %d, max xfer %d",
props.PathId, props.TargetId, props.MaxTransferBytes);
@@ -547,8 +528,6 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
struct storvsc_device_info *deviceInfo;
int ret = 0;
- DPRINT_ENTER(STORVSC);
-
deviceInfo = (struct storvsc_device_info *)AdditionalInfo;
storDevice = AllocStorDevice(Device);
if (!storDevice) {
@@ -584,8 +563,6 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
storDevice->TargetId);
Cleanup:
- DPRINT_EXIT(STORVSC);
-
return ret;
}
@@ -596,8 +573,6 @@ static int StorVscOnDeviceRemove(struct hv_device *Device)
{
struct storvsc_device *storDevice;
- DPRINT_ENTER(STORVSC);
-
DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
Device->Extension);
@@ -622,11 +597,9 @@ static int StorVscOnDeviceRemove(struct hv_device *Device)
DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", storDevice);
/* Close the channel */
- Device->Driver->VmbusChannelInterface.Close(Device);
+ vmbus_close(Device->channel);
FreeStorDevice(storDevice);
-
- DPRINT_EXIT(STORVSC);
return 0;
}
@@ -637,15 +610,12 @@ int StorVscOnHostReset(struct hv_device *Device)
struct vstor_packet *vstorPacket;
int ret;
- DPRINT_ENTER(STORVSC);
-
DPRINT_INFO(STORVSC, "resetting host adapter...");
storDevice = GetStorDevice(Device);
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
- DPRINT_EXIT(STORVSC);
return -1;
}
@@ -662,12 +632,11 @@ int StorVscOnHostReset(struct hv_device *Device)
vstorPacket->Flags = REQUEST_COMPLETION_FLAG;
vstorPacket->VmSrb.PathId = storDevice->PathId;
- ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
- vstorPacket,
- sizeof(struct vstor_packet),
- (unsigned long)&storDevice->ResetRequest,
- VmbusPacketTypeDataInBand,
- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+ ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ sizeof(struct vstor_packet),
+ (unsigned long)&storDevice->ResetRequest,
+ VmbusPacketTypeDataInBand,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC, "Unable to send reset packet %p ret %d",
vstorPacket, ret);
@@ -687,7 +656,6 @@ int StorVscOnHostReset(struct hv_device *Device)
Cleanup:
PutStorDevice(Device);
- DPRINT_EXIT(STORVSC);
return ret;
}
@@ -702,8 +670,6 @@ static int StorVscOnIORequest(struct hv_device *Device,
struct vstor_packet *vstorPacket;
int ret = 0;
- DPRINT_ENTER(STORVSC);
-
requestExtension =
(struct storvsc_request_extension *)Request->Extension;
vstorPacket = &requestExtension->VStorPacket;
@@ -720,7 +686,6 @@ static int StorVscOnIORequest(struct hv_device *Device,
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
- DPRINT_EXIT(STORVSC);
return -2;
}
@@ -763,19 +728,17 @@ static int StorVscOnIORequest(struct hv_device *Device,
vstorPacket->VmSrb.CdbLength);
if (requestExtension->Request->DataBuffer.Length) {
- ret = Device->Driver->VmbusChannelInterface.
- SendPacketMultiPageBuffer(Device,
+ ret = vmbus_sendpacket_multipagebuffer(Device->channel,
&requestExtension->Request->DataBuffer,
vstorPacket,
sizeof(struct vstor_packet),
(unsigned long)requestExtension);
} else {
- ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
- vstorPacket,
- sizeof(struct vstor_packet),
- (unsigned long)requestExtension,
- VmbusPacketTypeDataInBand,
- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+ ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ sizeof(struct vstor_packet),
+ (unsigned long)requestExtension,
+ VmbusPacketTypeDataInBand,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
}
if (ret != 0) {
@@ -786,8 +749,6 @@ static int StorVscOnIORequest(struct hv_device *Device,
atomic_inc(&storDevice->NumOutstandingRequests);
PutStorDevice(Device);
-
- DPRINT_EXIT(STORVSC);
return ret;
}
@@ -796,8 +757,6 @@ static int StorVscOnIORequest(struct hv_device *Device,
*/
static void StorVscOnCleanup(struct hv_driver *Driver)
{
- DPRINT_ENTER(STORVSC);
- DPRINT_EXIT(STORVSC);
}
/*
@@ -807,8 +766,6 @@ int StorVscInitialize(struct hv_driver *Driver)
{
struct storvsc_driver_object *storDriver;
- DPRINT_ENTER(STORVSC);
-
storDriver = (struct storvsc_driver_object *)Driver;
DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd "
@@ -833,7 +790,7 @@ int StorVscInitialize(struct hv_driver *Driver)
* Divide the ring buffer data size (which is 1 page less
* than the ring buffer size since that page is reserved for
* the ring buffer indices) by the max request size (which is
- * VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + struct vstor_packet + u64)
+ * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
*/
storDriver->MaxOutstandingRequestsPerChannel =
((storDriver->RingBufferSize - PAGE_SIZE) /
@@ -852,7 +809,5 @@ int StorVscInitialize(struct hv_driver *Driver)
storDriver->OnIORequest = StorVscOnIORequest;
- DPRINT_EXIT(STORVSC);
-
return 0;
}