Linux virtualization list
 help / color / mirror / Atom feed
* Re: [patch 1/2] vhost: potential integer overflows
From: Al Viro @ 2010-10-11 17:26 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Michael S. Tsirkin, Juan Quintela, David S. Miller, Rusty Russell,
	kvm, virtualization, netdev, kernel-janitors
In-Reply-To: <20101011172256.GF5851@bicker>

On Mon, Oct 11, 2010 at 07:22:57PM +0200, Dan Carpenter wrote:
> I did an audit for potential integer overflows of values which get passed
> to access_ok() and here are the results.

FWIW, UINT_MAX is wrong here.  What you want is maximal size_t value.

> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index dd3d6f7..c2aa12c 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -429,6 +429,14 @@ static int vq_access_ok(unsigned int num,
>  			struct vring_avail __user *avail,
>  			struct vring_used __user *used)
>  {
> +
> +	if (num > UINT_MAX / sizeof *desc)
> +		return 0;
> +	if (num > UINT_MAX / sizeof *avail->ring - sizeof *avail)
> +		return 0;
> +	if (num > UINT_MAX / sizeof *used->ring - sizeof *used)
> +		return 0;
> +
>  	return access_ok(VERIFY_READ, desc, num * sizeof *desc) &&
>  	       access_ok(VERIFY_READ, avail,
>  			 sizeof *avail + num * sizeof *avail->ring) &&
> @@ -447,6 +455,9 @@ int vhost_log_access_ok(struct vhost_dev *dev)
>  /* Caller should have vq mutex and device mutex */
>  static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base)
>  {
> +	if (vq->num > UINT_MAX / sizeof *vq->used->ring - sizeof *vq->used)
> +		return 0;
> +
>  	return vq_memory_access_ok(log_base, vq->dev->memory,
>  			    vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) &&
>  		(!vq->log_used || log_access_ok(log_base, vq->log_addr,
> @@ -606,12 +617,17 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
>  			}
>  
>  			/* Also validate log access for used ring if enabled. */
> -			if ((a.flags & (0x1 << VHOST_VRING_F_LOG)) &&
> -			    !log_access_ok(vq->log_base, a.log_guest_addr,
> +			if (a.flags & (0x1 << VHOST_VRING_F_LOG)) {
> +				if (vq->num > UINT_MAX / sizeof *vq->used->ring - sizeof *vq->used) {
> +					r = -EINVAL;
> +					break;
> +				}
> +				if (!log_access_ok(vq->log_base, a.log_guest_addr,
>  					   sizeof *vq->used +
>  					   vq->num * sizeof *vq->used->ring)) {
> -				r = -EINVAL;
> -				break;
> +					r = -EINVAL;
> +					break;
> +				}
>  			}
>  		}
>  
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [patch 2/2] vhost: fix return code for log_access_ok()
From: Dan Carpenter @ 2010-10-11 17:24 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Juan Quintela, David S. Miller, Rusty Russell, kvm,
	virtualization, netdev, kernel-janitors

access_ok() returns 1 if it's OK otherwise it should return 0.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index c2aa12c..f82fe57 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -371,7 +371,7 @@ static int log_access_ok(void __user *log_base, u64 addr, unsigned long sz)
 	/* Make sure 64 bit math will not overflow. */
 	if (a > ULONG_MAX - (unsigned long)log_base ||
 	    a + (unsigned long)log_base > ULONG_MAX)
-		return -EFAULT;
+		return 0;
 
 	return access_ok(VERIFY_WRITE, log_base + a,
 			 (sz + VHOST_PAGE_SIZE * 8 - 1) / VHOST_PAGE_SIZE / 8);

^ permalink raw reply related

* [patch 1/2] vhost: potential integer overflows
From: Dan Carpenter @ 2010-10-11 17:22 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Juan Quintela, David S. Miller, Rusty Russell, kvm,
	virtualization, netdev, kernel-janitors

I did an audit for potential integer overflows of values which get passed
to access_ok() and here are the results.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index dd3d6f7..c2aa12c 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -429,6 +429,14 @@ static int vq_access_ok(unsigned int num,
 			struct vring_avail __user *avail,
 			struct vring_used __user *used)
 {
+
+	if (num > UINT_MAX / sizeof *desc)
+		return 0;
+	if (num > UINT_MAX / sizeof *avail->ring - sizeof *avail)
+		return 0;
+	if (num > UINT_MAX / sizeof *used->ring - sizeof *used)
+		return 0;
+
 	return access_ok(VERIFY_READ, desc, num * sizeof *desc) &&
 	       access_ok(VERIFY_READ, avail,
 			 sizeof *avail + num * sizeof *avail->ring) &&
@@ -447,6 +455,9 @@ int vhost_log_access_ok(struct vhost_dev *dev)
 /* Caller should have vq mutex and device mutex */
 static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base)
 {
+	if (vq->num > UINT_MAX / sizeof *vq->used->ring - sizeof *vq->used)
+		return 0;
+
 	return vq_memory_access_ok(log_base, vq->dev->memory,
 			    vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) &&
 		(!vq->log_used || log_access_ok(log_base, vq->log_addr,
@@ -606,12 +617,17 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
 			}
 
 			/* Also validate log access for used ring if enabled. */
-			if ((a.flags & (0x1 << VHOST_VRING_F_LOG)) &&
-			    !log_access_ok(vq->log_base, a.log_guest_addr,
+			if (a.flags & (0x1 << VHOST_VRING_F_LOG)) {
+				if (vq->num > UINT_MAX / sizeof *vq->used->ring - sizeof *vq->used) {
+					r = -EINVAL;
+					break;
+				}
+				if (!log_access_ok(vq->log_base, a.log_guest_addr,
 					   sizeof *vq->used +
 					   vq->num * sizeof *vq->used->ring)) {
-				r = -EINVAL;
-				break;
+					r = -EINVAL;
+					break;
+				}
 			}
 		}
 

^ permalink raw reply related

* [PATCH 1/1] staging: hv: Rename camel cased functions in channel.c to lowercase
From: Hank Janssen @ 2010-10-07 18:40 UTC (permalink / raw)
  To: gregkh, hjanssen, Haiyang Zhang, devel, virtualization,
	linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>

Rename camel cased functions in channel.c to lowercase

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>

---
 drivers/staging/hv/channel.c           |  102 ++++++++++++++++----------------
 drivers/staging/hv/channel.h           |   94 +++++++++++++++---------------
 drivers/staging/hv/channel_interface.c |   20 +++---
 drivers/staging/hv/channel_mgmt.c      |    8 +-
 drivers/staging/hv/connection.c        |    4 +-
 drivers/staging/hv/hv_utils.c          |   12 ++--
 6 files changed, 120 insertions(+), 120 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 1037488..39b8fd3 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -27,13 +27,13 @@
 #include "vmbus_private.h"
 
 /* Internal routines */
-static int VmbusChannelCreateGpadlHeader(
+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 DumpVmbusChannel(struct vmbus_channel *channel);
-static void VmbusChannelSetEvent(struct vmbus_channel *channel);
+static void dump_vmbus_channel(struct vmbus_channel *channel);
+static void vmbus_setevent(struct vmbus_channel *channel);
 
 
 #if 0
@@ -67,10 +67,10 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
 #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;
 
@@ -115,9 +115,9 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
 
 #endif
 /*
- * VmbusChannelGetDebugInfo -Retrieve various channel debug info
+ * vmbus_get_debug_info -Retrieve various channel debug info
  */
-void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
+void vmbus_get_debug_info(struct vmbus_channel *channel,
 			      struct vmbus_channel_debug_info *debuginfo)
 {
 	struct hv_monitor_page *monitorpage;
@@ -160,9 +160,9 @@ void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
 }
 
 /*
- * VmbusChannelOpen - Open the specified channel.
+ * vmbus_open - Open the specified channel.
  */
-int VmbusChannelOpen(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
+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)
 {
@@ -212,7 +212,7 @@ int VmbusChannelOpen(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 
 	newchannel->RingBufferGpadlHandle = 0;
 
-	ret = VmbusChannelEstablishGpadl(newchannel,
+	ret = vmbus_establish_gpadl(newchannel,
 					 newchannel->Outbound.RingBuffer,
 					 send_ringbuffer_size +
 					 recv_ringbuffer_size,
@@ -307,10 +307,10 @@ errorout:
 }
 
 /*
- * 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;
@@ -325,10 +325,10 @@ static void DumpGpadlBody(struct vmbus_channel_gpadl_body *gpadl, u32 len)
 }
 
 /*
- * 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;
@@ -351,9 +351,9 @@ static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *gpadl)
 }
 
 /*
- * 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,
+static int create_gpadl_header(void *kbuffer, u32 size,
 					 struct vmbus_channel_msginfo **msginfo,
 					 u32 *messagecount)
 {
@@ -479,14 +479,14 @@ nomem:
 }
 
 /*
- * 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
  * @gpadl_handle: some funky thing
  */
-int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, void *kbuffer,
+int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 			       u32 size, u32 *gpadl_handle)
 {
 	struct vmbus_channel_gpadl_header *gpadlmsg;
@@ -503,7 +503,7 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, void *kbuffer,
 	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;
 
@@ -518,7 +518,7 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, void *kbuffer,
 	gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
 	gpadlmsg->Gpadl = next_gpadl_handle;
 
-	DumpGpadlHeader(gpadlmsg);
+	dump_gpadl_header(gpadlmsg);
 
 	spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
 	list_add_tail(&msginfo->MsgListEntry,
@@ -554,7 +554,7 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, void *kbuffer,
 				   submsginfo->MessageSize -
 				   sizeof(*submsginfo));
 
-			DumpGpadlBody(gpadl_body, submsginfo->MessageSize -
+			dump_gpadl_body(gpadl_body, submsginfo->MessageSize -
 				      sizeof(*submsginfo));
 			ret = VmbusPostMessage(gpadl_body,
 					       submsginfo->MessageSize -
@@ -586,9 +586,9 @@ Cleanup:
 }
 
 /*
- * VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
+ * vmbus_teardown_gpadl -Teardown the specified GPADL handle
  */
-int VmbusChannelTeardownGpadl(struct vmbus_channel *channel, u32 gpadl_handle)
+int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 {
 	struct vmbus_channel_gpadl_teardown *msg;
 	struct vmbus_channel_msginfo *info;
@@ -639,9 +639,9 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 }
 
 /*
- * 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;
@@ -674,7 +674,7 @@ void VmbusChannelClose(struct vmbus_channel *channel)
 
 	/* Tear down the gpadl for the channel's ring buffer */
 	if (channel->RingBufferGpadlHandle)
-		VmbusChannelTeardownGpadl(channel,
+		vmbus_teardown_gpadl(channel,
 					  channel->RingBufferGpadlHandle);
 
 	/* TODO: Send a msg to release the childRelId */
@@ -703,7 +703,7 @@ void VmbusChannelClose(struct vmbus_channel *channel)
 }
 
 /**
- * VmbusChannelSendPacket() - Send the specified buffer on the given channel
+ * 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
@@ -716,7 +716,7 @@ void VmbusChannelClose(struct vmbus_channel *channel)
  *
  * Mainly used by Hyper-V drivers.
  */
-int VmbusChannelSendPacket(struct vmbus_channel *channel, const void *buffer,
+int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
 			   u32 bufferlen, u64 requestid,
 			   enum vmbus_packet_type type, u32 flags)
 {
@@ -730,7 +730,7 @@ int VmbusChannelSendPacket(struct vmbus_channel *channel, const void *buffer,
 	DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
 		   channel, buffer, bufferlen);
 
-	DumpVmbusChannel(channel);
+	dump_vmbus_channel(channel);
 
 	/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
 
@@ -752,17 +752,17 @@ int VmbusChannelSendPacket(struct vmbus_channel *channel, const void *buffer,
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
-		VmbusChannelSetEvent(channel);
+		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,
+int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
 				     struct hv_page_buffer pagebuffers[],
 				     u32 pagecount, void *buffer, u32 bufferlen,
 				     u64 requestid)
@@ -779,7 +779,7 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
 	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
@@ -817,16 +817,16 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
-		VmbusChannelSetEvent(channel);
+		vmbus_setevent(channel);
 
 	return ret;
 }
 
 /*
- * 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,
+int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 				struct hv_multipage_buffer *multi_pagebuffer,
 				void *buffer, u32 bufferlen, u64 requestid)
 {
@@ -840,7 +840,7 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
 	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",
 		multi_pagebuffer->Offset,
@@ -885,14 +885,14 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
-		VmbusChannelSetEvent(channel);
+		vmbus_setevent(channel);
 
 	return ret;
 }
 
 
 /**
- * VmbusChannelRecvPacket() - Retrieve the user packet on the specified channel
+ * 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
@@ -904,7 +904,7 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
  *
  * Mainly used by Hyper-V drivers.
  */
-int VmbusChannelRecvPacket(struct vmbus_channel *channel, void *buffer,
+int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 			u32 bufferlen, u32 *buffer_actual_len, u64 *requestid)
 {
 	struct vmpacket_descriptor desc;
@@ -958,12 +958,12 @@ int VmbusChannelRecvPacket(struct vmbus_channel *channel, void *buffer,
 
 	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,
+int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 			      u32 bufferlen, u32 *buffer_actual_len,
 			      u64 *requestid)
 {
@@ -1017,11 +1017,11 @@ int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel, void *buffer,
 }
 
 /*
- * 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);
@@ -1030,9 +1030,9 @@ void VmbusChannelOnChannelEvent(struct vmbus_channel *channel)
 }
 
 /*
- * 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;
 
@@ -1041,9 +1041,9 @@ void VmbusChannelOnTimer(unsigned long data)
 }
 
 /*
- * 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 ");
diff --git a/drivers/staging/hv/channel.h b/drivers/staging/hv/channel.h
index 85c5079..7997056 100644
--- a/drivers/staging/hv/channel.h
+++ b/drivers/staging/hv/channel.h
@@ -52,61 +52,61 @@ struct vmbus_channel_packet_multipage_buffer {
 } __attribute__((packed));
 
 
-extern int VmbusChannelOpen(struct vmbus_channel *channel,
-			    u32 SendRingBufferSize,
-			    u32 RecvRingBufferSize,
-			    void *UserData,
-			    u32 UserDataLen,
-			    void(*OnChannelCallback)(void *context),
-			    void *Context);
-
-extern void VmbusChannelClose(struct vmbus_channel *channel);
-
-extern int VmbusChannelSendPacket(struct vmbus_channel *channel,
-				  const void *Buffer,
-				  u32 BufferLen,
-				  u64 RequestId,
-				  enum vmbus_packet_type Type,
-				  u32 Flags);
-
-extern int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
-					    struct hv_page_buffer PageBuffers[],
-					    u32 PageCount,
-					    void *Buffer,
-					    u32 BufferLen,
-					    u64 RequestId);
-
-extern int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
+extern int vmbus_open(struct vmbus_channel *channel,
+			    u32 send_ringbuffersize,
+			    u32 recv_ringbuffersize,
+			    void *userdata,
+			    u32 userdatalen,
+			    void(*onchannel_callback)(void *context),
+			    void *context);
+
+extern void vmbus_close(struct vmbus_channel *channel);
+
+extern int vmbus_sendpacket(struct vmbus_channel *channel,
+				  const void *buffer,
+				  u32 bufferLen,
+				  u64 requestid,
+				  enum vmbus_packet_type type,
+				  u32 flags);
+
+extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
+					    struct hv_page_buffer pagebuffers[],
+					    u32 pagecount,
+					    void *buffer,
+					    u32 bufferlen,
+					    u64 requestid);
+
+extern int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 					struct hv_multipage_buffer *mpb,
-					void *Buffer,
-					u32 BufferLen,
-					u64 RequestId);
+					void *buffer,
+					u32 bufferlen,
+					u64 requestid);
 
-extern int VmbusChannelEstablishGpadl(struct vmbus_channel *channel,
-				      void *Kbuffer,
-				      u32 Size,
-				      u32 *GpadlHandle);
+extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
+				      void *kbuffer,
+				      u32 size,
+				      u32 *gpadl_handle);
 
-extern int VmbusChannelTeardownGpadl(struct vmbus_channel *channel,
-				     u32 GpadlHandle);
+extern int vmbus_teardown_gpadl(struct vmbus_channel *channel,
+				     u32 gpadl_handle);
 
-extern int VmbusChannelRecvPacket(struct vmbus_channel *channel,
-				  void *Buffer,
-				  u32 BufferLen,
-				  u32 *BufferActualLen,
-				  u64 *RequestId);
+extern int vmbus_recvpacket(struct vmbus_channel *channel,
+				  void *buffer,
+				  u32 bufferlen,
+				  u32 *buffer_actual_len,
+				  u64 *requestid);
 
-extern int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel,
-				     void *Buffer,
-				     u32 BufferLen,
-				     u32 *BufferActualLen,
-				     u64 *RequestId);
+extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
+				     void *buffer,
+				     u32 bufferlen,
+				     u32 *buffer_actual_len,
+				     u64 *requestid);
 
-extern void VmbusChannelOnChannelEvent(struct vmbus_channel *channel);
+extern void vmbus_onchannel_event(struct vmbus_channel *channel);
 
-extern void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
+extern void vmbus_get_debug_info(struct vmbus_channel *channel,
 				     struct vmbus_channel_debug_info *debug);
 
-extern void VmbusChannelOnTimer(unsigned long data);
+extern void vmbus_ontimer(unsigned long data);
 
 #endif /* _CHANNEL_H_ */
diff --git a/drivers/staging/hv/channel_interface.c b/drivers/staging/hv/channel_interface.c
index 3f6a1cb..4d35923 100644
--- a/drivers/staging/hv/channel_interface.c
+++ b/drivers/staging/hv/channel_interface.c
@@ -31,21 +31,21 @@ static int IVmbusChannelOpen(struct hv_device *device, u32 SendBufferSize,
 			     void (*ChannelCallback)(void *context),
 			     void *Context)
 {
-	return VmbusChannelOpen(device->context, SendBufferSize,
+	return vmbus_open(device->context, SendBufferSize,
 				RecvRingBufferSize, UserData, UserDataLen,
 				ChannelCallback, Context);
 }
 
 static void IVmbusChannelClose(struct hv_device *device)
 {
-	VmbusChannelClose(device->context);
+	vmbus_close(device->context);
 }
 
 static int IVmbusChannelSendPacket(struct hv_device *device, const void *Buffer,
 				   u32 BufferLen, u64 RequestId, u32 Type,
 				   u32 Flags)
 {
-	return VmbusChannelSendPacket(device->context, Buffer, BufferLen,
+	return vmbus_sendpacket(device->context, Buffer, BufferLen,
 				      RequestId, Type, Flags);
 }
 
@@ -54,7 +54,7 @@ static int IVmbusChannelSendPacketPageBuffer(struct hv_device *device,
 				u32 PageCount, void *Buffer,
 				u32 BufferLen, u64 RequestId)
 {
-	return VmbusChannelSendPacketPageBuffer(device->context, PageBuffers,
+	return vmbus_sendpacket_pagebuffer(device->context, PageBuffers,
 						PageCount, Buffer, BufferLen,
 						RequestId);
 }
@@ -63,7 +63,7 @@ static int IVmbusChannelSendPacketMultiPageBuffer(struct hv_device *device,
 				struct hv_multipage_buffer *MultiPageBuffer,
 				void *Buffer, u32 BufferLen, u64 RequestId)
 {
-	return VmbusChannelSendPacketMultiPageBuffer(device->context,
+	return vmbus_sendpacket_multipagebuffer(device->context,
 						     MultiPageBuffer, Buffer,
 						     BufferLen, RequestId);
 }
@@ -72,7 +72,7 @@ static int IVmbusChannelRecvPacket(struct hv_device *device, void *Buffer,
 				   u32 BufferLen, u32 *BufferActualLen,
 				   u64 *RequestId)
 {
-	return VmbusChannelRecvPacket(device->context, Buffer, BufferLen,
+	return vmbus_recvpacket(device->context, Buffer, BufferLen,
 				      BufferActualLen, RequestId);
 }
 
@@ -80,20 +80,20 @@ static int IVmbusChannelRecvPacketRaw(struct hv_device *device, void *Buffer,
 				      u32 BufferLen, u32 *BufferActualLen,
 				      u64 *RequestId)
 {
-	return VmbusChannelRecvPacketRaw(device->context, Buffer, BufferLen,
+	return vmbus_recvpacket_raw(device->context, Buffer, BufferLen,
 					 BufferActualLen, RequestId);
 }
 
 static int IVmbusChannelEstablishGpadl(struct hv_device *device, void *Buffer,
 				       u32 BufferLen, u32 *GpadlHandle)
 {
-	return VmbusChannelEstablishGpadl(device->context, Buffer, BufferLen,
+	return vmbus_establish_gpadl(device->context, Buffer, BufferLen,
 					  GpadlHandle);
 }
 
 static int IVmbusChannelTeardownGpadl(struct hv_device *device, u32 GpadlHandle)
 {
-	return VmbusChannelTeardownGpadl(device->context, GpadlHandle);
+	return vmbus_teardown_gpadl(device->context, GpadlHandle);
 
 }
 
@@ -105,7 +105,7 @@ void GetChannelInfo(struct hv_device *device, struct hv_device_info *info)
 	if (!device->context)
 		return;
 
-	VmbusChannelGetDebugInfo(device->context, &debugInfo);
+	vmbus_get_debug_info(device->context, &debugInfo);
 
 	info->ChannelId = debugInfo.RelId;
 	info->ChannelState = debugInfo.State;
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 6ccf505..bdfd5af 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -172,7 +172,7 @@ void chn_cb_negotiate(void *context)
 	buflen = PAGE_SIZE;
 	buf = kmalloc(buflen, GFP_ATOMIC);
 
-	VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+	vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
 
 	if (recvlen > 0) {
 		icmsghdrp = (struct icmsg_hdr *)&buf[
@@ -183,7 +183,7 @@ void chn_cb_negotiate(void *context)
 		icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
 			| ICMSGHDRFLAG_RESPONSE;
 
-		VmbusChannelSendPacket(channel, buf,
+		vmbus_sendpacket(channel, buf,
 				       recvlen, requestid,
 				       VmbusPacketTypeDataInBand, 0);
 	}
@@ -249,7 +249,7 @@ struct vmbus_channel *AllocVmbusChannel(void)
 
 	init_timer(&channel->poll_timer);
 	channel->poll_timer.data = (unsigned long)channel;
-	channel->poll_timer.function = VmbusChannelOnTimer;
+	channel->poll_timer.function = vmbus_ontimer;
 
 	channel->ControlWQ = create_workqueue("hv_vmbus_ctl");
 	if (!channel->ControlWQ) {
@@ -392,7 +392,7 @@ static void VmbusChannelProcessOffer(void *context)
 			if (memcmp(&newChannel->OfferMsg.Offer.InterfaceType,
 				   &hv_cb_utils[cnt].data,
 				   sizeof(struct hv_guid)) == 0 &&
-				VmbusChannelOpen(newChannel, 2 * PAGE_SIZE,
+				vmbus_open(newChannel, 2 * PAGE_SIZE,
 						 2 * PAGE_SIZE, NULL, 0,
 						 hv_cb_utils[cnt].callback,
 						 newChannel) == 0) {
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 1f4d668..f847707 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -254,10 +254,10 @@ static void VmbusProcessChannelEvent(void *context)
 	channel = GetChannelFromRelId(relId);
 
 	if (channel) {
-		VmbusChannelOnChannelEvent(channel);
+		vmbus_onchannel_event(channel);
 		/*
 		 * WorkQueueQueueWorkItem(channel->dataWorkQueue,
-		 *			  VmbusChannelOnChannelEvent,
+		 *			  vmbus_onchannel_event,
 		 *			  (void*)channel);
 		 */
 	} else {
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c
index 6eb79fe..702a478 100644
--- a/drivers/staging/hv/hv_utils.c
+++ b/drivers/staging/hv/hv_utils.c
@@ -55,7 +55,7 @@ static void shutdown_onchannelcallback(void *context)
 	buflen = PAGE_SIZE;
 	buf = kmalloc(buflen, GFP_ATOMIC);
 
-	VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+	vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
 
 	if (recvlen > 0) {
 		DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
@@ -93,7 +93,7 @@ static void shutdown_onchannelcallback(void *context)
 		icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
 			| ICMSGHDRFLAG_RESPONSE;
 
-		VmbusChannelSendPacket(channel, buf,
+		vmbus_sendpacket(channel, buf,
 				       recvlen, requestid,
 				       VmbusPacketTypeDataInBand, 0);
 	}
@@ -159,7 +159,7 @@ static void timesync_onchannelcallback(void *context)
 	buflen = PAGE_SIZE;
 	buf = kmalloc(buflen, GFP_ATOMIC);
 
-	VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+	vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
 
 	if (recvlen > 0) {
 		DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
@@ -180,7 +180,7 @@ static void timesync_onchannelcallback(void *context)
 		icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
 			| ICMSGHDRFLAG_RESPONSE;
 
-		VmbusChannelSendPacket(channel, buf,
+		vmbus_sendpacket(channel, buf,
 				recvlen, requestid,
 				VmbusPacketTypeDataInBand, 0);
 	}
@@ -205,7 +205,7 @@ static void heartbeat_onchannelcallback(void *context)
 	buflen = PAGE_SIZE;
 	buf = kmalloc(buflen, GFP_ATOMIC);
 
-	VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);
+	vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
 
 	if (recvlen > 0) {
 		DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
@@ -233,7 +233,7 @@ static void heartbeat_onchannelcallback(void *context)
 		icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
 			| ICMSGHDRFLAG_RESPONSE;
 
-		VmbusChannelSendPacket(channel, buf,
+		vmbus_sendpacket(channel, buf,
 				       recvlen, requestid,
 				       VmbusPacketTypeDataInBand, 0);
 	}
-- 
1.6.3.2

^ permalink raw reply related

* Re: vhost_net_ioctl
From: devi thapa @ 2010-10-07  9:53 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: virtualization
In-Reply-To: <AANLkTin+z-Kb9+F4Mj5G8V5fq6X_X3CdSC_HCsRw6sz5@mail.gmail.com>

Thanks!!!!  I will surely follow as you guided.

On Wed, Oct 6, 2010 at 5:45 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Wed, Oct 6, 2010 at 12:34 PM, devi thapa <devi.thapa@gmail.com> wrote:
>> I am actually going only through net.c  and in this module they
>> haven't specified anywhere, where this value is coming from.
>
> In order to understand net.c it will be necessary to read other code
> too.  Make sure you have an environment that makes it easy to jump to
> function and variable definitions and switch between source files.
> For example, use ctags, cscope, or even Eclipse to navigate the kernel
> source tree.
>
>> So, you mean that kernel vhost code is connected  to QEMU userspace code.
>
> QEMU userspace makes use of the vhost interface.  If you get stuck
> understanding the kernel side, you can jump to the relevant place in
> QEMU and see what userspace is doing.  This will be useful especially
> for the part of the code that sets up a vhost-net device.
>
>> I request to guide me in following the code.
>
> In order to understand the code, you need to put in the effort to dig
> through the source for yourself.
>
> The strategy I follow is to read the code (you've already started with
> the kernel vhost-net code).  Much of it will be unclear on the first
> pass.
>
> Now switch to QEMU and read the vhost code there.  Patterns will
> become clearer but there will still be unanswered questions.
>
> Go back to the kernel and study it again with the insight you've
> gained from the userspace side.
>
> Iterate a few times.  That's how I understand new systems.
>
> Some other ideas to try if you get stuck:
>
> 1. Check the virtio specification for details on vring and the
> virtio-net device:
> http://ozlabs.org/~rusty/virtio-spec/virtio-spec-0.8.9.pdf
>
> 2. Use strace to see how QEMU uses the vhost file descriptor.
>
> 3. Look at related code like the virtio-net guest driver, the tap
> driver, KVM's ioeventfd and irqfd.
>
> Good luck!
>
> Stefan
>

^ permalink raw reply

* Re: [GIT PULL net-next-2.6] vhost-net patchset for 2.6.37
From: David Miller @ 2010-10-06 20:11 UTC (permalink / raw)
  To: mst; +Cc: kvm, virtualization, netdev, linux-kernel, jasowang
In-Reply-To: <20101005182732.GA25796@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 5 Oct 2010 20:27:32 +0200

> It looks like it was a quiet cycle for vhost-net:
> probably because most of energy was spent on bugfixes
> that went in for 2.6.36.
> People are working on multiqueue, tracing but I'm not
> sure it'll get done in time for 2.6.37 - so here's
> a tree with a single patch that helps windows guests
> which we definitely want in the next kernel.
> 
> Please merge for 2.6.37.

Pulled, thanks Michael.

^ permalink raw reply

* Re: vhost_net_ioctl
From: Stefan Hajnoczi @ 2010-10-06 12:15 UTC (permalink / raw)
  To: devi thapa; +Cc: virtualization
In-Reply-To: <AANLkTik2kogJ1ibqwOt7RhUPev9ANHYaixr9dm7b7-zZ@mail.gmail.com>

On Wed, Oct 6, 2010 at 12:34 PM, devi thapa <devi.thapa@gmail.com> wrote:
> I am actually going only through net.c  and in this module they
> haven't specified anywhere, where this value is coming from.

In order to understand net.c it will be necessary to read other code
too.  Make sure you have an environment that makes it easy to jump to
function and variable definitions and switch between source files.
For example, use ctags, cscope, or even Eclipse to navigate the kernel
source tree.

> So, you mean that kernel vhost code is connected  to QEMU userspace code.

QEMU userspace makes use of the vhost interface.  If you get stuck
understanding the kernel side, you can jump to the relevant place in
QEMU and see what userspace is doing.  This will be useful especially
for the part of the code that sets up a vhost-net device.

> I request to guide me in following the code.

In order to understand the code, you need to put in the effort to dig
through the source for yourself.

The strategy I follow is to read the code (you've already started with
the kernel vhost-net code).  Much of it will be unclear on the first
pass.

Now switch to QEMU and read the vhost code there.  Patterns will
become clearer but there will still be unanswered questions.

Go back to the kernel and study it again with the insight you've
gained from the userspace side.

Iterate a few times.  That's how I understand new systems.

Some other ideas to try if you get stuck:

1. Check the virtio specification for details on vring and the
virtio-net device:
http://ozlabs.org/~rusty/virtio-spec/virtio-spec-0.8.9.pdf

2. Use strace to see how QEMU uses the vhost file descriptor.

3. Look at related code like the virtio-net guest driver, the tap
driver, KVM's ioeventfd and irqfd.

Good luck!

Stefan

^ permalink raw reply

* Re: [RFC PATCH] virtio: (Partially) enable suspend/resume support
From: Amit Shah @ 2010-10-06 11:54 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Anthony Liguori, Virtualization List
In-Reply-To: <20101005152319.GA22056@redhat.com>

On (Tue) Oct 05 2010 [17:23:19], Michael S. Tsirkin wrote:
> On Tue, Oct 05, 2010 at 07:15:31PM +0530, Amit Shah wrote:
> > > > +
> > > > +	spin_lock_irqsave(&vp_dev->lock, flags);
> > > > +	list_for_each_entry(info, &vp_dev->virtqueues, node) {
> > > > +		/* Select the queue we're interested in */
> > > > +		iowrite16(info->queue_index,
> > > > +			  vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
> > > > +
> > > > +		/* Update the last idx we sent data in */
> > > > +		iowrite16(virtqueue_get_avail_idx(info->vq),
> > > > +			  vp_dev->ioaddr + VIRTIO_PCI_AVAIL_IDX);
> > > 
> > > Interesting. Could we just reset the ring instead?
> > > I think this would also solve the qemu problem you
> > > outline, won't it?
> > 
> > The problem here is qemu doesn't "know" we went into suspend and came
> > out of it.  When going to suspend, qemu could've received a kick
> > notification and would've been just about to process some queue entries.
> > Now when we resume and reset the ring, qemu could crash anyway seeing
> > invalid index values.
> 
> Hmm, I don't completely understand this.  When there's a reset I expect
> this to discard any previous kicks. No?

I'm talking of a situation like this:


	Guest					Host

   virtqueue_add_buf()
   virtqueue_kick()
					virtqueue_pop() (in progress)

    -->   suspend


Now there will be some buffers in the virtqueue but the host wouldn't
know on the next resume.  So we want to keep the ring state in the
current state so that the host continues consuming from where it left
off.  

Now this wouldn't crash on resume for virtio-net, but for virtio-serial
(which uses chardevs) and also for virtio-block, I guess there are more
problems.

For example, for virtio-serial, if the machine is re-started with a
chardev connected, the virtqueue_num_heads() function gets called, which
results in the 'Guest moved used index' message.

		Amit

^ permalink raw reply

* Re: vhost_net_ioctl
From: devi thapa @ 2010-10-06 11:34 UTC (permalink / raw)
  To: virtualization
In-Reply-To: <AANLkTikMK3fsoY5urLEoOT7XEj+03x2qMNO_h2EmSJFD@mail.gmail.com>

The arg value is being used to get the fd of the backend, in my case,
I prefer tap as a backend device.

And the same arg value is being used to get the features of backend device.

I am actually going only through net.c  and in this module they
haven't specified anywhere, where this value is coming from.

So, you mean that kernel vhost code is connected  to QEMU userspace code.

I request to guide me in following the code.

With hope,
Devi.






On 10/6/10, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Wed, Oct 6, 2010 at 11:16 AM, devi thapa <devi.thapa@gmail.com> wrote:
>>           What's the role or value of the third argument in the
>> vhost_net_ioctl function in /drivers/vhost/net.c .
>
> Read the code.  There is the kernel vhost code and the QEMU vhost
> userspace code to look at.  By studying both sides you can figure this
> out.
>
> Look at how arg is used in vhost_net_ioctl().
>
> Please spend more time learning how things work before sending
> questions to the mailing list.
>
> Stefan
>

^ permalink raw reply

* Re: vhost_net_ioctl
From: Stefan Hajnoczi @ 2010-10-06 10:33 UTC (permalink / raw)
  To: devi thapa; +Cc: virtualization
In-Reply-To: <AANLkTimzGqmS=YOsJjdM_-d1sJDd4w1t2Cyjk57xrQZo@mail.gmail.com>

On Wed, Oct 6, 2010 at 11:16 AM, devi thapa <devi.thapa@gmail.com> wrote:
>           What's the role or value of the third argument in the
> vhost_net_ioctl function in /drivers/vhost/net.c .

Read the code.  There is the kernel vhost code and the QEMU vhost
userspace code to look at.  By studying both sides you can figure this
out.

Look at how arg is used in vhost_net_ioctl().

Please spend more time learning how things work before sending
questions to the mailing list.

Stefan

^ permalink raw reply

* vhost_net_ioctl
From: devi thapa @ 2010-10-06 10:16 UTC (permalink / raw)
  To: virtualization

Hi All,


           What's the role or value of the third argument in the
vhost_net_ioctl function in /drivers/vhost/net.c .

       The function declaration is

         static long vhost_net_ioctl(struct file *f, unsigned int
ioctl, unsigned long arg)

As per my knowledge,

*f represents the fd of vhost-net device,
ioctl  any device request like VHOST_NET_SET_BACKEND,

But what's the third arg represent ?

With hope,
Devi.

^ permalink raw reply

* Re: [PATCH] virtio-spec trivial fixes
From: Rusty Russell @ 2010-10-06  9:06 UTC (permalink / raw)
  To: Amit Shah; +Cc: Virtualization List
In-Reply-To: <20101005135001.GE8207@amit-laptop.redhat.com>

On Wed, 6 Oct 2010 12:20:01 am Amit Shah wrote:
> Hello Rusty,
> 
> A few trivial fixes on top of virtio-spec-0.8.9 (patch -p0):

Thanks, applied.

If you turn on lyx change tracking, patches get uglier but it means
annotations of differences show up in next version.

Thanks!
Rusty.

^ permalink raw reply

* Re: VHOST_NET_SET_BACKEND
From: Stefan Hajnoczi @ 2010-10-06  8:19 UTC (permalink / raw)
  To: devi thapa; +Cc: virtualization
In-Reply-To: <AANLkTin_aMbpop_RQzruqSg5f36nYaChMEzQnG06YHRK@mail.gmail.com>

On Wed, Oct 6, 2010 at 7:43 AM, devi thapa <devi.thapa@gmail.com> wrote:
>       I dont know how to put this question, but bear with me.   My
> query is how to invoke the ioctl request "VHOST_NET_SET_BACKEND"  or
> how to set the backend, and when ?

Look at the QEMU side vhost-net code:
http://git.qemu.org/qemu.git/tree/hw/vhost_net.c#n145

Where does the backend fd come from?  It's the host network device
file descriptor that gets fetched by vhost_net_get_fd().  Currently it
must be a tap device file descriptor.

Stefan

^ permalink raw reply

* VHOST_NET_SET_BACKEND
From: devi thapa @ 2010-10-06  6:43 UTC (permalink / raw)
  To: virtualization

Hi  All,


       I dont know how to put this question, but bear with me.   My
query is how to invoke the ioctl request "VHOST_NET_SET_BACKEND"  or
how to set the backend, and when ?


With Anticipation,
Devi.

^ permalink raw reply

* Re: BUG - qdev - partial loss of network connectivity
From: Leszek Urbanski @ 2010-10-05 21:29 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: netdev, linux-nfs, qemu-devel, Anthony Liguori, virtualization
In-Reply-To: <20100927213203.GA28089@moo.pl>

<20100927213203.GA28089@moo.pl>; from Leszek Urbanski on Mon, Sep 27, 2010 at 23:32:03 +0200

> > > > >It's vanilla 2.6.32.22, but I also reproduced this on Debian's 2.6.32-23
> > > > >(based on 2.6.32.21).
> > > > >
> > > > >If offload is the only difference, I'll play with different offload
> > > > >options and check which one causes it.
> > > > >   
> > > > 
> > > > It's not technically the only difference but it's the most likely 
> > > > culprit IMHO.
> > > 
> > > udp fragmentation offload is definitely the culprit.
> > 
> > I see. Most likely guest bug - won't be the first bug around UFO.
> > If so pls copy netdev linux-nfs and virtualization.
> > Do you see anything in dmesg? Can try 2.6.36-rc5?
> 
> (for reference: first post is at:
> http://lists.nongnu.org/archive/html/qemu-devel/2010-09/msg01685.html )
> 
> I can't reproduce it on 2.6.36-rc5. Do you have an idea which patch may have

This one definitely fixes it: http://patchwork.ozlabs.org/patch/55643/

(Herbert Xu: udp: Fix bogus UFO packet generation)

The patch works with 2.6.32.24 too - it should probably be backported to
2.6.32.x.


-- 
Leszek "Tygrys" Urbanski, SCSA, SCNA
 "Unix-to-Unix Copy Program;" said PDP-1. "You will never find a more
  wretched hive of bugs and flamers. We must be cautious." -- DECWARS
     http://cygnus.moo.pl/ -- Cygnus High Altitude Balloon

^ permalink raw reply

* [GIT PULL net-next-2.6] vhost-net patchset for 2.6.37
From: Michael S. Tsirkin @ 2010-10-05 18:27 UTC (permalink / raw)
  To: David Miller; +Cc: kvm, virtualization, netdev, linux-kernel, Jason Wang

It looks like it was a quiet cycle for vhost-net:
probably because most of energy was spent on bugfixes
that went in for 2.6.36.
People are working on multiqueue, tracing but I'm not
sure it'll get done in time for 2.6.37 - so here's
a tree with a single patch that helps windows guests
which we definitely want in the next kernel.

Please merge for 2.6.37.
Thanks!

The following changes since commit a00eac0c459abecb539fb2a2abd3122dd7ca5d4a:

  ppp: Use a real SKB control block in fragmentation engine. (2010-10-05 01:36:52 -0700)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost-net-next

Jason Wang (1):
      vhost: max s/g to match qemu

 drivers/vhost/net.c   |    2 +-
 drivers/vhost/vhost.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 drivers/vhost/vhost.h |   18 ++++++++----------
 3 files changed, 57 insertions(+), 12 deletions(-)

^ permalink raw reply

* Re: [RFC PATCH] virtio: (Partially) enable suspend/resume support
From: Michael S. Tsirkin @ 2010-10-05 15:23 UTC (permalink / raw)
  To: Amit Shah; +Cc: Anthony Liguori, Virtualization List
In-Reply-To: <20101005134531.GD8207@amit-laptop.redhat.com>

On Tue, Oct 05, 2010 at 07:15:31PM +0530, Amit Shah wrote:
> > > +
> > > +	spin_lock_irqsave(&vp_dev->lock, flags);
> > > +	list_for_each_entry(info, &vp_dev->virtqueues, node) {
> > > +		/* Select the queue we're interested in */
> > > +		iowrite16(info->queue_index,
> > > +			  vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
> > > +
> > > +		/* Update the last idx we sent data in */
> > > +		iowrite16(virtqueue_get_avail_idx(info->vq),
> > > +			  vp_dev->ioaddr + VIRTIO_PCI_AVAIL_IDX);
> > 
> > Interesting. Could we just reset the ring instead?
> > I think this would also solve the qemu problem you
> > outline, won't it?
> 
> The problem here is qemu doesn't "know" we went into suspend and came
> out of it.  When going to suspend, qemu could've received a kick
> notification and would've been just about to process some queue entries.
> Now when we resume and reset the ring, qemu could crash anyway seeing
> invalid index values.

Hmm, I don't completely understand this.  When there's a reset I expect
this to discard any previous kicks. No?

>  I think that's happening now anyway.

How can one reproduce this?

^ permalink raw reply

* [PATCH] virtio-spec trivial fixes
From: Amit Shah @ 2010-10-05 13:50 UTC (permalink / raw)
  To: Virtualization List

Hello Rusty,

A few trivial fixes on top of virtio-spec-0.8.9 (patch -p0):

- grammatical errors
- mark '-' in 'avail->flags' as non-breakable hyphen
- add a footnote for console device to indicate queues 2 onwards are
  avl. if a feature was negotiated

		Amit


--- virtio-spec-0.8.9.lyx	2010-10-05 17:26:11.318836266 +0530
+++ virtio-spec-0.8.9-mod.lyx	2010-10-05 19:00:12.829710205 +0530
@@ -1,4 +1,4 @@
-#LyX 1.6.5 created this file. For more info see http://www.lyx.org/
+#LyX 1.6.7 created this file. For more info see http://www.lyx.org/
 \lyxformat 345
 \begin_document
 \begin_header
@@ -36,7 +36,8 @@
 \paperpagestyle default
 \tracking_changes true
 \output_changes true
-\author "Rusty Russell,,," 
+\author "" 
+\author "" 
 \author "" 
 \end_header
 
@@ -1784,6 +1785,9 @@
 \begin_layout Standard
 The number of descriptors in the table is specified by the Queue Size field
  for this virtqueue.
+\end_layout
+
+\begin_layout Subsection
 \begin_inset CommandInset label
 LatexCommand label
 name "sub:Indirect-Descriptors"
@@ -2076,8 +2080,8 @@
  and processing used buffers from the device.
  As an example, the virtio network device has two virtqueues: the transmit
  virtqueue and the receive virtqueue.
- The driver adds outgoing (read-only) packets are added to the transmit
- virtqueue, and then frees them after they are used.
+ The driver adds outgoing (read-only) packets to the transmit virtqueue,
+ and then frees them after they are used.
  Similarly, incoming (write-only) buffers are added to the receive virtqueue,
  and processed after they are used.
 \end_layout
@@ -2405,7 +2409,8 @@
 \end_layout
 
 \begin_layout Enumerate
-If the VRING_AVAIL_F_NO_INTERRUPT flag is not set in avail->flags:
+If the VRING_AVAIL_F_NO_INTERRUPT flag is not set in avail\SpecialChar \nobreakdash-
+>flags:
 \end_layout
 
 \begin_deeper
@@ -2639,7 +2644,7 @@
 
 \begin_layout Standard
 Any change to configuration space, or new virtqueues, or behavioural changes,
- should be indicated be negotiation of a new feature bit.
+ should be indicated by negotiation of a new feature bit.
  This establishes clarity
 \begin_inset Foot
 status open
@@ -4870,12 +4875,8 @@
 \emph on
 type
 \emph default
- of the request is either a read (VIRTIO_BLK_T_IN),
-\change_deleted 0 1285634492
- 
-\change_unchanged
- a write (VIRTIO_BLK_T_OUT), a scsi packet command (VIRTIO_BLK_T_SCSI_CMD
- or VIRTIO_BLK_T_SCSI_CMD_OUT
+ of the request is either a read (VIRTIO_BLK_T_IN), a write (VIRTIO_BLK_T_OUT),
+ a scsi packet command (VIRTIO_BLK_T_SCSI_CMD or VIRTIO_BLK_T_SCSI_CMD_OUT
 \begin_inset Foot
 status open
 
@@ -4993,11 +4994,7 @@
 \emph on
 data
 \emph default
- field is either read-only or write-only, depending on
-\change_deleted 0 1285634492
- 
-\change_unchanged
- the request.
+ field is either read-only or write-only, depending on the request.
  The size of the read or write can be derived from the total size of the
  request buffers.
 \end_layout
@@ -5169,8 +5166,17 @@
 
 \begin_layout Description
 Virtqueues 0:receiveq(port0).
- 1:transmitq(port0), 2:control receiveq, 3:control transmitq, 4:receiveq(port1),
- 5:transmitq(port1), ...
+ 1:transmitq(port0), 2:control receiveq
+\begin_inset Foot
+status open
+
+\begin_layout Plain Layout
+Ports 2 onwards only if VIRTIO_CONSOLE_F_MULTIPORT is set
+\end_layout
+
+\end_inset
+
+, 3:control transmitq, 4:receiveq(port1), 5:transmitq(port1), ...
 \end_layout
 
 \begin_layout Description
@@ -5318,7 +5324,7 @@
 \end_layout
 
 \begin_layout Enumerate
-If the host specified a port 'name', a sysfs attribute is created with the
+If the host specified a port `name', a sysfs attribute is created with the
  name filled in, so that udev rules can be written that can create a symlink
  from the port's name to the char device for port discovery by applications
  in the guest.

^ permalink raw reply

* Re: [RFC PATCH] virtio: (Partially) enable suspend/resume support
From: Amit Shah @ 2010-10-05 13:45 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Anthony Liguori, Virtualization List
In-Reply-To: <20101003155359.GB20285@redhat.com>

(Re-adding Rusty to CC, looks like the linux-foundation ml drops CCs.)

On (Sun) Oct 03 2010 [17:53:59], Michael S. Tsirkin wrote:
> On Wed, Sep 29, 2010 at 05:42:24PM +0530, Amit Shah wrote:
> > Let host know of our state (partial yet) so that the host PCI device is
> > up to where we were when we were suspended.
> > 
> > This is still an RFC as this doesn't completely work: an unused device
> > at the time of suspend will work fine after resume, but a device that
> > has seen some activity doesn't behave well after resume.  Especially,
> > host->guest communication doesn't go through.  This could be due to
> > interrupts/MSI not being wired properly.  I haven't looked at this part
> > of the problem yet.
> > 
> > We also need a per-driver resume callback which can update the devices
> > with driver-specific data.  Eg, for virtio_console, the guest port
> > open/close status will have to be known to the device.
> > 
> > QEMU also starts using the queues as soon as the VIRTIO_PCI_QUEUE_PFN
> > command is sent, so it has to be taught to only start using queues when
> > the device is ready and the queues are set up.
> > 
> > However, I just wanted to send this out to get reactions / comments.
> > 
> > Not-yet-Signed-off-by: Amit Shah <amit.shah@redhat.com>
> > ---
> >  drivers/virtio/virtio_pci.c  |   34 ++++++++++++++++++++++++++++++++++
> >  drivers/virtio/virtio_ring.c |    8 ++++++++
> >  include/linux/virtio.h       |    2 ++
> >  include/linux/virtio_pci.h   |    4 +++-
> >  4 files changed, 47 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> > index ef8d9d5..a3c7f59 100644
> > --- a/drivers/virtio/virtio_pci.c
> > +++ b/drivers/virtio/virtio_pci.c
> > @@ -698,8 +698,42 @@ static int virtio_pci_suspend(struct pci_dev *pci_dev, pm_message_t state)
> >  
> >  static int virtio_pci_resume(struct pci_dev *pci_dev)
> >  {
> > +	struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
> > +	struct virtio_pci_vq_info *info;
> > +	unsigned long flags;
> > +
> >  	pci_restore_state(pci_dev);
> >  	pci_set_power_state(pci_dev, PCI_D0);
> > +
> > +	iowrite32(vp_dev->vdev.features[0], vp_dev->ioaddr+VIRTIO_PCI_GUEST_FEATURES);
> 
> need spaces around +

That bit is taken from a place elsewhere in the file -- I guess it's
that way to keep everything on the same line.  But in the final
submission, I'll split up the line as I've done the others below.

> > +	if (vp_dev->msix_used_vectors)
> > +		iowrite16(vp_dev->msix_used_vectors,
> > +			  vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
> 
> I think this is wrong, msix_used_vectors is a counter not a vector
> number, try with 2 vectors and it will break I think: this is shared
> vectors configuration.  We just never had a need to remember the config
> vector number, either do remember it, or rely on the fact that it is
> always 0 in our code: and maybe add BUG_ON in vp_request_msix_vectors
> where it is first assigned. The condition would simply be
> msix_enabled.

Yes, I hadn't paid attention to MSI, this helps -- I'll adjust the code
accordingly.

> > +
> > +	spin_lock_irqsave(&vp_dev->lock, flags);
> > +	list_for_each_entry(info, &vp_dev->virtqueues, node) {
> > +		/* Select the queue we're interested in */
> > +		iowrite16(info->queue_index,
> > +			  vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
> > +
> > +		/* Update the last idx we sent data in */
> > +		iowrite16(virtqueue_get_avail_idx(info->vq),
> > +			  vp_dev->ioaddr + VIRTIO_PCI_AVAIL_IDX);
> 
> Interesting. Could we just reset the ring instead?
> I think this would also solve the qemu problem you
> outline, won't it?

The problem here is qemu doesn't "know" we went into suspend and came
out of it.  When going to suspend, qemu could've received a kick
notification and would've been just about to process some queue entries.
Now when we resume and reset the ring, qemu could crash anyway seeing
invalid index values.  I think that's happening now anyway.

However, I think the current qemu problem I have might be related to me
not introducing memory barriers here.

> > +		if (info->msix_vector != VIRTIO_MSI_NO_VECTOR) {
> > +			iowrite16(info->msix_vector,
> > +				  vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR);
> > +		}
> 
> actually it's probably better to write msix_vector if it is
> VIRTIO_MSI_NO_VECTOR as well, just to make sure
> we are in a known state.  The condition
> should be that msix is enabled in the device.
> 
> Further, please read the value back and verify that it was
> written successfully: on error you get VIRTIO_MSI_NO_VECTOR.

Yes, error handling is to be done yet.

> > +		/* activate the queue */
> > +		iowrite32(virt_to_phys(info->queue) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT,
> > +			  vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
> > +
> > +	}
> > +	spin_unlock_irqrestore(&vp_dev->lock, flags);
> > +
> > +	vp_set_status(&vp_dev->vdev, VIRTIO_CONFIG_S_DRIVER_OK);
> > +
> >  	return 0;
> >  }
> >  #endif
> > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > index 1475ed6..3eb91d1 100644
> > --- a/drivers/virtio/virtio_ring.c
> > +++ b/drivers/virtio/virtio_ring.c
> > @@ -237,6 +237,14 @@ add_head:
> >  }
> >  EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);
> >  
> > +u16 virtqueue_get_avail_idx(struct virtqueue *_vq)
> > +{
> > +	struct vring_virtqueue *vq = to_vvq(_vq);
> > +
> > +	return vq->vring.avail->idx;
> > +}
> > +EXPORT_SYMBOL_GPL(virtqueue_get_avail_idx);
> > +
> >  void virtqueue_kick(struct virtqueue *_vq)
> >  {
> >  	struct vring_virtqueue *vq = to_vvq(_vq);
> > diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> > index aff5b4f..cdb04ec 100644
> > --- a/include/linux/virtio.h
> > +++ b/include/linux/virtio.h
> > @@ -88,6 +88,8 @@ bool virtqueue_enable_cb(struct virtqueue *vq);
> >  
> >  void *virtqueue_detach_unused_buf(struct virtqueue *vq);
> >  
> > +u16 virtqueue_get_avail_idx(struct virtqueue *vq);
> > +
> 
> This is a bit of a layering violation, in that the avail index
> belongs to the ring internals.

Yes, it is.  This exercise is basically to find out what's needed to
make suspend work; we can design the final solution once we have a
better idea of what's involved.

> Possibly the best solution to expose it
> is to put the index in the ring. This was one of the ideas
> proposed for vring2. Other options include getting rid of the
> index entirely.
> 
> >  /**
> >   * virtio_device - representation of a device using virtio
> >   * @index: unique position on the virtio bus
> > diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
> > index 9a3d7c4..aa3e584 100644
> > --- a/include/linux/virtio_pci.h
> > +++ b/include/linux/virtio_pci.h
> > @@ -55,9 +55,11 @@
> >  /* Vector value used to disable MSI for queue */
> >  #define VIRTIO_MSI_NO_VECTOR            0xffff
> >  
> > +#define VIRTIO_PCI_AVAIL_IDX		24
> > +
> >  /* The remaining space is defined by each driver as the per-driver
> >   * configuration space */
> > -#define VIRTIO_PCI_CONFIG(dev)		((dev)->msix_enabled ? 24 : 20)
> > +#define VIRTIO_PCI_CONFIG(dev)		26
> 
> This will silently break all devices out there, won't it?

Sure it does :-)  (Has to be handled when this is proposed as a fix
officially.)

		Amit

^ permalink raw reply

* [PATCH] x86/xen: remove duplicated include
From: Nicolas Kaiser @ 2010-10-05 11:44 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: virtualization, xen-devel, linux-kernel

Remove duplicated include.

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
---
 arch/x86/xen/enlighten.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 7d46c84..3396891 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -58,7 +58,6 @@
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/reboot.h>
-#include <asm/setup.h>
 #include <asm/stackprotector.h>
 #include <asm/hypervisor.h>
 
-- 
1.7.2.2

^ permalink raw reply related

* Re: [PATCH 1/1] staging: hv: Remove camel case variables in channel.c
From: Florian Mickler @ 2010-10-05  7:23 UTC (permalink / raw)
  To: Greg KH
  Cc: Hank Janssen, hjanssen, Haiyang Zhang, devel, virtualization,
	linux-kernel
In-Reply-To: <20100930121210.GA14358@kroah.com>

On Thu, 30 Sep 2010 05:12:10 -0700
Greg KH <greg@kroah.com> wrote:

> On Wed, Sep 29, 2010 at 09:21:50PM -0700, Hank Janssen wrote:
> > 
> > Rename camel case variables in channel.c and changed them to
> > lowercase.
> > 
> > Sending this from my own accounts till we have a proper mail server
> > set up that allows us to send out patches without issues.
> 
> This paragraph goes below the '---' line, it doesn't belong in the
> change log, right?


I recently read something about 'scissor lines' which allow more
natural reading flow with patches by git automatically skipping
everything above a scissor-line:
'A line that mainly consists of scissors (either ">8" or "8<") and 
perforation (dash "-") marks is called a scissors line'

man git-mailinfo
git-am -c

:-)

Cheers,
Flo

^ permalink raw reply

* Re: [RFC PATCH] virtio: (Partially) enable suspend/resume support
From: Michael S. Tsirkin @ 2010-10-03 15:53 UTC (permalink / raw)
  To: Amit Shah; +Cc: Anthony Liguori, Virtualization List
In-Reply-To: <da50daa251eb982c43fa474de8d4f1303f1ad57f.1285762305.git.amit.shah@redhat.com>

On Wed, Sep 29, 2010 at 05:42:24PM +0530, Amit Shah wrote:
> Let host know of our state (partial yet) so that the host PCI device is
> up to where we were when we were suspended.
> 
> This is still an RFC as this doesn't completely work: an unused device
> at the time of suspend will work fine after resume, but a device that
> has seen some activity doesn't behave well after resume.  Especially,
> host->guest communication doesn't go through.  This could be due to
> interrupts/MSI not being wired properly.  I haven't looked at this part
> of the problem yet.
> 
> We also need a per-driver resume callback which can update the devices
> with driver-specific data.  Eg, for virtio_console, the guest port
> open/close status will have to be known to the device.
> 
> QEMU also starts using the queues as soon as the VIRTIO_PCI_QUEUE_PFN
> command is sent, so it has to be taught to only start using queues when
> the device is ready and the queues are set up.
> 
> However, I just wanted to send this out to get reactions / comments.
> 
> Not-yet-Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  drivers/virtio/virtio_pci.c  |   34 ++++++++++++++++++++++++++++++++++
>  drivers/virtio/virtio_ring.c |    8 ++++++++
>  include/linux/virtio.h       |    2 ++
>  include/linux/virtio_pci.h   |    4 +++-
>  4 files changed, 47 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> index ef8d9d5..a3c7f59 100644
> --- a/drivers/virtio/virtio_pci.c
> +++ b/drivers/virtio/virtio_pci.c
> @@ -698,8 +698,42 @@ static int virtio_pci_suspend(struct pci_dev *pci_dev, pm_message_t state)
>  
>  static int virtio_pci_resume(struct pci_dev *pci_dev)
>  {
> +	struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
> +	struct virtio_pci_vq_info *info;
> +	unsigned long flags;
> +
>  	pci_restore_state(pci_dev);
>  	pci_set_power_state(pci_dev, PCI_D0);
> +
> +	iowrite32(vp_dev->vdev.features[0], vp_dev->ioaddr+VIRTIO_PCI_GUEST_FEATURES);

need spaces around +

> +	if (vp_dev->msix_used_vectors)
> +		iowrite16(vp_dev->msix_used_vectors,
> +			  vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);

I think this is wrong, msix_used_vectors is a counter not a vector
number, try with 2 vectors and it will break I think: this is shared
vectors configuration.  We just never had a need to remember the config
vector number, either do remember it, or rely on the fact that it is
always 0 in our code: and maybe add BUG_ON in vp_request_msix_vectors
where it is first assigned. The condition would simply be
msix_enabled.



> +
> +	spin_lock_irqsave(&vp_dev->lock, flags);
> +	list_for_each_entry(info, &vp_dev->virtqueues, node) {
> +		/* Select the queue we're interested in */
> +		iowrite16(info->queue_index,
> +			  vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
> +
> +		/* Update the last idx we sent data in */
> +		iowrite16(virtqueue_get_avail_idx(info->vq),
> +			  vp_dev->ioaddr + VIRTIO_PCI_AVAIL_IDX);

Interesting. Could we just reset the ring instead?
I think this would also solve the qemu problem you
outline, won't it?

> +
> +		if (info->msix_vector != VIRTIO_MSI_NO_VECTOR) {
> +			iowrite16(info->msix_vector,
> +				  vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR);
> +		}

actually it's probably better to write msix_vector if it is
VIRTIO_MSI_NO_VECTOR as well, just to make sure
we are in a known state.  The condition
should be that msix is enabled in the device.

Further, please read the value back and verify that it was
written successfully: on error you get VIRTIO_MSI_NO_VECTOR.


> +
> +		/* activate the queue */
> +		iowrite32(virt_to_phys(info->queue) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT,
> +			  vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
> +
> +	}
> +	spin_unlock_irqrestore(&vp_dev->lock, flags);
> +
> +	vp_set_status(&vp_dev->vdev, VIRTIO_CONFIG_S_DRIVER_OK);
> +
>  	return 0;
>  }
>  #endif
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 1475ed6..3eb91d1 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -237,6 +237,14 @@ add_head:
>  }
>  EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);
>  
> +u16 virtqueue_get_avail_idx(struct virtqueue *_vq)
> +{
> +	struct vring_virtqueue *vq = to_vvq(_vq);
> +
> +	return vq->vring.avail->idx;
> +}
> +EXPORT_SYMBOL_GPL(virtqueue_get_avail_idx);
> +
>  void virtqueue_kick(struct virtqueue *_vq)
>  {
>  	struct vring_virtqueue *vq = to_vvq(_vq);
> diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> index aff5b4f..cdb04ec 100644
> --- a/include/linux/virtio.h
> +++ b/include/linux/virtio.h
> @@ -88,6 +88,8 @@ bool virtqueue_enable_cb(struct virtqueue *vq);
>  
>  void *virtqueue_detach_unused_buf(struct virtqueue *vq);
>  
> +u16 virtqueue_get_avail_idx(struct virtqueue *vq);
> +

This is a bit of a layering violation, in that the avail index
belongs to the ring internals. Possibly the best solution to expose it
is to put the index in the ring. This was one of the ideas
proposed for vring2. Other options include getting rid of the
index entirely.

>  /**
>   * virtio_device - representation of a device using virtio
>   * @index: unique position on the virtio bus
> diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
> index 9a3d7c4..aa3e584 100644
> --- a/include/linux/virtio_pci.h
> +++ b/include/linux/virtio_pci.h
> @@ -55,9 +55,11 @@
>  /* Vector value used to disable MSI for queue */
>  #define VIRTIO_MSI_NO_VECTOR            0xffff
>  
> +#define VIRTIO_PCI_AVAIL_IDX		24
> +
>  /* The remaining space is defined by each driver as the per-driver
>   * configuration space */
> -#define VIRTIO_PCI_CONFIG(dev)		((dev)->msix_enabled ? 24 : 20)
> +#define VIRTIO_PCI_CONFIG(dev)		26

This will silently break all devices out there, won't it?

>  
>  /* Virtio ABI version, this must match exactly */
>  #define VIRTIO_PCI_ABI_VERSION		0
> -- 
> 1.7.2.3
> 
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* [PATCH 1/1] staging: hv: Remove camel case variables in channel.c
From: Hank Janssen @ 2010-09-30 17:52 UTC (permalink / raw)
  To: Haiyang Zhang, hjanssen, devel, virtualization, linux-kernel; +Cc: gregkh


From: Haiyang Zhang <haiyangz@microsoft.com>

Rename camel case variables in channel.c and changed them to
lowercase.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>

---
 drivers/staging/hv/channel.c |  767 +++++++++++++++++++++---------------------
 1 files changed, 387 insertions(+), 380 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 37b7b4c..1037488 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -28,10 +28,10 @@
 
 /* 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);
+	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);
 
@@ -70,25 +70,25 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
  * VmbusChannelSetEvent - Trigger an event notification on the specified
  * channel.
  */
-static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
+static void VmbusChannelSetEvent(struct vmbus_channel *channel)
 {
-	struct hv_monitor_page *monitorPage;
+	struct hv_monitor_page *monitorpage;
 
-	if (Channel->OfferMsg.MonitorAllocated) {
+	if (channel->OfferMsg.MonitorAllocated) {
 		/* Each u32 represents 32 channels */
-		set_bit(Channel->OfferMsg.ChildRelId & 31,
+		set_bit(channel->OfferMsg.ChildRelId & 31,
 			(unsigned long *) gVmbusConnection.SendInterruptPage +
-			(Channel->OfferMsg.ChildRelId >> 5));
+			(channel->OfferMsg.ChildRelId >> 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->MonitorBit,
+			(unsigned long *)&monitorpage->TriggerGroup
+					[channel->MonitorGroup].Pending);
 
 	} else {
-		VmbusSetEvent(Channel->OfferMsg.ChildRelId);
+		VmbusSetEvent(channel->OfferMsg.ChildRelId);
 	}
 }
 
@@ -117,54 +117,54 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
 /*
  * VmbusChannelGetDebugInfo -Retrieve various channel debug info
  */
-void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
-			      struct vmbus_channel_debug_info *DebugInfo)
+void VmbusChannelGetDebugInfo(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.ChildRelId;
+	debuginfo->State = channel->State;
+	memcpy(&debuginfo->InterfaceType,
+	       &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
+	memcpy(&debuginfo->InterfaceInstance,
+	       &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->ServerMonitorPending =
+			monitorpage->TriggerGroup[monitor_group].Pending;
+	debuginfo->ServerMonitorLatency =
+			monitorpage->Latency[monitor_group][monitor_offset];
+	debuginfo->ServerMonitorConnectionId =
+			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->ClientMonitorPending =
+			monitorpage->TriggerGroup[monitor_group].Pending;
+	debuginfo->ClientMonitorLatency =
+			monitorpage->Latency[monitor_group][monitor_offset];
+	debuginfo->ClientMonitorConnectionId =
+			monitorpage->Parameter[monitor_group]
+					[monitor_offset].ConnectionId.u.Id;
 
-	RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound);
-	RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound);
+	RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound);
+	RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound);
 }
 
 /*
  * VmbusChannelOpen - 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 VmbusChannelOpen(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->OnChannelCallback = onchannelcallback;
+	newchannel->ChannelCallbackContext = context;
 
 	/* Allocate the ring buffer */
-	out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize)
+	out = osd_PageAlloc((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->RingBufferPages = out;
+	newchannel->RingBufferPageCount = (send_ringbuffer_size +
+					   recv_ringbuffer_size) >> PAGE_SHIFT;
 
-	ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
+	ret = RingBufferInit(&newchannel->Outbound, out, send_ringbuffer_size);
 	if (ret != 0) {
 		err = ret;
 		goto errorout;
 	}
 
-	ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
+	ret = RingBufferInit(&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->RingBufferGpadlHandle = 0;
 
-	ret = VmbusChannelEstablishGpadl(NewChannel,
-					 NewChannel->Outbound.RingBuffer,
-					 SendRingBufferSize +
-					 RecvRingBufferSize,
-					 &NewChannel->RingBufferGpadlHandle);
+	ret = VmbusChannelEstablishGpadl(newchannel,
+					 newchannel->Outbound.RingBuffer,
+					 send_ringbuffer_size +
+					 recv_ringbuffer_size,
+					 &newchannel->RingBufferGpadlHandle);
 
 	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.ChildRelId,
+		   newchannel->RingBufferGpadlHandle,
+		   newchannel->Outbound.RingBuffer,
+		   newchannel->Outbound.RingSize,
+		   newchannel->Inbound.RingBuffer,
+		   newchannel->Inbound.RingSize,
+		   send_ringbuffer_size);
 
 	/* Create and init the channel open message */
 	openInfo = kmalloc(sizeof(*openInfo) +
@@ -250,20 +250,20 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
 
 	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->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */
+	openMsg->ChildRelId = newchannel->OfferMsg.ChildRelId;
+	openMsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle;
+	openMsg->DownstreamRingBufferPageOffset = send_ringbuffer_size >>
 						  PAGE_SHIFT;
 	openMsg->ServerContextAreaGpadlHandle = 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,
@@ -283,10 +283,10 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
 	osd_WaitEventWait(openInfo->WaitEvent);
 
 	if (openInfo->Response.OpenResult.Status == 0)
-		DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel);
+		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.OpenResult.Status);
 
 Cleanup:
 	spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
@@ -298,9 +298,9 @@ Cleanup:
 	return 0;
 
 errorout:
-	RingBufferCleanup(&NewChannel->Outbound);
-	RingBufferCleanup(&NewChannel->Inbound);
-	osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize)
+	RingBufferCleanup(&newchannel->Outbound);
+	RingBufferCleanup(&newchannel->Inbound);
+	osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size)
 		     >> PAGE_SHIFT);
 	kfree(openInfo);
 	return err;
@@ -310,289 +310,292 @@ errorout:
  * DumpGpadlBody - Dump the gpadl body message to the console for
  * debugging purposes.
  */
-static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len)
+static void DumpGpadlBody(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
  * debugging purposes.
  */
-static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl)
+static void DumpGpadlHeader(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->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen);
+	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
  */
-static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
-					 struct vmbus_channel_msginfo **MsgInfo,
-					 u32 *MessageCount)
+static int VmbusChannelCreateGpadlHeader(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->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 < 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->RangeBufLen = 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->MessageSize = 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->MessageSize = msgsize;
+
+		gpadl_header = (struct vmbus_channel_gpadl_header *)
+			msgheader->Msg;
+		gpadl_header->RangeCount = 1;
+		gpadl_header->RangeBufLen = 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
  *
- * @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 VmbusChannelEstablishGpadl(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 = VmbusChannelCreateGpadlHeader(kbuffer, size, &msginfo, &msgcount);
 	if (ret)
 		return ret;
 
-	msgInfo->WaitEvent = osd_WaitEventCreate();
-	if (!msgInfo->WaitEvent) {
+	msginfo->WaitEvent = osd_WaitEventCreate();
+	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.MessageType = ChannelMessageGpadlHeader;
+	gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
+	gpadlmsg->Gpadl = next_gpadl_handle;
 
-	DumpGpadlHeader(gpadlMsg);
+	DumpGpadlHeader(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->MessageSize - sizeof(*msginfo));
 
-	ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize -
-			       sizeof(*msgInfo));
+	ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize -
+			       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.MessageType =
+				ChannelMessageGpadlBody;
+			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->MessageSize -
+				   sizeof(*submsginfo));
+
+			DumpGpadlBody(gpadl_body, submsginfo->MessageSize -
+				      sizeof(*submsginfo));
+			ret = VmbusPostMessage(gpadl_body,
+					       submsginfo->MessageSize -
+					       sizeof(*submsginfo));
 			if (ret != 0)
 				goto Cleanup;
 
 		}
 	}
-	osd_WaitEventWait(msgInfo->WaitEvent);
+	osd_WaitEventWait(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.ChildRelId,
+		   msginfo->Response.GpadlCreated.CreationStatus,
+		   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;
 }
 
 /*
  * VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
  */
-int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
+int VmbusChannelTeardownGpadl(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);
@@ -608,8 +611,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
 	msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
 
 	msg->Header.MessageType = ChannelMessageGpadlTeardown;
-	msg->ChildRelId = Channel->OfferMsg.ChildRelId;
-	msg->Gpadl = GpadlHandle;
+	msg->ChildRelId = channel->OfferMsg.ChildRelId;
+	msg->Gpadl = gpadl_handle;
 
 	spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
 	list_add_tail(&info->MsgListEntry,
@@ -638,7 +641,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
 /*
  * VmbusChannelClose - Close the specified channel
  */
-void VmbusChannelClose(struct vmbus_channel *Channel)
+void VmbusChannelClose(struct vmbus_channel *channel)
 {
 	struct vmbus_channel_close_channel *msg;
 	struct vmbus_channel_msginfo *info;
@@ -646,8 +649,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->OnChannelCallback = NULL;
+	del_timer_sync(&channel->poll_timer);
 
 	/* Send a closing message */
 	info = kmalloc(sizeof(*info) +
@@ -661,7 +664,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
 
 	msg = (struct vmbus_channel_close_channel *)info->Msg;
 	msg->Header.MessageType = ChannelMessageCloseChannel;
-	msg->ChildRelId = Channel->OfferMsg.ChildRelId;
+	msg->ChildRelId = channel->OfferMsg.ChildRelId;
 
 	ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
 	if (ret != 0) {
@@ -670,17 +673,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->RingBufferGpadlHandle)
+		VmbusChannelTeardownGpadl(channel,
+					  channel->RingBufferGpadlHandle);
 
 	/* TODO: Send a msg to release the childRelId */
 
 	/* Cleanup the ring buffers for this channel */
-	RingBufferCleanup(&Channel->Outbound);
-	RingBufferCleanup(&Channel->Inbound);
+	RingBufferCleanup(&channel->Outbound);
+	RingBufferCleanup(&channel->Inbound);
 
-	osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+	osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount);
 
 	kfree(info);
 
@@ -690,65 +693,66 @@ 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);
+		FreeVmbusChannel(channel);
 	}
 }
 
 /**
  * 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
+ * @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 VmbusChannelSendPacket(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);
+	DumpVmbusChannel(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 = RingBufferWrite(&channel->Outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-		VmbusChannelSetEvent(Channel);
+	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+		VmbusChannelSetEvent(channel);
 
 	return ret;
 }
@@ -758,61 +762,62 @@ EXPORT_SYMBOL(VmbusChannelSendPacket);
  * VmbusChannelSendPacketPageBuffer - 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 VmbusChannelSendPacketPageBuffer(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;
+	u32 descsize;
+	u32 packetlen;
+	u32 packetlen_aligned;
+	struct scatterlist bufferlist[3];
+	u64 aligned_data = 0;
 
-	if (PageCount > MAX_PAGE_BUFFER_COUNT)
+	if (pagecount > MAX_PAGE_BUFFER_COUNT)
 		return -EINVAL;
 
-	DumpVmbusChannel(Channel);
+	DumpVmbusChannel(channel);
 
 	/*
 	 * 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.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 = RingBufferWrite(&channel->Outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-		VmbusChannelSetEvent(Channel);
+	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+		VmbusChannelSetEvent(channel);
 
 	return ret;
 }
@@ -821,64 +826,66 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
  * VmbusChannelSendPacketMultiPageBuffer - 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 VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
+				struct hv_multipage_buffer *multi_pagebuffer,
+				void *buffer, u32 bufferlen, u64 requestid)
 {
 	int ret;
 	struct vmbus_channel_packet_multipage_buffer desc;
-	u32 descSize;
-	u32 packetLen;
-	u32 packetLenAligned;
-	struct scatterlist bufferList[3];
-	u64 alignedData = 0;
-	u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset,
-					 MultiPageBuffer->Length);
+	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);
+	DumpVmbusChannel(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_multipage_buffer is
 	 * the largest size we support
 	 */
-	descSize = sizeof(struct vmbus_channel_packet_multipage_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.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 = RingBufferWrite(&channel->Outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-		VmbusChannelSetEvent(Channel);
+	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+		VmbusChannelSetEvent(channel);
 
 	return ret;
 }
@@ -886,35 +893,35 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
 
 /**
  * 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
+ * @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 VmbusChannelRecvPacket(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 = RingBufferPeek(&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,32 +929,32 @@ 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.ChildRelId, 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 = RingBufferRead(&channel->Inbound, buffer, userlen,
 			     (desc.DataOffset8 << 3));
 
-	spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
 	return 0;
 }
@@ -956,25 +963,25 @@ EXPORT_SYMBOL(VmbusChannelRecvPacket);
 /*
  * VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel
  */
-int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
-			      u32 BufferLen, u32 *BufferActualLen,
-			      u64 *RequestId)
+int VmbusChannelRecvPacketRaw(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 = RingBufferPeek(&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,44 +989,44 @@ 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.ChildRelId, 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 = RingBufferRead(&channel->Inbound, buffer, packetlen, 0);
 
-	spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 	return 0;
 }
 
 /*
  * VmbusChannelOnChannelEvent - Channel event callback
  */
-void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel)
+void VmbusChannelOnChannelEvent(struct vmbus_channel *channel)
 {
-	DumpVmbusChannel(Channel);
+	DumpVmbusChannel(channel);
 	/* ASSERT(Channel->OnChannelCallback); */
 
-	Channel->OnChannelCallback(Channel->ChannelCallbackContext);
+	channel->OnChannelCallback(channel->ChannelCallbackContext);
 
-	mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100));
+	mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
 }
 
 /*
@@ -1036,9 +1043,9 @@ void VmbusChannelOnTimer(unsigned long data)
 /*
  * DumpVmbusChannel - Dump vmbus channel info to the console
  */
-static void DumpVmbusChannel(struct vmbus_channel *Channel)
+static void DumpVmbusChannel(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.ChildRelId);
+	DumpRingInfo(&channel->Outbound, "Outbound ");
+	DumpRingInfo(&channel->Inbound, "Inbound ");
 }
-- 
1.6.3.2

^ permalink raw reply related

* Re: [PATCH 1/1] staging: hv: Remove camel case variables in channel.c
From: Greg KH @ 2010-09-30 12:12 UTC (permalink / raw)
  To: Hank Janssen; +Cc: hjanssen, Haiyang Zhang, devel, virtualization, linux-kernel
In-Reply-To: <4CA4105E.80602@sailtheuniverse.com>

On Wed, Sep 29, 2010 at 09:21:50PM -0700, Hank Janssen wrote:
> 
> Rename camel case variables in channel.c and changed them to
> lowercase.
> 
> Sending this from my own accounts till we have a proper mail server
> set up that allows us to send out patches without issues.

This paragraph goes below the '---' line, it doesn't belong in the
change log, right?

> This patch was created by Haiyang Zhang.

Then put the proper "From:" line in the email body like the file,
Documentation/SubmittingPatches tells you to do so that git properly
credits the correct author.

Oh, you also forgot to cc: me so I know to pick the patch up :)

Care to try it again?

thanks,

greg k-h

^ permalink raw reply

* [PATCH 1/1] staging: hv: Remove camel case variables in channel.c
From: Hank Janssen @ 2010-09-30  4:21 UTC (permalink / raw)
  To: hjanssen, Haiyang Zhang, devel, virtualization, linux-kernel


Rename camel case variables in channel.c and changed them to
lowercase.

Sending this from my own accounts till we have a proper mail server
set up that allows us to send out patches without issues.

This patch was created by Haiyang Zhang.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>

---
 drivers/staging/hv/channel.c |  767 +++++++++++++++++++++---------------------
 1 files changed, 387 insertions(+), 380 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 37b7b4c..1037488 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -28,10 +28,10 @@
 
 /* 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);
+	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);
 
@@ -70,25 +70,25 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
  * VmbusChannelSetEvent - Trigger an event notification on the specified
  * channel.
  */
-static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
+static void VmbusChannelSetEvent(struct vmbus_channel *channel)
 {
-	struct hv_monitor_page *monitorPage;
+	struct hv_monitor_page *monitorpage;
 
-	if (Channel->OfferMsg.MonitorAllocated) {
+	if (channel->OfferMsg.MonitorAllocated) {
 		/* Each u32 represents 32 channels */
-		set_bit(Channel->OfferMsg.ChildRelId & 31,
+		set_bit(channel->OfferMsg.ChildRelId & 31,
 			(unsigned long *) gVmbusConnection.SendInterruptPage +
-			(Channel->OfferMsg.ChildRelId >> 5));
+			(channel->OfferMsg.ChildRelId >> 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->MonitorBit,
+			(unsigned long *)&monitorpage->TriggerGroup
+					[channel->MonitorGroup].Pending);
 
 	} else {
-		VmbusSetEvent(Channel->OfferMsg.ChildRelId);
+		VmbusSetEvent(channel->OfferMsg.ChildRelId);
 	}
 }
 
@@ -117,54 +117,54 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
 /*
  * VmbusChannelGetDebugInfo -Retrieve various channel debug info
  */
-void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
-			      struct vmbus_channel_debug_info *DebugInfo)
+void VmbusChannelGetDebugInfo(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.ChildRelId;
+	debuginfo->State = channel->State;
+	memcpy(&debuginfo->InterfaceType,
+	       &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
+	memcpy(&debuginfo->InterfaceInstance,
+	       &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->ServerMonitorPending =
+			monitorpage->TriggerGroup[monitor_group].Pending;
+	debuginfo->ServerMonitorLatency =
+			monitorpage->Latency[monitor_group][monitor_offset];
+	debuginfo->ServerMonitorConnectionId =
+			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->ClientMonitorPending =
+			monitorpage->TriggerGroup[monitor_group].Pending;
+	debuginfo->ClientMonitorLatency =
+			monitorpage->Latency[monitor_group][monitor_offset];
+	debuginfo->ClientMonitorConnectionId =
+			monitorpage->Parameter[monitor_group]
+					[monitor_offset].ConnectionId.u.Id;
 
-	RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound);
-	RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound);
+	RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound);
+	RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound);
 }
 
 /*
  * VmbusChannelOpen - 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 VmbusChannelOpen(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->OnChannelCallback = onchannelcallback;
+	newchannel->ChannelCallbackContext = context;
 
 	/* Allocate the ring buffer */
-	out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize)
+	out = osd_PageAlloc((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->RingBufferPages = out;
+	newchannel->RingBufferPageCount = (send_ringbuffer_size +
+					   recv_ringbuffer_size) >> PAGE_SHIFT;
 
-	ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
+	ret = RingBufferInit(&newchannel->Outbound, out, send_ringbuffer_size);
 	if (ret != 0) {
 		err = ret;
 		goto errorout;
 	}
 
-	ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
+	ret = RingBufferInit(&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->RingBufferGpadlHandle = 0;
 
-	ret = VmbusChannelEstablishGpadl(NewChannel,
-					 NewChannel->Outbound.RingBuffer,
-					 SendRingBufferSize +
-					 RecvRingBufferSize,
-					 &NewChannel->RingBufferGpadlHandle);
+	ret = VmbusChannelEstablishGpadl(newchannel,
+					 newchannel->Outbound.RingBuffer,
+					 send_ringbuffer_size +
+					 recv_ringbuffer_size,
+					 &newchannel->RingBufferGpadlHandle);
 
 	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.ChildRelId,
+		   newchannel->RingBufferGpadlHandle,
+		   newchannel->Outbound.RingBuffer,
+		   newchannel->Outbound.RingSize,
+		   newchannel->Inbound.RingBuffer,
+		   newchannel->Inbound.RingSize,
+		   send_ringbuffer_size);
 
 	/* Create and init the channel open message */
 	openInfo = kmalloc(sizeof(*openInfo) +
@@ -250,20 +250,20 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
 
 	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->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */
+	openMsg->ChildRelId = newchannel->OfferMsg.ChildRelId;
+	openMsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle;
+	openMsg->DownstreamRingBufferPageOffset = send_ringbuffer_size >>
 						  PAGE_SHIFT;
 	openMsg->ServerContextAreaGpadlHandle = 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,
@@ -283,10 +283,10 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
 	osd_WaitEventWait(openInfo->WaitEvent);
 
 	if (openInfo->Response.OpenResult.Status == 0)
-		DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel);
+		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.OpenResult.Status);
 
 Cleanup:
 	spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
@@ -298,9 +298,9 @@ Cleanup:
 	return 0;
 
 errorout:
-	RingBufferCleanup(&NewChannel->Outbound);
-	RingBufferCleanup(&NewChannel->Inbound);
-	osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize)
+	RingBufferCleanup(&newchannel->Outbound);
+	RingBufferCleanup(&newchannel->Inbound);
+	osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size)
 		     >> PAGE_SHIFT);
 	kfree(openInfo);
 	return err;
@@ -310,289 +310,292 @@ errorout:
  * DumpGpadlBody - Dump the gpadl body message to the console for
  * debugging purposes.
  */
-static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len)
+static void DumpGpadlBody(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
  * debugging purposes.
  */
-static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl)
+static void DumpGpadlHeader(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->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen);
+	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
  */
-static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
-					 struct vmbus_channel_msginfo **MsgInfo,
-					 u32 *MessageCount)
+static int VmbusChannelCreateGpadlHeader(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->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 < 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->RangeBufLen = 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->MessageSize = 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->MessageSize = msgsize;
+
+		gpadl_header = (struct vmbus_channel_gpadl_header *)
+			msgheader->Msg;
+		gpadl_header->RangeCount = 1;
+		gpadl_header->RangeBufLen = 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
  *
- * @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 VmbusChannelEstablishGpadl(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 = VmbusChannelCreateGpadlHeader(kbuffer, size, &msginfo, &msgcount);
 	if (ret)
 		return ret;
 
-	msgInfo->WaitEvent = osd_WaitEventCreate();
-	if (!msgInfo->WaitEvent) {
+	msginfo->WaitEvent = osd_WaitEventCreate();
+	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.MessageType = ChannelMessageGpadlHeader;
+	gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
+	gpadlmsg->Gpadl = next_gpadl_handle;
 
-	DumpGpadlHeader(gpadlMsg);
+	DumpGpadlHeader(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->MessageSize - sizeof(*msginfo));
 
-	ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize -
-			       sizeof(*msgInfo));
+	ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize -
+			       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.MessageType =
+				ChannelMessageGpadlBody;
+			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->MessageSize -
+				   sizeof(*submsginfo));
+
+			DumpGpadlBody(gpadl_body, submsginfo->MessageSize -
+				      sizeof(*submsginfo));
+			ret = VmbusPostMessage(gpadl_body,
+					       submsginfo->MessageSize -
+					       sizeof(*submsginfo));
 			if (ret != 0)
 				goto Cleanup;
 
 		}
 	}
-	osd_WaitEventWait(msgInfo->WaitEvent);
+	osd_WaitEventWait(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.ChildRelId,
+		   msginfo->Response.GpadlCreated.CreationStatus,
+		   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;
 }
 
 /*
  * VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
  */
-int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
+int VmbusChannelTeardownGpadl(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);
@@ -608,8 +611,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
 	msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
 
 	msg->Header.MessageType = ChannelMessageGpadlTeardown;
-	msg->ChildRelId = Channel->OfferMsg.ChildRelId;
-	msg->Gpadl = GpadlHandle;
+	msg->ChildRelId = channel->OfferMsg.ChildRelId;
+	msg->Gpadl = gpadl_handle;
 
 	spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
 	list_add_tail(&info->MsgListEntry,
@@ -638,7 +641,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
 /*
  * VmbusChannelClose - Close the specified channel
  */
-void VmbusChannelClose(struct vmbus_channel *Channel)
+void VmbusChannelClose(struct vmbus_channel *channel)
 {
 	struct vmbus_channel_close_channel *msg;
 	struct vmbus_channel_msginfo *info;
@@ -646,8 +649,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->OnChannelCallback = NULL;
+	del_timer_sync(&channel->poll_timer);
 
 	/* Send a closing message */
 	info = kmalloc(sizeof(*info) +
@@ -661,7 +664,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
 
 	msg = (struct vmbus_channel_close_channel *)info->Msg;
 	msg->Header.MessageType = ChannelMessageCloseChannel;
-	msg->ChildRelId = Channel->OfferMsg.ChildRelId;
+	msg->ChildRelId = channel->OfferMsg.ChildRelId;
 
 	ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
 	if (ret != 0) {
@@ -670,17 +673,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->RingBufferGpadlHandle)
+		VmbusChannelTeardownGpadl(channel,
+					  channel->RingBufferGpadlHandle);
 
 	/* TODO: Send a msg to release the childRelId */
 
 	/* Cleanup the ring buffers for this channel */
-	RingBufferCleanup(&Channel->Outbound);
-	RingBufferCleanup(&Channel->Inbound);
+	RingBufferCleanup(&channel->Outbound);
+	RingBufferCleanup(&channel->Inbound);
 
-	osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+	osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount);
 
 	kfree(info);
 
@@ -690,65 +693,66 @@ 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);
+		FreeVmbusChannel(channel);
 	}
 }
 
 /**
  * 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
+ * @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 VmbusChannelSendPacket(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);
+	DumpVmbusChannel(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 = RingBufferWrite(&channel->Outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-		VmbusChannelSetEvent(Channel);
+	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+		VmbusChannelSetEvent(channel);
 
 	return ret;
 }
@@ -758,61 +762,62 @@ EXPORT_SYMBOL(VmbusChannelSendPacket);
  * VmbusChannelSendPacketPageBuffer - 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 VmbusChannelSendPacketPageBuffer(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;
+	u32 descsize;
+	u32 packetlen;
+	u32 packetlen_aligned;
+	struct scatterlist bufferlist[3];
+	u64 aligned_data = 0;
 
-	if (PageCount > MAX_PAGE_BUFFER_COUNT)
+	if (pagecount > MAX_PAGE_BUFFER_COUNT)
 		return -EINVAL;
 
-	DumpVmbusChannel(Channel);
+	DumpVmbusChannel(channel);
 
 	/*
 	 * 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.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 = RingBufferWrite(&channel->Outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-		VmbusChannelSetEvent(Channel);
+	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+		VmbusChannelSetEvent(channel);
 
 	return ret;
 }
@@ -821,64 +826,66 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
  * VmbusChannelSendPacketMultiPageBuffer - 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 VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
+				struct hv_multipage_buffer *multi_pagebuffer,
+				void *buffer, u32 bufferlen, u64 requestid)
 {
 	int ret;
 	struct vmbus_channel_packet_multipage_buffer desc;
-	u32 descSize;
-	u32 packetLen;
-	u32 packetLenAligned;
-	struct scatterlist bufferList[3];
-	u64 alignedData = 0;
-	u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset,
-					 MultiPageBuffer->Length);
+	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);
+	DumpVmbusChannel(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_multipage_buffer is
 	 * the largest size we support
 	 */
-	descSize = sizeof(struct vmbus_channel_packet_multipage_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.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 = RingBufferWrite(&channel->Outbound, bufferlist, 3);
 
 	/* TODO: We should determine if this is optional */
-	if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
-		VmbusChannelSetEvent(Channel);
+	if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+		VmbusChannelSetEvent(channel);
 
 	return ret;
 }
@@ -886,35 +893,35 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
 
 /**
  * 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
+ * @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 VmbusChannelRecvPacket(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 = RingBufferPeek(&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,32 +929,32 @@ 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.ChildRelId, 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 = RingBufferRead(&channel->Inbound, buffer, userlen,
 			     (desc.DataOffset8 << 3));
 
-	spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
 	return 0;
 }
@@ -956,25 +963,25 @@ EXPORT_SYMBOL(VmbusChannelRecvPacket);
 /*
  * VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel
  */
-int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
-			      u32 BufferLen, u32 *BufferActualLen,
-			      u64 *RequestId)
+int VmbusChannelRecvPacketRaw(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 = RingBufferPeek(&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,44 +989,44 @@ 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.ChildRelId, 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 = RingBufferRead(&channel->Inbound, buffer, packetlen, 0);
 
-	spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+	spin_unlock_irqrestore(&channel->inbound_lock, flags);
 	return 0;
 }
 
 /*
  * VmbusChannelOnChannelEvent - Channel event callback
  */
-void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel)
+void VmbusChannelOnChannelEvent(struct vmbus_channel *channel)
 {
-	DumpVmbusChannel(Channel);
+	DumpVmbusChannel(channel);
 	/* ASSERT(Channel->OnChannelCallback); */
 
-	Channel->OnChannelCallback(Channel->ChannelCallbackContext);
+	channel->OnChannelCallback(channel->ChannelCallbackContext);
 
-	mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100));
+	mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
 }
 
 /*
@@ -1036,9 +1043,9 @@ void VmbusChannelOnTimer(unsigned long data)
 /*
  * DumpVmbusChannel - Dump vmbus channel info to the console
  */
-static void DumpVmbusChannel(struct vmbus_channel *Channel)
+static void DumpVmbusChannel(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.ChildRelId);
+	DumpRingInfo(&channel->Outbound, "Outbound ");
+	DumpRingInfo(&channel->Inbound, "Inbound ");
 }
-- 
1.6.3.2

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox