Linux virtualization list
 help / color / mirror / Atom feed
* [PATCH 21/22] Staging: hv: Move module parameter to earlier in the file
From: K. Y. Srinivasan @ 2011-03-28 17:00 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang, Abhishek Kane
In-Reply-To: <1301331653-26265-1-git-send-email-kys@microsoft.com>

Move module parameter to be earlier in the file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 95653da..14cc2ed 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -126,6 +126,9 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request);
 
 static int blkvsc_ringbuffer_size = BLKVSC_RING_BUFFER_SIZE;
 
+module_param(blkvsc_ringbuffer_size, int, S_IRUGO);
+MODULE_PARM_DESC(ring_size, "Ring buffer size (in bytes)");
+
 /*
  * There is a circular dependency involving blkvsc_probe()
  * and block_ops.
@@ -1219,9 +1222,6 @@ static void blkvsc_request(struct request_queue *queue)
 }
 
 
-module_param(blkvsc_ringbuffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(ring_size, "Ring buffer size (in bytes)");
-
 /* The one and only one */
 static  struct storvsc_driver_object g_blkvsc_drv;
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 22/22] Staging: hv: Get rid of some dead code in blkvsc_drv.c
From: K. Y. Srinivasan @ 2011-03-28 17:00 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Abhishek Kane, Hank Janssen
In-Reply-To: <1301331653-26265-1-git-send-email-kys@microsoft.com>

Get rid of some dead code in blkvsc_drv.c.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/blkvsc_drv.c |   26 --------------------------
 1 files changed, 0 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 14cc2ed..9faccbe 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -172,7 +172,6 @@ static int blk_vsc_initialize(struct hv_driver *driver)
 	stor_driver = hvdr_to_stordr(driver);
 
 	/* Make sure we are at least 2 pages since 1 page is used for control */
-	/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
 
 	driver->name = g_blk_driver_name;
 	memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
@@ -224,14 +223,6 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
 		   blkvsc_req->sector_count,
 		   blkvsc_req->request.data_buffer.offset,
 		   blkvsc_req->request.data_buffer.len);
-#if 0
-	for (i = 0; i < (blkvsc_req->request.data_buffer.len >> 12); i++) {
-		DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
-			   "req %p pfn[%d] %llx\n",
-			   blkvsc_req, i,
-			   blkvsc_req->request.data_buffer.pfn_array[i]);
-	}
-#endif
 
 	storvsc_req = &blkvsc_req->request;
 	vm_srb = &storvsc_req->vstor_packet.vm_srb;
@@ -373,9 +364,6 @@ static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
 
 static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
 {
-	/* ASSERT(blkvsc_req->req); */
-	/* ASSERT(blkvsc_req->sector_count <=
-	   (MAX_MULTIPAGE_BUFFER_COUNT*8)); */
 
 	blkvsc_req->cmd_len = 16;
 
@@ -432,7 +420,6 @@ static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
 static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
 			unsigned cmd, unsigned long argument)
 {
-/*	struct block_device_context *blkdev = bd->bd_disk->private_data; */
 	int ret;
 
 	switch (cmd) {
@@ -859,13 +846,6 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev)
 	blkdev->capacity = be64_to_cpu(*(unsigned long long *) &buf[0]) + 1;
 	blkdev->sector_size = be32_to_cpu(*(unsigned int *)&buf[8]);
 
-#if 0
-	blkdev->capacity = ((buf[0] << 24) | (buf[1] << 16) |
-			    (buf[2] << 8) | buf[3]) + 1;
-	blkdev->sector_size = (buf[4] << 24) | (buf[5] << 16) |
-			      (buf[6] << 8) | buf[7];
-#endif
-
 	kunmap(page_buf);
 
 	__free_page(page_buf);
@@ -937,7 +917,6 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev)
 
 	buf = kmap(page_buf);
 
-	/* print_hex_dump_bytes("", DUMP_PREFIX_NONE, buf, 64); */
 	/* be to le */
 	device_type = buf[0] & 0x1F;
 
@@ -957,8 +936,6 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev)
 		blkdev->device_id_len = 64;
 
 	memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len);
-	/* printk_hex_dump_bytes("", DUMP_PREFIX_NONE, blkdev->device_id,
-	 * blkdev->device_id_len); */
 
 	kunmap(page_buf);
 
@@ -1343,8 +1320,6 @@ static int blkvsc_probe(struct device *device)
 	/* Initialize what we can here */
 	spin_lock_init(&blkdev->lock);
 
-	/* ASSERT(sizeof(struct blkvsc_request_group) <= */
-	/* 	sizeof(struct blkvsc_request)); */
 
 	blkdev->request_pool = kmem_cache_create(dev_name(&device_obj->device),
 					sizeof(struct blkvsc_request), 0,
@@ -1480,7 +1455,6 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request)
 	struct blkvsc_request *comp_req, *tmp;
 	struct vmscsi_request *vm_srb;
 
-	/* ASSERT(blkvsc_req->group); */
 
 	DPRINT_DBG(BLKVSC_DRV, "blkdev %p blkvsc_req %p group %p type %s "
 		   "sect_start %lu sect_count %ld len %d group outstd %d "
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 00/07] Remove and replace all un-needed DPRINT and printk
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization

This patch set removes all un-needed DPRINT and printk calls and replaces
the remaining ones with the correct pr_, dev_ and netdev_ calls 
from hv_vmbus, hv_netvsc, hv_timesource and hv_utils.

Several DPRINTS are remaining that will be cleaned up in my next
set of patches. They deal with printing out certain debugging that will be 
implemented slightly differently.

The remaining hv_storvsc and hv_blkvsc will get the same treatment in
a different set of patches.

Regards,

Hank Janssen <hjanssen@microsoft.com>

^ permalink raw reply

* [PATCH 01/07] Remove all unneeded DPRINT from hv_vmbus
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1301432330-1705-1-git-send-email-hjanssen@microsoft.com>

Remove all un-needed DPRINT calls from hv_vmbus. Several
are remaining that will be cleaned up in my next set of patches.
They deal with printing out the ringbuffer debugging which is
going to be implemented slightly differently.

This patch deals with hv_vmbus only.

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

---
 drivers/staging/hv/channel.c      |   70 ++++---------------------------------
 drivers/staging/hv/channel_mgmt.c |   51 ++-------------------------
 drivers/staging/hv/connection.c   |    9 -----
 drivers/staging/hv/hv.c           |   54 ++++------------------------
 drivers/staging/hv/ring_buffer.c  |   20 ----------
 drivers/staging/hv/vmbus_drv.c    |   69 +-----------------------------------
 6 files changed, 21 insertions(+), 252 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 775a52a..c90dbaf 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -213,9 +213,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 
 
 	/* Establish the gpadl for the ring buffer */
-	DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
-		   newchannel);
-
 	newchannel->ringbuffer_gpadlhandle = 0;
 
 	ret = vmbus_establish_gpadl(newchannel,
@@ -229,16 +226,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		goto errorout;
 	}
 
-	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.child_relid,
-		   newchannel->ringbuffer_gpadlhandle,
-		   newchannel->outbound.ring_buffer,
-		   newchannel->outbound.ring_size,
-		   newchannel->inbound.ring_buffer,
-		   newchannel->inbound.ring_size,
-		   send_ringbuffer_size);
-
 	/* Create and init the channel open message */
 	openInfo = kmalloc(sizeof(*openInfo) +
 			   sizeof(struct vmbus_channel_open_channel),
@@ -272,14 +259,11 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	DPRINT_DBG(VMBUS, "Sending channel open msg...");
-
 	ret = vmbus_post_msg(openMsg,
 			       sizeof(struct vmbus_channel_open_channel));
-	if (ret != 0) {
-		DPRINT_ERR(VMBUS, "unable to open channel - %d", ret);
+
+	if (ret != 0)
 		goto Cleanup;
-	}
 
 	openInfo->wait_condition = 0;
 	wait_event_timeout(openInfo->waitevent,
@@ -291,11 +275,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	}
 
 
-	if (openInfo->response.open_result.status == 0)
-		DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
-	else
-		DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
-			    newchannel, openInfo->response.open_result.status);
+	if (openInfo->response.open_result.status)
+		err = openInfo->response.open_result.status;
 
 Cleanup:
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
@@ -303,7 +284,7 @@ Cleanup:
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
 	kfree(openInfo);
-	return 0;
+	return err;
 
 errorout:
 	ringbuffer_cleanup(&newchannel->outbound);
@@ -326,6 +307,7 @@ static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len)
 
 	pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
 		   sizeof(u64);
+
 	DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
 
 	for (i = 0; i < pfncount; i++)
@@ -530,19 +512,12 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 		      &vmbus_connection.chn_msg_list);
 
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
-	DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
-		   kbuffer, size, msgcount);
-
-	DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
-		   msginfo->msgsize - sizeof(*msginfo));
 
 	msginfo->wait_condition = 0;
 	ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
 			       sizeof(*msginfo));
-	if (ret != 0) {
-		DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
+	if (ret != 0)
 		goto Cleanup;
-	}
 
 	if (msgcount > 1) {
 		list_for_each(curr, &msginfo->submsglist) {
@@ -556,10 +531,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 				CHANNELMSG_GPADL_BODY;
 			gpadl_body->gpadl = next_gpadl_handle;
 
-			DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
-				   submsginfo->msgsize -
-				   sizeof(*submsginfo));
-
 			dump_gpadl_body(gpadl_body, submsginfo->msgsize -
 				      sizeof(*submsginfo));
 			ret = vmbus_post_msg(gpadl_body,
@@ -577,12 +548,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 
 
 	/* At this point, we received the gpadl created msg */
-	DPRINT_DBG(VMBUS, "Received GPADL created "
-		   "(relid %d, status %d handle %x)",
-		   channel->offermsg.child_relid,
-		   msginfo->response.gpadl_created.creation_status,
-		   gpadlmsg->gpadl);
-
 	*gpadl_handle = gpadlmsg->gpadl;
 
 Cleanup:
@@ -730,9 +695,6 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
 	u64 aligned_data = 0;
 	int ret;
 
-	DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
-		   channel, buffer, bufferlen);
-
 	dump_vmbus_channel(channel);
 
 	/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
@@ -846,10 +808,6 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 
 	dump_vmbus_channel(channel);
 
-	DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
-		multi_pagebuffer->offset,
-		multi_pagebuffer->len, pfncount);
-
 	if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
 		return -EINVAL;
 
@@ -926,8 +884,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 			     sizeof(struct vmpacket_descriptor));
 	if (ret != 0) {
 		spin_unlock_irqrestore(&channel->inbound_lock, flags);
-
-		/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
 		return 0;
 	}
 
@@ -937,11 +893,6 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 	userlen = packetlen - (desc.offset8 << 3);
 	/* ASSERT(userLen > 0); */
 
-	DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
-		   "flag %d tid %llx pktlen %d datalen %d> ",
-		   channel, channel->offermsg.child_relid, desc.type,
-		   desc.flags, desc.trans_id, packetlen, userlen);
-
 	*buffer_actual_len = userlen;
 
 	if (userlen > bufferlen) {
@@ -986,8 +937,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 			     sizeof(struct vmpacket_descriptor));
 	if (ret != 0) {
 		spin_unlock_irqrestore(&channel->inbound_lock, flags);
-
-		/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
 		return 0;
 	}
 
@@ -996,11 +945,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 	packetlen = desc.len8 << 3;
 	userlen = packetlen - (desc.offset8 << 3);
 
-	DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
-		   "flag %d tid %llx pktlen %d datalen %d> ",
-		   channel, channel->offermsg.child_relid, desc.type,
-		   desc.flags, desc.trans_id, packetlen, userlen);
-
 	*buffer_actual_len = packetlen;
 
 	if (packetlen > bufferlen) {
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index bc0393a..ebdd9d8 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -290,9 +290,7 @@ static void release_channel(struct work_struct *work)
 						     struct vmbus_channel,
 						     work);
 
-	DPRINT_DBG(VMBUS, "releasing channel (%p)", channel);
 	destroy_workqueue(channel->controlwq);
-	DPRINT_DBG(VMBUS, "channel released (%p)", channel);
 
 	kfree(channel);
 }
@@ -384,8 +382,6 @@ static void vmbus_process_offer(struct work_struct *work)
 	spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
 
 	if (!fnew) {
-		DPRINT_DBG(VMBUS, "Ignoring duplicate offer for relid (%d)",
-			   newchannel->offermsg.child_relid);
 		free_channel(newchannel);
 		return;
 	}
@@ -400,9 +396,6 @@ static void vmbus_process_offer(struct work_struct *work)
 		&newchannel->offermsg.offer.if_instance,
 		newchannel);
 
-	DPRINT_DBG(VMBUS, "child device object allocated - %p",
-		   newchannel->device_obj);
-
 	/*
 	 * Add the new device to the bus. This will kick off device-driver
 	 * binding which eventually invokes the device driver's AddDevice()
@@ -470,40 +463,12 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
 		}
 	}
 
-	if (!fsupported) {
-		DPRINT_DBG(VMBUS, "Ignoring channel offer notification for "
-			   "child relid %d", offer->child_relid);
+	if (!fsupported)
 		return;
-	}
 
 	guidtype = &offer->offer.if_type;
 	guidinstance = &offer->offer.if_instance;
 
-	DPRINT_INFO(VMBUS, "Channel offer notification - "
-		    "child relid %d monitor id %d allocated %d, "
-		    "type {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-		    "%02x%02x%02x%02x%02x%02x%02x%02x} "
-		    "instance {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-		    "%02x%02x%02x%02x%02x%02x%02x%02x}",
-		    offer->child_relid, offer->monitorid,
-		    offer->monitor_allocated,
-		    guidtype->data[3], guidtype->data[2],
-		    guidtype->data[1], guidtype->data[0],
-		    guidtype->data[5], guidtype->data[4],
-		    guidtype->data[7], guidtype->data[6],
-		    guidtype->data[8], guidtype->data[9],
-		    guidtype->data[10], guidtype->data[11],
-		    guidtype->data[12], guidtype->data[13],
-		    guidtype->data[14], guidtype->data[15],
-		    guidinstance->data[3], guidinstance->data[2],
-		    guidinstance->data[1], guidinstance->data[0],
-		    guidinstance->data[5], guidinstance->data[4],
-		    guidinstance->data[7], guidinstance->data[6],
-		    guidinstance->data[8], guidinstance->data[9],
-		    guidinstance->data[10], guidinstance->data[11],
-		    guidinstance->data[12], guidinstance->data[13],
-		    guidinstance->data[14], guidinstance->data[15]);
-
 	/* Allocate the channel object and save this offer. */
 	newchannel = alloc_channel();
 	if (!newchannel) {
@@ -511,8 +476,6 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
 		return;
 	}
 
-	DPRINT_DBG(VMBUS, "channel object allocated - %p", newchannel);
-
 	memcpy(&newchannel->offermsg, offer,
 	       sizeof(struct vmbus_channel_offer_channel));
 	newchannel->monitor_grp = (u8)offer->monitorid / 32;
@@ -535,11 +498,10 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 
 	rescind = (struct vmbus_channel_rescind_offer *)hdr;
 	channel = relid2channel(rescind->child_relid);
-	if (channel == NULL) {
-		DPRINT_DBG(VMBUS, "channel not found for relId %d",
-			   rescind->child_relid);
+
+	if (channel == NULL)
+		/* Just return here, no channel found */
 		return;
-	}
 
 	/* work is initialized for vmbus_process_rescind_offer() from
 	 * vmbus_process_offer() where the channel got created */
@@ -573,7 +535,6 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
 	unsigned long flags;
 
 	result = (struct vmbus_channel_open_result *)hdr;
-	DPRINT_DBG(VMBUS, "vmbus open result - %d", result->status);
 
 	/*
 	 * Find the open msg, copy the result and signal/unblock the wait event
@@ -618,8 +579,6 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
 	unsigned long flags;
 
 	gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr;
-	DPRINT_DBG(VMBUS, "vmbus gpadl created result - %d",
-		   gpadlcreated->creation_status);
 
 	/*
 	 * Find the establish msg, copy the result and signal/unblock the wait
@@ -770,8 +729,6 @@ void vmbus_onmessage(void *context)
 	hdr = (struct vmbus_channel_message_header *)msg->u.payload;
 	size = msg->header.payload_size;
 
-	DPRINT_DBG(VMBUS, "message type %d size %d", hdr->msgtype, size);
-
 	if (hdr->msgtype >= CHANNELMSG_COUNT) {
 		DPRINT_ERR(VMBUS,
 			   "Received invalid channel message type %d size %d",
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 44b203b..ed2a7a8 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -121,11 +121,6 @@ int vmbus_connect(void)
 
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, "
-		   "monitor1 pfn %llx,, monitor2 pfn %llx",
-		   msg->interrupt_page, msg->monitor_page1, msg->monitor_page2);
-
-	DPRINT_DBG(VMBUS, "Sending channel initiate msg...");
 	ret = vmbus_post_msg(msg,
 			       sizeof(struct vmbus_channel_initiate_contact));
 	if (ret != 0) {
@@ -156,9 +151,7 @@ int vmbus_connect(void)
 
 	/* Check if successful */
 	if (msginfo->response.version_response.version_supported) {
-		DPRINT_INFO(VMBUS, "Vmbus connected!!");
 		vmbus_connection.conn_state = CONNECTED;
-
 	} else {
 		DPRINT_ERR(VMBUS, "Vmbus connection failed!!..."
 			   "current version (%d) not supported",
@@ -300,11 +293,9 @@ void vmbus_on_event(unsigned long data)
 						(unsigned long *)
 						&recv_int_page[dword])) {
 						relid = (dword << 5) + bit;
-						DPRINT_DBG(VMBUS, "event detected for relid - %d", relid);
 
 						if (relid == 0) {
 							/* special case - vmbus channel protocol msg */
-							DPRINT_DBG(VMBUS, "invalid relid - %d", relid);
 							continue;
 						} else {
 							/* QueueWorkItem(VmbusProcessEvent, (void*)relid); */
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 2d492ad..d627a83 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -80,7 +80,7 @@ static int query_hypervisor_info(void)
 	op = HVCPUID_VENDOR_MAXFUNCTION;
 	cpuid(op, &eax, &ebx, &ecx, &edx);
 
-	DPRINT_INFO(VMBUS, "Vendor ID: %c%c%c%c%c%c%c%c%c%c%c%c",
+/*	DPRINT_INFO(VMBUS, "Vendor ID: %c%c%c%c%c%c%c%c%c%c%c%c",
 		    (ebx & 0xFF),
 		    ((ebx >> 8) & 0xFF),
 		    ((ebx >> 16) & 0xFF),
@@ -93,9 +93,9 @@ static int query_hypervisor_info(void)
 		    ((edx >> 8) & 0xFF),
 		    ((edx >> 16) & 0xFF),
 		    ((edx >> 24) & 0xFF));
-
+*/
 	max_leaf = eax;
-	eax = 0;
+/*	eax = 0;
 	ebx = 0;
 	ecx = 0;
 	edx = 0;
@@ -107,6 +107,7 @@ static int query_hypervisor_info(void)
 		    ((eax >> 8) & 0xFF),
 		    ((eax >> 16) & 0xFF),
 		    ((eax >> 24) & 0xFF));
+*/
 
 	if (max_leaf >= HVCPUID_VERSION) {
 		eax = 0;
@@ -137,18 +138,11 @@ static u64 do_hypercall(u64 control, void *input, void *output)
 	u64 output_address = (output) ? virt_to_phys(output) : 0;
 	volatile void *hypercall_page = hv_context.hypercall_page;
 
-	DPRINT_DBG(VMBUS, "Hypercall <control %llx input phys %llx virt %p "
-		   "output phys %llx virt %p hypercall %p>",
-		   control, input_address, input,
-		   output_address, output, hypercall_page);
-
 	__asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8");
 	__asm__ __volatile__("call *%3" : "=a" (hv_status) :
 			     "c" (control), "d" (input_address),
 			     "m" (hypercall_page));
 
-	DPRINT_DBG(VMBUS, "Hypercall <return %llx>",  hv_status);
-
 	return hv_status;
 
 #else
@@ -165,18 +159,12 @@ static u64 do_hypercall(u64 control, void *input, void *output)
 	u32 output_address_lo = output_address & 0xFFFFFFFF;
 	volatile void *hypercall_page = hv_context.hypercall_page;
 
-	DPRINT_DBG(VMBUS, "Hypercall <control %llx input %p output %p>",
-		   control, input, output);
-
 	__asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
 			      "=a"(hv_status_lo) : "d" (control_hi),
 			      "a" (control_lo), "b" (input_address_hi),
 			      "c" (input_address_lo), "D"(output_address_hi),
 			      "S"(output_address_lo), "m" (hypercall_page));
 
-	DPRINT_DBG(VMBUS, "Hypercall <return %llx>",
-		   hv_status_lo | ((u64)hv_status_hi << 32));
-
 	return hv_status_lo | ((u64)hv_status_hi << 32);
 #endif /* !x86_64 */
 }
@@ -197,13 +185,8 @@ int hv_init(void)
 	memset(hv_context.synic_message_page, 0,
 	       sizeof(void *) * MAX_NUM_CPUS);
 
-	if (!query_hypervisor_presence()) {
-		DPRINT_ERR(VMBUS, "No Windows hypervisor detected!!");
+	if (!query_hypervisor_presence())
 		goto Cleanup;
-	}
-
-	DPRINT_INFO(VMBUS,
-		    "Windows hypervisor detected! Retrieving more info...");
 
 	max_leaf = query_hypervisor_info();
 	/* HvQueryHypervisorFeatures(maxLeaf); */
@@ -213,11 +196,8 @@ int hv_init(void)
 	 */
 	rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
-	if (hv_context.guestid != 0) {
-		DPRINT_ERR(VMBUS, "Unknown guest id (0x%llx)!!",
-				hv_context.guestid);
+	if (hv_context.guestid != 0)
 		goto Cleanup;
-	}
 
 	/* Write our OS info */
 	wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID);
@@ -232,11 +212,8 @@ int hv_init(void)
 	*/
 	virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
 
-	if (!virtaddr) {
-		DPRINT_ERR(VMBUS,
-			   "unable to allocate hypercall page!!");
+	if (!virtaddr)
 		goto Cleanup;
-	}
 
 	hypercall_msr.enable = 1;
 
@@ -247,17 +224,11 @@ int hv_init(void)
 	hypercall_msr.as_uint64 = 0;
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-	if (!hypercall_msr.enable) {
-		DPRINT_ERR(VMBUS, "unable to set hypercall page!!");
+	if (!hypercall_msr.enable)
 		goto Cleanup;
-	}
 
 	hv_context.hypercall_page = virtaddr;
 
-	DPRINT_INFO(VMBUS, "Hypercall page VA=%p, PA=0x%0llx",
-		    hv_context.hypercall_page,
-		    (u64)hypercall_msr.guest_physical_address << PAGE_SHIFT);
-
 	/* Setup the global signal event param for the signal event hypercall */
 	hv_context.signal_event_buffer =
 			kmalloc(sizeof(struct hv_input_signal_event_buffer),
@@ -394,8 +365,6 @@ void hv_synic_init(void *irqarg)
 	/* Check the version */
 	rdmsrl(HV_X64_MSR_SVERSION, version);
 
-	DPRINT_INFO(VMBUS, "SynIC version: %llx", version);
-
 	hv_context.synic_message_page[cpu] =
 		(void *)get_zeroed_page(GFP_ATOMIC);
 
@@ -420,8 +389,6 @@ void hv_synic_init(void *irqarg)
 	simp.base_simp_gpa = virt_to_phys(hv_context.synic_message_page[cpu])
 		>> PAGE_SHIFT;
 
-	DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", simp.as_uint64);
-
 	wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
 
 	/* Setup the Synic's event page */
@@ -430,8 +397,6 @@ void hv_synic_init(void *irqarg)
 	siefp.base_siefp_gpa = virt_to_phys(hv_context.synic_event_page[cpu])
 		>> PAGE_SHIFT;
 
-	DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", siefp.as_uint64);
-
 	wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
 
 	/* Setup the interception SINT. */
@@ -446,9 +411,6 @@ void hv_synic_init(void *irqarg)
 	shared_sint.masked = false;
 	shared_sint.auto_eoi = true;
 
-	DPRINT_DBG(VMBUS, "HV_X64_MSR_SINT1 msr set to: %llx",
-		   shared_sint.as_uint64);
-
 	wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
 	/* Enable the global synic bit */
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
index 66688fb..9bd5218 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/staging/hv/ring_buffer.c
@@ -372,20 +372,12 @@ int ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 				&bytes_avail_toread,
 				&bytes_avail_towrite);
 
-	DPRINT_DBG(VMBUS, "Writing %u bytes...", totalbytes_towrite);
-
 	/* Dumpring_info(Outring_info, "BEFORE "); */
 
 	/* If there is only room for the packet, assume it is full. */
 	/* Otherwise, the next time around, we think the ring buffer */
 	/* is empty since the read index == write index */
 	if (bytes_avail_towrite <= totalbytes_towrite) {
-		DPRINT_DBG(VMBUS,
-			"No more space left on outbound ring buffer "
-			"(needed %u, avail %u)",
-			totalbytes_towrite,
-			bytes_avail_towrite);
-
 		spin_unlock_irqrestore(&outring_info->ring_lock, flags);
 		return -1;
 	}
@@ -499,18 +491,10 @@ int ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 				&bytes_avail_toread,
 				&bytes_avail_towrite);
 
