* [PATCH 3/8] staging: hv: Convert camel case functions in storvsc_api.h to lowercase
From: Hank Janssen @ 2010-12-06 20:26 UTC (permalink / raw)
To: hjanssen, gregkh, linux-kernel, devel, virtualization
Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1291667211-1865-2-git-send-email-hjanssen@microsoft.com>
From: Hank Janssen <hjanssen@microsoft.com>
Convert camel case functions in storvsc_api.h to lowercase
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc.c | 2 +-
drivers/staging/hv/blkvsc_drv.c | 2 +-
drivers/staging/hv/storvsc.c | 6 +++---
drivers/staging/hv/storvsc_api.h | 6 +++---
drivers/staging/hv/storvsc_drv.c | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
index 9ac04c3..e62c922 100644
--- a/drivers/staging/hv/blkvsc.c
+++ b/drivers/staging/hv/blkvsc.c
@@ -62,7 +62,7 @@ static int BlkVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
return ret;
}
-int BlkVscInitialize(struct hv_driver *Driver)
+int blk_vsc_initialize(struct hv_driver *Driver)
{
struct storvsc_driver_object *storDriver;
int ret = 0;
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index d65d69e..b3d05fc 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -1487,7 +1487,7 @@ static int __init blkvsc_init(void)
DPRINT_INFO(BLKVSC_DRV, "Blkvsc initializing....");
- ret = blkvsc_drv_init(BlkVscInitialize);
+ ret = blkvsc_drv_init(blk_vsc_initialize);
return ret;
}
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index c4346c6..7704131 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -605,7 +605,7 @@ static int StorVscOnDeviceRemove(struct hv_device *Device)
return 0;
}
-int StorVscOnHostReset(struct hv_device *Device)
+int stor_vsc_on_host_reset(struct hv_device *Device)
{
struct storvsc_device *storDevice;
struct storvsc_request_extension *request;
@@ -762,9 +762,9 @@ static void StorVscOnCleanup(struct hv_driver *Driver)
}
/*
- * StorVscInitialize - Main entry point
+ * stor_vsc_initialize - Main entry point
*/
-int StorVscInitialize(struct hv_driver *Driver)
+int stor_vsc_initialize(struct hv_driver *Driver)
{
struct storvsc_driver_object *storDriver;
diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h
index 46f031e..fbf5755 100644
--- a/drivers/staging/hv/storvsc_api.h
+++ b/drivers/staging/hv/storvsc_api.h
@@ -103,8 +103,8 @@ struct storvsc_device_info {
};
/* Interface */
-int StorVscInitialize(struct hv_driver *driver);
-int StorVscOnHostReset(struct hv_device *device);
-int BlkVscInitialize(struct hv_driver *driver);
+int stor_vsc_initialize(struct hv_driver *driver);
+int stor_vsc_on_host_reset(struct hv_device *device);
+int blk_vsc_initialize(struct hv_driver *driver);
#endif /* _STORVSC_API_H_ */
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 03695ce..0d96878 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -846,7 +846,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
scmnd->device, &device_ctx->device_obj);
/* Invokes the vsc to reset the host/bus */
- ret = StorVscOnHostReset(&device_ctx->device_obj);
+ ret = stor_vsc_on_host_reset(&device_ctx->device_obj);
if (ret != 0)
return ret;
@@ -941,7 +941,7 @@ static int __init storvsc_init(void)
int ret;
DPRINT_INFO(STORVSC_DRV, "Storvsc initializing....");
- ret = storvsc_drv_init(StorVscInitialize);
+ ret = storvsc_drv_init(stor_vsc_initialize);
return ret;
}
--
1.6.0.2
^ permalink raw reply related
* [PATCH 4/8] staging: hv: Convert camel case struct fields in storvsc.c to lowercase
From: Hank Janssen @ 2010-12-06 20:26 UTC (permalink / raw)
To: hjanssen, gregkh, linux-kernel, devel, virtualization
Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1291667211-1865-3-git-send-email-hjanssen@microsoft.com>
From: Hank Janssen <hjanssen@microsoft.com>
Convert camel cased struct fields in storvsc.c to lowercase
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/storvsc.c | 133 +++++++++++++++++++++---------------------
1 files changed, 67 insertions(+), 66 deletions(-)
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 7704131..3b6e63a 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -34,43 +34,43 @@
struct storvsc_request_extension {
/* LIST_ENTRY ListEntry; */
- struct hv_storvsc_request *Request;
- struct hv_device *Device;
+ struct hv_storvsc_request *request;
+ struct hv_device *device;
/* Synchronize the request/response if needed */
- struct osd_waitevent *WaitEvent;
+ struct osd_waitevent *wait_event;
- struct vstor_packet VStorPacket;
+ struct vstor_packet vstor_packet;
};
/* A storvsc device is a device object that contains a vmbus channel */
struct storvsc_device {
- struct hv_device *Device;
+ struct hv_device *device;
/* 0 indicates the device is being destroyed */
- atomic_t RefCount;
+ atomic_t ref_count;
- atomic_t NumOutstandingRequests;
+ atomic_t num_outstanding_requests;
/*
* Each unique Port/Path/Target represents 1 channel ie scsi
* controller. In reality, the pathid, targetid is always 0
* and the port is set by us
*/
- unsigned int PortNumber;
- unsigned char PathId;
- unsigned char TargetId;
+ unsigned int port_number;
+ unsigned char path_id;
+ unsigned char target_id;
/* LIST_ENTRY OutstandingRequestList; */
/* HANDLE OutstandingRequestLock; */
/* Used for vsc/vsp channel reset process */
- struct storvsc_request_extension InitRequest;
- struct storvsc_request_extension ResetRequest;
+ struct storvsc_request_extension init_request;
+ struct storvsc_request_extension reset_request;
};
-static const char *gDriverName = "storvsc";
+static const char *g_driver_name = "storvsc";
/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
static const struct hv_guid gStorVscDeviceType = {
@@ -90,10 +90,10 @@ static inline struct storvsc_device *AllocStorDevice(struct hv_device *Device)
return NULL;
/* Set to 2 to allow both inbound and outbound traffics */
- /* (ie GetStorDevice() and MustGetStorDevice()) to proceed. */
- atomic_cmpxchg(&storDevice->RefCount, 0, 2);
+ /* (ie get_stor_device() and must_get_stor_device()) to proceed. */
+ atomic_cmpxchg(&storDevice->ref_count, 0, 2);
- storDevice->Device = Device;
+ storDevice->device = Device;
Device->Extension = storDevice;
return storDevice;
@@ -101,7 +101,7 @@ static inline struct storvsc_device *AllocStorDevice(struct hv_device *Device)
static inline void FreeStorDevice(struct storvsc_device *Device)
{
- /* ASSERT(atomic_read(&Device->RefCount) == 0); */
+ /* ASSERT(atomic_read(&Device->ref_count) == 0); */
kfree(Device);
}
@@ -111,8 +111,8 @@ static inline struct storvsc_device *GetStorDevice(struct hv_device *Device)
struct storvsc_device *storDevice;
storDevice = (struct storvsc_device *)Device->Extension;
- if (storDevice && atomic_read(&storDevice->RefCount) > 1)
- atomic_inc(&storDevice->RefCount);
+ if (storDevice && atomic_read(&storDevice->ref_count) > 1)
+ atomic_inc(&storDevice->ref_count);
else
storDevice = NULL;
@@ -125,8 +125,8 @@ static inline struct storvsc_device *MustGetStorDevice(struct hv_device *Device)
struct storvsc_device *storDevice;
storDevice = (struct storvsc_device *)Device->Extension;
- if (storDevice && atomic_read(&storDevice->RefCount))
- atomic_inc(&storDevice->RefCount);
+ if (storDevice && atomic_read(&storDevice->ref_count))
+ atomic_inc(&storDevice->ref_count);
else
storDevice = NULL;
@@ -140,8 +140,8 @@ static inline void PutStorDevice(struct hv_device *Device)
storDevice = (struct storvsc_device *)Device->Extension;
/* ASSERT(storDevice); */
- atomic_dec(&storDevice->RefCount);
- /* ASSERT(atomic_read(&storDevice->RefCount)); */
+ atomic_dec(&storDevice->ref_count);
+ /* ASSERT(atomic_read(&storDevice->ref_count)); */
}
/* Drop ref count to 1 to effectively disable GetStorDevice() */
@@ -153,7 +153,7 @@ static inline struct storvsc_device *ReleaseStorDevice(struct hv_device *Device)
/* ASSERT(storDevice); */
/* Busy wait until the ref drop to 2, then set it to 1 */
- while (atomic_cmpxchg(&storDevice->RefCount, 2, 1) != 2)
+ while (atomic_cmpxchg(&storDevice->ref_count, 2, 1) != 2)
udelay(100);
return storDevice;
@@ -169,7 +169,7 @@ static inline struct storvsc_device *FinalReleaseStorDevice(
/* ASSERT(storDevice); */
/* Busy wait until the ref drop to 1, then set it to 0 */
- while (atomic_cmpxchg(&storDevice->RefCount, 1, 0) != 1)
+ while (atomic_cmpxchg(&storDevice->ref_count, 1, 0) != 1)
udelay(100);
Device->Extension = NULL;
@@ -190,16 +190,16 @@ static int StorVscChannelInit(struct hv_device *Device)
return -1;
}
- request = &storDevice->InitRequest;
- vstorPacket = &request->VStorPacket;
+ request = &storDevice->init_request;
+ vstorPacket = &request->vstor_packet;
/*
* Now, initiate the vsc/vsp initialization protocol on the open
* channel
*/
memset(request, 0, sizeof(struct storvsc_request_extension));
- request->WaitEvent = osd_waitevent_create();
- if (!request->WaitEvent) {
+ request->wait_event = osd_waitevent_create();
+ if (!request->wait_event) {
ret = -ENOMEM;
goto nomem;
}
@@ -224,7 +224,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_waitevent_wait(request->WaitEvent);
+ osd_waitevent_wait(request->wait_event);
if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
vstorPacket->status != 0) {
@@ -255,7 +255,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_waitevent_wait(request->WaitEvent);
+ osd_waitevent_wait(request->wait_event);
/* TODO: Check returned version */
if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
@@ -273,7 +273,7 @@ static int StorVscChannelInit(struct hv_device *Device)
vstorPacket->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
vstorPacket->flags = REQUEST_COMPLETION_FLAG;
vstorPacket->storage_channel_properties.port_number =
- storDevice->PortNumber;
+ storDevice->port_number;
ret = vmbus_sendpacket(Device->channel, vstorPacket,
sizeof(struct vstor_packet),
@@ -287,7 +287,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_waitevent_wait(request->WaitEvent);
+ osd_waitevent_wait(request->wait_event);
/* TODO: Check returned version */
if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
@@ -298,8 +298,8 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- storDevice->PathId = vstorPacket->storage_channel_properties.path_id;
- storDevice->TargetId
+ storDevice->path_id = vstorPacket->storage_channel_properties.path_id;
+ storDevice->target_id
= vstorPacket->storage_channel_properties.target_id;
DPRINT_DBG(STORVSC, "channel flag 0x%x, max xfer len 0x%x",
@@ -324,7 +324,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_waitevent_wait(request->WaitEvent);
+ osd_waitevent_wait(request->wait_event);
if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
vstorPacket->status != 0) {
@@ -337,8 +337,8 @@ static int StorVscChannelInit(struct hv_device *Device)
DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
Cleanup:
- kfree(request->WaitEvent);
- request->WaitEvent = NULL;
+ kfree(request->wait_event);
+ request->wait_event = NULL;
nomem:
PutStorDevice(Device);
return ret;
@@ -365,7 +365,7 @@ static void StorVscOnIOCompletion(struct hv_device *Device,
/* ASSERT(RequestExt != NULL); */
/* ASSERT(RequestExt->Request != NULL); */
- request = RequestExt->Request;
+ request = RequestExt->request;
/* ASSERT(request->OnIOCompletion != NULL); */
@@ -403,7 +403,7 @@ static void StorVscOnIOCompletion(struct hv_device *Device,
request->on_io_completion(request);
- atomic_dec(&storDevice->NumOutstandingRequests);
+ atomic_dec(&storDevice->num_outstanding_requests);
PutStorDevice(Device);
}
@@ -463,18 +463,18 @@ static void StorVscOnChannelCallback(void *context)
/* ASSERT(request);c */
/* if (vstorPacket.Flags & SYNTHETIC_FLAG) */
- if ((request == &storDevice->InitRequest) ||
- (request == &storDevice->ResetRequest)) {
+ if ((request == &storDevice->init_request) ||
+ (request == &storDevice->reset_request)) {
/* DPRINT_INFO(STORVSC,
* "reset completion - operation "
* "%u status %u",
* vstorPacket.Operation,
* vstorPacket.Status); */
- memcpy(&request->VStorPacket, packet,
+ memcpy(&request->vstor_packet, packet,
sizeof(struct vstor_packet));
- osd_waitevent_set(request->WaitEvent);
+ osd_waitevent_set(request->wait_event);
} else {
StorVscOnReceive(device,
(struct vstor_packet *)packet,
@@ -522,6 +522,7 @@ static int StorVscConnectToVsp(struct hv_device *Device)
/*
* StorVscOnDeviceAdd - Callback when the device belonging to this driver is added
+ * is added
*/
static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
{
@@ -552,17 +553,17 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
storChannel->PathId = props->PathId;
storChannel->TargetId = props->TargetId; */
- storDevice->PortNumber = deviceInfo->port_number;
+ storDevice->port_number = deviceInfo->port_number;
/* Send it back up */
ret = StorVscConnectToVsp(Device);
/* deviceInfo->PortNumber = storDevice->PortNumber; */
- deviceInfo->path_id = storDevice->PathId;
- deviceInfo->target_id = storDevice->TargetId;
+ deviceInfo->path_id = storDevice->path_id;
+ deviceInfo->target_id = storDevice->target_id;
DPRINT_DBG(STORVSC, "assigned port %u, path %u target %u\n",
- storDevice->PortNumber, storDevice->PathId,
- storDevice->TargetId);
+ storDevice->port_number, storDevice->path_id,
+ storDevice->target_id);
Cleanup:
return ret;
@@ -585,9 +586,9 @@ static int StorVscOnDeviceRemove(struct hv_device *Device)
* only allow inbound traffic (responses) to proceed so that
* outstanding requests can be completed.
*/
- while (atomic_read(&storDevice->NumOutstandingRequests)) {
+ while (atomic_read(&storDevice->num_outstanding_requests)) {
DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
- atomic_read(&storDevice->NumOutstandingRequests));
+ atomic_read(&storDevice->num_outstanding_requests));
udelay(100);
}
@@ -621,22 +622,22 @@ int stor_vsc_on_host_reset(struct hv_device *Device)
return -1;
}
- request = &storDevice->ResetRequest;
- vstorPacket = &request->VStorPacket;
+ request = &storDevice->reset_request;
+ vstorPacket = &request->vstor_packet;
- request->WaitEvent = osd_waitevent_create();
- if (!request->WaitEvent) {
+ request->wait_event = osd_waitevent_create();
+ if (!request->wait_event) {
ret = -ENOMEM;
goto Cleanup;
}
vstorPacket->operation = VSTOR_OPERATION_RESET_BUS;
vstorPacket->flags = REQUEST_COMPLETION_FLAG;
- vstorPacket->vm_srb.path_id = storDevice->PathId;
+ vstorPacket->vm_srb.path_id = storDevice->path_id;
ret = vmbus_sendpacket(Device->channel, vstorPacket,
sizeof(struct vstor_packet),
- (unsigned long)&storDevice->ResetRequest,
+ (unsigned long)&storDevice->reset_request,
VmbusPacketTypeDataInBand,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
@@ -646,9 +647,9 @@ int stor_vsc_on_host_reset(struct hv_device *Device)
}
/* FIXME: Add a timeout */
- osd_waitevent_wait(request->WaitEvent);
+ osd_waitevent_wait(request->wait_event);
- kfree(request->WaitEvent);
+ kfree(request->wait_event);
DPRINT_INFO(STORVSC, "host adapter reset completed");
/*
@@ -674,7 +675,7 @@ static int StorVscOnIORequest(struct hv_device *Device,
requestExtension =
(struct storvsc_request_extension *)Request->extension;
- vstorPacket = &requestExtension->VStorPacket;
+ vstorPacket = &requestExtension->vstor_packet;
storDevice = GetStorDevice(Device);
DPRINT_DBG(STORVSC, "enter - Device %p, DeviceExt %p, Request %p, "
@@ -694,8 +695,8 @@ static int StorVscOnIORequest(struct hv_device *Device,
/* print_hex_dump_bytes("", DUMP_PREFIX_NONE, Request->Cdb,
* Request->CdbLen); */
- requestExtension->Request = Request;
- requestExtension->Device = Device;
+ requestExtension->request = Request;
+ requestExtension->device = Device;
memset(vstorPacket, 0 , sizeof(struct vstor_packet));
@@ -729,9 +730,9 @@ static int StorVscOnIORequest(struct hv_device *Device,
vstorPacket->vm_srb.sense_info_length,
vstorPacket->vm_srb.cdb_length);
- if (requestExtension->Request->data_buffer.Length) {
+ if (requestExtension->request->data_buffer.Length) {
ret = vmbus_sendpacket_multipagebuffer(Device->channel,
- &requestExtension->Request->data_buffer,
+ &requestExtension->request->data_buffer,
vstorPacket,
sizeof(struct vstor_packet),
(unsigned long)requestExtension);
@@ -748,7 +749,7 @@ static int StorVscOnIORequest(struct hv_device *Device,
vstorPacket, ret);
}
- atomic_inc(&storDevice->NumOutstandingRequests);
+ atomic_inc(&storDevice->num_outstanding_requests);
PutStorDevice(Device);
return ret;
@@ -782,7 +783,7 @@ int stor_vsc_initialize(struct hv_driver *Driver)
/* Make sure we are at least 2 pages since 1 page is used for control */
/* ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1)); */
- Driver->name = gDriverName;
+ Driver->name = g_driver_name;
memcpy(&Driver->deviceType, &gStorVscDeviceType,
sizeof(struct hv_guid));
--
1.6.0.2
^ permalink raw reply related
* [PATCH 5/8] staging: hv: Convert camel case function names in storvsc.c to lowercase
From: Hank Janssen @ 2010-12-06 20:26 UTC (permalink / raw)
To: hjanssen, gregkh, linux-kernel, devel, virtualization
Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1291667211-1865-4-git-send-email-hjanssen@microsoft.com>
From: Hank Janssen <hjanssen@microsoft.com>
Convert camel case function names in storvsc.c to lowercase
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc.c | 8 ++--
drivers/staging/hv/storvsc.c | 91 +++++++++++++++++++++--------------------
2 files changed, 51 insertions(+), 48 deletions(-)
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
index e62c922..208492c 100644
--- a/drivers/staging/hv/blkvsc.c
+++ b/drivers/staging/hv/blkvsc.c
@@ -42,7 +42,7 @@ static int BlkVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
deviceInfo = (struct storvsc_device_info *)AdditionalInfo;
- ret = StorVscOnDeviceAdd(Device, AdditionalInfo);
+ ret = stor_vsc_on_device_add(Device, AdditionalInfo);
if (ret != 0)
return ret;
@@ -94,9 +94,9 @@ int blk_vsc_initialize(struct hv_driver *Driver)
/* Setup the dispatch table */
storDriver->base.OnDeviceAdd = BlkVscOnDeviceAdd;
- storDriver->base.OnDeviceRemove = StorVscOnDeviceRemove;
- storDriver->base.OnCleanup = StorVscOnCleanup;
- storDriver->on_io_request = StorVscOnIORequest;
+ storDriver->base.OnDeviceRemove = stor_vsc_on_device_remove;
+ storDriver->base.OnCleanup = stor_vsc_on_cleanup;
+ storDriver->on_io_request = stor_vsc_on_io_request;
return ret;
}
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 3b6e63a..6643038 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -81,7 +81,7 @@ static const struct hv_guid gStorVscDeviceType = {
};
-static inline struct storvsc_device *AllocStorDevice(struct hv_device *Device)
+static inline struct storvsc_device *alloc_stor_device(struct hv_device *Device)
{
struct storvsc_device *storDevice;
@@ -99,14 +99,14 @@ static inline struct storvsc_device *AllocStorDevice(struct hv_device *Device)
return storDevice;
}
-static inline void FreeStorDevice(struct storvsc_device *Device)
+static inline void free_stor_device(struct storvsc_device *Device)
{
/* ASSERT(atomic_read(&Device->ref_count) == 0); */
kfree(Device);
}
/* Get the stordevice object iff exists and its refcount > 1 */
-static inline struct storvsc_device *GetStorDevice(struct hv_device *Device)
+static inline struct storvsc_device *get_stor_device(struct hv_device *Device)
{
struct storvsc_device *storDevice;
@@ -120,7 +120,8 @@ static inline struct storvsc_device *GetStorDevice(struct hv_device *Device)
}
/* Get the stordevice object iff exists and its refcount > 0 */
-static inline struct storvsc_device *MustGetStorDevice(struct hv_device *Device)
+static inline struct storvsc_device *must_get_stor_device(
+ struct hv_device *Device)
{
struct storvsc_device *storDevice;
@@ -133,7 +134,7 @@ static inline struct storvsc_device *MustGetStorDevice(struct hv_device *Device)
return storDevice;
}
-static inline void PutStorDevice(struct hv_device *Device)
+static inline void put_stor_device(struct hv_device *Device)
{
struct storvsc_device *storDevice;
@@ -144,8 +145,9 @@ static inline void PutStorDevice(struct hv_device *Device)
/* ASSERT(atomic_read(&storDevice->ref_count)); */
}
-/* Drop ref count to 1 to effectively disable GetStorDevice() */
-static inline struct storvsc_device *ReleaseStorDevice(struct hv_device *Device)
+/* Drop ref count to 1 to effectively disable get_stor_device() */
+static inline struct storvsc_device *release_stor_device(
+ struct hv_device *Device)
{
struct storvsc_device *storDevice;
@@ -160,7 +162,7 @@ static inline struct storvsc_device *ReleaseStorDevice(struct hv_device *Device)
}
/* Drop ref count to 0. No one can use StorDevice object. */
-static inline struct storvsc_device *FinalReleaseStorDevice(
+static inline struct storvsc_device *final_release_stor_device(
struct hv_device *Device)
{
struct storvsc_device *storDevice;
@@ -176,14 +178,14 @@ static inline struct storvsc_device *FinalReleaseStorDevice(
return storDevice;
}
-static int StorVscChannelInit(struct hv_device *Device)
+static int stor_vsc_channel_init(struct hv_device *Device)
{
struct storvsc_device *storDevice;
struct storvsc_request_extension *request;
struct vstor_packet *vstorPacket;
int ret;
- storDevice = GetStorDevice(Device);
+ storDevice = get_stor_device(Device);
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
@@ -340,18 +342,18 @@ Cleanup:
kfree(request->wait_event);
request->wait_event = NULL;
nomem:
- PutStorDevice(Device);
+ put_stor_device(Device);
return ret;
}
-static void StorVscOnIOCompletion(struct hv_device *Device,
+static void stor_vsc_on_io_completion(struct hv_device *Device,
struct vstor_packet *VStorPacket,
struct storvsc_request_extension *RequestExt)
{
struct hv_storvsc_request *request;
struct storvsc_device *storDevice;
- storDevice = MustGetStorDevice(Device);
+ storDevice = must_get_stor_device(Device);
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
@@ -405,17 +407,17 @@ static void StorVscOnIOCompletion(struct hv_device *Device,
atomic_dec(&storDevice->num_outstanding_requests);
- PutStorDevice(Device);
+ put_stor_device(Device);
}
-static void StorVscOnReceive(struct hv_device *Device,
+static void stor_vsc_on_receive(struct hv_device *Device,
struct vstor_packet *VStorPacket,
struct storvsc_request_extension *RequestExt)
{
switch (VStorPacket->operation) {
case VSTOR_OPERATION_COMPLETE_IO:
DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION");
- StorVscOnIOCompletion(Device, VStorPacket, RequestExt);
+ stor_vsc_on_io_completion(Device, VStorPacket, RequestExt);
break;
case VSTOR_OPERATION_REMOVE_DEVICE:
DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
@@ -429,7 +431,7 @@ static void StorVscOnReceive(struct hv_device *Device,
}
}
-static void StorVscOnChannelCallback(void *context)
+static void stor_vsc_on_channel_callback(void *context)
{
struct hv_device *device = (struct hv_device *)context;
struct storvsc_device *storDevice;
@@ -441,7 +443,7 @@ static void StorVscOnChannelCallback(void *context)
/* ASSERT(device); */
- storDevice = MustGetStorDevice(device);
+ storDevice = must_get_stor_device(device);
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
@@ -476,7 +478,7 @@ static void StorVscOnChannelCallback(void *context)
osd_waitevent_set(request->wait_event);
} else {
- StorVscOnReceive(device,
+ stor_vsc_on_receive(device,
(struct vstor_packet *)packet,
request);
}
@@ -486,11 +488,11 @@ static void StorVscOnChannelCallback(void *context)
}
} while (1);
- PutStorDevice(device);
+ put_stor_device(device);
return;
}
-static int StorVscConnectToVsp(struct hv_device *Device)
+static int stor_vsc_connect_to_vsp(struct hv_device *Device)
{
struct vmstorage_channel_properties props;
struct storvsc_driver_object *storDriver;
@@ -505,7 +507,7 @@ static int StorVscConnectToVsp(struct hv_device *Device)
storDriver->ring_buffer_size,
(void *)&props,
sizeof(struct vmstorage_channel_properties),
- StorVscOnChannelCallback, Device);
+ stor_vsc_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);
@@ -515,16 +517,17 @@ static int StorVscConnectToVsp(struct hv_device *Device)
return -1;
}
- ret = StorVscChannelInit(Device);
+ ret = stor_vsc_channel_init(Device);
return ret;
}
/*
- * StorVscOnDeviceAdd - Callback when the device belonging to this driver is added
+ * stor_vsc_on_device_add - Callback when the device belonging to this driver
* is added
*/
-static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
+static int stor_vsc_on_device_add(struct hv_device *Device,
+ void *AdditionalInfo)
{
struct storvsc_device *storDevice;
/* struct vmstorage_channel_properties *props; */
@@ -532,7 +535,7 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
int ret = 0;
deviceInfo = (struct storvsc_device_info *)AdditionalInfo;
- storDevice = AllocStorDevice(Device);
+ storDevice = alloc_stor_device(Device);
if (!storDevice) {
ret = -1;
goto Cleanup;
@@ -555,7 +558,7 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
storDevice->port_number = deviceInfo->port_number;
/* Send it back up */
- ret = StorVscConnectToVsp(Device);
+ ret = stor_vsc_connect_to_vsp(Device);
/* deviceInfo->PortNumber = storDevice->PortNumber; */
deviceInfo->path_id = storDevice->path_id;
@@ -570,16 +573,16 @@ Cleanup:
}
/*
- * StorVscOnDeviceRemove - Callback when the our device is being removed
+ * stor_vsc_on_device_remove - Callback when the our device is being removed
*/
-static int StorVscOnDeviceRemove(struct hv_device *Device)
+static int stor_vsc_on_device_remove(struct hv_device *Device)
{
struct storvsc_device *storDevice;
DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
Device->Extension);
- storDevice = ReleaseStorDevice(Device);
+ storDevice = release_stor_device(Device);
/*
* At this point, all outbound traffic should be disable. We
@@ -595,14 +598,14 @@ static int StorVscOnDeviceRemove(struct hv_device *Device)
DPRINT_INFO(STORVSC, "removing storage device (%p)...",
Device->Extension);
- storDevice = FinalReleaseStorDevice(Device);
+ storDevice = final_release_stor_device(Device);
DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", storDevice);
/* Close the channel */
vmbus_close(Device->channel);
- FreeStorDevice(storDevice);
+ free_stor_device(storDevice);
return 0;
}
@@ -615,7 +618,7 @@ int stor_vsc_on_host_reset(struct hv_device *Device)
DPRINT_INFO(STORVSC, "resetting host adapter...");
- storDevice = GetStorDevice(Device);
+ storDevice = get_stor_device(Device);
if (!storDevice) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
@@ -658,14 +661,14 @@ int stor_vsc_on_host_reset(struct hv_device *Device)
*/
Cleanup:
- PutStorDevice(Device);
+ put_stor_device(Device);
return ret;
}
/*
- * StorVscOnIORequest - Callback to initiate an I/O request
+ * stor_vsc_on_io_request - Callback to initiate an I/O request
*/
-static int StorVscOnIORequest(struct hv_device *Device,
+static int stor_vsc_on_io_request(struct hv_device *Device,
struct hv_storvsc_request *Request)
{
struct storvsc_device *storDevice;
@@ -676,7 +679,7 @@ static int StorVscOnIORequest(struct hv_device *Device,
requestExtension =
(struct storvsc_request_extension *)Request->extension;
vstorPacket = &requestExtension->vstor_packet;
- storDevice = GetStorDevice(Device);
+ storDevice = get_stor_device(Device);
DPRINT_DBG(STORVSC, "enter - Device %p, DeviceExt %p, Request %p, "
"Extension %p", Device, storDevice, Request,
@@ -751,14 +754,14 @@ static int StorVscOnIORequest(struct hv_device *Device,
atomic_inc(&storDevice->num_outstanding_requests);
- PutStorDevice(Device);
+ put_stor_device(Device);
return ret;
}
/*
- * StorVscOnCleanup - Perform any cleanup when the driver is removed
+ * stor_vsc_on_cleanup - Perform any cleanup when the driver is removed
*/
-static void StorVscOnCleanup(struct hv_driver *Driver)
+static void stor_vsc_on_cleanup(struct hv_driver *Driver)
{
}
@@ -806,11 +809,11 @@ int stor_vsc_initialize(struct hv_driver *Driver)
STORVSC_MAX_IO_REQUESTS);
/* Setup the dispatch table */
- storDriver->base.OnDeviceAdd = StorVscOnDeviceAdd;
- storDriver->base.OnDeviceRemove = StorVscOnDeviceRemove;
- storDriver->base.OnCleanup = StorVscOnCleanup;
+ storDriver->base.OnDeviceAdd = stor_vsc_on_device_add;
+ storDriver->base.OnDeviceRemove = stor_vsc_on_device_remove;
+ storDriver->base.OnCleanup = stor_vsc_on_cleanup;
- storDriver->on_io_request = StorVscOnIORequest;
+ storDriver->on_io_request = stor_vsc_on_io_request;
return 0;
}
--
1.6.0.2
^ permalink raw reply related
* [PATCH 6/8] staging: hv: Convert camel case local variables in storvsc.c to lowercase
From: Hank Janssen @ 2010-12-06 20:26 UTC (permalink / raw)
To: hjanssen, gregkh, linux-kernel, devel, virtualization
Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1291667211-1865-5-git-send-email-hjanssen@microsoft.com>
From: Hank Janssen <hjanssen@microsoft.com>
Convert camel case local variables in storvsc.c to lowercase
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/storvsc.c | 496 +++++++++++++++++++++---------------------
1 files changed, 249 insertions(+), 247 deletions(-)
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 6643038..9295113 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -50,7 +50,7 @@ struct storvsc_device {
/* 0 indicates the device is being destroyed */
atomic_t ref_count;
- atomic_t num_outstanding_requests;
+ atomic_t num_outstanding_req;
/*
* Each unique Port/Path/Target represents 1 channel ie scsi
@@ -81,119 +81,119 @@ static const struct hv_guid gStorVscDeviceType = {
};
-static inline struct storvsc_device *alloc_stor_device(struct hv_device *Device)
+static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
- storDevice = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
- if (!storDevice)
+ stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
+ if (!stor_device)
return NULL;
/* Set to 2 to allow both inbound and outbound traffics */
/* (ie get_stor_device() and must_get_stor_device()) to proceed. */
- atomic_cmpxchg(&storDevice->ref_count, 0, 2);
+ atomic_cmpxchg(&stor_device->ref_count, 0, 2);
- storDevice->device = Device;
- Device->Extension = storDevice;
+ stor_device->device = device;
+ device->Extension = stor_device;
- return storDevice;
+ return stor_device;
}
-static inline void free_stor_device(struct storvsc_device *Device)
+static inline void free_stor_device(struct storvsc_device *device)
{
- /* ASSERT(atomic_read(&Device->ref_count) == 0); */
- kfree(Device);
+ /* ASSERT(atomic_read(&device->ref_count) == 0); */
+ kfree(device);
}
/* Get the stordevice object iff exists and its refcount > 1 */
-static inline struct storvsc_device *get_stor_device(struct hv_device *Device)
+static inline struct storvsc_device *get_stor_device(struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
- storDevice = (struct storvsc_device *)Device->Extension;
- if (storDevice && atomic_read(&storDevice->ref_count) > 1)
- atomic_inc(&storDevice->ref_count);
+ stor_device = (struct storvsc_device *)device->Extension;
+ if (stor_device && atomic_read(&stor_device->ref_count) > 1)
+ atomic_inc(&stor_device->ref_count);
else
- storDevice = NULL;
+ stor_device = NULL;
- return storDevice;
+ return stor_device;
}
/* Get the stordevice object iff exists and its refcount > 0 */
static inline struct storvsc_device *must_get_stor_device(
- struct hv_device *Device)
+ struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
- storDevice = (struct storvsc_device *)Device->Extension;
- if (storDevice && atomic_read(&storDevice->ref_count))
- atomic_inc(&storDevice->ref_count);
+ stor_device = (struct storvsc_device *)device->Extension;
+ if (stor_device && atomic_read(&stor_device->ref_count))
+ atomic_inc(&stor_device->ref_count);
else
- storDevice = NULL;
+ stor_device = NULL;
- return storDevice;
+ return stor_device;
}
-static inline void put_stor_device(struct hv_device *Device)
+static inline void put_stor_device(struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
- storDevice = (struct storvsc_device *)Device->Extension;
- /* ASSERT(storDevice); */
+ stor_device = (struct storvsc_device *)device->Extension;
+ /* ASSERT(stor_device); */
- atomic_dec(&storDevice->ref_count);
- /* ASSERT(atomic_read(&storDevice->ref_count)); */
+ atomic_dec(&stor_device->ref_count);
+ /* ASSERT(atomic_read(&stor_device->ref_count)); */
}
/* Drop ref count to 1 to effectively disable get_stor_device() */
static inline struct storvsc_device *release_stor_device(
- struct hv_device *Device)
+ struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
- storDevice = (struct storvsc_device *)Device->Extension;
- /* ASSERT(storDevice); */
+ stor_device = (struct storvsc_device *)device->Extension;
+ /* ASSERT(stor_device); */
/* Busy wait until the ref drop to 2, then set it to 1 */
- while (atomic_cmpxchg(&storDevice->ref_count, 2, 1) != 2)
+ while (atomic_cmpxchg(&stor_device->ref_count, 2, 1) != 2)
udelay(100);
- return storDevice;
+ return stor_device;
}
-/* Drop ref count to 0. No one can use StorDevice object. */
+/* Drop ref count to 0. No one can use stor_device object. */
static inline struct storvsc_device *final_release_stor_device(
- struct hv_device *Device)
+ struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
- storDevice = (struct storvsc_device *)Device->Extension;
- /* ASSERT(storDevice); */
+ stor_device = (struct storvsc_device *)device->Extension;
+ /* ASSERT(stor_device); */
/* Busy wait until the ref drop to 1, then set it to 0 */
- while (atomic_cmpxchg(&storDevice->ref_count, 1, 0) != 1)
+ while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
udelay(100);
- Device->Extension = NULL;
- return storDevice;
+ device->Extension = NULL;
+ return stor_device;
}
-static int stor_vsc_channel_init(struct hv_device *Device)
+static int stor_vsc_channel_init(struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
struct storvsc_request_extension *request;
- struct vstor_packet *vstorPacket;
+ struct vstor_packet *vstor_packet;
int ret;
- storDevice = get_stor_device(Device);
- if (!storDevice) {
+ stor_device = get_stor_device(device);
+ if (!stor_device) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
return -1;
}
- request = &storDevice->init_request;
- vstorPacket = &request->vstor_packet;
+ request = &stor_device->init_request;
+ vstor_packet = &request->vstor_packet;
/*
* Now, initiate the vsc/vsp initialization protocol on the open
@@ -206,8 +206,8 @@ static int stor_vsc_channel_init(struct hv_device *Device)
goto nomem;
}
- vstorPacket->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
- vstorPacket->flags = REQUEST_COMPLETION_FLAG;
+ vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
+ vstor_packet->flags = REQUEST_COMPLETION_FLAG;
/*SpinlockAcquire(gDriverExt.packetListLock);
INSERT_TAIL_LIST(&gDriverExt.packetList, &packet->listEntry.entry);
@@ -215,7 +215,7 @@ static int stor_vsc_channel_init(struct hv_device *Device)
DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION...");
- ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
VmbusPacketTypeDataInBand,
@@ -228,25 +228,25 @@ static int stor_vsc_channel_init(struct hv_device *Device)
osd_waitevent_wait(request->wait_event);
- if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstorPacket->status != 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)",
- vstorPacket->operation, vstorPacket->status);
+ vstor_packet->operation, vstor_packet->status);
goto Cleanup;
}
DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
/* reuse the packet for version range supported */
- memset(vstorPacket, 0, sizeof(struct vstor_packet));
- vstorPacket->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
- vstorPacket->flags = REQUEST_COMPLETION_FLAG;
+ memset(vstor_packet, 0, sizeof(struct vstor_packet));
+ vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
+ vstor_packet->flags = REQUEST_COMPLETION_FLAG;
- vstorPacket->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
- FILL_VMSTOR_REVISION(vstorPacket->version.revision);
+ vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
+ FILL_VMSTOR_REVISION(vstor_packet->version.revision);
- ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
VmbusPacketTypeDataInBand,
@@ -260,24 +260,24 @@ static int stor_vsc_channel_init(struct hv_device *Device)
osd_waitevent_wait(request->wait_event);
/* TODO: Check returned version */
- if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstorPacket->status != 0) {
+ 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)",
- vstorPacket->operation, vstorPacket->status);
+ vstor_packet->operation, vstor_packet->status);
goto Cleanup;
}
/* Query channel properties */
DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
- memset(vstorPacket, 0, sizeof(struct vstor_packet));
- vstorPacket->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
- vstorPacket->flags = REQUEST_COMPLETION_FLAG;
- vstorPacket->storage_channel_properties.port_number =
- storDevice->port_number;
+ memset(vstor_packet, 0, sizeof(struct vstor_packet));
+ vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
+ vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+ vstor_packet->storage_channel_properties.port_number =
+ stor_device->port_number;
- ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
VmbusPacketTypeDataInBand,
@@ -292,29 +292,29 @@ static int stor_vsc_channel_init(struct hv_device *Device)
osd_waitevent_wait(request->wait_event);
/* TODO: Check returned version */
- if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstorPacket->status != 0) {
+ if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
+ vstor_packet->status != 0) {
DPRINT_ERR(STORVSC, "QUERY_PROPERTIES_OPERATION failed "
"(op %d status 0x%x)",
- vstorPacket->operation, vstorPacket->status);
+ vstor_packet->operation, vstor_packet->status);
goto Cleanup;
}
- storDevice->path_id = vstorPacket->storage_channel_properties.path_id;
- storDevice->target_id
- = vstorPacket->storage_channel_properties.target_id;
+ 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",
- vstorPacket->storage_channel_properties.flags,
- vstorPacket->storage_channel_properties.max_transfer_bytes);
+ vstor_packet->storage_channel_properties.flags,
+ vstor_packet->storage_channel_properties.max_transfer_bytes);
DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
- memset(vstorPacket, 0, sizeof(struct vstor_packet));
- vstorPacket->operation = VSTOR_OPERATION_END_INITIALIZATION;
- vstorPacket->flags = REQUEST_COMPLETION_FLAG;
+ memset(vstor_packet, 0, sizeof(struct vstor_packet));
+ vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
+ vstor_packet->flags = REQUEST_COMPLETION_FLAG;
- ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
VmbusPacketTypeDataInBand,
@@ -328,11 +328,11 @@ static int stor_vsc_channel_init(struct hv_device *Device)
osd_waitevent_wait(request->wait_event);
- if (vstorPacket->operation != VSTOR_OPERATION_COMPLETE_IO ||
- vstorPacket->status != 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)",
- vstorPacket->operation, vstorPacket->status);
+ vstor_packet->operation, vstor_packet->status);
goto Cleanup;
}
@@ -342,82 +342,82 @@ Cleanup:
kfree(request->wait_event);
request->wait_event = NULL;
nomem:
- put_stor_device(Device);
+ put_stor_device(device);
return ret;
}
-static void stor_vsc_on_io_completion(struct hv_device *Device,
- struct vstor_packet *VStorPacket,
- struct storvsc_request_extension *RequestExt)
+static void stor_vsc_on_io_completion(struct hv_device *device,
+ struct vstor_packet *vstor_packet,
+ struct storvsc_request_extension *request_ext)
{
struct hv_storvsc_request *request;
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
- storDevice = must_get_stor_device(Device);
- if (!storDevice) {
+ stor_device = must_get_stor_device(device);
+ if (!stor_device) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
return;
}
DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request extension %p "
- "completed bytes xfer %u", RequestExt,
- VStorPacket->vm_srb.data_transfer_length);
+ "completed bytes xfer %u", request_ext,
+ vstor_packet->vm_srb.data_transfer_length);
- /* ASSERT(RequestExt != NULL); */
- /* ASSERT(RequestExt->Request != NULL); */
+ /* ASSERT(request_ext != NULL); */
+ /* ASSERT(request_ext->request != NULL); */
- request = RequestExt->request;
+ request = request_ext->request;
/* ASSERT(request->OnIOCompletion != NULL); */
/* Copy over the status...etc */
- request->status = VStorPacket->vm_srb.scsi_status;
+ request->status = vstor_packet->vm_srb.scsi_status;
- if (request->status != 0 || VStorPacket->vm_srb.srb_status != 1) {
+ if (request->status != 0 || vstor_packet->vm_srb.srb_status != 1) {
DPRINT_WARN(STORVSC,
"cmd 0x%x scsi status 0x%x srb status 0x%x\n",
- request->cdb[0], VStorPacket->vm_srb.scsi_status,
- VStorPacket->vm_srb.srb_status);
+ request->cdb[0], vstor_packet->vm_srb.scsi_status,
+ vstor_packet->vm_srb.srb_status);
}
if ((request->status & 0xFF) == 0x02) {
/* CHECK_CONDITION */
- if (VStorPacket->vm_srb.srb_status & 0x80) {
+ if (vstor_packet->vm_srb.srb_status & 0x80) {
/* autosense data available */
DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data "
- "valid - len %d\n", RequestExt,
- VStorPacket->vm_srb.sense_info_length);
+ "valid - len %d\n", request_ext,
+ vstor_packet->vm_srb.sense_info_length);
- /* ASSERT(VStorPacket->vm_srb.sense_info_length <= */
+ /* ASSERT(vstor_packet->vm_srb.sense_info_length <= */
/* request->SenseBufferSize); */
memcpy(request->sense_buffer,
- VStorPacket->vm_srb.sense_data,
- VStorPacket->vm_srb.sense_info_length);
+ vstor_packet->vm_srb.sense_data,
+ vstor_packet->vm_srb.sense_info_length);
request->sense_buffer_size =
- VStorPacket->vm_srb.sense_info_length;
+ vstor_packet->vm_srb.sense_info_length;
}
}
/* TODO: */
- request->bytes_xfer = VStorPacket->vm_srb.data_transfer_length;
+ request->bytes_xfer = vstor_packet->vm_srb.data_transfer_length;
request->on_io_completion(request);
- atomic_dec(&storDevice->num_outstanding_requests);
+ atomic_dec(&stor_device->num_outstanding_req);
- put_stor_device(Device);
+ put_stor_device(device);
}
-static void stor_vsc_on_receive(struct hv_device *Device,
- struct vstor_packet *VStorPacket,
- struct storvsc_request_extension *RequestExt)
+static void stor_vsc_on_receive(struct hv_device *device,
+ struct vstor_packet *vstor_packet,
+ struct storvsc_request_extension *request_ext)
{
- switch (VStorPacket->operation) {
+ switch (vstor_packet->operation) {
case VSTOR_OPERATION_COMPLETE_IO:
DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION");
- stor_vsc_on_io_completion(Device, VStorPacket, RequestExt);
+ stor_vsc_on_io_completion(device, vstor_packet, request_ext);
break;
case VSTOR_OPERATION_REMOVE_DEVICE:
DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
@@ -426,7 +426,7 @@ static void stor_vsc_on_receive(struct hv_device *Device,
default:
DPRINT_INFO(STORVSC, "Unknown operation received - %d",
- VStorPacket->operation);
+ vstor_packet->operation);
break;
}
}
@@ -434,17 +434,17 @@ static void stor_vsc_on_receive(struct hv_device *Device,
static void stor_vsc_on_channel_callback(void *context)
{
struct hv_device *device = (struct hv_device *)context;
- struct storvsc_device *storDevice;
- u32 bytesRecvd;
- u64 requestId;
+ struct storvsc_device *stor_device;
+ u32 bytes_recvd;
+ u64 request_id;
unsigned char packet[ALIGN_UP(sizeof(struct vstor_packet), 8)];
struct storvsc_request_extension *request;
int ret;
/* ASSERT(device); */
- storDevice = must_get_stor_device(device);
- if (!storDevice) {
+ stor_device = must_get_stor_device(device);
+ if (!stor_device) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
return;
@@ -453,25 +453,26 @@ static void stor_vsc_on_channel_callback(void *context)
do {
ret = vmbus_recvpacket(device->channel, packet,
ALIGN_UP(sizeof(struct vstor_packet), 8),
- &bytesRecvd, &requestId);
- if (ret == 0 && bytesRecvd > 0) {
+ &bytes_recvd, &request_id);
+ if (ret == 0 && bytes_recvd > 0) {
DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx",
- bytesRecvd, requestId);
+ bytes_recvd, request_id);
- /* ASSERT(bytesRecvd == sizeof(struct vstor_packet)); */
+ /* ASSERT(bytes_recvd ==
+ sizeof(struct vstor_packet)); */
request = (struct storvsc_request_extension *)
- (unsigned long)requestId;
+ (unsigned long)request_id;
/* ASSERT(request);c */
- /* if (vstorPacket.Flags & SYNTHETIC_FLAG) */
- if ((request == &storDevice->init_request) ||
- (request == &storDevice->reset_request)) {
+ /* if (vstor_packet.Flags & SYNTHETIC_FLAG) */
+ if ((request == &stor_device->init_request) ||
+ (request == &stor_device->reset_request)) {
/* DPRINT_INFO(STORVSC,
* "reset completion - operation "
* "%u status %u",
- * vstorPacket.Operation,
- * vstorPacket.Status); */
+ * vstor_packet.Operation,
+ * vstor_packet.Status); */
memcpy(&request->vstor_packet, packet,
sizeof(struct vstor_packet));
@@ -492,22 +493,22 @@ static void stor_vsc_on_channel_callback(void *context)
return;
}
-static int stor_vsc_connect_to_vsp(struct hv_device *Device)
+static int stor_vsc_connect_to_vsp(struct hv_device *device)
{
struct vmstorage_channel_properties props;
- struct storvsc_driver_object *storDriver;
+ struct storvsc_driver_object *stor_driver;
int ret;
- storDriver = (struct storvsc_driver_object *)Device->Driver;
+ stor_driver = (struct storvsc_driver_object *)device->Driver;
memset(&props, 0, sizeof(struct vmstorage_channel_properties));
/* Open the channel */
- ret = vmbus_open(Device->channel,
- storDriver->ring_buffer_size,
- storDriver->ring_buffer_size,
+ ret = vmbus_open(device->channel,
+ stor_driver->ring_buffer_size,
+ stor_driver->ring_buffer_size,
(void *)&props,
sizeof(struct vmstorage_channel_properties),
- stor_vsc_on_channel_callback, Device);
+ stor_vsc_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);
@@ -517,7 +518,7 @@ static int stor_vsc_connect_to_vsp(struct hv_device *Device)
return -1;
}
- ret = stor_vsc_channel_init(Device);
+ ret = stor_vsc_channel_init(device);
return ret;
}
@@ -526,17 +527,17 @@ static int stor_vsc_connect_to_vsp(struct hv_device *Device)
* stor_vsc_on_device_add - Callback when the device belonging to this driver
* is added
*/
-static int stor_vsc_on_device_add(struct hv_device *Device,
- void *AdditionalInfo)
+static int stor_vsc_on_device_add(struct hv_device *device,
+ void *additional_info)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
/* struct vmstorage_channel_properties *props; */
- struct storvsc_device_info *deviceInfo;
+ struct storvsc_device_info *device_info;
int ret = 0;
- deviceInfo = (struct storvsc_device_info *)AdditionalInfo;
- storDevice = alloc_stor_device(Device);
- if (!storDevice) {
+ device_info = (struct storvsc_device_info *)additional_info;
+ stor_device = alloc_stor_device(device);
+ if (!stor_device) {
ret = -1;
goto Cleanup;
}
@@ -556,17 +557,17 @@ static int stor_vsc_on_device_add(struct hv_device *Device,
storChannel->PathId = props->PathId;
storChannel->TargetId = props->TargetId; */
- storDevice->port_number = deviceInfo->port_number;
+ stor_device->port_number = device_info->port_number;
/* Send it back up */
- ret = stor_vsc_connect_to_vsp(Device);
+ ret = stor_vsc_connect_to_vsp(device);
- /* deviceInfo->PortNumber = storDevice->PortNumber; */
- deviceInfo->path_id = storDevice->path_id;
- deviceInfo->target_id = storDevice->target_id;
+ /* device_info->PortNumber = stor_device->PortNumber; */
+ 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",
- storDevice->port_number, storDevice->path_id,
- storDevice->target_id);
+ stor_device->port_number, stor_device->path_id,
+ stor_device->target_id);
Cleanup:
return ret;
@@ -575,58 +576,58 @@ Cleanup:
/*
* stor_vsc_on_device_remove - Callback when the our device is being removed
*/
-static int stor_vsc_on_device_remove(struct hv_device *Device)
+static int stor_vsc_on_device_remove(struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
- Device->Extension);
+ device->Extension);
- storDevice = release_stor_device(Device);
+ stor_device = release_stor_device(device);
/*
* At this point, all outbound traffic should be disable. We
* only allow inbound traffic (responses) to proceed so that
* outstanding requests can be completed.
*/
- while (atomic_read(&storDevice->num_outstanding_requests)) {
+ while (atomic_read(&stor_device->num_outstanding_req)) {
DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
- atomic_read(&storDevice->num_outstanding_requests));
+ atomic_read(&stor_device->num_outstanding_req));
udelay(100);
}
DPRINT_INFO(STORVSC, "removing storage device (%p)...",
- Device->Extension);
+ device->Extension);
- storDevice = final_release_stor_device(Device);
+ stor_device = final_release_stor_device(device);
- DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", storDevice);
+ DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", stor_device);
/* Close the channel */
- vmbus_close(Device->channel);
+ vmbus_close(device->channel);
- free_stor_device(storDevice);
+ free_stor_device(stor_device);
return 0;
}
-int stor_vsc_on_host_reset(struct hv_device *Device)
+int stor_vsc_on_host_reset(struct hv_device *device)
{
- struct storvsc_device *storDevice;
+ struct storvsc_device *stor_device;
struct storvsc_request_extension *request;
- struct vstor_packet *vstorPacket;
+ struct vstor_packet *vstor_packet;
int ret;
DPRINT_INFO(STORVSC, "resetting host adapter...");
- storDevice = get_stor_device(Device);
- if (!storDevice) {
+ stor_device = get_stor_device(device);
+ if (!stor_device) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
return -1;
}
- request = &storDevice->reset_request;
- vstorPacket = &request->vstor_packet;
+ request = &stor_device->reset_request;
+ vstor_packet = &request->vstor_packet;
request->wait_event = osd_waitevent_create();
if (!request->wait_event) {
@@ -634,18 +635,18 @@ int stor_vsc_on_host_reset(struct hv_device *Device)
goto Cleanup;
}
- vstorPacket->operation = VSTOR_OPERATION_RESET_BUS;
- vstorPacket->flags = REQUEST_COMPLETION_FLAG;
- vstorPacket->vm_srb.path_id = storDevice->path_id;
+ vstor_packet->operation = VSTOR_OPERATION_RESET_BUS;
+ vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+ vstor_packet->vm_srb.path_id = stor_device->path_id;
- ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
- (unsigned long)&storDevice->reset_request,
+ (unsigned long)&stor_device->reset_request,
VmbusPacketTypeDataInBand,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC, "Unable to send reset packet %p ret %d",
- vstorPacket, ret);
+ vstor_packet, ret);
goto Cleanup;
}
@@ -661,118 +662,118 @@ int stor_vsc_on_host_reset(struct hv_device *Device)
*/
Cleanup:
- put_stor_device(Device);
+ put_stor_device(device);
return ret;
}
/*
* stor_vsc_on_io_request - Callback to initiate an I/O request
*/
-static int stor_vsc_on_io_request(struct hv_device *Device,
- struct hv_storvsc_request *Request)
+static int stor_vsc_on_io_request(struct hv_device *device,
+ struct hv_storvsc_request *request)
{
- struct storvsc_device *storDevice;
- struct storvsc_request_extension *requestExtension;
- struct vstor_packet *vstorPacket;
+ struct storvsc_device *stor_device;
+ struct storvsc_request_extension *request_extension;
+ struct vstor_packet *vstor_packet;
int ret = 0;
- requestExtension =
- (struct storvsc_request_extension *)Request->extension;
- vstorPacket = &requestExtension->vstor_packet;
- storDevice = get_stor_device(Device);
+ request_extension =
+ (struct storvsc_request_extension *)request->extension;
+ vstor_packet = &request_extension->vstor_packet;
+ stor_device = get_stor_device(device);
DPRINT_DBG(STORVSC, "enter - Device %p, DeviceExt %p, Request %p, "
- "Extension %p", Device, storDevice, Request,
- requestExtension);
+ "Extension %p", device, stor_device, request,
+ request_extension);
DPRINT_DBG(STORVSC, "req %p len %d bus %d, target %d, lun %d cdblen %d",
- Request, Request->data_buffer.Length, Request->bus,
- Request->target_id, Request->lun_id, Request->cdb_len);
+ request, request->data_buffer.Length, request->bus,
+ request->target_id, request->lun_id, request->cdb_len);
- if (!storDevice) {
+ if (!stor_device) {
DPRINT_ERR(STORVSC, "unable to get stor device..."
"device being destroyed?");
return -2;
}
- /* print_hex_dump_bytes("", DUMP_PREFIX_NONE, Request->Cdb,
- * Request->CdbLen); */
+ /* print_hex_dump_bytes("", DUMP_PREFIX_NONE, request->Cdb,
+ * request->CdbLen); */
- requestExtension->request = Request;
- requestExtension->device = Device;
+ request_extension->request = request;
+ request_extension->device = device;
- memset(vstorPacket, 0 , sizeof(struct vstor_packet));
+ memset(vstor_packet, 0 , sizeof(struct vstor_packet));
- vstorPacket->flags |= REQUEST_COMPLETION_FLAG;
+ vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
- vstorPacket->vm_srb.length = sizeof(struct vmscsi_request);
+ vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
- vstorPacket->vm_srb.port_number = Request->host;
- vstorPacket->vm_srb.path_id = Request->bus;
- vstorPacket->vm_srb.target_id = Request->target_id;
- vstorPacket->vm_srb.lun = Request->lun_id;
+ vstor_packet->vm_srb.port_number = request->host;
+ vstor_packet->vm_srb.path_id = request->bus;
+ vstor_packet->vm_srb.target_id = request->target_id;
+ vstor_packet->vm_srb.lun = request->lun_id;
- vstorPacket->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
+ vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
/* Copy over the scsi command descriptor block */
- vstorPacket->vm_srb.cdb_length = Request->cdb_len;
- memcpy(&vstorPacket->vm_srb.cdb, Request->cdb, Request->cdb_len);
+ vstor_packet->vm_srb.cdb_length = request->cdb_len;
+ memcpy(&vstor_packet->vm_srb.cdb, request->cdb, request->cdb_len);
- vstorPacket->vm_srb.data_in = Request->type;
- vstorPacket->vm_srb.data_transfer_length = Request->data_buffer.Length;
+ vstor_packet->vm_srb.data_in = request->type;
+ vstor_packet->vm_srb.data_transfer_length = request->data_buffer.Length;
- vstorPacket->operation = VSTOR_OPERATION_EXECUTE_SRB;
+ 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",
- vstorPacket->vm_srb.length,
- vstorPacket->vm_srb.port_number,
- vstorPacket->vm_srb.path_id,
- vstorPacket->vm_srb.target_id,
- vstorPacket->vm_srb.lun,
- vstorPacket->vm_srb.sense_info_length,
- vstorPacket->vm_srb.cdb_length);
-
- if (requestExtension->request->data_buffer.Length) {
- ret = vmbus_sendpacket_multipagebuffer(Device->channel,
- &requestExtension->request->data_buffer,
- vstorPacket,
+ 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_extension->request->data_buffer.Length) {
+ ret = vmbus_sendpacket_multipagebuffer(device->channel,
+ &request_extension->request->data_buffer,
+ vstor_packet,
sizeof(struct vstor_packet),
- (unsigned long)requestExtension);
+ (unsigned long)request_extension);
} else {
- ret = vmbus_sendpacket(Device->channel, vstorPacket,
+ ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
- (unsigned long)requestExtension,
+ (unsigned long)request_extension,
VmbusPacketTypeDataInBand,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
}
if (ret != 0) {
DPRINT_DBG(STORVSC, "Unable to send packet %p ret %d",
- vstorPacket, ret);
+ vstor_packet, ret);
}
- atomic_inc(&storDevice->num_outstanding_requests);
+ atomic_inc(&stor_device->num_outstanding_req);
- put_stor_device(Device);
+ put_stor_device(device);
return ret;
}
/*
* stor_vsc_on_cleanup - Perform any cleanup when the driver is removed
*/
-static void stor_vsc_on_cleanup(struct hv_driver *Driver)
+static void stor_vsc_on_cleanup(struct hv_driver *driver)
{
}
/*
* stor_vsc_initialize - Main entry point
*/
-int stor_vsc_initialize(struct hv_driver *Driver)
+int stor_vsc_initialize(struct hv_driver *driver)
{
- struct storvsc_driver_object *storDriver;
+ struct storvsc_driver_object *stor_driver;
- storDriver = (struct storvsc_driver_object *)Driver;
+ stor_driver = (struct storvsc_driver_object *)driver;
DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd "
"sizeof(struct storvsc_request_extension)=%zd "
@@ -784,13 +785,14 @@ int stor_vsc_initialize(struct hv_driver *Driver)
sizeof(struct vmscsi_request));
/* Make sure we are at least 2 pages since 1 page is used for control */
- /* ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1)); */
+ /* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
- Driver->name = g_driver_name;
- memcpy(&Driver->deviceType, &gStorVscDeviceType,
+ driver->name = g_driver_name;
+ memcpy(&driver->deviceType, &gStorVscDeviceType,
sizeof(struct hv_guid));
- storDriver->request_ext_size = sizeof(struct storvsc_request_extension);
+ stor_driver->request_ext_size =
+ sizeof(struct storvsc_request_extension);
/*
* Divide the ring buffer data size (which is 1 page less
@@ -798,22 +800,22 @@ int stor_vsc_initialize(struct hv_driver *Driver)
* the ring buffer indices) by the max request size (which is
* vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
*/
- storDriver->max_outstanding_req_per_channel =
- ((storDriver->ring_buffer_size - PAGE_SIZE) /
+ stor_driver->max_outstanding_req_per_channel =
+ ((stor_driver->ring_buffer_size - PAGE_SIZE) /
ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET +
sizeof(struct vstor_packet) + sizeof(u64),
sizeof(u64)));
DPRINT_INFO(STORVSC, "max io %u, currently %u\n",
- storDriver->max_outstanding_req_per_channel,
+ stor_driver->max_outstanding_req_per_channel,
STORVSC_MAX_IO_REQUESTS);
/* Setup the dispatch table */
- storDriver->base.OnDeviceAdd = stor_vsc_on_device_add;
- storDriver->base.OnDeviceRemove = stor_vsc_on_device_remove;
- storDriver->base.OnCleanup = stor_vsc_on_cleanup;
+ stor_driver->base.OnDeviceAdd = stor_vsc_on_device_add;
+ stor_driver->base.OnDeviceRemove = stor_vsc_on_device_remove;
+ stor_driver->base.OnCleanup = stor_vsc_on_cleanup;
- storDriver->on_io_request = stor_vsc_on_io_request;
+ stor_driver->on_io_request = stor_vsc_on_io_request;
return 0;
}
--
1.6.0.2
^ permalink raw reply related
* [PATCH 7/8] staging: hv: Convert camel case function names in blkvsc.c to lowercase
From: Hank Janssen @ 2010-12-06 20:26 UTC (permalink / raw)
To: hjanssen, gregkh, linux-kernel, devel, virtualization
Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1291667211-1865-6-git-send-email-hjanssen@microsoft.com>
From: Hank Janssen <hjanssen@microsoft.com>
Convert camel case function names in blkvsc.c to lowercase
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
index 208492c..4f4a65c 100644
--- a/drivers/staging/hv/blkvsc.c
+++ b/drivers/staging/hv/blkvsc.c
@@ -35,7 +35,7 @@ static const struct hv_guid gBlkVscDeviceType = {
}
};
-static int BlkVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
+static int blk_vsc_on_device_add(struct hv_device *Device, void *AdditionalInfo)
{
struct storvsc_device_info *deviceInfo;
int ret = 0;
@@ -93,7 +93,7 @@ int blk_vsc_initialize(struct hv_driver *Driver)
storDriver->max_outstanding_req_per_channel);
/* Setup the dispatch table */
- storDriver->base.OnDeviceAdd = BlkVscOnDeviceAdd;
+ storDriver->base.OnDeviceAdd = blk_vsc_on_device_add;
storDriver->base.OnDeviceRemove = stor_vsc_on_device_remove;
storDriver->base.OnCleanup = stor_vsc_on_cleanup;
storDriver->on_io_request = stor_vsc_on_io_request;
--
1.6.0.2
^ permalink raw reply related
* [PATCH 8/8] staging: hv: Convert camel case local variables in blkvsc.c to lowercase
From: Hank Janssen @ 2010-12-06 20:26 UTC (permalink / raw)
To: hjanssen, gregkh, linux-kernel, devel, virtualization
Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1291667211-1865-7-git-send-email-hjanssen@microsoft.com>
From: Hank Janssen <hjanssen@microsoft.com>
Convert camel case local variables in blkvsc.c to lowercase
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc.c | 52 +++++++++++++++++++++---------------------
1 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
index 4f4a65c..bc16d91 100644
--- a/drivers/staging/hv/blkvsc.c
+++ b/drivers/staging/hv/blkvsc.c
@@ -25,24 +25,24 @@
#include "osd.h"
#include "storvsc.c"
-static const char *gBlkDriverName = "blkvsc";
+static const char *g_blk_driver_name = "blkvsc";
/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const struct hv_guid gBlkVscDeviceType = {
+static const struct hv_guid g_blk_device_type = {
.data = {
0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
}
};
-static int blk_vsc_on_device_add(struct hv_device *Device, void *AdditionalInfo)
+static int blk_vsc_on_device_add(struct hv_device *device, void *additional_info)
{
- struct storvsc_device_info *deviceInfo;
+ struct storvsc_device_info *device_info;
int ret = 0;
- deviceInfo = (struct storvsc_device_info *)AdditionalInfo;
+ device_info = (struct storvsc_device_info *)additional_info;
- ret = stor_vsc_on_device_add(Device, AdditionalInfo);
+ ret = stor_vsc_on_device_add(device, additional_info);
if (ret != 0)
return ret;
@@ -51,31 +51,31 @@ static int blk_vsc_on_device_add(struct hv_device *Device, void *AdditionalInfo)
* id. For IDE devices, the device instance id is formatted as
* <bus id> * - <device id> - 8899 - 000000000000.
*/
- deviceInfo->path_id = Device->deviceInstance.data[3] << 24 |
- Device->deviceInstance.data[2] << 16 |
- Device->deviceInstance.data[1] << 8 |
- Device->deviceInstance.data[0];
+ device_info->path_id = device->deviceInstance.data[3] << 24 |
+ device->deviceInstance.data[2] << 16 |
+ device->deviceInstance.data[1] << 8 |
+ device->deviceInstance.data[0];
- deviceInfo->target_id = Device->deviceInstance.data[5] << 8 |
- Device->deviceInstance.data[4];
+ device_info->target_id = device->deviceInstance.data[5] << 8 |
+ device->deviceInstance.data[4];
return ret;
}
-int blk_vsc_initialize(struct hv_driver *Driver)
+int blk_vsc_initialize(struct hv_driver *driver)
{
- struct storvsc_driver_object *storDriver;
+ struct storvsc_driver_object *stor_driver;
int ret = 0;
- storDriver = (struct storvsc_driver_object *)Driver;
+ stor_driver = (struct storvsc_driver_object *)driver;
/* Make sure we are at least 2 pages since 1 page is used for control */
- /* ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1)); */
+ /* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
- Driver->name = gBlkDriverName;
- memcpy(&Driver->deviceType, &gBlkVscDeviceType, sizeof(struct hv_guid));
+ driver->name = g_blk_driver_name;
+ memcpy(&driver->deviceType, &g_blk_device_type, sizeof(struct hv_guid));
- storDriver->request_ext_size = sizeof(struct storvsc_request_extension);
+ stor_driver->request_ext_size = sizeof(struct storvsc_request_extension);
/*
* Divide the ring buffer data size (which is 1 page less than the ring
@@ -83,20 +83,20 @@ int blk_vsc_initialize(struct hv_driver *Driver)
* by the max request size (which is
* vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
*/
- storDriver->max_outstanding_req_per_channel =
- ((storDriver->ring_buffer_size - PAGE_SIZE) /
+ stor_driver->max_outstanding_req_per_channel =
+ ((stor_driver->ring_buffer_size - PAGE_SIZE) /
ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET +
sizeof(struct vstor_packet) + sizeof(u64),
sizeof(u64)));
DPRINT_INFO(BLKVSC, "max io outstd %u",
- storDriver->max_outstanding_req_per_channel);
+ stor_driver->max_outstanding_req_per_channel);
/* Setup the dispatch table */
- storDriver->base.OnDeviceAdd = blk_vsc_on_device_add;
- storDriver->base.OnDeviceRemove = stor_vsc_on_device_remove;
- storDriver->base.OnCleanup = stor_vsc_on_cleanup;
- storDriver->on_io_request = stor_vsc_on_io_request;
+ stor_driver->base.OnDeviceAdd = blk_vsc_on_device_add;
+ stor_driver->base.OnDeviceRemove = stor_vsc_on_device_remove;
+ stor_driver->base.OnCleanup = stor_vsc_on_cleanup;
+ stor_driver->on_io_request = stor_vsc_on_io_request;
return ret;
}
--
1.6.0.2
^ permalink raw reply related
* Re: [PATCH 2/8] staging: hv: Convert camel case struct fields in storvsc_api.h to lowercase
From: Ky Srinivasan @ 2010-12-07 0:59 UTC (permalink / raw)
To: devel, virtualization, hjanssen, gregkh, linux-kernel
Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1291667211-1865-2-git-send-email-hjanssen@microsoft.com>
Greg,
My new KVP patches are ready to go. Should I wait for Hank's patches to be checked in before I send the KVP patches?
Regards
K. Y
>>> On 12/6/2010 at 3:26 PM, in message
<1291667211-1865-2-git-send-email-hjanssen@microsoft.com>, Hank Janssen
<hjanssen@microsoft.com> wrote:
> From: Hank Janssen <hjanssen@microsoft.com>
>
> Convert camel case struct fields in vstorage.h to lowercase
>
> Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
>
> ---
> drivers/staging/hv/blkvsc.c | 20 +++---
> drivers/staging/hv/blkvsc_drv.c | 115 ++++++++++++++++++++------------------
> drivers/staging/hv/storvsc.c | 67 +++++++++++-----------
> drivers/staging/hv/storvsc_api.h | 50 ++++++++--------
> drivers/staging/hv/storvsc_drv.c | 91 +++++++++++++++---------------
> 5 files changed, 175 insertions(+), 168 deletions(-)
>
> diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
> index d5b0abd..9ac04c3 100644
> --- a/drivers/staging/hv/blkvsc.c
> +++ b/drivers/staging/hv/blkvsc.c
> @@ -51,12 +51,12 @@ static int BlkVscOnDeviceAdd(struct hv_device *Device,
> void *AdditionalInfo)
> * id. For IDE devices, the device instance id is formatted as
> * <bus id> * - <device id> - 8899 - 000000000000.
> */
> - deviceInfo->PathId = Device->deviceInstance.data[3] << 24 |
> + deviceInfo->path_id = Device->deviceInstance.data[3] << 24 |
> Device->deviceInstance.data[2] << 16 |
> Device->deviceInstance.data[1] << 8 |
> Device->deviceInstance.data[0];
>
> - deviceInfo->TargetId = Device->deviceInstance.data[5] << 8 |
> + deviceInfo->target_id = Device->deviceInstance.data[5] << 8 |
> Device->deviceInstance.data[4];
>
> return ret;
> @@ -75,7 +75,7 @@ int BlkVscInitialize(struct hv_driver *Driver)
> Driver->name = gBlkDriverName;
> memcpy(&Driver->deviceType, &gBlkVscDeviceType, sizeof(struct hv_guid));
>
> - storDriver->RequestExtSize = sizeof(struct storvsc_request_extension);
> + storDriver->request_ext_size = sizeof(struct storvsc_request_extension);
>
> /*
> * Divide the ring buffer data size (which is 1 page less than the ring
> @@ -83,20 +83,20 @@ int BlkVscInitialize(struct hv_driver *Driver)
> * by the max request size (which is
> * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
> */
> - storDriver->MaxOutstandingRequestsPerChannel =
> - ((storDriver->RingBufferSize - PAGE_SIZE) /
> + storDriver->max_outstanding_req_per_channel =
> + ((storDriver->ring_buffer_size - PAGE_SIZE) /
> ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET +
> sizeof(struct vstor_packet) + sizeof(u64),
> sizeof(u64)));
>
> DPRINT_INFO(BLKVSC, "max io outstd %u",
> - storDriver->MaxOutstandingRequestsPerChannel);
> + storDriver->max_outstanding_req_per_channel);
>
> /* Setup the dispatch table */
> - storDriver->Base.OnDeviceAdd = BlkVscOnDeviceAdd;
> - storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove;
> - storDriver->Base.OnCleanup = StorVscOnCleanup;
> - storDriver->OnIORequest = StorVscOnIORequest;
> + storDriver->base.OnDeviceAdd = BlkVscOnDeviceAdd;
> + storDriver->base.OnDeviceRemove = StorVscOnDeviceRemove;
> + storDriver->base.OnCleanup = StorVscOnCleanup;
> + storDriver->on_io_request = StorVscOnIORequest;
>
> return ret;
> }
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 3f81ca5..d65d69e 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -177,13 +177,13 @@ static int blkvsc_drv_init(int (*drv_init)(struct
> hv_driver *drv))
> struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx;
> int ret;
>
> - storvsc_drv_obj->RingBufferSize = blkvsc_ringbuffer_size;
> + storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
>
> /* Callback to client driver to complete the initialization */
> - drv_init(&storvsc_drv_obj->Base);
> + drv_init(&storvsc_drv_obj->base);
>
> - drv_ctx->driver.name = storvsc_drv_obj->Base.name;
> - memcpy(&drv_ctx->class_id, &storvsc_drv_obj->Base.deviceType,
> + drv_ctx->driver.name = storvsc_drv_obj->base.name;
> + memcpy(&drv_ctx->class_id, &storvsc_drv_obj->base.deviceType,
> sizeof(struct hv_guid));
>
> drv_ctx->probe = blkvsc_probe;
> @@ -230,8 +230,8 @@ static void blkvsc_drv_exit(void)
> device_unregister(current_dev);
> }
>
> - if (storvsc_drv_obj->Base.OnCleanup)
> - storvsc_drv_obj->Base.OnCleanup(&storvsc_drv_obj->Base);
> + if (storvsc_drv_obj->base.OnCleanup)
> + storvsc_drv_obj->base.OnCleanup(&storvsc_drv_obj->base);
>
> vmbus_child_driver_unregister(drv_ctx);
>
> @@ -262,7 +262,7 @@ static int blkvsc_probe(struct device *device)
>
> DPRINT_DBG(BLKVSC_DRV, "blkvsc_probe - enter");
>
> - if (!storvsc_drv_obj->Base.OnDeviceAdd) {
> + if (!storvsc_drv_obj->base.OnDeviceAdd) {
> DPRINT_ERR(BLKVSC_DRV, "OnDeviceAdd() not set");
> ret = -1;
> goto Cleanup;
> @@ -284,7 +284,7 @@ static int blkvsc_probe(struct device *device)
>
> blkdev->request_pool = kmem_cache_create(dev_name(&device_ctx->device),
> sizeof(struct blkvsc_request) +
> - storvsc_drv_obj->RequestExtSize, 0,
> + storvsc_drv_obj->request_ext_size, 0,
> SLAB_HWCACHE_ALIGN, NULL);
> if (!blkdev->request_pool) {
> ret = -ENOMEM;
> @@ -293,7 +293,7 @@ static int blkvsc_probe(struct device *device)
>
>
> /* Call to the vsc driver to add the device */
> - ret = storvsc_drv_obj->Base.OnDeviceAdd(device_obj, &device_info);
> + ret = storvsc_drv_obj->base.OnDeviceAdd(device_obj, &device_info);
> if (ret != 0) {
> DPRINT_ERR(BLKVSC_DRV, "unable to add blkvsc device");
> goto Cleanup;
> @@ -301,9 +301,9 @@ static int blkvsc_probe(struct device *device)
>
> blkdev->device_ctx = device_ctx;
> /* this identified the device 0 or 1 */
> - blkdev->target = device_info.TargetId;
> + blkdev->target = device_info.target_id;
> /* this identified the ide ctrl 0 or 1 */
> - blkdev->path = device_info.PathId;
> + blkdev->path = device_info.path_id;
>
> dev_set_drvdata(device, blkdev);
>
> @@ -391,7 +391,7 @@ static int blkvsc_probe(struct device *device)
> return ret;
>
> Remove:
> - storvsc_drv_obj->Base.OnDeviceRemove(device_obj);
> + storvsc_drv_obj->base.OnDeviceRemove(device_obj);
>
> Cleanup:
> if (blkdev) {
> @@ -459,9 +459,9 @@ static int blkvsc_do_flush(struct block_device_context
> *blkdev)
> blkvsc_req->req = NULL;
> blkvsc_req->write = 0;
>
> - blkvsc_req->request.DataBuffer.PfnArray[0] = 0;
> - blkvsc_req->request.DataBuffer.Offset = 0;
> - blkvsc_req->request.DataBuffer.Length = 0;
> + blkvsc_req->request.data_buffer.PfnArray[0] = 0;
> + blkvsc_req->request.data_buffer.Offset = 0;
> + blkvsc_req->request.data_buffer.Length = 0;
>
> blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
> blkvsc_req->cmd_len = 10;
> @@ -506,9 +506,9 @@ static int blkvsc_do_inquiry(struct block_device_context
> *blkdev)
> blkvsc_req->req = NULL;
> blkvsc_req->write = 0;
>
> - blkvsc_req->request.DataBuffer.PfnArray[0] = page_to_pfn(page_buf);
> - blkvsc_req->request.DataBuffer.Offset = 0;
> - blkvsc_req->request.DataBuffer.Length = 64;
> + blkvsc_req->request.data_buffer.PfnArray[0] = page_to_pfn(page_buf);
> + blkvsc_req->request.data_buffer.Offset = 0;
> + blkvsc_req->request.data_buffer.Length = 64;
>
> blkvsc_req->cmnd[0] = INQUIRY;
> blkvsc_req->cmnd[1] = 0x1; /* Get product data */
> @@ -593,9 +593,9 @@ static int blkvsc_do_read_capacity(struct
> block_device_context *blkdev)
> blkvsc_req->req = NULL;
> blkvsc_req->write = 0;
>
> - blkvsc_req->request.DataBuffer.PfnArray[0] = page_to_pfn(page_buf);
> - blkvsc_req->request.DataBuffer.Offset = 0;
> - blkvsc_req->request.DataBuffer.Length = 8;
> + blkvsc_req->request.data_buffer.PfnArray[0] = page_to_pfn(page_buf);
> + blkvsc_req->request.data_buffer.Offset = 0;
> + blkvsc_req->request.data_buffer.Length = 8;
>
> blkvsc_req->cmnd[0] = READ_CAPACITY;
> blkvsc_req->cmd_len = 16;
> @@ -614,7 +614,7 @@ static int blkvsc_do_read_capacity(struct
> block_device_context *blkdev)
> wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond);
>
> /* check error */
> - if (blkvsc_req->request.Status) {
> + if (blkvsc_req->request.status) {
> scsi_normalize_sense(blkvsc_req->sense_buffer,
> SCSI_SENSE_BUFFERSIZE, &sense_hdr);
>
> @@ -670,9 +670,9 @@ static int blkvsc_do_read_capacity16(struct
> block_device_context *blkdev)
> blkvsc_req->req = NULL;
> blkvsc_req->write = 0;
>
> - blkvsc_req->request.DataBuffer.PfnArray[0] = page_to_pfn(page_buf);
> - blkvsc_req->request.DataBuffer.Offset = 0;
> - blkvsc_req->request.DataBuffer.Length = 12;
> + blkvsc_req->request.data_buffer.PfnArray[0] = page_to_pfn(page_buf);
> + blkvsc_req->request.data_buffer.Offset = 0;
> + blkvsc_req->request.data_buffer.Length = 12;
>
> blkvsc_req->cmnd[0] = 0x9E; /* READ_CAPACITY16; */
> blkvsc_req->cmd_len = 16;
> @@ -691,7 +691,7 @@ static int blkvsc_do_read_capacity16(struct
> block_device_context *blkdev)
> wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond);
>
> /* check error */
> - if (blkvsc_req->request.Status) {
> + if (blkvsc_req->request.status) {
> scsi_normalize_sense(blkvsc_req->sense_buffer,
> SCSI_SENSE_BUFFERSIZE, &sense_hdr);
> if (sense_hdr.asc == 0x3A) {
> @@ -741,14 +741,14 @@ static int blkvsc_remove(struct device *device)
>
> DPRINT_DBG(BLKVSC_DRV, "blkvsc_remove()\n");
>
> - if (!storvsc_drv_obj->Base.OnDeviceRemove)
> + if (!storvsc_drv_obj->base.OnDeviceRemove)
> return -1;
>
> /*
> * Call to the vsc driver to let it know that the device is being
> * removed
> */
> - ret = storvsc_drv_obj->Base.OnDeviceRemove(device_obj);
> + ret = storvsc_drv_obj->base.OnDeviceRemove(device_obj);
> if (ret != 0) {
> /* TODO: */
> DPRINT_ERR(BLKVSC_DRV,
> @@ -865,38 +865,38 @@ static int blkvsc_submit_request(struct blkvsc_request
> *blkvsc_req,
> (blkvsc_req->write) ? "WRITE" : "READ",
> (unsigned long) blkvsc_req->sector_start,
> blkvsc_req->sector_count,
> - blkvsc_req->request.DataBuffer.Offset,
> - blkvsc_req->request.DataBuffer.Length);
> + blkvsc_req->request.data_buffer.Offset,
> + blkvsc_req->request.data_buffer.Length);
> #if 0
> - for (i = 0; i < (blkvsc_req->request.DataBuffer.Length >> 12); i++) {
> + for (i = 0; i < (blkvsc_req->request.data_buffer.Length >> 12); i++) {
> DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
> "req %p pfn[%d] %llx\n",
> blkvsc_req, i,
> - blkvsc_req->request.DataBuffer.PfnArray[i]);
> + blkvsc_req->request.data_buffer.PfnArray[i]);
> }
> #endif
>
> storvsc_req = &blkvsc_req->request;
> - storvsc_req->Extension = (void *)((unsigned long)blkvsc_req +
> + storvsc_req->extension = (void *)((unsigned long)blkvsc_req +
> sizeof(struct blkvsc_request));
>
> - storvsc_req->Type = blkvsc_req->write ? WRITE_TYPE : READ_TYPE;
> + storvsc_req->type = blkvsc_req->write ? WRITE_TYPE : READ_TYPE;
>
> - storvsc_req->OnIOCompletion = request_completion;
> - storvsc_req->Context = blkvsc_req;
> + storvsc_req->on_io_completion = request_completion;
> + storvsc_req->context = blkvsc_req;
>
> - storvsc_req->Host = blkdev->port;
> - storvsc_req->Bus = blkdev->path;
> - storvsc_req->TargetId = blkdev->target;
> - storvsc_req->LunId = 0; /* this is not really used at all */
> + storvsc_req->host = blkdev->port;
> + storvsc_req->bus = blkdev->path;
> + storvsc_req->target_id = blkdev->target;
> + storvsc_req->lun_id = 0; /* this is not really used at all */
>
> - storvsc_req->CdbLen = blkvsc_req->cmd_len;
> - storvsc_req->Cdb = blkvsc_req->cmnd;
> + storvsc_req->cdb_len = blkvsc_req->cmd_len;
> + storvsc_req->cdb = blkvsc_req->cmnd;
>
> - storvsc_req->SenseBuffer = blkvsc_req->sense_buffer;
> - storvsc_req->SenseBufferSize = SCSI_SENSE_BUFFERSIZE;
> + storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
> + storvsc_req->sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
>
> - ret = storvsc_drv_obj->OnIORequest(&blkdev->device_ctx->device_obj,
> + ret = storvsc_drv_obj->on_io_request(&blkdev->device_ctx->device_obj,
> &blkvsc_req->request);
> if (ret == 0)
> blkdev->num_outstanding_reqs++;
> @@ -992,8 +992,10 @@ static int blkvsc_do_request(struct block_device_context
> *blkdev,
>
> blkvsc_req->dev = blkdev;
> blkvsc_req->req = req;
> - blkvsc_req->request.DataBuffer.Offset = bvec->bv_offset;
> - blkvsc_req->request.DataBuffer.Length = 0;
> + blkvsc_req->request.data_buffer.Offset
> + = bvec->bv_offset;
> + blkvsc_req->request.data_buffer.Length
> + = 0;
>
> /* Add to the group */
> blkvsc_req->group = group;
> @@ -1007,8 +1009,11 @@ static int blkvsc_do_request(struct
> block_device_context *blkdev,
> }
>
> /* Add the curr bvec/segment to the curr blkvsc_req */
> - blkvsc_req->request.DataBuffer.PfnArray[databuf_idx] =
> page_to_pfn(bvec->bv_page);
> - blkvsc_req->request.DataBuffer.Length += bvec->bv_len;
> + blkvsc_req->request.data_buffer.
> + PfnArray[databuf_idx]
> + = page_to_pfn(bvec->bv_page);
> + blkvsc_req->request.data_buffer.Length
> + += bvec->bv_len;
>
> prev_bvec = bvec;
>
> @@ -1073,7 +1078,7 @@ static int blkvsc_do_request(struct
> block_device_context *blkdev,
> static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
> {
> struct blkvsc_request *blkvsc_req =
> - (struct blkvsc_request *)request->Context;
> + (struct blkvsc_request *)request->context;
> struct block_device_context *blkdev =
> (struct block_device_context *)blkvsc_req->dev;
> struct scsi_sense_hdr sense_hdr;
> @@ -1083,7 +1088,7 @@ static void blkvsc_cmd_completion(struct
> hv_storvsc_request *request)
>
> blkdev->num_outstanding_reqs--;
>
> - if (blkvsc_req->request.Status)
> + if (blkvsc_req->request.status)
> if (scsi_normalize_sense(blkvsc_req->sense_buffer,
> SCSI_SENSE_BUFFERSIZE, &sense_hdr))
> scsi_print_sense_hdr("blkvsc", &sense_hdr);
> @@ -1095,7 +1100,7 @@ static void blkvsc_cmd_completion(struct
> hv_storvsc_request *request)
> static void blkvsc_request_completion(struct hv_storvsc_request *request)
> {
> struct blkvsc_request *blkvsc_req =
> - (struct blkvsc_request *)request->Context;
> + (struct blkvsc_request *)request->context;
> struct block_device_context *blkdev =
> (struct block_device_context *)blkvsc_req->dev;
> unsigned long flags;
> @@ -1110,7 +1115,7 @@ static void blkvsc_request_completion(struct
> hv_storvsc_request *request)
> (blkvsc_req->write) ? "WRITE" : "READ",
> (unsigned long)blkvsc_req->sector_start,
> blkvsc_req->sector_count,
> - blkvsc_req->request.DataBuffer.Length,
> + blkvsc_req->request.data_buffer.Length,
> blkvsc_req->group->outstanding,
> blkdev->num_outstanding_reqs);
>
> @@ -1137,7 +1142,7 @@ static void blkvsc_request_completion(struct
> hv_storvsc_request *request)
> list_del(&comp_req->req_entry);
>
> if (!__blk_end_request(comp_req->req,
> - (!comp_req->request.Status ? 0 : -EIO),
> + (!comp_req->request.status ? 0 : -EIO),
> comp_req->sector_count * blkdev->sector_size)) {
> /*
> * All the sectors have been xferred ie the
> @@ -1195,7 +1200,7 @@ static int blkvsc_cancel_pending_reqs(struct
> block_device_context *blkdev)
>
> if (comp_req->req) {
> ret = __blk_end_request(comp_req->req,
> - (!comp_req->request.Status ? 0 : -EIO),
> + (!comp_req->request.status ? 0 : -EIO),
> comp_req->sector_count *
> blkdev->sector_size);
>
> diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
> index 96b4ed9..c4346c6 100644
> --- a/drivers/staging/hv/storvsc.c
> +++ b/drivers/staging/hv/storvsc.c
> @@ -370,16 +370,16 @@ static void StorVscOnIOCompletion(struct hv_device
> *Device,
> /* ASSERT(request->OnIOCompletion != NULL); */
>
> /* Copy over the status...etc */
> - request->Status = VStorPacket->vm_srb.scsi_status;
> + request->status = VStorPacket->vm_srb.scsi_status;
>
> - if (request->Status != 0 || VStorPacket->vm_srb.srb_status != 1) {
> + if (request->status != 0 || VStorPacket->vm_srb.srb_status != 1) {
> DPRINT_WARN(STORVSC,
> "cmd 0x%x scsi status 0x%x srb status 0x%x\n",
> - request->Cdb[0], VStorPacket->vm_srb.scsi_status,
> + request->cdb[0], VStorPacket->vm_srb.scsi_status,
> VStorPacket->vm_srb.srb_status);
> }
>
> - if ((request->Status & 0xFF) == 0x02) {
> + if ((request->status & 0xFF) == 0x02) {
> /* CHECK_CONDITION */
> if (VStorPacket->vm_srb.srb_status & 0x80) {
> /* autosense data available */
> @@ -389,19 +389,19 @@ static void StorVscOnIOCompletion(struct hv_device
> *Device,
>
> /* ASSERT(VStorPacket->vm_srb.sense_info_length <= */
> /* request->SenseBufferSize); */
> - memcpy(request->SenseBuffer,
> + memcpy(request->sense_buffer,
> VStorPacket->vm_srb.sense_data,
> VStorPacket->vm_srb.sense_info_length);
>
> - request->SenseBufferSize =
> + request->sense_buffer_size =
> VStorPacket->vm_srb.sense_info_length;
> }
> }
>
> /* TODO: */
> - request->BytesXfer = VStorPacket->vm_srb.data_transfer_length;
> + request->bytes_xfer = VStorPacket->vm_srb.data_transfer_length;
>
> - request->OnIOCompletion(request);
> + request->on_io_completion(request);
>
> atomic_dec(&storDevice->NumOutstandingRequests);
>
> @@ -501,7 +501,8 @@ static int StorVscConnectToVsp(struct hv_device *Device)
>
> /* Open the channel */
> ret = vmbus_open(Device->channel,
> - storDriver->RingBufferSize, storDriver->RingBufferSize,
> + storDriver->ring_buffer_size,
> + storDriver->ring_buffer_size,
> (void *)&props,
> sizeof(struct vmstorage_channel_properties),
> StorVscOnChannelCallback, Device);
> @@ -551,13 +552,13 @@ static int StorVscOnDeviceAdd(struct hv_device *Device,
> void *AdditionalInfo)
> storChannel->PathId = props->PathId;
> storChannel->TargetId = props->TargetId; */
>
> - storDevice->PortNumber = deviceInfo->PortNumber;
> + storDevice->PortNumber = deviceInfo->port_number;
> /* Send it back up */
> ret = StorVscConnectToVsp(Device);
>
> /* deviceInfo->PortNumber = storDevice->PortNumber; */
> - deviceInfo->PathId = storDevice->PathId;
> - deviceInfo->TargetId = storDevice->TargetId;
> + deviceInfo->path_id = storDevice->PathId;
> + deviceInfo->target_id = storDevice->TargetId;
>
> DPRINT_DBG(STORVSC, "assigned port %u, path %u target %u\n",
> storDevice->PortNumber, storDevice->PathId,
> @@ -672,7 +673,7 @@ static int StorVscOnIORequest(struct hv_device *Device,
> int ret = 0;
>
> requestExtension =
> - (struct storvsc_request_extension *)Request->Extension;
> + (struct storvsc_request_extension *)Request->extension;
> vstorPacket = &requestExtension->VStorPacket;
> storDevice = GetStorDevice(Device);
>
> @@ -681,8 +682,8 @@ static int StorVscOnIORequest(struct hv_device *Device,
> requestExtension);
>
> DPRINT_DBG(STORVSC, "req %p len %d bus %d, target %d, lun %d cdblen %d",
> - Request, Request->DataBuffer.Length, Request->Bus,
> - Request->TargetId, Request->LunId, Request->CdbLen);
> + Request, Request->data_buffer.Length, Request->bus,
> + Request->target_id, Request->lun_id, Request->cdb_len);
>
> if (!storDevice) {
> DPRINT_ERR(STORVSC, "unable to get stor device..."
> @@ -702,19 +703,19 @@ static int StorVscOnIORequest(struct hv_device *Device,
>
> vstorPacket->vm_srb.length = sizeof(struct vmscsi_request);
>
> - vstorPacket->vm_srb.port_number = Request->Host;
> - vstorPacket->vm_srb.path_id = Request->Bus;
> - vstorPacket->vm_srb.target_id = Request->TargetId;
> - vstorPacket->vm_srb.lun = Request->LunId;
> + vstorPacket->vm_srb.port_number = Request->host;
> + vstorPacket->vm_srb.path_id = Request->bus;
> + vstorPacket->vm_srb.target_id = Request->target_id;
> + vstorPacket->vm_srb.lun = Request->lun_id;
>
> vstorPacket->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
>
> /* Copy over the scsi command descriptor block */
> - vstorPacket->vm_srb.cdb_length = Request->CdbLen;
> - memcpy(&vstorPacket->vm_srb.cdb, Request->Cdb, Request->CdbLen);
> + vstorPacket->vm_srb.cdb_length = Request->cdb_len;
> + memcpy(&vstorPacket->vm_srb.cdb, Request->cdb, Request->cdb_len);
>
> - vstorPacket->vm_srb.data_in = Request->Type;
> - vstorPacket->vm_srb.data_transfer_length = Request->DataBuffer.Length;
> + vstorPacket->vm_srb.data_in = Request->type;
> + vstorPacket->vm_srb.data_transfer_length = Request->data_buffer.Length;
>
> vstorPacket->operation = VSTOR_OPERATION_EXECUTE_SRB;
>
> @@ -728,9 +729,9 @@ static int StorVscOnIORequest(struct hv_device *Device,
> vstorPacket->vm_srb.sense_info_length,
> vstorPacket->vm_srb.cdb_length);
>
> - if (requestExtension->Request->DataBuffer.Length) {
> + if (requestExtension->Request->data_buffer.Length) {
> ret = vmbus_sendpacket_multipagebuffer(Device->channel,
> - &requestExtension->Request->DataBuffer,
> + &requestExtension->Request->data_buffer,
> vstorPacket,
> sizeof(struct vstor_packet),
> (unsigned long)requestExtension);
> @@ -785,7 +786,7 @@ int StorVscInitialize(struct hv_driver *Driver)
> memcpy(&Driver->deviceType, &gStorVscDeviceType,
> sizeof(struct hv_guid));
>
> - storDriver->RequestExtSize = sizeof(struct storvsc_request_extension);
> + storDriver->request_ext_size = sizeof(struct storvsc_request_extension);
>
> /*
> * Divide the ring buffer data size (which is 1 page less
> @@ -793,22 +794,22 @@ int StorVscInitialize(struct hv_driver *Driver)
> * the ring buffer indices) by the max request size (which is
> * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
> */
> - storDriver->MaxOutstandingRequestsPerChannel =
> - ((storDriver->RingBufferSize - PAGE_SIZE) /
> + storDriver->max_outstanding_req_per_channel =
> + ((storDriver->ring_buffer_size - PAGE_SIZE) /
> ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET +
> sizeof(struct vstor_packet) + sizeof(u64),
> sizeof(u64)));
>
> DPRINT_INFO(STORVSC, "max io %u, currently %u\n",
> - storDriver->MaxOutstandingRequestsPerChannel,
> + storDriver->max_outstanding_req_per_channel,
> STORVSC_MAX_IO_REQUESTS);
>
> /* Setup the dispatch table */
> - storDriver->Base.OnDeviceAdd = StorVscOnDeviceAdd;
> - storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove;
> - storDriver->Base.OnCleanup = StorVscOnCleanup;
> + storDriver->base.OnDeviceAdd = StorVscOnDeviceAdd;
> + storDriver->base.OnDeviceRemove = StorVscOnDeviceRemove;
> + storDriver->base.OnCleanup = StorVscOnCleanup;
>
> - storDriver->OnIORequest = StorVscOnIORequest;
> + storDriver->on_io_request = StorVscOnIORequest;
>
> return 0;
> }
> diff --git a/drivers/staging/hv/storvsc_api.h
> b/drivers/staging/hv/storvsc_api.h
> index 8505a1c..46f031e 100644
> --- a/drivers/staging/hv/storvsc_api.h
> +++ b/drivers/staging/hv/storvsc_api.h
> @@ -53,58 +53,58 @@ enum storvsc_request_type{
> };
>
> struct hv_storvsc_request {
> - enum storvsc_request_type Type;
> - u32 Host;
> - u32 Bus;
> - u32 TargetId;
> - u32 LunId;
> - u8 *Cdb;
> - u32 CdbLen;
> - u32 Status;
> - u32 BytesXfer;
> + enum storvsc_request_type type;
> + u32 host;
> + u32 bus;
> + u32 target_id;
> + u32 lun_id;
> + u8 *cdb;
> + u32 cdb_len;
> + u32 status;
> + u32 bytes_xfer;
>
> - unsigned char *SenseBuffer;
> - u32 SenseBufferSize;
> + unsigned char *sense_buffer;
> + u32 sense_buffer_size;
>
> - void *Context;
> + void *context;
>
> - void (*OnIOCompletion)(struct hv_storvsc_request *Request);
> + void (*on_io_completion)(struct hv_storvsc_request *request);
>
> /* This points to the memory after DataBuffer */
> - void *Extension;
> + void *extension;
>
> - struct hv_multipage_buffer DataBuffer;
> + struct hv_multipage_buffer data_buffer;
> };
>
> /* Represents the block vsc driver */
> struct storvsc_driver_object {
> /* Must be the first field */
> /* Which is a bug FIXME! */
> - struct hv_driver Base;
> + struct hv_driver base;
>
> /* Set by caller (in bytes) */
> - u32 RingBufferSize;
> + u32 ring_buffer_size;
>
> /* Allocate this much private extension for each I/O request */
> - u32 RequestExtSize;
> + u32 request_ext_size;
>
> /* Maximum # of requests in flight per channel/device */
> - u32 MaxOutstandingRequestsPerChannel;
> + u32 max_outstanding_req_per_channel;
>
> /* Specific to this driver */
> - int (*OnIORequest)(struct hv_device *Device,
> - struct hv_storvsc_request *Request);
> + int (*on_io_request)(struct hv_device *device,
> + struct hv_storvsc_request *request);
> };
>
> struct storvsc_device_info {
> - unsigned int PortNumber;
> - unsigned char PathId;
> - unsigned char TargetId;
> + unsigned int port_number;
> + unsigned char path_id;
> + unsigned char target_id;
> };
>
> /* Interface */
> int StorVscInitialize(struct hv_driver *driver);
> -int StorVscOnHostReset(struct hv_device *Device);
> +int StorVscOnHostReset(struct hv_device *device);
> int BlkVscInitialize(struct hv_driver *driver);
>
> #endif /* _STORVSC_API_H_ */
> diff --git a/drivers/staging/hv/storvsc_drv.c
> b/drivers/staging/hv/storvsc_drv.c
> index defc34a..03695ce 100644
> --- a/drivers/staging/hv/storvsc_drv.c
> +++ b/drivers/staging/hv/storvsc_drv.c
> @@ -141,28 +141,28 @@ static int storvsc_drv_init(int (*drv_init)(struct
> hv_driver *drv))
> struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
> struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
>
> - storvsc_drv_obj->RingBufferSize = storvsc_ringbuffer_size;
> + storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
>
> /* Callback to client driver to complete the initialization */
> - drv_init(&storvsc_drv_obj->Base);
> + drv_init(&storvsc_drv_obj->base);
>
> DPRINT_INFO(STORVSC_DRV,
> "request extension size %u, max outstanding reqs %u",
> - storvsc_drv_obj->RequestExtSize,
> - storvsc_drv_obj->MaxOutstandingRequestsPerChannel);
> + storvsc_drv_obj->request_ext_size,
> + storvsc_drv_obj->max_outstanding_req_per_channel);
>
> - if (storvsc_drv_obj->MaxOutstandingRequestsPerChannel <
> + if (storvsc_drv_obj->max_outstanding_req_per_channel <
> STORVSC_MAX_IO_REQUESTS) {
> DPRINT_ERR(STORVSC_DRV,
> "The number of outstanding io requests (%d) "
> "is larger than that supported (%d) internally.",
> STORVSC_MAX_IO_REQUESTS,
> - storvsc_drv_obj->MaxOutstandingRequestsPerChannel);
> + storvsc_drv_obj->max_outstanding_req_per_channel);
> return -1;
> }
>
> - drv_ctx->driver.name = storvsc_drv_obj->Base.name;
> - memcpy(&drv_ctx->class_id, &storvsc_drv_obj->Base.deviceType,
> + drv_ctx->driver.name = storvsc_drv_obj->base.name;
> + memcpy(&drv_ctx->class_id, &storvsc_drv_obj->base.deviceType,
> sizeof(struct hv_guid));
>
> drv_ctx->probe = storvsc_probe;
> @@ -207,8 +207,8 @@ static void storvsc_drv_exit(void)
> device_unregister(current_dev);
> }
>
> - if (storvsc_drv_obj->Base.OnCleanup)
> - storvsc_drv_obj->Base.OnCleanup(&storvsc_drv_obj->Base);
> + if (storvsc_drv_obj->base.OnCleanup)
> + storvsc_drv_obj->base.OnCleanup(&storvsc_drv_obj->base);
>
> vmbus_child_driver_unregister(drv_ctx);
> return;
> @@ -232,7 +232,7 @@ static int storvsc_probe(struct device *device)
> struct host_device_context *host_device_ctx;
> struct storvsc_device_info device_info;
>
> - if (!storvsc_drv_obj->Base.OnDeviceAdd)
> + if (!storvsc_drv_obj->base.OnDeviceAdd)
> return -1;
>
> host = scsi_host_alloc(&scsi_driver,
> @@ -253,7 +253,7 @@ static int storvsc_probe(struct device *device)
> host_device_ctx->request_pool =
> kmem_cache_create(dev_name(&device_ctx->device),
> sizeof(struct storvsc_cmd_request) +
> - storvsc_drv_obj->RequestExtSize, 0,
> + storvsc_drv_obj->request_ext_size, 0,
> SLAB_HWCACHE_ALIGN, NULL);
>
> if (!host_device_ctx->request_pool) {
> @@ -261,9 +261,9 @@ static int storvsc_probe(struct device *device)
> return -ENOMEM;
> }
>
> - device_info.PortNumber = host->host_no;
> + device_info.port_number = host->host_no;
> /* Call to the vsc driver to add the device */
> - ret = storvsc_drv_obj->Base.OnDeviceAdd(device_obj,
> + ret = storvsc_drv_obj->base.OnDeviceAdd(device_obj,
> (void *)&device_info);
> if (ret != 0) {
> DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device");
> @@ -273,8 +273,8 @@ static int storvsc_probe(struct device *device)
> }
>
> /* host_device_ctx->port = device_info.PortNumber; */
> - host_device_ctx->path = device_info.PathId;
> - host_device_ctx->target = device_info.TargetId;
> + host_device_ctx->path = device_info.path_id;
> + host_device_ctx->target = device_info.target_id;
>
> /* max # of devices per target */
> host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
> @@ -288,7 +288,7 @@ static int storvsc_probe(struct device *device)
> if (ret != 0) {
> DPRINT_ERR(STORVSC_DRV, "unable to add scsi host device");
>
> - storvsc_drv_obj->Base.OnDeviceRemove(device_obj);
> + storvsc_drv_obj->base.OnDeviceRemove(device_obj);
>
> kmem_cache_destroy(host_device_ctx->request_pool);
> scsi_host_put(host);
> @@ -318,14 +318,14 @@ static int storvsc_remove(struct device *device)
> (struct host_device_context *)host->hostdata;
>
>
> - if (!storvsc_drv_obj->Base.OnDeviceRemove)
> + if (!storvsc_drv_obj->base.OnDeviceRemove)
> return -1;
>
> /*
> * Call to the vsc driver to let it know that the device is being
> * removed
> */
> - ret = storvsc_drv_obj->Base.OnDeviceRemove(device_obj);
> + ret = storvsc_drv_obj->base.OnDeviceRemove(device_obj);
> if (ret != 0) {
> /* TODO: */
> DPRINT_ERR(STORVSC, "unable to remove vsc device (ret %d)",
> @@ -351,7 +351,7 @@ static int storvsc_remove(struct device *device)
> static void storvsc_commmand_completion(struct hv_storvsc_request *request)
> {
> struct storvsc_cmd_request *cmd_request =
> - (struct storvsc_cmd_request *)request->Context;
> + (struct storvsc_cmd_request *)request->context;
> struct scsi_cmnd *scmnd = cmd_request->cmd;
> struct host_device_context *host_device_ctx =
> (struct host_device_context *)scmnd->device->host->hostdata;
> @@ -376,16 +376,17 @@ static void storvsc_commmand_completion(struct
> hv_storvsc_request *request)
> cmd_request->bounce_sgl_count);
> }
>
> - scmnd->result = request->Status;
> + scmnd->result = request->status;
>
> if (scmnd->result) {
> if (scsi_normalize_sense(scmnd->sense_buffer,
> - request->SenseBufferSize, &sense_hdr))
> + request->sense_buffer_size, &sense_hdr))
> scsi_print_sense_hdr("storvsc", &sense_hdr);
> }
>
> - /* ASSERT(request->BytesXfer <= request->DataBuffer.Length); */
> - scsi_set_resid(scmnd, request->DataBuffer.Length - request->BytesXfer);
> + /* ASSERT(request->BytesXfer <= request->data_buffer.Length); */
> + scsi_set_resid(scmnd,
> + request->data_buffer.Length - request->bytes_xfer);
>
> scsi_done_fn = scmnd->scsi_done;
>
> @@ -658,42 +659,42 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd
> *scmnd,
>
> request = &cmd_request->request;
>
> - request->Extension =
> + request->extension =
> (void *)((unsigned long)cmd_request + request_size);
> DPRINT_DBG(STORVSC_DRV, "req %p size %d ext %d", request, request_size,
> - storvsc_drv_obj->RequestExtSize);
> + storvsc_drv_obj->request_ext_size);
>
> /* Build the SRB */
> switch (scmnd->sc_data_direction) {
> case DMA_TO_DEVICE:
> - request->Type = WRITE_TYPE;
> + request->type = WRITE_TYPE;
> break;
> case DMA_FROM_DEVICE:
> - request->Type = READ_TYPE;
> + request->type = READ_TYPE;
> break;
> default:
> - request->Type = UNKNOWN_TYPE;
> + request->type = UNKNOWN_TYPE;
> break;
> }
>
> - request->OnIOCompletion = storvsc_commmand_completion;
> - request->Context = cmd_request;/* scmnd; */
> + request->on_io_completion = storvsc_commmand_completion;
> + request->context = cmd_request;/* scmnd; */
>
> /* request->PortId = scmnd->device->channel; */
> - request->Host = host_device_ctx->port;
> - request->Bus = scmnd->device->channel;
> - request->TargetId = scmnd->device->id;
> - request->LunId = scmnd->device->lun;
> + request->host = host_device_ctx->port;
> + request->bus = scmnd->device->channel;
> + request->target_id = scmnd->device->id;
> + request->lun_id = scmnd->device->lun;
>
> /* ASSERT(scmnd->cmd_len <= 16); */
> - request->CdbLen = scmnd->cmd_len;
> - request->Cdb = scmnd->cmnd;
> + request->cdb_len = scmnd->cmd_len;
> + request->cdb = scmnd->cmnd;
>
> - request->SenseBuffer = scmnd->sense_buffer;
> - request->SenseBufferSize = SCSI_SENSE_BUFFERSIZE;
> + request->sense_buffer = scmnd->sense_buffer;
> + request->sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
>
>
> - request->DataBuffer.Length = scsi_bufflen(scmnd);
> + request->data_buffer.Length = scsi_bufflen(scmnd);
> if (scsi_sg_count(scmnd)) {
> sgl = (struct scatterlist *)scsi_sglist(scmnd);
> sg_count = scsi_sg_count(scmnd);
> @@ -734,25 +735,25 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd
> *scmnd,
> sg_count = cmd_request->bounce_sgl_count;
> }
>
> - request->DataBuffer.Offset = sgl[0].offset;
> + request->data_buffer.Offset = sgl[0].offset;
>
> for (i = 0; i < sg_count; i++) {
> DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n",
> i, sgl[i].length, sgl[i].offset);
> - request->DataBuffer.PfnArray[i] =
> + request->data_buffer.PfnArray[i] =
> page_to_pfn(sg_page((&sgl[i])));
> }
> } else if (scsi_sglist(scmnd)) {
> /* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
> - request->DataBuffer.Offset =
> + request->data_buffer.Offset =
> virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
> - request->DataBuffer.PfnArray[0] =
> + request->data_buffer.PfnArray[0] =
> virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
> }
>
> retry_request:
> /* Invokes the vsc to start an IO */
> - ret = storvsc_drv_obj->OnIORequest(&device_ctx->device_obj,
> + ret = storvsc_drv_obj->on_io_request(&device_ctx->device_obj,
> &cmd_request->request);
> if (ret == -1) {
> /* no more space */
^ permalink raw reply
* Re: [PATCH 2/8] staging: hv: Convert camel case struct fields in storvsc_api.h to lowercase
From: Greg KH @ 2010-12-07 2:02 UTC (permalink / raw)
To: Ky Srinivasan
Cc: devel, virtualization, hjanssen, linux-kernel, Haiyang Zhang,
Abhishek Kane
In-Reply-To: <4CFD24820200003000091628@novprvoes0310.provo.novell.com>
On Mon, Dec 06, 2010 at 05:59:30PM -0700, Ky Srinivasan wrote:
> Greg,
>
> My new KVP patches are ready to go. Should I wait for Hank's patches
> to be checked in before I send the KVP patches?
Hank's patches went in a few hours ago :)
thanks,
greg k-h
^ permalink raw reply
* [PATCH 1/3]: An implementation of HyperV KVP functionality
From: Ky Srinivasan @ 2010-12-07 22:09 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Zbr, Haiyang Zhang, Stephen Hemminger, Greg KH
[-- Attachment #1: Type: text/plain, Size: 827 bytes --]
This patch is re-based on the latest linux-next tree.
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: Reserve a connector index for implementing HyperV Key Value Pair
(KVP) functionality.
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Index: linux.trees.git/include/linux/connector.h
===================================================================
--- linux.trees.git.orig/include/linux/connector.h 2010-11-05 16:45:32.000000000 -0400
+++ linux.trees.git/include/linux/connector.h 2010-12-07 06:58:34.000000000 -0500
@@ -42,8 +42,9 @@
#define CN_VAL_DM_USERSPACE_LOG 0x1
#define CN_IDX_DRBD 0x8
#define CN_VAL_DRBD 0x1
+#define CN_KVP_IDX 0x9 /* HyperV KVP */
-#define CN_NETLINK_USERS 8
+#define CN_NETLINK_USERS 9
/*
* Maximum connector's message size.
[-- Attachment #2: kvp_connector.patch --]
[-- Type: text/plain, Size: 766 bytes --]
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: Reserve a connector index for implementing HyperV Key Value Pair
(KVP) functionality.
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Index: linux.trees.git/include/linux/connector.h
===================================================================
--- linux.trees.git.orig/include/linux/connector.h 2010-11-05 16:45:32.000000000 -0400
+++ linux.trees.git/include/linux/connector.h 2010-12-07 06:58:34.000000000 -0500
@@ -42,8 +42,9 @@
#define CN_VAL_DM_USERSPACE_LOG 0x1
#define CN_IDX_DRBD 0x8
#define CN_VAL_DRBD 0x1
+#define CN_KVP_IDX 0x9 /* HyperV KVP */
-#define CN_NETLINK_USERS 8
+#define CN_NETLINK_USERS 9
/*
* Maximum connector's message size.
[-- Attachment #3: Type: text/plain, Size: 159 bytes --]
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
^ permalink raw reply
* [PATCH 2/3]: An implementation of HyperV KVP functionality
From: Ky Srinivasan @ 2010-12-07 22:25 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Zbr, Haiyang Zhang, Stephen Hemminger, Greg KH
This patch is re-based on the latest linux-next tree.
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: The hv_utils module will be composed of more than one file;
rename hv_utils.c to accommodate this without changing the module name.
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Index: linux.trees.git/drivers/staging/hv/Makefile
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/Makefile 2010-12-07 07:04:41.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/Makefile 2010-12-07 08:00:10.000000000 -0500
@@ -10,3 +10,4 @@ hv_vmbus-y := vmbus_drv.o osd.o \
hv_storvsc-y := storvsc_drv.o storvsc.o
hv_blkvsc-y := blkvsc_drv.o blkvsc.o
hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
+hv_utils-y := hv_util.o
Index: linux.trees.git/drivers/staging/hv/hv_util.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.trees.git/drivers/staging/hv/hv_util.c 2010-12-07 08:00:10.000000000 -0500
@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2010, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ * Haiyang Zhang <haiyangz@microsoft.com>
+ * Hank Janssen <hjanssen@microsoft.com>
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sysctl.h>
+#include <linux/reboot.h>
+#include <linux/dmi.h>
+#include <linux/pci.h>
+
+#include "logging.h"
+#include "osd.h"
+#include "vmbus.h"
+#include "vmbus_packet_format.h"
+#include "vmbus_channel_interface.h"
+#include "version_info.h"
+#include "channel.h"
+#include "vmbus_private.h"
+#include "vmbus_api.h"
+#include "utils.h"
+
+
+static void shutdown_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+ u8 execute_shutdown = false;
+
+ struct shutdown_msg_data *shutdown_msg;
+
+ struct icmsg_hdr *icmsghdrp;
+ struct icmsg_negotiate *negop = NULL;
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, negop, buf);
+ } else {
+ shutdown_msg = (struct shutdown_msg_data *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+
+ switch (shutdown_msg->flags) {
+ case 0:
+ case 1:
+ icmsghdrp->status = HV_S_OK;
+ execute_shutdown = true;
+
+ DPRINT_INFO(VMBUS, "Shutdown request received -"
+ " gracefull shutdown initiated");
+ break;
+ default:
+ icmsghdrp->status = HV_E_FAIL;
+ execute_shutdown = false;
+
+ DPRINT_INFO(VMBUS, "Shutdown request received -"
+ " Invalid request");
+ break;
+ };
+ }
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+
+ if (execute_shutdown == true)
+ orderly_poweroff(false);
+}
+
+/*
+ * Set guest time to host UTC time.
+ */
+static inline void do_adj_guesttime(u64 hosttime)
+{
+ s64 host_tns;
+ struct timespec host_ts;
+
+ host_tns = (hosttime - WLTIMEDELTA) * 100;
+ host_ts = ns_to_timespec(host_tns);
+
+ do_settimeofday(&host_ts);
+}
+
+/*
+ * Synchronize time with host after reboot, restore, etc.
+ *
+ * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
+ * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time
+ * message after the timesync channel is opened. Since the hv_utils module is
+ * loaded after hv_vmbus, the first message is usually missed. The other
+ * thing is, systime is automatically set to emulated hardware clock which may
+ * not be UTC time or in the same time zone. So, to override these effects, we
+ * use the first 50 time samples for initial system time setting.
+ */
+static inline void adj_guesttime(u64 hosttime, u8 flags)
+{
+ static s32 scnt = 50;
+
+ if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
+ do_adj_guesttime(hosttime);
+ return;
+ }
+
+ if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
+ scnt--;
+ do_adj_guesttime(hosttime);
+ }
+}
+
+/*
+ * Time Sync Channel message handler.
+ */
+static void timesync_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+ struct icmsg_hdr *icmsghdrp;
+ struct ictimesync_data *timedatap;
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, NULL, buf);
+ } else {
+ timedatap = (struct ictimesync_data *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+ adj_guesttime(timedatap->parenttime, timedatap->flags);
+ }
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+}
+
+/*
+ * Heartbeat functionality.
+ * Every two seconds, Hyper-V send us a heartbeat request message.
+ * we respond to this message, and Hyper-V knows we are alive.
+ */
+static void heartbeat_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+ struct icmsg_hdr *icmsghdrp;
+ struct heartbeat_msg_data *heartbeat_msg;
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, NULL, buf);
+ } else {
+ heartbeat_msg = (struct heartbeat_msg_data *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+
+ DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
+ heartbeat_msg->seq_num);
+
+ heartbeat_msg->seq_num += 1;
+ }
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+}
+
+static const struct pci_device_id __initconst
+hv_utils_pci_table[] __maybe_unused = {
+ { PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
+
+
+static const struct dmi_system_id __initconst
+hv_utils_dmi_table[] __maybe_unused = {
+ {
+ .ident = "Hyper-V",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
+ DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
+ },
+ },
+ { },
+};
+MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
+
+
+static int __init init_hyperv_utils(void)
+{
+ printk(KERN_INFO "Registering HyperV Utility Driver\n");
+
+ if (!dmi_check_system(hv_utils_dmi_table))
+ return -ENODEV;
+
+ hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
+ &shutdown_onchannelcallback;
+ hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
+
+ hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
+ ×ync_onchannelcallback;
+ hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback;
+
+ hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
+ &heartbeat_onchannelcallback;
+ hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
+
+ return 0;
+}
+
+static void exit_hyperv_utils(void)
+{
+ printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
+
+ hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+ hv_cb_utils[HV_SHUTDOWN_MSG].callback = &chn_cb_negotiate;
+
+ hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+ hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;
+
+ hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+ hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
+}
+
+module_init(init_hyperv_utils);
+module_exit(exit_hyperv_utils);
+
+MODULE_DESCRIPTION("Hyper-V Utilities");
+MODULE_VERSION(HV_DRV_VERSION);
+MODULE_LICENSE("GPL");
Index: linux.trees.git/drivers/staging/hv/hv_utils.c
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/hv_utils.c 2010-12-07 07:04:41.000000000 -0500
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2010, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- * Haiyang Zhang <haiyangz@microsoft.com>
- * Hank Janssen <hjanssen@microsoft.com>
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/sysctl.h>
-#include <linux/reboot.h>
-#include <linux/dmi.h>
-#include <linux/pci.h>
-
-#include "logging.h"
-#include "osd.h"
-#include "vmbus.h"
-#include "vmbus_packet_format.h"
-#include "vmbus_channel_interface.h"
-#include "version_info.h"
-#include "channel.h"
-#include "vmbus_private.h"
-#include "vmbus_api.h"
-#include "utils.h"
-
-
-static void shutdown_onchannelcallback(void *context)
-{
- struct vmbus_channel *channel = context;
- u8 *buf;
- u32 buflen, recvlen;
- u64 requestid;
- u8 execute_shutdown = false;
-
- struct shutdown_msg_data *shutdown_msg;
-
- struct icmsg_hdr *icmsghdrp;
- struct icmsg_negotiate *negop = NULL;
-
- buflen = PAGE_SIZE;
- buf = kmalloc(buflen, GFP_ATOMIC);
-
- vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
-
- if (recvlen > 0) {
- DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
- recvlen, requestid);
-
- icmsghdrp = (struct icmsg_hdr *)&buf[
- sizeof(struct vmbuspipe_hdr)];
-
- if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
- prep_negotiate_resp(icmsghdrp, negop, buf);
- } else {
- shutdown_msg = (struct shutdown_msg_data *)&buf[
- sizeof(struct vmbuspipe_hdr) +
- sizeof(struct icmsg_hdr)];
-
- switch (shutdown_msg->flags) {
- case 0:
- case 1:
- icmsghdrp->status = HV_S_OK;
- execute_shutdown = true;
-
- DPRINT_INFO(VMBUS, "Shutdown request received -"
- " gracefull shutdown initiated");
- break;
- default:
- icmsghdrp->status = HV_E_FAIL;
- execute_shutdown = false;
-
- DPRINT_INFO(VMBUS, "Shutdown request received -"
- " Invalid request");
- break;
- };
- }
-
- icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
- | ICMSGHDRFLAG_RESPONSE;
-
- vmbus_sendpacket(channel, buf,
- recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
- }
-
- kfree(buf);
-
- if (execute_shutdown == true)
- orderly_poweroff(false);
-}
-
-/*
- * Set guest time to host UTC time.
- */
-static inline void do_adj_guesttime(u64 hosttime)
-{
- s64 host_tns;
- struct timespec host_ts;
-
- host_tns = (hosttime - WLTIMEDELTA) * 100;
- host_ts = ns_to_timespec(host_tns);
-
- do_settimeofday(&host_ts);
-}
-
-/*
- * Synchronize time with host after reboot, restore, etc.
- *
- * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
- * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time
- * message after the timesync channel is opened. Since the hv_utils module is
- * loaded after hv_vmbus, the first message is usually missed. The other
- * thing is, systime is automatically set to emulated hardware clock which may
- * not be UTC time or in the same time zone. So, to override these effects, we
- * use the first 50 time samples for initial system time setting.
- */
-static inline void adj_guesttime(u64 hosttime, u8 flags)
-{
- static s32 scnt = 50;
-
- if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
- do_adj_guesttime(hosttime);
- return;
- }
-
- if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
- scnt--;
- do_adj_guesttime(hosttime);
- }
-}
-
-/*
- * Time Sync Channel message handler.
- */
-static void timesync_onchannelcallback(void *context)
-{
- struct vmbus_channel *channel = context;
- u8 *buf;
- u32 buflen, recvlen;
- u64 requestid;
- struct icmsg_hdr *icmsghdrp;
- struct ictimesync_data *timedatap;
-
- buflen = PAGE_SIZE;
- buf = kmalloc(buflen, GFP_ATOMIC);
-
- vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
-
- if (recvlen > 0) {
- DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
- recvlen, requestid);
-
- icmsghdrp = (struct icmsg_hdr *)&buf[
- sizeof(struct vmbuspipe_hdr)];
-
- if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
- prep_negotiate_resp(icmsghdrp, NULL, buf);
- } else {
- timedatap = (struct ictimesync_data *)&buf[
- sizeof(struct vmbuspipe_hdr) +
- sizeof(struct icmsg_hdr)];
- adj_guesttime(timedatap->parenttime, timedatap->flags);
- }
-
- icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
- | ICMSGHDRFLAG_RESPONSE;
-
- vmbus_sendpacket(channel, buf,
- recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
- }
-
- kfree(buf);
-}
-
-/*
- * Heartbeat functionality.
- * Every two seconds, Hyper-V send us a heartbeat request message.
- * we respond to this message, and Hyper-V knows we are alive.
- */
-static void heartbeat_onchannelcallback(void *context)
-{
- struct vmbus_channel *channel = context;
- u8 *buf;
- u32 buflen, recvlen;
- u64 requestid;
- struct icmsg_hdr *icmsghdrp;
- struct heartbeat_msg_data *heartbeat_msg;
-
- buflen = PAGE_SIZE;
- buf = kmalloc(buflen, GFP_ATOMIC);
-
- vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
-
- if (recvlen > 0) {
- DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
- recvlen, requestid);
-
- icmsghdrp = (struct icmsg_hdr *)&buf[
- sizeof(struct vmbuspipe_hdr)];
-
- if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
- prep_negotiate_resp(icmsghdrp, NULL, buf);
- } else {
- heartbeat_msg = (struct heartbeat_msg_data *)&buf[
- sizeof(struct vmbuspipe_hdr) +
- sizeof(struct icmsg_hdr)];
-
- DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
- heartbeat_msg->seq_num);
-
- heartbeat_msg->seq_num += 1;
- }
-
- icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
- | ICMSGHDRFLAG_RESPONSE;
-
- vmbus_sendpacket(channel, buf,
- recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
- }
-
- kfree(buf);
-}
-
-static const struct pci_device_id __initconst
-hv_utils_pci_table[] __maybe_unused = {
- { PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
- { 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
-
-
-static const struct dmi_system_id __initconst
-hv_utils_dmi_table[] __maybe_unused = {
- {
- .ident = "Hyper-V",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
- DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
- },
- },
- { },
-};
-MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
-
-
-static int __init init_hyperv_utils(void)
-{
- printk(KERN_INFO "Registering HyperV Utility Driver\n");
-
- if (!dmi_check_system(hv_utils_dmi_table))
- return -ENODEV;
-
- hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
- &shutdown_onchannelcallback;
- hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
-
- hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
- ×ync_onchannelcallback;
- hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback;
-
- hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
- &heartbeat_onchannelcallback;
- hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
-
- return 0;
-}
-
-static void exit_hyperv_utils(void)
-{
- printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
-
- hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_SHUTDOWN_MSG].callback = &chn_cb_negotiate;
-
- hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;
-
- hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
-}
-
-module_init(init_hyperv_utils);
-module_exit(exit_hyperv_utils);
-
-MODULE_DESCRIPTION("Hyper-V Utilities");
-MODULE_VERSION(HV_DRV_VERSION);
-MODULE_LICENSE("GPL");
^ permalink raw reply
* Re: [PATCH 2/3]: An implementation of HyperV KVP functionality
From: Evgeniy Polyakov @ 2010-12-07 22:29 UTC (permalink / raw)
To: Ky Srinivasan
Cc: devel, Haiyang Zhang, Greg KH, Virtualization, Stephen Hemminger
In-Reply-To: <4CFE5204020000300009174C@novprvoes0310.provo.novell.com>
On Tue, Dec 07, 2010 at 03:25:56PM -0700, Ky Srinivasan (ksrinivasan@novell.com) wrote:
> +static void shutdown_onchannelcallback(void *context)
> +{
> + struct vmbus_channel *channel = context;
> + u8 *buf;
> + u32 buflen, recvlen;
> + u64 requestid;
> + u8 execute_shutdown = false;
> +
> + struct shutdown_msg_data *shutdown_msg;
> +
> + struct icmsg_hdr *icmsghdrp;
> + struct icmsg_negotiate *negop = NULL;
> +
> + buflen = PAGE_SIZE;
> + buf = kmalloc(buflen, GFP_ATOMIC);
> +
> + vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
This did not change since previous review and this is wrong.
It is the right way to crash kernel.
I did not read further since this is a show-stopper imo.
--
Evgeniy Polyakov
^ permalink raw reply
* [PATCH 3/3]: An implementation of HyperV KVP functionality
From: Ky Srinivasan @ 2010-12-07 22:31 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Zbr, Haiyang Zhang, Stephen Hemminger, Greg KH
This patch is re-based on the latest linux-next tree.
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: An implementation of key/value pair feature (KVP) for Linux
on HyperV.
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Index: linux.trees.git/drivers/staging/hv/Makefile
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/Makefile 2010-12-07 07:04:48.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/Makefile 2010-12-07 07:59:46.000000000 -0500
@@ -10,4 +10,4 @@ hv_vmbus-y := vmbus_drv.o osd.o \
hv_storvsc-y := storvsc_drv.o storvsc.o
hv_blkvsc-y := blkvsc_drv.o blkvsc.o
hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
-hv_utils-y := hv_util.o
+hv_utils-y := hv_util.o hv_kvp.o
Index: linux.trees.git/drivers/staging/hv/utils.h
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/utils.h 2010-12-07 06:55:53.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/utils.h 2010-12-07 07:05:39.000000000 -0500
@@ -102,6 +102,7 @@ struct ictimesync_data{
#define HV_SHUTDOWN_MSG 0
#define HV_TIMESYNC_MSG 1
#define HV_HEARTBEAT_MSG 2
+#define HV_KVP_MSG 3
struct hyperv_service_callback {
u8 msg_type;
Index: linux.trees.git/drivers/staging/hv/hv_kvp.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.trees.git/drivers/staging/hv/hv_kvp.c 2010-12-07 07:05:39.000000000 -0500
@@ -0,0 +1,356 @@
+/*
+ * An implementation of key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include <linux/net.h>
+#include <linux/nls.h>
+#include <linux/connector.h>
+#include <linux/workqueue.h>
+
+#include "logging.h"
+#include "osd.h"
+#include "vmbus.h"
+#include "vmbus_packet_format.h"
+#include "vmbus_channel_interface.h"
+#include "version_info.h"
+#include "channel.h"
+#include "vmbus_private.h"
+#include "vmbus_api.h"
+#include "utils.h"
+#include "hv_kvp.h"
+
+
+
+/*
+ * Global state maintained for transaction that is being processed.
+ * Note that only one transaction can be active at any point in time.
+ *
+ * This state is set when we receive a request from the host; we
+ * cleanup this state when the transaction is completed - when we respond
+ * to the host with the key value.
+ */
+
+static struct {
+ bool active; /* transaction status - active or not */
+ u8 *recv_buffer; /* the receive buffer that we allocated */
+ int recv_len; /* number of bytes received. */
+ struct vmbus_channel *recv_channel; /* chn we got the request */
+ u64 recv_req_id; /* request ID. */
+} kvp_transaction;
+
+static int kvp_send_key(int index);
+
+static void kvp_respond_to_host(char *key, char *value, int error);
+static void kvp_work_func(struct work_struct *dummy);
+static void kvp_register(void);
+
+static DECLARE_DELAYED_WORK(kvp_work, kvp_work_func);
+
+static struct cb_id kvp_id = { CN_KVP_IDX, CN_KVP_VAL };
+static const char kvp_name[] = "kvp_kernel_module";
+static int timeout_fired;
+
+/*
+ * Register the kernel component with the user-level daemon.
+ * As part of this registration, pass the LIC version number.
+ */
+
+static void
+kvp_register(void)
+{
+
+ struct cn_msg *msg;
+
+ msg = kzalloc(sizeof(*msg) + strlen(HV_DRV_VERSION) + 1 , GFP_ATOMIC);
+
+ if (msg) {
+ msg->id.idx = CN_KVP_IDX;
+ msg->id.val = CN_KVP_VAL;
+ msg->seq = KVP_REGISTER;
+ strcpy(msg->data, HV_DRV_VERSION);
+ msg->len = strlen(HV_DRV_VERSION) + 1;
+ cn_netlink_send(msg, 0, GFP_ATOMIC);
+ kfree(msg);
+ }
+}
+static void
+kvp_work_func(struct work_struct *dummy)
+{
+ /*
+ * If the timer fires, the user-mode component has not responded;
+ * process the pending transaction.
+ */
+ kvp_respond_to_host("Unknown key", "Guest timed out", timeout_fired);
+ timeout_fired = 1;
+}
+
+/*
+ * Callback when data is received from user mode.
+ */
+
+static void
+kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
+{
+ struct hv_ku_msg *message;
+
+ message = (struct hv_ku_msg *)msg->data;
+ if (msg->seq == KVP_REGISTER) {
+ printk(KERN_INFO "KVP: user-mode registering done.\n");
+ kvp_register();
+ }
+
+ if (msg->seq == KVP_USER_SET) {
+ /*
+ * Complete the transaction by forwarding the key value
+ * to the host. But first, cancel the timeout.
+ */
+ if (cancel_delayed_work_sync(&kvp_work))
+ kvp_respond_to_host(message->kvp_key,
+ message->kvp_value,
+ !strlen(message->kvp_key));
+ }
+}
+
+static int
+kvp_send_key(int index)
+{
+ struct cn_msg *msg;
+
+ msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg) , GFP_ATOMIC);
+
+ if (msg) {
+ msg->id.idx = CN_KVP_IDX;
+ msg->id.val = CN_KVP_VAL;
+ msg->seq = KVP_KERNEL_GET;
+ ((struct hv_ku_msg *)msg->data)->kvp_index = index;
+ msg->len = sizeof(struct hv_ku_msg);
+ cn_netlink_send(msg, 0, GFP_ATOMIC);
+ kfree(msg);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * Send a response back to the host.
+ */
+
+static void
+kvp_respond_to_host(char *key, char *value, int error)
+{
+ struct hv_kvp_msg *kvp_msg;
+ struct hv_kvp_msg_enumerate *kvp_data;
+ char *key_name;
+ struct icmsg_hdr *icmsghdrp;
+ int keylen, valuelen;
+ u8 *buf;
+ u32 buf_len;
+ struct vmbus_channel *channel;
+ u64 req_id;
+
+ /*
+ * If a transaction is not active; log and return.
+ */
+
+ if (!kvp_transaction.active) {
+ /*
+ * This is a spurious call!
+ */
+ printk(KERN_WARNING "KVP: Transaction not active\n");
+ return;
+ }
+ /*
+ * Copy the global state for completing the transaction. Note that
+ * only one transaction can be active at a time.
+ */
+
+ buf = kvp_transaction.recv_buffer;
+ buf_len = kvp_transaction.recv_len;
+ channel = kvp_transaction.recv_channel;
+ req_id = kvp_transaction.recv_req_id;
+ kvp_transaction.active = false;
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[sizeof(struct vmbuspipe_hdr)];
+ kvp_msg = (struct hv_kvp_msg *)&buf[sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+ kvp_data = &kvp_msg->kvp_data;
+ key_name = key;
+
+ /*
+ * If the error parameter is set, terminate the host's enumeration.
+ */
+ if (error) {
+ /*
+ * We don't support this index or the we have timedout;
+ * terminate the host-side iteration by returning an error.
+ */
+ icmsghdrp->status = HV_E_FAIL;
+ goto response_done;
+ }
+
+ /*
+ * The windows host expects the key/value pair to be encoded
+ * in utf16.
+ */
+ keylen = utf8s_to_utf16s(key_name, strlen(key_name),
+ (wchar_t *)kvp_data->data.key);
+ kvp_data->data.key_size = 2*(keylen + 1); /* utf16 encoding */
+ valuelen = utf8s_to_utf16s(value, strlen(value),
+ (wchar_t *)kvp_data->data.value);
+ kvp_data->data.value_size = 2*(valuelen + 1); /* utf16 encoding */
+
+ kvp_data->data.value_type = REG_SZ; /* all our values are strings */
+ icmsghdrp->status = HV_S_OK;
+
+response_done:
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf, buf_len, req_id,
+ VmbusPacketTypeDataInBand, 0);
+
+ /*
+ * Free up the buffer that was allocatted when we received a message
+ * from the host.
+ */
+ kfree(buf);
+}
+
+/*
+ * This callback is invoked when we get a KVP message from the host.
+ * The host ensures that only one KVP transaction can be active at a time.
+ * KVP implementation in Linux needs to forward the key to a user-mde
+ * component to retrive the corresponding value. Consequently, we cannot
+ * respond to the host in the conext of this callback. Since the host
+ * guarantees that at most only one transaction can be active at a time,
+ * we stash away the transaction state in a set of global variables.
+ */
+
+void hv_kvp_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+
+ struct hv_kvp_msg *kvp_msg;
+ struct hv_kvp_msg_enumerate *kvp_data;
+
+ struct icmsg_hdr *icmsghdrp;
+ struct icmsg_negotiate *negop = NULL;
+
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "KVP packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, negop, buf);
+ } else {
+ kvp_msg = (struct hv_kvp_msg *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+
+ kvp_data = &kvp_msg->kvp_data;
+
+ /*
+ * We only support the "get" operation on
+ * "KVP_POOL_AUTO" pool.
+ */
+
+ if ((kvp_msg->kvp_hdr.pool != KVP_POOL_AUTO) ||
+ (kvp_msg->kvp_hdr.operation !=
+ KVP_OP_ENUMERATE) ||
+ kvp_transaction.active) {
+ if (kvp_transaction.active)
+ printk(KERN_WARNING
+ "KVP: Invalid call\n");
+ icmsghdrp->status = HV_E_FAIL;
+ goto callback_done;
+ }
+
+ /*
+ * Stash away this global state for completing the
+ * transaction; note transactions are serialized.
+ */
+ kvp_transaction.recv_buffer = buf;
+ kvp_transaction.recv_len = recvlen;
+ kvp_transaction.recv_channel = channel;
+ kvp_transaction.recv_req_id = requestid;
+ kvp_transaction.active = true;
+
+ /*
+ * Get the information from the
+ * user-mode component.
+ * component. This transaction will be
+ * completed when we get the value from
+ * the user-mode component.
+ * Set a timeout to deal with
+ * user-mode not responding.
+ */
+ kvp_send_key(kvp_data->index);
+ schedule_delayed_work(&kvp_work, 100);
+
+ return;
+
+ }
+
+callback_done:
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+
+
+}
+
+int
+hv_kvp_init(void)
+{
+ int err;
+
+ err = cn_add_callback(&kvp_id, kvp_name, kvp_cn_callback);
+ if (err)
+ return err;
+
+ return 0;
+}
+
+void hv_kvp_deinit(void)
+{
+ cn_del_callback(&kvp_id);
+ cancel_delayed_work_sync(&kvp_work);
+}
Index: linux.trees.git/drivers/staging/hv/hv_kvp.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.trees.git/drivers/staging/hv/hv_kvp.h 2010-12-07 07:05:39.000000000 -0500
@@ -0,0 +1,184 @@
+/*
+ * An implementation of HyperV key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+#ifndef _KVP_H
+#define _KVP_H_
+
+/*
+ * Maximum value size - used for both key names and value data, and includes
+ * any applicable NULL terminators.
+ *
+ * Note: This limit is somewhat arbitrary, but falls easily within what is
+ * supported for all native guests (back to Win 2000) and what is reasonable
+ * for the IC KVP exchange functionality. Note that Windows Me/98/95 are
+ * limited to 255 character key names.
+ *
+ * MSDN recommends not storing data values larger than 2048 bytes in the
+ * registry.
+ *
+ * Note: This value is used in defining the KVP exchange message - this value
+ * cannot be modified without affecting the message size and compatability.
+ */
+
+/*
+ * bytes, including any null terminators
+ */
+#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048)
+
+
+/*
+ * Maximum key size - the registry limit for the length of an entry name
+ * is 256 characters, including the null terminator
+ */
+
+#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512)
+
+/*
+ * In Linux, we implement the KVP functionality in two components:
+ * 1) The kernel component which is packaged as part of the hv_utils driver
+ * is responsible for communicating with the host and responsible for
+ * implementing the host/guest protocol. 2) A user level daemon that is
+ * responsible for data gathering.
+ *
+ * Host/Guest Protocol: The host iterates over an index and expects the guest
+ * to assign a key name to the index and also return the value corresponding to
+ * the key. The host will have atmost one KVP transaction outstanding at any
+ * given point in time. The host side iteration stops when the guest returns
+ * an error. Microsoft has specified the following mapping of key names to
+ * host specified index:
+ *
+ * Index Key Name
+ * 0 FullyQualifiedDomainName
+ * 1 IntegrationServicesVersion
+ * 2 NetworkAddressIPv4
+ * 3 NetworkAddressIPv6
+ * 4 OSBuildNumber
+ * 5 OSName
+ * 6 OSMajorVersion
+ * 7 OSMinorVersion
+ * 8 OSVersion
+ * 9 ProcessorArchitecture
+ *
+ * The Windows host expects the Key Name and Key Value to be encoded in utf16.
+ *
+ * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the
+ * data gathering functionality in a user mode daemon. The user level daemon
+ * is also responsible for binding the key name to the index as well. The
+ * kernel and user-level daemon communicate using a connector channel.
+ *
+ * The user mode component first registers with the
+ * the kernel component. Subsequently, the kernel component requests, data
+ * for the specified keys. In response to this message the user mode component
+ * fills in the value corresponding to the specified key. We overload the
+ * sequence field in the cn_msg header to define our KVP message types.
+ *
+ *
+ * The kernel component simply acts as a conduit for communication between the
+ * Windows host and the user-level daemon. The kernel component passes up the
+ * index received from the Host to the user-level daemon. If the index is
+ * valid (supported), the corresponding key as well as its
+ * value (both are strings) is returned. If the index is invalid
+ * (not supported), a NULL key string is returned.
+ */
+
+/*
+ *
+ * The following definitions are shared with the user-mode component; do not
+ * change any of this without making the corresponding changes in
+ * the KVP user-mode component.
+ */
+
+#define CN_KVP_VAL 0x1 /* This supports queries from the kernel */
+#define CN_KVP_USER_VAL 0x2 /* This supports queries from the user */
+
+enum hv_ku_op {
+ KVP_REGISTER = 0, /* Register the user mode component */
+ KVP_KERNEL_GET, /* Kernel is requesting the value */
+ KVP_KERNEL_SET, /* Kernel is providing the value */
+ KVP_USER_GET, /* User is requesting the value */
+ KVP_USER_SET /* User is providing the value */
+};
+
+struct hv_ku_msg {
+ __u32 kvp_index; /* Key index */
+ __u8 kvp_key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; /* Key name */
+ __u8 kvp_value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; /* Key value */
+};
+
+
+
+
+#ifdef __KERNEL__
+
+/*
+ * Registry value types.
+ */
+
+#define REG_SZ 1
+
+enum hv_kvp_exchg_op {
+ KVP_OP_GET = 0,
+ KVP_OP_SET,
+ KVP_OP_DELETE,
+ KVP_OP_ENUMERATE,
+ KVP_OP_COUNT /* Number of operations, must be last. */
+};
+
+enum hv_kvp_exchg_pool {
+ KVP_POOL_EXTERNAL = 0,
+ KVP_POOL_GUEST,
+ KVP_POOL_AUTO,
+ KVP_POOL_AUTO_EXTERNAL,
+ KVP_POOL_AUTO_INTERNAL,
+ KVP_POOL_COUNT /* Number of pools, must be last. */
+};
+
+struct hv_kvp_hdr {
+ u8 operation;
+ u8 pool;
+};
+
+struct hv_kvp_exchg_msg_value {
+ u32 value_type;
+ u32 key_size;
+ u32 value_size;
+ u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
+ u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
+};
+
+struct hv_kvp_msg_enumerate {
+ u32 index;
+ struct hv_kvp_exchg_msg_value data;
+};
+
+struct hv_kvp_msg {
+ struct hv_kvp_hdr kvp_hdr;
+ struct hv_kvp_msg_enumerate kvp_data;
+};
+
+int hv_kvp_init(void);
+void hv_kvp_deinit(void);
+void hv_kvp_onchannelcallback(void *);
+
+#endif /* __KERNEL__ */
+#endif /* _KVP_H */
+
Index: linux.trees.git/drivers/staging/hv/hv_util.c
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/hv_util.c 2010-12-07 07:04:48.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/hv_util.c 2010-12-07 07:54:13.000000000 -0500
@@ -37,6 +37,7 @@
#include "vmbus_private.h"
#include "vmbus_api.h"
#include "utils.h"
+#include "hv_kvp.h"
static void shutdown_onchannelcallback(void *context)
@@ -265,6 +266,10 @@ static int __init init_hyperv_utils(void
{
printk(KERN_INFO "Registering HyperV Utility Driver\n");
+ if (hv_kvp_init())
+ return -ENODEV;
+
+
if (!dmi_check_system(hv_utils_dmi_table))
return -ENODEV;
@@ -280,6 +285,11 @@ static int __init init_hyperv_utils(void
&heartbeat_onchannelcallback;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
+ hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
+ &hv_kvp_onchannelcallback;
+
+
+
return 0;
}
@@ -298,6 +308,13 @@ static void exit_hyperv_utils(void)
hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
&chn_cb_negotiate;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
+
+ hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+
+ hv_kvp_deinit();
+
+
}
module_init(init_hyperv_utils);
Index: linux.trees.git/drivers/staging/hv/channel_mgmt.c
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/channel_mgmt.c 2010-12-07 06:55:53.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/channel_mgmt.c 2010-12-07 07:05:39.000000000 -0500
@@ -34,8 +34,8 @@ struct vmbus_channel_message_table_entry
void (*messageHandler)(struct vmbus_channel_message_header *msg);
};
-#define MAX_MSG_TYPES 3
-#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 7
+#define MAX_MSG_TYPES 4
+#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8
static const struct hv_guid
gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
@@ -98,6 +98,15 @@ static const struct hv_guid
0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
}
},
+ /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
+ /* KVP */
+ {
+ .data = {
+ 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+ 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6
+ }
+ },
+
};
@@ -231,6 +240,16 @@ struct hyperv_service_callback hv_cb_uti
.callback = chn_cb_negotiate,
.log_msg = "Heartbeat channel functionality initialized"
},
+ /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
+ /* KVP */
+ {
+ .data = {
+ 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+ 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6
+ },
+ .callback = chn_cb_negotiate,
+ .log_msg = "KVP channel functionality initialized"
+ },
};
EXPORT_SYMBOL(hv_cb_utils);
^ permalink raw reply
* [PATCH]: A daemon to support HyperV KVP functionality
From: Ky Srinivasan @ 2010-12-07 22:37 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Zbr, Haiyang Zhang, Stephen Hemminger, Greg KH
[-- Attachment #1: Type: text/plain, Size: 12949 bytes --]
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: An implementation of key/value pair feature (KVP) for Linux
on HyperV.
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Index: linux.trees.git/drivers/staging/hv/tools/hv_kvp_daemon.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.trees.git/drivers/staging/hv/tools/hv_kvp_daemon.c 2010-12-07 08:46:19.000000000 -0500
@@ -0,0 +1,470 @@
+/*
+ * An implementation of key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/poll.h>
+#include <sys/utsname.h>
+#include <linux/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <linux/connector.h>
+#include <linux/netlink.h>
+#include <sys/socket.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+#include <syslog.h>
+
+/*
+ * KYS: TODO. Need to register these in the kernel.
+ *
+ * The following definitions are shared with the in-kernel component; do not
+ * change any of this without making the corresponding changes in
+ * the KVP kernel component.
+ */
+#define CN_KVP_IDX 0x9 /* MSFT KVP functionality */
+#define CN_KVP_VAL 0x1 /* This supports queries from the kernel */
+#define CN_KVP_USER_VAL 0x2 /* This supports queries from the user */
+
+/*
+ * KVP protocol: The user mode component first registers with the
+ * the kernel component. Subsequently, the kernel component requests, data
+ * for the specified keys. In response to this message the user mode component
+ * fills in the value corresponding to the specified key. We overload the
+ * sequence field in the cn_msg header to define our KVP message types.
+ *
+ * We use this infrastructure for also supporting queries from user mode
+ * application for state that may be maintained in the KVP kernel component.
+ *
+ * XXXKYS: Have a shared header file between the user and kernel (TODO)
+ */
+
+enum kvp_op {
+ KVP_REGISTER = 0, /* Register the user mode component*/
+ KVP_KERNEL_GET, /*Kernel is requesting the value for the specified key*/
+ KVP_KERNEL_SET, /*Kernel is providing the value for the specified key*/
+ KVP_USER_GET, /*User is requesting the value for the specified key*/
+ KVP_USER_SET /*User is providing the value for the specified key*/
+};
+
+#define HV_KVP_EXCHANGE_MAX_KEY_SIZE 512
+#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE 2048
+
+struct hv_ku_msg {
+ __u32 kvp_index;
+ __u8 kvp_key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; /* Key name */
+ __u8 kvp_value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; /* Key value */
+};
+
+enum key_index {
+ FullyQualifiedDomainName = 0,
+ IntegrationServicesVersion, /*This key is serviced in the kernel*/
+ NetworkAddressIPv4,
+ NetworkAddressIPv6,
+ OSBuildNumber,
+ OSName,
+ OSMajorVersion,
+ OSMinorVersion,
+ OSVersion,
+ ProcessorArchitecture
+};
+
+/*
+ * End of shared definitions.
+ */
+
+static char kvp_send_buffer[4096];
+static char kvp_recv_buffer[4096];
+static struct sockaddr_nl addr;
+
+static char os_name[100];
+static char os_major[50];
+static char os_minor[50];
+static char processor_arch[50];
+static char os_build[100];
+static char *lic_version;
+
+void kvp_get_os_info(void)
+{
+ FILE *file;
+ char *eol;
+ struct utsname buf;
+
+ uname(&buf);
+ strcpy(os_build, buf.release);
+ strcpy(processor_arch, buf.machine);
+
+ file = fopen("/etc/SuSE-release", "r");
+ if (file != NULL)
+ goto kvp_osinfo_found;
+ file = fopen("/etc/redhat-release", "r");
+ if (file != NULL)
+ goto kvp_osinfo_found;
+ /*
+ * Add code for other supported platforms.
+ */
+
+ /*
+ * We don't have information about the os.
+ */
+ strcpy(os_name, "Linux");
+ strcpy(os_major, "0");
+ strcpy(os_minor, "0");
+ return;
+
+kvp_osinfo_found:
+ fgets(os_name, 99, file);
+ eol = index(os_name, '\n');
+ *eol = '\0';
+ fgets(os_major, 49, file);
+ eol = index(os_major, '\n');
+ *eol = '\0';
+ fgets(os_minor, 49, file);
+ eol = index(os_minor, '\n');
+ *eol = '\0';
+ fclose(file);
+ return;
+}
+
+static int
+kvp_get_ip_address(int family, char *buffer, int length)
+{
+ struct ifaddrs *ifap;
+ struct ifaddrs *curp;
+ int ipv4_len = strlen("255.255.255.255") + 1;
+ int ipv6_len = strlen("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")+1;
+ int offset = 0;
+ const char *str;
+ char tmp[50];
+ int error = 0;
+
+ /*
+ * On entry into this function, the buffer is capable of holding the
+ * maximum key value (2048 bytes).
+ */
+
+ if (getifaddrs(&ifap)) {
+ strcpy(buffer, "getifaddrs failed\n");
+ return 1;
+ }
+
+ curp = ifap;
+ while (curp != NULL) {
+ if ((curp->ifa_addr != NULL) &&
+ (curp->ifa_addr->sa_family == family)) {
+ if (family == AF_INET) {
+ struct sockaddr_in *addr =
+ (struct sockaddr_in *) curp->ifa_addr;
+
+ str = inet_ntop(family, &addr->sin_addr,
+ tmp, 50);
+ if (str == NULL) {
+ strcpy(buffer, "inet_ntop failed\n");
+ error = 1;
+ goto getaddr_done;
+ }
+ if (offset == 0)
+ strcpy(buffer, tmp);
+ else
+ strcat(buffer, tmp);
+ strcat(buffer, ";");
+
+ offset += strlen(str) + 1;
+ if ((length - offset) < (ipv4_len + 1))
+ goto getaddr_done;
+
+ } else {
+
+ /*
+ * We only support AF_INET and AF_INET6
+ * and the list of addresses is seperated by a ";".
+ */
+ struct sockaddr_in6 *addr =
+ (struct sockaddr_in6 *) curp->ifa_addr;
+
+ str = inet_ntop(family,
+ &addr->sin6_addr.s6_addr,
+ tmp, 50);
+ if (str == NULL) {
+ strcpy(buffer, "inet_ntop failed\n");
+ error = 1;
+ goto getaddr_done;
+ }
+ if (offset == 0)
+ strcpy(buffer, tmp);
+ else
+ strcat(buffer, tmp);
+ strcat(buffer, ";");
+ offset += strlen(str) + 1;
+ if ((length - offset) < (ipv6_len + 1))
+ goto getaddr_done;
+
+ }
+
+ }
+ curp = curp->ifa_next;
+ }
+
+getaddr_done:
+ freeifaddrs(ifap);
+ return error;
+}
+
+
+static int
+kvp_get_domain_name(char *buffer, int length)
+{
+ struct addrinfo hints, *info ;
+ gethostname(buffer, length);
+ int error = 0;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
+
+ error = getaddrinfo(buffer, "http", &hints, &info);
+ if (error != 0) {
+ strcpy(buffer, "getaddrinfo failed\n");
+ error = 1;
+ goto get_domain_done;
+ }
+ strcpy(buffer, info->ai_canonname);
+get_domain_done:
+ freeaddrinfo(info);
+ return error;
+}
+
+static int
+netlink_send(int fd, struct cn_msg *msg)
+{
+ struct nlmsghdr *nlh;
+ unsigned int size;
+ struct msghdr message;
+ char buffer[64];
+ struct iovec iov[2];
+
+ size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len);
+
+ nlh = (struct nlmsghdr *)buffer;
+ nlh->nlmsg_seq = 0;
+ nlh->nlmsg_pid = getpid();
+ nlh->nlmsg_type = NLMSG_DONE;
+ nlh->nlmsg_len = NLMSG_LENGTH(size - sizeof(*nlh));
+ nlh->nlmsg_flags = 0;
+
+ iov[0].iov_base = nlh;
+ iov[0].iov_len = sizeof(*nlh);
+
+ iov[1].iov_base = msg;
+ iov[1].iov_len = size;
+
+ memset(&message, 0, sizeof(message));
+ message.msg_name = &addr;
+ message.msg_namelen = sizeof(addr);
+ message.msg_iov = iov;
+ message.msg_iovlen = 2;
+
+ return sendmsg(fd, &message, 0);
+}
+
+main(void)
+{
+ int fd, len, sock_opt;
+ int error;
+ struct cn_msg *message;
+ struct pollfd pfd;
+ struct nlmsghdr *incoming_msg;
+ struct cn_msg *incoming_cn_msg;
+ char *key_value;
+ char *key_name;
+ int key_index;
+
+ daemon(1, 0);
+ openlog("KVP", 0, LOG_USER);
+ syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
+ /*
+ * Retrieve OS release information.
+ */
+ kvp_get_os_info();
+
+ fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
+ if (fd < 0) {
+ syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd);
+ exit(-1);
+ }
+ addr.nl_family = AF_NETLINK;
+ addr.nl_pad = 0;
+ addr.nl_pid = 0;
+ addr.nl_groups = CN_KVP_IDX;
+
+
+ error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ if (error < 0) {
+ syslog(LOG_ERR, "bind failed; error:%d", error);
+ close(fd);
+ exit(-1);
+ }
+ sock_opt = addr.nl_groups;
+ setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt));
+ /*
+ * Register ourselves with the kernel.
+ */
+ message = (struct cn_msg *)kvp_send_buffer;
+ message->id.idx = CN_KVP_IDX;
+ message->id.val = CN_KVP_VAL;
+ message->seq = KVP_REGISTER;
+ message->ack = 0;
+ message->len = 0;
+
+ len = netlink_send(fd, message);
+ if (len < 0) {
+ syslog(LOG_ERR, "netlink_send failed; error:%d", len);
+ close(fd);
+ exit(-1);
+ }
+
+ pfd.fd = fd;
+
+ while (1) {
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+ poll(&pfd, 1, -1);
+
+ len = recv(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0);
+
+ if (len < 0) {
+ syslog(LOG_ERR, "recv failed; error:%d", len);
+ close(fd);
+ return -1;
+ }
+
+ incoming_msg = (struct nlmsghdr *)kvp_recv_buffer;
+ incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg);
+
+ switch (incoming_cn_msg->seq) {
+ case KVP_REGISTER:
+ /*
+ * Driver is registering with us; stash away the version
+ * information.
+ */
+ lic_version = malloc(strlen(incoming_cn_msg->data) + 1);
+ if (lic_version) {
+ strcpy(lic_version, incoming_cn_msg->data);
+ syslog(LOG_INFO, "KVP LIC Version: %s",
+ lic_version);
+ } else {
+ syslog(LOG_ERR, "malloc failed");
+ }
+ continue;
+
+ case KVP_KERNEL_GET:
+ break;
+ default:
+ continue;
+ }
+
+ key_index =
+ ((struct hv_ku_msg *)incoming_cn_msg->data)->kvp_index;
+ key_name =
+ ((struct hv_ku_msg *)incoming_cn_msg->data)->kvp_key;
+ key_value =
+ ((struct hv_ku_msg *)incoming_cn_msg->data)->kvp_value;
+
+ switch (key_index) {
+ case FullyQualifiedDomainName:
+ kvp_get_domain_name(key_value,
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE);
+ strcpy(key_name, "FullyQualifiedDomainName");
+ break;
+ case IntegrationServicesVersion:
+ strcpy(key_name, "IntegrationServicesVersion");
+ strcpy(key_value, lic_version);
+ break;
+ case NetworkAddressIPv4:
+ kvp_get_ip_address(AF_INET, key_value,
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE);
+ strcpy(key_name, "NetworkAddressIPv4");
+ break;
+ case NetworkAddressIPv6:
+ kvp_get_ip_address(AF_INET6, key_value,
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE);
+ strcpy(key_name, "NetworkAddressIPv6");
+ break;
+ case OSBuildNumber:
+ strcpy(key_value, os_build);
+ strcpy(key_name, "OSBuildNumber");
+ break;
+ case OSName:
+ strcpy(key_value, os_name);
+ strcpy(key_name, "OSName");
+ break;
+ case OSMajorVersion:
+ strcpy(key_value, os_major);
+ strcpy(key_name, "OSMajorVersion");
+ break;
+ case OSMinorVersion:
+ strcpy(key_value, os_minor);
+ strcpy(key_name, "OSMinorVersion");
+ break;
+ case OSVersion:
+ strcpy(key_value, os_build);
+ strcpy(key_name, "OSVersion");
+ break;
+ case ProcessorArchitecture:
+ strcpy(key_value, processor_arch);
+ strcpy(key_name, "ProcessorArchitecture");
+ break;
+ default:
+ strcpy(key_value, "Unknown Key");
+ /*
+ * We use a null key name to terminate enumeration.
+ */
+ strcpy(key_name, "");
+ break;
+ }
+ /*
+ * Send the value back to the kernel. The response is
+ * already in the receive buffer. Update the cn_msg header to
+ * reflect the key value that has been added to the message
+ */
+
+ incoming_cn_msg->id.idx = CN_KVP_IDX;
+ incoming_cn_msg->id.val = CN_KVP_VAL;
+ incoming_cn_msg->seq = KVP_USER_SET;
+ incoming_cn_msg->ack = 0;
+ incoming_cn_msg->len = sizeof(struct hv_ku_msg);
+
+ len = netlink_send(fd, incoming_cn_msg);
+ if (len < 0) {
+ syslog(LOG_ERR, "net_link send failed; error:%d", len);
+ exit(-1);
+ }
+ }
+
+}
[-- Attachment #2: hv_kvp_daemon.patch --]
[-- Type: text/plain, Size: 12947 bytes --]
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: An implementation of key/value pair feature (KVP) for Linux
on HyperV.
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Index: linux.trees.git/drivers/staging/hv/tools/hv_kvp_daemon.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.trees.git/drivers/staging/hv/tools/hv_kvp_daemon.c 2010-12-07 08:46:19.000000000 -0500
@@ -0,0 +1,470 @@
+/*
+ * An implementation of key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/poll.h>
+#include <sys/utsname.h>
+#include <linux/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <linux/connector.h>
+#include <linux/netlink.h>
+#include <sys/socket.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+#include <syslog.h>
+
+/*
+ * KYS: TODO. Need to register these in the kernel.
+ *
+ * The following definitions are shared with the in-kernel component; do not
+ * change any of this without making the corresponding changes in
+ * the KVP kernel component.
+ */
+#define CN_KVP_IDX 0x9 /* MSFT KVP functionality */
+#define CN_KVP_VAL 0x1 /* This supports queries from the kernel */
+#define CN_KVP_USER_VAL 0x2 /* This supports queries from the user */
+
+/*
+ * KVP protocol: The user mode component first registers with the
+ * the kernel component. Subsequently, the kernel component requests, data
+ * for the specified keys. In response to this message the user mode component
+ * fills in the value corresponding to the specified key. We overload the
+ * sequence field in the cn_msg header to define our KVP message types.
+ *
+ * We use this infrastructure for also supporting queries from user mode
+ * application for state that may be maintained in the KVP kernel component.
+ *
+ * XXXKYS: Have a shared header file between the user and kernel (TODO)
+ */
+
+enum kvp_op {
+ KVP_REGISTER = 0, /* Register the user mode component*/
+ KVP_KERNEL_GET, /*Kernel is requesting the value for the specified key*/
+ KVP_KERNEL_SET, /*Kernel is providing the value for the specified key*/
+ KVP_USER_GET, /*User is requesting the value for the specified key*/
+ KVP_USER_SET /*User is providing the value for the specified key*/
+};
+
+#define HV_KVP_EXCHANGE_MAX_KEY_SIZE 512
+#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE 2048
+
+struct hv_ku_msg {
+ __u32 kvp_index;
+ __u8 kvp_key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; /* Key name */
+ __u8 kvp_value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; /* Key value */
+};
+
+enum key_index {
+ FullyQualifiedDomainName = 0,
+ IntegrationServicesVersion, /*This key is serviced in the kernel*/
+ NetworkAddressIPv4,
+ NetworkAddressIPv6,
+ OSBuildNumber,
+ OSName,
+ OSMajorVersion,
+ OSMinorVersion,
+ OSVersion,
+ ProcessorArchitecture
+};
+
+/*
+ * End of shared definitions.
+ */
+
+static char kvp_send_buffer[4096];
+static char kvp_recv_buffer[4096];
+static struct sockaddr_nl addr;
+
+static char os_name[100];
+static char os_major[50];
+static char os_minor[50];
+static char processor_arch[50];
+static char os_build[100];
+static char *lic_version;
+
+void kvp_get_os_info(void)
+{
+ FILE *file;
+ char *eol;
+ struct utsname buf;
+
+ uname(&buf);
+ strcpy(os_build, buf.release);
+ strcpy(processor_arch, buf.machine);
+
+ file = fopen("/etc/SuSE-release", "r");
+ if (file != NULL)
+ goto kvp_osinfo_found;
+ file = fopen("/etc/redhat-release", "r");
+ if (file != NULL)
+ goto kvp_osinfo_found;
+ /*
+ * Add code for other supported platforms.
+ */
+
+ /*
+ * We don't have information about the os.
+ */
+ strcpy(os_name, "Linux");
+ strcpy(os_major, "0");
+ strcpy(os_minor, "0");
+ return;
+
+kvp_osinfo_found:
+ fgets(os_name, 99, file);
+ eol = index(os_name, '\n');
+ *eol = '\0';
+ fgets(os_major, 49, file);
+ eol = index(os_major, '\n');
+ *eol = '\0';
+ fgets(os_minor, 49, file);
+ eol = index(os_minor, '\n');
+ *eol = '\0';
+ fclose(file);
+ return;
+}
+
+static int
+kvp_get_ip_address(int family, char *buffer, int length)
+{
+ struct ifaddrs *ifap;
+ struct ifaddrs *curp;
+ int ipv4_len = strlen("255.255.255.255") + 1;
+ int ipv6_len = strlen("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")+1;
+ int offset = 0;
+ const char *str;
+ char tmp[50];
+ int error = 0;
+
+ /*
+ * On entry into this function, the buffer is capable of holding the
+ * maximum key value (2048 bytes).
+ */
+
+ if (getifaddrs(&ifap)) {
+ strcpy(buffer, "getifaddrs failed\n");
+ return 1;
+ }
+
+ curp = ifap;
+ while (curp != NULL) {
+ if ((curp->ifa_addr != NULL) &&
+ (curp->ifa_addr->sa_family == family)) {
+ if (family == AF_INET) {
+ struct sockaddr_in *addr =
+ (struct sockaddr_in *) curp->ifa_addr;
+
+ str = inet_ntop(family, &addr->sin_addr,
+ tmp, 50);
+ if (str == NULL) {
+ strcpy(buffer, "inet_ntop failed\n");
+ error = 1;
+ goto getaddr_done;
+ }
+ if (offset == 0)
+ strcpy(buffer, tmp);
+ else
+ strcat(buffer, tmp);
+ strcat(buffer, ";");
+
+ offset += strlen(str) + 1;
+ if ((length - offset) < (ipv4_len + 1))
+ goto getaddr_done;
+
+ } else {
+
+ /*
+ * We only support AF_INET and AF_INET6
+ * and the list of addresses is seperated by a ";".
+ */
+ struct sockaddr_in6 *addr =
+ (struct sockaddr_in6 *) curp->ifa_addr;
+
+ str = inet_ntop(family,
+ &addr->sin6_addr.s6_addr,
+ tmp, 50);
+ if (str == NULL) {
+ strcpy(buffer, "inet_ntop failed\n");
+ error = 1;
+ goto getaddr_done;
+ }
+ if (offset == 0)
+ strcpy(buffer, tmp);
+ else
+ strcat(buffer, tmp);
+ strcat(buffer, ";");
+ offset += strlen(str) + 1;
+ if ((length - offset) < (ipv6_len + 1))
+ goto getaddr_done;
+
+ }
+
+ }
+ curp = curp->ifa_next;
+ }
+
+getaddr_done:
+ freeifaddrs(ifap);
+ return error;
+}
+
+
+static int
+kvp_get_domain_name(char *buffer, int length)
+{
+ struct addrinfo hints, *info ;
+ gethostname(buffer, length);
+ int error = 0;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
+
+ error = getaddrinfo(buffer, "http", &hints, &info);
+ if (error != 0) {
+ strcpy(buffer, "getaddrinfo failed\n");
+ error = 1;
+ goto get_domain_done;
+ }
+ strcpy(buffer, info->ai_canonname);
+get_domain_done:
+ freeaddrinfo(info);
+ return error;
+}
+
+static int
+netlink_send(int fd, struct cn_msg *msg)
+{
+ struct nlmsghdr *nlh;
+ unsigned int size;
+ struct msghdr message;
+ char buffer[64];
+ struct iovec iov[2];
+
+ size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len);
+
+ nlh = (struct nlmsghdr *)buffer;
+ nlh->nlmsg_seq = 0;
+ nlh->nlmsg_pid = getpid();
+ nlh->nlmsg_type = NLMSG_DONE;
+ nlh->nlmsg_len = NLMSG_LENGTH(size - sizeof(*nlh));
+ nlh->nlmsg_flags = 0;
+
+ iov[0].iov_base = nlh;
+ iov[0].iov_len = sizeof(*nlh);
+
+ iov[1].iov_base = msg;
+ iov[1].iov_len = size;
+
+ memset(&message, 0, sizeof(message));
+ message.msg_name = &addr;
+ message.msg_namelen = sizeof(addr);
+ message.msg_iov = iov;
+ message.msg_iovlen = 2;
+
+ return sendmsg(fd, &message, 0);
+}
+
+main(void)
+{
+ int fd, len, sock_opt;
+ int error;
+ struct cn_msg *message;
+ struct pollfd pfd;
+ struct nlmsghdr *incoming_msg;
+ struct cn_msg *incoming_cn_msg;
+ char *key_value;
+ char *key_name;
+ int key_index;
+
+ daemon(1, 0);
+ openlog("KVP", 0, LOG_USER);
+ syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
+ /*
+ * Retrieve OS release information.
+ */
+ kvp_get_os_info();
+
+ fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
+ if (fd < 0) {
+ syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd);
+ exit(-1);
+ }
+ addr.nl_family = AF_NETLINK;
+ addr.nl_pad = 0;
+ addr.nl_pid = 0;
+ addr.nl_groups = CN_KVP_IDX;
+
+
+ error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ if (error < 0) {
+ syslog(LOG_ERR, "bind failed; error:%d", error);
+ close(fd);
+ exit(-1);
+ }
+ sock_opt = addr.nl_groups;
+ setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt));
+ /*
+ * Register ourselves with the kernel.
+ */
+ message = (struct cn_msg *)kvp_send_buffer;
+ message->id.idx = CN_KVP_IDX;
+ message->id.val = CN_KVP_VAL;
+ message->seq = KVP_REGISTER;
+ message->ack = 0;
+ message->len = 0;
+
+ len = netlink_send(fd, message);
+ if (len < 0) {
+ syslog(LOG_ERR, "netlink_send failed; error:%d", len);
+ close(fd);
+ exit(-1);
+ }
+
+ pfd.fd = fd;
+
+ while (1) {
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+ poll(&pfd, 1, -1);
+
+ len = recv(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0);
+
+ if (len < 0) {
+ syslog(LOG_ERR, "recv failed; error:%d", len);
+ close(fd);
+ return -1;
+ }
+
+ incoming_msg = (struct nlmsghdr *)kvp_recv_buffer;
+ incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg);
+
+ switch (incoming_cn_msg->seq) {
+ case KVP_REGISTER:
+ /*
+ * Driver is registering with us; stash away the version
+ * information.
+ */
+ lic_version = malloc(strlen(incoming_cn_msg->data) + 1);
+ if (lic_version) {
+ strcpy(lic_version, incoming_cn_msg->data);
+ syslog(LOG_INFO, "KVP LIC Version: %s",
+ lic_version);
+ } else {
+ syslog(LOG_ERR, "malloc failed");
+ }
+ continue;
+
+ case KVP_KERNEL_GET:
+ break;
+ default:
+ continue;
+ }
+
+ key_index =
+ ((struct hv_ku_msg *)incoming_cn_msg->data)->kvp_index;
+ key_name =
+ ((struct hv_ku_msg *)incoming_cn_msg->data)->kvp_key;
+ key_value =
+ ((struct hv_ku_msg *)incoming_cn_msg->data)->kvp_value;
+
+ switch (key_index) {
+ case FullyQualifiedDomainName:
+ kvp_get_domain_name(key_value,
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE);
+ strcpy(key_name, "FullyQualifiedDomainName");
+ break;
+ case IntegrationServicesVersion:
+ strcpy(key_name, "IntegrationServicesVersion");
+ strcpy(key_value, lic_version);
+ break;
+ case NetworkAddressIPv4:
+ kvp_get_ip_address(AF_INET, key_value,
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE);
+ strcpy(key_name, "NetworkAddressIPv4");
+ break;
+ case NetworkAddressIPv6:
+ kvp_get_ip_address(AF_INET6, key_value,
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE);
+ strcpy(key_name, "NetworkAddressIPv6");
+ break;
+ case OSBuildNumber:
+ strcpy(key_value, os_build);
+ strcpy(key_name, "OSBuildNumber");
+ break;
+ case OSName:
+ strcpy(key_value, os_name);
+ strcpy(key_name, "OSName");
+ break;
+ case OSMajorVersion:
+ strcpy(key_value, os_major);
+ strcpy(key_name, "OSMajorVersion");
+ break;
+ case OSMinorVersion:
+ strcpy(key_value, os_minor);
+ strcpy(key_name, "OSMinorVersion");
+ break;
+ case OSVersion:
+ strcpy(key_value, os_build);
+ strcpy(key_name, "OSVersion");
+ break;
+ case ProcessorArchitecture:
+ strcpy(key_value, processor_arch);
+ strcpy(key_name, "ProcessorArchitecture");
+ break;
+ default:
+ strcpy(key_value, "Unknown Key");
+ /*
+ * We use a null key name to terminate enumeration.
+ */
+ strcpy(key_name, "");
+ break;
+ }
+ /*
+ * Send the value back to the kernel. The response is
+ * already in the receive buffer. Update the cn_msg header to
+ * reflect the key value that has been added to the message
+ */
+
+ incoming_cn_msg->id.idx = CN_KVP_IDX;
+ incoming_cn_msg->id.val = CN_KVP_VAL;
+ incoming_cn_msg->seq = KVP_USER_SET;
+ incoming_cn_msg->ack = 0;
+ incoming_cn_msg->len = sizeof(struct hv_ku_msg);
+
+ len = netlink_send(fd, incoming_cn_msg);
+ if (len < 0) {
+ syslog(LOG_ERR, "net_link send failed; error:%d", len);
+ exit(-1);
+ }
+ }
+
+}
[-- Attachment #3: Type: text/plain, Size: 159 bytes --]
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
^ permalink raw reply
* Re: [PATCH 1/3]: An implementation of HyperV KVP functionality
From: Greg KH @ 2010-12-07 23:10 UTC (permalink / raw)
To: Ky Srinivasan
Cc: devel, Haiyang Zhang, Virtualization, Zbr, Stephen Hemminger
In-Reply-To: <4CFE4E40020000300009170B@novprvoes0310.provo.novell.com>
On Tue, Dec 07, 2010 at 03:09:52PM -0700, Ky Srinivasan wrote:
> This patch is re-based on the latest linux-next tree.
>
> From: K. Y. Srinivasan <ksrinivasan@novell.com>
> Subject: Reserve a connector index for implementing HyperV Key Value Pair
> (KVP) functionality.
A hint, this is not how you submit a patch. Please put the Subject line
up above in the real Subject for the email.
Also provide a bit of a description in the body of the email that
explains what is going on.
>
> Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
>
> Index: linux.trees.git/include/linux/connector.h
> ===================================================================
What are these lines from? Surely you aren't using cvs these days, are
you?
I should be able to take the email and directly feed it to 'git am' to
apply it, without editing it at all.
Care to fix this, and address the connector issues, and then resend them
all?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 2/3]: An implementation of HyperV KVP functionality
From: Greg KH @ 2010-12-07 23:12 UTC (permalink / raw)
To: Ky Srinivasan
Cc: devel, Haiyang Zhang, Virtualization, Zbr, Stephen Hemminger
In-Reply-To: <4CFE5204020000300009174C@novprvoes0310.provo.novell.com>
On Tue, Dec 07, 2010 at 03:25:56PM -0700, Ky Srinivasan wrote:
> This patch is re-based on the latest linux-next tree.
>
> From: K. Y. Srinivasan <ksrinivasan@novell.com>
>
> Subject: The hv_utils module will be composed of more than one file;
> rename hv_utils.c to accommodate this without changing the module name.
>
> Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
>
Please put the diffstat of the patch in below the signed-off-by: and
after a --- line.
> Index: linux.trees.git/drivers/staging/hv/Makefile
> ===================================================================
> --- linux.trees.git.orig/drivers/staging/hv/Makefile 2010-12-07 07:04:41.000000000 -0500
> +++ linux.trees.git/drivers/staging/hv/Makefile 2010-12-07 08:00:10.000000000 -0500
> @@ -10,3 +10,4 @@ hv_vmbus-y := vmbus_drv.o osd.o \
> hv_storvsc-y := storvsc_drv.o storvsc.o
> hv_blkvsc-y := blkvsc_drv.o blkvsc.o
> hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
> +hv_utils-y := hv_util.o
> Index: linux.trees.git/drivers/staging/hv/hv_util.c
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux.trees.git/drivers/staging/hv/hv_util.c 2010-12-07 08:00:10.000000000 -0500
Are you renaming the file here? Are you using git? If so, it should
produce a patch that shows the rename happened, not this big 'remove it
all and then add it back' type thing.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 3/3]: An implementation of HyperV KVP functionality
From: Greg KH @ 2010-12-07 23:13 UTC (permalink / raw)
To: Ky Srinivasan
Cc: devel, Haiyang Zhang, Virtualization, Zbr, Stephen Hemminger
In-Reply-To: <4CFE5342020000300009175A@novprvoes0310.provo.novell.com>
On Tue, Dec 07, 2010 at 03:31:14PM -0700, Ky Srinivasan wrote:
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux.trees.git/drivers/staging/hv/hv_kvp.c 2010-12-07 07:05:39.000000000 -0500
> @@ -0,0 +1,356 @@
> +/*
> + * An implementation of key value pair (KVP) functionality for Linux.
> + *
> + *
> + * Copyright (C) 2010, Novell, Inc.
> + * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
This is fine.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
> + * NON INFRINGEMENT. See the GNU General Public License for more
> + * details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
These two paragraphs are not needed.
Especially if the FSF moves again, you don't want to have to go and
patch all old files in the kernel.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 2/3]: An implementation of HyperV KVP functionality
From: Ky Srinivasan @ 2010-12-07 23:19 UTC (permalink / raw)
To: Evgeniy Polyakov
Cc: devel, Haiyang Zhang, Greg KH, Virtualization, Stephen Hemminger
In-Reply-To: <20101207222933.GA10431@ioremap.net>
>>> On 12/7/2010 at 5:29 PM, in message <20101207222933.GA10431@ioremap.net>,
Evgeniy Polyakov <zbr@ioremap.net> wrote:
> On Tue, Dec 07, 2010 at 03:25:56PM -0700, Ky Srinivasan
> (ksrinivasan@novell.com) wrote:
>> +static void shutdown_onchannelcallback(void *context)
>> +{
>> + struct vmbus_channel *channel = context;
>> + u8 *buf;
>> + u32 buflen, recvlen;
>> + u64 requestid;
>> + u8 execute_shutdown = false;
>> +
>> + struct shutdown_msg_data *shutdown_msg;
>> +
>> + struct icmsg_hdr *icmsghdrp;
>> + struct icmsg_negotiate *negop = NULL;
>> +
>> + buflen = PAGE_SIZE;
>> + buf = kmalloc(buflen, GFP_ATOMIC);
>> +
>> + vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
>
> This did not change since previous review and this is wrong.
> It is the right way to crash kernel.
>
> I did not read further since this is a show-stopper imo.
Hank, do you want to respond to this comment.
Regards,
K. Y
^ permalink raw reply
* RE: [PATCH 2/3]: An implementation of HyperV KVP functionality
From: Hank Janssen @ 2010-12-08 18:09 UTC (permalink / raw)
To: Ky Srinivasan, Evgeniy Polyakov
Cc: devel@driverdev.osuosl.org, Virtualization@lists.osdl.org,
Haiyang Zhang, Greg KH, Stephen Hemminger
In-Reply-To: <4CFE5E770200003000091778@novprvoes0310.provo.novell.com>
> From: Ky Srinivasan [mailto:ksrinivasan@novell.com]
> Sent: Tuesday, December 07, 2010 3:19 PM
> >>> On 12/7/2010 at 5:29 PM, in message
> <20101207222933.GA10431@ioremap.net>,
> Evgeniy Polyakov <zbr@ioremap.net> wrote:
> > On Tue, Dec 07, 2010 at 03:25:56PM -0700, Ky Srinivasan
> > (ksrinivasan@novell.com) wrote:
> >> +static void shutdown_onchannelcallback(void *context)
> >> +{
> >> + struct vmbus_channel *channel = context;
> >> + u8 *buf;
> >> + u32 buflen, recvlen;
> >> + u64 requestid;
> >> + u8 execute_shutdown = false;
> >> +
> >> + struct shutdown_msg_data *shutdown_msg;
> >> +
> >> + struct icmsg_hdr *icmsghdrp;
> >> + struct icmsg_negotiate *negop = NULL;
> >> +
> >> + buflen = PAGE_SIZE;
> >> + buf = kmalloc(buflen, GFP_ATOMIC);
> >> +
> >> + vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
> >
> > This did not change since previous review and this is wrong.
> > It is the right way to crash kernel.
> >
> > I did not read further since this is a show-stopper imo.
> Hank, do you want to respond to this comment.
>
I will submit a patch for hv_utils.c to check the return value from
kmalloc and vmbus_recvpacket and return if either one of them fail.
The function is a void because they are treated here as fire and
Forget. But it comment about what would happen if kmalloc or
Vmbus_recvpacket fails is correct. We could cause a crash.
So I will correct that part.
Hank.
^ permalink raw reply
* Re: [PATCH 1/3]: An implementation of HyperV KVP functionality
From: Ky Srinivasan @ 2010-12-08 21:31 UTC (permalink / raw)
To: Greg KH; +Cc: devel, Zbr, Haiyang Zhang, Stephen Hemminger, Virtualization
In-Reply-To: <20101207231042.GD27918@suse.de>
>
> Care to fix this, and address the connector issues, and then resend them
> all?
Evgeniy has acked the patch for adding a new connector index for implementing the KVP functionality. The concern Evgeniy had was with regards to the code currently in the upstream tree and Hank is planning to submit a patch to fix that issue.
Regards,
K. Y
>
> thanks,
>
> greg k-h
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: [PATCH 1/3]: An implementation of HyperV KVP functionality
From: Evgeniy Polyakov @ 2010-12-08 21:44 UTC (permalink / raw)
To: Ky Srinivasan
Cc: devel, Virtualization, Haiyang Zhang, Greg KH, Stephen Hemminger
In-Reply-To: <4CFF96D30200003000091878@novprvoes0310.provo.novell.com>
On Wed, Dec 08, 2010 at 02:31:47PM -0700, Ky Srinivasan (ksrinivasan@novell.com) wrote:
> > Care to fix this, and address the connector issues, and then resend them
> > all?
>
> Evgeniy has acked the patch for adding a new connector index for implementing the KVP functionality. The concern Evgeniy had was with regards to the code currently in the upstream tree and Hank is planning to submit a patch to fix that issue.
Connector is ok, but rest of the code looks wrong sometimes,
so please resumbit the whole series with proper descriptions
and subject lines.
Thank you.
--
Evgeniy Polyakov
^ permalink raw reply
* [PATCH 1/4] Add a connector Index to support HyperV KVP functionality
From: Ky Srinivasan @ 2010-12-08 22:20 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Zbr, Haiyang Zhang, Stephen Hemminger, Greg KH
From 5b7c16baf2f310a1e7e119c3df8fd976ca0e2f57 Mon Sep 17 00:00:00 2001
From: ksrinivasan <ksrinivasan@novell.com>
Date: Wed, 8 Dec 2010 09:35:13 -0700
Added a connector index to support key value/pair (KVP) functionality
for Linux guests hosted on a HyperV platform. All KVP related
data gathering will be done in a user-level daemon. The kernel
component of KVP communicates with the data gathering daemon using this
connector index.
Signed-off-by: ksrinivasan <ksrinivasan@novell.com>
---
include/linux/connector.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 7e8ca75..2e9759c 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -42,8 +42,9 @@
#define CN_VAL_DM_USERSPACE_LOG 0x1
#define CN_IDX_DRBD 0x8
#define CN_VAL_DRBD 0x1
+#define CN_KVP_IDX 0x9 /* HyperV KVP */
-#define CN_NETLINK_USERS 8
+#define CN_NETLINK_USERS 9
/*
* Maximum connector's message size.
--
1.7.1
^ permalink raw reply related
* [PATCH 2/4] Rename the file hv_utils.c
From: Ky Srinivasan @ 2010-12-08 22:26 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Zbr, Haiyang Zhang, Stephen Hemminger, Greg KH
From 453acddcf55f1e68c5baf9dc5e8f601d18de15b0 Mon Sep 17 00:00:00 2001
From: ksrinivasan <ksrinivasan@novell.com>
Date: Wed, 8 Dec 2010 12:24:58 -0700
The hv_utils module will be composed of more than one file.
Rename hv_utils.c to accommodate this without changing the module name.
Signed-off-by: ksrinivasan <ksrinivasan@novell.com>
---
drivers/staging/hv/Makefile | 1 +
drivers/staging/hv/hv_util.c | 308 +++++++++++++++++++++++++++++++++++++++++
drivers/staging/hv/hv_utils.c | 308 -----------------------------------------
3 files changed, 309 insertions(+), 308 deletions(-)
create mode 100644 drivers/staging/hv/hv_util.c
delete mode 100644 drivers/staging/hv/hv_utils.c
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index acd39bd..4c14138 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -10,3 +10,4 @@ hv_vmbus-y := vmbus_drv.o osd.o \
hv_storvsc-y := storvsc_drv.o storvsc.o
hv_blkvsc-y := blkvsc_drv.o blkvsc.o
hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
+hv_utils-y := hv_util.o
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
new file mode 100644
index 0000000..53e1e29
--- /dev/null
+++ b/drivers/staging/hv/hv_util.c
@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2010, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ * Haiyang Zhang <haiyangz@microsoft.com>
+ * Hank Janssen <hjanssen@microsoft.com>
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sysctl.h>
+#include <linux/reboot.h>
+#include <linux/dmi.h>
+#include <linux/pci.h>
+
+#include "logging.h"
+#include "osd.h"
+#include "vmbus.h"
+#include "vmbus_packet_format.h"
+#include "vmbus_channel_interface.h"
+#include "version_info.h"
+#include "channel.h"
+#include "vmbus_private.h"
+#include "vmbus_api.h"
+#include "utils.h"
+
+
+static void shutdown_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+ u8 execute_shutdown = false;
+
+ struct shutdown_msg_data *shutdown_msg;
+
+ struct icmsg_hdr *icmsghdrp;
+ struct icmsg_negotiate *negop = NULL;
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, negop, buf);
+ } else {
+ shutdown_msg = (struct shutdown_msg_data *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+
+ switch (shutdown_msg->flags) {
+ case 0:
+ case 1:
+ icmsghdrp->status = HV_S_OK;
+ execute_shutdown = true;
+
+ DPRINT_INFO(VMBUS, "Shutdown request received -"
+ " gracefull shutdown initiated");
+ break;
+ default:
+ icmsghdrp->status = HV_E_FAIL;
+ execute_shutdown = false;
+
+ DPRINT_INFO(VMBUS, "Shutdown request received -"
+ " Invalid request");
+ break;
+ };
+ }
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+
+ if (execute_shutdown == true)
+ orderly_poweroff(false);
+}
+
+/*
+ * Set guest time to host UTC time.
+ */
+static inline void do_adj_guesttime(u64 hosttime)
+{
+ s64 host_tns;
+ struct timespec host_ts;
+
+ host_tns = (hosttime - WLTIMEDELTA) * 100;
+ host_ts = ns_to_timespec(host_tns);
+
+ do_settimeofday(&host_ts);
+}
+
+/*
+ * Synchronize time with host after reboot, restore, etc.
+ *
+ * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
+ * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time
+ * message after the timesync channel is opened. Since the hv_utils module is
+ * loaded after hv_vmbus, the first message is usually missed. The other
+ * thing is, systime is automatically set to emulated hardware clock which may
+ * not be UTC time or in the same time zone. So, to override these effects, we
+ * use the first 50 time samples for initial system time setting.
+ */
+static inline void adj_guesttime(u64 hosttime, u8 flags)
+{
+ static s32 scnt = 50;
+
+ if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
+ do_adj_guesttime(hosttime);
+ return;
+ }
+
+ if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
+ scnt--;
+ do_adj_guesttime(hosttime);
+ }
+}
+
+/*
+ * Time Sync Channel message handler.
+ */
+static void timesync_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+ struct icmsg_hdr *icmsghdrp;
+ struct ictimesync_data *timedatap;
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, NULL, buf);
+ } else {
+ timedatap = (struct ictimesync_data *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+ adj_guesttime(timedatap->parenttime, timedatap->flags);
+ }
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+}
+
+/*
+ * Heartbeat functionality.
+ * Every two seconds, Hyper-V send us a heartbeat request message.
+ * we respond to this message, and Hyper-V knows we are alive.
+ */
+static void heartbeat_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+ struct icmsg_hdr *icmsghdrp;
+ struct heartbeat_msg_data *heartbeat_msg;
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, NULL, buf);
+ } else {
+ heartbeat_msg = (struct heartbeat_msg_data *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+
+ DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
+ heartbeat_msg->seq_num);
+
+ heartbeat_msg->seq_num += 1;
+ }
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+}
+
+static const struct pci_device_id __initconst
+hv_utils_pci_table[] __maybe_unused = {
+ { PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
+
+
+static const struct dmi_system_id __initconst
+hv_utils_dmi_table[] __maybe_unused = {
+ {
+ .ident = "Hyper-V",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
+ DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
+ },
+ },
+ { },
+};
+MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
+
+
+static int __init init_hyperv_utils(void)
+{
+ printk(KERN_INFO "Registering HyperV Utility Driver\n");
+
+ if (!dmi_check_system(hv_utils_dmi_table))
+ return -ENODEV;
+
+ hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
+ &shutdown_onchannelcallback;
+ hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
+
+ hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
+ ×ync_onchannelcallback;
+ hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback;
+
+ hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
+ &heartbeat_onchannelcallback;
+ hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
+
+ return 0;
+}
+
+static void exit_hyperv_utils(void)
+{
+ printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
+
+ hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+ hv_cb_utils[HV_SHUTDOWN_MSG].callback = &chn_cb_negotiate;
+
+ hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+ hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;
+
+ hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+ hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
+}
+
+module_init(init_hyperv_utils);
+module_exit(exit_hyperv_utils);
+
+MODULE_DESCRIPTION("Hyper-V Utilities");
+MODULE_VERSION(HV_DRV_VERSION);
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c
deleted file mode 100644
index 53e1e29..0000000
--- a/drivers/staging/hv/hv_utils.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2010, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- * Haiyang Zhang <haiyangz@microsoft.com>
- * Hank Janssen <hjanssen@microsoft.com>
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/sysctl.h>
-#include <linux/reboot.h>
-#include <linux/dmi.h>
-#include <linux/pci.h>
-
-#include "logging.h"
-#include "osd.h"
-#include "vmbus.h"
-#include "vmbus_packet_format.h"
-#include "vmbus_channel_interface.h"
-#include "version_info.h"
-#include "channel.h"
-#include "vmbus_private.h"
-#include "vmbus_api.h"
-#include "utils.h"
-
-
-static void shutdown_onchannelcallback(void *context)
-{
- struct vmbus_channel *channel = context;
- u8 *buf;
- u32 buflen, recvlen;
- u64 requestid;
- u8 execute_shutdown = false;
-
- struct shutdown_msg_data *shutdown_msg;
-
- struct icmsg_hdr *icmsghdrp;
- struct icmsg_negotiate *negop = NULL;
-
- buflen = PAGE_SIZE;
- buf = kmalloc(buflen, GFP_ATOMIC);
-
- vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
-
- if (recvlen > 0) {
- DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
- recvlen, requestid);
-
- icmsghdrp = (struct icmsg_hdr *)&buf[
- sizeof(struct vmbuspipe_hdr)];
-
- if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
- prep_negotiate_resp(icmsghdrp, negop, buf);
- } else {
- shutdown_msg = (struct shutdown_msg_data *)&buf[
- sizeof(struct vmbuspipe_hdr) +
- sizeof(struct icmsg_hdr)];
-
- switch (shutdown_msg->flags) {
- case 0:
- case 1:
- icmsghdrp->status = HV_S_OK;
- execute_shutdown = true;
-
- DPRINT_INFO(VMBUS, "Shutdown request received -"
- " gracefull shutdown initiated");
- break;
- default:
- icmsghdrp->status = HV_E_FAIL;
- execute_shutdown = false;
-
- DPRINT_INFO(VMBUS, "Shutdown request received -"
- " Invalid request");
- break;
- };
- }
-
- icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
- | ICMSGHDRFLAG_RESPONSE;
-
- vmbus_sendpacket(channel, buf,
- recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
- }
-
- kfree(buf);
-
- if (execute_shutdown == true)
- orderly_poweroff(false);
-}
-
-/*
- * Set guest time to host UTC time.
- */
-static inline void do_adj_guesttime(u64 hosttime)
-{
- s64 host_tns;
- struct timespec host_ts;
-
- host_tns = (hosttime - WLTIMEDELTA) * 100;
- host_ts = ns_to_timespec(host_tns);
-
- do_settimeofday(&host_ts);
-}
-
-/*
- * Synchronize time with host after reboot, restore, etc.
- *
- * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
- * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time
- * message after the timesync channel is opened. Since the hv_utils module is
- * loaded after hv_vmbus, the first message is usually missed. The other
- * thing is, systime is automatically set to emulated hardware clock which may
- * not be UTC time or in the same time zone. So, to override these effects, we
- * use the first 50 time samples for initial system time setting.
- */
-static inline void adj_guesttime(u64 hosttime, u8 flags)
-{
- static s32 scnt = 50;
-
- if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
- do_adj_guesttime(hosttime);
- return;
- }
-
- if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
- scnt--;
- do_adj_guesttime(hosttime);
- }
-}
-
-/*
- * Time Sync Channel message handler.
- */
-static void timesync_onchannelcallback(void *context)
-{
- struct vmbus_channel *channel = context;
- u8 *buf;
- u32 buflen, recvlen;
- u64 requestid;
- struct icmsg_hdr *icmsghdrp;
- struct ictimesync_data *timedatap;
-
- buflen = PAGE_SIZE;
- buf = kmalloc(buflen, GFP_ATOMIC);
-
- vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
-
- if (recvlen > 0) {
- DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
- recvlen, requestid);
-
- icmsghdrp = (struct icmsg_hdr *)&buf[
- sizeof(struct vmbuspipe_hdr)];
-
- if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
- prep_negotiate_resp(icmsghdrp, NULL, buf);
- } else {
- timedatap = (struct ictimesync_data *)&buf[
- sizeof(struct vmbuspipe_hdr) +
- sizeof(struct icmsg_hdr)];
- adj_guesttime(timedatap->parenttime, timedatap->flags);
- }
-
- icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
- | ICMSGHDRFLAG_RESPONSE;
-
- vmbus_sendpacket(channel, buf,
- recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
- }
-
- kfree(buf);
-}
-
-/*
- * Heartbeat functionality.
- * Every two seconds, Hyper-V send us a heartbeat request message.
- * we respond to this message, and Hyper-V knows we are alive.
- */
-static void heartbeat_onchannelcallback(void *context)
-{
- struct vmbus_channel *channel = context;
- u8 *buf;
- u32 buflen, recvlen;
- u64 requestid;
- struct icmsg_hdr *icmsghdrp;
- struct heartbeat_msg_data *heartbeat_msg;
-
- buflen = PAGE_SIZE;
- buf = kmalloc(buflen, GFP_ATOMIC);
-
- vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
-
- if (recvlen > 0) {
- DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
- recvlen, requestid);
-
- icmsghdrp = (struct icmsg_hdr *)&buf[
- sizeof(struct vmbuspipe_hdr)];
-
- if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
- prep_negotiate_resp(icmsghdrp, NULL, buf);
- } else {
- heartbeat_msg = (struct heartbeat_msg_data *)&buf[
- sizeof(struct vmbuspipe_hdr) +
- sizeof(struct icmsg_hdr)];
-
- DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
- heartbeat_msg->seq_num);
-
- heartbeat_msg->seq_num += 1;
- }
-
- icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
- | ICMSGHDRFLAG_RESPONSE;
-
- vmbus_sendpacket(channel, buf,
- recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
- }
-
- kfree(buf);
-}
-
-static const struct pci_device_id __initconst
-hv_utils_pci_table[] __maybe_unused = {
- { PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
- { 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
-
-
-static const struct dmi_system_id __initconst
-hv_utils_dmi_table[] __maybe_unused = {
- {
- .ident = "Hyper-V",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
- DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
- },
- },
- { },
-};
-MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
-
-
-static int __init init_hyperv_utils(void)
-{
- printk(KERN_INFO "Registering HyperV Utility Driver\n");
-
- if (!dmi_check_system(hv_utils_dmi_table))
- return -ENODEV;
-
- hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
- &shutdown_onchannelcallback;
- hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
-
- hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
- ×ync_onchannelcallback;
- hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback;
-
- hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
- &heartbeat_onchannelcallback;
- hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
-
- return 0;
-}
-
-static void exit_hyperv_utils(void)
-{
- printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
-
- hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_SHUTDOWN_MSG].callback = &chn_cb_negotiate;
-
- hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;
-
- hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
- &chn_cb_negotiate;
- hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
-}
-
-module_init(init_hyperv_utils);
-module_exit(exit_hyperv_utils);
-
-MODULE_DESCRIPTION("Hyper-V Utilities");
-MODULE_VERSION(HV_DRV_VERSION);
-MODULE_LICENSE("GPL");
--
1.7.1
^ permalink raw reply related
* [PATCH 3/4] An Implementation of KVP functionality
From: Ky Srinivasan @ 2010-12-08 22:29 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Zbr, Haiyang Zhang, Stephen Hemminger, Greg KH
From 2843393e8f50421e81e033806cd121cfb8cc7b6a Mon Sep 17 00:00:00 2001
From: ksrinivasan <ksrinivasan@novell.com>
Date: Wed, 8 Dec 2010 13:46:46 -0700
This is an implementation of the key/value pair (KVP) functionality
for Linux guests hosted on HyperV. All guest specific data gathering for
KVP will be implemented in a user-level daemon. This kernel component packaged
as part of the hv_utils driver supports communication with the HyperV
host.
Signed-off-by: ksrinivasan <ksrinivasan@novell.com>
---
drivers/staging/hv/Makefile | 2 +-
drivers/staging/hv/channel_mgmt.c | 23 +++-
drivers/staging/hv/hv_kvp.c | 346 +++++++++++++++++++++++++++++++++++++
drivers/staging/hv/hv_kvp.h | 175 +++++++++++++++++++
drivers/staging/hv/hv_util.c | 17 ++
drivers/staging/hv/utils.h | 1 +
6 files changed, 561 insertions(+), 3 deletions(-)
create mode 100644 drivers/staging/hv/hv_kvp.c
create mode 100644 drivers/staging/hv/hv_kvp.h
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index 4c14138..606ce7d 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -10,4 +10,4 @@ hv_vmbus-y := vmbus_drv.o osd.o \
hv_storvsc-y := storvsc_drv.o storvsc.o
hv_blkvsc-y := blkvsc_drv.o blkvsc.o
hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
-hv_utils-y := hv_util.o
+hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 0f4d609..375f164 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -34,8 +34,8 @@ struct vmbus_channel_message_table_entry {
void (*messageHandler)(struct vmbus_channel_message_header *msg);
};
-#define MAX_MSG_TYPES 3
-#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 7
+#define MAX_MSG_TYPES 4
+#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8
static const struct hv_guid
gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
@@ -98,6 +98,15 @@ static const struct hv_guid
0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
}
},
+ /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
+ /* KVP */
+ {
+ .data = {
+ 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+ 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6
+ }
+ },
+
};
@@ -231,6 +240,16 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
.callback = chn_cb_negotiate,
.log_msg = "Heartbeat channel functionality initialized"
},
+ /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
+ /* KVP */
+ {
+ .data = {
+ 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+ 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6
+ },
+ .callback = chn_cb_negotiate,
+ .log_msg = "KVP channel functionality initialized"
+ },
};
EXPORT_SYMBOL(hv_cb_utils);
diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c
new file mode 100644
index 0000000..16a95ea
--- /dev/null
+++ b/drivers/staging/hv/hv_kvp.c
@@ -0,0 +1,346 @@
+/*
+ * An implementation of key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+
+#include <linux/net.h>
+#include <linux/nls.h>
+#include <linux/connector.h>
+#include <linux/workqueue.h>
+
+#include "logging.h"
+#include "osd.h"
+#include "vmbus.h"
+#include "vmbus_packet_format.h"
+#include "vmbus_channel_interface.h"
+#include "version_info.h"
+#include "channel.h"
+#include "vmbus_private.h"
+#include "vmbus_api.h"
+#include "utils.h"
+#include "hv_kvp.h"
+
+
+
+/*
+ * Global state maintained for transaction that is being processed.
+ * Note that only one transaction can be active at any point in time.
+ *
+ * This state is set when we receive a request from the host; we
+ * cleanup this state when the transaction is completed - when we respond
+ * to the host with the key value.
+ */
+
+static struct {
+ bool active; /* transaction status - active or not */
+ u8 *recv_buffer; /* the receive buffer that we allocated */
+ int recv_len; /* number of bytes received. */
+ struct vmbus_channel *recv_channel; /* chn we got the request */
+ u64 recv_req_id; /* request ID. */
+} kvp_transaction;
+
+static int kvp_send_key(int index);
+
+static void kvp_respond_to_host(char *key, char *value, int error);
+static void kvp_work_func(struct work_struct *dummy);
+static void kvp_register(void);
+
+static DECLARE_DELAYED_WORK(kvp_work, kvp_work_func);
+
+static struct cb_id kvp_id = { CN_KVP_IDX, CN_KVP_VAL };
+static const char kvp_name[] = "kvp_kernel_module";
+static int timeout_fired;
+
+/*
+ * Register the kernel component with the user-level daemon.
+ * As part of this registration, pass the LIC version number.
+ */
+
+static void
+kvp_register(void)
+{
+
+ struct cn_msg *msg;
+
+ msg = kzalloc(sizeof(*msg) + strlen(HV_DRV_VERSION) + 1 , GFP_ATOMIC);
+
+ if (msg) {
+ msg->id.idx = CN_KVP_IDX;
+ msg->id.val = CN_KVP_VAL;
+ msg->seq = KVP_REGISTER;
+ strcpy(msg->data, HV_DRV_VERSION);
+ msg->len = strlen(HV_DRV_VERSION) + 1;
+ cn_netlink_send(msg, 0, GFP_ATOMIC);
+ kfree(msg);
+ }
+}
+static void
+kvp_work_func(struct work_struct *dummy)
+{
+ /*
+ * If the timer fires, the user-mode component has not responded;
+ * process the pending transaction.
+ */
+ kvp_respond_to_host("Unknown key", "Guest timed out", timeout_fired);
+ timeout_fired = 1;
+}
+
+/*
+ * Callback when data is received from user mode.
+ */
+
+static void
+kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
+{
+ struct hv_ku_msg *message;
+
+ message = (struct hv_ku_msg *)msg->data;
+ if (msg->seq == KVP_REGISTER) {
+ printk(KERN_INFO "KVP: user-mode registering done.\n");
+ kvp_register();
+ }
+
+ if (msg->seq == KVP_USER_SET) {
+ /*
+ * Complete the transaction by forwarding the key value
+ * to the host. But first, cancel the timeout.
+ */
+ if (cancel_delayed_work_sync(&kvp_work))
+ kvp_respond_to_host(message->kvp_key,
+ message->kvp_value,
+ !strlen(message->kvp_key));
+ }
+}
+
+static int
+kvp_send_key(int index)
+{
+ struct cn_msg *msg;
+
+ msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg) , GFP_ATOMIC);
+
+ if (msg) {
+ msg->id.idx = CN_KVP_IDX;
+ msg->id.val = CN_KVP_VAL;
+ msg->seq = KVP_KERNEL_GET;
+ ((struct hv_ku_msg *)msg->data)->kvp_index = index;
+ msg->len = sizeof(struct hv_ku_msg);
+ cn_netlink_send(msg, 0, GFP_ATOMIC);
+ kfree(msg);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * Send a response back to the host.
+ */
+
+static void
+kvp_respond_to_host(char *key, char *value, int error)
+{
+ struct hv_kvp_msg *kvp_msg;
+ struct hv_kvp_msg_enumerate *kvp_data;
+ char *key_name;
+ struct icmsg_hdr *icmsghdrp;
+ int keylen, valuelen;
+ u8 *buf;
+ u32 buf_len;
+ struct vmbus_channel *channel;
+ u64 req_id;
+
+ /*
+ * If a transaction is not active; log and return.
+ */
+
+ if (!kvp_transaction.active) {
+ /*
+ * This is a spurious call!
+ */
+ printk(KERN_WARNING "KVP: Transaction not active\n");
+ return;
+ }
+ /*
+ * Copy the global state for completing the transaction. Note that
+ * only one transaction can be active at a time.
+ */
+
+ buf = kvp_transaction.recv_buffer;
+ buf_len = kvp_transaction.recv_len;
+ channel = kvp_transaction.recv_channel;
+ req_id = kvp_transaction.recv_req_id;
+ kvp_transaction.active = false;
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[sizeof(struct vmbuspipe_hdr)];
+ kvp_msg = (struct hv_kvp_msg *)&buf[sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+ kvp_data = &kvp_msg->kvp_data;
+ key_name = key;
+
+ /*
+ * If the error parameter is set, terminate the host's enumeration.
+ */
+ if (error) {
+ /*
+ * We don't support this index or the we have timedout;
+ * terminate the host-side iteration by returning an error.
+ */
+ icmsghdrp->status = HV_E_FAIL;
+ goto response_done;
+ }
+
+ /*
+ * The windows host expects the key/value pair to be encoded
+ * in utf16.
+ */
+ keylen = utf8s_to_utf16s(key_name, strlen(key_name),
+ (wchar_t *)kvp_data->data.key);
+ kvp_data->data.key_size = 2*(keylen + 1); /* utf16 encoding */
+ valuelen = utf8s_to_utf16s(value, strlen(value),
+ (wchar_t *)kvp_data->data.value);
+ kvp_data->data.value_size = 2*(valuelen + 1); /* utf16 encoding */
+
+ kvp_data->data.value_type = REG_SZ; /* all our values are strings */
+ icmsghdrp->status = HV_S_OK;
+
+response_done:
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf, buf_len, req_id,
+ VmbusPacketTypeDataInBand, 0);
+
+ /*
+ * Free up the buffer that was allocatted when we received a message
+ * from the host.
+ */
+ kfree(buf);
+}
+
+/*
+ * This callback is invoked when we get a KVP message from the host.
+ * The host ensures that only one KVP transaction can be active at a time.
+ * KVP implementation in Linux needs to forward the key to a user-mde
+ * component to retrive the corresponding value. Consequently, we cannot
+ * respond to the host in the conext of this callback. Since the host
+ * guarantees that at most only one transaction can be active at a time,
+ * we stash away the transaction state in a set of global variables.
+ */
+
+void hv_kvp_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+
+ struct hv_kvp_msg *kvp_msg;
+ struct hv_kvp_msg_enumerate *kvp_data;
+
+ struct icmsg_hdr *icmsghdrp;
+ struct icmsg_negotiate *negop = NULL;
+
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "KVP packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, negop, buf);
+ } else {
+ kvp_msg = (struct hv_kvp_msg *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+
+ kvp_data = &kvp_msg->kvp_data;
+
+ /*
+ * We only support the "get" operation on
+ * "KVP_POOL_AUTO" pool.
+ */
+
+ if ((kvp_msg->kvp_hdr.pool != KVP_POOL_AUTO) ||
+ (kvp_msg->kvp_hdr.operation !=
+ KVP_OP_ENUMERATE) ||
+ kvp_transaction.active) {
+ if (kvp_transaction.active)
+ printk(KERN_WARNING
+ "KVP: Invalid call\n");
+ icmsghdrp->status = HV_E_FAIL;
+ goto callback_done;
+ }
+
+ /*
+ * Stash away this global state for completing the
+ * transaction; note transactions are serialized.
+ */
+ kvp_transaction.recv_buffer = buf;
+ kvp_transaction.recv_len = recvlen;
+ kvp_transaction.recv_channel = channel;
+ kvp_transaction.recv_req_id = requestid;
+ kvp_transaction.active = true;
+
+ /*
+ * Get the information from the
+ * user-mode component.
+ * component. This transaction will be
+ * completed when we get the value from
+ * the user-mode component.
+ * Set a timeout to deal with
+ * user-mode not responding.
+ */
+ kvp_send_key(kvp_data->index);
+ schedule_delayed_work(&kvp_work, 100);
+
+ return;
+
+ }
+
+callback_done:
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+
+
+}
+
+int
+hv_kvp_init(void)
+{
+ int err;
+
+ err = cn_add_callback(&kvp_id, kvp_name, kvp_cn_callback);
+ if (err)
+ return err;
+
+ return 0;
+}
+
+void hv_kvp_deinit(void)
+{
+ cn_del_callback(&kvp_id);
+ cancel_delayed_work_sync(&kvp_work);
+}
diff --git a/drivers/staging/hv/hv_kvp.h b/drivers/staging/hv/hv_kvp.h
new file mode 100644
index 0000000..c58c2c6
--- /dev/null
+++ b/drivers/staging/hv/hv_kvp.h
@@ -0,0 +1,175 @@
+/*
+ * An implementation of HyperV key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ *
+ */
+#ifndef _KVP_H
+#define _KVP_H_
+
+/*
+ * Maximum value size - used for both key names and value data, and includes
+ * any applicable NULL terminators.
+ *
+ * Note: This limit is somewhat arbitrary, but falls easily within what is
+ * supported for all native guests (back to Win 2000) and what is reasonable
+ * for the IC KVP exchange functionality. Note that Windows Me/98/95 are
+ * limited to 255 character key names.
+ *
+ * MSDN recommends not storing data values larger than 2048 bytes in the
+ * registry.
+ *
+ * Note: This value is used in defining the KVP exchange message - this value
+ * cannot be modified without affecting the message size and compatability.
+ */
+
+/*
+ * bytes, including any null terminators
+ */
+#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048)
+
+
+/*
+ * Maximum key size - the registry limit for the length of an entry name
+ * is 256 characters, including the null terminator
+ */
+
+#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512)
+
+/*
+ * In Linux, we implement the KVP functionality in two components:
+ * 1) The kernel component which is packaged as part of the hv_utils driver
+ * is responsible for communicating with the host and responsible for
+ * implementing the host/guest protocol. 2) A user level daemon that is
+ * responsible for data gathering.
+ *
+ * Host/Guest Protocol: The host iterates over an index and expects the guest
+ * to assign a key name to the index and also return the value corresponding to
+ * the key. The host will have atmost one KVP transaction outstanding at any
+ * given point in time. The host side iteration stops when the guest returns
+ * an error. Microsoft has specified the following mapping of key names to
+ * host specified index:
+ *
+ * Index Key Name
+ * 0 FullyQualifiedDomainName
+ * 1 IntegrationServicesVersion
+ * 2 NetworkAddressIPv4
+ * 3 NetworkAddressIPv6
+ * 4 OSBuildNumber
+ * 5 OSName
+ * 6 OSMajorVersion
+ * 7 OSMinorVersion
+ * 8 OSVersion
+ * 9 ProcessorArchitecture
+ *
+ * The Windows host expects the Key Name and Key Value to be encoded in utf16.
+ *
+ * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the
+ * data gathering functionality in a user mode daemon. The user level daemon
+ * is also responsible for binding the key name to the index as well. The
+ * kernel and user-level daemon communicate using a connector channel.
+ *
+ * The user mode component first registers with the
+ * the kernel component. Subsequently, the kernel component requests, data
+ * for the specified keys. In response to this message the user mode component
+ * fills in the value corresponding to the specified key. We overload the
+ * sequence field in the cn_msg header to define our KVP message types.
+ *
+ *
+ * The kernel component simply acts as a conduit for communication between the
+ * Windows host and the user-level daemon. The kernel component passes up the
+ * index received from the Host to the user-level daemon. If the index is
+ * valid (supported), the corresponding key as well as its
+ * value (both are strings) is returned. If the index is invalid
+ * (not supported), a NULL key string is returned.
+ */
+
+/*
+ *
+ * The following definitions are shared with the user-mode component; do not
+ * change any of this without making the corresponding changes in
+ * the KVP user-mode component.
+ */
+
+#define CN_KVP_VAL 0x1 /* This supports queries from the kernel */
+#define CN_KVP_USER_VAL 0x2 /* This supports queries from the user */
+
+enum hv_ku_op {
+ KVP_REGISTER = 0, /* Register the user mode component */
+ KVP_KERNEL_GET, /* Kernel is requesting the value */
+ KVP_KERNEL_SET, /* Kernel is providing the value */
+ KVP_USER_GET, /* User is requesting the value */
+ KVP_USER_SET /* User is providing the value */
+};
+
+struct hv_ku_msg {
+ __u32 kvp_index; /* Key index */
+ __u8 kvp_key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; /* Key name */
+ __u8 kvp_value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; /* Key value */
+};
+
+
+
+
+#ifdef __KERNEL__
+
+/*
+ * Registry value types.
+ */
+
+#define REG_SZ 1
+
+enum hv_kvp_exchg_op {
+ KVP_OP_GET = 0,
+ KVP_OP_SET,
+ KVP_OP_DELETE,
+ KVP_OP_ENUMERATE,
+ KVP_OP_COUNT /* Number of operations, must be last. */
+};
+
+enum hv_kvp_exchg_pool {
+ KVP_POOL_EXTERNAL = 0,
+ KVP_POOL_GUEST,
+ KVP_POOL_AUTO,
+ KVP_POOL_AUTO_EXTERNAL,
+ KVP_POOL_AUTO_INTERNAL,
+ KVP_POOL_COUNT /* Number of pools, must be last. */
+};
+
+struct hv_kvp_hdr {
+ u8 operation;
+ u8 pool;
+};
+
+struct hv_kvp_exchg_msg_value {
+ u32 value_type;
+ u32 key_size;
+ u32 value_size;
+ u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
+ u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
+};
+
+struct hv_kvp_msg_enumerate {
+ u32 index;
+ struct hv_kvp_exchg_msg_value data;
+};
+
+struct hv_kvp_msg {
+ struct hv_kvp_hdr kvp_hdr;
+ struct hv_kvp_msg_enumerate kvp_data;
+};
+
+int hv_kvp_init(void);
+void hv_kvp_deinit(void);
+void hv_kvp_onchannelcallback(void *);
+
+#endif /* __KERNEL__ */
+#endif /* _KVP_H */
+
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 53e1e29..0b1855d 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -37,6 +37,7 @@
#include "vmbus_private.h"
#include "vmbus_api.h"
#include "utils.h"
+#include "hv_kvp.h"
static void shutdown_onchannelcallback(void *context)
@@ -265,6 +266,10 @@ static int __init init_hyperv_utils(void)
{
printk(KERN_INFO "Registering HyperV Utility Driver\n");
+ if (hv_kvp_init())
+ return -ENODEV;
+
+
if (!dmi_check_system(hv_utils_dmi_table))
return -ENODEV;
@@ -280,6 +285,11 @@ static int __init init_hyperv_utils(void)
&heartbeat_onchannelcallback;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
+ hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
+ &hv_kvp_onchannelcallback;
+
+
+
return 0;
}
@@ -298,6 +308,13 @@ static void exit_hyperv_utils(void)
hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
&chn_cb_negotiate;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
+
+ hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
+ &chn_cb_negotiate;
+
+ hv_kvp_deinit();
+
+
}
module_init(init_hyperv_utils);
diff --git a/drivers/staging/hv/utils.h b/drivers/staging/hv/utils.h
index 7c07499..6d27d15 100644
--- a/drivers/staging/hv/utils.h
+++ b/drivers/staging/hv/utils.h
@@ -102,6 +102,7 @@ struct ictimesync_data{
#define HV_SHUTDOWN_MSG 0
#define HV_TIMESYNC_MSG 1
#define HV_HEARTBEAT_MSG 2
+#define HV_KVP_MSG 3
struct hyperv_service_callback {
u8 msg_type;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH 1/4] Add a connector Index to support HyperV KVP functionality
From: Greg KH @ 2010-12-08 22:32 UTC (permalink / raw)
To: Ky Srinivasan
Cc: Haiyang Zhang, Virtualization, Zbr, devel, Stephen Hemminger
In-Reply-To: <4CFFA25B02000030000918BE@novprvoes0310.provo.novell.com>
Please make your subject a bit more descriptive, for this one, it would
be:
Subject: [PATCH 1/4] Connector: add index to support HyperV
And what is a "KVP"?
On Wed, Dec 08, 2010 at 03:20:59PM -0700, Ky Srinivasan wrote:
> >From 5b7c16baf2f310a1e7e119c3df8fd976ca0e2f57 Mon Sep 17 00:00:00 2001
> From: ksrinivasan <ksrinivasan@novell.com>
I doubt that's your full name you want as the changelog author
information :)
> Date: Wed, 8 Dec 2010 09:35:13 -0700
Why is this in the body of your message?
>
> Added a connector index to support key value/pair (KVP) functionality
> for Linux guests hosted on a HyperV platform. All KVP related
> data gathering will be done in a user-level daemon. The kernel
> component of KVP communicates with the data gathering daemon using this
> connector index.
>
>
> Signed-off-by: ksrinivasan <ksrinivasan@novell.com>
Same error here with your name :(
Third time's a charm?
greg k-h
^ permalink raw reply
* Re: [PATCH 2/4] Rename the file hv_utils.c
From: Greg KH @ 2010-12-08 22:34 UTC (permalink / raw)
To: Ky Srinivasan
Cc: devel, Haiyang Zhang, Virtualization, Zbr, Stephen Hemminger
In-Reply-To: <4CFFA39202000030000918CC@novprvoes0310.provo.novell.com>
For the subject on the rest of the patches they would look like:
Subject: [PATCH 2/4] Staging: hv: rename hv_utils.c to hv_util.c
Note the "Staging: hv:" prefix.
On Wed, Dec 08, 2010 at 03:26:10PM -0700, Ky Srinivasan wrote:
> >From 453acddcf55f1e68c5baf9dc5e8f601d18de15b0 Mon Sep 17 00:00:00 2001
> From: ksrinivasan <ksrinivasan@novell.com>
> Date: Wed, 8 Dec 2010 12:24:58 -0700
>
> The hv_utils module will be composed of more than one file.
> Rename hv_utils.c to accommodate this without changing the module name.
>
>
> Signed-off-by: ksrinivasan <ksrinivasan@novell.com>
Again, use your full name.
thanks,
greg k-h
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox