]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/hv/channel.c
Merge branch 'master' into tk71
[mv-sheeva.git] / drivers / staging / hv / channel.c
index fece30c303a54aeae1a5b9c326f4a1f1fad3a957..45a627d77b41786cc520974fd0cc7258657a2d85 100644 (file)
 #include "vmbus_private.h"
 
 /* Internal routines */
-static int VmbusChannelCreateGpadlHeader(
-       void *Kbuffer,  /* must be phys and virt contiguous */
-       u32 Size,       /* page-size multiple */
-       struct vmbus_channel_msginfo **msgInfo,
-       u32 *MessageCount);
-static void DumpVmbusChannel(struct vmbus_channel *channel);
-static void VmbusChannelSetEvent(struct vmbus_channel *channel);
+static int create_gpadl_header(
+       void *kbuffer,  /* must be phys and virt contiguous */
+       u32 size,       /* page-size multiple */
+       struct vmbus_channel_msginfo **msginfo,
+       u32 *messagecount);
+static void dump_vmbus_channel(struct vmbus_channel *channel);
+static void vmbus_setevent(struct vmbus_channel *channel);
 
 
 #if 0
@@ -43,52 +43,52 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
        int j = 0;
 
        DPRINT_DBG(VMBUS, "monitorPage - %p, trigger state - %d",
-                  MonitorPage, MonitorPage->TriggerState);
+                  MonitorPage, MonitorPage->trigger_state);
 
        for (i = 0; i < 4; i++)
                DPRINT_DBG(VMBUS, "trigger group (%d) - %llx", i,
-                          MonitorPage->TriggerGroup[i].AsUINT64);
+                          MonitorPage->trigger_group[i].as_uint64);
 
        for (i = 0; i < 4; i++) {
                for (j = 0; j < 32; j++) {
                        DPRINT_DBG(VMBUS, "latency (%d)(%d) - %llx", i, j,
-                                  MonitorPage->Latency[i][j]);
+                                  MonitorPage->latency[i][j]);
                }
        }
        for (i = 0; i < 4; i++) {
                for (j = 0; j < 32; j++) {
                        DPRINT_DBG(VMBUS, "param-conn id (%d)(%d) - %d", i, j,
-                              MonitorPage->Parameter[i][j].ConnectionId.Asu32);
+                              MonitorPage->parameter[i][j].connectionid.asu32);
                        DPRINT_DBG(VMBUS, "param-flag (%d)(%d) - %d", i, j,
-                               MonitorPage->Parameter[i][j].FlagNumber);
+                               MonitorPage->parameter[i][j].flag_number);
                }
        }
 }
 #endif
 
 /*
- * VmbusChannelSetEvent - Trigger an event notification on the specified
+ * vmbus_setevent- Trigger an event notification on the specified
  * channel.
  */
-static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
+static void vmbus_setevent(struct vmbus_channel *channel)
 {
-       struct hv_monitor_page *monitorPage;
+       struct hv_monitor_page *monitorpage;
 
-       if (Channel->OfferMsg.MonitorAllocated) {
+       if (channel->offermsg.monitor_allocated) {
                /* Each u32 represents 32 channels */
-               set_bit(Channel->OfferMsg.ChildRelId & 31,
+               set_bit(channel->offermsg.child_relid & 31,
                        (unsigned long *) gVmbusConnection.SendInterruptPage +
-                       (Channel->OfferMsg.ChildRelId >> 5));
+                       (channel->offermsg.child_relid >> 5));
 
-               monitorPage = gVmbusConnection.MonitorPages;
-               monitorPage++; /* Get the child to parent monitor page */
+               monitorpage = gVmbusConnection.MonitorPages;
+               monitorpage++; /* Get the child to parent monitor page */
 
-               set_bit(Channel->MonitorBit,
-                       (unsigned long *)&monitorPage->TriggerGroup
-                                       [Channel->MonitorGroup].Pending);
+               set_bit(channel->monitor_bit,
+                       (unsigned long *)&monitorpage->trigger_group
+                                       [channel->monitor_grp].pending);
 
        } else {
-               VmbusSetEvent(Channel->OfferMsg.ChildRelId);
+               VmbusSetEvent(channel->offermsg.child_relid);
        }
 }
 
@@ -97,74 +97,74 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
 {
        struct hv_monitor_page *monitorPage;
 
-       if (Channel->OfferMsg.MonitorAllocated) {
+       if (Channel->offermsg.monitor_allocated) {
                /* Each u32 represents 32 channels */
-               clear_bit(Channel->OfferMsg.ChildRelId & 31,
+               clear_bit(Channel->offermsg.child_relid & 31,
                          (unsigned long *)gVmbusConnection.SendInterruptPage +
-                         (Channel->OfferMsg.ChildRelId >> 5));
+                         (Channel->offermsg.child_relid >> 5));
 
                monitorPage =
                        (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
                monitorPage++; /* Get the child to parent monitor page */
 
-               clear_bit(Channel->MonitorBit,
-                         (unsigned long *)&monitorPage->TriggerGroup
-                                       [Channel->MonitorGroup].Pending);
+               clear_bit(Channel->monitor_bit,
+                         (unsigned long *)&monitorPage->trigger_group
+                                       [Channel->monitor_grp].Pending);
        }
 }
 
 #endif
 /*
- * VmbusChannelGetDebugInfo -Retrieve various channel debug info
+ * vmbus_get_debug_info -Retrieve various channel debug info
  */
-void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
-                             struct vmbus_channel_debug_info *DebugInfo)
+void vmbus_get_debug_info(struct vmbus_channel *channel,
+                             struct vmbus_channel_debug_info *debuginfo)
 {
-       struct hv_monitor_page *monitorPage;
-       u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
-       u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
+       struct hv_monitor_page *monitorpage;
+       u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
+       u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
        /* u32 monitorBit       = 1 << monitorOffset; */
 
-       DebugInfo->RelId = Channel->OfferMsg.ChildRelId;
-       DebugInfo->State = Channel->State;
-       memcpy(&DebugInfo->InterfaceType,
-              &Channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
-       memcpy(&DebugInfo->InterfaceInstance,
-              &Channel->OfferMsg.Offer.InterfaceInstance,
+       debuginfo->relid = channel->offermsg.child_relid;
+       debuginfo->state = channel->state;
+       memcpy(&debuginfo->interfacetype,
+              &channel->offermsg.offer.InterfaceType, sizeof(struct hv_guid));
+       memcpy(&debuginfo->interface_instance,
+              &channel->offermsg.offer.InterfaceInstance,
               sizeof(struct hv_guid));
 
-       monitorPage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
+       monitorpage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
 
-       DebugInfo->MonitorId = Channel->OfferMsg.MonitorId;
+       debuginfo->monitorid = channel->offermsg.monitorid;
 
-       DebugInfo->ServerMonitorPending =
-                       monitorPage->TriggerGroup[monitorGroup].Pending;
-       DebugInfo->ServerMonitorLatency =
-                       monitorPage->Latency[monitorGroup][monitorOffset];
-       DebugInfo->ServerMonitorConnectionId =
-                       monitorPage->Parameter[monitorGroup]
-                                             [monitorOffset].ConnectionId.u.Id;
+       debuginfo->servermonitor_pending =
+                       monitorpage->trigger_group[monitor_group].pending;
+       debuginfo->servermonitor_latency =
+                       monitorpage->latency[monitor_group][monitor_offset];
+       debuginfo->servermonitor_connectionid =
+                       monitorpage->parameter[monitor_group]
+                                       [monitor_offset].connectionid.u.id;
 
-       monitorPage++;
+       monitorpage++;
 
-       DebugInfo->ClientMonitorPending =
-                       monitorPage->TriggerGroup[monitorGroup].Pending;
-       DebugInfo->ClientMonitorLatency =
-                       monitorPage->Latency[monitorGroup][monitorOffset];
-       DebugInfo->ClientMonitorConnectionId =
-                       monitorPage->Parameter[monitorGroup]
-                                             [monitorOffset].ConnectionId.u.Id;
+       debuginfo->clientmonitor_pending =
+                       monitorpage->trigger_group[monitor_group].pending;
+       debuginfo->clientmonitor_latency =
+                       monitorpage->latency[monitor_group][monitor_offset];
+       debuginfo->clientmonitor_connectionid =
+                       monitorpage->parameter[monitor_group]
+                                       [monitor_offset].connectionid.u.id;
 
-       RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound);
-       RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound);
+       ringbuffer_get_debuginfo(&channel->inbound, &debuginfo->inbound);
+       ringbuffer_get_debuginfo(&channel->outbound, &debuginfo->outbound);
 }
 
 /*
- * VmbusChannelOpen - Open the specified channel.
+ * vmbus_open - Open the specified channel.
  */
-int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
-                    u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
-                    void (*OnChannelCallback)(void *context), void *Context)
+int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
+                    u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
+                    void (*onchannelcallback)(void *context), void *context)
 {
        struct vmbus_channel_open_channel *openMsg;
        struct vmbus_channel_msginfo *openInfo = NULL;
@@ -176,30 +176,30 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
        /* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
        /* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
 
-       NewChannel->OnChannelCallback = OnChannelCallback;
-       NewChannel->ChannelCallbackContext = Context;
+       newchannel->onchannel_callback = onchannelcallback;
+       newchannel->channel_callback_context = context;
 
        /* Allocate the ring buffer */
-       out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize)
+       out = osd_page_alloc((send_ringbuffer_size + recv_ringbuffer_size)
                             >> PAGE_SHIFT);
        if (!out)
                return -ENOMEM;
 
        /* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */
 
-       in = (void *)((unsigned long)out + SendRingBufferSize);
+       in = (void *)((unsigned long)out + send_ringbuffer_size);
 
-       NewChannel->RingBufferPages = out;
-       NewChannel->RingBufferPageCount = (SendRingBufferSize +
-                                          RecvRingBufferSize) >> PAGE_SHIFT;
+       newchannel->ringbuffer_pages = out;
+       newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
+                                          recv_ringbuffer_size) >> PAGE_SHIFT;
 
-       ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
+       ret = ringbuffer_init(&newchannel->outbound, out, send_ringbuffer_size);
        if (ret != 0) {
                err = ret;
                goto errorout;
        }
 
-       ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
+       ret = ringbuffer_init(&newchannel->inbound, in, recv_ringbuffer_size);
        if (ret != 0) {
                err = ret;
                goto errorout;
@@ -208,15 +208,15 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
 
        /* Establish the gpadl for the ring buffer */
        DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
-                  NewChannel);
+                  newchannel);
 
-       NewChannel->RingBufferGpadlHandle = 0;
+       newchannel->ringbuffer_gpadlhandle = 0;
 
-       ret = VmbusChannelEstablishGpadl(NewChannel,
-                                        NewChannel->Outbound.RingBuffer,
-                                        SendRingBufferSize +
-                                        RecvRingBufferSize,
-                                        &NewChannel->RingBufferGpadlHandle);
+       ret = vmbus_establish_gpadl(newchannel,
+                                        newchannel->outbound.ring_buffer,
+                                        send_ringbuffer_size +
+                                        recv_ringbuffer_size,
+                                        &newchannel->ringbuffer_gpadlhandle);
 
        if (ret != 0) {
                err = ret;
@@ -225,13 +225,13 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
 
        DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p "
                   "size %d recv ring %p size %d, downstreamoffset %d>",
-                  NewChannel, NewChannel->OfferMsg.ChildRelId,
-                  NewChannel->RingBufferGpadlHandle,
-                  NewChannel->Outbound.RingBuffer,
-                  NewChannel->Outbound.RingSize,
-                  NewChannel->Inbound.RingBuffer,
-                  NewChannel->Inbound.RingSize,
-                  SendRingBufferSize);
+                  newchannel, newchannel->offermsg.child_relid,
+                  newchannel->ringbuffer_gpadlhandle,
+                  newchannel->outbound.ring_buffer,
+                  newchannel->outbound.ring_size,
+                  newchannel->inbound.ring_buffer,
+                  newchannel->inbound.ring_size,
+                  send_ringbuffer_size);
 
        /* Create and init the channel open message */
        openInfo = kmalloc(sizeof(*openInfo) +
@@ -242,31 +242,31 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
                goto errorout;
        }
 
-       openInfo->WaitEvent = osd_WaitEventCreate();
-       if (!openInfo->WaitEvent) {
+       openInfo->waitevent = osd_waitevent_create();
+       if (!openInfo->waitevent) {
                err = -ENOMEM;
                goto errorout;
        }
 
-       openMsg = (struct vmbus_channel_open_channel *)openInfo->Msg;
-       openMsg->Header.MessageType = ChannelMessageOpenChannel;
-       openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; /* FIXME */
-       openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId;
-       openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle;
-       openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >>
+       openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
+       openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
+       openMsg->openid = newchannel->offermsg.child_relid; /* FIXME */
+       openMsg->child_relid = newchannel->offermsg.child_relid;
+       openMsg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
+       openMsg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
                                                  PAGE_SHIFT;
-       openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */
+       openMsg->server_contextarea_gpadlhandle = 0; /* TODO */
 
-       if (UserDataLen > MAX_USER_DEFINED_BYTES) {
+       if (userdatalen > MAX_USER_DEFINED_BYTES) {
                err = -EINVAL;
                goto errorout;
        }
 
-       if (UserDataLen)
-               memcpy(openMsg->UserData, UserData, UserDataLen);
+       if (userdatalen)
+               memcpy(openMsg->userdata, userdata, userdatalen);
 
        spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
-       list_add_tail(&openInfo->MsgListEntry,
+       list_add_tail(&openInfo->msglistentry,
                      &gVmbusConnection.ChannelMsgList);
        spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
 
@@ -280,339 +280,344 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
        }
 
        /* FIXME: Need to time-out here */
-       osd_WaitEventWait(openInfo->WaitEvent);
+       osd_waitevent_wait(openInfo->waitevent);
 
-       if (openInfo->Response.OpenResult.Status == 0)
-               DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel);
+       if (openInfo->response.open_result.status == 0)
+               DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
        else
                DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
-                           NewChannel, openInfo->Response.OpenResult.Status);
+                           newchannel, openInfo->response.open_result.status);
 
 Cleanup:
        spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
-       list_del(&openInfo->MsgListEntry);
+       list_del(&openInfo->msglistentry);
        spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
 
-       kfree(openInfo->WaitEvent);
+       kfree(openInfo->waitevent);
        kfree(openInfo);
        return 0;
 
 errorout:
-       RingBufferCleanup(&NewChannel->Outbound);
-       RingBufferCleanup(&NewChannel->Inbound);
-       osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize)
+       ringbuffer_cleanup(&newchannel->outbound);
+       ringbuffer_cleanup(&newchannel->inbound);
+       osd_page_free(out, (send_ringbuffer_size + recv_ringbuffer_size)
                     >> PAGE_SHIFT);
        kfree(openInfo);
        return err;
 }
+EXPORT_SYMBOL_GPL(vmbus_open);
 
 /*
- * DumpGpadlBody - Dump the gpadl body message to the console for
+ * dump_gpadl_body - Dump the gpadl body message to the console for
  * debugging purposes.
  */
-static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len)
+static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len)
 {
        int i;
-       int pfnCount;
+       int pfncount;
 
-       pfnCount = (Len - sizeof(struct vmbus_channel_gpadl_body)) /
+       pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
                   sizeof(u64);
-       DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", Len, pfnCount);
+       DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
 
-       for (i = 0; i < pfnCount; i++)
+       for (i = 0; i < pfncount; i++)
                DPRINT_DBG(VMBUS, "gpadl body  - %d) pfn %llu",
-                          i, Gpadl->Pfn[i]);
+                          i, gpadl->pfn[i]);
 }
 
 /*
- * DumpGpadlHeader - Dump the gpadl header message to the console for
+ * dump_gpadl_header - Dump the gpadl header message to the console for
  * debugging purposes.
  */
-static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl)
+static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl)
 {
        int i, j;
-       int pageCount;
+       int pagecount;
 
        DPRINT_DBG(VMBUS,
                   "gpadl header - relid %d, range count %d, range buflen %d",
-                  Gpadl->ChildRelId, Gpadl->RangeCount, Gpadl->RangeBufLen);
-       for (i = 0; i < Gpadl->RangeCount; i++) {
-               pageCount = Gpadl->Range[i].ByteCount >> PAGE_SHIFT;
-               pageCount = (pageCount > 26) ? 26 : pageCount;
+                  gpadl->child_relid, gpadl->rangecount, gpadl->range_buflen);
+       for (i = 0; i < gpadl->rangecount; i++) {
+               pagecount = gpadl->range[i].ByteCount >> 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].ByteCount,
+                          gpadl->range[i].ByteOffset, pagecount);
 
-               for (j = 0; j < pageCount; j++)
+               for (j = 0; j < pagecount; j++)
                        DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
-                                  Gpadl->Range[i].PfnArray[j]);
+                                  gpadl->range[i].PfnArray[j]);
        }
 }
 
 /*
- * VmbusChannelCreateGpadlHeader - Creates a gpadl for the specified buffer
+ * create_gpadl_header - Creates a gpadl for the specified buffer
  */