-	DPRINT_DBG(VMBUS, "Reading %u bytes...", buflen);
-
 	/* Dumpring_info(Inring_info, "BEFORE "); */
 
 	/* Make sure there is something to read */
 	if (bytes_avail_toread < buflen) {
-		DPRINT_DBG(VMBUS,
-			"got callback but not enough to read "
-			"<avail to read %d read size %d>!!",
-			bytes_avail_toread,
-			buflen);
-
 		spin_unlock_irqrestore(&inring_info->ring_lock, flags);
 
 		return -1;
@@ -568,8 +552,6 @@ copyto_ringbuffer(
 
 	/* wrap-around detected! */
 	if (srclen > ring_buffer_size - start_write_offset) {
-		DPRINT_DBG(VMBUS, "wrap-around detected!");
-
 		frag_len = ring_buffer_size - start_write_offset;
 		memcpy(ring_buffer + start_write_offset, src, frag_len);
 		memcpy(ring_buffer, src + frag_len, srclen - frag_len);
@@ -607,8 +589,6 @@ copyfrom_ringbuffer(
 
 	/* wrap-around detected at the src */
 	if (destlen > ring_buffer_size - start_read_offset) {
-		DPRINT_DBG(VMBUS, "src wrap-around detected!");
-
 		frag_len = ring_buffer_size - start_read_offset;
 
 		memcpy(dest, ring_buffer + start_read_offset, frag_len);
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 3263fc8..b320f71 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -245,21 +245,6 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	struct hv_device *dev = device_to_hv_device(device);
 	int ret;
 
-	DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={"
-		    "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-		    "%02x%02x%02x%02x%02x%02x%02x%02x}",
-		    dev->dev_type.data[3], dev->dev_type.data[2],
-		    dev->dev_type.data[1], dev->dev_type.data[0],
-		    dev->dev_type.data[5], dev->dev_type.data[4],
-		    dev->dev_type.data[7], dev->dev_type.data[6],
-		    dev->dev_type.data[8], dev->dev_type.data[9],
-		    dev->dev_type.data[10],
-		    dev->dev_type.data[11],
-		    dev->dev_type.data[12],
-		    dev->dev_type.data[13],
-		    dev->dev_type.data[14],
-		    dev->dev_type.data[15]);
-
 	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
 			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
@@ -323,10 +308,6 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
 		   sizeof(struct hv_guid)) == 0) {
 
 		device_ctx->drv = drv->priv;
-		DPRINT_INFO(VMBUS_DRV,
-			    "device object (%p) set to driver object (%p)",
-			    &device_ctx,
-			    device_ctx->drv);
 
 		match = 1;
 	}
@@ -539,22 +520,16 @@ static int vmbus_on_isr(void)
 	msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
 
 	/* Check if there are actual msgs to be process */
-	if (msg->header.message_type != HVMSG_NONE) {
-		DPRINT_DBG(VMBUS, "received msg type %d size %d",
-				msg->header.message_type,
-				msg->header.payload_size);
+	if (msg->header.message_type != HVMSG_NONE)
 		ret |= 0x1;
-	}
 
 	/* TODO: Check if there are events to be process */
 	page_addr = hv_context.synic_event_page[cpu];
 	event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
 
 	/* Since we are a child, we only need to check bit 0 */
-	if (test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) {
-		DPRINT_DBG(VMBUS, "received event %d", event->flags32[0]);
+	if (test_and_clear_bit(0, (unsigned long *) &event->flags32[0]))
 		ret |= 0x2;
-	}
 
 	return ret;
 }
@@ -594,18 +569,6 @@ static int vmbus_bus_init(struct pci_dev *pdev)
 	int ret;
 	unsigned int vector;
 
-	DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++",
-		    HV_DRV_VERSION);
-	DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++",
-			VMBUS_REVISION_NUMBER);
-	DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++",
-			VMBUS_MESSAGE_SINT);
-	DPRINT_DBG(VMBUS, "sizeof(vmbus_channel_packet_page_buffer)=%zd, "
-			"sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd",
-			sizeof(struct vmbus_channel_packet_page_buffer),
-			sizeof(struct vmbus_channel_packet_multipage_buffer));
-
-
 	/* Hypervisor initialization...setup hypercall page..etc */
 	ret = hv_init();
 	if (ret != 0) {
@@ -646,8 +609,6 @@ static int vmbus_bus_init(struct pci_dev *pdev)
 	}
 
 	vector = IRQ0_VECTOR + pdev->irq;
-	DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", pdev->irq,
-			vector);
 
 	/*
 	 * Notify the hypervisor of our irq and
@@ -761,25 +722,6 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
 		return NULL;
 	}
 
-	DPRINT_DBG(VMBUS_DRV, "child device (%p) allocated - "
-		"type {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-		"%02x%02x%02x%02x%02x%02x%02x%02x},"
-		"id {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-		"%02x%02x%02x%02x%02x%02x%02x%02x}",
-		&child_device_obj->device,
-		type->data[3], type->data[2], type->data[1], type->data[0],
-		type->data[5], type->data[4], type->data[7], type->data[6],
-		type->data[8], type->data[9], type->data[10], type->data[11],
-		type->data[12], type->data[13], type->data[14], type->data[15],
-		instance->data[3], instance->data[2],
-		instance->data[1], instance->data[0],
-		instance->data[5], instance->data[4],
-		instance->data[7], instance->data[6],
-		instance->data[8], instance->data[9],
-		instance->data[10], instance->data[11],
-		instance->data[12], instance->data[13],
-		instance->data[14], instance->data[15]);
-
 	child_device_obj->channel = channel;
 	memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
 	memcpy(&child_device_obj->dev_instance, instance,
@@ -798,9 +740,6 @@ int vmbus_child_device_register(struct hv_device *child_device_obj)
 
 	static atomic_t device_num = ATOMIC_INIT(0);
 
-	DPRINT_DBG(VMBUS_DRV, "child device (%p) registering",
-		   child_device_obj);
-
 	/* Set the device name. Otherwise, device_register() will fail. */
 	dev_set_name(&child_device_obj->device, "vmbus_0_%d",
 		     atomic_inc_return(&device_num));
@@ -835,10 +774,6 @@ int vmbus_child_device_register(struct hv_device *child_device_obj)
  */
 void vmbus_child_device_unregister(struct hv_device *device_obj)
 {
-
-	DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)",
-		    &device_obj->device);
-
 	/*
 	 * Kick off the process of unregistering the device.
 	 * This will call vmbus_remove() and eventually vmbus_device_release()
-- 
1.6.0.2

^ permalink raw reply related

* [PATCH 02/07] Remove all unneeded DPRINT from hv_netvsc
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan
In-Reply-To: <1301432330-1705-1-git-send-email-hjanssen@microsoft.com>

Remove all un-needed DPRINT calls from hv_netvsc.

This patch deals with hv_netvsc only.

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

---
 drivers/staging/hv/netvsc.c       |  102 ++-----------------------------------
 drivers/staging/hv/netvsc_drv.c   |   10 ----
 drivers/staging/hv/rndis_filter.c |   13 -----
 3 files changed, 4 insertions(+), 121 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 20b1597..be572b4 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -178,13 +178,6 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 	struct netvsc_driver *driver = (struct netvsc_driver *)drv;
 
-	DPRINT_DBG(NETVSC, "sizeof(struct hv_netvsc_packet)=%zd, "
-		   "sizeof(struct nvsp_message)=%zd, "
-		   "sizeof(struct vmtransfer_page_packet_header)=%zd",
-		   sizeof(struct hv_netvsc_packet),
-		   sizeof(struct nvsp_message),
-		   sizeof(struct vmtransfer_page_packet_header));
-
 	drv->name = driver_name;
 	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
 
@@ -223,8 +216,6 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 		goto cleanup;
 	}
 
-	DPRINT_INFO(NETVSC, "Establishing receive buffer's GPADL...");
-
 	/*
 	 * Establish the gpadl handle for this buffer on this
 	 * channel.  Note: This call uses the vmbus connection rather
@@ -241,8 +232,6 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 
 
 	/* Notify the NetVsp of the gpadl handle */
-	DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendReceiveBuffer...");
-
 	init_packet = &net_device->channel_init_pkt;
 
 	memset(init_packet, 0, sizeof(struct nvsp_message));
@@ -301,14 +290,6 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 		net_device->recv_section_cnt *
 	       sizeof(struct nvsp_1_receive_buffer_section));
 
-	DPRINT_INFO(NETVSC, "Receive sections info (count %d, offset %d, "
-		    "endoffset %d, suballoc size %d, num suballocs %d)",
-		    net_device->recv_section_cnt,
-		    net_device->recv_section[0].offset,
-		    net_device->recv_section[0].end_offset,
-		    net_device->recv_section[0].sub_alloc_size,
-		    net_device->recv_section[0].num_sub_allocs);
-
 	/*
 	 * For 1st release, there should only be 1 section that represents the
 	 * entire receive buffer
@@ -356,8 +337,6 @@ static int netvsc_init_send_buf(struct hv_device *device)
 		goto cleanup;
 	}
 
-	DPRINT_INFO(NETVSC, "Establishing send buffer's GPADL...");
-
 	/*
 	 * Establish the gpadl handle for this buffer on this
 	 * channel.  Note: This call uses the vmbus connection rather
@@ -372,8 +351,6 @@ static int netvsc_init_send_buf(struct hv_device *device)
 	}
 
 	/* Notify the NetVsp of the gpadl handle */
-	DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendSendBuffer...");
-
 	init_packet = &net_device->channel_init_pkt;
 
 	memset(init_packet, 0, sizeof(struct nvsp_message));
