summaryrefslogtreecommitdiff
path: root/drivers/staging/hv
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/hv')
-rw-r--r--drivers/staging/hv/Kconfig1
-rw-r--r--drivers/staging/hv/Makefile1
-rw-r--r--drivers/staging/hv/blkvsc.c22
-rw-r--r--drivers/staging/hv/blkvsc_drv.c58
-rw-r--r--drivers/staging/hv/channel.c148
-rw-r--r--drivers/staging/hv/channel_mgmt.c103
-rw-r--r--drivers/staging/hv/connection.c189
-rw-r--r--drivers/staging/hv/hv.c4
-rw-r--r--drivers/staging/hv/hv_kvp.c346
-rw-r--r--drivers/staging/hv/hv_kvp.h184
-rw-r--r--drivers/staging/hv/hv_util.c (renamed from drivers/staging/hv/hv_utils.c)20
-rw-r--r--drivers/staging/hv/netvsc.c126
-rw-r--r--drivers/staging/hv/netvsc_drv.c38
-rw-r--r--drivers/staging/hv/osd.h10
-rw-r--r--drivers/staging/hv/rndis_filter.c52
-rw-r--r--drivers/staging/hv/storvsc.c52
-rw-r--r--drivers/staging/hv/storvsc_drv.c32
-rw-r--r--drivers/staging/hv/tools/hv_kvp_daemon.c470
-rw-r--r--drivers/staging/hv/utils.h1
-rw-r--r--drivers/staging/hv/vmbus_api.h68
-rw-r--r--drivers/staging/hv/vmbus_channel_interface.h26
-rw-r--r--drivers/staging/hv/vmbus_drv.c245
-rw-r--r--drivers/staging/hv/vmbus_packet_format.h118
-rw-r--r--drivers/staging/hv/vmbus_private.h58
24 files changed, 1705 insertions, 667 deletions
diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig
index 7455c804962a..2780312cc30d 100644
--- a/drivers/staging/hv/Kconfig
+++ b/drivers/staging/hv/Kconfig
@@ -31,6 +31,7 @@ config HYPERV_NET
config HYPERV_UTILS
tristate "Microsoft Hyper-V Utilities driver"
+ depends on CONNECTOR
default HYPERV
help
Select this option to enable the Hyper-V Utilities.
diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index acd39bd75b1c..606ce7daa4ee 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 hv_kvp.o
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
index bc16d9172eb2..b0e07c1fc4c8 100644
--- a/drivers/staging/hv/blkvsc.c
+++ b/drivers/staging/hv/blkvsc.c
@@ -51,13 +51,13 @@ static int blk_vsc_on_device_add(struct hv_device *device, void *additional_info
* id. For IDE devices, the device instance id is formatted as
* <bus id> * - <device id> - 8899 - 000000000000.
*/
- device_info->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->dev_instance.data[3] << 24 |
+ device->dev_instance.data[2] << 16 |
+ device->dev_instance.data[1] << 8 |
+ device->dev_instance.data[0];
- device_info->target_id = device->deviceInstance.data[5] << 8 |
- device->deviceInstance.data[4];
+ device_info->target_id = device->dev_instance.data[5] << 8 |
+ device->dev_instance.data[4];
return ret;
}
@@ -73,7 +73,7 @@ int blk_vsc_initialize(struct hv_driver *driver)
/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
driver->name = g_blk_driver_name;
- memcpy(&driver->deviceType, &g_blk_device_type, sizeof(struct hv_guid));
+ memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
stor_driver->request_ext_size = sizeof(struct storvsc_request_extension);
@@ -85,7 +85,7 @@ int blk_vsc_initialize(struct hv_driver *driver)
*/
stor_driver->max_outstanding_req_per_channel =
((stor_driver->ring_buffer_size - PAGE_SIZE) /
- ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET +
+ ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
sizeof(struct vstor_packet) + sizeof(u64),
sizeof(u64)));
@@ -93,9 +93,9 @@ int blk_vsc_initialize(struct hv_driver *driver)
stor_driver->max_outstanding_req_per_channel);
/* Setup the dispatch table */
- 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->base.dev_add = blk_vsc_on_device_add;
+ stor_driver->base.dev_rm = stor_vsc_on_device_remove;
+ stor_driver->base.cleanup = stor_vsc_on_cleanup;
stor_driver->on_io_request = stor_vsc_on_io_request;
return ret;
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 4fb809485d9e..58bbcd60b3d7 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -183,7 +183,7 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
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,
+ memcpy(&drv_ctx->class_id, &storvsc_drv_obj->base.dev_type,
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.cleanup)
+ storvsc_drv_obj->base.cleanup(&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.dev_add) {
DPRINT_ERR(BLKVSC_DRV, "OnDeviceAdd() not set");
ret = -1;
goto Cleanup;
@@ -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.dev_add(device_obj, &device_info);
if (ret != 0) {
DPRINT_ERR(BLKVSC_DRV, "unable to add blkvsc device");
goto Cleanup;
@@ -392,7 +392,7 @@ static int blkvsc_probe(struct device *device)
return ret;
Remove:
- storvsc_drv_obj->base.OnDeviceRemove(device_obj);
+ storvsc_drv_obj->base.dev_rm(device_obj);
Cleanup:
if (blkdev) {
@@ -460,9 +460,9 @@ static int blkvsc_do_flush(struct block_device_context *blkdev)
blkvsc_req->req = NULL;
blkvsc_req->write = 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->request.data_buffer.pfn_array[0] = 0;
+ blkvsc_req->request.data_buffer.offset = 0;
+ blkvsc_req->request.data_buffer.len = 0;
blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
blkvsc_req->cmd_len = 10;
@@ -507,9 +507,9 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev)
blkvsc_req->req = NULL;
blkvsc_req->write = 0;
- 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->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf);
+ blkvsc_req->request.data_buffer.offset = 0;
+ blkvsc_req->request.data_buffer.len = 64;
blkvsc_req->cmnd[0] = INQUIRY;
blkvsc_req->cmnd[1] = 0x1; /* Get product data */
@@ -594,9 +594,9 @@ static int blkvsc_do_read_capacity(struct block_device_context *blkdev)
blkvsc_req->req = NULL;
blkvsc_req->write = 0;
- 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->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf);
+ blkvsc_req->request.data_buffer.offset = 0;
+ blkvsc_req->request.data_buffer.len = 8;
blkvsc_req->cmnd[0] = READ_CAPACITY;
blkvsc_req->cmd_len = 16;
@@ -671,9 +671,9 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev)
blkvsc_req->req = NULL;
blkvsc_req->write = 0;
- 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->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf);
+ blkvsc_req->request.data_buffer.offset = 0;
+ blkvsc_req->request.data_buffer.len = 12;
blkvsc_req->cmnd[0] = 0x9E; /* READ_CAPACITY16; */
blkvsc_req->cmd_len = 16;
@@ -742,14 +742,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.dev_rm)
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.dev_rm(device_obj);
if (ret != 0) {
/* TODO: */
DPRINT_ERR(BLKVSC_DRV,
@@ -866,14 +866,14 @@ 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.data_buffer.Offset,
- blkvsc_req->request.data_buffer.Length);
+ blkvsc_req->request.data_buffer.offset,
+ blkvsc_req->request.data_buffer.len);
#if 0
- for (i = 0; i < (blkvsc_req->request.data_buffer.Length >> 12); i++) {
+ for (i = 0; i < (blkvsc_req->request.data_buffer.len >> 12); i++) {
DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
"req %p pfn[%d] %llx\n",
blkvsc_req, i,
- blkvsc_req->request.data_buffer.PfnArray[i]);
+ blkvsc_req->request.data_buffer.pfn_array[i]);
}
#endif
@@ -993,9 +993,9 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
blkvsc_req->dev = blkdev;
blkvsc_req->req = req;
- blkvsc_req->request.data_buffer.Offset
+ blkvsc_req->request.data_buffer.offset
= bvec->bv_offset;
- blkvsc_req->request.data_buffer.Length
+ blkvsc_req->request.data_buffer.len
= 0;
/* Add to the group */
@@ -1011,9 +1011,9 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
/* Add the curr bvec/segment to the curr blkvsc_req */
blkvsc_req->request.data_buffer.
- PfnArray[databuf_idx]
+ pfn_array[databuf_idx]
= page_to_pfn(bvec->bv_page);
- blkvsc_req->request.data_buffer.Length
+ blkvsc_req->request.data_buffer.len
+= bvec->bv_len;
prev_bvec = bvec;
@@ -1116,7 +1116,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.data_buffer.Length,
+ blkvsc_req->request.data_buffer.len,
blkvsc_req->group->outstanding,
blkdev->num_outstanding_reqs);
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 45a627d77b41..ba9afdabedc1 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -77,10 +77,10 @@ static void vmbus_setevent(struct vmbus_channel *channel)
if (channel->offermsg.monitor_allocated) {
/* Each u32 represents 32 channels */
set_bit(channel->offermsg.child_relid & 31,
- (unsigned long *) gVmbusConnection.SendInterruptPage +
+ (unsigned long *) vmbus_connection.send_int_page +
(channel->offermsg.child_relid >> 5));
- monitorpage = gVmbusConnection.MonitorPages;
+ monitorpage = vmbus_connection.monitor_pages;
monitorpage++; /* Get the child to parent monitor page */
set_bit(channel->monitor_bit,
@@ -88,7 +88,7 @@ static void vmbus_setevent(struct vmbus_channel *channel)
[channel->monitor_grp].pending);
} else {
- VmbusSetEvent(channel->offermsg.child_relid);
+ vmbus_set_event(channel->offermsg.child_relid);
}
}
@@ -100,11 +100,11 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
if (Channel->offermsg.monitor_allocated) {
/* Each u32 represents 32 channels */
clear_bit(Channel->offermsg.child_relid & 31,
- (unsigned long *)gVmbusConnection.SendInterruptPage +
+ (unsigned long *)vmbus_connection.send_int_page +
(Channel->offermsg.child_relid >> 5));
- monitorPage =
- (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
+ monitorPage = (struct hv_monitor_page *)
+ vmbus_connection.monitor_pages;
monitorPage++; /* Get the child to parent monitor page */
clear_bit(Channel->monitor_bit,
@@ -128,12 +128,12 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
debuginfo->relid = channel->offermsg.child_relid;
debuginfo->state = channel->state;
memcpy(&debuginfo->interfacetype,
- &channel->offermsg.offer.InterfaceType, sizeof(struct hv_guid));
+ &channel->offermsg.offer.if_type, sizeof(struct hv_guid));
memcpy(&debuginfo->interface_instance,
- &channel->offermsg.offer.InterfaceInstance,
+ &channel->offermsg.offer.if_instance,
sizeof(struct hv_guid));
- monitorpage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
+ monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages;
debuginfo->monitorid = channel->offermsg.monitorid;
@@ -265,14 +265,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
if (userdatalen)
memcpy(openMsg->userdata, userdata, userdatalen);
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_add_tail(&openInfo->msglistentry,
- &gVmbusConnection.ChannelMsgList);
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ &vmbus_connection.chn_msg_list);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Sending channel open msg...");
- ret = VmbusPostMessage(openMsg,
+ ret = vmbus_post_msg(openMsg,
sizeof(struct vmbus_channel_open_channel));
if (ret != 0) {
DPRINT_ERR(VMBUS, "unable to open channel - %d", ret);
@@ -289,9 +289,9 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
newchannel, openInfo->response.open_result.status);
Cleanup:
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&openInfo->msglistentry);
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
kfree(openInfo->waitevent);
kfree(openInfo);
@@ -338,16 +338,16 @@ static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl)
"gpadl header - relid %d, range count %d, range buflen %d",
gpadl->child_relid, gpadl->rangecount, gpadl->range_buflen);
for (i = 0; i < gpadl->rangecount; i++) {
- pagecount = gpadl->range[i].ByteCount >> PAGE_SHIFT;
+ pagecount = gpadl->range[i].byte_count >> PAGE_SHIFT;
pagecount = (pagecount > 26) ? 26 : pagecount;
DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
- "page count %d", i, gpadl->range[i].ByteCount,
- gpadl->range[i].ByteOffset, pagecount);
+ "page count %d", i, gpadl->range[i].byte_count,
+ gpadl->range[i].byte_offset, pagecount);
for (j = 0; j < pagecount; j++)
DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
- gpadl->range[i].PfnArray[j]);
+ gpadl->range[i].pfn_array[j]);
}
}
@@ -399,10 +399,10 @@ static int create_gpadl_header(void *kbuffer, u32 size,
gpadl_header->rangecount = 1;
gpadl_header->range_buflen = sizeof(struct gpa_range) +
pagecount * sizeof(u64);
- gpadl_header->range[0].ByteOffset = 0;
- gpadl_header->range[0].ByteCount = size;
+ gpadl_header->range[0].byte_offset = 0;
+ gpadl_header->range[0].byte_count = size;
for (i = 0; i < pfncount; i++)
- gpadl_header->range[0].PfnArray[i] = pfn+i;
+ gpadl_header->range[0].pfn_array[i] = pfn+i;
*msginfo = msgheader;
*messagecount = 1;
@@ -463,10 +463,10 @@ static int create_gpadl_header(void *kbuffer, u32 size,
gpadl_header->rangecount = 1;
gpadl_header->range_buflen = sizeof(struct gpa_range) +
pagecount * sizeof(u64);
- gpadl_header->range[0].ByteOffset = 0;
- gpadl_header->range[0].ByteCount = size;
+ gpadl_header->range[0].byte_offset = 0;
+ gpadl_header->range[0].byte_count = size;
for (i = 0; i < pagecount; i++)
- gpadl_header->range[0].PfnArray[i] = pfn+i;
+ gpadl_header->range[0].pfn_array[i] = pfn+i;
*msginfo = msgheader;
*messagecount = 1;
@@ -501,8 +501,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
unsigned long flags;
int ret = 0;
- next_gpadl_handle = atomic_read(&gVmbusConnection.NextGpadlHandle);
- atomic_inc(&gVmbusConnection.NextGpadlHandle);
+ next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
+ atomic_inc(&vmbus_connection.next_gpadl_handle);
ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
if (ret)
@@ -521,18 +521,18 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
dump_gpadl_header(gpadlmsg);
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_add_tail(&msginfo->msglistentry,
- &gVmbusConnection.ChannelMsgList);
+ &vmbus_connection.chn_msg_list);
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
kbuffer, size, msgcount);
DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
msginfo->msgsize - sizeof(*msginfo));
- ret = VmbusPostMessage(gpadlmsg, msginfo->msgsize -
+ ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
sizeof(*msginfo));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
@@ -557,7 +557,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
dump_gpadl_body(gpadl_body, submsginfo->msgsize -
sizeof(*submsginfo));
- ret = VmbusPostMessage(gpadl_body,
+ ret = vmbus_post_msg(gpadl_body,
submsginfo->msgsize -
sizeof(*submsginfo));
if (ret != 0)
@@ -577,9 +577,9 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
*gpadl_handle = gpadlmsg->gpadl;
Cleanup:
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&msginfo->msglistentry);
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
kfree(msginfo->waitevent);
kfree(msginfo);
@@ -616,12 +616,12 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
msg->child_relid = channel->offermsg.child_relid;
msg->gpadl = gpadl_handle;
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_add_tail(&info->msglistentry,
- &gVmbusConnection.ChannelMsgList);
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ &vmbus_connection.chn_msg_list);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
- ret = VmbusPostMessage(msg,
+ ret = vmbus_post_msg(msg,
sizeof(struct vmbus_channel_gpadl_teardown));
if (ret != 0) {
/* TODO: */
@@ -631,9 +631,9 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
osd_waitevent_wait(info->waitevent);
/* Received a torndown response */
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&info->msglistentry);
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
kfree(info->waitevent);
kfree(info);
@@ -669,7 +669,7 @@ void vmbus_close(struct vmbus_channel *channel)
msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
msg->child_relid = channel->offermsg.child_relid;
- ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
+ ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel));
if (ret != 0) {
/* TODO: */
/* something... */
@@ -697,9 +697,9 @@ void vmbus_close(struct vmbus_channel *channel)
*/
if (channel->state == CHANNEL_OPEN_STATE) {
- spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
list_del(&channel->listentry);
- spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
free_channel(channel);
}
@@ -726,7 +726,7 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
{
struct vmpacket_descriptor desc;
u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen;
- u32 packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
+ u32 packetlen_aligned = ALIGN(packetlen, sizeof(u64));
struct scatterlist bufferlist[3];
u64 aligned_data = 0;
int ret;
@@ -739,12 +739,12 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.Type = type; /* VmbusPacketTypeDataInBand; */
- desc.Flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
+ desc.type = type; /* VmbusPacketTypeDataInBand; */
+ desc.flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
/* in 8-bytes granularity */
- desc.DataOffset8 = sizeof(struct vmpacket_descriptor) >> 3;
- desc.Length8 = (u16)(packetlen_aligned >> 3);
- desc.TransactionId = requestid;
+ desc.offset8 = sizeof(struct vmpacket_descriptor) >> 3;
+ desc.len8 = (u16)(packetlen_aligned >> 3);
+ desc.trans_id = requestid;
sg_init_table(bufferlist, 3);
sg_set_buf(&bufferlist[0], &desc, sizeof(struct vmpacket_descriptor));
@@ -793,12 +793,12 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
((MAX_PAGE_BUFFER_COUNT - pagecount) *
sizeof(struct hv_page_buffer));
packetlen = descsize + bufferlen;
- packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
+ packetlen_aligned = ALIGN(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.type = VmbusPacketTypeDataUsingGpaDirect;
+ desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
desc.length8 = (u16)(packetlen_aligned >> 3);
@@ -806,9 +806,9 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
desc.rangecount = pagecount;
for (i = 0; i < pagecount; i++) {
- desc.range[i].Length = pagebuffers[i].Length;
- desc.range[i].Offset = pagebuffers[i].Offset;
- desc.range[i].Pfn = pagebuffers[i].Pfn;
+ desc.range[i].len = pagebuffers[i].len;
+ desc.range[i].offset = pagebuffers[i].offset;
+ desc.range[i].pfn = pagebuffers[i].pfn;
}
sg_init_table(bufferlist, 3);
@@ -842,14 +842,14 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
u32 packetlen_aligned;
struct scatterlist bufferlist[3];
u64 aligned_data = 0;
- u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->Offset,
- multi_pagebuffer->Length);
+ u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->offset,
+ multi_pagebuffer->len);
dump_vmbus_channel(channel);
DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
- multi_pagebuffer->Offset,
- multi_pagebuffer->Length, pfncount);
+ multi_pagebuffer->offset,
+ multi_pagebuffer->len, pfncount);
if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
return -EINVAL;
@@ -862,22 +862,22 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) *
sizeof(u64));
packetlen = descsize + bufferlen;
- packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
+ packetlen_aligned = ALIGN(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.type = VmbusPacketTypeDataUsingGpaDirect;
+ desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
desc.length8 = (u16)(packetlen_aligned >> 3);
desc.transactionid = requestid;
desc.rangecount = 1;
- desc.range.Length = multi_pagebuffer->Length;
- desc.range.Offset = multi_pagebuffer->Offset;
+ desc.range.len = multi_pagebuffer->len;
+ desc.range.offset = multi_pagebuffer->offset;
- memcpy(desc.range.PfnArray, multi_pagebuffer->PfnArray,
+ memcpy(desc.range.pfn_array, multi_pagebuffer->pfn_array,
pfncount * sizeof(u64));
sg_init_table(bufferlist, 3);
@@ -934,14 +934,14 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
/* VmbusChannelClearEvent(Channel); */
- packetlen = desc.Length8 << 3;
- userlen = packetlen - (desc.DataOffset8 << 3);
+ packetlen = desc.len8 << 3;
+ userlen = packetlen - (desc.offset8 << 3);
/* ASSERT(userLen > 0); */
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- channel, channel->offermsg.child_relid, desc.Type,
- desc.Flags, desc.TransactionId, packetlen, userlen);
+ channel, channel->offermsg.child_relid, desc.type,
+ desc.flags, desc.trans_id, packetlen, userlen);
*buffer_actual_len = userlen;
@@ -953,11 +953,11 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
return -1;
}
- *requestid = desc.TransactionId;
+ *requestid = desc.trans_id;
/* Copy over the packet to the user buffer */
ret = ringbuffer_read(&channel->inbound, buffer, userlen,
- (desc.DataOffset8 << 3));
+ (desc.offset8 << 3));
spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -994,13 +994,13 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
/* VmbusChannelClearEvent(Channel); */
- packetlen = desc.Length8 << 3;
- userlen = packetlen - (desc.DataOffset8 << 3);
+ packetlen = desc.len8 << 3;
+ userlen = packetlen - (desc.offset8 << 3);
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- channel, channel->offermsg.child_relid, desc.Type,
- desc.Flags, desc.TransactionId, packetlen, userlen);
+ channel, channel->offermsg.child_relid, desc.type,
+ desc.flags, desc.trans_id, packetlen, userlen);
*buffer_actual_len = packetlen;
@@ -1012,7 +1012,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
return -2;
}
- *requestid = desc.TransactionId;
+ *requestid = desc.trans_id;
/* Copy over the entire packet to the user buffer */
ret = ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index d44d5c39f68b..a9c9d49a99bb 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
+ }
+ },
+
};
@@ -185,7 +194,7 @@ void chn_cb_negotiate(void *context)
vmbus_sendpacket(channel, buf,
recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
+ VM_PKT_DATA_INBAND, 0);
}
kfree(buf);
@@ -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);
@@ -289,7 +308,7 @@ void free_channel(struct vmbus_channel *channel)
* ie we can't destroy ourselves.
*/
INIT_WORK(&channel->work, release_channel);
- queue_work(gVmbusConnection.WorkQueue, &channel->work);
+ queue_work(vmbus_connection.work_queue, &channel->work);
}
@@ -304,10 +323,10 @@ static void count_hv_channel(void)
static int counter;
unsigned long flags;
- spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
if (++counter == MAX_MSG_TYPES)
complete(&hv_channel_ready);
- spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
}
/*
@@ -342,14 +361,14 @@ static void vmbus_process_offer(struct work_struct *work)
INIT_WORK(&newchannel->work, vmbus_process_rescind_offer);
/* Make sure this is a new offer */
- spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
- list_for_each_entry(channel, &gVmbusConnection.ChannelList, listentry) {
- if (!memcmp(&channel->offermsg.offer.InterfaceType,
- &newchannel->offermsg.offer.InterfaceType,
+ list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
+ if (!memcmp(&channel->offermsg.offer.if_type,
+ &newchannel->offermsg.offer.if_type,
sizeof(struct hv_guid)) &&
- !memcmp(&channel->offermsg.offer.InterfaceInstance,
- &newchannel->offermsg.offer.InterfaceInstance,
+ !memcmp(&channel->offermsg.offer.if_instance,
+ &newchannel->offermsg.offer.if_instance,
sizeof(struct hv_guid))) {
fnew = false;
break;
@@ -358,9 +377,9 @@ static void vmbus_process_offer(struct work_struct *work)
if (fnew)
list_add_tail(&newchannel->listentry,
- &gVmbusConnection.ChannelList);
+ &vmbus_connection.chn_list);
- spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
if (!fnew) {
DPRINT_DBG(VMBUS, "Ignoring duplicate offer for relid (%d)",
@@ -372,11 +391,11 @@ static void vmbus_process_offer(struct work_struct *work)
/*
* Start the process of binding this offer to the driver
* We need to set the DeviceObject field before calling
- * VmbusChildDeviceAdd()
+ * vmbus_child_dev_add()
*/
newchannel->device_obj = vmbus_child_device_create(
- &newchannel->offermsg.offer.InterfaceType,
- &newchannel->offermsg.offer.InterfaceInstance,
+ &newchannel->offermsg.offer.if_type,
+ &newchannel->offermsg.offer.if_instance,
newchannel);
DPRINT_DBG(VMBUS, "child device object allocated - %p",
@@ -387,15 +406,15 @@ static void vmbus_process_offer(struct work_struct *work)
* binding which eventually invokes the device driver's AddDevice()
* method.
*/
- ret = VmbusChildDeviceAdd(newchannel->device_obj);
+ ret = vmbus_child_dev_add(newchannel->device_obj);
if (ret != 0) {
DPRINT_ERR(VMBUS,
"unable to add child device object (relid %d)",
newchannel->offermsg.child_relid);
- spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
list_del(&newchannel->listentry);
- spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
free_channel(newchannel);
} else {
@@ -408,7 +427,7 @@ static void vmbus_process_offer(struct work_struct *work)
/* Open IC channels */
for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
- if (memcmp(&newchannel->offermsg.offer.InterfaceType,
+ if (memcmp(&newchannel->offermsg.offer.if_type,
&hv_cb_utils[cnt].data,
sizeof(struct hv_guid)) == 0 &&
vmbus_open(newchannel, 2 * PAGE_SIZE,
@@ -442,7 +461,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
offer = (struct vmbus_channel_offer_channel *)hdr;
for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) {
- if (memcmp(&offer->offer.InterfaceType,
+ if (memcmp(&offer->offer.if_type,
&gSupportedDeviceClasses[i], sizeof(struct hv_guid)) == 0) {
fsupported = 1;
break;
@@ -455,8 +474,8 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
return;
}
- guidtype = &offer->offer.InterfaceType;
- guidinstance = &offer->offer.InterfaceInstance;
+ guidtype = &offer->offer.if_type;
+ guidinstance = &offer->offer.if_instance;
DPRINT_INFO(VMBUS, "Channel offer notification - "
"child relid %d monitor id %d allocated %d, "
@@ -513,7 +532,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
struct vmbus_channel *channel;
rescind = (struct vmbus_channel_rescind_offer *)hdr;
- channel = GetChannelFromRelId(rescind->child_relid);
+ channel = relid2channel(rescind->child_relid);
if (channel == NULL) {
DPRINT_DBG(VMBUS, "channel not found for relId %d",
rescind->child_relid);
@@ -558,9 +577,9 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
/*
* Find the open msg, copy the result and signal/unblock the wait event
*/
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
- list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
+ list_for_each(curr, &vmbus_connection.chn_msg_list) {
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
@@ -579,7 +598,7 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
}
}
}
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
}
/*
@@ -606,9 +625,9 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
* Find the establish msg, copy the result and signal/unblock the wait
* event
*/
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
- list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
+ list_for_each(curr, &vmbus_connection.chn_msg_list) {
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
@@ -629,7 +648,7 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
}
}
}
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
}
/*
@@ -654,9 +673,9 @@ static void vmbus_ongpadl_torndown(
/*
* Find the open msg, copy the result and signal/unblock the wait event
*/
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
- list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
+ list_for_each(curr, &vmbus_connection.chn_msg_list) {
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
@@ -675,7 +694,7 @@ static void vmbus_ongpadl_torndown(
}
}
}
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
}
/*
@@ -696,9 +715,9 @@ static void vmbus_onversion_response(
unsigned long flags;
version_response = (struct vmbus_channel_version_response *)hdr;
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
- list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
+ list_for_each(curr, &vmbus_connection.chn_msg_list) {
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
@@ -714,7 +733,7 @@ static void vmbus_onversion_response(
osd_waitevent_set(msginfo->waitevent);
}
}
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
}
/* Channel message dispatch table */
@@ -801,7 +820,7 @@ int vmbus_request_offers(void)
&msgInfo->msgListEntry);
SpinlockRelease(gVmbusConnection.channelMsgLock);*/
- ret = VmbusPostMessage(msg,
+ ret = vmbus_post_msg(msg,
sizeof(struct vmbus_channel_message_header));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to request offers - %d", ret);
@@ -838,14 +857,14 @@ void vmbus_release_unattached_channels(void)
struct vmbus_channel *start = NULL;
unsigned long flags;
- spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
+ spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
- list_for_each_entry_safe(channel, pos, &gVmbusConnection.ChannelList,
+ list_for_each_entry_safe(channel, pos, &vmbus_connection.chn_list,
listentry) {
if (channel == start)
break;
- if (!channel->device_obj->Driver) {
+ if (!channel->device_obj->drv) {
list_del(&channel->listentry);
DPRINT_INFO(VMBUS,
"Releasing unattached device object %p",
@@ -859,7 +878,7 @@ void vmbus_release_unattached_channels(void)
}
}
- spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
}
/* eof */
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index c2e298ff4834..b3ac66e5499f 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -29,119 +29,119 @@
#include "vmbus_private.h"
-struct VMBUS_CONNECTION gVmbusConnection = {
- .ConnectState = Disconnected,
- .NextGpadlHandle = ATOMIC_INIT(0xE1E10),
+struct vmbus_connection vmbus_connection = {
+ .conn_state = DISCONNECTED,
+ .next_gpadl_handle = ATOMIC_INIT(0xE1E10),
};
/*
- * VmbusConnect - Sends a connect request on the partition service connection
+ * vmbus_connect - Sends a connect request on the partition service connection
*/
-int VmbusConnect(void)
+int vmbus_connect(void)
{
int ret = 0;
- struct vmbus_channel_msginfo *msgInfo = NULL;
+ struct vmbus_channel_msginfo *msginfo = NULL;
struct vmbus_channel_initiate_contact *msg;
unsigned long flags;
/* Make sure we are not connecting or connected */
- if (gVmbusConnection.ConnectState != Disconnected)
+ if (vmbus_connection.conn_state != DISCONNECTED)
return -1;
/* Initialize the vmbus connection */
- gVmbusConnection.ConnectState = Connecting;
- gVmbusConnection.WorkQueue = create_workqueue("hv_vmbus_con");
- if (!gVmbusConnection.WorkQueue) {
+ vmbus_connection.conn_state = CONNECTING;
+ vmbus_connection.work_queue = create_workqueue("hv_vmbus_con");
+ if (!vmbus_connection.work_queue) {
ret = -1;
goto Cleanup;
}
- INIT_LIST_HEAD(&gVmbusConnection.ChannelMsgList);
- spin_lock_init(&gVmbusConnection.channelmsg_lock);
+ INIT_LIST_HEAD(&vmbus_connection.chn_msg_list);
+ spin_lock_init(&vmbus_connection.channelmsg_lock);
- INIT_LIST_HEAD(&gVmbusConnection.ChannelList);
- spin_lock_init(&gVmbusConnection.channel_lock);
+ INIT_LIST_HEAD(&vmbus_connection.chn_list);
+ spin_lock_init(&vmbus_connection.channel_lock);
/*
* Setup the vmbus event connection for channel interrupt
* abstraction stuff
*/
- gVmbusConnection.InterruptPage = osd_page_alloc(1);
- if (gVmbusConnection.InterruptPage == NULL) {
+ vmbus_connection.int_page = osd_page_alloc(1);
+ if (vmbus_connection.int_page == NULL) {
ret = -1;
goto Cleanup;
}
- gVmbusConnection.RecvInterruptPage = gVmbusConnection.InterruptPage;
- gVmbusConnection.SendInterruptPage =
- (void *)((unsigned long)gVmbusConnection.InterruptPage +
+ vmbus_connection.recv_int_page = vmbus_connection.int_page;
+ vmbus_connection.send_int_page =
+ (void *)((unsigned long)vmbus_connection.int_page +
(PAGE_SIZE >> 1));
/*
* Setup the monitor notification facility. The 1st page for
* parent->child and the 2nd page for child->parent
*/
- gVmbusConnection.MonitorPages = osd_page_alloc(2);
- if (gVmbusConnection.MonitorPages == NULL) {
+ vmbus_connection.monitor_pages = osd_page_alloc(2);
+ if (vmbus_connection.monitor_pages == NULL) {
ret = -1;
goto Cleanup;
}
- msgInfo = kzalloc(sizeof(*msgInfo) +
+ msginfo = kzalloc(sizeof(*msginfo) +
sizeof(struct vmbus_channel_initiate_contact),
GFP_KERNEL);
- if (msgInfo == NULL) {
+ if (msginfo == NULL) {
ret = -ENOMEM;
goto Cleanup;
}
- msgInfo->waitevent = osd_waitevent_create();
- if (!msgInfo->waitevent) {
+ msginfo->waitevent = osd_waitevent_create();
+ if (!msginfo->waitevent) {
ret = -ENOMEM;
goto Cleanup;
}
- msg = (struct vmbus_channel_initiate_contact *)msgInfo->msg;
+ msg = (struct vmbus_channel_initiate_contact *)msginfo->msg;
msg->header.msgtype = CHANNELMSG_INITIATE_CONTACT;
msg->vmbus_version_requested = VMBUS_REVISION_NUMBER;
- msg->interrupt_page = virt_to_phys(gVmbusConnection.InterruptPage);
- msg->monitor_page1 = virt_to_phys(gVmbusConnection.MonitorPages);
+ msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
+ msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages);
msg->monitor_page2 = virt_to_phys(
- (void *)((unsigned long)gVmbusConnection.MonitorPages +
+ (void *)((unsigned long)vmbus_connection.monitor_pages +
PAGE_SIZE));
/*
* Add to list before we send the request since we may
* receive the response before returning from this routine
*/
- spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&msgInfo->msglistentry,
- &gVmbusConnection.ChannelMsgList);
+ spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
+ list_add_tail(&msginfo->msglistentry,
+ &vmbus_connection.chn_msg_list);
- spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, "
"monitor1 pfn %llx,, monitor2 pfn %llx",
msg->interrupt_page, msg->monitor_page1, msg->monitor_page2);
DPRINT_DBG(VMBUS, "Sending channel initiate msg...");
- ret = VmbusPostMessage(msg,
+ ret = vmbus_post_msg(msg,
sizeof(struct vmbus_channel_initiate_contact));
if (ret != 0) {
- list_del(&msgInfo->msglistentry);
+ list_del(&msginfo->msglistentry);
goto Cleanup;
}
/* Wait for the connection response */
- osd_waitevent_wait(msgInfo->waitevent);
+ osd_waitevent_wait(msginfo->waitevent);
- list_del(&msgInfo->msglistentry);
+ list_del(&msginfo->msglistentry);
/* Check if successful */
- if (msgInfo->response.version_response.version_supported) {
+ if (msginfo->response.version_response.version_supported) {
DPRINT_INFO(VMBUS, "Vmbus connected!!");
- gVmbusConnection.ConnectState = Connected;
+ vmbus_connection.conn_state = CONNECTED;
} else {
DPRINT_ERR(VMBUS, "Vmbus connection failed!!..."
@@ -151,44 +151,45 @@ int VmbusConnect(void)
goto Cleanup;
}
- kfree(msgInfo->waitevent);
- kfree(msgInfo);
+ kfree(msginfo->waitevent);
+ kfree(msginfo);
return 0;
Cleanup:
- gVmbusConnection.ConnectState = Disconnected;
+ vmbus_connection.conn_state = DISCONNECTED;
- if (gVmbusConnection.WorkQueue)
- destroy_workqueue(gVmbusConnection.WorkQueue);
+ if (vmbus_connection.work_queue)
+ destroy_workqueue(vmbus_connection.work_queue);
- if (gVmbusConnection.InterruptPage) {
- osd_page_free(gVmbusConnection.InterruptPage, 1);
- gVmbusConnection.InterruptPage = NULL;
+ if (vmbus_connection.int_page) {
+ osd_page_free(vmbus_connection.int_page, 1);
+ vmbus_connection.int_page = NULL;
}
- if (gVmbusConnection.MonitorPages) {
- osd_page_free(gVmbusConnection.MonitorPages, 2);
- gVmbusConnection.MonitorPages = NULL;
+ if (vmbus_connection.monitor_pages) {
+ osd_page_free(vmbus_connection.monitor_pages, 2);
+ vmbus_connection.monitor_pages = NULL;
}
- if (msgInfo) {
- kfree(msgInfo->waitevent);
- kfree(msgInfo);
+ if (msginfo) {
+ kfree(msginfo->waitevent);
+ kfree(msginfo);
}
return ret;
}
/*
- * VmbusDisconnect - Sends a disconnect request on the partition service connection
+ * vmbus_disconnect -
+ * Sends a disconnect request on the partition service connection
*/
-int VmbusDisconnect(void)
+int vmbus_disconnect(void)
{
int ret = 0;
struct vmbus_channel_message_header *msg;
/* Make sure we are connected */
- if (gVmbusConnection.ConnectState != Connected)
+ if (vmbus_connection.conn_state != CONNECTED)
return -1;
msg = kzalloc(sizeof(struct vmbus_channel_message_header), GFP_KERNEL);
@@ -197,17 +198,17 @@ int VmbusDisconnect(void)
msg->msgtype = CHANNELMSG_UNLOAD;
- ret = VmbusPostMessage(msg,
+ ret = vmbus_post_msg(msg,
sizeof(struct vmbus_channel_message_header));
if (ret != 0)
goto Cleanup;
- osd_page_free(gVmbusConnection.InterruptPage, 1);
+ osd_page_free(vmbus_connection.int_page, 1);
/* TODO: iterate thru the msg list and free up */
- destroy_workqueue(gVmbusConnection.WorkQueue);
+ destroy_workqueue(vmbus_connection.work_queue);
- gVmbusConnection.ConnectState = Disconnected;
+ vmbus_connection.conn_state = DISCONNECTED;
DPRINT_INFO(VMBUS, "Vmbus disconnected!!");
@@ -217,33 +218,34 @@ Cleanup:
}
/*
- * GetChannelFromRelId - Get the channel object given its child relative id (ie channel id)
+ * relid2channel - Get the channel object given its
+ * child relative id (ie channel id)
*/
-struct vmbus_channel *GetChannelFromRelId(u32 relId)
+struct vmbus_channel *relid2channel(u32 relid)
{
struct vmbus_channel *channel;
- struct vmbus_channel *foundChannel = NULL;
+ struct vmbus_channel *found_channel = NULL;
unsigned long flags;
- spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_for_each_entry(channel, &gVmbusConnection.ChannelList, listentry) {
- if (channel->offermsg.child_relid == relId) {
- foundChannel = channel;
+ spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
+ list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
+ if (channel->offermsg.child_relid == relid) {
+ found_channel = channel;
break;
}
}
- spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
+ spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
- return foundChannel;
+ return found_channel;
}
/*
- * VmbusProcessChannelEvent - Process a channel event notification
+ * process_chn_event - Process a channel event notification
*/
-static void VmbusProcessChannelEvent(void *context)
+static void process_chn_event(void *context)
{
struct vmbus_channel *channel;
- u32 relId = (u32)(unsigned long)context;
+ u32 relid = (u32)(unsigned long)context;
/* ASSERT(relId > 0); */
@@ -251,7 +253,7 @@ static void VmbusProcessChannelEvent(void *context)
* Find the channel based on this relid and invokes the
* channel callback to process the event
*/
- channel = GetChannelFromRelId(relId);
+ channel = relid2channel(relid);
if (channel) {
vmbus_onchannel_event(channel);
@@ -261,27 +263,29 @@ static void VmbusProcessChannelEvent(void *context)
* (void*)channel);
*/
} else {
- DPRINT_ERR(VMBUS, "channel not found for relid - %d.", relId);
+ DPRINT_ERR(VMBUS, "channel not found for relid - %d.", relid);
}
}
/*
- * VmbusOnEvents - Handler for events
+ * vmbus_on_event - Handler for events
*/
-void VmbusOnEvents(void)
+void vmbus_on_event(void)
{
int dword;
int maxdword = MAX_NUM_CHANNELS_SUPPORTED >> 5;
int bit;
int relid;
- u32 *recvInterruptPage = gVmbusConnection.RecvInterruptPage;
+ u32 *recv_int_page = vmbus_connection.recv_int_page;
/* Check events */
- if (recvInterruptPage) {
+ if (recv_int_page) {
for (dword = 0; dword < maxdword; dword++) {
- if (recvInterruptPage[dword]) {
+ if (recv_int_page[dword]) {
for (bit = 0; bit < 32; bit++) {
- if (test_and_clear_bit(bit, (unsigned long *)&recvInterruptPage[dword])) {
+ if (test_and_clear_bit(bit,
+ (unsigned long *)
+ &recv_int_page[dword])) {
relid = (dword << 5) + bit;
DPRINT_DBG(VMBUS, "event detected for relid - %d", relid);
@@ -292,7 +296,8 @@ void VmbusOnEvents(void)
} else {
/* QueueWorkItem(VmbusProcessEvent, (void*)relid); */
/* ret = WorkQueueQueueWorkItem(gVmbusConnection.workQueue, VmbusProcessChannelEvent, (void*)relid); */
- VmbusProcessChannelEvent((void *)(unsigned long)relid);
+ process_chn_event((void *)
+ (unsigned long)relid);
}
}
}
@@ -303,26 +308,26 @@ void VmbusOnEvents(void)
}
/*
- * VmbusPostMessage - Send a msg on the vmbus's message connection
+ * vmbus_post_msg - Send a msg on the vmbus's message connection
*/
-int VmbusPostMessage(void *buffer, size_t bufferLen)
+int vmbus_post_msg(void *buffer, size_t buflen)
{
- union hv_connection_id connId;
+ union hv_connection_id conn_id;
- connId.asu32 = 0;
- connId.u.id = VMBUS_MESSAGE_CONNECTION_ID;
- return hv_post_message(connId, 1, buffer, bufferLen);
+ conn_id.asu32 = 0;
+ conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID;
+ return hv_post_message(conn_id, 1, buffer, buflen);
}
/*
- * VmbusSetEvent - Send an event notification to the parent
+ * vmbus_set_event - Send an event notification to the parent
*/
-int VmbusSetEvent(u32 childRelId)
+int vmbus_set_event(u32 child_relid)
{
/* Each u32 represents 32 channels */
- set_bit(childRelId & 31,
- (unsigned long *)gVmbusConnection.SendInterruptPage +
- (childRelId >> 5));
+ set_bit(child_relid & 31,
+ (unsigned long *)vmbus_connection.send_int_page +
+ (child_relid >> 5));
return hv_signal_event();
}
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index a34d713d9c57..021acbaae247 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -267,7 +267,7 @@ int hv_init(void)
hv_context.signal_event_param =
(struct hv_input_signal_event *)
- (ALIGN_UP((unsigned long)
+ (ALIGN((unsigned long)
hv_context.signal_event_buffer,
HV_HYPERCALL_PARAM_ALIGN));
hv_context.signal_event_param->connectionid.asu32 = 0;
@@ -338,7 +338,7 @@ u16 hv_post_message(union hv_connection_id connection_id,
return -1;
aligned_msg = (struct hv_input_post_message *)
- (ALIGN_UP(addr, HV_HYPERCALL_PARAM_ALIGN));
+ (ALIGN(addr, HV_HYPERCALL_PARAM_ALIGN));
aligned_msg->connectionid = connection_id;
aligned_msg->message_type = message_type;
diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c
new file mode 100644
index 000000000000..bc1c20e8d611
--- /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.
+ *
+ * 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 */
+ 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;
+static u8 *recv_buffer;
+/*
+ * 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;
+ 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_len = kvp_transaction.recv_len;
+ channel = kvp_transaction.recv_channel;
+ req_id = kvp_transaction.recv_req_id;
+
+ icmsghdrp = (struct icmsg_hdr *)
+ &recv_buffer[sizeof(struct vmbuspipe_hdr)];
+ kvp_msg = (struct hv_kvp_msg *)
+ &recv_buffer[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, recv_buffer, buf_len, req_id,
+ VM_PKT_DATA_INBAND, 0);
+
+ kvp_transaction.active = false;
+}
+
+/*
+ * 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;
+ u32 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;
+
+
+ if (kvp_transaction.active)
+ return;
+
+
+ vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "KVP packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&recv_buffer[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, negop, recv_buffer);
+ } else {
+ kvp_msg = (struct hv_kvp_msg *)&recv_buffer[
+ 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)) {
+ icmsghdrp->status = HV_E_FAIL;
+ goto callback_done;
+ }
+
+ /*
+ * Stash away this global state for completing the
+ * transaction; note transactions are serialized.
+ */
+ 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, recv_buffer,
+ recvlen, requestid,
+ VM_PKT_DATA_INBAND, 0);
+ }
+
+}
+
+int
+hv_kvp_init(void)
+{
+ int err;
+
+ err = cn_add_callback(&kvp_id, kvp_name, kvp_cn_callback);
+ if (err)
+ return err;
+ recv_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!recv_buffer)
+ return -ENOMEM;
+
+ return 0;
+}
+
+void hv_kvp_deinit(void)
+{
+ cn_del_callback(&kvp_id);
+ cancel_delayed_work_sync(&kvp_work);
+ kfree(recv_buffer);
+}
diff --git a/drivers/staging/hv/hv_kvp.h b/drivers/staging/hv/hv_kvp.h
new file mode 100644
index 000000000000..e069f59b5135
--- /dev/null
+++ b/drivers/staging/hv/hv_kvp.h
@@ -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 */
+
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_util.c
index 0074581f20e8..43c7ec0e9adb 100644
--- a/drivers/staging/hv/hv_utils.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 u8 *shut_txf_buf;
static u8 *time_txf_buf;
@@ -96,7 +97,7 @@ static void shutdown_onchannelcallback(void *context)
vmbus_sendpacket(channel, shut_txf_buf,
recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
+ VM_PKT_DATA_INBAND, 0);
}
if (execute_shutdown == true)
@@ -178,7 +179,7 @@ static void timesync_onchannelcallback(void *context)
vmbus_sendpacket(channel, time_txf_buf,
recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
+ VM_PKT_DATA_INBAND, 0);
}
}
@@ -224,7 +225,7 @@ static void heartbeat_onchannelcallback(void *context)
vmbus_sendpacket(channel, hbeat_txf_buf,
recvlen, requestid,
- VmbusPacketTypeDataInBand, 0);
+ VM_PKT_DATA_INBAND, 0);
}
}
@@ -255,6 +256,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;
@@ -283,6 +288,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;
}
@@ -302,6 +312,10 @@ static void exit_hyperv_utils(void)
&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();
+
kfree(shut_txf_buf);
kfree(time_txf_buf);
kfree(hbeat_txf_buf);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 0edbe7483a4c..431936338731 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -86,7 +86,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
atomic_cmpxchg(&net_device->refcnt, 0, 2);
net_device->dev = device;
- device->Extension = net_device;
+ device->ext = net_device;
return net_device;
}
@@ -94,7 +94,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
static void free_net_device(struct netvsc_device *device)
{
WARN_ON(atomic_read(&device->refcnt) == 0);
- device->dev->Extension = NULL;
+ device->dev->ext = NULL;
kfree(device);
}
@@ -104,7 +104,7 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
{
struct netvsc_device *net_device;
- net_device = device->Extension;
+ net_device = device->ext;
if (net_device && atomic_read(&net_device->refcnt) > 1)
atomic_inc(&net_device->refcnt);
else
@@ -118,7 +118,7 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
{
struct netvsc_device *net_device;
- net_device = device->Extension;
+ net_device = device->ext;
if (net_device && atomic_read(&net_device->refcnt))
atomic_inc(&net_device->refcnt);
else
@@ -131,7 +131,7 @@ static void put_net_device(struct hv_device *device)
{
struct netvsc_device *net_device;
- net_device = device->Extension;
+ net_device = device->ext;
/* ASSERT(netDevice); */
atomic_dec(&net_device->refcnt);
@@ -142,7 +142,7 @@ static struct netvsc_device *release_outbound_net_device(
{
struct netvsc_device *net_device;
- net_device = device->Extension;
+ net_device = device->ext;
if (net_device == NULL)
return NULL;
@@ -158,7 +158,7 @@ static struct netvsc_device *release_inbound_net_device(
{
struct netvsc_device *net_device;
- net_device = device->Extension;
+ net_device = device->ext;
if (net_device == NULL)
return NULL;
@@ -166,7 +166,7 @@ static struct netvsc_device *release_inbound_net_device(
while (atomic_cmpxchg(&net_device->refcnt, 1, 0) != 1)
udelay(100);
- device->Extension = NULL;
+ device->ext = NULL;
return net_device;
}
@@ -188,7 +188,7 @@ int netvsc_initialize(struct hv_driver *drv)
/* ASSERT(driver->RingBufferSize >= (PAGE_SIZE << 1)); */
drv->name = driver_name;
- memcpy(&drv->deviceType, &netvsc_device_type, sizeof(struct hv_guid));
+ memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
/* Make sure it is set by the caller */
/* FIXME: These probably should still be tested in some way */
@@ -196,9 +196,9 @@ int netvsc_initialize(struct hv_driver *drv)
/* ASSERT(driver->OnLinkStatusChanged); */
/* Setup the dispatch table */
- driver->base.OnDeviceAdd = netvsc_device_add;
- driver->base.OnDeviceRemove = netvsc_device_remove;
- driver->base.OnCleanup = netvsc_cleanup;
+ driver->base.dev_add = netvsc_device_add;
+ driver->base.dev_rm = netvsc_device_remove;
+ driver->base.cleanup = netvsc_cleanup;
driver->send = netvsc_send;
@@ -270,7 +270,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, init_packet,
sizeof(struct nvsp_message),
(unsigned long)init_packet,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(NETVSC,
@@ -404,7 +404,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, init_packet,
sizeof(struct nvsp_message),
(unsigned long)init_packet,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(NETVSC,
@@ -466,7 +466,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
revoke_packet,
sizeof(struct nvsp_message),
(unsigned long)revoke_packet,
- VmbusPacketTypeDataInBand, 0);
+ VM_PKT_DATA_INBAND, 0);
/*
* If we failed here, we might as well return and
* have a leak rather than continue and a bugchk
@@ -540,7 +540,7 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
revoke_packet,
sizeof(struct nvsp_message),
(unsigned long)revoke_packet,
- VmbusPacketTypeDataInBand, 0);
+ VM_PKT_DATA_INBAND, 0);
/*
* If we failed here, we might as well return and have a leak
* rather than continue and a bugchk
@@ -612,7 +612,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, init_packet,
sizeof(struct nvsp_message),
(unsigned long)init_packet,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
@@ -666,7 +666,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, init_packet,
sizeof(struct nvsp_message),
(unsigned long)init_packet,
- VmbusPacketTypeDataInBand, 0);
+ VM_PKT_DATA_INBAND, 0);
if (ret != 0) {
DPRINT_ERR(NETVSC,
"unable to send NvspMessage1TypeSendNdisVersion");
@@ -708,7 +708,7 @@ static int netvsc_device_add(struct hv_device *device, void *additional_info)
struct netvsc_device *net_device;
struct hv_netvsc_packet *packet, *pos;
struct netvsc_driver *net_driver =
- (struct netvsc_driver *)device->Driver;
+ (struct netvsc_driver *)device->drv;
net_device = alloc_net_device(device);
if (!net_device) {
@@ -806,7 +806,7 @@ static int netvsc_device_remove(struct hv_device *device)
struct hv_netvsc_packet *netvsc_packet, *pos;
DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...",
- device->Extension);
+ device->ext);
/* Stop outbound traffic ie sends and receives completions */
net_device = release_outbound_net_device(device);
@@ -827,7 +827,7 @@ static int netvsc_device_remove(struct hv_device *device)
NetVscDisconnectFromVsp(net_device);
DPRINT_INFO(NETVSC, "Disabling inbound traffic on net device (%p)...",
- device->Extension);
+ device->ext);
/* Stop inbound traffic ie receives and sends completions */
net_device = release_inbound_net_device(device);
@@ -872,7 +872,7 @@ static void netvsc_send_completion(struct hv_device *device,
}
nvsp_packet = (struct nvsp_message *)((unsigned long)packet +
- (packet->DataOffset8 << 3));
+ (packet->offset8 << 3));
DPRINT_DBG(NETVSC, "send completion packet - type %d",
nvsp_packet->hdr.msg_type);
@@ -890,7 +890,7 @@ static void netvsc_send_completion(struct hv_device *device,
NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE) {
/* Get the send context */
nvsc_packet = (struct hv_netvsc_packet *)(unsigned long)
- packet->TransactionId;
+ packet->trans_id;
/* ASSERT(nvscPacket); */
/* Notify the layer above us */
@@ -946,7 +946,7 @@ static int netvsc_send(struct hv_device *device,
ret = vmbus_sendpacket(device->channel, &sendMessage,
sizeof(struct nvsp_message),
(unsigned long)packet,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
}
@@ -987,15 +987,15 @@ static void netvsc_receive(struct hv_device *device,
* All inbound packets other than send completion should be xfer page
* packet
*/
- if (packet->Type != VmbusPacketTypeDataUsingTransferPages) {
+ if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) {
DPRINT_ERR(NETVSC, "Unknown packet type received - %d",
- packet->Type);
+ packet->type);
put_net_device(device);
return;
}
nvsp_packet = (struct nvsp_message *)((unsigned long)packet +
- (packet->DataOffset8 << 3));
+ (packet->offset8 << 3));
/* Make sure this is a valid nvsp packet */
if (nvsp_packet->hdr.msg_type !=
@@ -1011,16 +1011,16 @@ static void netvsc_receive(struct hv_device *device,
vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;
- if (vmxferpage_packet->TransferPageSetId != NETVSC_RECEIVE_BUFFER_ID) {
+ if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) {
DPRINT_ERR(NETVSC, "Invalid xfer page set id - "
"expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID,
- vmxferpage_packet->TransferPageSetId);
+ vmxferpage_packet->xfer_pageset_id);
put_net_device(device);
return;
}
DPRINT_DBG(NETVSC, "xfer page - range count %d",
- vmxferpage_packet->RangeCount);
+ vmxferpage_packet->range_cnt);
/*
* Grab free packets (range count + 1) to represent this xfer
@@ -1031,7 +1031,7 @@ static void netvsc_receive(struct hv_device *device,
spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
while (!list_empty(&net_device->recv_pkt_list)) {
list_move_tail(net_device->recv_pkt_list.next, &listHead);
- if (++count == vmxferpage_packet->RangeCount + 1)
+ if (++count == vmxferpage_packet->range_cnt + 1)
break;
}
spin_unlock_irqrestore(&net_device->recv_pkt_list_lock, flags);
@@ -1044,7 +1044,7 @@ static void netvsc_receive(struct hv_device *device,
if (count < 2) {
DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. "
"Dropping this xfer page packet completely!",
- count, vmxferpage_packet->RangeCount + 1);
+ count, vmxferpage_packet->range_cnt + 1);
/* Return it to the freelist */
spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
@@ -1056,7 +1056,7 @@ static void netvsc_receive(struct hv_device *device,
flags);
netvsc_send_recv_completion(device,
- vmxferpage_packet->d.TransactionId);
+ vmxferpage_packet->d.trans_id);
put_net_device(device);
return;
@@ -1071,9 +1071,9 @@ static void netvsc_receive(struct hv_device *device,
/* ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <= */
/* vmxferpagePacket->RangeCount); */
- if (xferpage_packet->count != vmxferpage_packet->RangeCount) {
+ if (xferpage_packet->count != vmxferpage_packet->range_cnt) {
DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer "
- "page...got %d", vmxferpage_packet->RangeCount,
+ "page...got %d", vmxferpage_packet->range_cnt,
xferpage_packet->count);
}
@@ -1091,52 +1091,52 @@ static void netvsc_receive(struct hv_device *device,
netvsc_packet->device = device;
/* Save this so that we can send it back */
netvsc_packet->completion.recv.recv_completion_tid =
- vmxferpage_packet->d.TransactionId;
+ vmxferpage_packet->d.trans_id;
netvsc_packet->total_data_buflen =
- vmxferpage_packet->Ranges[i].ByteCount;
+ vmxferpage_packet->ranges[i].byte_count;
netvsc_packet->page_buf_cnt = 1;
/* ASSERT(vmxferpagePacket->Ranges[i].ByteOffset + */
/* vmxferpagePacket->Ranges[i].ByteCount < */
/* netDevice->ReceiveBufferSize); */
- netvsc_packet->page_buf[0].Length =
- vmxferpage_packet->Ranges[i].ByteCount;
+ netvsc_packet->page_buf[0].len =
+ vmxferpage_packet->ranges[i].byte_count;
start = virt_to_phys((void *)((unsigned long)net_device->
- recv_buf + vmxferpage_packet->Ranges[i].ByteOffset));
+ recv_buf + vmxferpage_packet->ranges[i].byte_offset));
- netvsc_packet->page_buf[0].Pfn = start >> PAGE_SHIFT;
+ netvsc_packet->page_buf[0].pfn = start >> PAGE_SHIFT;
end_virtual = (unsigned long)net_device->recv_buf
- + vmxferpage_packet->Ranges[i].ByteOffset
- + vmxferpage_packet->Ranges[i].ByteCount - 1;
+ + vmxferpage_packet->ranges[i].byte_offset
+ + vmxferpage_packet->ranges[i].byte_count - 1;
end = virt_to_phys((void *)end_virtual);
/* Calculate the page relative offset */
- netvsc_packet->page_buf[0].Offset =
- vmxferpage_packet->Ranges[i].ByteOffset &
+ netvsc_packet->page_buf[0].offset =
+ vmxferpage_packet->ranges[i].byte_offset &
(PAGE_SIZE - 1);
if ((end >> PAGE_SHIFT) != (start >> PAGE_SHIFT)) {
/* Handle frame across multiple pages: */
- netvsc_packet->page_buf[0].Length =
- (netvsc_packet->page_buf[0].Pfn <<
+ netvsc_packet->page_buf[0].len =
+ (netvsc_packet->page_buf[0].pfn <<
PAGE_SHIFT)
+ PAGE_SIZE - start;
bytes_remain = netvsc_packet->total_data_buflen -
- netvsc_packet->page_buf[0].Length;
+ netvsc_packet->page_buf[0].len;
for (j = 1; j < NETVSC_PACKET_MAXPAGE; j++) {
- netvsc_packet->page_buf[j].Offset = 0;
+ netvsc_packet->page_buf[j].offset = 0;
if (bytes_remain <= PAGE_SIZE) {
- netvsc_packet->page_buf[j].Length =
+ netvsc_packet->page_buf[j].len =
bytes_remain;
bytes_remain = 0;
} else {
- netvsc_packet->page_buf[j].Length =
+ netvsc_packet->page_buf[j].len =
PAGE_SIZE;
bytes_remain -= PAGE_SIZE;
}
- netvsc_packet->page_buf[j].Pfn =
+ netvsc_packet->page_buf[j].pfn =
virt_to_phys((void *)(end_virtual -
bytes_remain)) >> PAGE_SHIFT;
netvsc_packet->page_buf_cnt++;
@@ -1147,14 +1147,14 @@ static void netvsc_receive(struct hv_device *device,
}
DPRINT_DBG(NETVSC, "[%d] - (abs offset %u len %u) => "
"(pfn %llx, offset %u, len %u)", i,
- vmxferpage_packet->Ranges[i].ByteOffset,
- vmxferpage_packet->Ranges[i].ByteCount,
- netvsc_packet->page_buf[0].Pfn,
- netvsc_packet->page_buf[0].Offset,
- netvsc_packet->page_buf[0].Length);
+ vmxferpage_packet->ranges[i].byte_offset,
+ vmxferpage_packet->ranges[i].byte_count,
+ netvsc_packet->page_buf[0].pfn,
+ netvsc_packet->page_buf[0].offset,
+ netvsc_packet->page_buf[0].len);
/* Pass it to the upper layer */
- ((struct netvsc_driver *)device->Driver)->
+ ((struct netvsc_driver *)device->drv)->
recv_cb(device, netvsc_packet);
netvsc_receive_completion(netvsc_packet->
@@ -1187,7 +1187,7 @@ retry_send_cmplt:
/* Send the completion */
ret = vmbus_sendpacket(device->channel, &recvcompMessage,
sizeof(struct nvsp_message), transaction_id,
- VmbusPacketTypeCompletion, 0);
+ VM_PKT_COMP, 0);
if (ret == 0) {
/* success */
/* no-op */
@@ -1300,12 +1300,12 @@ static void netvsc_channel_cb(void *context)
bytes_recvd, request_id);
desc = (struct vmpacket_descriptor *)buffer;
- switch (desc->Type) {
- case VmbusPacketTypeCompletion:
+ switch (desc->type) {
+ case VM_PKT_COMP:
netvsc_send_completion(device, desc);
break;
- case VmbusPacketTypeDataUsingTransferPages:
+ case VM_PKT_DATA_USING_XFER_PAGES:
netvsc_receive(device, desc);
break;
@@ -1313,7 +1313,7 @@ static void netvsc_channel_cb(void *context)
DPRINT_ERR(NETVSC,
"unhandled packet type %d, "
"tid %llx len %d\n",
- desc->Type, request_id,
+ desc->type, request_id,
bytes_recvd);
break;
}
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 54706a16dc0a..95fa810255ed 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -178,18 +178,18 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
packet->total_data_buflen = skb->len;
/* Start filling in the page buffers starting after RNDIS buffer. */
- packet->page_buf[1].Pfn = virt_to_phys(skb->data) >> PAGE_SHIFT;
- packet->page_buf[1].Offset
+ packet->page_buf[1].pfn = virt_to_phys(skb->data) >> PAGE_SHIFT;
+ packet->page_buf[1].offset
= (unsigned long)skb->data & (PAGE_SIZE - 1);
- packet->page_buf[1].Length = skb_headlen(skb);
+ packet->page_buf[1].len = skb_headlen(skb);
/* Additional fragments are after SKB data */
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *f = &skb_shinfo(skb)->frags[i];
- packet->page_buf[i+2].Pfn = page_to_pfn(f->page);
- packet->page_buf[i+2].Offset = f->page_offset;
- packet->page_buf[i+2].Length = f->size;
+ packet->page_buf[i+2].pfn = page_to_pfn(f->page);
+ packet->page_buf[i+2].offset = f->page_offset;
+ packet->page_buf[i+2].len = f->size;
}
/* Set the completion routine */
@@ -277,16 +277,16 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
* hv_netvsc_packet cannot be deallocated
*/
for (i = 0; i < packet->page_buf_cnt; i++) {
- data = kmap_atomic(pfn_to_page(packet->page_buf[i].Pfn),
+ data = kmap_atomic(pfn_to_page(packet->page_buf[i].pfn),
KM_IRQ1);
data = (void *)(unsigned long)data +
- packet->page_buf[i].Offset;
+ packet->page_buf[i].offset;
- memcpy(skb_put(skb, packet->page_buf[i].Length), data,
- packet->page_buf[i].Length);
+ memcpy(skb_put(skb, packet->page_buf[i].len), data,
+ packet->page_buf[i].len);
kunmap_atomic((void *)((unsigned long)data -
- packet->page_buf[i].Offset), KM_IRQ1);
+ packet->page_buf[i].offset), KM_IRQ1);
}
local_irq_restore(flags);
@@ -349,7 +349,7 @@ static int netvsc_probe(struct device *device)
struct netvsc_device_info device_info;
int ret;
- if (!net_drv_obj->base.OnDeviceAdd)
+ if (!net_drv_obj->base.dev_add)
return -1;
net = alloc_etherdev(sizeof(struct net_device_context));
@@ -365,7 +365,7 @@ static int netvsc_probe(struct device *device)
dev_set_drvdata(device, net);
/* Notify the netvsc driver of the new device */
- ret = net_drv_obj->base.OnDeviceAdd(device_obj, &device_info);
+ ret = net_drv_obj->base.dev_add(device_obj, &device_info);
if (ret != 0) {
free_netdev(net);
dev_set_drvdata(device, NULL);
@@ -400,7 +400,7 @@ static int netvsc_probe(struct device *device)
ret = register_netdev(net);
if (ret != 0) {
/* Remove the device and release the resource */
- net_drv_obj->base.OnDeviceRemove(device_obj);
+ net_drv_obj->base.dev_rm(device_obj);
free_netdev(net);
}
@@ -424,7 +424,7 @@ static int netvsc_remove(struct device *device)
return 0;
}
- if (!net_drv_obj->base.OnDeviceRemove)
+ if (!net_drv_obj->base.dev_rm)
return -1;
/* Stop outbound asap */
@@ -437,7 +437,7 @@ static int netvsc_remove(struct device *device)
* Call to the vsc driver to let it know that the device is being
* removed
*/
- ret = net_drv_obj->base.OnDeviceRemove(device_obj);
+ ret = net_drv_obj->base.dev_rm(device_obj);
if (ret != 0) {
/* TODO: */
DPRINT_ERR(NETVSC, "unable to remove vsc device (ret %d)", ret);
@@ -483,8 +483,8 @@ static void netvsc_drv_exit(void)
device_unregister(current_dev);
}
- if (netvsc_drv_obj->base.OnCleanup)
- netvsc_drv_obj->base.OnCleanup(&netvsc_drv_obj->base);
+ if (netvsc_drv_obj->base.cleanup)
+ netvsc_drv_obj->base.cleanup(&netvsc_drv_obj->base);
vmbus_child_driver_unregister(drv_ctx);
@@ -505,7 +505,7 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
drv_init(&net_drv_obj->base);
drv_ctx->driver.name = net_drv_obj->base.name;
- memcpy(&drv_ctx->class_id, &net_drv_obj->base.deviceType,
+ memcpy(&drv_ctx->class_id, &net_drv_obj->base.dev_type,
sizeof(struct hv_guid));
drv_ctx->probe = netvsc_probe;
diff --git a/drivers/staging/hv/osd.h b/drivers/staging/hv/osd.h
index 870ef0768833..f7871614b983 100644
--- a/drivers/staging/hv/osd.h
+++ b/drivers/staging/hv/osd.h
@@ -25,16 +25,12 @@
#ifndef _OSD_H_
#define _OSD_H_
+#include <linux/kernel.h>
#include <linux/workqueue.h>
/* Defines */
-#define ALIGN_UP(value, align) (((value) & (align-1)) ? \
- (((value) + (align-1)) & ~(align-1)) : \
- (value))
-#define ALIGN_DOWN(value, align) ((value) & ~(align-1))
-#define NUM_PAGES_SPANNED(addr, len) ((ALIGN_UP(addr+len, PAGE_SIZE) - \
- ALIGN_DOWN(addr, PAGE_SIZE)) >> \
- PAGE_SHIFT)
+#define NUM_PAGES_SPANNED(addr, len) ((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - \
+ (addr >> PAGE_SHIFT))
#define LOWORD(dw) ((unsigned short)(dw))
#define HIWORD(dw) ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF))
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 53676dcbf381..287e12eddd89 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -255,10 +255,10 @@ static int rndis_filter_send_request(struct rndis_device *dev,
packet->total_data_buflen = req->request_msg.msg_len;
packet->page_buf_cnt = 1;
- packet->page_buf[0].Pfn = virt_to_phys(&req->request_msg) >>
+ packet->page_buf[0].pfn = virt_to_phys(&req->request_msg) >>
PAGE_SHIFT;
- packet->page_buf[0].Length = req->request_msg.msg_len;
- packet->page_buf[0].Offset =
+ packet->page_buf[0].len = req->request_msg.msg_len;
+ packet->page_buf[0].offset =
(unsigned long)&req->request_msg & (PAGE_SIZE - 1);
packet->completion.send.send_completion_ctx = req;/* packet; */
@@ -371,8 +371,8 @@ static void rndis_filter_receive_data(struct rndis_device *dev,
data_offset = RNDIS_HEADER_SIZE + rndis_pkt->data_offset;
pkt->total_data_buflen -= data_offset;
- pkt->page_buf[0].Offset += data_offset;
- pkt->page_buf[0].Length -= data_offset;
+ pkt->page_buf[0].offset += data_offset;
+ pkt->page_buf[0].len -= data_offset;
pkt->is_data_pkt = true;
@@ -383,7 +383,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev,
static int rndis_filter_receive(struct hv_device *dev,
struct hv_netvsc_packet *pkt)
{
- struct netvsc_device *net_dev = dev->Extension;
+ struct netvsc_device *net_dev = dev->ext;
struct rndis_device *rndis_dev;
struct rndis_message rndis_msg;
struct rndis_message *rndis_hdr;
@@ -406,10 +406,10 @@ static int rndis_filter_receive(struct hv_device *dev,
}
rndis_hdr = (struct rndis_message *)kmap_atomic(
- pfn_to_page(pkt->page_buf[0].Pfn), KM_IRQ0);
+ pfn_to_page(pkt->page_buf[0].pfn), KM_IRQ0);
rndis_hdr = (void *)((unsigned long)rndis_hdr +
- pkt->page_buf[0].Offset);
+ pkt->page_buf[0].offset);
/* Make sure we got a valid rndis message */
/*
@@ -419,7 +419,7 @@ static int rndis_filter_receive(struct hv_device *dev,
* */
#if 0
if (pkt->total_data_buflen != rndis_hdr->msg_len) {
- kunmap_atomic(rndis_hdr - pkt->page_buf[0].Offset,
+ kunmap_atomic(rndis_hdr - pkt->page_buf[0].offset,
KM_IRQ0);
DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u "
@@ -443,7 +443,7 @@ static int rndis_filter_receive(struct hv_device *dev,
sizeof(struct rndis_message) :
rndis_hdr->msg_len);
- kunmap_atomic(rndis_hdr - pkt->page_buf[0].Offset, KM_IRQ0);
+ kunmap_atomic(rndis_hdr - pkt->page_buf[0].offset, KM_IRQ0);
dump_rndis_message(&rndis_msg);
@@ -622,10 +622,10 @@ int rndis_filter_init(struct netvsc_driver *drv)
rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/
/* Save the original dispatch handlers before we override it */
- rndis_filter.inner_drv.base.OnDeviceAdd = drv->base.OnDeviceAdd;
- rndis_filter.inner_drv.base.OnDeviceRemove =
- drv->base.OnDeviceRemove;
- rndis_filter.inner_drv.base.OnCleanup = drv->base.OnCleanup;
+ rndis_filter.inner_drv.base.dev_add = drv->base.dev_add;
+ rndis_filter.inner_drv.base.dev_rm =
+ drv->base.dev_rm;
+ rndis_filter.inner_drv.base.cleanup = drv->base.cleanup;
/* ASSERT(Driver->OnSend); */
/* ASSERT(Driver->OnReceiveCallback); */
@@ -635,9 +635,9 @@ int rndis_filter_init(struct netvsc_driver *drv)
drv->link_status_change;
/* Override */
- drv->base.OnDeviceAdd = rndis_filte_device_add;
- drv->base.OnDeviceRemove = rndis_filter_device_remove;
- drv->base.OnCleanup = rndis_filter_cleanup;
+ drv->base.dev_add = rndis_filte_device_add;
+ drv->base.dev_rm = rndis_filter_device_remove;
+ drv->base.cleanup = rndis_filter_cleanup;
drv->send = rndis_filter_send;
/* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */
drv->recv_cb = rndis_filter_receive;
@@ -770,7 +770,7 @@ static int rndis_filte_device_add(struct hv_device *dev,
* NOTE! Once the channel is created, we may get a receive callback
* (RndisFilterOnReceive()) before this call is completed
*/
- ret = rndis_filter.inner_drv.base.OnDeviceAdd(dev, additional_info);
+ ret = rndis_filter.inner_drv.base.dev_add(dev, additional_info);
if (ret != 0) {
kfree(rndisDevice);
return ret;
@@ -778,7 +778,7 @@ static int rndis_filte_device_add(struct hv_device *dev,
/* Initialize the rndis device */
- netDevice = dev->Extension;
+ netDevice = dev->ext;
/* ASSERT(netDevice); */
/* ASSERT(netDevice->Device); */
@@ -818,7 +818,7 @@ static int rndis_filte_device_add(struct hv_device *dev,
static int rndis_filter_device_remove(struct hv_device *dev)
{
- struct netvsc_device *net_dev = dev->Extension;
+ struct netvsc_device *net_dev = dev->ext;
struct rndis_device *rndis_dev = net_dev->extension;
/* Halt and release the rndis device */
@@ -828,7 +828,7 @@ static int rndis_filter_device_remove(struct hv_device *dev)
net_dev->extension = NULL;
/* Pass control to inner driver to remove the device */
- rndis_filter.inner_drv.base.OnDeviceRemove(dev);
+ rndis_filter.inner_drv.base.dev_rm(dev);
return 0;
}
@@ -839,7 +839,7 @@ static void rndis_filter_cleanup(struct hv_driver *drv)
int rndis_filter_open(struct hv_device *dev)
{
- struct netvsc_device *netDevice = dev->Extension;
+ struct netvsc_device *netDevice = dev->ext;
if (!netDevice)
return -EINVAL;
@@ -849,7 +849,7 @@ int rndis_filter_open(struct hv_device *dev)
int rndis_filter_close(struct hv_device *dev)
{
- struct netvsc_device *netDevice = dev->Extension;
+ struct netvsc_device *netDevice = dev->ext;
if (!netDevice)
return -EINVAL;
@@ -884,10 +884,10 @@ static int rndis_filter_send(struct hv_device *dev,
rndisPacket->data_len = pkt->total_data_buflen;
pkt->is_data_pkt = true;
- pkt->page_buf[0].Pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT;
- pkt->page_buf[0].Offset =
+ pkt->page_buf[0].pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT;
+ pkt->page_buf[0].offset =
(unsigned long)rndisMessage & (PAGE_SIZE-1);
- pkt->page_buf[0].Length = rndisMessageSize;
+ pkt->page_buf[0].len = rndisMessageSize;
/* Save the packet send completion and context */
filterPacket->completion = pkt->completion.send.send_completion;
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 9295113e09b9..a6121092d47a 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -94,7 +94,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
atomic_cmpxchg(&stor_device->ref_count, 0, 2);
stor_device->device = device;
- device->Extension = stor_device;
+ device->ext = stor_device;
return stor_device;
}
@@ -110,7 +110,7 @@ static inline struct storvsc_device *get_stor_device(struct hv_device *device)
{
struct storvsc_device *stor_device;
- stor_device = (struct storvsc_device *)device->Extension;
+ stor_device = (struct storvsc_device *)device->ext;
if (stor_device && atomic_read(&stor_device->ref_count) > 1)
atomic_inc(&stor_device->ref_count);
else
@@ -125,7 +125,7 @@ static inline struct storvsc_device *must_get_stor_device(
{
struct storvsc_device *stor_device;
- stor_device = (struct storvsc_device *)device->Extension;
+ stor_device = (struct storvsc_device *)device->ext;
if (stor_device && atomic_read(&stor_device->ref_count))
atomic_inc(&stor_device->ref_count);
else
@@ -138,7 +138,7 @@ static inline void put_stor_device(struct hv_device *device)
{
struct storvsc_device *stor_device;
- stor_device = (struct storvsc_device *)device->Extension;
+ stor_device = (struct storvsc_device *)device->ext;
/* ASSERT(stor_device); */
atomic_dec(&stor_device->ref_count);
@@ -151,7 +151,7 @@ static inline struct storvsc_device *release_stor_device(
{
struct storvsc_device *stor_device;
- stor_device = (struct storvsc_device *)device->Extension;
+ stor_device = (struct storvsc_device *)device->ext;
/* ASSERT(stor_device); */
/* Busy wait until the ref drop to 2, then set it to 1 */
@@ -167,14 +167,14 @@ static inline struct storvsc_device *final_release_stor_device(
{
struct storvsc_device *stor_device;
- stor_device = (struct storvsc_device *)device->Extension;
+ stor_device = (struct storvsc_device *)device->ext;
/* ASSERT(stor_device); */
/* Busy wait until the ref drop to 1, then set it to 0 */
while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
udelay(100);
- device->Extension = NULL;
+ device->ext = NULL;
return stor_device;
}
@@ -218,7 +218,7 @@ static int stor_vsc_channel_init(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC,
@@ -249,7 +249,7 @@ static int stor_vsc_channel_init(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC,
@@ -280,7 +280,7 @@ static int stor_vsc_channel_init(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
@@ -317,7 +317,7 @@ static int stor_vsc_channel_init(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
@@ -437,7 +437,7 @@ static void stor_vsc_on_channel_callback(void *context)
struct storvsc_device *stor_device;
u32 bytes_recvd;
u64 request_id;
- unsigned char packet[ALIGN_UP(sizeof(struct vstor_packet), 8)];
+ unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
struct storvsc_request_extension *request;
int ret;
@@ -452,7 +452,7 @@ static void stor_vsc_on_channel_callback(void *context)
do {
ret = vmbus_recvpacket(device->channel, packet,
- ALIGN_UP(sizeof(struct vstor_packet), 8),
+ ALIGN(sizeof(struct vstor_packet), 8),
&bytes_recvd, &request_id);
if (ret == 0 && bytes_recvd > 0) {
DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx",
@@ -499,7 +499,7 @@ static int stor_vsc_connect_to_vsp(struct hv_device *device)
struct storvsc_driver_object *stor_driver;
int ret;
- stor_driver = (struct storvsc_driver_object *)device->Driver;
+ stor_driver = (struct storvsc_driver_object *)device->drv;
memset(&props, 0, sizeof(struct vmstorage_channel_properties));
/* Open the channel */
@@ -581,7 +581,7 @@ static int stor_vsc_on_device_remove(struct hv_device *device)
struct storvsc_device *stor_device;
DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
- device->Extension);
+ device->ext);
stor_device = release_stor_device(device);
@@ -597,7 +597,7 @@ static int stor_vsc_on_device_remove(struct hv_device *device)
}
DPRINT_INFO(STORVSC, "removing storage device (%p)...",
- device->Extension);
+ device->ext);
stor_device = final_release_stor_device(device);
@@ -642,7 +642,7 @@ int stor_vsc_on_host_reset(struct hv_device *device)
ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)&stor_device->reset_request,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
if (ret != 0) {
DPRINT_ERR(STORVSC, "Unable to send reset packet %p ret %d",
@@ -687,7 +687,7 @@ static int stor_vsc_on_io_request(struct hv_device *device,
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, request->data_buffer.len, request->bus,
request->target_id, request->lun_id, request->cdb_len);
if (!stor_device) {
@@ -720,7 +720,7 @@ static int stor_vsc_on_io_request(struct hv_device *device,
memcpy(&vstor_packet->vm_srb.cdb, request->cdb, request->cdb_len);
vstor_packet->vm_srb.data_in = request->type;
- vstor_packet->vm_srb.data_transfer_length = request->data_buffer.Length;
+ vstor_packet->vm_srb.data_transfer_length = request->data_buffer.len;
vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
@@ -734,7 +734,7 @@ static int stor_vsc_on_io_request(struct hv_device *device,
vstor_packet->vm_srb.sense_info_length,
vstor_packet->vm_srb.cdb_length);
- if (request_extension->request->data_buffer.Length) {
+ if (request_extension->request->data_buffer.len) {
ret = vmbus_sendpacket_multipagebuffer(device->channel,
&request_extension->request->data_buffer,
vstor_packet,
@@ -744,7 +744,7 @@ static int stor_vsc_on_io_request(struct hv_device *device,
ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet),
(unsigned long)request_extension,
- VmbusPacketTypeDataInBand,
+ VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
}
@@ -788,7 +788,7 @@ int stor_vsc_initialize(struct hv_driver *driver)
/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
driver->name = g_driver_name;
- memcpy(&driver->deviceType, &gStorVscDeviceType,
+ memcpy(&driver->dev_type, &gStorVscDeviceType,
sizeof(struct hv_guid));
stor_driver->request_ext_size =
@@ -802,7 +802,7 @@ int stor_vsc_initialize(struct hv_driver *driver)
*/
stor_driver->max_outstanding_req_per_channel =
((stor_driver->ring_buffer_size - PAGE_SIZE) /
- ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET +
+ ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
sizeof(struct vstor_packet) + sizeof(u64),
sizeof(u64)));
@@ -811,9 +811,9 @@ int stor_vsc_initialize(struct hv_driver *driver)
STORVSC_MAX_IO_REQUESTS);
/* Setup the dispatch table */
- 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;
+ stor_driver->base.dev_add = stor_vsc_on_device_add;
+ stor_driver->base.dev_rm = stor_vsc_on_device_remove;
+ stor_driver->base.cleanup = stor_vsc_on_cleanup;
stor_driver->on_io_request = stor_vsc_on_io_request;
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 17f1b344fbc5..956c9ebaa6a5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -161,7 +161,7 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
}
drv_ctx->driver.name = storvsc_drv_obj->base.name;
- memcpy(&drv_ctx->class_id, &storvsc_drv_obj->base.deviceType,
+ memcpy(&drv_ctx->class_id, &storvsc_drv_obj->base.dev_type,
sizeof(struct hv_guid));
drv_ctx->probe = storvsc_probe;
@@ -206,8 +206,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.cleanup)
+ storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
vmbus_child_driver_unregister(drv_ctx);
return;
@@ -231,7 +231,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.dev_add)
return -1;
host = scsi_host_alloc(&scsi_driver,
@@ -262,7 +262,7 @@ static int storvsc_probe(struct device *device)
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.dev_add(device_obj,
(void *)&device_info);
if (ret != 0) {
DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device");
@@ -287,7 +287,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.dev_rm(device_obj);
kmem_cache_destroy(host_device_ctx->request_pool);
scsi_host_put(host);
@@ -317,14 +317,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.dev_rm)
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.dev_rm(device_obj);
if (ret != 0) {
/* TODO: */
DPRINT_ERR(STORVSC, "unable to remove vsc device (ret %d)",
@@ -385,7 +385,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
/* ASSERT(request->BytesXfer <= request->data_buffer.Length); */
scsi_set_resid(scmnd,
- request->data_buffer.Length - request->bytes_xfer);
+ request->data_buffer.len - request->bytes_xfer);
scsi_done_fn = scmnd->scsi_done;
@@ -434,7 +434,7 @@ static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
struct scatterlist *bounce_sgl;
struct page *page_buf;
- num_pages = ALIGN_UP(len, PAGE_SIZE) >> PAGE_SHIFT;
+ num_pages = ALIGN(len, PAGE_SIZE) >> PAGE_SHIFT;
bounce_sgl = kcalloc(num_pages, sizeof(struct scatterlist), GFP_ATOMIC);
if (!bounce_sgl)
@@ -693,7 +693,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
request->sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
- request->data_buffer.Length = scsi_bufflen(scmnd);
+ request->data_buffer.len = scsi_bufflen(scmnd);
if (scsi_sg_count(scmnd)) {
sgl = (struct scatterlist *)scsi_sglist(scmnd);
sg_count = scsi_sg_count(scmnd);
@@ -720,7 +720,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
}
cmd_request->bounce_sgl_count =
- ALIGN_UP(scsi_bufflen(scmnd), PAGE_SIZE) >>
+ ALIGN(scsi_bufflen(scmnd), PAGE_SIZE) >>
PAGE_SHIFT;
/*
@@ -734,19 +734,19 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
sg_count = cmd_request->bounce_sgl_count;
}
- request->data_buffer.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->data_buffer.PfnArray[i] =
+ request->data_buffer.pfn_array[i] =
page_to_pfn(sg_page((&sgl[i])));
}
} else if (scsi_sglist(scmnd)) {
/* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
- request->data_buffer.Offset =
+ request->data_buffer.offset =
virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
- request->data_buffer.PfnArray[0] =
+ request->data_buffer.pfn_array[0] =
virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
}
diff --git a/drivers/staging/hv/tools/hv_kvp_daemon.c b/drivers/staging/hv/tools/hv_kvp_daemon.c
new file mode 100644
index 000000000000..f5a2dd694611
--- /dev/null
+++ b/drivers/staging/hv/tools/hv_kvp_daemon.c
@@ -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);
+ }
+ }
+
+}
diff --git a/drivers/staging/hv/utils.h b/drivers/staging/hv/utils.h
index 7c0749999a6f..6d27d15ab525 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;
diff --git a/drivers/staging/hv/vmbus_api.h b/drivers/staging/hv/vmbus_api.h
index 2da3f52610b3..635ce22a0334 100644
--- a/drivers/staging/hv/vmbus_api.h
+++ b/drivers/staging/hv/vmbus_api.h
@@ -32,17 +32,17 @@
/* Single-page buffer */
struct hv_page_buffer {
- u32 Length;
- u32 Offset;
- u64 Pfn;
+ u32 len;
+ u32 offset;
+ u64 pfn;
};
/* Multiple-page buffer */
struct hv_multipage_buffer {
/* Length and Offset determines the # of pfns in the array */
- u32 Length;
- u32 Offset;
- u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
+ u32 len;
+ u32 offset;
+ u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT];
};
/* 0x18 includes the proprietary packet header */
@@ -59,29 +59,29 @@ struct hv_driver;
struct hv_device;
struct hv_dev_port_info {
- u32 InterruptMask;
- u32 ReadIndex;
- u32 WriteIndex;
- u32 BytesAvailToRead;
- u32 BytesAvailToWrite;
+ u32 int_mask;
+ u32 read_idx;
+ u32 write_idx;
+ u32 bytes_avail_toread;
+ u32 bytes_avail_towrite;
};
struct hv_device_info {
- u32 ChannelId;
- u32 ChannelState;
- struct hv_guid ChannelType;
- struct hv_guid ChannelInstance;
-
- u32 MonitorId;
- u32 ServerMonitorPending;
- u32 ServerMonitorLatency;
- u32 ServerMonitorConnectionId;
- u32 ClientMonitorPending;
- u32 ClientMonitorLatency;
- u32 ClientMonitorConnectionId;
-
- struct hv_dev_port_info Inbound;
- struct hv_dev_port_info Outbound;
+ u32 chn_id;
+ u32 chn_state;
+ struct hv_guid chn_type;
+ struct hv_guid chn_instance;
+
+ u32 monitor_id;
+ u32 server_monitor_pending;
+ u32 server_monitor_latency;
+ u32 server_monitor_conn_id;
+ u32 client_monitor_pending;
+ u32 client_monitor_latency;
+ u32 client_monitor_conn_id;
+
+ struct hv_dev_port_info inbound;
+ struct hv_dev_port_info outbound;
};
/* Base driver object */
@@ -89,30 +89,30 @@ struct hv_driver {
const char *name;
/* the device type supported by this driver */
- struct hv_guid deviceType;
+ struct hv_guid dev_type;
- int (*OnDeviceAdd)(struct hv_device *device, void *data);
- int (*OnDeviceRemove)(struct hv_device *device);
- void (*OnCleanup)(struct hv_driver *driver);
+ int (*dev_add)(struct hv_device *device, void *data);
+ int (*dev_rm)(struct hv_device *device);
+ void (*cleanup)(struct hv_driver *driver);
};
/* Base device object */
struct hv_device {
/* the driver for this device */
- struct hv_driver *Driver;
+ struct hv_driver *drv;
char name[64];
/* the device type id of this device */
- struct hv_guid deviceType;
+ struct hv_guid dev_type;
/* the device instance id of this device */
- struct hv_guid deviceInstance;
+ struct hv_guid dev_instance;
struct vmbus_channel *channel;
/* Device extension; */
- void *Extension;
+ void *ext;
};
#endif /* _VMBUS_API_H_ */
diff --git a/drivers/staging/hv/vmbus_channel_interface.h b/drivers/staging/hv/vmbus_channel_interface.h
index 26742823748d..fbfad5e8b92d 100644
--- a/drivers/staging/hv/vmbus_channel_interface.h
+++ b/drivers/staging/hv/vmbus_channel_interface.h
@@ -48,19 +48,19 @@
* struct contains the fundamental information about an offer.
*/
struct vmbus_channel_offer {
- struct hv_guid InterfaceType;
- struct hv_guid InterfaceInstance;
- u64 InterruptLatencyIn100nsUnits;
- u32 InterfaceRevision;
- u32 ServerContextAreaSize; /* in bytes */
- u16 ChannelFlags;
- u16 MmioMegabytes; /* in bytes * 1024 * 1024 */
+ struct hv_guid if_type;
+ struct hv_guid if_instance;
+ u64 int_latency; /* in 100ns units */
+ u32 if_revision;
+ u32 server_ctx_size; /* in bytes */
+ u16 chn_flags;
+ u16 mmio_megabytes; /* in bytes * 1024 * 1024 */
union {
/* Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes. */
struct {
- unsigned char UserDefined[MAX_USER_DEFINED_BYTES];
- } Standard;
+ unsigned char user_def[MAX_USER_DEFINED_BYTES];
+ } std;
/*
* Pipes:
@@ -70,11 +70,11 @@ struct vmbus_channel_offer {
* use.
*/
struct {
- u32 PipeMode;
- unsigned char UserDefined[MAX_PIPE_USER_DEFINED_BYTES];
- } Pipe;
+ u32 pipe_mode;
+ unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES];
+ } pipe;
} u;
- u32 Padding;
+ u32 padding;
} __attribute__((packed));
/* Server Flags */
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 84fdb64d3ceb..dacaa54edeac 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -113,7 +113,7 @@ static struct device_attribute vmbus_device_attrs[] = {
};
/* The one and only one */
-static struct vmbus_driver_context g_vmbus_drv = {
+static struct vmbus_driver_context vmbus_drv = {
.bus.name = "vmbus",
.bus.match = vmbus_match,
.bus.shutdown = vmbus_shutdown,
@@ -123,14 +123,14 @@ static struct vmbus_driver_context g_vmbus_drv = {
.bus.dev_attrs = vmbus_device_attrs,
};
-static const char *gDriverName = "hyperv";
+static const char *driver_name = "hyperv";
/*
* Windows vmbus does not defined this.
* We defined this to be consistent with other devices
*/
/* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */
-static const struct hv_guid gVmbusDeviceType = {
+static const struct hv_guid device_type = {
.data = {
0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d,
0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85
@@ -138,35 +138,35 @@ static const struct hv_guid gVmbusDeviceType = {
};
/* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */
-static const struct hv_guid gVmbusDeviceId = {
+static const struct hv_guid device_id = {
.data = {
0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40,
0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5
}
};
-static struct hv_device *gDevice; /* vmbus root device */
+static struct hv_device *vmbus_device; /* vmbus root device */
/*
- * VmbusChildDeviceAdd - Registers the child device with the vmbus
+ * vmbus_child_dev_add - Registers the child device with the vmbus
*/
-int VmbusChildDeviceAdd(struct hv_device *ChildDevice)
+int vmbus_child_dev_add(struct hv_device *child_dev)
{
- return vmbus_child_device_register(gDevice, ChildDevice);
+ return vmbus_child_device_register(vmbus_device, child_dev);
}
/*
- * VmbusOnDeviceAdd - Callback when the root bus device is added
+ * vmbus_dev_add - Callback when the root bus device is added
*/
-static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo)
+static int vmbus_dev_add(struct hv_device *dev, void *info)
{
- u32 *irqvector = AdditionalInfo;
+ u32 *irqvector = info;
int ret;
- gDevice = dev;
+ vmbus_device = dev;
- memcpy(&gDevice->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid));
- memcpy(&gDevice->deviceInstance, &gVmbusDeviceId,
+ memcpy(&vmbus_device->dev_type, &device_type, sizeof(struct hv_guid));
+ memcpy(&vmbus_device->dev_instance, &device_id,
sizeof(struct hv_guid));
/* strcpy(dev->name, "vmbus"); */
@@ -174,29 +174,29 @@ static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo)
on_each_cpu(hv_synic_init, (void *)irqvector, 1);
/* Connect to VMBus in the root partition */
- ret = VmbusConnect();
+ ret = vmbus_connect();
/* VmbusSendEvent(device->localPortId+1); */
return ret;
}
/*
- * VmbusOnDeviceRemove - Callback when the root bus device is removed
+ * vmbus_dev_rm - Callback when the root bus device is removed
*/
-static int VmbusOnDeviceRemove(struct hv_device *dev)
+static int vmbus_dev_rm(struct hv_device *dev)
{
int ret = 0;
vmbus_release_unattached_channels();
- VmbusDisconnect();
+ vmbus_disconnect();
on_each_cpu(hv_synic_cleanup, NULL, 1);
return ret;
}
/*
- * VmbusOnCleanup - Perform any cleanup when the driver is removed
+ * vmbus_cleanup - Perform any cleanup when the driver is removed
*/
-static void VmbusOnCleanup(struct hv_driver *drv)
+static void vmbus_cleanup(struct hv_driver *drv)
{
/* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */
@@ -239,7 +239,7 @@ static void vmbus_on_msg_dpc(struct hv_driver *drv)
continue;
INIT_WORK(&ctx->work, vmbus_onmessage_work);
memcpy(&ctx->msg, msg, sizeof(*msg));
- queue_work(gVmbusConnection.WorkQueue, &ctx->work);
+ queue_work(vmbus_connection.work_queue, &ctx->work);
}
msg->header.message_type = HVMSG_NONE;
@@ -309,37 +309,38 @@ static void get_channel_info(struct hv_device *device,
vmbus_get_debug_info(device->channel, &debug_info);
- info->ChannelId = debug_info.relid;
- info->ChannelState = debug_info.state;
- memcpy(&info->ChannelType, &debug_info.interfacetype,
+ info->chn_id = debug_info.relid;
+ info->chn_state = debug_info.state;
+ memcpy(&info->chn_type, &debug_info.interfacetype,
sizeof(struct hv_guid));
- memcpy(&info->ChannelInstance, &debug_info.interface_instance,
+ memcpy(&info->chn_instance, &debug_info.interface_instance,
sizeof(struct hv_guid));
- info->MonitorId = debug_info.monitorid;
+ info->monitor_id = debug_info.monitorid;
- info->ServerMonitorPending = debug_info.servermonitor_pending;
- info->ServerMonitorLatency = debug_info.servermonitor_latency;
- info->ServerMonitorConnectionId = debug_info.servermonitor_connectionid;
+ info->server_monitor_pending = debug_info.servermonitor_pending;
+ info->server_monitor_latency = debug_info.servermonitor_latency;
+ info->server_monitor_conn_id = debug_info.servermonitor_connectionid;
- info->ClientMonitorPending = debug_info.clientmonitor_pending;
- info->ClientMonitorLatency = debug_info.clientmonitor_latency;
- info->ClientMonitorConnectionId = debug_info.clientmonitor_connectionid;
+ info->client_monitor_pending = debug_info.clientmonitor_pending;
+ info->client_monitor_latency = debug_info.clientmonitor_latency;
+ info->client_monitor_conn_id = debug_info.clientmonitor_connectionid;
- info->Inbound.InterruptMask = debug_info.inbound.current_interrupt_mask;
- info->Inbound.ReadIndex = debug_info.inbound.current_read_index;
- info->Inbound.WriteIndex = debug_info.inbound.current_write_index;
- info->Inbound.BytesAvailToRead = debug_info.inbound.bytes_avail_toread;
- info->Inbound.BytesAvailToWrite =
+ info->inbound.int_mask = debug_info.inbound.current_interrupt_mask;
+ info->inbound.read_idx = debug_info.inbound.current_read_index;
+ info->inbound.write_idx = debug_info.inbound.current_write_index;
+ info->inbound.bytes_avail_toread =
+ debug_info.inbound.bytes_avail_toread;
+ info->inbound.bytes_avail_towrite =
debug_info.inbound.bytes_avail_towrite;
- info->Outbound.InterruptMask =
+ info->outbound.int_mask =
debug_info.outbound.current_interrupt_mask;
- info->Outbound.ReadIndex = debug_info.outbound.current_read_index;
- info->Outbound.WriteIndex = debug_info.outbound.current_write_index;
- info->Outbound.BytesAvailToRead =
+ info->outbound.read_idx = debug_info.outbound.current_read_index;
+ info->outbound.write_idx = debug_info.outbound.current_write_index;
+ info->outbound.bytes_avail_toread =
debug_info.outbound.bytes_avail_toread;
- info->Outbound.BytesAvailToWrite =
+ info->outbound.bytes_avail_towrite =
debug_info.outbound.bytes_avail_towrite;
}
@@ -363,85 +364,85 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
if (!strcmp(dev_attr->attr.name, "class_id")) {
return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x%02x%02x%02x%02x%02x%02x}\n",
- device_info.ChannelType.data[3],
- device_info.ChannelType.data[2],
- device_info.ChannelType.data[1],
- device_info.ChannelType.data[0],
- device_info.ChannelType.data[5],
- device_info.ChannelType.data[4],
- device_info.ChannelType.data[7],
- device_info.ChannelType.data[6],
- device_info.ChannelType.data[8],
- device_info.ChannelType.data[9],
- device_info.ChannelType.data[10],
- device_info.ChannelType.data[11],
- device_info.ChannelType.data[12],
- device_info.ChannelType.data[13],
- device_info.ChannelType.data[14],
- device_info.ChannelType.data[15]);
+ device_info.chn_type.data[3],
+ device_info.chn_type.data[2],
+ device_info.chn_type.data[1],
+ device_info.chn_type.data[0],
+ device_info.chn_type.data[5],
+ device_info.chn_type.data[4],
+ device_info.chn_type.data[7],
+ device_info.chn_type.data[6],
+ device_info.chn_type.data[8],
+ device_info.chn_type.data[9],
+ device_info.chn_type.data[10],
+ device_info.chn_type.data[11],
+ device_info.chn_type.data[12],
+ device_info.chn_type.data[13],
+ device_info.chn_type.data[14],
+ device_info.chn_type.data[15]);
} else if (!strcmp(dev_attr->attr.name, "device_id")) {
return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x%02x%02x%02x%02x%02x%02x}\n",
- device_info.ChannelInstance.data[3],
- device_info.ChannelInstance.data[2],
- device_info.ChannelInstance.data[1],
- device_info.ChannelInstance.data[0],
- device_info.ChannelInstance.data[5],
- device_info.ChannelInstance.data[4],
- device_info.ChannelInstance.data[7],
- device_info.ChannelInstance.data[6],
- device_info.ChannelInstance.data[8],
- device_info.ChannelInstance.data[9],
- device_info.ChannelInstance.data[10],
- device_info.ChannelInstance.data[11],
- device_info.ChannelInstance.data[12],
- device_info.ChannelInstance.data[13],
- device_info.ChannelInstance.data[14],
- device_info.ChannelInstance.data[15]);
+ device_info.chn_instance.data[3],
+ device_info.chn_instance.data[2],
+ device_info.chn_instance.data[1],
+ device_info.chn_instance.data[0],
+ device_info.chn_instance.data[5],
+ device_info.chn_instance.data[4],
+ device_info.chn_instance.data[7],
+ device_info.chn_instance.data[6],
+ device_info.chn_instance.data[8],
+ device_info.chn_instance.data[9],
+ device_info.chn_instance.data[10],
+ device_info.chn_instance.data[11],
+ device_info.chn_instance.data[12],
+ device_info.chn_instance.data[13],
+ device_info.chn_instance.data[14],
+ device_info.chn_instance.data[15]);
} else if (!strcmp(dev_attr->attr.name, "state")) {
- return sprintf(buf, "%d\n", device_info.ChannelState);
+ return sprintf(buf, "%d\n", device_info.chn_state);
} else if (!strcmp(dev_attr->attr.name, "id")) {
- return sprintf(buf, "%d\n", device_info.ChannelId);
+ return sprintf(buf, "%d\n", device_info.chn_id);
} else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
- return sprintf(buf, "%d\n", device_info.Outbound.InterruptMask);
+ return sprintf(buf, "%d\n", device_info.outbound.int_mask);
} else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
- return sprintf(buf, "%d\n", device_info.Outbound.ReadIndex);
+ return sprintf(buf, "%d\n", device_info.outbound.read_idx);
} else if (!strcmp(dev_attr->attr.name, "out_write_index")) {
- return sprintf(buf, "%d\n", device_info.Outbound.WriteIndex);
+ return sprintf(buf, "%d\n", device_info.outbound.write_idx);
} else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) {
return sprintf(buf, "%d\n",
- device_info.Outbound.BytesAvailToRead);
+ device_info.outbound.bytes_avail_toread);
} else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) {
return sprintf(buf, "%d\n",
- device_info.Outbound.BytesAvailToWrite);
+ device_info.outbound.bytes_avail_towrite);
} else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) {
- return sprintf(buf, "%d\n", device_info.Inbound.InterruptMask);
+ return sprintf(buf, "%d\n", device_info.inbound.int_mask);
} else if (!strcmp(dev_attr->attr.name, "in_read_index")) {
- return sprintf(buf, "%d\n", device_info.Inbound.ReadIndex);
+ return sprintf(buf, "%d\n", device_info.inbound.read_idx);
} else if (!strcmp(dev_attr->attr.name, "in_write_index")) {
- return sprintf(buf, "%d\n", device_info.Inbound.WriteIndex);
+ return sprintf(buf, "%d\n", device_info.inbound.write_idx);
} else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) {
return sprintf(buf, "%d\n",
- device_info.Inbound.BytesAvailToRead);
+ device_info.inbound.bytes_avail_toread);
} else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) {
return sprintf(buf, "%d\n",
- device_info.Inbound.BytesAvailToWrite);
+ device_info.inbound.bytes_avail_towrite);
} else if (!strcmp(dev_attr->attr.name, "monitor_id")) {
- return sprintf(buf, "%d\n", device_info.MonitorId);
+ return sprintf(buf, "%d\n", device_info.monitor_id);
} else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) {
- return sprintf(buf, "%d\n", device_info.ServerMonitorPending);
+ return sprintf(buf, "%d\n", device_info.server_monitor_pending);
} else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) {
- return sprintf(buf, "%d\n", device_info.ServerMonitorLatency);
+ return sprintf(buf, "%d\n", device_info.server_monitor_latency);
} else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) {
return sprintf(buf, "%d\n",
- device_info.ServerMonitorConnectionId);
+ device_info.server_monitor_conn_id);
} else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) {
- return sprintf(buf, "%d\n", device_info.ClientMonitorPending);
+ return sprintf(buf, "%d\n", device_info.client_monitor_pending);
} else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) {
- return sprintf(buf, "%d\n", device_info.ClientMonitorLatency);
+ return sprintf(buf, "%d\n", device_info.client_monitor_latency);
} else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) {
return sprintf(buf, "%d\n",
- device_info.ClientMonitorConnectionId);
+ device_info.client_monitor_conn_id);
} else {
return 0;
}
@@ -461,9 +462,9 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
*/
static int vmbus_bus_init(void)
{
- struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv;
- struct hv_driver *driver = &g_vmbus_drv.drv_obj;
- struct vm_device *dev_ctx = &g_vmbus_drv.device_ctx;
+ struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
+ struct hv_driver *driver = &vmbus_drv.drv_obj;
+ struct vm_device *dev_ctx = &vmbus_drv.device_ctx;
int ret;
unsigned int vector;
@@ -478,13 +479,13 @@ static int vmbus_bus_init(void)
sizeof(struct vmbus_channel_packet_page_buffer),
sizeof(struct vmbus_channel_packet_multipage_buffer));
- driver->name = gDriverName;
- memcpy(&driver->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid));
+ driver->name = driver_name;
+ memcpy(&driver->dev_type, &device_type, sizeof(struct hv_guid));
/* Setup dispatch table */
- driver->OnDeviceAdd = VmbusOnDeviceAdd;
- driver->OnDeviceRemove = VmbusOnDeviceRemove;
- driver->OnCleanup = VmbusOnCleanup;
+ driver->dev_add = vmbus_dev_add;
+ driver->dev_rm = vmbus_dev_rm;
+ driver->cleanup = vmbus_cleanup;
/* Hypervisor initialization...setup hypercall page..etc */
ret = hv_init();
@@ -495,7 +496,7 @@ static int vmbus_bus_init(void)
}
/* Sanity checks */
- if (!driver->OnDeviceAdd) {
+ if (!driver->dev_add) {
DPRINT_ERR(VMBUS_DRV, "OnDeviceAdd() routine not set");
ret = -1;
goto cleanup;
@@ -536,7 +537,7 @@ static int vmbus_bus_init(void)
/* Call to bus driver to add the root device */
memset(dev_ctx, 0, sizeof(struct vm_device));
- ret = driver->OnDeviceAdd(&dev_ctx->device_obj, &vector);
+ ret = driver->dev_add(&dev_ctx->device_obj, &vector);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV,
"ERROR - Unable to add vmbus root device");
@@ -550,9 +551,9 @@ static int vmbus_bus_init(void)
}
/* strcpy(dev_ctx->device.bus_id, dev_ctx->device_obj.name); */
dev_set_name(&dev_ctx->device, "vmbus_0_0");
- memcpy(&dev_ctx->class_id, &dev_ctx->device_obj.deviceType,
+ memcpy(&dev_ctx->class_id, &dev_ctx->device_obj.dev_type,
sizeof(struct hv_guid));
- memcpy(&dev_ctx->device_id, &dev_ctx->device_obj.deviceInstance,
+ memcpy(&dev_ctx->device_id, &dev_ctx->device_obj.dev_instance,
sizeof(struct hv_guid));
/* No need to bind a driver to the root device. */
@@ -590,17 +591,17 @@ cleanup:
*/
static void vmbus_bus_exit(void)
{
- struct hv_driver *driver = &g_vmbus_drv.drv_obj;
- struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv;
+ struct hv_driver *driver = &vmbus_drv.drv_obj;
+ struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
- struct vm_device *dev_ctx = &g_vmbus_drv.device_ctx;
+ struct vm_device *dev_ctx = &vmbus_drv.device_ctx;
/* Remove the root device */
- if (driver->OnDeviceRemove)
- driver->OnDeviceRemove(&dev_ctx->device_obj);
+ if (driver->dev_rm)
+ driver->dev_rm(&dev_ctx->device_obj);
- if (driver->OnCleanup)
- driver->OnCleanup(driver);
+ if (driver->cleanup)
+ driver->cleanup(driver);
/* Unregister the root bus device */
device_unregister(&dev_ctx->device);
@@ -634,7 +635,7 @@ int vmbus_child_driver_register(struct driver_context *driver_ctx)
driver_ctx, driver_ctx->driver.name);
/* The child driver on this vmbus */
- driver_ctx->driver.bus = &g_vmbus_drv.bus;
+ driver_ctx->driver.bus = &vmbus_drv.bus;
ret = driver_register(&driver_ctx->driver);
@@ -706,8 +707,8 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
child_device_obj = &child_device_ctx->device_obj;
child_device_obj->channel = channel;
- memcpy(&child_device_obj->deviceType, type, sizeof(struct hv_guid));
- memcpy(&child_device_obj->deviceInstance, instance,
+ memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
+ memcpy(&child_device_obj->dev_instance, instance,
sizeof(struct hv_guid));
memcpy(&child_device_ctx->class_id, type, sizeof(struct hv_guid));
@@ -737,7 +738,7 @@ int vmbus_child_device_register(struct hv_device *root_device_obj,
atomic_inc_return(&device_num));
/* The new device belongs to this bus */
- child_device_ctx->device.bus = &g_vmbus_drv.bus; /* device->dev.bus; */
+ child_device_ctx->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
child_device_ctx->device.parent = &root_device_ctx->device;
child_device_ctx->device.release = vmbus_device_release;
@@ -875,11 +876,11 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
struct vmbus_driver_context *vmbus_drv_ctx =
(struct vmbus_driver_context *)driver_ctx;
- device_ctx->device_obj.Driver = &vmbus_drv_ctx->drv_obj;
+ device_ctx->device_obj.drv = &vmbus_drv_ctx->drv_obj;
DPRINT_INFO(VMBUS_DRV,
"device object (%p) set to driver object (%p)",
&device_ctx->device_obj,
- device_ctx->device_obj.Driver);
+ device_ctx->device_obj.drv);
match = 1;
}
@@ -1045,12 +1046,12 @@ static void vmbus_msg_dpc(unsigned long data)
static void vmbus_event_dpc(unsigned long data)
{
/* Call to bus driver to handle interrupt */
- VmbusOnEvents();
+ vmbus_on_event();
}
static irqreturn_t vmbus_isr(int irq, void *dev_id)
{
- struct hv_driver *driver = &g_vmbus_drv.drv_obj;
+ struct hv_driver *driver = &vmbus_drv.drv_obj;
int ret;
/* Call to bus driver to handle interrupt */
@@ -1059,10 +1060,10 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id)
/* Schedules a dpc if necessary */
if (ret > 0) {
if (test_bit(0, (unsigned long *)&ret))
- tasklet_schedule(&g_vmbus_drv.msg_dpc);
+ tasklet_schedule(&vmbus_drv.msg_dpc);
if (test_bit(1, (unsigned long *)&ret))
- tasklet_schedule(&g_vmbus_drv.event_dpc);
+ tasklet_schedule(&vmbus_drv.event_dpc);
return IRQ_HANDLED;
} else {
diff --git a/drivers/staging/hv/vmbus_packet_format.h b/drivers/staging/hv/vmbus_packet_format.h
index f9f6b4bf6fb1..5cb13e523c48 100644
--- a/drivers/staging/hv/vmbus_packet_format.h
+++ b/drivers/staging/hv/vmbus_packet_format.h
@@ -25,43 +25,43 @@
#define _VMBUSPACKETFORMAT_H_
struct vmpacket_descriptor {
- u16 Type;
- u16 DataOffset8;
- u16 Length8;
- u16 Flags;
- u64 TransactionId;
+ u16 type;
+ u16 offset8;
+ u16 len8;
+ u16 flags;
+ u64 trans_id;
} __attribute__((packed));
struct vmpacket_header {
- u32 PreviousPacketStartOffset;
- struct vmpacket_descriptor Descriptor;
+ u32 prev_pkt_start_offset;
+ struct vmpacket_descriptor descriptor;
} __attribute__((packed));
struct vmtransfer_page_range {
- u32 ByteCount;
- u32 ByteOffset;
+ u32 byte_count;
+ u32 byte_offset;
} __attribute__((packed));
struct vmtransfer_page_packet_header {
struct vmpacket_descriptor d;
- u16 TransferPageSetId;
- bool SenderOwnsSet;
- u8 Reserved;
- u32 RangeCount;
- struct vmtransfer_page_range Ranges[1];
+ u16 xfer_pageset_id;
+ bool sender_owns_set;
+ u8 reserved;
+ u32 range_cnt;
+ struct vmtransfer_page_range ranges[1];
} __attribute__((packed));
struct vmgpadl_packet_header {
struct vmpacket_descriptor d;
- u32 Gpadl;
- u32 Reserved;
+ u32 gpadl;
+ u32 reserved;
} __attribute__((packed));
struct vmadd_remove_transfer_page_set {
struct vmpacket_descriptor d;
- u32 Gpadl;
- u16 TransferPageSetId;
- u16 Reserved;
+ u32 gpadl;
+ u16 xfer_pageset_id;
+ u16 reserved;
} __attribute__((packed));
/*
@@ -69,9 +69,9 @@ struct vmadd_remove_transfer_page_set {
* look virtually contiguous.
*/
struct gpa_range {
- u32 ByteCount;
- u32 ByteOffset;
- u64 PfnArray[0];
+ u32 byte_count;
+ u32 byte_offset;
+ u64 pfn_array[0];
};
/*
@@ -83,9 +83,9 @@ struct gpa_range {
*/
struct vmestablish_gpadl {
struct vmpacket_descriptor d;
- u32 Gpadl;
- u32 RangeCount;
- struct gpa_range Range[1];
+ u32 gpadl;
+ u32 range_cnt;
+ struct gpa_range range[1];
} __attribute__((packed));
/*
@@ -94,8 +94,8 @@ struct vmestablish_gpadl {
*/
struct vmteardown_gpadl {
struct vmpacket_descriptor d;
- u32 Gpadl;
- u32 Reserved; /* for alignment to a 8-byte boundary */
+ u32 gpadl;
+ u32 reserved; /* for alignment to a 8-byte boundary */
} __attribute__((packed));
/*
@@ -104,56 +104,56 @@ struct vmteardown_gpadl {
*/
struct vmdata_gpa_direct {
struct vmpacket_descriptor d;
- u32 Reserved;
- u32 RangeCount;
- struct gpa_range Range[1];
+ u32 reserved;
+ u32 range_cnt;
+ struct gpa_range range[1];
} __attribute__((packed));
/* This is the format for a Additional Data Packet. */
struct vmadditional_data {
struct vmpacket_descriptor d;
- u64 TotalBytes;
- u32 ByteOffset;
- u32 ByteCount;
- unsigned char Data[1];
+ u64 total_bytes;
+ u32 offset;
+ u32 byte_cnt;
+ unsigned char data[1];
} __attribute__((packed));
union vmpacket_largest_possible_header {
- struct vmpacket_descriptor SimpleHeader;
- struct vmtransfer_page_packet_header TransferPageHeader;
- struct vmgpadl_packet_header GpadlHeader;
- struct vmadd_remove_transfer_page_set AddRemoveTransferPageHeader;
- struct vmestablish_gpadl EstablishGpadlHeader;
- struct vmteardown_gpadl TeardownGpadlHeader;
- struct vmdata_gpa_direct DataGpaDirectHeader;
+ struct vmpacket_descriptor simple_hdr;
+ struct vmtransfer_page_packet_header xfer_page_hdr;
+ struct vmgpadl_packet_header gpadl_hdr;
+ struct vmadd_remove_transfer_page_set add_rm_xfer_page_hdr;
+ struct vmestablish_gpadl establish_gpadl_hdr;
+ struct vmteardown_gpadl teardown_gpadl_hdr;
+ struct vmdata_gpa_direct data_gpa_direct_hdr;
};
#define VMPACKET_DATA_START_ADDRESS(__packet) \
(void *)(((unsigned char *)__packet) + \
- ((struct vmpacket_descriptor)__packet)->DataOffset8 * 8)
+ ((struct vmpacket_descriptor)__packet)->offset8 * 8)
#define VMPACKET_DATA_LENGTH(__packet) \
- ((((struct vmpacket_descriptor)__packet)->Length8 - \
- ((struct vmpacket_descriptor)__packet)->DataOffset8) * 8)
+ ((((struct vmpacket_descriptor)__packet)->len8 - \
+ ((struct vmpacket_descriptor)__packet)->offset8) * 8)
#define VMPACKET_TRANSFER_MODE(__packet) \
- (((struct IMPACT)__packet)->Type)
+ (((struct IMPACT)__packet)->type)
enum vmbus_packet_type {
- VmbusPacketTypeInvalid = 0x0,
- VmbusPacketTypeSynch = 0x1,
- VmbusPacketTypeAddTransferPageSet = 0x2,
- VmbusPacketTypeRemoveTransferPageSet = 0x3,
- VmbusPacketTypeEstablishGpadl = 0x4,
- VmbusPacketTypeTearDownGpadl = 0x5,
- VmbusPacketTypeDataInBand = 0x6,
- VmbusPacketTypeDataUsingTransferPages = 0x7,
- VmbusPacketTypeDataUsingGpadl = 0x8,
- VmbusPacketTypeDataUsingGpaDirect = 0x9,
- VmbusPacketTypeCancelRequest = 0xa,
- VmbusPacketTypeCompletion = 0xb,
- VmbusPacketTypeDataUsingAdditionalPackets = 0xc,
- VmbusPacketTypeAdditionalData = 0xd
+ VM_PKT_INVALID = 0x0,
+ VM_PKT_SYNCH = 0x1,
+ VM_PKT_ADD_XFER_PAGESET = 0x2,
+ VM_PKT_RM_XFER_PAGESET = 0x3,
+ VM_PKT_ESTABLISH_GPADL = 0x4,
+ VM_PKT_TEARDOWN_GPADL = 0x5,
+ VM_PKT_DATA_INBAND = 0x6,
+ VM_PKT_DATA_USING_XFER_PAGES = 0x7,
+ VM_PKT_DATA_USING_GPADL = 0x8,
+ VM_PKT_DATA_USING_GPA_DIRECT = 0x9,
+ VM_PKT_CANCEL_REQUEST = 0xa,
+ VM_PKT_COMP = 0xb,
+ VM_PKT_DATA_USING_ADDITIONAL_PKT = 0xc,
+ VM_PKT_ADDITIONAL_DATA = 0xd
};
#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1
diff --git a/drivers/staging/hv/vmbus_private.h b/drivers/staging/hv/vmbus_private.h
index 07f6d22eeabb..004d8de1c7df 100644
--- a/drivers/staging/hv/vmbus_private.h
+++ b/drivers/staging/hv/vmbus_private.h
@@ -45,19 +45,19 @@
#define MAX_NUM_CHANNELS_SUPPORTED 256
-enum VMBUS_CONNECT_STATE {
- Disconnected,
- Connecting,
- Connected,
- Disconnecting
+enum vmbus_connect_state {
+ DISCONNECTED,
+ CONNECTING,
+ CONNECTED,
+ DISCONNECTING
};
#define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT
-struct VMBUS_CONNECTION {
- enum VMBUS_CONNECT_STATE ConnectState;
+struct vmbus_connection {
+ enum vmbus_connect_state conn_state;
- atomic_t NextGpadlHandle;
+ atomic_t next_gpadl_handle;
/*
* Represents channel interrupts. Each bit position represents a
@@ -66,47 +66,47 @@ struct VMBUS_CONNECTION {
* event. The other end receives the port event and parse the
* recvInterruptPage to see which bit is set
*/
- void *InterruptPage;
- void *SendInterruptPage;
- void *RecvInterruptPage;
+ void *int_page;
+ void *send_int_page;
+ void *recv_int_page;
/*
* 2 pages - 1st page for parent->child notification and 2nd
* is child->parent notification
*/
- void *MonitorPages;
- struct list_head ChannelMsgList;
+ void *monitor_pages;
+ struct list_head chn_msg_list;
spinlock_t channelmsg_lock;
/* List of channels */
- struct list_head ChannelList;
+ struct list_head chn_list;
spinlock_t channel_lock;
- struct workqueue_struct *WorkQueue;
+ struct workqueue_struct *work_queue;
};
-struct VMBUS_MSGINFO {
+struct vmbus_msginfo {
/* Bookkeeping stuff */
- struct list_head MsgListEntry;
+ struct list_head msglist_entry;
/* Synchronize the request/response if needed */
- struct osd_waitevent *WaitEvent;
+ struct osd_waitevent *wait_event;
/* The message itself */
- unsigned char Msg[0];
+ unsigned char msg[0];
};
-extern struct VMBUS_CONNECTION gVmbusConnection;
+extern struct vmbus_connection vmbus_connection;
/* General vmbus interface */
-struct hv_device *vmbus_child_device_create(struct hv_guid *deviceType,
- struct hv_guid *deviceInstance,
+struct hv_device *vmbus_child_device_create(struct hv_guid *type,
+ struct hv_guid *instance,
struct vmbus_channel *channel);
-int VmbusChildDeviceAdd(struct hv_device *Device);
+int vmbus_child_dev_add(struct hv_device *device);
int vmbus_child_device_register(struct hv_device *root_device_obj,
struct hv_device *child_device_obj);
void vmbus_child_device_unregister(struct hv_device *device_obj);
@@ -115,20 +115,20 @@ void vmbus_child_device_unregister(struct hv_device *device_obj);
/* VmbusChildDeviceDestroy( */
/* struct hv_device *); */
-struct vmbus_channel *GetChannelFromRelId(u32 relId);
+struct vmbus_channel *relid2channel(u32 relid);
/* Connection interface */
-int VmbusConnect(void);
+int vmbus_connect(void);
-int VmbusDisconnect(void);
+int vmbus_disconnect(void);
-int VmbusPostMessage(void *buffer, size_t bufSize);
+int vmbus_post_msg(void *buffer, size_t buflen);
-int VmbusSetEvent(u32 childRelId);
+int vmbus_set_event(u32 child_relid);
-void VmbusOnEvents(void);
+void vmbus_on_event(void);
#endif /* _VMBUS_PRIVATE_H_ */