-static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
-                                        struct vmbus_channel_msginfo **MsgInfo,
-                                        u32 *MessageCount)
+static int create_gpadl_header(void *kbuffer, u32 size,
+                                        struct vmbus_channel_msginfo **msginfo,
+                                        u32 *messagecount)
 {
        int i;
-       int pageCount;
+       int pagecount;
        unsigned long long pfn;
-       struct vmbus_channel_gpadl_header *gpaHeader;
-       struct vmbus_channel_gpadl_body *gpadlBody;
-       struct vmbus_channel_msginfo *msgHeader;
-       struct vmbus_channel_msginfo *msgBody = NULL;
-       u32 msgSize;
+       struct vmbus_channel_gpadl_header *gpadl_header;
+       struct vmbus_channel_gpadl_body *gpadl_body;
+       struct vmbus_channel_msginfo *msgheader;
+       struct vmbus_channel_msginfo *msgbody = NULL;
+       u32 msgsize;
 
-       int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize;
+       int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
 
        /* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */
        /* ASSERT((Size & (PAGE_SIZE-1)) == 0); */
 
-       pageCount = Size >> PAGE_SHIFT;
-       pfn = virt_to_phys(Kbuffer) >> PAGE_SHIFT;
+       pagecount = size >> PAGE_SHIFT;
+       pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT;
 
        /* do we need a gpadl body msg */
-       pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+       pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
                  sizeof(struct vmbus_channel_gpadl_header) -
                  sizeof(struct gpa_range);
-       pfnCount = pfnSize / sizeof(u64);
+       pfncount = pfnsize / sizeof(u64);
 
-       if (pageCount > pfnCount) {
+       if (pagecount > pfncount) {
                /* we need a gpadl body */
                /* fill in the header */
-               msgSize = sizeof(struct vmbus_channel_msginfo) +
+               msgsize = sizeof(struct vmbus_channel_msginfo) +
                          sizeof(struct vmbus_channel_gpadl_header) +
-                         sizeof(struct gpa_range) + pfnCount * sizeof(u64);
-               msgHeader =  kzalloc(msgSize, GFP_KERNEL);
-               if (!msgHeader)
+                         sizeof(struct gpa_range) + pfncount * sizeof(u64);
+               msgheader =  kzalloc(msgsize, GFP_KERNEL);
+               if (!msgheader)
                        goto nomem;
 
-               INIT_LIST_HEAD(&msgHeader->SubMsgList);
-               msgHeader->MessageSize = msgSize;
+               INIT_LIST_HEAD(&msgheader->submsglist);
+               msgheader->msgsize = msgsize;
 
-               gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
-               gpaHeader->RangeCount = 1;
-               gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
-                                        pageCount * sizeof(u64);
-               gpaHeader->Range[0].ByteOffset = 0;
-               gpaHeader->Range[0].ByteCount = Size;
-               for (i = 0; i < pfnCount; i++)
-                       gpaHeader->Range[0].PfnArray[i] = pfn+i;
-               *MsgInfo = msgHeader;
-               *MessageCount = 1;
+               gpadl_header = (struct vmbus_channel_gpadl_header *)
+                       msgheader->msg;
+               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;
+               for (i = 0; i < pfncount; i++)
+                       gpadl_header->range[0].PfnArray[i] = pfn+i;
+               *msginfo = msgheader;
+               *messagecount = 1;
 
-               pfnSum = pfnCount;
-               pfnLeft = pageCount - pfnCount;
+               pfnsum = pfncount;
+               pfnleft = pagecount - pfncount;
 
                /* how many pfns can we fit */
-               pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+               pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
                          sizeof(struct vmbus_channel_gpadl_body);
-               pfnCount = pfnSize / sizeof(u64);
+               pfncount = pfnsize / sizeof(u64);
 
                /* fill in the body */
-               while (pfnLeft) {
-                       if (pfnLeft > pfnCount)
-                               pfnCurr = pfnCount;
+               while (pfnleft) {
+                       if (pfnleft > pfncount)
+                               pfncurr = pfncount;
                        else
-                               pfnCurr = pfnLeft;
+                               pfncurr = pfnleft;
 
-                       msgSize = sizeof(struct vmbus_channel_msginfo) +
+                       msgsize = sizeof(struct vmbus_channel_msginfo) +
                                  sizeof(struct vmbus_channel_gpadl_body) +
-                                 pfnCurr * sizeof(u64);
-                       msgBody = kzalloc(msgSize, GFP_KERNEL);
+                                 pfncurr * sizeof(u64);
+                       msgbody = kzalloc(msgsize, GFP_KERNEL);
                        /* FIXME: we probably need to more if this fails */
-                       if (!msgBody)
+                       if (!msgbody)
                                goto nomem;
-                       msgBody->MessageSize = msgSize;
-                       (*MessageCount)++;
-                       gpadlBody =
-                               (struct vmbus_channel_gpadl_body *)msgBody->Msg;
+                       msgbody->msgsize = msgsize;
+                       (*messagecount)++;
+                       gpadl_body =
+                               (struct vmbus_channel_gpadl_body *)msgbody->msg;
 
                        /*
                         * FIXME:
                         * Gpadl is u32 and we are using a pointer which could
                         * be 64-bit
                         */
-                       /* gpadlBody->Gpadl = kbuffer; */
-                       for (i = 0; i < pfnCurr; i++)
-                               gpadlBody->Pfn[i] = pfn + pfnSum + i;
+                       /* gpadl_body->Gpadl = kbuffer; */
+                       for (i = 0; i < pfncurr; i++)
+                               gpadl_body->pfn[i] = pfn + pfnsum + i;
 
                        /* add to msg header */
-                       list_add_tail(&msgBody->MsgListEntry,
-                                     &msgHeader->SubMsgList);
-                       pfnSum += pfnCurr;
-                       pfnLeft -= pfnCurr;
+                       list_add_tail(&msgbody->msglistentry,
+                                     &msgheader->submsglist);
+                       pfnsum += pfncurr;
+                       pfnleft -= pfncurr;
                }
        } else {
                /* everything fits in a header */
-               msgSize = sizeof(struct vmbus_channel_msginfo) +
+               msgsize = sizeof(struct vmbus_channel_msginfo) +
                          sizeof(struct vmbus_channel_gpadl_header) +
-                         sizeof(struct gpa_range) + pageCount * sizeof(u64);
-               msgHeader = kzalloc(msgSize, GFP_KERNEL);
-               if (msgHeader == NULL)
+                         sizeof(struct gpa_range) + pagecount * sizeof(u64);
+               msgheader = kzalloc(msgsize, GFP_KERNEL);
+               if (msgheader == NULL)
                        goto nomem;
-               msgHeader->MessageSize = msgSize;
-
-               gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
-               gpaHeader->RangeCount = 1;
-               gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
-                                        pageCount * sizeof(u64);
-               gpaHeader->Range[0].ByteOffset = 0;
-               gpaHeader->Range[0].ByteCount = Size;
-               for (i = 0; i < pageCount; i++)
-                       gpaHeader->Range[0].PfnArray[i] = pfn+i;
-
-               *MsgInfo = msgHeader;
-               *MessageCount = 1;
+               msgheader->msgsize = msgsize;
+
+               gpadl_header = (struct vmbus_channel_gpadl_header *)
+                       msgheader->msg;
+               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;
+               for (i = 0; i < pagecount; i++)
+                       gpadl_header->range[0].PfnArray[i] = pfn+i;
+
+               *msginfo = msgheader;
+               *messagecount = 1;
        }
 
        return 0;
 nomem:
-       kfree(msgHeader);
-       kfree(msgBody);
+       kfree(msgheader);
+       kfree(msgbody);
        return -ENOMEM;
 }
 
 /*
- * VmbusChannelEstablishGpadl - Estabish a GPADL for the specified buffer
+ * vmbus_establish_gpadl - Estabish a GPADL for the specified buffer
  *
- * @Channel: a channel
- * @Kbuffer: from kmalloc
- * @Size: page-size multiple
- * @GpadlHandle: some funky thing
+ * @channel: a channel
+ * @kbuffer: from kmalloc
+ * @size: page-size multiple
+ * @gpadl_handle: some funky thing
  */
-int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
-                              u32 Size, u32 *GpadlHandle)
+int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
+                              u32 size, u32 *gpadl_handle)
 {
-       struct vmbus_channel_gpadl_header *gpadlMsg;
-       struct vmbus_channel_gpadl_body *gpadlBody;
+       struct vmbus_channel_gpadl_header *gpadlmsg;
+       struct vmbus_channel_gpadl_body *gpadl_body;
        /* struct vmbus_channel_gpadl_created *gpadlCreated; */
-       struct vmbus_channel_msginfo *msgInfo = NULL;
-       struct vmbus_channel_msginfo *subMsgInfo;
-       u32 msgCount;
+       struct vmbus_channel_msginfo *msginfo = NULL;
+       struct vmbus_channel_msginfo *submsginfo;
+       u32 msgcount;
        struct list_head *curr;
-       u32 nextGpadlHandle;
+       u32 next_gpadl_handle;
        unsigned long flags;
        int ret = 0;
 
-       nextGpadlHandle = atomic_read(&gVmbusConnection.NextGpadlHandle);
+       next_gpadl_handle = atomic_read(&gVmbusConnection.NextGpadlHandle);
        atomic_inc(&gVmbusConnection.NextGpadlHandle);
 
-       ret = VmbusChannelCreateGpadlHeader(Kbuffer, Size, &msgInfo, &msgCount);
+       ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
        if (ret)
                return ret;
 
-       msgInfo->WaitEvent = osd_WaitEventCreate();
-       if (!msgInfo->WaitEvent) {
+       msginfo->waitevent = osd_waitevent_create();
+       if (!msginfo->waitevent) {
                ret = -ENOMEM;
                goto Cleanup;
        }
 
-       gpadlMsg = (struct vmbus_channel_gpadl_header *)msgInfo->Msg;
-       gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader;
-       gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId;
-       gpadlMsg->Gpadl = nextGpadlHandle;
+       gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg;
+       gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER;
+       gpadlmsg->child_relid = channel->offermsg.child_relid;
+       gpadlmsg->gpadl = next_gpadl_handle;
 
-       DumpGpadlHeader(gpadlMsg);
+       dump_gpadl_header(gpadlmsg);
 
        spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
-       list_add_tail(&msgInfo->MsgListEntry,
+       list_add_tail(&msginfo->msglistentry,
                      &gVmbusConnection.ChannelMsgList);
 
        spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
        DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
-                  Kbuffer, Size, msgCount);
+                  kbuffer, size, msgcount);
 
        DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
-                  msgInfo->MessageSize - sizeof(*msgInfo));
+                  msginfo->msgsize - sizeof(*msginfo));
 