@@ -438,9 +415,6 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 	 * to send a revoke msg here
 	 */
 	if (net_device->recv_section_cnt) {
-		DPRINT_INFO(NETVSC,
-			    "Sending NvspMessage1TypeRevokeReceiveBuffer...");
-
 		/* Send the revoke receive buffer */
 		revoke_packet = &net_device->revoke_packet;
 		memset(revoke_packet, 0, sizeof(struct nvsp_message));
@@ -468,8 +442,6 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 
 	/* Teardown the gpadl on the vsp end */
 	if (net_device->recv_buf_gpadl_handle) {
-		DPRINT_INFO(NETVSC, "Tearing down receive buffer's GPADL...");
-
 		ret = vmbus_teardown_gpadl(net_device->dev->channel,
 			   net_device->recv_buf_gpadl_handle);
 
@@ -483,8 +455,6 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 	}
 
 	if (net_device->recv_buf) {
-		DPRINT_INFO(NETVSC, "Freeing up receive buffer...");
-
 		/* Free up the receive buffer */
 		free_pages((unsigned long)net_device->recv_buf,
 			get_order(net_device->recv_buf_size));
@@ -512,9 +482,6 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
 	 *  to send a revoke msg here
 	 */
 	if (net_device->send_section_size) {
-		DPRINT_INFO(NETVSC,
-			    "Sending NvspMessage1TypeRevokeSendBuffer...");
-
 		/* Send the revoke send buffer */
 		revoke_packet = &net_device->revoke_packet;
 		memset(revoke_packet, 0, sizeof(struct nvsp_message));
@@ -542,7 +509,6 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
 
 	/* Teardown the gpadl on the vsp end */
 	if (net_device->send_buf_gpadl_handle) {
-		DPRINT_INFO(NETVSC, "Tearing down send buffer's GPADL...");
 		ret = vmbus_teardown_gpadl(net_device->dev->channel,
 					   net_device->send_buf_gpadl_handle);
 
@@ -559,8 +525,6 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
 	}
 
 	if (net_device->send_buf) {
-		DPRINT_INFO(NETVSC, "Freeing up send buffer...");
-
 		/* Free up the receive buffer */
 		free_pages((unsigned long)net_device->send_buf,
 				get_order(net_device->send_buf_size));
@@ -594,8 +558,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	init_packet->msg.init_msg.init.max_protocol_ver =
 		NVSP_MAX_PROTOCOL_VERSION;
 
-	DPRINT_INFO(NETVSC, "Sending NvspMessageTypeInit...");
-
 	/* Send the init request */
 	net_device->wait_condition = 0;
 	ret = vmbus_sendpacket(device->channel, init_packet,
@@ -604,10 +566,8 @@ static int netvsc_connect_vsp(struct hv_device *device)
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 
-	if (ret != 0) {
-		DPRINT_ERR(NETVSC, "unable to send NvspMessageTypeInit");
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	wait_event_timeout(net_device->channel_init_wait,
 			net_device->wait_condition,
@@ -617,31 +577,17 @@ static int netvsc_connect_vsp(struct hv_device *device)
 		goto cleanup;
 	}
 
-	DPRINT_INFO(NETVSC, "NvspMessageTypeInit status(%d) max mdl chain (%d)",
-		init_packet->msg.init_msg.init_complete.status,
-		init_packet->msg.init_msg.
-		    init_complete.max_mdl_chain_len);
-
-	if (init_packet->msg.init_msg.init_complete.status !=
+	if (init_packet->msg.init_msg.init_complete.status !=
 	    NVSP_STAT_SUCCESS) {
-		DPRINT_ERR(NETVSC,
-			"unable to initialize with netvsp (status 0x%x)",
-			init_packet->msg.init_msg.init_complete.status);
 		ret = -1;
 		goto cleanup;
 	}
 
 	if (init_packet->msg.init_msg.init_complete.
 	    negotiated_protocol_ver != NVSP_PROTOCOL_VERSION_1) {
-		DPRINT_ERR(NETVSC, "unable to initialize with netvsp "
-			   "(version expected 1 got %d)",
-			   init_packet->msg.init_msg.
-			   init_complete.negotiated_protocol_ver);
 		ret = -1;
 		goto cleanup;
 	}
-	DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendNdisVersion...");
-
 	/* Send the ndis version */
 	memset(init_packet, 0, sizeof(struct nvsp_message));
 
@@ -661,8 +607,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
 				(unsigned long)init_packet,
 				VM_PKT_DATA_INBAND, 0);
 	if (ret != 0) {
-		DPRINT_ERR(NETVSC,
-			   "unable to send NvspMessage1TypeSendNdisVersion");
 		ret = -1;
 		goto cleanup;
 	}
@@ -702,8 +646,6 @@ static int netvsc_device_add(struct hv_device *device, void *additional_info)
 		goto cleanup;
 	}
 
-	DPRINT_DBG(NETVSC, "netvsc channel object allocated - %p", net_device);
-
 	/* Initialize the NetVSC channel extension */
 	net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
 	spin_lock_init(&net_device->recv_pkt_list_lock);
@@ -716,12 +658,9 @@ static int netvsc_device_add(struct hv_device *device, void *additional_info)
 		packet = kzalloc(sizeof(struct hv_netvsc_packet) +
 				 (NETVSC_RECEIVE_SG_COUNT *
 				  sizeof(struct hv_page_buffer)), GFP_KERNEL);
-		if (!packet) {
-			DPRINT_DBG(NETVSC, "unable to allocate netvsc pkts "
-				   "for receive pool (wanted %d got %d)",
-				   NETVSC_RECEIVE_PACKETLIST_COUNT, i);
+		if (!packet)
 			break;
-		}
+
 		list_add_tail(&packet->list_ent,
 			      &net_device->recv_pkt_list);
 	}
@@ -749,9 +688,6 @@ static int netvsc_device_add(struct hv_device *device, void *additional_info)
 		goto close;
 	}
 
-	DPRINT_INFO(NETVSC, "*** NetVSC channel handshake result - %d ***",
-		    ret);
-
 	return ret;
 
 close:
@@ -785,9 +721,6 @@ static int netvsc_device_remove(struct hv_device *device)
 	struct netvsc_device *net_device;
 	struct hv_netvsc_packet *netvsc_packet, *pos;
 
-	DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...",
-		    device->ext);
-
 	/* Stop outbound traffic ie sends and receives completions */
 	net_device = release_outbound_net_device(device);
 	if (!net_device) {
@@ -802,13 +735,8 @@ static int netvsc_device_remove(struct hv_device *device)
 		udelay(100);
 	}
 
-	DPRINT_INFO(NETVSC, "Disconnecting from netvsp...");
-
 	NetVscDisconnectFromVsp(net_device);
 
-	DPRINT_INFO(NETVSC, "Disabling inbound traffic on net device (%p)...",
-		    device->ext);
-
 	/* Stop inbound traffic ie receives and sends completions */
 	net_device = release_inbound_net_device(device);
 
@@ -853,9 +781,6 @@ static void netvsc_send_completion(struct hv_device *device,
 	nvsp_packet = (struct nvsp_message *)((unsigned long)packet +
 			(packet->offset8 << 3));
 
-	DPRINT_DBG(NETVSC, "send completion packet - type %d",
-		   nvsp_packet->hdr.msg_type);
-
 	if ((nvsp_packet->hdr.msg_type == NVSP_MSG_TYPE_INIT_COMPLETE) ||
 	    (nvsp_packet->hdr.msg_type ==
 	     NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE) ||
@@ -985,9 +910,6 @@ static void netvsc_receive(struct hv_device *device,
 		return;
 	}
 
-	DPRINT_DBG(NETVSC, "NVSP packet received - type %d",
-		   nvsp_packet->hdr.msg_type);
-
 	vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;
 
 	if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) {
@@ -998,9 +920,6 @@ static void netvsc_receive(struct hv_device *device,
 		return;
 	}
 
-	DPRINT_DBG(NETVSC, "xfer page - range count %d",
-		   vmxferpage_packet->range_cnt);
-
 	/*
 	 * Grab free packets (range count + 1) to represent this xfer
 	 * page packet. +1 to represent the xfer page packet itself.
@@ -1117,13 +1036,6 @@ static void netvsc_receive(struct hv_device *device,
 					break;
 			}
 		}
-		DPRINT_DBG(NETVSC, "[%d] - (abs offset %u len %u) => "
-			   "(pfn %llx, offset %u, len %u)", i,
-			   vmxferpage_packet->ranges[i].byte_offset,
-			   vmxferpage_packet->ranges[i].byte_count,
-			   netvsc_packet->page_buf[0].pfn,
-			   netvsc_packet->page_buf[0].offset,
-			   netvsc_packet->page_buf[0].len);
 
 		/* Pass it to the upper layer */
 		((struct netvsc_driver *)device->drv)->
@@ -1143,9 +1055,6 @@ static void netvsc_send_recv_completion(struct hv_device *device,
 	int retries = 0;
 	int ret;
 
-	DPRINT_DBG(NETVSC, "Sending receive completion pkt - %llx",
-		   transaction_id);
-
 	recvcompMessage.hdr.msg_type =
 				NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE;
 
@@ -1261,9 +1170,6 @@ static void netvsc_channel_cb(void *context)
 					   &bytes_recvd, &request_id);
 		if (ret == 0) {
 			if (bytes_recvd > 0) {
-				DPRINT_DBG(NETVSC, "receive %d bytes, tid %llx",
-					   bytes_recvd, request_id);
-
 				desc = (struct vmpacket_descriptor *)buffer;
 				switch (desc->type) {
 				case VM_PKT_COMP:
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 2d40f5f..1772a19 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -136,9 +136,6 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 	int ret;
 	unsigned int i, num_pages;
 
-	DPRINT_DBG(NETVSC_DRV, "xmit packet - len %d data_len %d",
-		   skb->len, skb->data_len);
-
 	/* Add 1 for skb->data and additional one for RNDIS */
 	num_pages = skb_shinfo(skb)->nr_frags + 1 + 1;
 	if (num_pages > net_device_ctx->avail)
@@ -196,10 +193,6 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 		net->stats.tx_bytes += skb->len;
 		net->stats.tx_packets++;
 
-		DPRINT_DBG(NETVSC_DRV, "# of xmits %lu total size %lu",
-			   net->stats.tx_packets,
-			   net->stats.tx_bytes);
-
 		net_device_ctx->avail -= num_pages;
 		if (net_device_ctx->avail < PACKET_PAGES_LOWATER)
 			netif_stop_queue(net);
@@ -297,9 +290,6 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
 	 */
 	netif_rx(skb);
 
-	DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
-		   net->stats.rx_packets, net->stats.rx_bytes);
-
 	return 0;
 }
 
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index e7189cd..d1b13dc 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -283,14 +283,6 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 		 */
 		if (request->request_msg.msg.init_req.req_id
 		    == resp->msg.init_complete.req_id) {
-			DPRINT_DBG(NETVSC, "found rndis request for "
-				"this response (id 0x%x req type 0x%x res "
-				"type 0x%x)",
-				request->request_msg.msg.
-				   init_req.req_id,
-				request->request_msg.ndis_msg_type,
-				resp->ndis_msg_type);
-
 			found = true;
 			break;
 		}
@@ -605,9 +597,6 @@ Exit:
 
 int rndis_filter_init(struct netvsc_driver *drv)
 {
-	DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd",
-		   sizeof(struct rndis_filter_packet));
-
 	drv->req_ext_size = sizeof(struct rndis_filter_packet);
 
 	/* Driver->Context = rndisDriver; */
@@ -765,8 +754,6 @@ static int rndis_filte_device_add(struct hv_device *dev,
 	if (!rndisDevice)
 		return -1;
 
-	DPRINT_DBG(NETVSC, "rndis device object allocated - %p", rndisDevice);
-
 	/*
 	 * Let the inner driver handle this first to create the netvsc channel
 	 * NOTE! Once the channel is created, we may get a receive callback
-- 
1.6.0.2

^ permalink raw reply related

* [PATCH 03/07] Remove all unneeded DPRINT from hv_utils
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan
In-Reply-To: <1301432330-1705-1-git-send-email-hjanssen@microsoft.com>

Remove all un-needed DPRINT calls from hv_utils.

This patch deals with hv_utils only.

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

---
 drivers/staging/hv/hv_kvp.c  |    3 ---
 drivers/staging/hv/hv_util.c |   12 ------------
 2 files changed, 0 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c
index faf692e..7775820 100644
--- a/drivers/staging/hv/hv_kvp.c
+++ b/drivers/staging/hv/hv_kvp.c
@@ -259,9 +259,6 @@ void hv_kvp_onchannelcallback(void *context)
 	vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE, &recvlen, &requestid);
 
 	if (recvlen > 0) {
-		DPRINT_DBG(VMBUS, "KVP packet: len=%d, requestid=%lld",
-			   recvlen, requestid);
-
 		icmsghdrp = (struct icmsg_hdr *)&recv_buffer[
 			sizeof(struct vmbuspipe_hdr)];
 
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 4792f2c..3e74f79 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -59,9 +59,6 @@ static void shutdown_onchannelcallback(void *context)
 			 PAGE_SIZE, &recvlen, &requestid);
 
 	if (recvlen > 0) {
-		DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
-			   recvlen, requestid);
-
 		icmsghdrp = (struct icmsg_hdr *)&shut_txf_buf[
 			sizeof(struct vmbuspipe_hdr)];
 
@@ -159,9 +156,6 @@ static void timesync_onchannelcallback(void *context)
 			 PAGE_SIZE, &recvlen, &requestid);
 
 	if (recvlen > 0) {
-		DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
-			recvlen, requestid);
-
 		icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[
 				sizeof(struct vmbuspipe_hdr)];
 
@@ -200,9 +194,6 @@ static void heartbeat_onchannelcallback(void *context)
 			 PAGE_SIZE, &recvlen, &requestid);
 
 	if (recvlen > 0) {
-		DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
-			   recvlen, requestid);
-
 		icmsghdrp = (struct icmsg_hdr *)&hbeat_txf_buf[
 				sizeof(struct vmbuspipe_hdr)];
 
@@ -214,9 +205,6 @@ static void heartbeat_onchannelcallback(void *context)
 					sizeof(struct vmbuspipe_hdr) +
 					sizeof(struct icmsg_hdr)];
 
-			DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
-				   heartbeat_msg->seq_num);
-
 			heartbeat_msg->seq_num += 1;
 		}
 
-- 
1.6.0.2

^ permalink raw reply related

* [PATCH 04/07] Replace DPRINT with natives in hv_vmbus
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan
In-Reply-To: <1301432330-1705-1-git-send-email-hjanssen@microsoft.com>

Replace all remaining DPRINT calls (excluding the ringbuffer debug
which is going to be done in a next set of patches) with their
native pr_ calls. And also changed some of the printouts to be more
useful.

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

---
 drivers/staging/hv/channel.c      |    9 +++++--
 drivers/staging/hv/channel_mgmt.c |   25 ++++++++++-----------
 drivers/staging/hv/connection.c   |   12 ++++++----
 drivers/staging/hv/hv.c           |   10 ++++----
 drivers/staging/hv/ring_buffer.c  |    1 +
 drivers/staging/hv/vmbus_drv.c    |   43 +++++++++++++++---------------------
 6 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index c90dbaf..ddadd6e 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
@@ -898,7 +900,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 	if (userlen > bufferlen) {
 		spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
-		DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d",
+		pr_err("Buffer too small - got %d needs %d\n",
 			   bufferlen, userlen);
 		return -1;
 	}
@@ -950,8 +952,9 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 	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);
+		pr_err("Buffer too small - needed %d bytes but "
+			"got space for only %d bytes\n",
+			packetlen, bufferlen);
 		return -2;
 	}
 
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index ebdd9d8..a75a1ae 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
@@ -403,8 +405,7 @@ static void vmbus_process_offer(struct work_struct *work)
 	 */
 	ret = vmbus_child_device_register(newchannel->device_obj);
 	if (ret != 0) {
-		DPRINT_ERR(VMBUS,
-			   "unable to add child device object (relid %d)",
+		pr_err("unable to add child device object (relid %d)\n",
 			   newchannel->offermsg.child_relid);
 
 		spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
@@ -430,8 +431,9 @@ static void vmbus_process_offer(struct work_struct *work)
 						 hv_cb_utils[cnt].callback,
 						 newchannel) == 0) {
 				hv_cb_utils[cnt].channel = newchannel;
-				DPRINT_INFO(VMBUS, "%s",
-						hv_cb_utils[cnt].log_msg);
+
+				pr_info("%s\n", hv_cb_utils[cnt].log_msg);
+
 				count_hv_channel();
 			}
 		}
@@ -472,7 +474,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
 	/* Allocate the channel object and save this offer. */
 	newchannel = alloc_channel();
 	if (!newchannel) {
-		DPRINT_ERR(VMBUS, "unable to allocate channel object");
+		pr_err("Unable to allocate channel object\n");
 		return;
 	}
 
@@ -730,8 +732,7 @@ void vmbus_onmessage(void *context)
 	size = msg->header.payload_size;
 
 	if (hdr->msgtype >= CHANNELMSG_COUNT) {
-		DPRINT_ERR(VMBUS,
-			   "Received invalid channel message type %d size %d",
+		pr_err("Received invalid channel message type %d size %d\n",
 			   hdr->msgtype, size);
 		print_hex_dump_bytes("", DUMP_PREFIX_NONE,
 				     (unsigned char *)msg->u.payload, size);
@@ -741,8 +742,7 @@ void vmbus_onmessage(void *context)
 	if (gChannelMessageTable[hdr->msgtype].messageHandler)
 		gChannelMessageTable[hdr->msgtype].messageHandler(hdr);
 	else
-		DPRINT_ERR(VMBUS, "Unhandled channel message type %d",
-			   hdr->msgtype);
+		pr_err("Unhandled channel message type %d\n", hdr->msgtype);
 }
 
 /*
@@ -770,7 +770,7 @@ int vmbus_request_offers(void)
 	ret = vmbus_post_msg(msg,
 			       sizeof(struct vmbus_channel_message_header));
 	if (ret != 0) {
-		DPRINT_ERR(VMBUS, "Unable to request offers - %d", ret);
+		pr_err("Unable to request offers - %d\n", ret);
 
 		goto cleanup;
 	}
@@ -810,9 +810,8 @@ void vmbus_release_unattached_channels(void)
 
 		if (!channel->device_obj->drv) {
 			list_del(&channel->listentry);
-			DPRINT_INFO(VMBUS,
-				    "Releasing unattached device object %p",
-				    channel->device_obj);
+
+			pr_err("Releasing unattached device object\n");
 
 			vmbus_child_device_unregister(channel->device_obj);
 			free_channel(channel);
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index ed2a7a8..7de0780 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -20,6 +20,8 @@
  *   Hank Janssen  <hjanssen@microsoft.com>
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
@@ -153,9 +155,9 @@ int vmbus_connect(void)
 	if (msginfo->response.version_response.version_supported) {
 		vmbus_connection.conn_state = CONNECTED;
 	} else {
-		DPRINT_ERR(VMBUS, "Vmbus connection failed!!..."
-			   "current version (%d) not supported",
-			   VMBUS_REVISION_NUMBER);
+		pr_err("Unable to connect, "
+			"Version %d not supported by Hyper-V\n",
+			VMBUS_REVISION_NUMBER);
 		ret = -1;
 		goto Cleanup;
 	}
@@ -216,7 +218,7 @@ int vmbus_disconnect(void)
 
 	vmbus_connection.conn_state = DISCONNECTED;
 
-	DPRINT_INFO(VMBUS, "Vmbus disconnected!!");
+	pr_info("hv_vmbus disconnected\n");
 
 Cleanup:
 	kfree(msg);
@@ -269,7 +271,7 @@ static void process_chn_event(void *context)
 		 *			  (void*)channel);
 		 */
 	} else {
-		DPRINT_ERR(VMBUS, "channel not found for relid - %d.", relid);
+		pr_err("channel not found for relid - %d\n", relid);
 	}
 }
 
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index d627a83..8898d7f 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -19,6 +19,8 @@
  *   Hank Janssen  <hjanssen@microsoft.com>
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
@@ -116,7 +118,7 @@ static int query_hypervisor_info(void)
 		edx = 0;
 		op = HVCPUID_VERSION;
 		cpuid(op, &eax, &ebx, &ecx, &edx);
-		DPRINT_INFO(VMBUS, "OS Build:%d-%d.%d-%d-%d.%d",\
+		pr_info("Hyper-V Host OS Build:%d-%d.%d-%d-%d.%d\n",
 			    eax,
 			    ebx >> 16,
 			    ebx & 0xFFFF,
@@ -369,8 +371,7 @@ void hv_synic_init(void *irqarg)
 		(void *)get_zeroed_page(GFP_ATOMIC);
 
 	if (hv_context.synic_message_page[cpu] == NULL) {
-		DPRINT_ERR(VMBUS,
-			   "unable to allocate SYNIC message page!!");
+		pr_err("Unable to allocate SYNIC message page\n");
 		goto Cleanup;
 	}
 
@@ -378,8 +379,7 @@ void hv_synic_init(void *irqarg)
 		(void *)get_zeroed_page(GFP_ATOMIC);
 
 	if (hv_context.synic_event_page[cpu] == NULL) {
-		DPRINT_ERR(VMBUS,
-			   "unable to allocate SYNIC event page!!");
+		pr_err("Unable to allocate SYNIC event page\n");
 		goto Cleanup;
 	}
 
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
index 9bd5218..66e1b3f 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/staging/hv/ring_buffer.c
@@ -20,6 +20,7 @@
  *   Hank Janssen  <hjanssen@microsoft.com>
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/kernel.h>
 #include <linux/mm.h>
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index b320f71..cb6dbc0 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -20,6 +20,8 @@
  *
  * 3/9/2011: K. Y. Srinivasan	- Significant restructuring and cleanup
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
@@ -350,18 +352,16 @@ static int vmbus_probe(struct device *child_device)
 		ret = dev->probe_error =
 		drv->driver.probe(child_device);
 		if (ret != 0) {
-			DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s "
-				   "(%p) on driver %s (%d)...",
-				   dev_name(child_device), child_device,
-				   child_device->driver->name, ret);
+			pr_err("probe failed for device %s (%d)\n",
+			       dev_name(child_device), ret);
 
 			INIT_WORK(&dev->probe_failed_work_item,
 				  vmbus_probe_failed_cb);
 			schedule_work(&dev->probe_failed_work_item);
 		}
 	} else {
-		DPRINT_ERR(VMBUS_DRV, "probe() method not set for driver - %s",
-			   child_device->driver->name);
+		pr_err("probe not set for driver %s\n",
+		       dev_name(child_device));
 		ret = -1;
 	}
 	return ret;
@@ -386,9 +386,8 @@ static int vmbus_remove(struct device *child_device)
 		if (drv->driver.remove) {
 			ret = drv->driver.remove(child_device);
 		} else {
-			DPRINT_ERR(VMBUS_DRV,
-				   "remove() method not set for driver - %s",
-				   child_device->driver->name);
+			pr_err("remove not set for driver %s\n",
+				dev_name(child_device));
 			ret = -1;
 		}
 	}
@@ -572,12 +571,10 @@ static int vmbus_bus_init(struct pci_dev *pdev)
 	/* Hypervisor initialization...setup hypercall page..etc */
 	ret = hv_init();
 	if (ret != 0) {
-		DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x",
-				ret);
+		pr_err("Unable to initialize the hypervisor - 0x%x\n", ret);
 		goto cleanup;
 	}
 
-
 	hv_bus.bus.name = driver_name;
 
 	/* Initialize the bus context */
@@ -599,7 +596,7 @@ static int vmbus_bus_init(struct pci_dev *pdev)
 			  driver_name, pdev);
 
 	if (ret != 0) {
-		DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
+		pr_err("Unable to request IRQ %d\n",
 			   pdev->irq);
 
 		bus_unregister(&hv_bus.bus);
@@ -669,8 +666,7 @@ int vmbus_child_driver_register(struct device_driver *drv)
 {
 	int ret;
 
-	DPRINT_INFO(VMBUS_DRV, "child driver (%p) registering - name %s",
-		    drv, drv->name);
+	pr_info("child driver registering - name %s\n", drv->name);
 
 	/* The child driver on this vmbus */
 	drv->bus = &hv_bus.bus;
@@ -695,8 +691,7 @@ EXPORT_SYMBOL(vmbus_child_driver_register);
  */
 void vmbus_child_driver_unregister(struct device_driver *drv)
 {
-	DPRINT_INFO(VMBUS_DRV, "child driver (%p) unregistering - name %s",
-		    drv, drv->name);
+	pr_info("child driver unregistering - name %s\n", drv->name);
 
 	driver_unregister(drv);
 
@@ -717,8 +712,7 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
 	/* Allocate the new child device */
 	child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
 	if (!child_device_obj) {
-		DPRINT_ERR(VMBUS_DRV,
-			"unable to allocate device_context for child device");
+		pr_err("Unable to allocate device object for child device\n");
 		return NULL;
 	}
 
@@ -759,11 +753,10 @@ int vmbus_child_device_register(struct hv_device *child_device_obj)
 	ret = child_device_obj->probe_error;
 
 	if (ret)
-		DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)",
-			   &child_device_obj->device);
+		pr_err("Unable to register child device\n");
 	else
-		DPRINT_INFO(VMBUS_DRV, "child device (%p) registered",
-			    &child_device_obj->device);
+		pr_info("child device %s registered\n",
+			dev_name(&child_device_obj->device));
 
 	return ret;
 }
@@ -780,8 +773,8 @@ void vmbus_child_device_unregister(struct hv_device *device_obj)
 	 */
 	device_unregister(&device_obj->device);
 
-	DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered",
-		    &device_obj->device);
+	pr_info("child device %s unregistered\n",
+		dev_name(&device_obj->device));
 }
 
 
-- 
1.6.0.2

^ permalink raw reply related

* [PATCH 05/07] replace DPRINT with native primitives in hv_netvsc
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1301432330-1705-1-git-send-email-hjanssen@microsoft.com>

Replace all remaining DPRINT calls with their native dev_ and
netvsc_ calls. And also change some of the verbiage to be more useful.

rndis_filter has a few remaining DPRINT calls in it that will be removed
in a future patch because the debug will be implemented differently.

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

---
 drivers/staging/hv/netvsc.c       |  115 +++++++++++++++++++------------------
 drivers/staging/hv/netvsc_drv.c   |   36 ++++++------
 drivers/staging/hv/rndis_filter.c |   51 +++++++++--------
 3 files changed, 103 insertions(+), 99 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index be572b4..ddf7546 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
@@ -200,7 +202,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "unable to get net device..."
+		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
 		return -1;
 	}
@@ -209,9 +211,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 		(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
 				get_order(net_device->recv_buf_size));
 	if (!net_device->recv_buf) {
-		DPRINT_ERR(NETVSC,
-			   "unable to allocate receive buffer of size %d",
-			   net_device->recv_buf_size);
+		dev_err(&device->device, "unable to allocate receive "
+			"buffer of size %d", net_device->recv_buf_size);
 		ret = -1;
 		goto cleanup;
 	}
@@ -225,8 +226,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 				    net_device->recv_buf_size,
 				    &net_device->recv_buf_gpadl_handle);
 	if (ret != 0) {
-		DPRINT_ERR(NETVSC,
-			   "unable to establish receive buffer's gpadl");
+		dev_err(&device->device,
+			"unable to establish receive buffer's gpadl");
 		goto cleanup;
 	}
 
@@ -250,8 +251,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
-		DPRINT_ERR(NETVSC,
-			   "unable to send receive buffer's gpadl to netvsp");
+		dev_err(&device->device,
+			"unable to send receive buffer's gpadl to netvsp");
 		goto cleanup;
 	}
 
@@ -264,7 +265,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	/* Check the response */
 	if (init_packet->msg.v1_msg.
 	    send_recv_buf_complete.status != NVSP_STAT_SUCCESS) {
-		DPRINT_ERR(NETVSC, "Unable to complete receive buffer "
+		dev_err(&device->device, "Unable to complete receive buffer "
 			   "initialzation with NetVsp - status %d",
 			   init_packet->msg.v1_msg.
 			   send_recv_buf_complete.status);
@@ -318,7 +319,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
 
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "unable to get net device..."
+		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
 		return -1;
 	}
@@ -331,8 +332,8 @@ static int netvsc_init_send_buf(struct hv_device *device)
 		(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
 				get_order(net_device->send_buf_size));
 	if (!net_device->send_buf) {
-		DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d",
-			   net_device->send_buf_size);
+		dev_err(&device->device, "unable to allocate send "
+			"buffer of size %d", net_device->send_buf_size);
 		ret = -1;
 		goto cleanup;
 	}
@@ -346,7 +347,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
 				    net_device->send_buf_size,
 				    &net_device->send_buf_gpadl_handle);
 	if (ret != 0) {
-		DPRINT_ERR(NETVSC, "unable to establish send buffer's gpadl");
+		dev_err(&device->device, "unable to establish send buffer's gpadl");
 		goto cleanup;
 	}
 
@@ -369,7 +370,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
-		DPRINT_ERR(NETVSC,
+		dev_err(&device->device,
 			   "unable to send receive buffer's gpadl to netvsp");
 		goto cleanup;
 	}
@@ -382,7 +383,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
 	/* Check the response */
 	if (init_packet->msg.v1_msg.
 	    send_send_buf_complete.status != NVSP_STAT_SUCCESS) {
-		DPRINT_ERR(NETVSC, "Unable to complete send buffer "
+		dev_err(&device->device, "Unable to complete send buffer "
 			   "initialzation with NetVsp - status %d",
 			   init_packet->msg.v1_msg.
 			   send_send_buf_complete.status);
@@ -434,8 +435,8 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		 * have a leak rather than continue and a bugchk
 		 */
 		if (ret != 0) {
-			DPRINT_ERR(NETVSC, "unable to send revoke receive "
-				   "buffer to netvsp");
+			dev_err(&net_device->dev->device, "unable to send "
+				"revoke receive buffer to netvsp");
 			return -1;
 		}
 	}
@@ -447,7 +448,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 
 		/* If we failed here, we might as well return and have a leak rather than continue and a bugchk */
 		if (ret != 0) {
-			DPRINT_ERR(NETVSC,
+			dev_err(&net_device->dev->device,
 				   "unable to teardown receive buffer's gpadl");
 			return -1;
 		}
@@ -501,8 +502,8 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
 		 * rather than continue and a bugchk
 		 */
 		if (ret != 0) {
-			DPRINT_ERR(NETVSC, "unable to send revoke send buffer "
-				   "to netvsp");
+			dev_err(&net_device->dev->device, "unable to send "
+				"revoke send buffer to netvsp");
 			return -1;
 		}
 	}
@@ -517,8 +518,8 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
 		 * rather than continue and a bugchk
 		 */
 		if (ret != 0) {
-			DPRINT_ERR(NETVSC, "unable to teardown send buffer's "
-				   "gpadl");
+			dev_err(&net_device->dev->device,
+				"unable to teardown send buffer's gpadl");
 			return -1;
 		}
 		net_device->send_buf_gpadl_handle = 0;
@@ -544,7 +545,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
 
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "unable to get net device..."
+		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
 		return -1;
 	}