-       ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize -
-                              sizeof(*msgInfo));
+       ret = VmbusPostMessage(gpadlmsg, msginfo->msgsize -
+                              sizeof(*msginfo));
        if (ret != 0) {
                DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
                goto Cleanup;
        }
 
-       if (msgCount > 1) {
-               list_for_each(curr, &msgInfo->SubMsgList) {
+       if (msgcount > 1) {
+               list_for_each(curr, &msginfo->submsglist) {
 
                        /* FIXME: should this use list_entry() instead ? */
-                       subMsgInfo = (struct vmbus_channel_msginfo *)curr;
-                       gpadlBody =
-                            (struct vmbus_channel_gpadl_body *)subMsgInfo->Msg;
+                       submsginfo = (struct vmbus_channel_msginfo *)curr;
+                       gpadl_body =
+                            (struct vmbus_channel_gpadl_body *)submsginfo->msg;
 
-                       gpadlBody->Header.MessageType = ChannelMessageGpadlBody;
-                       gpadlBody->Gpadl = nextGpadlHandle;
+                       gpadl_body->header.msgtype =
+                               CHANNELMSG_GPADL_BODY;
+                       gpadl_body->gpadl = next_gpadl_handle;
 
                        DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
-                                  subMsgInfo->MessageSize -
-                                  sizeof(*subMsgInfo));
-
-                       DumpGpadlBody(gpadlBody, subMsgInfo->MessageSize -
-                                     sizeof(*subMsgInfo));
-                       ret = VmbusPostMessage(gpadlBody,
-                                              subMsgInfo->MessageSize -
-                                              sizeof(*subMsgInfo));
+                                  submsginfo->msgsize -
+                                  sizeof(*submsginfo));
+
+                       dump_gpadl_body(gpadl_body, submsginfo->msgsize -
+                                     sizeof(*submsginfo));
+                       ret = VmbusPostMessage(gpadl_body,
+                                              submsginfo->msgsize -
+                                              sizeof(*submsginfo));
                        if (ret != 0)
                                goto Cleanup;
 
                }
        }
-       osd_WaitEventWait(msgInfo->WaitEvent);
+       osd_waitevent_wait(msginfo->waitevent);
 
        /* At this point, we received the gpadl created msg */
        DPRINT_DBG(VMBUS, "Received GPADL created "
                   "(relid %d, status %d handle %x)",
-                  Channel->OfferMsg.ChildRelId,
-                  msgInfo->Response.GpadlCreated.CreationStatus,
-                  gpadlMsg->Gpadl);
+                  channel->offermsg.child_relid,
+                  msginfo->response.gpadl_created.creation_status,
+                  gpadlmsg->gpadl);
 
-       *GpadlHandle = gpadlMsg->Gpadl;
+       *gpadl_handle = gpadlmsg->gpadl;
 
 Cleanup:
        spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
-       list_del(&msgInfo->MsgListEntry);
+       list_del(&msginfo->msglistentry);
        spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
 
-       kfree(msgInfo->WaitEvent);
-       kfree(msgInfo);
+       kfree(msginfo->waitevent);
+       kfree(msginfo);
        return ret;
 }
+EXPORT_SYMBOL_GPL(vmbus_establish_gpadl);
 
 /*
- * VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
+ * vmbus_teardown_gpadl -Teardown the specified GPADL handle
  */
-int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
+int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 {
        struct vmbus_channel_gpadl_teardown *msg;
        struct vmbus_channel_msginfo *info;
        unsigned long flags;
        int ret;
 
-       /* ASSERT(GpadlHandle != 0); */
+       /* ASSERT(gpadl_handle != 0); */
 
        info = kmalloc(sizeof(*info) +
                       sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
-       info->WaitEvent = osd_WaitEventCreate();
-       if (!info->WaitEvent) {
+       info->waitevent = osd_waitevent_create();
+       if (!info->waitevent) {
                kfree(info);
                return -ENOMEM;
        }
 
-       msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
+       msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
 
-       msg->Header.MessageType = ChannelMessageGpadlTeardown;
-       msg->ChildRelId = Channel->OfferMsg.ChildRelId;
-       msg->Gpadl = GpadlHandle;
+       msg->header.msgtype = CHANNELMSG_GPADL_TEARDOWN;
+       msg->child_relid = channel->offermsg.child_relid;
+       msg->gpadl = gpadl_handle;
 
        spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
-       list_add_tail(&info->MsgListEntry,
+       list_add_tail(&info->msglistentry,
                      &gVmbusConnection.ChannelMsgList);
        spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
 
@@ -623,22 +628,23 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
                /* something... */
        }
 
-       osd_WaitEventWait(info->WaitEvent);
+       osd_waitevent_wait(info->waitevent);
 
        /* Received a torndown response */
        spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
-       list_del(&info->MsgListEntry);
+       list_del(&info->msglistentry);
        spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
 
-       kfree(info->WaitEvent);
+       kfree(info->waitevent);
        kfree(info);
        return ret;
 }
+EXPORT_SYMBOL_GPL(vmbus_teardown_gpadl);
 
 /*
- * VmbusChannelClose - Close the specified channel
+ * vmbus_close - Close the specified channel
  */
-void VmbusChannelClose(struct vmbus_channel *Channel)
+void vmbus_close(struct vmbus_channel *channel)
 {
        struct vmbus_channel_close_channel *msg;
        struct vmbus_channel_msginfo *info;
@@ -646,8 +652,8 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
        int ret;
 
        /* Stop callback and cancel the timer asap */
-       Channel->OnChannelCallback = NULL;
-       del_timer_sync(&Channel->poll_timer);
+       channel->onchannel_callback = NULL;
+       del_timer_sync(&channel->poll_timer);
 
        /* Send a closing message */
        info = kmalloc(sizeof(*info) +
@@ -657,11 +663,11 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
        if (!info)
                return;
 
-       /* info->waitEvent = osd_WaitEventCreate(); */
+       /* info->waitEvent = osd_waitevent_create(); */
 
-       msg = (struct vmbus_channel_close_channel *)info->Msg;
-       msg->Header.MessageType = ChannelMessageCloseChannel;
-       msg->ChildRelId = Channel->OfferMsg.ChildRelId;
+       msg = (struct vmbus_channel_close_channel *)info->msg;
+       msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
+       msg->child_relid = channel->offermsg.child_relid;
 
        ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
        if (ret != 0) {
@@ -670,17 +676,17 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
        }
 
        /* Tear down the gpadl for the channel's ring buffer */
-       if (Channel->RingBufferGpadlHandle)
-               VmbusChannelTeardownGpadl(Channel,
-                                         Channel->RingBufferGpadlHandle);
+       if (channel->ringbuffer_gpadlhandle)
+               vmbus_teardown_gpadl(channel,
+                                         channel->ringbuffer_gpadlhandle);
 
        /* TODO: Send a msg to release the childRelId */
 
        /* Cleanup the ring buffers for this channel */
-       RingBufferCleanup(&Channel->Outbound);
-       RingBufferCleanup(&Channel->Inbound);
+       ringbuffer_cleanup(&channel->outbound);
+       ringbuffer_cleanup(&channel->inbound);
 
-       osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+       osd_page_free(channel->ringbuffer_pages, channel->ringbuffer_pagecount);
 
        kfree(info);
 
@@ -690,231 +696,237 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
         * caller will free the channel
         */
 
-       if (Channel->State == CHANNEL_OPEN_STATE) {
+       if (channel->state == CHANNEL_OPEN_STATE) {
                spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
-               list_del(&Channel->ListEntry);
+               list_del(&channel->listentry);
                spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
 
-               FreeVmbusChannel(Channel);
+               free_channel(channel);
        }
 }
+EXPORT_SYMBOL_GPL(vmbus_close);
 
 /**
- * VmbusChannelSendPacket() - Send the specified buffer on the given channel
- * @Channel: Pointer to vmbus_channel structure.
- * @Buffer: Pointer to the buffer you want to receive the data into.
- * @BufferLen: Maximum size of what the the buffer will hold
- * @RequestId: Identifier of the request
- * @vmbus_packet_type: Type of packet that is being send e.g. negotiate, time
+ * vmbus_sendpacket() - Send the specified buffer on the given channel
+ * @channel: Pointer to vmbus_channel structure.
+ * @buffer: Pointer to the buffer you want to receive the data into.
+ * @bufferlen: Maximum size of what the the buffer will hold
+ * @requestid: Identifier of the request
+ * @type: Type of packet that is being send e.g. negotiate, time
  * packet etc.
  *
- * Sends data in @Buffer directly to hyper-v via the vmbus
+ * Sends data in @buffer directly to hyper-v via the vmbus
  * This will send the data unparsed to hyper-v.
  *
  * Mainly used by Hyper-V drivers.
  */
-int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer,
-                          u32 BufferLen, u64 RequestId,
-                          enum vmbus_packet_type Type, u32 Flags)
+int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
+                          u32 bufferlen, u64 requestid,
+                          enum vmbus_packet_type type, u32 flags)
 {
        struct vmpacket_descriptor desc;
-       u32 packetLen = sizeof(struct vmpacket_descriptor) + BufferLen;
-       u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
-       struct scatterlist bufferList[3];
-       u64 alignedData = 0;
+       u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen;
+       u32 packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
+       struct scatterlist bufferlist[3];
+       u64 aligned_data = 0;
        int ret;
 
        DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
-                  Channel, Buffer, BufferLen);
+                  channel, buffer, bufferlen);
 
-       DumpVmbusChannel(Channel);
+       dump_vmbus_channel(channel);
 
        /* 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)(packetLenAligned >> 3);
-       desc.TransactionId = RequestId;
+       desc.Length8 = (u16)(packetlen_aligned >> 3);
+       desc.TransactionId = requestid;
 
-       sg_init_table(bufferList, 3);
-       sg_set_buf(&bufferList[0], &desc, sizeof(struct vmpacket_descriptor));
-       sg_set_buf(&bufferList[1], Buffer, BufferLen);
-       sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+       sg_init_table(bufferlist, 3);
+       sg_set_buf(&bufferlist[0], &desc, sizeof(struct vmpacket_descriptor));
+       sg_set_buf(&bufferlist[1], buffer, bufferlen);
+       sg_set_buf(&bufferlist[2], &aligned_data,
+                  packetlen_aligned - packetlen);
 
-       ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+       ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
 
        /* TODO: We should determine if this is optional */
-       if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-               VmbusChannelSetEvent(Channel);
+       if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+               vmbus_setevent(channel);
 
        return ret;
 }
-EXPORT_SYMBOL(VmbusChannelSendPacket);
+EXPORT_SYMBOL(vmbus_sendpacket);
 
 /*
- * VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer
+ * vmbus_sendpacket_pagebuffer - Send a range of single-page buffer
  * packets using a GPADL Direct packet type.
  */