@@ -672,18 +673,19 @@ static int netvsc_device_add(struct hv_device *device, void *additional_info)
 			 netvsc_channel_cb, device);
 
 	if (ret != 0) {
-		DPRINT_ERR(NETVSC, "unable to open channel: %d", ret);
+		dev_err(&device->device, "unable to open channel: %d", ret);
 		ret = -1;
 		goto cleanup;
 	}
 
 	/* Channel is opened */
-	DPRINT_INFO(NETVSC, "*** NetVSC channel opened successfully! ***");
+	pr_info("hv_netvsc channel opened successfully");
 
 	/* Connect with the NetVsp */
 	ret = netvsc_connect_vsp(device);
 	if (ret != 0) {
-		DPRINT_ERR(NETVSC, "unable to connect to NetVSP - %d", ret);
+		dev_err(&device->device,
+			"unable to connect to NetVSP - %d", ret);
 		ret = -1;
 		goto close;
 	}
@@ -724,14 +726,15 @@ static int netvsc_device_remove(struct hv_device *device)
 	/* Stop outbound traffic ie sends and receives completions */
 	net_device = release_outbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "No net device present!!");
+		dev_err(&device->device, "No net device present!!");
 		return -1;
 	}
 
 	/* Wait for all send completions */
 	while (atomic_read(&net_device->num_outstanding_sends)) {
-		DPRINT_INFO(NETVSC, "waiting for %d requests to complete...",
-			    atomic_read(&net_device->num_outstanding_sends));
+		dev_err(&device->device,
+			"waiting for %d requests to complete...",
+			atomic_read(&net_device->num_outstanding_sends));
 		udelay(100);
 	}
 
@@ -741,7 +744,7 @@ static int netvsc_device_remove(struct hv_device *device)
 	net_device = release_inbound_net_device(device);
 
 	/* At this point, no one should be accessing netDevice except in here */
-	DPRINT_INFO(NETVSC, "net device (%p) safe to remove", net_device);
+	dev_notice(&device->device, "net device safe to remove");
 
 	/* Now, we can close the channel safely */
 	vmbus_close(device->channel);
@@ -773,7 +776,7 @@ static void netvsc_send_completion(struct hv_device *device,
 
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "unable to get net device..."
+		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
 		return;
 	}
@@ -803,7 +806,7 @@ static void netvsc_send_completion(struct hv_device *device,
 
 		atomic_dec(&net_device->num_outstanding_sends);
 	} else {
-		DPRINT_ERR(NETVSC, "Unknown send completion packet type - "
+		dev_err(&device->device, "Unknown send completion packet type- "
 			   "%d received!!", nvsp_packet->hdr.msg_type);
 	}
 
@@ -820,7 +823,7 @@ static int netvsc_send(struct hv_device *device,
 
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
+		dev_err(&device->device, "net device (%p) shutting down..."
 			   "ignoring outbound packets", net_device);
 		return -2;
 	}
@@ -856,7 +859,7 @@ static int netvsc_send(struct hv_device *device,
 	}
 
 	if (ret != 0)
-		DPRINT_ERR(NETVSC, "Unable to send packet %p ret %d",
+		dev_err(&device->device, "Unable to send packet %p ret %d",
 			   packet, ret);
 
 	atomic_inc(&net_device->num_outstanding_sends);
@@ -882,7 +885,7 @@ static void netvsc_receive(struct hv_device *device,
 
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "unable to get net device..."
+		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
 		return;
 	}
@@ -892,7 +895,7 @@ static void netvsc_receive(struct hv_device *device,
 	 * packet
 	 */
 	if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) {
-		DPRINT_ERR(NETVSC, "Unknown packet type received - %d",
+		dev_err(&device->device, "Unknown packet type received - %d",
 			   packet->type);
 		put_net_device(device);
 		return;
@@ -904,8 +907,8 @@ static void netvsc_receive(struct hv_device *device,
 	/* Make sure this is a valid nvsp packet */
 	if (nvsp_packet->hdr.msg_type !=
 	    NVSP_MSG1_TYPE_SEND_RNDIS_PKT) {
-		DPRINT_ERR(NETVSC, "Unknown nvsp packet type received - %d",
-			   nvsp_packet->hdr.msg_type);
+		dev_err(&device->device, "Unknown nvsp packet type received-"
+			" %d", nvsp_packet->hdr.msg_type);
 		put_net_device(device);
 		return;
 	}
@@ -913,7 +916,7 @@ static void netvsc_receive(struct hv_device *device,
 	vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;
 
 	if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) {
-		DPRINT_ERR(NETVSC, "Invalid xfer page set id - "
+		dev_err(&device->device, "Invalid xfer page set id - "
 			   "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID,
 			   vmxferpage_packet->xfer_pageset_id);
 		put_net_device(device);
@@ -940,9 +943,9 @@ static void netvsc_receive(struct hv_device *device,
 	 * some of the xfer page packet ranges...
 	 */
 	if (count < 2) {
-		DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. "
-			   "Dropping this xfer page packet completely!",
-			   count, vmxferpage_packet->range_cnt + 1);
+		dev_err(&device->device, "Got only %d netvsc pkt...needed "
+			"%d pkts. Dropping this xfer page packet completely!",
+			count, vmxferpage_packet->range_cnt + 1);
 
 		/* Return it to the freelist */
 		spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
@@ -968,9 +971,9 @@ static void netvsc_receive(struct hv_device *device,
 	xferpage_packet->count = count - 1;
 
 	if (xferpage_packet->count != vmxferpage_packet->range_cnt) {
-		DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer "
-			    "page...got %d", vmxferpage_packet->range_cnt,
-			    xferpage_packet->count);
+		dev_err(&device->device, "Needed %d netvsc pkts to satisy "
+			"this xfer page...got %d",
+			vmxferpage_packet->range_cnt, xferpage_packet->count);
 	}
 
 	/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
@@ -1073,20 +1076,20 @@ retry_send_cmplt:
 	} else if (ret == -1) {
 		/* no more room...wait a bit and attempt to retry 3 times */
 		retries++;
-		DPRINT_ERR(NETVSC, "unable to send receive completion pkt "
-			   "(tid %llx)...retrying %d", transaction_id, retries);
+		dev_err(&device->device, "unable to send receive completion pkt"
+			" (tid %llx)...retrying %d", transaction_id, retries);
 
 		if (retries < 4) {
 			udelay(100);
 			goto retry_send_cmplt;
 		} else {
-			DPRINT_ERR(NETVSC, "unable to send receive completion "
-				  "pkt (tid %llx)...give up retrying",
-				  transaction_id);
+			dev_err(&device->device, "unable to send receive "
+				"completion pkt (tid %llx)...give up retrying",
+				transaction_id);
 		}
 	} else {
-		DPRINT_ERR(NETVSC, "unable to send receive completion pkt - "
-			   "%llx", transaction_id);
+		dev_err(&device->device, "unable to send receive "
+			"completion pkt - %llx", transaction_id);
 	}
 }
 
@@ -1107,7 +1110,7 @@ static void netvsc_receive_completion(void *context)
 	 */
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "unable to get net device..."
+		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
 		return;
 	}
@@ -1160,7 +1163,7 @@ static void netvsc_channel_cb(void *context)
 
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
+		dev_err(&device->device, "net device (%p) shutting down..."
 			   "ignoring inbound packets", net_device);
 		goto out;
 	}
@@ -1181,7 +1184,7 @@ static void netvsc_channel_cb(void *context)
 					break;
 
 				default:
-					DPRINT_ERR(NETVSC,
+					dev_err(&device->device,
 						   "unhandled packet type %d, "
 						   "tid %llx len %d\n",
 						   desc->type, request_id,
@@ -1210,7 +1213,7 @@ static void netvsc_channel_cb(void *context)
 			buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
 			if (buffer == NULL) {
 				/* Try again next time around */
-				DPRINT_ERR(NETVSC,
+				dev_err(&device->device,
 					   "unable to allocate buffer of size "
 					   "(%d)!!", bytes_recvd);
 				break;
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 1772a19..54a203b 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/highmem.h>
@@ -77,14 +79,14 @@ static int netvsc_open(struct net_device *net)
 		/* Open up the device */
 		ret = rndis_filter_open(device_obj);
 		if (ret != 0) {
-			DPRINT_ERR(NETVSC_DRV,
-				   "unable to open device (ret %d).", ret);
+			netdev_err(net, "unable to open device (ret %d).\n",
+				   ret);
 			return ret;
 		}
 
 		netif_start_queue(net);
 	} else {
-		DPRINT_ERR(NETVSC_DRV, "unable to open device...link is down.");
+		netdev_err(net, "unable to open device...link is down.\n");
 	}
 
 	return ret;
@@ -100,7 +102,7 @@ static int netvsc_close(struct net_device *net)
 
 	ret = rndis_filter_close(device_obj);
 	if (ret != 0)
-		DPRINT_ERR(NETVSC_DRV, "unable to close device (ret %d).", ret);
+		netdev_err(net, "unable to close device (ret %d).\n", ret);
 
 	return ret;
 }
@@ -147,7 +149,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 			 net_drv_obj->req_ext_size, GFP_ATOMIC);
 	if (!packet) {
 		/* out of memory, silently drop packet */
-		DPRINT_ERR(NETVSC_DRV, "unable to allocate hv_netvsc_packet");
+		netdev_err(net, "unable to allocate hv_netvsc_packet\n");
 
 		dev_kfree_skb(skb);
 		net->stats.tx_dropped++;
@@ -214,8 +216,8 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
 	struct net_device *net = dev_get_drvdata(&device_obj->device);
 
 	if (!net) {
-		DPRINT_ERR(NETVSC_DRV, "got link status but net device "
-				"not initialized yet");
+		netdev_err(net, "got link status but net device "
+				"not initialized yet\n");
 		return;
 	}
 
@@ -243,8 +245,8 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
 	unsigned long flags;
 
 	if (!net) {
-		DPRINT_ERR(NETVSC_DRV, "got receive callback but net device "
-				"not initialized yet");
+		netdev_err(net, "got receive callback but net device"
+			" not initialized yet\n");
 		return 0;
 	}
 
@@ -350,8 +352,7 @@ static int netvsc_probe(struct device *device)
 		free_netdev(net);
 		dev_set_drvdata(device, NULL);
 
-		DPRINT_ERR(NETVSC_DRV, "unable to add netvsc device (ret %d)",
-			   ret);
+		netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
 		return ret;
 	}
 
@@ -397,7 +398,7 @@ static int netvsc_remove(struct device *device)
 	int ret;
 
 	if (net == NULL) {
-		DPRINT_INFO(NETVSC, "no net device to remove");
+		dev_err(device, "No net device to remove\n");
 		return 0;
 	}
 
@@ -417,7 +418,7 @@ static int netvsc_remove(struct device *device)
 	ret = net_drv_obj->base.dev_rm(device_obj);
 	if (ret != 0) {
 		/* TODO: */
-		DPRINT_ERR(NETVSC, "unable to remove vsc device (ret %d)", ret);
+		netdev_err(net, "unable to remove vsc device (ret %d)\n", ret);
 	}
 
 	free_netdev(net);
@@ -446,16 +447,13 @@ static void netvsc_drv_exit(void)
 		/* Get the device */
 		ret = driver_for_each_device(&drv->driver, NULL,
 					     &current_dev, netvsc_drv_exit_cb);
-		if (ret)
-			DPRINT_WARN(NETVSC_DRV,
-				    "driver_for_each_device returned %d", ret);
 
 		if (current_dev == NULL)
 			break;
 
 		/* Initiate removal from the top-down */
-		DPRINT_INFO(NETVSC_DRV, "unregistering device (%p)...",
-			    current_dev);
+		dev_err(current_dev, "unregistering device (%s)...\n",
+			dev_name(current_dev));
 
 		device_unregister(current_dev);
 	}
@@ -509,7 +507,7 @@ MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table);
 
 static int __init netvsc_init(void)
 {
-	DPRINT_INFO(NETVSC_DRV, "Netvsc initializing....");
+	pr_info("initializing....");
 
 	if (!dmi_check_system(hv_netvsc_dmi_table))
 		return -ENODEV;
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index d1b13dc..1678705 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -25,7 +25,7 @@
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/if_ether.h>
-
+#include <linux/netdevice.h>
 #include "logging.h"
 #include "hv_api.h"
 #include "netvsc_api.h"
@@ -294,10 +294,11 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 			memcpy(&request->response_msg, resp,
 			       resp->msg_len);
 		} else {
-			DPRINT_ERR(NETVSC, "rndis response buffer overflow "
-				  "detected (size %u max %zu)",
-				  resp->msg_len,
-				  sizeof(struct rndis_filter_packet));
+			dev_err(&dev->net_dev->dev->device,
+				"rndis response buffer overflow "
+				"detected (size %u max %zu)\n",
+				resp->msg_len,
+				sizeof(struct rndis_filter_packet));
 
 			if (resp->ndis_msg_type ==
 			    REMOTE_NDIS_RESET_CMPLT) {
@@ -314,10 +315,11 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 		request->wait_condition = 1;
 		wake_up(&request->wait_event);
 	} else {
-		DPRINT_ERR(NETVSC, "no rndis request found for this response "
-			   "(id 0x%x res type 0x%x)",
-			   resp->msg.init_complete.req_id,
-			   resp->ndis_msg_type);
+		dev_err(&dev->net_dev->dev->device,
+			"no rndis request found for this response "
+			"(id 0x%x res type 0x%x)\n",
+			resp->msg.init_complete.req_id,
+			resp->ndis_msg_type);
 	}
 }
 
@@ -380,15 +382,15 @@ static int rndis_filter_receive(struct hv_device *dev,
 
 	/* Make sure the rndis device state is initialized */
 	if (!net_dev->extension) {
-		DPRINT_ERR(NETVSC, "got rndis message but no rndis device..."
-			  "dropping this message!");
+		dev_err(&dev->device, "got rndis message but no rndis device - "
+			  "dropping this message!\n");
 		return -1;
 	}
 
 	rndis_dev = (struct rndis_device *)net_dev->extension;
 	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
-		DPRINT_ERR(NETVSC, "got rndis message but rndis device "
-			   "uninitialized...dropping this message!");
+		dev_err(&dev->device, "got rndis message but rndis device "
+			   "uninitialized...dropping this message!\n");
 		return -1;
 	}
 
@@ -409,8 +411,8 @@ static int rndis_filter_receive(struct hv_device *dev,
 		kunmap_atomic(rndis_hdr - pkt->page_buf[0].offset,
 			      KM_IRQ0);
 
-		DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u "
-			   "bytes got %u)...dropping this message!",
+		dev_err(&dev->device, "invalid rndis message? (expected %u "
+			   "bytes got %u)...dropping this message!\n",
 			   rndis_hdr->msg_len,
 			   pkt->total_data_buflen);
 		return -1;
@@ -419,8 +421,8 @@ static int rndis_filter_receive(struct hv_device *dev,
 
 	if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) &&
 	    (rndis_hdr->msg_len > sizeof(struct rndis_message))) {
-		DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow "
-			   "detected (got %u, max %zu)...marking it an error!",
+		dev_err(&dev->device, "incoming rndis message buffer overflow "
+			   "detected (got %u, max %zu)..marking it an error!\n",
 			   rndis_hdr->msg_len,
 			   sizeof(struct rndis_message));
 	}
@@ -452,7 +454,8 @@ static int rndis_filter_receive(struct hv_device *dev,
 		rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg);
 		break;
 	default:
-		DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)",
+		dev_err(&dev->device,
+			"unhandled rndis message (type %u len %u)\n",
 			   rndis_msg.ndis_msg_type,
 			   rndis_msg.msg_len);
 		break;
@@ -575,7 +578,8 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		msecs_to_jiffies(2000));
 	if (request->wait_condition == 0) {
 		ret = -1;
-		DPRINT_ERR(NETVSC, "timeout before we got a set response...");
+		dev_err(&dev->net_dev->dev->device,
+			"timeout before we got a set response...\n");
 		/*
 		 * We cant deallocate the request since we may still receive a
 		 * send completion for it.
@@ -789,16 +793,15 @@ static int rndis_filte_device_add(struct hv_device *dev,
 		 */
 	}
 
-	DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM",
-		    rndisDevice, rndisDevice->hw_mac_adr);
-
 	memcpy(deviceInfo->mac_adr, rndisDevice->hw_mac_adr, ETH_ALEN);
 
 	rndis_filter_query_device_link_status(rndisDevice);
 
 	deviceInfo->link_state = rndisDevice->link_stat;
-	DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice,
-		    ((deviceInfo->link_state) ? ("down") : ("up")));
+
+	dev_info(&dev->device, "Device MAC %pM link state %s",
+		 rndisDevice->hw_mac_adr,
+		 ((deviceInfo->link_state) ? ("down\n") : ("up\n")));
 
 	return ret;
 }
-- 
1.6.0.2

^ permalink raw reply related

* [PATCH 06/07] Replaced DPRINT and printk with native functions in hv_utils
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1301432330-1705-1-git-send-email-hjanssen@microsoft.com>

Replaced all DPRINT and printk calls with pr_ calls

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

---
 drivers/staging/hv/hv_kvp.c  |    6 +++---
 drivers/staging/hv/hv_util.c |   17 +++++++++--------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hv_kvp.c b/drivers/staging/hv/hv_kvp.c
index 7775820..c71a148 100644
--- a/drivers/staging/hv/hv_kvp.c
+++ b/drivers/staging/hv/hv_kvp.c
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
-
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/net.h>
 #include <linux/nls.h>
@@ -114,7 +114,7 @@ kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
 
 	message = (struct hv_ku_msg *)msg->data;
 	if (msg->seq == KVP_REGISTER) {
-		printk(KERN_INFO "KVP: user-mode registering done.\n");
+		pr_info("KVP: user-mode registering done.\n");
 		kvp_register();
 	}
 
@@ -174,7 +174,7 @@ kvp_respond_to_host(char *key, char *value, int error)
 		/*
 		 * This is a spurious call!
 		 */