-int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
-                                    struct hv_page_buffer PageBuffers[],
-                                    u32 PageCount, void *Buffer, u32 BufferLen,
-                                    u64 RequestId)
+int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
+                                    struct hv_page_buffer pagebuffers[],
+                                    u32 pagecount, void *buffer, u32 bufferlen,
+                                    u64 requestid)
 {
        int ret;
        int i;
-       struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER desc;
-       u32 descSize;
-       u32 packetLen;
-       u32 packetLenAligned;
-       struct scatterlist bufferList[3];
-       u64 alignedData = 0;
-
-       if (PageCount > MAX_PAGE_BUFFER_COUNT)
+       struct vmbus_channel_packet_page_buffer desc;
+       u32 descsize;
+       u32 packetlen;
+       u32 packetlen_aligned;
+       struct scatterlist bufferlist[3];
+       u64 aligned_data = 0;
+
+       if (pagecount > MAX_PAGE_BUFFER_COUNT)
                return -EINVAL;
 
-       DumpVmbusChannel(Channel);
+       dump_vmbus_channel(channel);
 
        /*
-        * Adjust the size down since VMBUS_CHANNEL_PACKET_PAGE_BUFFER is the
+        * Adjust the size down since vmbus_channel_packet_page_buffer is the
         * largest size we support
         */
-       descSize = sizeof(struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER) -
-                         ((MAX_PAGE_BUFFER_COUNT - PageCount) *
+       descsize = sizeof(struct vmbus_channel_packet_page_buffer) -
+                         ((MAX_PAGE_BUFFER_COUNT - pagecount) *
                          sizeof(struct hv_page_buffer));
-       packetLen = descSize + BufferLen;
-       packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+       packetlen = descsize + bufferlen;
+       packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
 
        /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
 
        /* Setup the descriptor */
-       desc.Type = VmbusPacketTypeDataUsingGpaDirect;
-       desc.Flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
-       desc.DataOffset8 = descSize >> 3; /* in 8-bytes grandularity */
-       desc.Length8 = (u16)(packetLenAligned >> 3);
-       desc.TransactionId = RequestId;
-       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.type = VmbusPacketTypeDataUsingGpaDirect;
+       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 = 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;
        }
 
-       sg_init_table(bufferList, 3);
-       sg_set_buf(&bufferList[0], &desc, descSize);
-       sg_set_buf(&bufferList[1], Buffer, BufferLen);
-       sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+       sg_init_table(bufferlist, 3);
+       sg_set_buf(&bufferlist[0], &desc, descsize);
+       sg_set_buf(&bufferlist[1], buffer, bufferlen);
+       sg_set_buf(&bufferlist[2], &aligned_data,
+               packetlen_aligned - packetlen);
 
-       ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+       ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
 
        /* TODO: We should determine if this is optional */
-       if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-               VmbusChannelSetEvent(Channel);
+       if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+               vmbus_setevent(channel);
 
        return ret;
 }
+EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer);
 
 /*
- * VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet
+ * vmbus_sendpacket_multipagebuffer - Send a multi-page buffer packet
  * using a GPADL Direct packet type.
  */
-int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
-                               struct hv_multipage_buffer *MultiPageBuffer,
-                               void *Buffer, u32 BufferLen, u64 RequestId)
+int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
+                               struct hv_multipage_buffer *multi_pagebuffer,
+                               void *buffer, u32 bufferlen, u64 requestid)
 {
        int ret;
-       struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER desc;
-       u32 descSize;
-       u32 packetLen;
-       u32 packetLenAligned;
-       struct scatterlist bufferList[3];
-       u64 alignedData = 0;
-       u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset,
-                                        MultiPageBuffer->Length);
+       struct vmbus_channel_packet_multipage_buffer desc;
+       u32 descsize;
+       u32 packetlen;
+       u32 packetlen_aligned;
+       struct scatterlist bufferlist[3];
+       u64 aligned_data = 0;
+       u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->Offset,
+                                        multi_pagebuffer->Length);
 
-       DumpVmbusChannel(Channel);
+       dump_vmbus_channel(channel);
 
        DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
-                  MultiPageBuffer->Offset, MultiPageBuffer->Length, PfnCount);
+               multi_pagebuffer->Offset,
+               multi_pagebuffer->Length, pfncount);
 
-       if ((PfnCount < 0) || (PfnCount > MAX_MULTIPAGE_BUFFER_COUNT))
+       if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
                return -EINVAL;
 
        /*
-        * Adjust the size down since VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER is
+        * Adjust the size down since vmbus_channel_packet_multipage_buffer is
         * the largest size we support
         */
-       descSize = sizeof(struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER) -
-                         ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount) *
+       descsize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
+                         ((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) *
                          sizeof(u64));
-       packetLen = descSize + BufferLen;
-       packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+       packetlen = descsize + bufferlen;
+       packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
 
        /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
 
        /* Setup the descriptor */
-       desc.Type = VmbusPacketTypeDataUsingGpaDirect;
-       desc.Flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
-       desc.DataOffset8 = descSize >> 3; /* in 8-bytes grandularity */
-       desc.Length8 = (u16)(packetLenAligned >> 3);
-       desc.TransactionId = RequestId;
-       desc.RangeCount = 1;
+       desc.type = VmbusPacketTypeDataUsingGpaDirect;
+       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 = MultiPageBuffer->Length;
-       desc.Range.Offset = MultiPageBuffer->Offset;
+       desc.range.Length = multi_pagebuffer->Length;
+       desc.range.Offset = multi_pagebuffer->Offset;
 
-       memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray,
-              PfnCount * sizeof(u64));
+       memcpy(desc.range.PfnArray, multi_pagebuffer->PfnArray,
+              pfncount * sizeof(u64));
 
-       sg_init_table(bufferList, 3);
-       sg_set_buf(&bufferList[0], &desc, descSize);
-       sg_set_buf(&bufferList[1], Buffer, BufferLen);
-       sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+       sg_init_table(bufferlist, 3);
+       sg_set_buf(&bufferlist[0], &desc, descsize);
+       sg_set_buf(&bufferlist[1], buffer, bufferlen);
+       sg_set_buf(&bufferlist[2], &aligned_data,
+               packetlen_aligned - packetlen);
 
-       ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+       ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
 
        /* TODO: We should determine if this is optional */
-       if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-               VmbusChannelSetEvent(Channel);
+       if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+               vmbus_setevent(channel);
 
        return ret;
 }
-
+EXPORT_SYMBOL_GPL(vmbus_sendpacket_multipagebuffer);
 
 /**
- * VmbusChannelRecvPacket() - Retrieve the user packet on the specified channel
- * @Channel: Pointer to vmbus_channel structure.
- * @Buffer: Pointer to the buffer you want to receive the data into.
- * @BufferLen: Maximum size of what the the buffer will hold
- * @BufferActualLen: The actual size of the data after it was received
- * @RequestId: Identifier of the request
+ * vmbus_recvpacket() - Retrieve the user packet on the specified channel
+ * @channel: Pointer to vmbus_channel structure.
+ * @buffer: Pointer to the buffer you want to receive the data into.
+ * @bufferlen: Maximum size of what the the buffer will hold
+ * @buffer_actual_len: The actual size of the data after it was received
+ * @requestid: Identifier of the request
  *
  * Receives directly from the hyper-v vmbus and puts the data it received
  * into Buffer. This will receive the data unparsed from hyper-v.
  *
  * Mainly used by Hyper-V drivers.
  */