-		printk(KERN_WARNING "KVP: Transaction not active\n");
+		pr_warn("KVP: Transaction not active\n");
 		return;
 	}
 	/*
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index 3e74f79..3af0a11 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -76,15 +78,15 @@ static void shutdown_onchannelcallback(void *context)
 				icmsghdrp->status = HV_S_OK;
 				execute_shutdown = true;
 
-				DPRINT_INFO(VMBUS, "Shutdown request received -"
-					    " gracefull shutdown initiated");
+				pr_info("Shutdown request received -"
+					    " gracefull shutdown initiated\n");
 				break;
 			default:
 				icmsghdrp->status = HV_E_FAIL;
 				execute_shutdown = false;
 
-				DPRINT_INFO(VMBUS, "Shutdown request received -"
-					    " Invalid request");
+				pr_info("Shutdown request received -"
+					    " Invalid request\n");
 				break;
 			};
 		}
@@ -242,7 +244,7 @@ MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
 
 static int __init init_hyperv_utils(void)
 {
-	printk(KERN_INFO "Registering HyperV Utility Driver\n");
+	pr_info("Registering HyperV Utility Driver\n");
 
 	if (hv_kvp_init())
 		return -ENODEV;
@@ -256,8 +258,7 @@ static int __init init_hyperv_utils(void)
 	hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 
 	if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) {
-		printk(KERN_INFO
-		       "Unable to allocate memory for receive buffer\n");
+		pr_info("Unable to allocate memory for receive buffer\n");
 		kfree(shut_txf_buf);
 		kfree(time_txf_buf);
 		kfree(hbeat_txf_buf);
@@ -286,7 +287,7 @@ static int __init init_hyperv_utils(void)
 
 static void exit_hyperv_utils(void)
 {
-	printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
+	pr_info("De-Registered HyperV Utility Driver\n");
 
 	hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
 		&chn_cb_negotiate;
-- 
1.6.0.2

^ permalink raw reply related

* [PATCH 07/07] Replaced printk with pr_info in hv_timesource
From: Hank Janssen @ 2011-03-29 20:58 UTC (permalink / raw)
  To: hjanssen, haiyangz, gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan
In-Reply-To: <1301432330-1705-1-git-send-email-hjanssen@microsoft.com>

Replaced printk in hv_timesource with pr_ calls

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

---
 drivers/staging/hv/hv_timesource.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/hv_timesource.c b/drivers/staging/hv/hv_timesource.c
index a7ee533..0efb049 100644
--- a/drivers/staging/hv/hv_timesource.c
+++ b/drivers/staging/hv/hv_timesource.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/version.h>
 #include <linux/clocksource.h>
@@ -91,7 +92,7 @@ static int __init init_hv_clocksource(void)
 	if (!dmi_check_system(hv_timesource_dmi_table))
 		return -ENODEV;
 
-	printk(KERN_INFO "Registering HyperV clock source\n");
+	pr_info("Registering HyperV clock source\n");
 	return clocksource_register(&hyperv_cs);
 }
 
-- 
1.6.0.2

^ permalink raw reply related

* Re: virtio-blk.c handling of i/o which is not a 512 multiple
From: Stefan Hajnoczi @ 2011-03-30  8:45 UTC (permalink / raw)
  To: Conor Murphy; +Cc: qemu-devel, kvm, virtualization
In-Reply-To: <loom.20110330T100043-284@post.gmane.org>

On Wed, Mar 30, 2011 at 9:15 AM, Conor Murphy
<conor_murphy_virt@hotmail.com> wrote:
> I'm trying to write a virtio-blk driver for Solaris. I've gotten it to the point
> where Solaris can see the device and create a ZFS file system on it.
>
> However when I try and create a UFS filesystem on the device, the VM crashed
> with the error
> *** glibc detected *** /usr/bin/qemu-kvm: double free or corruption (!prev):
> 0x00007f2d38000a00 ***

This is a bug in QEMU.  A guest must not be able to trigger a crash.

> I can reproduce the problem with a simple dd, i.e.
> dd if=/dev/zero of=/dev/rdsk/c2d10p0 bs=5000 count=1

I think this a raw character device, which is why you're even able to
perform non-blocksize accesses?  Have you looked at how other drivers
(like the Xen pv blkfront) handle this?

> My driver will create a virtio-blk request with two elements in the sg list, one
> for the first 4096 byes and the other for the remaining 904.
>
> From stepping through with gdb, virtio_blk_handle_write will sets n_sectors to 9
> (5000 / 512). Later on the code, n_sectors is used the calculate the size of the
> buffer required but 9 * 512 is too small and so when the request is process it
> ends up writing past the end of the buffer and I guest this triggers the glibc
> error.

We need to validate that (qiov->size % BDRV_SECTOR_SIZE) == 0 and
reject invalid requests.

> Is there a requirement for virtio-blk guest drivers that all i/o requests are
> sized in multiples of 512 bytes?

There is no strict requirement according to the virtio specification,
but maybe there should be:

http://ozlabs.org/~rusty/virtio-spec/virtio-spec-0.8.9.pdf

Stefan

^ permalink raw reply

* [PATCH] xen: events: fix error checks in bind_*_to_irqhandler()
From: Nicolas Kaiser @ 2011-03-30 19:14 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: xen-devel, virtualization, linux-kernel, Konrad Rzeszutek Wilk

Checking 'irq < 0' doesn't work when 'irq' is unsigned.

The assigned bind_evtchn_to_irq() and bind_virq_to_irq()
return int, so using int appears appropriate.

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
---
 drivers/xen/events.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 036343b..589f0a5 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -912,8 +912,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
 			      unsigned long irqflags,
 			      const char *devname, void *dev_id)
 {
-	unsigned int irq;
-	int retval;
+	int irq, retval;
 
 	irq = bind_evtchn_to_irq(evtchn);
 	if (irq < 0)
@@ -955,8 +954,7 @@ int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
 			    irq_handler_t handler,
 			    unsigned long irqflags, const char *devname, void *dev_id)
 {
-	unsigned int irq;
-	int retval;
+	int irq, retval;
 
 	irq = bind_virq_to_irq(virq, cpu);
 	if (irq < 0)
-- 
1.7.3.4

^ permalink raw reply related

* Re: [PATCH] xen: events: fix error checks in bind_*_to_irqhandler()
From: Konrad Rzeszutek Wilk @ 2011-03-30 19:31 UTC (permalink / raw)
  To: Nicolas Kaiser, Ian Campbell
  Cc: linux-kernel, Jeremy Fitzhardinge, xen-devel, virtualization
In-Reply-To: <20110330211426.13f182d6@absol.kitzblitz>

On Wed, Mar 30, 2011 at 09:14:26PM +0200, Nicolas Kaiser wrote:
> Checking 'irq < 0' doesn't work when 'irq' is unsigned.
> 
> The assigned bind_evtchn_to_irq() and bind_virq_to_irq()
> return int, so using int appears appropriate.

Whoops. Good check. Will have it queue up for rc2.

Will fix up the bind_virq_to_irqhandler case as well.
> 
> Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
> ---
>  drivers/xen/events.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/xen/events.c b/drivers/xen/events.c
> index 036343b..589f0a5 100644
> --- a/drivers/xen/events.c
> +++ b/drivers/xen/events.c
> @@ -912,8 +912,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
>  			      unsigned long irqflags,
>  			      const char *devname, void *dev_id)
>  {
> -	unsigned int irq;
> -	int retval;
> +	int irq, retval;
>  
>  	irq = bind_evtchn_to_irq(evtchn);
>  	if (irq < 0)
> @@ -955,8 +954,7 @@ int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
>  			    irq_handler_t handler,
>  			    unsigned long irqflags, const char *devname, void *dev_id)
>  {
> -	unsigned int irq;
> -	int retval;
> +	int irq, retval;
>  
>  	irq = bind_virq_to_irq(virq, cpu);
>  	if (irq < 0)
> -- 
> 1.7.3.4
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply

* [PATCH] virtio_net: convert to hw_features
From: Michał Mirosław @ 2011-03-31 11:01 UTC (permalink / raw)
  To: netdev; +Cc: virtualization, Michael S. Tsirkin

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/virtio_net.c |   46 +++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 27 deletions(-)

This is an example conversion to hw_features when constraints are
constant and can be detected at init time.

Build tested only.

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 82dba5a..0cb0b06 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -710,17 +710,6 @@ static int virtnet_close(struct net_device *dev)
 	return 0;
 }
 
-static int virtnet_set_tx_csum(struct net_device *dev, u32 data)
-{
-	struct virtnet_info *vi = netdev_priv(dev);
-	struct virtio_device *vdev = vi->vdev;
-
-	if (data && !virtio_has_feature(vdev, VIRTIO_NET_F_CSUM))
-		return -ENOSYS;
-
-	return ethtool_op_set_tx_hw_csum(dev, data);
-}
-
 static void virtnet_set_rx_mode(struct net_device *dev)
 {
 	struct virtnet_info *vi = netdev_priv(dev);
@@ -822,10 +811,6 @@ static void virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
 }
 
 static const struct ethtool_ops virtnet_ethtool_ops = {
-	.set_tx_csum = virtnet_set_tx_csum,
-	.set_sg = ethtool_op_set_sg,
-	.set_tso = ethtool_op_set_tso,
-	.set_ufo = ethtool_op_set_ufo,
 	.get_link = ethtool_op_get_link,
 };
 
@@ -912,22 +897,29 @@ static int virtnet_probe(struct virtio_device *vdev)
 	SET_NETDEV_DEV(dev, &vdev->dev);
 
 	/* Do we support "hardware" checksums? */
-	if (csum && virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) {
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) {
 		/* This opens up the world of extra features. */
-		dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
-		if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
-			dev->features |= NETIF_F_TSO | NETIF_F_UFO
+		dev->hw_features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
+		if (csum)
+			dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
+
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
+			dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
 				| NETIF_F_TSO_ECN | NETIF_F_TSO6;
 		}
 		/* Individual feature bits: what can host handle? */
-		if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO4))
-			dev->features |= NETIF_F_TSO;
-		if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO6))
-			dev->features |= NETIF_F_TSO6;
-		if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
-			dev->features |= NETIF_F_TSO_ECN;
-		if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
-			dev->features |= NETIF_F_UFO;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO4))
+			dev->hw_features |= NETIF_F_TSO;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO6))
+			dev->hw_features |= NETIF_F_TSO6;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
+			dev->hw_features |= NETIF_F_TSO_ECN;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
+			dev->hw_features |= NETIF_F_UFO;
+
+		if (gso)
+			dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
+		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
 
 	/* Configuration may specify what MAC to use.  Otherwise random. */
-- 
1.7.2.5

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH RESEND] net: convert xen-netfront to hw_features
From: Michał Mirosław @ 2011-03-31 11:01 UTC (permalink / raw)
  To: netdev
  Cc: xen-devel, Jeremy Fitzhardinge, virtualization, Ian Campbell,
	Konrad Rzeszutek Wilk

Not tested in any way. The original code for offload setting seems broken
as it resets the features on every netback reconnect.

This will set GSO_ROBUST at device creation time (earlier than connect time).

RX checksum offload is forced on - so advertise as it is.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
[I don't know Xen code enough to say this is correct. There is Xen netback
driver coming in, that has similar changes to be made. Please match
them up if you can.]

 drivers/net/xen-netfront.c |   57 +++++++++++++++++--------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 5c8d9c3..2a71c9f 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1148,6 +1148,8 @@ static const struct net_device_ops xennet_netdev_ops = {
 	.ndo_change_mtu	     = xennet_change_mtu,
 	.ndo_set_mac_address = eth_mac_addr,
 	.ndo_validate_addr   = eth_validate_addr,
+	.ndo_fix_features    = xennet_fix_features,
+	.ndo_set_features    = xennet_set_features,
 };
 
 static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev)
@@ -1209,7 +1211,9 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev
 	netdev->netdev_ops	= &xennet_netdev_ops;
 
 	netif_napi_add(netdev, &np->napi, xennet_poll, 64);
-	netdev->features        = NETIF_F_IP_CSUM;
+	netdev->features        = NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
+				  NETIF_F_GSO_ROBUST;
+	netdev->hw_features	= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO;
 
 	SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops);
 	SET_NETDEV_DEV(netdev, &dev->dev);
@@ -1510,52 +1514,40 @@ again:
 	return err;
 }
 
-static int xennet_set_sg(struct net_device *dev, u32 data)
+static u32 xennet_fix_features(struct net_device *dev, u32 features)
 {
-	if (data) {
-		struct netfront_info *np = netdev_priv(dev);
-		int val;
+	struct netfront_info *np = netdev_priv(dev);
+	int val;
 
+	if (features & NETIF_F_SG) {
 		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
 				 "%d", &val) < 0)
 			val = 0;
+
 		if (!val)
-			return -ENOSYS;
-	} else if (dev->mtu > ETH_DATA_LEN)
-		dev->mtu = ETH_DATA_LEN;
-
-	return ethtool_op_set_sg(dev, data);
-}
-
-static int xennet_set_tso(struct net_device *dev, u32 data)
-{
-	if (data) {
-		struct netfront_info *np = netdev_priv(dev);
-		int val;
+			features &= ~NETIF_F_SG;
+	}
 
+	if (features & NETIF_F_TSO) {
 		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
 				 "feature-gso-tcpv4", "%d", &val) < 0)
 			val = 0;
+
 		if (!val)
-			return -ENOSYS;
+			features &= ~NETIF_F_TSO;
 	}
 
-	return ethtool_op_set_tso(dev, data);
+	return features;
 }
 
-static void xennet_set_features(struct net_device *dev)
+static int xennet_set_features(struct net_device *dev, u32 features)
 {
-	/* Turn off all GSO bits except ROBUST. */
-	dev->features &= ~NETIF_F_GSO_MASK;
-	dev->features |= NETIF_F_GSO_ROBUST;
-	xennet_set_sg(dev, 0);
+	if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {
+		netdev_info(dev, "Reducing MTU because no SG offload");
+		dev->mtu = ETH_DATA_LEN;
+	}
 
-	/* We need checksum offload to enable scatter/gather and TSO. */
-	if (!(dev->features & NETIF_F_IP_CSUM))
-		return;
-
-	if (!xennet_set_sg(dev, 1))
-		xennet_set_tso(dev, 1);
+	return 0;
 }
 
 static int xennet_connect(struct net_device *dev)
@@ -1582,7 +1574,7 @@ static int xennet_connect(struct net_device *dev)
 	if (err)
 		return err;
 
-	xennet_set_features(dev);
+	netdev_update_features(dev);
 
 	spin_lock_bh(&np->rx_lock);
 	spin_lock_irq(&np->tx_lock);
@@ -1710,9 +1702,6 @@ static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data)
 
 static const struct ethtool_ops xennet_ethtool_ops =
 {
-	.set_tx_csum = ethtool_op_set_tx_csum,
-	.set_sg = xennet_set_sg,
-	.set_tso = xennet_set_tso,
 	.get_link = ethtool_op_get_link,
 
 	.get_sset_count = xennet_get_sset_count,
-- 
1.7.2.5

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* Re: [PATCH RESEND] net: convert xen-netfront to hw_features
From: Ian Campbell @ 2011-03-31 11:13 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: netdev@vger.kernel.org, Jeremy Fitzhardinge,
	virtualization@lists.linux-foundation.org,
	xen-devel@lists.xensource.com, Konrad Rzeszutek Wilk
In-Reply-To: <20110331110136.03A1A13A6A@rere.qmqm.pl>

On Thu, 2011-03-31 at 12:01 +0100, Michał Mirosław wrote:
> Not tested in any way. The original code for offload setting seems broken
> as it resets the features on every netback reconnect.

Thanks, I've got a pending TODO item to test this and propagate similar
changes to netback. I hope to get to it soon...

Is this urgent (for 2.6.39) IYHO? I think it's been broken this way for
a long time now...

Ian.

> 
> This will set GSO_ROBUST at device creation time (earlier than connect time).
> 
> RX checksum offload is forced on - so advertise as it is.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> [I don't know Xen code enough to say this is correct. There is Xen netback
> driver coming in, that has similar changes to be made. Please match
> them up if you can.]
> 
>  drivers/net/xen-netfront.c |   57 +++++++++++++++++--------------------------
>  1 files changed, 23 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index 5c8d9c3..2a71c9f 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -1148,6 +1148,8 @@ static const struct net_device_ops xennet_netdev_ops = {
>  	.ndo_change_mtu	     = xennet_change_mtu,
>  	.ndo_set_mac_address = eth_mac_addr,
>  	.ndo_validate_addr   = eth_validate_addr,
> +	.ndo_fix_features    = xennet_fix_features,
> +	.ndo_set_features    = xennet_set_features,
>  };
>  
>  static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev)
> @@ -1209,7 +1211,9 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev
>  	netdev->netdev_ops	= &xennet_netdev_ops;
>  
>  	netif_napi_add(netdev, &np->napi, xennet_poll, 64);
> -	netdev->features        = NETIF_F_IP_CSUM;
> +	netdev->features        = NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
> +				  NETIF_F_GSO_ROBUST;
> +	netdev->hw_features	= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO;
>  
>  	SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops);
>  	SET_NETDEV_DEV(netdev, &dev->dev);
> @@ -1510,52 +1514,40 @@ again:
>  	return err;
>  }
>  
> -static int xennet_set_sg(struct net_device *dev, u32 data)
> +static u32 xennet_fix_features(struct net_device *dev, u32 features)
>  {
> -	if (data) {
> -		struct netfront_info *np = netdev_priv(dev);
> -		int val;
> +	struct netfront_info *np = netdev_priv(dev);
> +	int val;
>  
> +	if (features & NETIF_F_SG) {
>  		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
>  				 "%d", &val) < 0)
>  			val = 0;
> +
>  		if (!val)
> -			return -ENOSYS;
> -	} else if (dev->mtu > ETH_DATA_LEN)
> -		dev->mtu = ETH_DATA_LEN;
> -
> -	return ethtool_op_set_sg(dev, data);
> -}
> -
> -static int xennet_set_tso(struct net_device *dev, u32 data)
> -{
> -	if (data) {
> -		struct netfront_info *np = netdev_priv(dev);
> -		int val;
> +			features &= ~NETIF_F_SG;
> +	}
>  
> +	if (features & NETIF_F_TSO) {
>  		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
>  				 "feature-gso-tcpv4", "%d", &val) < 0)
>  			val = 0;
> +
>  		if (!val)
> -			return -ENOSYS;
> +			features &= ~NETIF_F_TSO;
>  	}
>  
> -	return ethtool_op_set_tso(dev, data);
> +	return features;
>  }
>  
> -static void xennet_set_features(struct net_device *dev)
> +static int xennet_set_features(struct net_device *dev, u32 features)
>  {
> -	/* Turn off all GSO bits except ROBUST. */
> -	dev->features &= ~NETIF_F_GSO_MASK;
> -	dev->features |= NETIF_F_GSO_ROBUST;
> -	xennet_set_sg(dev, 0);
> +	if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {
> +		netdev_info(dev, "Reducing MTU because no SG offload");
> +		dev->mtu = ETH_DATA_LEN;
> +	}
>  
> -	/* We need checksum offload to enable scatter/gather and TSO. */
> -	if (!(dev->features & NETIF_F_IP_CSUM))
> -		return;
> -
> -	if (!xennet_set_sg(dev, 1))
> -		xennet_set_tso(dev, 1);
> +	return 0;
>  }
>  
>  static int xennet_connect(struct net_device *dev)
> @@ -1582,7 +1574,7 @@ static int xennet_connect(struct net_device *dev)
>  	if (err)
>  		return err;
>  
> -	xennet_set_features(dev);
> +	netdev_update_features(dev);
>  
>  	spin_lock_bh(&np->rx_lock);
>  	spin_lock_irq(&np->tx_lock);
> @@ -1710,9 +1702,6 @@ static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data)
>  
>  static const struct ethtool_ops xennet_ethtool_ops =
>  {
> -	.set_tx_csum = ethtool_op_set_tx_csum,
> -	.set_sg = xennet_set_sg,
> -	.set_tso = xennet_set_tso,
>  	.get_link = ethtool_op_get_link,
>  
>  	.get_sset_count = xennet_get_sset_count,


_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH RESEND] net: convert xen-netfront to hw_features
From: Michał Mirosław @ 2011-03-31 11:37 UTC (permalink / raw)
  To: Ian Campbell
  Cc: netdev@vger.kernel.org, Jeremy Fitzhardinge,
	virtualization@lists.linux-foundation.org,
	xen-devel@lists.xensource.com, Konrad Rzeszutek Wilk
In-Reply-To: <1301570010.27123.172.camel@zakaz.uk.xensource.com>

On Thu, Mar 31, 2011 at 12:13:30PM +0100, Ian Campbell wrote:
> On Thu, 2011-03-31 at 12:01 +0100, Michał Mirosław wrote:
> > Not tested in any way. The original code for offload setting seems broken
> > as it resets the features on every netback reconnect.
> Thanks, I've got a pending TODO item to test this and propagate similar
> changes to netback. I hope to get to it soon...
> 
> Is this urgent (for 2.6.39) IYHO? I think it's been broken this way for
> a long time now...

This probably affects only people who are using suspending VM's to disk or
[live] migration. The bug is hard to notice if you're not looking for it.
I only noticed it after trying to change the code.

Best Regards,
Michał Mirosław

^ permalink raw reply

* [PATCH 1/5] staging: hv: change camel case funct names to lower case funct in hv_mouse
From: Hank Janssen @ 2011-04-01 21:32 UTC (permalink / raw)
  To: hjanssen, hjanssen, haiyangz, gregkh, linux-kernel, devel,
	virtualization
  Cc: Abhishek Kane, K. Y. Srinivasan

Change all camelcase function names to lower case in hv_mouse

Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

---
 drivers/staging/hv/hv_mouse.c |   92 ++++++++++++++++++++++-------------------
 1 files changed, 49 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 50147f8..084ba3b 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -200,7 +200,7 @@ static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info
 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
 
-static struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *alloc_input_device(struct hv_device *Device)
 {
 	struct mousevsc_dev *inputDevice;
 
@@ -211,7 +211,7 @@ static struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
 
 	/*
 	 * Set to 2 to allow both inbound and outbound traffics
-	 * (ie GetInputDevice() and MustGetInputDevice()) to proceed.
+	 * (ie get_input_device() and must_get_input_device()) to proceed.
 	 */
 	atomic_cmpxchg(&inputDevice->RefCount, 0, 2);
 
@@ -221,7 +221,7 @@ static struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
 	return inputDevice;
 }
 