-int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
-                          u32 BufferLen, u32 *BufferActualLen, u64 *RequestId)
+int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
+                       u32 bufferlen, u32 *buffer_actual_len, u64 *requestid)
 {
        struct vmpacket_descriptor desc;
-       u32 packetLen;
-       u32 userLen;
+       u32 packetlen;
+       u32 userlen;
        int ret;
        unsigned long flags;
 
-       *BufferActualLen = 0;
-       *RequestId = 0;
+       *buffer_actual_len = 0;
+       *requestid = 0;
 
-       spin_lock_irqsave(&Channel->inbound_lock, flags);
+       spin_lock_irqsave(&channel->inbound_lock, flags);
 
-       ret = RingBufferPeek(&Channel->Inbound, &desc,
+       ret = ringbuffer_peek(&channel->inbound, &desc,
                             sizeof(struct vmpacket_descriptor));
        if (ret != 0) {
-               spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+               spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
                /* DPRINT_DBG(VMBUS, "nothing to read!!"); */
                return 0;
@@ -922,59 +934,59 @@ int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
 
        /* VmbusChannelClearEvent(Channel); */
 
-       packetLen = desc.Length8 << 3;
-       userLen = packetLen - (desc.DataOffset8 << 3);
+       packetlen = desc.Length8 << 3;
+       userlen = packetlen - (desc.DataOffset8 << 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.ChildRelId, desc.Type,
-                  desc.Flags, desc.TransactionId, packetLen, userLen);
+                  channel, channel->offermsg.child_relid, desc.Type,
+                  desc.Flags, desc.TransactionId, packetlen, userlen);
 
-       *BufferActualLen = userLen;
+       *buffer_actual_len = userlen;
 
-       if (userLen > BufferLen) {
-               spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+       if (userlen > bufferlen) {
+               spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
                DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d",
-                          BufferLen, userLen);
+                          bufferlen, userlen);
                return -1;
        }
 
-       *RequestId = desc.TransactionId;
+       *requestid = desc.TransactionId;
 
        /* Copy over the packet to the user buffer */
-       ret = RingBufferRead(&Channel->Inbound, Buffer, userLen,
+       ret = ringbuffer_read(&channel->inbound, buffer, userlen,
                             (desc.DataOffset8 << 3));
 
-       spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+       spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
        return 0;
 }
-EXPORT_SYMBOL(VmbusChannelRecvPacket);
+EXPORT_SYMBOL(vmbus_recvpacket);
 
 /*
- * VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel
+ * vmbus_recvpacket_raw - Retrieve the raw packet on the specified channel
  */
-int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
-                             u32 BufferLen, u32 *BufferActualLen,
-                             u64 *RequestId)
+int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
+                             u32 bufferlen, u32 *buffer_actual_len,
+                             u64 *requestid)
 {
        struct vmpacket_descriptor desc;
-       u32 packetLen;
-       u32 userLen;
+       u32 packetlen;
+       u32 userlen;
        int ret;
        unsigned long flags;
 
-       *BufferActualLen = 0;
-       *RequestId = 0;
+       *buffer_actual_len = 0;
+       *requestid = 0;
 
-       spin_lock_irqsave(&Channel->inbound_lock, flags);
+       spin_lock_irqsave(&channel->inbound_lock, flags);
 
-       ret = RingBufferPeek(&Channel->Inbound, &desc,
+       ret = ringbuffer_peek(&channel->inbound, &desc,
                             sizeof(struct vmpacket_descriptor));
        if (ret != 0) {
-               spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+               spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
                /* DPRINT_DBG(VMBUS, "nothing to read!!"); */
                return 0;
@@ -982,63 +994,64 @@ int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
 
        /* VmbusChannelClearEvent(Channel); */
 
-       packetLen = desc.Length8 << 3;
-       userLen = packetLen - (desc.DataOffset8 << 3);
+       packetlen = desc.Length8 << 3;
+       userlen = packetlen - (desc.DataOffset8 << 3);
 
        DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
                   "flag %d tid %llx pktlen %d datalen %d> ",
-                  Channel, Channel->OfferMsg.ChildRelId, desc.Type,
-                  desc.Flags, desc.TransactionId, packetLen, userLen);
+                  channel, channel->offermsg.child_relid, desc.Type,
+                  desc.Flags, desc.TransactionId, packetlen, userlen);
 
-       *BufferActualLen = packetLen;
+       *buffer_actual_len = packetlen;
 
-       if (packetLen > BufferLen) {
-               spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+       if (packetlen > bufferlen) {
+               spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
                DPRINT_ERR(VMBUS, "buffer too small - needed %d bytes but "
-                          "got space for only %d bytes", packetLen, BufferLen);
+                          "got space for only %d bytes", packetlen, bufferlen);
                return -2;
        }
 
-       *RequestId = desc.TransactionId;
+       *requestid = desc.TransactionId;
 
        /* Copy over the entire packet to the user buffer */
-       ret = RingBufferRead(&Channel->Inbound, Buffer, packetLen, 0);
+       ret = ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
 
-       spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+       spin_unlock_irqrestore(&channel->inbound_lock, flags);
        return 0;
 }
+EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
 
 /*
- * VmbusChannelOnChannelEvent - Channel event callback
+ * vmbus_onchannel_event - Channel event callback
  */
-void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel)
+void vmbus_onchannel_event(struct vmbus_channel *channel)
 {
-       DumpVmbusChannel(Channel);
+       dump_vmbus_channel(channel);
        /* ASSERT(Channel->OnChannelCallback); */
 
-       Channel->OnChannelCallback(Channel->ChannelCallbackContext);
+       channel->onchannel_callback(channel->channel_callback_context);
 
-       mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100));
+       mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
 }
 
 /*
- * VmbusChannelOnTimer - Timer event callback
+ * vmbus_ontimer - Timer event callback
  */
-void VmbusChannelOnTimer(unsigned long data)
+void vmbus_ontimer(unsigned long data)
 {
        struct vmbus_channel *channel = (struct vmbus_channel *)data;
 
-       if (channel->OnChannelCallback)
-               channel->OnChannelCallback(channel->ChannelCallbackContext);
+       if (channel->onchannel_callback)
+               channel->onchannel_callback(channel->channel_callback_context);
 }
 
 /*
- * DumpVmbusChannel - Dump vmbus channel info to the console
+ * dump_vmbus_channel- Dump vmbus channel info to the console
  */
-static void DumpVmbusChannel(struct vmbus_channel *Channel)
+static void dump_vmbus_channel(struct vmbus_channel *channel)
 {
-       DPRINT_DBG(VMBUS, "Channel (%d)", Channel->OfferMsg.ChildRelId);
-       DumpRingInfo(&Channel->Outbound, "Outbound ");
-       DumpRingInfo(&Channel->Inbound, "Inbound ");
+       DPRINT_DBG(VMBUS, "Channel (%d)", channel->offermsg.child_relid);
+       dump_ring_info(&channel->outbound, "Outbound ");
+       dump_ring_info(&channel->inbound, "Inbound ");
 }