-static void FreeInputDevice(struct mousevsc_dev *Device)
+static void free_input_device(struct mousevsc_dev *Device)
 {
 	WARN_ON(atomic_read(&Device->RefCount) == 0);
 	kfree(Device);
@@ -230,7 +230,7 @@ static void FreeInputDevice(struct mousevsc_dev *Device)
 /*
  * Get the inputdevice object if exists and its refcount > 1
  */
-static struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *get_input_device(struct hv_device *Device)
 {
 	struct mousevsc_dev *inputDevice;
 
@@ -256,7 +256,7 @@ static struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
 /*
  * Get the inputdevice object iff exists and its refcount > 0
  */
-static struct mousevsc_dev *MustGetInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *must_get_input_device(struct hv_device *Device)
 {
 	struct mousevsc_dev *inputDevice;
 
@@ -270,7 +270,7 @@ static struct mousevsc_dev *MustGetInputDevice(struct hv_device *Device)
 	return inputDevice;
 }
 
-static void PutInputDevice(struct hv_device *Device)
+static void put_input_device(struct hv_device *Device)
 {
 	struct mousevsc_dev *inputDevice;
 
@@ -280,9 +280,9 @@ static void PutInputDevice(struct hv_device *Device)
 }
 
 /*
- * Drop ref count to 1 to effectively disable GetInputDevice()
+ * Drop ref count to 1 to effectively disable get_input_device()
  */
-static struct mousevsc_dev *ReleaseInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *release_input_device(struct hv_device *Device)
 {
 	struct mousevsc_dev *inputDevice;
 
@@ -298,7 +298,7 @@ static struct mousevsc_dev *ReleaseInputDevice(struct hv_device *Device)
 /*
  * Drop ref count to 0. No one can use InputDevice object.
  */
-static struct mousevsc_dev *FinalReleaseInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *final_release_input_device(struct hv_device *Device)
 {
 	struct mousevsc_dev *inputDevice;
 
@@ -312,12 +312,13 @@ static struct mousevsc_dev *FinalReleaseInputDevice(struct hv_device *Device)
 	return inputDevice;
 }
 
-static void MousevscOnSendCompletion(struct hv_device *Device, struct vmpacket_descriptor *Packet)
+static void mousevsc_on_send_completion(struct hv_device *Device,
+					struct vmpacket_descriptor *Packet)
 {
 	struct mousevsc_dev *inputDevice;
 	void *request;
 
-	inputDevice = MustGetInputDevice(Device);
+	inputDevice = must_get_input_device(Device);
 	if (!inputDevice) {
 		pr_err("unable to get input device...device being destroyed?");
 		return;
@@ -330,10 +331,11 @@ static void MousevscOnSendCompletion(struct hv_device *Device, struct vmpacket_d
 		/* Shouldn't we be doing something here? */
 	}
 
-	PutInputDevice(Device);
+	put_input_device(Device);
 }
 
-static void MousevscOnReceiveDeviceInfo(struct mousevsc_dev *InputDevice, struct synthhid_device_info *DeviceInfo)
+static void mousevsc_on_receive_device_info(struct mousevsc_dev *InputDevice,
+					struct synthhid_device_info *DeviceInfo)
 {
 	int ret = 0;
 	struct hid_descriptor *desc;
@@ -413,7 +415,8 @@ Cleanup:
 	wake_up(&InputDevice->DeviceInfoWaitEvent);
 }
 
-static void MousevscOnReceiveInputReport(struct mousevsc_dev *InputDevice, struct synthhid_input_report *InputReport)
+static void mousevsc_on_receive_input_report(struct mousevsc_dev *InputDevice,
+				struct synthhid_input_report *InputReport)
 {
 	struct mousevsc_drv_obj *inputDriver;
 
@@ -429,13 +432,14 @@ static void MousevscOnReceiveInputReport(struct mousevsc_dev *InputDevice, struc
 			     InputReport->header.size);
 }
 
-static void MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
+static void mousevsc_on_receive(struct hv_device *Device,
+				struct vmpacket_descriptor *Packet)
 {
 	struct pipe_prt_msg *pipeMsg;
 	struct synthhid_msg *hidMsg;
 	struct mousevsc_dev *inputDevice;
 
-	inputDevice = MustGetInputDevice(Device);
+	inputDevice = must_get_input_device(Device);
 	if (!inputDevice) {
 		pr_err("unable to get input device...device being destroyed?");
 		return;
@@ -446,7 +450,7 @@ static void MousevscOnReceive(struct hv_device *Device, struct vmpacket_descript
 	if (pipeMsg->type != PipeMessageData) {
 		pr_err("unknown pipe msg type - type %d len %d",
 			   pipeMsg->type, pipeMsg->size);
-		PutInputDevice(Device);
+		put_input_device(Device);
 		return ;
 	}
 
@@ -468,11 +472,11 @@ static void MousevscOnReceive(struct hv_device *Device, struct vmpacket_descript
 		 * Parse out the device info into device attr,
 		 * hid desc and report desc
 		 */
-		MousevscOnReceiveDeviceInfo(inputDevice,
+		mousevsc_on_receive_device_info(inputDevice,
 					    (struct synthhid_device_info *)&pipeMsg->data[0]);
 		break;
 	case SynthHidInputReport:
-		MousevscOnReceiveInputReport(inputDevice,
+		mousevsc_on_receive_input_report(inputDevice,
 					     (struct synthhid_input_report *)&pipeMsg->data[0]);
 
 		break;
@@ -482,10 +486,10 @@ static void MousevscOnReceive(struct hv_device *Device, struct vmpacket_descript
 		break;
 	}
 
-	PutInputDevice(Device);
+	put_input_device(Device);
 }
 
-static void MousevscOnChannelCallback(void *Context)
+static void mousevsc_on_channel_callback(void *Context)
 {
 	const int packetSize = 0x100;
 	int ret = 0;
@@ -499,7 +503,7 @@ static void MousevscOnChannelCallback(void *Context)
 	unsigned char	*buffer = packet;
 	int	bufferlen = packetSize;
 
-	inputDevice = MustGetInputDevice(device);
+	inputDevice = must_get_input_device(device);
 
 	if (!inputDevice) {
 		pr_err("unable to get input device...device being destroyed?");
@@ -515,12 +519,13 @@ static void MousevscOnChannelCallback(void *Context)
 
 				switch (desc->type) {
 					case VM_PKT_COMP:
-						MousevscOnSendCompletion(device,
-									 desc);
+						mousevsc_on_send_completion(
+							device, desc);
 						break;
 
 					case VM_PKT_DATA_INBAND:
-						MousevscOnReceive(device, desc);
+						mousevsc_on_receive(
+							device, desc);
 						break;
 
 					default:
@@ -568,19 +573,19 @@ static void MousevscOnChannelCallback(void *Context)
 		}
 	} while (1);
 
-	PutInputDevice(device);
+	put_input_device(device);
 
 	return;
 }
 
-static int MousevscConnectToVsp(struct hv_device *Device)
+static int mousevsc_connect_to_vsp(struct hv_device *Device)
 {
 	int ret = 0;
 	struct mousevsc_dev *inputDevice;
 	struct mousevsc_prt_msg *request;
 	struct mousevsc_prt_msg *response;
 
-	inputDevice = GetInputDevice(Device);
+	inputDevice = get_input_device(Device);
 
 	if (!inputDevice) {
 		pr_err("unable to get input device...device being destroyed?");
@@ -651,19 +656,20 @@ static int MousevscConnectToVsp(struct hv_device *Device)
 		ret = -1;
 
 Cleanup:
-	PutInputDevice(Device);
+	put_input_device(Device);
 
 	return ret;
 }
 
-static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
+static int mousevsc_on_device_add(struct hv_device *Device,
+					void *AdditionalInfo)
 {
 	int ret = 0;
 	struct mousevsc_dev *inputDevice;
 	struct mousevsc_drv_obj *inputDriver;
 	struct hv_input_dev_info dev_info;
 
-	inputDevice = AllocInputDevice(Device);
+	inputDevice = alloc_input_device(Device);
 
 	if (!inputDevice) {
 		ret = -1;
@@ -678,25 +684,25 @@ static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
 		INPUTVSC_RECV_RING_BUFFER_SIZE,
 		NULL,
 		0,
-		MousevscOnChannelCallback,
+		mousevsc_on_channel_callback,
 		Device
 		);
 
 	if (ret != 0) {
 		pr_err("unable to open channel: %d", ret);
-		FreeInputDevice(inputDevice);
+		free_input_device(inputDevice);
 		return -1;
 	}
 
 	pr_info("InputVsc channel open: %d", ret);
 
-	ret = MousevscConnectToVsp(Device);
+	ret = mousevsc_connect_to_vsp(Device);
 
 	if (ret != 0) {
 		pr_err("unable to connect channel: %d", ret);
 
 		vmbus_close(Device->channel);
-		FreeInputDevice(inputDevice);
+		free_input_device(inputDevice);
 		return ret;
 	}
 
@@ -724,7 +730,7 @@ Cleanup:
 	return ret;
 }
 
-static int MousevscOnDeviceRemove(struct hv_device *Device)
+static int mousevsc_on_device_remove(struct hv_device *Device)
 {
 	struct mousevsc_dev *inputDevice;
 	int ret = 0;
@@ -732,7 +738,7 @@ static int MousevscOnDeviceRemove(struct hv_device *Device)
 	pr_info("disabling input device (%p)...",
 		    Device->ext);
 
-	inputDevice = ReleaseInputDevice(Device);
+	inputDevice = release_input_device(Device);
 
 
 	/*
@@ -749,19 +755,19 @@ static int MousevscOnDeviceRemove(struct hv_device *Device)
 
 	pr_info("removing input device (%p)...", Device->ext);
 
-	inputDevice = FinalReleaseInputDevice(Device);
+	inputDevice = final_release_input_device(Device);
 
 	pr_info("input device (%p) safe to remove", inputDevice);
 
 	/* Close the channel */
 	vmbus_close(Device->channel);
 
-	FreeInputDevice(inputDevice);
+	free_input_device(inputDevice);
 
 	return ret;
 }
 
-static void MousevscOnCleanup(struct hv_driver *drv)
+static void mousevsc_on_cleanup(struct hv_driver *drv)
 {
 }
 
@@ -984,9 +990,9 @@ static int mouse_vsc_initialize(struct hv_driver *Driver)
 	       sizeof(struct hv_guid));
 
 	/* Setup the dispatch table */
-	inputDriver->Base.dev_add = MousevscOnDeviceAdd;
-	inputDriver->Base.dev_rm = MousevscOnDeviceRemove;
-	inputDriver->Base.cleanup = MousevscOnCleanup;
+	inputDriver->Base.dev_add = mousevsc_on_device_add;
+	inputDriver->Base.dev_rm = mousevsc_on_device_remove;
+	inputDriver->Base.cleanup = mousevsc_on_cleanup;
 
 	return ret;
 }
-- 
1.7.1

^ permalink raw reply related

* [PATCH 2/5] staging: hv: Convert camel case func params to lower case in hv_mouse
From: Hank Janssen @ 2011-04-01 21:32 UTC (permalink / raw)
  To: hjanssen, hjanssen, haiyangz, gregkh, linux-kernel, devel,
	virtualization
  Cc: Abhishek Kane, K. Y. Srinivasan
In-Reply-To: <1301693534-14629-1-git-send-email-hjanssen@microsoft.com>

Change all camelcase function params to lower case in hv_mouse

Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

---
 drivers/staging/hv/hv_mouse.c |  172 +++++++++++++++++++++--------------------
 1 files changed, 87 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 084ba3b..3b0390d 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -200,7 +200,7 @@ static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info
 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
 
-static struct mousevsc_dev *alloc_input_device(struct hv_device *Device)
+static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *inputDevice;
 
@@ -215,26 +215,26 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *Device)
 	 */
 	atomic_cmpxchg(&inputDevice->RefCount, 0, 2);
 
-	inputDevice->Device = Device;
-	Device->ext = inputDevice;
+	inputDevice->Device = device;
+	device->ext = inputDevice;
 
 	return inputDevice;
 }
 
-static void free_input_device(struct mousevsc_dev *Device)
+static void free_input_device(struct mousevsc_dev *device)
 {
-	WARN_ON(atomic_read(&Device->RefCount) == 0);
-	kfree(Device);
+	WARN_ON(atomic_read(&device->RefCount) == 0);
+	kfree(device);
 }
 
 /*
  * Get the inputdevice object if exists and its refcount > 1
  */
-static struct mousevsc_dev *get_input_device(struct hv_device *Device)
+static struct mousevsc_dev *get_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *inputDevice;
 
-	inputDevice = (struct mousevsc_dev *)Device->ext;
+	inputDevice = (struct mousevsc_dev *)device->ext;
 
 /*
  *	FIXME
@@ -256,11 +256,11 @@ static struct mousevsc_dev *get_input_device(struct hv_device *Device)
 /*
  * Get the inputdevice object iff exists and its refcount > 0
  */
-static struct mousevsc_dev *must_get_input_device(struct hv_device *Device)
+static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *inputDevice;
 
-	inputDevice = (struct mousevsc_dev *)Device->ext;
+	inputDevice = (struct mousevsc_dev *)device->ext;
 
 	if (inputDevice && atomic_read(&inputDevice->RefCount))
 		atomic_inc(&inputDevice->RefCount);
@@ -270,11 +270,11 @@ static struct mousevsc_dev *must_get_input_device(struct hv_device *Device)
 	return inputDevice;
 }
 
-static void put_input_device(struct hv_device *Device)
+static void put_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *inputDevice;
 
-	inputDevice = (struct mousevsc_dev *)Device->ext;
+	inputDevice = (struct mousevsc_dev *)device->ext;
 
 	atomic_dec(&inputDevice->RefCount);
 }
@@ -282,11 +282,11 @@ static void put_input_device(struct hv_device *Device)
 /*
  * Drop ref count to 1 to effectively disable get_input_device()
  */
-static struct mousevsc_dev *release_input_device(struct hv_device *Device)
+static struct mousevsc_dev *release_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *inputDevice;
 
-	inputDevice = (struct mousevsc_dev *)Device->ext;
+	inputDevice = (struct mousevsc_dev *)device->ext;
 
 	/* Busy wait until the ref drop to 2, then set it to 1  */
 	while (atomic_cmpxchg(&inputDevice->RefCount, 2, 1) != 2)
@@ -296,82 +296,83 @@ static struct mousevsc_dev *release_input_device(struct hv_device *Device)
 }
 
 /*
- * Drop ref count to 0. No one can use InputDevice object.
+ * Drop ref count to 0. No one can use input_device object.
  */
-static struct mousevsc_dev *final_release_input_device(struct hv_device *Device)
+static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *inputDevice;
 
-	inputDevice = (struct mousevsc_dev *)Device->ext;
+	inputDevice = (struct mousevsc_dev *)device->ext;
 
 	/* Busy wait until the ref drop to 1, then set it to 0  */
 	while (atomic_cmpxchg(&inputDevice->RefCount, 1, 0) != 1)
 		udelay(100);
 
-	Device->ext = NULL;
+	device->ext = NULL;
 	return inputDevice;
 }
 
-static void mousevsc_on_send_completion(struct hv_device *Device,
-					struct vmpacket_descriptor *Packet)
+static void mousevsc_on_send_completion(struct hv_device *device,
+					struct vmpacket_descriptor *packet)
 {
 	struct mousevsc_dev *inputDevice;
 	void *request;
 
-	inputDevice = must_get_input_device(Device);
+	inputDevice = must_get_input_device(device);
 	if (!inputDevice) {
 		pr_err("unable to get input device...device being destroyed?");
 		return;
 	}
 
-	request = (void *)(unsigned long)Packet->trans_id;
+	request = (void *)(unsigned long)packet->trans_id;
 
 	if (request == &inputDevice->ProtocolReq) {
 		/* FIXME */
 		/* Shouldn't we be doing something here? */
 	}
 
-	put_input_device(Device);
+	put_input_device(device);
 }
 
-static void mousevsc_on_receive_device_info(struct mousevsc_dev *InputDevice,
-					struct synthhid_device_info *DeviceInfo)
+static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
+				struct synthhid_device_info *device_info)
 {
 	int ret = 0;
 	struct hid_descriptor *desc;
 	struct mousevsc_prt_msg ack;
 
 	/* Assume success for now */
-	InputDevice->DeviceInfoStatus = 0;
+	input_device->DeviceInfoStatus = 0;
 
 	/* Save the device attr */
-	memcpy(&InputDevice->hid_dev_info, &DeviceInfo->hid_dev_info, sizeof(struct hv_input_dev_info));
+	memcpy(&input_device->hid_dev_info, &device_info->hid_dev_info,
+		sizeof(struct hv_input_dev_info));
 
 	/* Save the hid desc */
-	desc = &DeviceInfo->hid_descriptor;
+	desc = &device_info->hid_descriptor;
 	WARN_ON(desc->bLength > 0);
 
-	InputDevice->HidDesc = kzalloc(desc->bLength, GFP_KERNEL);
+	input_device->HidDesc = kzalloc(desc->bLength, GFP_KERNEL);
 
-	if (!InputDevice->HidDesc) {
+	if (!input_device->HidDesc) {
 		pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
 		goto Cleanup;
 	}
 
-	memcpy(InputDevice->HidDesc, desc, desc->bLength);
+	memcpy(input_device->HidDesc, desc, desc->bLength);
 
 	/* Save the report desc */
-	InputDevice->ReportDescSize = desc->desc[0].wDescriptorLength;
-	InputDevice->ReportDesc = kzalloc(InputDevice->ReportDescSize,
+	input_device->ReportDescSize = desc->desc[0].wDescriptorLength;
+	input_device->ReportDesc = kzalloc(input_device->ReportDescSize,
 					  GFP_KERNEL);
 
-	if (!InputDevice->ReportDesc) {
+	if (!input_device->ReportDesc) {
 		pr_err("unable to allocate report descriptor - size %d",
-			   InputDevice->ReportDescSize);
+			   input_device->ReportDescSize);
 		goto Cleanup;
 	}
 
-	memcpy(InputDevice->ReportDesc,
+	memcpy(input_device->ReportDesc,
 	       ((unsigned char *)desc) + desc->bLength,
 	       desc->desc[0].wDescriptorLength);
 
@@ -385,7 +386,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *InputDevice,
 	ack.ack.header.size = 1;
 	ack.ack.reserved = 0;
 
-	ret = vmbus_sendpacket(InputDevice->Device->channel,
+	ret = vmbus_sendpacket(input_device->Device->channel,
 			&ack,
 			sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
 			sizeof(struct synthhid_device_info_ack),
@@ -398,59 +399,60 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *InputDevice,
 		goto Cleanup;
 	}
 
-	InputDevice->device_wait_condition = 1;
-	wake_up(&InputDevice->DeviceInfoWaitEvent);
+	input_device->device_wait_condition = 1;
+	wake_up(&input_device->DeviceInfoWaitEvent);
 
 	return;
 
 Cleanup:
-	kfree(InputDevice->HidDesc);
-	InputDevice->HidDesc = NULL;
+	kfree(input_device->HidDesc);
+	input_device->HidDesc = NULL;
 
-	kfree(InputDevice->ReportDesc);
-	InputDevice->ReportDesc = NULL;
+	kfree(input_device->ReportDesc);
+	input_device->ReportDesc = NULL;
 
-	InputDevice->DeviceInfoStatus = -1;
-	InputDevice->device_wait_condition = 1;
-	wake_up(&InputDevice->DeviceInfoWaitEvent);
+	input_device->DeviceInfoStatus = -1;
+	input_device->device_wait_condition = 1;
+	wake_up(&input_device->DeviceInfoWaitEvent);
 }
 
-static void mousevsc_on_receive_input_report(struct mousevsc_dev *InputDevice,
-				struct synthhid_input_report *InputReport)
+static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
+				struct synthhid_input_report *input_report)
 {
 	struct mousevsc_drv_obj *inputDriver;
 
-	if (!InputDevice->bInitializeComplete) {
-		pr_info("Initialization incomplete...ignoring InputReport msg");
+	if (!input_device->bInitializeComplete) {
+		pr_info("Initialization incomplete...ignoring input_report msg");
 		return;
 	}
 
-	inputDriver = (struct mousevsc_drv_obj *)InputDevice->Device->drv;
+	inputDriver = (struct mousevsc_drv_obj *)input_device->Device->drv;
 
-	inputreport_callback(InputDevice->Device,
-			     InputReport->buffer,
-			     InputReport->header.size);
+	inputreport_callback(input_device->Device,
+			     input_report->buffer,
+			     input_report->header.size);
 }
 
-static void mousevsc_on_receive(struct hv_device *Device,
-				struct vmpacket_descriptor *Packet)
+static void mousevsc_on_receive(struct hv_device *device,
+				struct vmpacket_descriptor *packet)
 {
 	struct pipe_prt_msg *pipeMsg;
 	struct synthhid_msg *hidMsg;
 	struct mousevsc_dev *inputDevice;
 
-	inputDevice = must_get_input_device(Device);
+	inputDevice = must_get_input_device(device);
 	if (!inputDevice) {
 		pr_err("unable to get input device...device being destroyed?");
 		return;
 	}
 
-	pipeMsg = (struct pipe_prt_msg *)((unsigned long)Packet + (Packet->offset8 << 3));
+	pipeMsg = (struct pipe_prt_msg *)((unsigned long)packet +
+						(packet->offset8 << 3));
 
 	if (pipeMsg->type != PipeMessageData) {
 		pr_err("unknown pipe msg type - type %d len %d",
 			   pipeMsg->type, pipeMsg->size);
-		put_input_device(Device);
+		put_input_device(device);
 		return ;
 	}
 
@@ -486,14 +488,14 @@ static void mousevsc_on_receive(struct hv_device *Device,
 		break;
 	}
 
-	put_input_device(Device);
+	put_input_device(device);
 }
 
-static void mousevsc_on_channel_callback(void *Context)
+static void mousevsc_on_channel_callback(void *context)
 {
 	const int packetSize = 0x100;
 	int ret = 0;
-	struct hv_device *device = (struct hv_device *)Context;
+	struct hv_device *device = (struct hv_device *)context;
 	struct mousevsc_dev *inputDevice;
 
 	u32 bytesRecvd;
@@ -578,14 +580,14 @@ static void mousevsc_on_channel_callback(void *Context)
 	return;
 }
 
-static int mousevsc_connect_to_vsp(struct hv_device *Device)
+static int mousevsc_connect_to_vsp(struct hv_device *device)
 {
 	int ret = 0;
 	struct mousevsc_dev *inputDevice;
 	struct mousevsc_prt_msg *request;
 	struct mousevsc_prt_msg *response;
 
-	inputDevice = get_input_device(Device);
+	inputDevice = get_input_device(device);
 
 	if (!inputDevice) {
 		pr_err("unable to get input device...device being destroyed?");
@@ -611,7 +613,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *Device)
 
 	pr_info("synthhid protocol request...");
 
-	ret = vmbus_sendpacket(Device->channel, request,
+	ret = vmbus_sendpacket(device->channel, request,
 					sizeof(struct pipe_prt_msg) -
 					sizeof(unsigned char) +
 					sizeof(struct synthhid_protocol_request),
@@ -656,20 +658,20 @@ static int mousevsc_connect_to_vsp(struct hv_device *Device)
 		ret = -1;
 
 Cleanup:
-	put_input_device(Device);
+	put_input_device(device);
 
 	return ret;
 }
 
-static int mousevsc_on_device_add(struct hv_device *Device,
-					void *AdditionalInfo)
+static int mousevsc_on_device_add(struct hv_device *device,
+					void *additional_info)
 {
 	int ret = 0;
 	struct mousevsc_dev *inputDevice;
 	struct mousevsc_drv_obj *inputDriver;
 	struct hv_input_dev_info dev_info;
 
-	inputDevice = alloc_input_device(Device);
+	inputDevice = alloc_input_device(device);
 
 	if (!inputDevice) {
 		ret = -1;
@@ -679,13 +681,13 @@ static int mousevsc_on_device_add(struct hv_device *Device,
 	inputDevice->bInitializeComplete = false;
 
 	/* Open the channel */
-	ret = vmbus_open(Device->channel,
+	ret = vmbus_open(device->channel,
 		INPUTVSC_SEND_RING_BUFFER_SIZE,
 		INPUTVSC_RECV_RING_BUFFER_SIZE,
 		NULL,
 		0,
 		mousevsc_on_channel_callback,
-		Device
+		device
 		);
 
 	if (ret != 0) {
@@ -696,12 +698,12 @@ static int mousevsc_on_device_add(struct hv_device *Device,
 
 	pr_info("InputVsc channel open: %d", ret);
 
-	ret = mousevsc_connect_to_vsp(Device);
+	ret = mousevsc_connect_to_vsp(device);
 
 	if (ret != 0) {
 		pr_err("unable to connect channel: %d", ret);
 
-		vmbus_close(Device->channel);
+		vmbus_close(device->channel);
 		free_input_device(inputDevice);
 		return ret;
 	}
@@ -714,14 +716,14 @@ static int mousevsc_on_device_add(struct hv_device *Device,
 	strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse");
 
 	/* Send the device info back up */
-	deviceinfo_callback(Device, &dev_info);
+	deviceinfo_callback(device, &dev_info);
 
 	/* Send the report desc back up */
 	/* workaround SA-167 */
 	if (inputDevice->ReportDesc[14] == 0x25)
 		inputDevice->ReportDesc[14] = 0x29;
 
-	reportdesc_callback(Device, inputDevice->ReportDesc,
+	reportdesc_callback(device, inputDevice->ReportDesc,
 			    inputDevice->ReportDescSize);
 
 	inputDevice->bInitializeComplete = true;
@@ -730,15 +732,15 @@ Cleanup:
 	return ret;
 }
 
-static int mousevsc_on_device_remove(struct hv_device *Device)
+static int mousevsc_on_device_remove(struct hv_device *device)
 {
 	struct mousevsc_dev *inputDevice;
 	int ret = 0;
 
 	pr_info("disabling input device (%p)...",
-		    Device->ext);
+		    device->ext);
 
-	inputDevice = release_input_device(Device);
+	inputDevice = release_input_device(device);
 
 
 	/*
@@ -753,14 +755,14 @@ static int mousevsc_on_device_remove(struct hv_device *Device)
 		udelay(100);
 	}
 
-	pr_info("removing input device (%p)...", Device->ext);
+	pr_info("removing input device (%p)...", device->ext);
 
-	inputDevice = final_release_input_device(Device);
+	inputDevice = final_release_input_device(device);
 
 	pr_info("input device (%p) safe to remove", inputDevice);
 
 	/* Close the channel */
-	vmbus_close(Device->channel);
+	vmbus_close(device->channel);
 
 	free_input_device(inputDevice);
 
@@ -979,14 +981,14 @@ static void mousevsc_drv_exit(void)
 	return;
 }
 
-static int mouse_vsc_initialize(struct hv_driver *Driver)
+static int mouse_vsc_initialize(struct hv_driver *driver)
 {
 	struct mousevsc_drv_obj *inputDriver =
-		(struct mousevsc_drv_obj *)Driver;
+		(struct mousevsc_drv_obj *)driver;
 	int ret = 0;
 
-	Driver->name = driver_name;
-	memcpy(&Driver->dev_type, &mouse_guid,
+	driver->name = driver_name;
+	memcpy(&driver->dev_type, &mouse_guid,
 	       sizeof(struct hv_guid));
 
 	/* Setup the dispatch table */
-- 
1.7.1

^ permalink raw reply related

* [PATCH 3/5] staging: hv: Convert camel case member of struct mousevsc_drv_obj to lower case
From: Hank Janssen @ 2011-04-01 21:32 UTC (permalink / raw)
  To: hjanssen, hjanssen, haiyangz, gregkh, linux-kernel, devel,
	virtualization
  Cc: Abhishek Kane, K. Y. Srinivasan
In-Reply-To: <1301693534-14629-1-git-send-email-hjanssen@microsoft.com>

Change camelcase members of mousevsc_drv_obj to lower case in hv_mouse.

Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

---
 drivers/staging/hv/hv_mouse.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 3b0390d..ce88868 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -46,7 +46,7 @@ struct hv_input_dev_info {
 /* Represents the input vsc driver */
 /* FIXME - can be removed entirely */
 struct mousevsc_drv_obj {
-	struct hv_driver Base;
+	struct hv_driver base;
 };
 
 
@@ -836,7 +836,7 @@ static int mousevsc_probe(struct device *device)
 	dev_set_drvdata(device, input_dev_ctx);
 
 	/* Call to the vsc driver to add the device */
-	ret = mousevsc_drv_obj->Base.dev_add(device_obj, NULL);
+	ret = mousevsc_drv_obj->base.dev_add(device_obj, NULL);
 
 	if (ret != 0) {
 		DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device");
@@ -868,14 +868,14 @@ static int mousevsc_remove(struct device *device)
 		input_dev_ctx->connected = 0;
 	}
 
-	if (!mousevsc_drv_obj->Base.dev_rm)
+	if (!mousevsc_drv_obj->base.dev_rm)
 		return -1;
 
 	/*
 	 * Call to the vsc driver to let it know that the device
 	 * is being removed
 	 */
-	ret = mousevsc_drv_obj->Base.dev_rm(device_obj);
+	ret = mousevsc_drv_obj->base.dev_rm(device_obj);
 
 	if (ret != 0) {
 		DPRINT_ERR(INPUTVSC_DRV,
@@ -951,7 +951,7 @@ static int mousevsc_drv_exit_cb(struct device *dev, void *data)
 static void mousevsc_drv_exit(void)
 {
 	struct mousevsc_drv_obj *mousevsc_drv_obj = &g_mousevsc_drv;
-	struct hv_driver *drv = &g_mousevsc_drv.Base;
+	struct hv_driver *drv = &g_mousevsc_drv.base;
 	int ret;
 
 	struct device *current_dev = NULL;
@@ -973,8 +973,8 @@ static void mousevsc_drv_exit(void)
 		device_unregister(current_dev);
 	}
 
-	if (mousevsc_drv_obj->Base.cleanup)
-		mousevsc_drv_obj->Base.cleanup(&mousevsc_drv_obj->Base);
+	if (mousevsc_drv_obj->base.cleanup)
+		mousevsc_drv_obj->base.cleanup(&mousevsc_drv_obj->base);
 
 	vmbus_child_driver_unregister(&drv->driver);
 
@@ -992,9 +992,9 @@ static int mouse_vsc_initialize(struct hv_driver *driver)
 	       sizeof(struct hv_guid));
 
 	/* Setup the dispatch table */
-	inputDriver->Base.dev_add = mousevsc_on_device_add;
-	inputDriver->Base.dev_rm = mousevsc_on_device_remove;
-	inputDriver->Base.cleanup = mousevsc_on_cleanup;
+	inputDriver->base.dev_add = mousevsc_on_device_add;
+	inputDriver->base.dev_rm = mousevsc_on_device_remove;
+	inputDriver->base.cleanup = mousevsc_on_cleanup;
 
 	return ret;
 }
@@ -1003,14 +1003,14 @@ static int mouse_vsc_initialize(struct hv_driver *driver)
 static int __init mousevsc_init(void)
 {
 	struct mousevsc_drv_obj *input_drv_obj = &g_mousevsc_drv;
-	struct hv_driver *drv = &g_mousevsc_drv.Base;
+	struct hv_driver *drv = &g_mousevsc_drv.base;
 
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
 	/* Callback to client driver to complete the initialization */
-	mouse_vsc_initialize(&input_drv_obj->Base);
+	mouse_vsc_initialize(&input_drv_obj->base);
 
-	drv->driver.name = input_drv_obj->Base.name;
+	drv->driver.name = input_drv_obj->base.name;
 	drv->priv = input_drv_obj;
 
 	drv->driver.probe = mousevsc_probe;
-- 
1.7.1

^ permalink raw reply related

* [PATCH 4/5] staging: hv: Convert camel case members of struct mousevsc_dev to lower case
From: Hank Janssen @ 2011-04-01 21:32 UTC (permalink / raw)
  To: hjanssen, hjanssen, haiyangz, gregkh, linux-kernel, devel,
	virtualization
  Cc: Abhishek Kane
In-Reply-To: <1301693534-14629-1-git-send-email-hjanssen@microsoft.com>

Change camelcase members of struct mousevsc_dev to lower case in hv_mouse

Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

---
 drivers/staging/hv/hv_mouse.c |  127 +++++++++++++++++++++--------------------
 1 files changed, 65 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index ce88868..1edcdf7 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -167,23 +167,23 @@ struct  mousevsc_prt_msg {
  * Represents an mousevsc device
  */
 struct mousevsc_dev {
-	struct hv_device	*Device;
+	struct hv_device	*device;
 	/* 0 indicates the device is being destroyed */
-	atomic_t		RefCount;
-	int			NumOutstandingRequests;
-	unsigned char		bInitializeComplete;
-	struct mousevsc_prt_msg	ProtocolReq;
-	struct mousevsc_prt_msg	ProtocolResp;
+	atomic_t		ref_count;
+	int			num_outstanding_req;
+	unsigned char		init_complete;
+	struct mousevsc_prt_msg	protocol_req;
+	struct mousevsc_prt_msg	protocol_resp;
 	/* Synchronize the request/response if needed */
-	wait_queue_head_t	ProtocolWaitEvent;
-	wait_queue_head_t	DeviceInfoWaitEvent;
+	wait_queue_head_t	protocol_wait_event;
+	wait_queue_head_t	dev_info_wait_event;
 	int			protocol_wait_condition;
 	int			device_wait_condition;
-	int			DeviceInfoStatus;
+	int			dev_info_status;
 
-	struct hid_descriptor	*HidDesc;
-	unsigned char		*ReportDesc;
-	u32			ReportDescSize;
+	struct hid_descriptor	*hid_desc;
+	unsigned char		*report_desc;
+	u32			report_desc_size;
 	struct hv_input_dev_info hid_dev_info;
 };
 
@@ -213,9 +213,9 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 	 * Set to 2 to allow both inbound and outbound traffics
 	 * (ie get_input_device() and must_get_input_device()) to proceed.
 	 */
-	atomic_cmpxchg(&inputDevice->RefCount, 0, 2);
+	atomic_cmpxchg(&inputDevice->ref_count, 0, 2);
 
-	inputDevice->Device = device;
+	inputDevice->device = device;
 	device->ext = inputDevice;
 
 	return inputDevice;
@@ -223,7 +223,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 
 static void free_input_device(struct mousevsc_dev *device)
 {
-	WARN_ON(atomic_read(&device->RefCount) == 0);
+	WARN_ON(atomic_read(&device->ref_count) == 0);
 	kfree(device);
 }
 
@@ -242,11 +242,11 @@ static struct mousevsc_dev *get_input_device(struct hv_device *device)
  *	what the intention is...
  *
  *	printk(KERN_ERR "-------------------------> REFCOUNT = %d",
- *	       inputDevice->RefCount);
+ *	       inputDevice->ref_count);
  */
 
-	if (inputDevice && atomic_read(&inputDevice->RefCount) > 1)
-		atomic_inc(&inputDevice->RefCount);
+	if (inputDevice && atomic_read(&inputDevice->ref_count) > 1)
+		atomic_inc(&inputDevice->ref_count);
 	else
 		inputDevice = NULL;
 
@@ -262,8 +262,8 @@ static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
 
 	inputDevice = (struct mousevsc_dev *)device->ext;
 
-	if (inputDevice && atomic_read(&inputDevice->RefCount))
-		atomic_inc(&inputDevice->RefCount);
+	if (inputDevice && atomic_read(&inputDevice->ref_count))
+		atomic_inc(&inputDevice->ref_count);
 	else
 		inputDevice = NULL;
 
@@ -276,7 +276,7 @@ static void put_input_device(struct hv_device *device)
 
 	inputDevice = (struct mousevsc_dev *)device->ext;
 
-	atomic_dec(&inputDevice->RefCount);
+	atomic_dec(&inputDevice->ref_count);
 }
 
 /*
@@ -289,7 +289,7 @@ static struct mousevsc_dev *release_input_device(struct hv_device *device)
 	inputDevice = (struct mousevsc_dev *)device->ext;
 
 	/* Busy wait until the ref drop to 2, then set it to 1  */
-	while (atomic_cmpxchg(&inputDevice->RefCount, 2, 1) != 2)
+	while (atomic_cmpxchg(&inputDevice->ref_count, 2, 1) != 2)
 		udelay(100);
 
 	return inputDevice;
@@ -305,7 +305,7 @@ static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
 	inputDevice = (struct mousevsc_dev *)device->ext;
 
 	/* Busy wait until the ref drop to 1, then set it to 0  */
-	while (atomic_cmpxchg(&inputDevice->RefCount, 1, 0) != 1)
+	while (atomic_cmpxchg(&inputDevice->ref_count, 1, 0) != 1)
 		udelay(100);
 
 	device->ext = NULL;
@@ -326,7 +326,7 @@ static void mousevsc_on_send_completion(struct hv_device *device,
 
 	request = (void *)(unsigned long)packet->trans_id;
 
-	if (request == &inputDevice->ProtocolReq) {
+	if (request == &inputDevice->protocol_req) {
 		/* FIXME */
 		/* Shouldn't we be doing something here? */
 	}
@@ -342,7 +342,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	struct mousevsc_prt_msg ack;
 
 	/* Assume success for now */
-	input_device->DeviceInfoStatus = 0;
+	input_device->dev_info_status = 0;
 
 	/* Save the device attr */
 	memcpy(&input_device->hid_dev_info, &device_info->hid_dev_info,
@@ -352,27 +352,27 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	desc = &device_info->hid_descriptor;
 	WARN_ON(desc->bLength > 0);
 
-	input_device->HidDesc = kzalloc(desc->bLength, GFP_KERNEL);
+	input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL);
 
-	if (!input_device->HidDesc) {
+	if (!input_device->hid_desc) {
 		pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
 		goto Cleanup;
 	}
 
-	memcpy(input_device->HidDesc, desc, desc->bLength);
+	memcpy(input_device->hid_desc, desc, desc->bLength);
 
 	/* Save the report desc */
-	input_device->ReportDescSize = desc->desc[0].wDescriptorLength;
-	input_device->ReportDesc = kzalloc(input_device->ReportDescSize,
+	input_device->report_desc_size = desc->desc[0].wDescriptorLength;
+	input_device->report_desc = kzalloc(input_device->report_desc_size,
 					  GFP_KERNEL);
 
-	if (!input_device->ReportDesc) {
+	if (!input_device->report_desc) {
 		pr_err("unable to allocate report descriptor - size %d",
-			   input_device->ReportDescSize);
+			   input_device->report_desc_size);
 		goto Cleanup;
 	}
 
-	memcpy(input_device->ReportDesc,
+	memcpy(input_device->report_desc,
 	       ((unsigned char *)desc) + desc->bLength,
 	       desc->desc[0].wDescriptorLength);
 
@@ -386,7 +386,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	ack.ack.header.size = 1;
 	ack.ack.reserved = 0;
 
-	ret = vmbus_sendpacket(input_device->Device->channel,
+	ret = vmbus_sendpacket(input_device->device->channel,
 			&ack,
 			sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
 			sizeof(struct synthhid_device_info_ack),
@@ -400,20 +400,20 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	}
 
 	input_device->device_wait_condition = 1;
-	wake_up(&input_device->DeviceInfoWaitEvent);
+	wake_up(&input_device->dev_info_wait_event);
 
 	return;
 
 Cleanup:
-	kfree(input_device->HidDesc);
-	input_device->HidDesc = NULL;
+	kfree(input_device->hid_desc);
+	input_device->hid_desc = NULL;
 
-	kfree(input_device->ReportDesc);
-	input_device->ReportDesc = NULL;
+	kfree(input_device->report_desc);
+	input_device->report_desc = NULL;
 
-	input_device->DeviceInfoStatus = -1;
+	input_device->dev_info_status = -1;
 	input_device->device_wait_condition = 1;
-	wake_up(&input_device->DeviceInfoWaitEvent);
+	wake_up(&input_device->dev_info_wait_event);
 }
 
 static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
@@ -421,14 +421,14 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
 {
 	struct mousevsc_drv_obj *inputDriver;
 
-	if (!input_device->bInitializeComplete) {
+	if (!input_device->init_complete) {
 		pr_info("Initialization incomplete...ignoring input_report msg");
 		return;
 	}
 
-	inputDriver = (struct mousevsc_drv_obj *)input_device->Device->drv;
+	inputDriver = (struct mousevsc_drv_obj *)input_device->device->drv;
 
-	inputreport_callback(input_device->Device,
+	inputreport_callback(input_device->device,
 			     input_report->buffer,
 			     input_report->header.size);
 }
@@ -460,11 +460,11 @@ static void mousevsc_on_receive(struct hv_device *device,
 
 	switch (hidMsg->header.type) {
 	case SynthHidProtocolResponse:
-		memcpy(&inputDevice->ProtocolResp, pipeMsg,
+		memcpy(&inputDevice->protocol_resp, pipeMsg,
 		       pipeMsg->size + sizeof(struct pipe_prt_msg) -
 		       sizeof(unsigned char));
 		inputDevice->protocol_wait_condition = 1;
-		wake_up(&inputDevice->ProtocolWaitEvent);
+		wake_up(&inputDevice->protocol_wait_event);
 		break;
 
 	case SynthHidInitialDeviceInfo:
@@ -594,10 +594,10 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		return -1;
 	}
 
-	init_waitqueue_head(&inputDevice->ProtocolWaitEvent);
-	init_waitqueue_head(&inputDevice->DeviceInfoWaitEvent);
+	init_waitqueue_head(&inputDevice->protocol_wait_event);
+	init_waitqueue_head(&inputDevice->dev_info_wait_event);
 
-	request = &inputDevice->ProtocolReq;
+	request = &inputDevice->protocol_req;
 
 	/*
 	 * Now, initiate the vsc/vsp initialization protocol on the open channel
@@ -626,13 +626,14 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	}
 
 	inputDevice->protocol_wait_condition = 0;
-	wait_event_timeout(inputDevice->ProtocolWaitEvent, inputDevice->protocol_wait_condition, msecs_to_jiffies(1000));
+	wait_event_timeout(inputDevice->protocol_wait_event,
+		inputDevice->protocol_wait_condition, msecs_to_jiffies(1000));
 	if (inputDevice->protocol_wait_condition == 0) {
 		ret = -ETIMEDOUT;
 		goto Cleanup;
 	}
 
-	response = &inputDevice->ProtocolResp;
+	response = &inputDevice->protocol_resp;
 
 	if (!response->response.approved) {
 		pr_err("synthhid protocol request failed (version %d)",
@@ -642,7 +643,8 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	}
 
 	inputDevice->device_wait_condition = 0;
-	wait_event_timeout(inputDevice->DeviceInfoWaitEvent, inputDevice->device_wait_condition, msecs_to_jiffies(1000));
+	wait_event_timeout(inputDevice->dev_info_wait_event,
+		inputDevice->device_wait_condition, msecs_to_jiffies(1000));
 	if (inputDevice->device_wait_condition == 0) {
 		ret = -ETIMEDOUT;
 		goto Cleanup;
@@ -652,7 +654,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	 * We should have gotten the device attr, hid desc and report
 	 * desc at this point
 	 */
-	if (!inputDevice->DeviceInfoStatus)
+	if (!inputDevice->dev_info_status)
 		pr_info("**** input channel up and running!! ****");
 	else
 		ret = -1;
@@ -678,7 +680,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 		goto Cleanup;
 	}
 
-	inputDevice->bInitializeComplete = false;
+	inputDevice->init_complete = false;
 
 	/* Open the channel */
 	ret = vmbus_open(device->channel,
@@ -708,7 +710,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 		return ret;
 	}
 
-	inputDriver = (struct mousevsc_drv_obj *)inputDevice->Device->drv;
+	inputDriver = (struct mousevsc_drv_obj *)inputDevice->device->drv;
 
 	dev_info.vendor = inputDevice->hid_dev_info.vendor;
 	dev_info.product = inputDevice->hid_dev_info.product;
@@ -720,13 +722,13 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	/* Send the report desc back up */
 	/* workaround SA-167 */
-	if (inputDevice->ReportDesc[14] == 0x25)
-		inputDevice->ReportDesc[14] = 0x29;
+	if (inputDevice->report_desc[14] == 0x25)
+		inputDevice->report_desc[14] = 0x29;
 
-	reportdesc_callback(device, inputDevice->ReportDesc,
-			    inputDevice->ReportDescSize);
+	reportdesc_callback(device, inputDevice->report_desc,
+			    inputDevice->report_desc_size);
 
-	inputDevice->bInitializeComplete = true;
+	inputDevice->init_complete = true;
 
 Cleanup:
 	return ret;
@@ -749,8 +751,9 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 	 *
 	 * so that outstanding requests can be completed.
 	 */
-	while (inputDevice->NumOutstandingRequests) {
-		pr_info("waiting for %d requests to complete...", inputDevice->NumOutstandingRequests);
+	while (inputDevice->num_outstanding_req) {
+		pr_info("waiting for %d requests to complete...",
+			inputDevice->num_outstanding_req);
 
 		udelay(100);
 	}
-- 
1.7.1

^ permalink raw reply related

* [PATCH 5/5] staging: hv: Convert camel case in in all functions to lower case in hv_mouse
From: Hank Janssen @ 2011-04-01 21:32 UTC (permalink / raw)
  To: hjanssen, hjanssen, haiyangz, gregkh, linux-kernel, devel,
	virtualization
  Cc: Abhishek Kane, K. Y. Srinivasan
In-Reply-To: <1301693534-14629-1-git-send-email-hjanssen@microsoft.com>

Convert all camelcase variables inside of all remaining functions to lower 
case in hv_mouse.

Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

---
 drivers/staging/hv/hv_mouse.c |  225 +++++++++++++++++++++--------------------
 1 files changed, 113 insertions(+), 112 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 1edcdf7..23b69c1 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -202,23 +202,23 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
 
 static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 
-	inputDevice = kzalloc(sizeof(struct mousevsc_dev), GFP_KERNEL);
+	input_dev = kzalloc(sizeof(struct mousevsc_dev), GFP_KERNEL);
 
-	if (!inputDevice)
+	if (!input_dev)
 		return NULL;
 
 	/*
 	 * Set to 2 to allow both inbound and outbound traffics
 	 * (ie get_input_device() and must_get_input_device()) to proceed.
 	 */
-	atomic_cmpxchg(&inputDevice->ref_count, 0, 2);
+	atomic_cmpxchg(&input_dev->ref_count, 0, 2);
 
-	inputDevice->device = device;
-	device->ext = inputDevice;
+	input_dev->device = device;
+	device->ext = input_dev;
 
-	return inputDevice;
+	return input_dev;
 }
 
 static void free_input_device(struct mousevsc_dev *device)
@@ -232,9 +232,9 @@ static void free_input_device(struct mousevsc_dev *device)
  */
 static struct mousevsc_dev *get_input_device(struct hv_device *device)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 
-	inputDevice = (struct mousevsc_dev *)device->ext;
+	input_dev = (struct mousevsc_dev *)device->ext;
 
 /*
  *	FIXME
@@ -242,15 +242,15 @@ static struct mousevsc_dev *get_input_device(struct hv_device *device)
  *	what the intention is...
  *
  *	printk(KERN_ERR "-------------------------> REFCOUNT = %d",
- *	       inputDevice->ref_count);
+ *	       input_dev->ref_count);
  */
 
-	if (inputDevice && atomic_read(&inputDevice->ref_count) > 1)
-		atomic_inc(&inputDevice->ref_count);
+	if (input_dev && atomic_read(&input_dev->ref_count) > 1)
+		atomic_inc(&input_dev->ref_count);
 	else
-		inputDevice = NULL;
+		input_dev = NULL;
 
-	return inputDevice;
+	return input_dev;
 }
 
 /*
@@ -258,25 +258,25 @@ static struct mousevsc_dev *get_input_device(struct hv_device *device)
  */
 static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 
-	inputDevice = (struct mousevsc_dev *)device->ext;
+	input_dev = (struct mousevsc_dev *)device->ext;
 
-	if (inputDevice && atomic_read(&inputDevice->ref_count))
-		atomic_inc(&inputDevice->ref_count);
+	if (input_dev && atomic_read(&input_dev->ref_count))
+		atomic_inc(&input_dev->ref_count);
 	else
-		inputDevice = NULL;
+		input_dev = NULL;
 
-	return inputDevice;
+	return input_dev;
 }
 
 static void put_input_device(struct hv_device *device)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 
-	inputDevice = (struct mousevsc_dev *)device->ext;
+	input_dev = (struct mousevsc_dev *)device->ext;
 
-	atomic_dec(&inputDevice->ref_count);
+	atomic_dec(&input_dev->ref_count);
 }
 
 /*
@@ -284,15 +284,15 @@ static void put_input_device(struct hv_device *device)
  */
 static struct mousevsc_dev *release_input_device(struct hv_device *device)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 
-	inputDevice = (struct mousevsc_dev *)device->ext;
+	input_dev = (struct mousevsc_dev *)device->ext;
 
 	/* Busy wait until the ref drop to 2, then set it to 1  */
-	while (atomic_cmpxchg(&inputDevice->ref_count, 2, 1) != 2)
+	while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2)
 		udelay(100);
 
-	return inputDevice;
+	return input_dev;
 }
 
 /*
@@ -300,33 +300,33 @@ static struct mousevsc_dev *release_input_device(struct hv_device *device)
  */
 static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 
-	inputDevice = (struct mousevsc_dev *)device->ext;
+	input_dev = (struct mousevsc_dev *)device->ext;
 
 	/* Busy wait until the ref drop to 1, then set it to 0  */
-	while (atomic_cmpxchg(&inputDevice->ref_count, 1, 0) != 1)
+	while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1)
 		udelay(100);
 
 	device->ext = NULL;
-	return inputDevice;
+	return input_dev;
 }
 
 static void mousevsc_on_send_completion(struct hv_device *device,
 					struct vmpacket_descriptor *packet)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 	void *request;
 
-	inputDevice = must_get_input_device(device);
-	if (!inputDevice) {
+	input_dev = must_get_input_device(device);
+	if (!input_dev) {
 		pr_err("unable to get input device...device being destroyed?");
 		return;
 	}
 
 	request = (void *)(unsigned long)packet->trans_id;
 
-	if (request == &inputDevice->protocol_req) {
+	if (request == &input_dev->protocol_req) {
 		/* FIXME */
 		/* Shouldn't we be doing something here? */
 	}
@@ -419,14 +419,14 @@ Cleanup:
 static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
 				struct synthhid_input_report *input_report)
 {
-	struct mousevsc_drv_obj *inputDriver;
+	struct mousevsc_drv_obj *input_drv;
 
 	if (!input_device->init_complete) {
 		pr_info("Initialization incomplete...ignoring input_report msg");
 		return;
 	}
 
-	inputDriver = (struct mousevsc_drv_obj *)input_device->device->drv;
+	input_drv = (struct mousevsc_drv_obj *)input_device->device->drv;
 
 	inputreport_callback(input_device->device,
 			     input_report->buffer,
@@ -436,55 +436,55 @@ static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
 static void mousevsc_on_receive(struct hv_device *device,
 				struct vmpacket_descriptor *packet)
 {
-	struct pipe_prt_msg *pipeMsg;
-	struct synthhid_msg *hidMsg;
-	struct mousevsc_dev *inputDevice;
+	struct pipe_prt_msg *pipe_msg;
+	struct synthhid_msg *hid_msg;
+	struct mousevsc_dev *input_dev;
 
-	inputDevice = must_get_input_device(device);
-	if (!inputDevice) {
+	input_dev = must_get_input_device(device);
+	if (!input_dev) {
 		pr_err("unable to get input device...device being destroyed?");
 		return;
 	}
 
-	pipeMsg = (struct pipe_prt_msg *)((unsigned long)packet +
+	pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
 						(packet->offset8 << 3));
 
-	if (pipeMsg->type != PipeMessageData) {
+	if (pipe_msg->type != PipeMessageData) {
 		pr_err("unknown pipe msg type - type %d len %d",
-			   pipeMsg->type, pipeMsg->size);
+			   pipe_msg->type, pipe_msg->size);
 		put_input_device(device);
 		return ;
 	}
 
-	hidMsg = (struct synthhid_msg *)&pipeMsg->data[0];
+	hid_msg = (struct synthhid_msg *)&pipe_msg->data[0];
 
-	switch (hidMsg->header.type) {
+	switch (hid_msg->header.type) {
 	case SynthHidProtocolResponse:
-		memcpy(&inputDevice->protocol_resp, pipeMsg,
-		       pipeMsg->size + sizeof(struct pipe_prt_msg) -
+		memcpy(&input_dev->protocol_resp, pipe_msg,
+		       pipe_msg->size + sizeof(struct pipe_prt_msg) -
 		       sizeof(unsigned char));
-		inputDevice->protocol_wait_condition = 1;
-		wake_up(&inputDevice->protocol_wait_event);
+		input_dev->protocol_wait_condition = 1;
+		wake_up(&input_dev->protocol_wait_event);
 		break;
 
 	case SynthHidInitialDeviceInfo:
-		WARN_ON(pipeMsg->size >= sizeof(struct hv_input_dev_info));
+		WARN_ON(pipe_msg->size >= sizeof(struct hv_input_dev_info));
 
 		/*
 		 * Parse out the device info into device attr,
 		 * hid desc and report desc
 		 */
-		mousevsc_on_receive_device_info(inputDevice,
-					    (struct synthhid_device_info *)&pipeMsg->data[0]);
+		mousevsc_on_receive_device_info(input_dev,
+			(struct synthhid_device_info *)&pipe_msg->data[0]);
 		break;
 	case SynthHidInputReport:
-		mousevsc_on_receive_input_report(inputDevice,
-					     (struct synthhid_input_report *)&pipeMsg->data[0]);
+		mousevsc_on_receive_input_report(input_dev,
+			(struct synthhid_input_report *)&pipe_msg->data[0]);
 
 		break;
 	default:
 		pr_err("unsupported hid msg type - type %d len %d",
-		       hidMsg->header.type, hidMsg->header.size);
+		       hid_msg->header.type, hid_msg->header.size);
 		break;
 	}
 
@@ -496,27 +496,28 @@ static void mousevsc_on_channel_callback(void *context)
 	const int packetSize = 0x100;
 	int ret = 0;
 	struct hv_device *device = (struct hv_device *)context;
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 
-	u32 bytesRecvd;
-	u64 requestId;
+	u32 bytes_recvd;
+	u64 req_id;
 	unsigned char packet[packetSize];
 	struct vmpacket_descriptor *desc;
 	unsigned char	*buffer = packet;
 	int	bufferlen = packetSize;
 
-	inputDevice = must_get_input_device(device);
+	input_dev = must_get_input_device(device);
 
-	if (!inputDevice) {
+	if (!input_dev) {
 		pr_err("unable to get input device...device being destroyed?");
 		return;
 	}
 
 	do {
-		ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, &bytesRecvd, &requestId);
+		ret = vmbus_recvpacket_raw(device->channel, buffer,
+					bufferlen, &bytes_recvd, &req_id);
 
 		if (ret == 0) {
-			if (bytesRecvd > 0) {
+			if (bytes_recvd > 0) {
 				desc = (struct vmpacket_descriptor *)buffer;
 
 				switch (desc->type) {
@@ -533,8 +534,8 @@ static void mousevsc_on_channel_callback(void *context)
 					default:
 						pr_err("unhandled packet type %d, tid %llx len %d\n",
 							   desc->type,
-							   requestId,
-							   bytesRecvd);
+							   req_id,
+							   bytes_recvd);
 						break;
 				}
 
@@ -560,8 +561,8 @@ static void mousevsc_on_channel_callback(void *context)
 			}
 		} else if (ret == -2) {
 			/* Handle large packet */
-			bufferlen = bytesRecvd;
-			buffer = kzalloc(bytesRecvd, GFP_KERNEL);
+			bufferlen = bytes_recvd;
+			buffer = kzalloc(bytes_recvd, GFP_KERNEL);
 
 			if (buffer == NULL) {
 				buffer = packet;
@@ -569,7 +570,7 @@ static void mousevsc_on_channel_callback(void *context)
 
 				/* Try again next time around */
 				pr_err("unable to allocate buffer of size %d!",
-				       bytesRecvd);
+				       bytes_recvd);
 				break;
 			}
 		}
@@ -583,21 +584,21 @@ static void mousevsc_on_channel_callback(void *context)
 static int mousevsc_connect_to_vsp(struct hv_device *device)
 {
 	int ret = 0;
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 	struct mousevsc_prt_msg *request;
 	struct mousevsc_prt_msg *response;
 
-	inputDevice = get_input_device(device);
+	input_dev = get_input_device(device);
 
-	if (!inputDevice) {
+	if (!input_dev) {
 		pr_err("unable to get input device...device being destroyed?");
 		return -1;
 	}
 
-	init_waitqueue_head(&inputDevice->protocol_wait_event);
-	init_waitqueue_head(&inputDevice->dev_info_wait_event);
+	init_waitqueue_head(&input_dev->protocol_wait_event);
+	init_waitqueue_head(&input_dev->dev_info_wait_event);
 
-	request = &inputDevice->protocol_req;
+	request = &input_dev->protocol_req;
 
 	/*
 	 * Now, initiate the vsc/vsp initialization protocol on the open channel
@@ -625,15 +626,15 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		goto Cleanup;
 	}
 
-	inputDevice->protocol_wait_condition = 0;
-	wait_event_timeout(inputDevice->protocol_wait_event,
-		inputDevice->protocol_wait_condition, msecs_to_jiffies(1000));
-	if (inputDevice->protocol_wait_condition == 0) {
+	input_dev->protocol_wait_condition = 0;
+	wait_event_timeout(input_dev->protocol_wait_event,
+		input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
+	if (input_dev->protocol_wait_condition == 0) {
 		ret = -ETIMEDOUT;
 		goto Cleanup;
 	}
 
-	response = &inputDevice->protocol_resp;
+	response = &input_dev->protocol_resp;
 
 	if (!response->response.approved) {
 		pr_err("synthhid protocol request failed (version %d)",
@@ -642,10 +643,10 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		goto Cleanup;
 	}
 
-	inputDevice->device_wait_condition = 0;
-	wait_event_timeout(inputDevice->dev_info_wait_event,
-		inputDevice->device_wait_condition, msecs_to_jiffies(1000));
-	if (inputDevice->device_wait_condition == 0) {
+	input_dev->device_wait_condition = 0;
+	wait_event_timeout(input_dev->dev_info_wait_event,
+		input_dev->device_wait_condition, msecs_to_jiffies(1000));
+	if (input_dev->device_wait_condition == 0) {
 		ret = -ETIMEDOUT;
 		goto Cleanup;
 	}
@@ -654,7 +655,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	 * We should have gotten the device attr, hid desc and report
 	 * desc at this point
 	 */
-	if (!inputDevice->dev_info_status)
+	if (!input_dev->dev_info_status)
 		pr_info("**** input channel up and running!! ****");
 	else
 		ret = -1;
@@ -669,18 +670,18 @@ static int mousevsc_on_device_add(struct hv_device *device,
 					void *additional_info)
 {
 	int ret = 0;
-	struct mousevsc_dev *inputDevice;
-	struct mousevsc_drv_obj *inputDriver;
+	struct mousevsc_dev *input_dev;
+	struct mousevsc_drv_obj *input_drv;
 	struct hv_input_dev_info dev_info;
 
-	inputDevice = alloc_input_device(device);
+	input_dev = alloc_input_device(device);
 
-	if (!inputDevice) {
+	if (!input_dev) {
 		ret = -1;
 		goto Cleanup;
 	}
 
-	inputDevice->init_complete = false;
+	input_dev->init_complete = false;
 
 	/* Open the channel */
 	ret = vmbus_open(device->channel,
@@ -694,7 +695,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	if (ret != 0) {
 		pr_err("unable to open channel: %d", ret);
-		free_input_device(inputDevice);
+		free_input_device(input_dev);
 		return -1;
 	}
 
@@ -706,15 +707,15 @@ static int mousevsc_on_device_add(struct hv_device *device,
 		pr_err("unable to connect channel: %d", ret);
 
 		vmbus_close(device->channel);
-		free_input_device(inputDevice);
+		free_input_device(input_dev);
 		return ret;
 	}
 
-	inputDriver = (struct mousevsc_drv_obj *)inputDevice->device->drv;
+	input_drv = (struct mousevsc_drv_obj *)input_dev->device->drv;
 
-	dev_info.vendor = inputDevice->hid_dev_info.vendor;
-	dev_info.product = inputDevice->hid_dev_info.product;
-	dev_info.version = inputDevice->hid_dev_info.version;
+	dev_info.vendor = input_dev->hid_dev_info.vendor;
+	dev_info.product = input_dev->hid_dev_info.product;
+	dev_info.version = input_dev->hid_dev_info.version;
 	strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse");
 
 	/* Send the device info back up */
@@ -722,13 +723,13 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	/* Send the report desc back up */
 	/* workaround SA-167 */
-	if (inputDevice->report_desc[14] == 0x25)
-		inputDevice->report_desc[14] = 0x29;
+	if (input_dev->report_desc[14] == 0x25)
+		input_dev->report_desc[14] = 0x29;
 
-	reportdesc_callback(device, inputDevice->report_desc,
-			    inputDevice->report_desc_size);
+	reportdesc_callback(device, input_dev->report_desc,
+			    input_dev->report_desc_size);
 
-	inputDevice->init_complete = true;
+	input_dev->init_complete = true;
 
 Cleanup:
 	return ret;
@@ -736,13 +737,13 @@ Cleanup:
 
 static int mousevsc_on_device_remove(struct hv_device *device)
 {
-	struct mousevsc_dev *inputDevice;
+	struct mousevsc_dev *input_dev;
 	int ret = 0;
 
 	pr_info("disabling input device (%p)...",
 		    device->ext);
 
-	inputDevice = release_input_device(device);
+	input_dev = release_input_device(device);
 
 
 	/*
@@ -751,23 +752,23 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 	 *
 	 * so that outstanding requests can be completed.
 	 */
-	while (inputDevice->num_outstanding_req) {
+	while (input_dev->num_outstanding_req) {
 		pr_info("waiting for %d requests to complete...",
-			inputDevice->num_outstanding_req);
+			input_dev->num_outstanding_req);
 
 		udelay(100);
 	}
 
 	pr_info("removing input device (%p)...", device->ext);
 
-	inputDevice = final_release_input_device(device);
+	input_dev = final_release_input_device(device);
 
-	pr_info("input device (%p) safe to remove", inputDevice);
+	pr_info("input device (%p) safe to remove", input_dev);
 
 	/* Close the channel */
 	vmbus_close(device->channel);
 
-	free_input_device(inputDevice);
+	free_input_device(input_dev);
 
 	return ret;
 }
@@ -986,7 +987,7 @@ static void mousevsc_drv_exit(void)
 
 static int mouse_vsc_initialize(struct hv_driver *driver)
 {
-	struct mousevsc_drv_obj *inputDriver =
+	struct mousevsc_drv_obj *input_drv =
 		(struct mousevsc_drv_obj *)driver;
 	int ret = 0;
 
@@ -995,9 +996,9 @@ static int mouse_vsc_initialize(struct hv_driver *driver)
 	       sizeof(struct hv_guid));
 
 	/* Setup the dispatch table */
-	inputDriver->base.dev_add = mousevsc_on_device_add;
-	inputDriver->base.dev_rm = mousevsc_on_device_remove;
-	inputDriver->base.cleanup = mousevsc_on_cleanup;
+	input_drv->base.dev_add = mousevsc_on_device_add;
+	input_drv->base.dev_rm = mousevsc_on_device_remove;
+	input_drv->base.cleanup = mousevsc_on_cleanup;
 
 	return ret;
 }
-- 
1.7.1

^ permalink raw reply related

* Re: [PATCH] virtio_net: convert to hw_features
From: David Miller @ 2011-04-02  3:54 UTC (permalink / raw)
  To: mirq-linux; +Cc: netdev, virtualization, mst
In-Reply-To: <20110331110135.6988113A64@rere.qmqm.pl>

From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Thu, 31 Mar 2011 13:01:35 +0200 (CEST)

> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Applied.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH RESEND] net: convert xen-netfront to hw_features
From: David Miller @ 2011-04-02  3:54 UTC (permalink / raw)
  To: mirq-linux
  Cc: xen-devel, Ian.Campbell, konrad.wilk, netdev, virtualization,
	jeremy.fitzhardinge
In-Reply-To: <20110331110136.03A1A13A6A@rere.qmqm.pl>

From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Thu, 31 Mar 2011 13:01:35 +0200 (CEST)

> Not tested in any way. The original code for offload setting seems broken
> as it resets the features on every netback reconnect.
> 
> This will set GSO_ROBUST at device creation time (earlier than connect time).
> 
> RX checksum offload is forced on - so advertise as it is.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Applied.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* [PATCH] xen: netfront: fix declaration order
From: Eric Dumazet @ 2011-04-03 11:07 UTC (permalink / raw)
  To: David Miller
  Cc: xen-devel, Ian.Campbell, konrad.wilk, netdev, mirq-linux,
	jeremy.fitzhardinge, virtualization
In-Reply-To: <20110401.205455.70198735.davem@davemloft.net>

Le vendredi 01 avril 2011 à 20:54 -0700, David Miller a écrit :
> From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Date: Thu, 31 Mar 2011 13:01:35 +0200 (CEST)
> 
> > Not tested in any way. The original code for offload setting seems broken
> > as it resets the features on every netback reconnect.
> > 
> > This will set GSO_ROBUST at device creation time (earlier than connect time).
> > 
> > RX checksum offload is forced on - so advertise as it is.
> > 
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> 
> Applied.

Hmm... I had to apply following patch to make it actually compile.

Thanks

[PATCH] xen: netfront: fix declaration order

Must declare xennet_fix_features() and xennet_set_features() before
using them.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/xen-netfront.c |   72 +++++++++++++++++------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f6e7e27..0cfe4cc 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1140,6 +1140,42 @@ static void xennet_uninit(struct net_device *dev)
 	gnttab_free_grant_references(np->gref_rx_head);
 }
 
+static u32 xennet_fix_features(struct net_device *dev, u32 features)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	int val;
+
+	if (features & NETIF_F_SG) {
+		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
+				 "%d", &val) < 0)
+			val = 0;
+
+		if (!val)
+			features &= ~NETIF_F_SG;
+	}
+
+	if (features & NETIF_F_TSO) {
+		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
+				 "feature-gso-tcpv4", "%d", &val) < 0)
+			val = 0;
+
+		if (!val)
+			features &= ~NETIF_F_TSO;
+	}
+
+	return features;
+}
+
+static int xennet_set_features(struct net_device *dev, u32 features)
+{
+	if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {
+		netdev_info(dev, "Reducing MTU because no SG offload");
+		dev->mtu = ETH_DATA_LEN;
+	}
+
+	return 0;
+}
+
 static const struct net_device_ops xennet_netdev_ops = {
 	.ndo_open            = xennet_open,
 	.ndo_uninit          = xennet_uninit,
@@ -1513,42 +1549,6 @@ again:
 	return err;
 }
 
-static u32 xennet_fix_features(struct net_device *dev, u32 features)
-{
-	struct netfront_info *np = netdev_priv(dev);
-	int val;
-
-	if (features & NETIF_F_SG) {
-		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
-				 "%d", &val) < 0)
-			val = 0;
-
-		if (!val)
-			features &= ~NETIF_F_SG;
-	}
-
-	if (features & NETIF_F_TSO) {
-		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
-				 "feature-gso-tcpv4", "%d", &val) < 0)
-			val = 0;
-
-		if (!val)
-			features &= ~NETIF_F_TSO;
-	}
-
-	return features;
-}
-
-static int xennet_set_features(struct net_device *dev, u32 features)
-{
-	if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {
-		netdev_info(dev, "Reducing MTU because no SG offload");
-		dev->mtu = ETH_DATA_LEN;
-	}
-
-	return 0;
-}
-
 static int xennet_connect(struct net_device *dev)
 {
 	struct netfront_info *np = netdev_priv(dev);


_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization

^ 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