Linux virtualization list
 help / color / mirror / Atom feed
* [PATCH 68/77] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive()
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index dbb5201..8e1ef00 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -358,14 +358,14 @@ int rndis_filter_receive(struct hv_device *dev,
 	if (!net_dev->extension) {
 		dev_err(&dev->device, "got rndis message but no rndis device - "
 			  "dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_dev = (struct rndis_device *)net_dev->extension;
 	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
 		dev_err(&dev->device, "got rndis message but rndis device "
 			   "uninitialized...dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_hdr = (struct rndis_message *)kmap_atomic(
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 69/77] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device()
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

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

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 8e1ef00..f26886d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -437,7 +437,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 	request = get_rndis_request(dev, REMOTE_NDIS_QUERY_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 70/77] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter()
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes and cleanup some error paths.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f26886d..f5f3052 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -511,7 +511,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
 			sizeof(u32));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -531,7 +531,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
 	if (t == 0) {
-		ret = -1;
 		dev_err(&dev->net_dev->dev->device,
 			"timeout before we got a set response...\n");
 		/*
@@ -540,8 +539,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 */
 		goto Exit;
 	} else {
-		if (ret > 0)
-			ret = 0;
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
 	}
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 71/77] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device()
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f5f3052..a71f29d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -562,7 +562,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -596,7 +596,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = 0;
 	} else {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		ret = -1;
+		ret = -EINVAL;
 	}
 
 Cleanup:
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 72/77] Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add()
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

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

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index a71f29d..f0d1362 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -673,7 +673,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndisDevice = get_rndis_device();
 	if (!rndisDevice)
-		return -1;
+		return -ENODEV;
 
 	/*
 	 * Let the inner driver handle this first to create the netvsc channel
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 73/77] Staging: hv: mouse: Change the jump label Cleanup to cleanup
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Change the jump label Cleanup to cleanup.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 0338030..b04ba2c 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -339,7 +339,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	if (!input_device->hid_desc) {
 		pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->hid_desc, desc, desc->bLength);
@@ -352,7 +352,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (!input_device->report_desc) {
 		pr_err("unable to allocate report descriptor - size %d",
 			   input_device->report_desc_size);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->report_desc,
@@ -379,7 +379,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (ret != 0) {
 		pr_err("unable to send synthhid device info ack - ret %d",
 			   ret);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_device->device_wait_condition = 1;
@@ -387,7 +387,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	return;
 
-Cleanup:
+cleanup:
 	kfree(input_device->hid_desc);
 	input_device->hid_desc = NULL;
 
@@ -606,7 +606,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 					VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
 		pr_err("unable to send synthhid protocol request.");
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->protocol_wait_condition = 0;
@@ -614,7 +614,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->protocol_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	response = &input_dev->protocol_resp;
@@ -623,7 +623,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		pr_err("synthhid protocol request failed (version %d)",
 		       SYNTHHID_INPUT_VERSION);
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->device_wait_condition = 0;
@@ -631,7 +631,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->device_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->device_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/*
@@ -643,7 +643,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	else
 		ret = -1;
 
-Cleanup:
+cleanup:
 	put_input_device(device);
 
 	return ret;
@@ -661,7 +661,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	if (!input_dev) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->init_complete = false;
@@ -714,7 +714,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	input_dev->init_complete = true;
 
-Cleanup:
+cleanup:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 74/77] Staging: hv: mouse: Get rid of  the unused  PCI signature
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Get rid of  the unused  PCI signature.

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

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index b04ba2c..1b30f26 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -22,8 +22,6 @@
 #include <linux/input.h>
 #include <linux/hid.h>
 #include <linux/hiddev.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
 #include <linux/delay.h>
 
 #include "hyperv.h"
@@ -949,20 +947,6 @@ static void __exit mousevsc_exit(void)
  * broken.  It's safe if you want to load it yourself manually, but
  * don't inflict it on unsuspecting users, that's just mean.
  */
-#if 0
-
-/*
- * We use a PCI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-const static struct pci_device_id microsoft_hv_pci_table[] = {
-	{ PCI_DEVICE(0x1414, 0x5353) },	/* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
-#endif
 
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 75/77] Staging: hv: mouse: Disable auto-loading of the mouse driver
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Disable auto-loading of the mouse driver.

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

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 1b30f26..ab5f1da 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -950,7 +950,7 @@ static void __exit mousevsc_exit(void)
 
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
-MODULE_ALIAS("vmbus:hv_mouse");
+/*MODULE_ALIAS("vmbus:hv_mouse");*/
 module_init(mousevsc_init);
 module_exit(mousevsc_exit);
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 76/77] Staging: hv: netvsc: Change the jump label Cleanup to cleanup
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Change the jump label Cleanup to cleanup.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f0d1362..79dfe78 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -438,7 +438,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis query */
@@ -450,12 +450,12 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Copy the response back */
@@ -463,7 +463,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	if (query_complete->info_buflen > inresult_size) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(result,
@@ -473,7 +473,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	*result_size = query_complete->info_buflen;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -512,7 +512,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			sizeof(u32));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -526,7 +526,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
@@ -543,7 +543,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		status = set_complete->status;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 Exit:
@@ -563,7 +563,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -578,7 +578,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0) {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 
@@ -586,7 +586,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	init_complete = &request->response_msg.msg.init_complete;
@@ -599,7 +599,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = -EINVAL;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -615,7 +615,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_HALT_MSG,
 				RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
 	if (!request)
-		goto Cleanup;
+		goto cleanup;
 
 	/* Setup the rndis set */
 	halt = &request->request_msg.msg.halt_req;
@@ -626,7 +626,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 
 	dev->state = RNDIS_DEV_UNINITIALIZED;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 	return;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 77/77] Staging: hv: netvsc: Change the jump lable Exit to exit
From: K. Y. Srinivasan @ 2011-06-16 20:17 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
In-Reply-To: <1308255470-3826-1-git-send-email-kys@microsoft.com>

Change the jump lable Exit to exit.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 79dfe78..6db48b9 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -537,7 +537,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 * We can't deallocate the request since we may still receive a
 		 * send completion for it.
 		 */
-		goto Exit;
+		goto exit;
 	} else {
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
@@ -546,7 +546,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 cleanup:
 	if (request)
 		put_rndis_request(dev, request);
-Exit:
+exit:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related

* Re: [PATCH 09/11] xen/xenbus: use printk_ratelimited() instead of printk_ratelimit()
From: Jeremy Fitzhardinge @ 2011-06-16 21:00 UTC (permalink / raw)
  To: Manuel Zerpies
  Cc: Jeremy Fitzhardinge, Konrad Rzeszutek Wilk, linux-kernel,
	virtualization, christian.dietrich, xen-devel
In-Reply-To: <d2bc569719b3b1d8271d1f4b2c4080bbc7527e04.1308142053.git.manuel.f.zerpies@ww.stud.uni-erlangen.de>

On 06/16/2011 05:14 AM, Manuel Zerpies wrote:
> Since printk_ratelimit() shouldn't be used anymore (see comment in
> include/linux/printk.h), replace it with printk_ratelimited()
>
Looks OK to me, but please fix the indentation of the rest of the
statement to match.

Thanks,
    J

> Signed-off-by: Manuel Zerpies <manuel.f.zerpies@ww.stud.uni-erlangen.de>
> ---
>  drivers/xen/xenbus/xenbus_xs.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
> index 5534690..4055858 100644
> --- a/drivers/xen/xenbus/xenbus_xs.c
> +++ b/drivers/xen/xenbus/xenbus_xs.c
> @@ -44,6 +44,7 @@
>  #include <linux/rwsem.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
> +#include <linux/ratelimit.h>
>  #include <xen/xenbus.h>
>  #include "xenbus_comms.h"
>  
> @@ -270,8 +271,7 @@ static void *xs_talkv(struct xenbus_transaction t,
>  	}
>  
>  	if (msg.type != type) {
> -		if (printk_ratelimit())
> -			printk(KERN_WARNING
> +		`printk_ratelimited(KERN_WARNING
>  			       "XENBUS unexpected type [%d], expected [%d]\n",
>  			       msg.type, type);
>  		kfree(ret);

^ permalink raw reply

* Re: [PATCH 09/11] xen/xenbus: use printk_ratelimited() instead of printk_ratelimit()
From: Joe Perches @ 2011-06-16 23:44 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Jeremy Fitzhardinge, Konrad Rzeszutek Wilk, Manuel Zerpies,
	linux-kernel, virtualization, christian.dietrich, xen-devel
In-Reply-To: <4DFA6EF7.9060702@goop.org>

On Thu, 2011-06-16 at 14:00 -0700, Jeremy Fitzhardinge wrote:
> On 06/16/2011 05:14 AM, Manuel Zerpies wrote:
> > Since printk_ratelimit() shouldn't be used anymore (see comment in
> > include/linux/printk.h), replace it with printk_ratelimited()
> Looks OK to me, but please fix the indentation of the rest of the
> statement to match.
[]
> > diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
[]
> > @@ -270,8 +271,7 @@ static void *xs_talkv(struct xenbus_transaction t,
> >  	}
> >  
> >  	if (msg.type != type) {
> > -		if (printk_ratelimit())
> > -			printk(KERN_WARNING
> > +		`printk_ratelimited(KERN_WARNING

Appears that it's not compile tested?
A stray "`" got put before printk_ratelimited()

^ permalink raw reply

* [PATCH 1/5] staging: hv: fix some white spaces in netvsc driver
From: Haiyang Zhang @ 2011-06-17 14:58 UTC (permalink / raw)
  To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
	vir

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>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/staging/hv/netvsc.c     |    8 ++++----
 drivers/staging/hv/netvsc_drv.c |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 0ae35e7..b6e1fb9 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -525,10 +525,10 @@ int netvsc_send(struct hv_device *device,
 						  (unsigned long)packet);
 	} else {
 		ret = vmbus_sendpacket(device->channel, &sendMessage,
-				       sizeof(struct nvsp_message),
-				       (unsigned long)packet,
-				       VM_PKT_DATA_INBAND,
-				       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+				sizeof(struct nvsp_message),
+				(unsigned long)packet,
+				VM_PKT_DATA_INBAND,
+				VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 
 	}
 
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index b339acc..8380fe9 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -122,7 +122,7 @@ static void netvsc_xmit_completion(void *context)
 		atomic_add(num_pages, &net_device_ctx->avail);
 		if (atomic_read(&net_device_ctx->avail) >=
 				PACKET_PAGES_HIWATER)
- 			netif_wake_queue(net);
+			netif_wake_queue(net);
 	}
 }
 
-- 
1.6.3.2

^ permalink raw reply related

* [PATCH 2/5] staging: hv: remove unnecessary includes in netvsc
From: Haiyang Zhang @ 2011-06-17 14:58 UTC (permalink / raw)
  To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
	vir
In-Reply-To: <1308322688-9796-1-git-send-email-haiyangz@microsoft.com>

hyperv.h is included by hyperv_net.h already, so no need to include it
again in these C files.

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>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/staging/hv/netvsc.c       |    1 -
 drivers/staging/hv/netvsc_drv.c   |    1 -
 drivers/staging/hv/rndis_filter.c |    1 -
 3 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index b6e1fb9..ed9b8af 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -28,7 +28,6 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 
-#include "hyperv.h"
 #include "hyperv_net.h"
 
 
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 8380fe9..e5aba38 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -38,7 +38,6 @@
 #include <net/sock.h>
 #include <net/pkt_sched.h>
 
-#include "hyperv.h"
 #include "hyperv_net.h"
 
 static const char *driver_name = "netvsc";
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 6db48b9..8416bf2 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -27,7 +27,6 @@
 #include <linux/if_ether.h>
 #include <linux/netdevice.h>
 
-#include "hyperv.h"
 #include "hyperv_net.h"
 
 
-- 
1.6.3.2

^ permalink raw reply related

* [PATCH 3/5] staging: hv: add newline to log messages in netvsc
From: Haiyang Zhang @ 2011-06-17 14:58 UTC (permalink / raw)
  To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
	vir
In-Reply-To: <1308322688-9796-1-git-send-email-haiyangz@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>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/staging/hv/netvsc.c     |   60 +++++++++++++++++++-------------------
 drivers/staging/hv/netvsc_drv.c |    2 +-
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index ed9b8af..68ed3b4 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -158,7 +158,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		 */
 		if (ret != 0) {
 			dev_err(&net_device->dev->device, "unable to send "
-				"revoke receive buffer to netvsp");
+				"revoke receive buffer to netvsp\n");
 			return ret;
 		}
 	}
@@ -173,7 +173,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		 */
 		if (ret != 0) {
 			dev_err(&net_device->dev->device,
-				   "unable to teardown receive buffer's gpadl");
+				   "unable to teardown receive buffer's gpadl\n");
 			return -ret;
 		}
 		net_device->recv_buf_gpadl_handle = 0;
@@ -205,7 +205,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
-			   "device being destroyed?");
+			   "device being destroyed?\n");
 		return -ENODEV;
 	}
 
@@ -214,7 +214,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 				get_order(net_device->recv_buf_size));
 	if (!net_device->recv_buf) {
 		dev_err(&device->device, "unable to allocate receive "
-			"buffer of size %d", net_device->recv_buf_size);
+			"buffer of size %d\n", net_device->recv_buf_size);
 		ret = -ENOMEM;
 		goto cleanup;
 	}
@@ -229,7 +229,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 				    &net_device->recv_buf_gpadl_handle);
 	if (ret != 0) {
 		dev_err(&device->device,
-			"unable to establish receive buffer's gpadl");
+			"unable to establish receive buffer's gpadl\n");
 		goto cleanup;
 	}
 
@@ -253,7 +253,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
 		dev_err(&device->device,
-			"unable to send receive buffer's gpadl to netvsp");
+			"unable to send receive buffer's gpadl to netvsp\n");
 		goto cleanup;
 	}
 
@@ -265,7 +265,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	if (init_packet->msg.v1_msg.
 	    send_recv_buf_complete.status != NVSP_STAT_SUCCESS) {
 		dev_err(&device->device, "Unable to complete receive buffer "
-			   "initialzation with NetVsp - status %d",
+			   "initialzation with NetVsp - status %d\n",
 			   init_packet->msg.v1_msg.
 			   send_recv_buf_complete.status);
 		ret = -EINVAL;
@@ -321,7 +321,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
-			   "device being destroyed?");
+			   "device being destroyed?\n");
 		return -ENODEV;
 	}
 
@@ -407,14 +407,14 @@ 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) {
-		dev_err(&device->device, "No net device present!!");
+		dev_err(&device->device, "No net device present!!\n");
 		return -ENODEV;
 	}
 
 	/* Wait for all send completions */
 	while (atomic_read(&net_device->num_outstanding_sends)) {
 		dev_err(&device->device,
-			"waiting for %d requests to complete...",
+			"waiting for %d requests to complete...\n",
 			atomic_read(&net_device->num_outstanding_sends));
 		udelay(100);
 	}
@@ -425,7 +425,7 @@ 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 */
-	dev_notice(&device->device, "net device safe to remove");
+	dev_notice(&device->device, "net device safe to remove\n");
 
 	/* Now, we can close the channel safely */
 	vmbus_close(device->channel);
@@ -451,7 +451,7 @@ static void netvsc_send_completion(struct hv_device *device,
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
-			   "device being destroyed?");
+			   "device being destroyed?\n");
 		return;
 	}
 
@@ -480,7 +480,7 @@ static void netvsc_send_completion(struct hv_device *device,
 		atomic_dec(&net_device->num_outstanding_sends);
 	} else {
 		dev_err(&device->device, "Unknown send completion packet type- "
-			   "%d received!!", nvsp_packet->hdr.msg_type);
+			   "%d received!!\n", nvsp_packet->hdr.msg_type);
 	}
 
 	put_net_device(device);
@@ -497,7 +497,7 @@ int netvsc_send(struct hv_device *device,
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "net device (%p) shutting down..."
-			   "ignoring outbound packets", net_device);
+			   "ignoring outbound packets\n", net_device);
 		return -ENODEV;
 	}
 
@@ -532,7 +532,7 @@ int netvsc_send(struct hv_device *device,
 	}
 
 	if (ret != 0)
-		dev_err(&device->device, "Unable to send packet %p ret %d",
+		dev_err(&device->device, "Unable to send packet %p ret %d\n",
 			   packet, ret);
 
 	atomic_inc(&net_device->num_outstanding_sends);
@@ -566,19 +566,19 @@ retry_send_cmplt:
 		/* no more room...wait a bit and attempt to retry 3 times */
 		retries++;
 		dev_err(&device->device, "unable to send receive completion pkt"
-			" (tid %llx)...retrying %d", transaction_id, retries);
+			" (tid %llx)...retrying %d\n", transaction_id, retries);
 
 		if (retries < 4) {
 			udelay(100);
 			goto retry_send_cmplt;
 		} else {
 			dev_err(&device->device, "unable to send receive "
-				"completion pkt (tid %llx)...give up retrying",
+				"completion pkt (tid %llx)...give up retrying\n",
 				transaction_id);
 		}
 	} else {
 		dev_err(&device->device, "unable to send receive "
-			"completion pkt - %llx", transaction_id);
+			"completion pkt - %llx\n", transaction_id);
 	}
 }
 
@@ -600,7 +600,7 @@ static void netvsc_receive_completion(void *context)
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
-			   "device being destroyed?");
+			   "device being destroyed?\n");
 		return;
 	}
 
@@ -652,7 +652,7 @@ static void netvsc_receive(struct hv_device *device,
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
-			   "device being destroyed?");
+			   "device being destroyed?\n");
 		return;
 	}
 
@@ -661,7 +661,7 @@ static void netvsc_receive(struct hv_device *device,
 	 * packet
 	 */
 	if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) {
-		dev_err(&device->device, "Unknown packet type received - %d",
+		dev_err(&device->device, "Unknown packet type received - %d\n",
 			   packet->type);
 		put_net_device(device);
 		return;
@@ -674,7 +674,7 @@ static void netvsc_receive(struct hv_device *device,
 	if (nvsp_packet->hdr.msg_type !=
 	    NVSP_MSG1_TYPE_SEND_RNDIS_PKT) {
 		dev_err(&device->device, "Unknown nvsp packet type received-"
-			" %d", nvsp_packet->hdr.msg_type);
+			" %d\n", nvsp_packet->hdr.msg_type);
 		put_net_device(device);
 		return;
 	}
@@ -683,7 +683,7 @@ static void netvsc_receive(struct hv_device *device,
 
 	if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) {
 		dev_err(&device->device, "Invalid xfer page set id - "
-			   "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID,
+			   "expecting %x got %x\n", NETVSC_RECEIVE_BUFFER_ID,
 			   vmxferpage_packet->xfer_pageset_id);
 		put_net_device(device);
 		return;
@@ -710,7 +710,7 @@ static void netvsc_receive(struct hv_device *device,
 	 */
 	if (count < 2) {
 		dev_err(&device->device, "Got only %d netvsc pkt...needed "
-			"%d pkts. Dropping this xfer page packet completely!",
+			"%d pkts. Dropping this xfer page packet completely!\n",
 			count, vmxferpage_packet->range_cnt + 1);
 
 		/* Return it to the freelist */
@@ -738,7 +738,7 @@ static void netvsc_receive(struct hv_device *device,
 
 	if (xferpage_packet->count != vmxferpage_packet->range_cnt) {
 		dev_err(&device->device, "Needed %d netvsc pkts to satisy "
-			"this xfer page...got %d",
+			"this xfer page...got %d\n",
 			vmxferpage_packet->range_cnt, xferpage_packet->count);
 	}
 
@@ -837,7 +837,7 @@ static void netvsc_channel_cb(void *context)
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "net device (%p) shutting down..."
-			   "ignoring inbound packets", net_device);
+			   "ignoring inbound packets\n", net_device);
 		goto out;
 	}
 
@@ -888,7 +888,7 @@ static void netvsc_channel_cb(void *context)
 				/* Try again next time around */
 				dev_err(&device->device,
 					   "unable to allocate buffer of size "
-					   "(%d)!!", bytes_recvd);
+					   "(%d)!!\n", bytes_recvd);
 				break;
 			}
 
@@ -945,18 +945,18 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 			 netvsc_channel_cb, device);
 
 	if (ret != 0) {
-		dev_err(&device->device, "unable to open channel: %d", ret);
+		dev_err(&device->device, "unable to open channel: %d\n", ret);
 		goto cleanup;
 	}
 
 	/* Channel is opened */
-	pr_info("hv_netvsc channel opened successfully");
+	pr_info("hv_netvsc channel opened successfully\n");
 
 	/* Connect with the NetVsp */
 	ret = netvsc_connect_vsp(device);
 	if (ret != 0) {
 		dev_err(&device->device,
-			"unable to connect to NetVSP - %d", ret);
+			"unable to connect to NetVSP - %d\n", ret);
 		goto close;
 	}
 
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index e5aba38..c9ed19a 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -433,7 +433,7 @@ static int __init netvsc_drv_init(void)
 	struct hv_driver *drv = &netvsc_drv;
 	int ret;
 
-	pr_info("initializing....");
+	pr_info("initializing....\n");
 
 	drv->driver.name = driver_name;
 
-- 
1.6.3.2

^ permalink raw reply related

* [PATCH 4/5] staging: hv: convert dev_<loglevel> to netdev_<loglevel> in netvsc
From: Haiyang Zhang @ 2011-06-17 14:58 UTC (permalink / raw)
  To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
	vir
In-Reply-To: <1308322688-9796-1-git-send-email-haiyangz@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>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/staging/hv/netvsc.c       |   71 +++++++++++++++++++++---------------
 drivers/staging/hv/rndis_filter.c |   17 +++++----
 2 files changed, 51 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 68ed3b4..551537a 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -27,6 +27,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/netdevice.h>
 
 #include "hyperv_net.h"
 
@@ -130,6 +131,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 {
 	struct nvsp_message *revoke_packet;
 	int ret = 0;
+	struct net_device *ndev = dev_get_drvdata(&net_device->dev->device);
 
 	/*
 	 * If we got a section count, it means we received a
@@ -157,7 +159,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		 * have a leak rather than continue and a bugchk
 		 */
 		if (ret != 0) {
-			dev_err(&net_device->dev->device, "unable to send "
+			netdev_err(ndev, "unable to send "
 				"revoke receive buffer to netvsp\n");
 			return ret;
 		}
@@ -172,7 +174,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		 * rather than continue and a bugchk
 		 */
 		if (ret != 0) {
-			dev_err(&net_device->dev->device,
+			netdev_err(ndev,
 				   "unable to teardown receive buffer's gpadl\n");
 			return -ret;
 		}
@@ -201,10 +203,11 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	int t;
 	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "unable to get net device..."
+		netdev_err(ndev, "unable to get net device..."
 			   "device being destroyed?\n");
 		return -ENODEV;
 	}
@@ -213,7 +216,7 @@ 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) {
-		dev_err(&device->device, "unable to allocate receive "
+		netdev_err(ndev, "unable to allocate receive "
 			"buffer of size %d\n", net_device->recv_buf_size);
 		ret = -ENOMEM;
 		goto cleanup;
@@ -228,7 +231,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 				    net_device->recv_buf_size,
 				    &net_device->recv_buf_gpadl_handle);
 	if (ret != 0) {
-		dev_err(&device->device,
+		netdev_err(ndev,
 			"unable to establish receive buffer's gpadl\n");
 		goto cleanup;
 	}
@@ -252,7 +255,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
-		dev_err(&device->device,
+		netdev_err(ndev,
 			"unable to send receive buffer's gpadl to netvsp\n");
 		goto cleanup;
 	}
@@ -264,7 +267,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) {
-		dev_err(&device->device, "Unable to complete receive buffer "
+		netdev_err(ndev, "Unable to complete receive buffer "
 			   "initialzation with NetVsp - status %d\n",
 			   init_packet->msg.v1_msg.
 			   send_recv_buf_complete.status);
@@ -317,10 +320,11 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
 	int ndis_version;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "unable to get net device..."
+		netdev_err(ndev, "unable to get net device..."
 			   "device being destroyed?\n");
 		return -ENODEV;
 	}
@@ -403,17 +407,18 @@ int netvsc_device_remove(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
 	struct hv_netvsc_packet *netvsc_packet, *pos;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	/* Stop outbound traffic ie sends and receives completions */
 	net_device = release_outbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "No net device present!!\n");
+		netdev_err(ndev, "No net device present!!\n");
 		return -ENODEV;
 	}
 
 	/* Wait for all send completions */
 	while (atomic_read(&net_device->num_outstanding_sends)) {
-		dev_err(&device->device,
+		dev_info(&device->device,
 			"waiting for %d requests to complete...\n",
 			atomic_read(&net_device->num_outstanding_sends));
 		udelay(100);
@@ -447,10 +452,11 @@ static void netvsc_send_completion(struct hv_device *device,
 	struct netvsc_device *net_device;
 	struct nvsp_message *nvsp_packet;
 	struct hv_netvsc_packet *nvsc_packet;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "unable to get net device..."
+		netdev_err(ndev, "unable to get net device..."
 			   "device being destroyed?\n");
 		return;
 	}
@@ -479,7 +485,7 @@ static void netvsc_send_completion(struct hv_device *device,
 
 		atomic_dec(&net_device->num_outstanding_sends);
 	} else {
-		dev_err(&device->device, "Unknown send completion packet type- "
+		netdev_err(ndev, "Unknown send completion packet type- "
 			   "%d received!!\n", nvsp_packet->hdr.msg_type);
 	}
 
@@ -491,12 +497,12 @@ int netvsc_send(struct hv_device *device,
 {
 	struct netvsc_device *net_device;
 	int ret = 0;
-
 	struct nvsp_message sendMessage;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	net_device = get_outbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "net device (%p) shutting down..."
+		netdev_err(ndev, "net device (%p) shutting down..."
 			   "ignoring outbound packets\n", net_device);
 		return -ENODEV;
 	}
@@ -532,7 +538,7 @@ int netvsc_send(struct hv_device *device,
 	}
 
 	if (ret != 0)
-		dev_err(&device->device, "Unable to send packet %p ret %d\n",
+		netdev_err(ndev, "Unable to send packet %p ret %d\n",
 			   packet, ret);
 
 	atomic_inc(&net_device->num_outstanding_sends);
@@ -546,6 +552,7 @@ static void netvsc_send_recv_completion(struct hv_device *device,
 	struct nvsp_message recvcompMessage;
 	int retries = 0;
 	int ret;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	recvcompMessage.hdr.msg_type =
 				NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE;
@@ -565,19 +572,19 @@ retry_send_cmplt:
 	} else if (ret == -EAGAIN) {
 		/* no more room...wait a bit and attempt to retry 3 times */
 		retries++;
-		dev_err(&device->device, "unable to send receive completion pkt"
+		netdev_err(ndev, "unable to send receive completion pkt"
 			" (tid %llx)...retrying %d\n", transaction_id, retries);
 
 		if (retries < 4) {
 			udelay(100);
 			goto retry_send_cmplt;
 		} else {
-			dev_err(&device->device, "unable to send receive "
+			netdev_err(ndev, "unable to send receive "
 				"completion pkt (tid %llx)...give up retrying\n",
 				transaction_id);
 		}
 	} else {
-		dev_err(&device->device, "unable to send receive "
+		netdev_err(ndev, "unable to send receive "
 			"completion pkt - %llx\n", transaction_id);
 	}
 }
@@ -591,6 +598,7 @@ static void netvsc_receive_completion(void *context)
 	u64 transaction_id = 0;
 	bool fsend_receive_comp = false;
 	unsigned long flags;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	/*
 	 * Even though it seems logical to do a GetOutboundNetDevice() here to
@@ -599,7 +607,7 @@ static void netvsc_receive_completion(void *context)
 	 */
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "unable to get net device..."
+		netdev_err(ndev, "unable to get net device..."
 			   "device being destroyed?\n");
 		return;
 	}
@@ -646,12 +654,13 @@ static void netvsc_receive(struct hv_device *device,
 	int i, j;
 	int count = 0, bytes_remain = 0;
 	unsigned long flags;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	LIST_HEAD(listHead);
 
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "unable to get net device..."
+		netdev_err(ndev, "unable to get net device..."
 			   "device being destroyed?\n");
 		return;
 	}
@@ -661,7 +670,7 @@ static void netvsc_receive(struct hv_device *device,
 	 * packet
 	 */
 	if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) {
-		dev_err(&device->device, "Unknown packet type received - %d\n",
+		netdev_err(ndev, "Unknown packet type received - %d\n",
 			   packet->type);
 		put_net_device(device);
 		return;
@@ -673,7 +682,7 @@ 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) {
-		dev_err(&device->device, "Unknown nvsp packet type received-"
+		netdev_err(ndev, "Unknown nvsp packet type received-"
 			" %d\n", nvsp_packet->hdr.msg_type);
 		put_net_device(device);
 		return;
@@ -682,7 +691,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) {
-		dev_err(&device->device, "Invalid xfer page set id - "
+		netdev_err(ndev, "Invalid xfer page set id - "
 			   "expecting %x got %x\n", NETVSC_RECEIVE_BUFFER_ID,
 			   vmxferpage_packet->xfer_pageset_id);
 		put_net_device(device);
@@ -709,7 +718,7 @@ static void netvsc_receive(struct hv_device *device,
 	 * some of the xfer page packet ranges...
 	 */
 	if (count < 2) {
-		dev_err(&device->device, "Got only %d netvsc pkt...needed "
+		netdev_err(ndev, "Got only %d netvsc pkt...needed "
 			"%d pkts. Dropping this xfer page packet completely!\n",
 			count, vmxferpage_packet->range_cnt + 1);
 
@@ -737,7 +746,7 @@ static void netvsc_receive(struct hv_device *device,
 	xferpage_packet->count = count - 1;
 
 	if (xferpage_packet->count != vmxferpage_packet->range_cnt) {
-		dev_err(&device->device, "Needed %d netvsc pkts to satisy "
+		netdev_err(ndev, "Needed %d netvsc pkts to satisy "
 			"this xfer page...got %d\n",
 			vmxferpage_packet->range_cnt, xferpage_packet->count);
 	}
@@ -827,6 +836,7 @@ static void netvsc_channel_cb(void *context)
 	struct vmpacket_descriptor *desc;
 	unsigned char *buffer;
 	int bufferlen = NETVSC_PACKET_SIZE;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char),
 			 GFP_ATOMIC);
@@ -836,7 +846,7 @@ static void netvsc_channel_cb(void *context)
 
 	net_device = get_inbound_net_device(device);
 	if (!net_device) {
-		dev_err(&device->device, "net device (%p) shutting down..."
+		netdev_err(ndev, "net device (%p) shutting down..."
 			   "ignoring inbound packets\n", net_device);
 		goto out;
 	}
@@ -857,7 +867,7 @@ static void netvsc_channel_cb(void *context)
 					break;
 
 				default:
-					dev_err(&device->device,
+					netdev_err(ndev,
 						   "unhandled packet type %d, "
 						   "tid %llx len %d\n",
 						   desc->type, request_id,
@@ -886,7 +896,7 @@ static void netvsc_channel_cb(void *context)
 			buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
 			if (buffer == NULL) {
 				/* Try again next time around */
-				dev_err(&device->device,
+				netdev_err(ndev,
 					   "unable to allocate buffer of size "
 					   "(%d)!!\n", bytes_recvd);
 				break;
@@ -914,6 +924,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 	((struct netvsc_device_info *)additional_info)->ring_size;
 	struct netvsc_device *net_device;
 	struct hv_netvsc_packet *packet, *pos;
+	struct net_device *ndev = dev_get_drvdata(&device->device);
 
 	net_device = alloc_net_device(device);
 	if (!net_device) {
@@ -945,7 +956,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 			 netvsc_channel_cb, device);
 
 	if (ret != 0) {
-		dev_err(&device->device, "unable to open channel: %d\n", ret);
+		netdev_err(ndev, "unable to open channel: %d\n", ret);
 		goto cleanup;
 	}
 
@@ -955,7 +966,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 	/* Connect with the NetVsp */
 	ret = netvsc_connect_vsp(device);
 	if (ret != 0) {
-		dev_err(&device->device,
+		netdev_err(ndev,
 			"unable to connect to NetVSP - %d\n", ret);
 		goto close;
 	}
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 8416bf2..20e673d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -249,6 +249,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 	struct rndis_request *request = NULL;
 	bool found = false;
 	unsigned long flags;
+	struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device);
 
 	spin_lock_irqsave(&dev->request_lock, flags);
 	list_for_each_entry(request, &dev->req_list, list_ent) {
@@ -269,7 +270,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 			memcpy(&request->response_msg, resp,
 			       resp->msg_len);
 		} else {
-			dev_err(&dev->net_dev->dev->device,
+			netdev_err(ndev,
 				"rndis response buffer overflow "
 				"detected (size %u max %zu)\n",
 				resp->msg_len,
@@ -289,7 +290,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 
 		complete(&request->wait_event);
 	} else {
-		dev_err(&dev->net_dev->dev->device,
+		netdev_err(ndev,
 			"no rndis request found for this response "
 			"(id 0x%x res type 0x%x)\n",
 			resp->msg.init_complete.req_id,
@@ -349,20 +350,21 @@ int rndis_filter_receive(struct hv_device *dev,
 	struct rndis_device *rndis_dev;
 	struct rndis_message rndis_msg;
 	struct rndis_message *rndis_hdr;
+	struct net_device *ndev = dev_get_drvdata(&dev->device);
 
 	if (!net_dev)
 		return -EINVAL;
 
 	/* Make sure the rndis device state is initialized */
 	if (!net_dev->extension) {
-		dev_err(&dev->device, "got rndis message but no rndis device - "
+		netdev_err(ndev, "got rndis message but no rndis device - "
 			  "dropping this message!\n");
 		return -ENODEV;
 	}
 
 	rndis_dev = (struct rndis_device *)net_dev->extension;
 	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
-		dev_err(&dev->device, "got rndis message but rndis device "
+		netdev_err(ndev, "got rndis message but rndis device "
 			   "uninitialized...dropping this message!\n");
 		return -ENODEV;
 	}
@@ -376,7 +378,7 @@ int rndis_filter_receive(struct hv_device *dev,
 	/* Make sure we got a valid rndis message */
 	if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) &&
 	    (rndis_hdr->msg_len > sizeof(struct rndis_message))) {
-		dev_err(&dev->device, "incoming rndis message buffer overflow "
+		netdev_err(ndev, "incoming rndis message buffer overflow "
 			   "detected (got %u, max %zu)..marking it an error!\n",
 			   rndis_hdr->msg_len,
 			   sizeof(struct rndis_message));
@@ -409,7 +411,7 @@ int rndis_filter_receive(struct hv_device *dev,
 		rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg);
 		break;
 	default:
-		dev_err(&dev->device,
+		netdev_err(ndev,
 			"unhandled rndis message (type %u len %u)\n",
 			   rndis_msg.ndis_msg_type,
 			   rndis_msg.msg_len);
@@ -505,6 +507,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	struct rndis_set_complete *set_complete;
 	u32 status;
 	int ret, t;
+	struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device);
 
 	request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
@@ -530,7 +533,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
 	if (t == 0) {
-		dev_err(&dev->net_dev->dev->device,
+		netdev_err(ndev,
 			"timeout before we got a set response...\n");
 		/*
 		 * We can't deallocate the request since we may still receive a
-- 
1.6.3.2

^ permalink raw reply related

* [PATCH 5/5] staging: hv: fix a kernel warning in netvsc_linkstatus_callback()
From: Haiyang Zhang @ 2011-06-17 14:58 UTC (permalink / raw)
  To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
	vir; +Cc: stable
In-Reply-To: <1308322688-9796-1-git-send-email-haiyangz@microsoft.com>

netif_notify_peers() is not allowed in netvsc_linkstatus_callback() on some
distros, because netvsc_linkstatus_callback() is within IRQ context. So we
move the first call to netif_notify_peers() into queued work as well, but with
zero delay.

This should also be back-ported to stable kernels 2.6.32 and later.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: stable <stable@kernel.org>
---
 drivers/staging/hv/netvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index c9ed19a..2299b88 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -216,8 +216,8 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
 	if (status == 1) {
 		netif_carrier_on(net);
 		netif_wake_queue(net);
-		netif_notify_peers(net);
 		ndev_ctx = netdev_priv(net);
+		schedule_delayed_work(&ndev_ctx->dwork, 0);
 		schedule_delayed_work(&ndev_ctx->dwork, msecs_to_jiffies(20));
 	} else {
 		netif_carrier_off(net);
-- 
1.6.3.2

^ permalink raw reply related

* Re: [PATCH 1/5] staging: hv: fix some white spaces in netvsc driver
From: Nicolas Kaiser @ 2011-06-17 16:03 UTC (permalink / raw)
  To: Haiyang Zhang
  Cc: hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
	virtualization
In-Reply-To: <1308322688-9796-1-git-send-email-haiyangz@microsoft.com>

* Haiyang Zhang <haiyangz@microsoft.com>:
> diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
> index 0ae35e7..b6e1fb9 100644
> --- a/drivers/staging/hv/netvsc.c
> +++ b/drivers/staging/hv/netvsc.c
> @@ -525,10 +525,10 @@ int netvsc_send(struct hv_device *device,
>  						  (unsigned long)packet);
>  	} else {
>  		ret = vmbus_sendpacket(device->channel, &sendMessage,
> -				       sizeof(struct nvsp_message),
> -				       (unsigned long)packet,
> -				       VM_PKT_DATA_INBAND,
> -				       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> +				sizeof(struct nvsp_message),
> +				(unsigned long)packet,
> +				VM_PKT_DATA_INBAND,
> +				VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);

Why? The arguments were nicely aligned.

Best regards,
Nicolas Kaiser

^ permalink raw reply

* RE: [PATCH 1/5] staging: hv: fix some white spaces in netvsc driver
From: Haiyang Zhang @ 2011-06-17 16:43 UTC (permalink / raw)
  To: Nicolas Kaiser
  Cc: Abhishek Kane (Mindtree Consulting PVT LTD), gregkh@suse.de,
	linux-kernel@vger.kernel.org, virtualization@lists.osdl.org,
	devel@linuxdriverproject.org
In-Reply-To: <20110617180324.1eeb2ea0@absol.kitzblitz>

> -----Original Message-----
> From: Nicolas Kaiser [mailto:nikai@nikai.net]
> Sent: Friday, June 17, 2011 12:03 PM
> To: Haiyang Zhang
> Cc: Hank Janssen; KY Srinivasan; Abhishek Kane (Mindtree Consulting
> PVT LTD); gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org
> Subject: Re: [PATCH 1/5] staging: hv: fix some white spaces in netvsc
> driver
> 
> * Haiyang Zhang <haiyangz@microsoft.com>:
> > diff --git a/drivers/staging/hv/netvsc.c
> b/drivers/staging/hv/netvsc.c
> > index 0ae35e7..b6e1fb9 100644
> > --- a/drivers/staging/hv/netvsc.c
> > +++ b/drivers/staging/hv/netvsc.c
> > @@ -525,10 +525,10 @@ int netvsc_send(struct hv_device *device,
> >  						  (unsigned long)packet);
> >  	} else {
> >  		ret = vmbus_sendpacket(device->channel, &sendMessage,
> > -				       sizeof(struct nvsp_message),
> > -				       (unsigned long)packet,
> > -				       VM_PKT_DATA_INBAND,
> > -
> VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> > +				sizeof(struct nvsp_message),
> > +				(unsigned long)packet,
> > +				VM_PKT_DATA_INBAND,
> > +				VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
> 
> Why? The arguments were nicely aligned.

Because the last line went beyond 80 chars, and triggered checkpatch warning.

Thanks,
-Haiyang

^ permalink raw reply

* Re: [PATCH] virtio-net: per cpu 64 bit stats
From: Stephen Hemminger @ 2011-06-17 19:13 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: netdev, virtualization
In-Reply-To: <20110615183316.GB7197@redhat.com>

On Wed, 15 Jun 2011 21:33:16 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Wed, Jun 15, 2011 at 11:43:37AM -0400, Stephen Hemminger wrote:
> > Use per-cpu variables to maintain 64 bit statistics.
> > Compile tested only.
> > 
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> Interesting. Does this help speed at all?
> 
> > --- a/drivers/net/virtio_net.c	2011-06-14 15:18:46.448596355 -0400
> > +++ b/drivers/net/virtio_net.c	2011-06-15 09:54:22.914426067 -0400
> > @@ -40,6 +40,15 @@ module_param(gso, bool, 0444);
> >  
> >  #define VIRTNET_SEND_COMMAND_SG_MAX    2
> >  
> > +struct virtnet_stats {
> > +	struct u64_stats_sync syncp;
> > +	u64 tx_bytes;
> > +	u64 tx_packets;
> > +
> > +	u64 rx_bytes;
> > +	u64 rx_packets;
> > +};
> > +
> >  struct virtnet_info {
> >  	struct virtio_device *vdev;
> >  	struct virtqueue *rvq, *svq, *cvq;
> > @@ -56,6 +65,9 @@ struct virtnet_info {
> >  	/* Host will merge rx buffers for big packets (shake it! shake it!) */
> >  	bool mergeable_rx_bufs;
> >  
> > +	/* Active statistics */
> > +	struct virtnet_stats __percpu *stats;
> > +
> >  	/* Work struct for refilling if we run low on memory. */
> >  	struct delayed_work refill;
> >  
> > @@ -209,7 +221,6 @@ static int receive_mergeable(struct virt
> >  			skb->dev->stats.rx_length_errors++;
> >  			return -EINVAL;
> >  		}
> > -
> >  		page = virtqueue_get_buf(vi->rvq, &len);
> >  		if (!page) {
> >  			pr_debug("%s: rx error: %d buffers missing\n",
> > @@ -217,6 +228,7 @@ static int receive_mergeable(struct virt
> >  			skb->dev->stats.rx_length_errors++;
> >  			return -EINVAL;
> >  		}
> > +
> >  		if (len > PAGE_SIZE)
> >  			len = PAGE_SIZE;
> >
> 
> Let's not tweak whitespace unnecessarily.
>   
> > @@ -230,6 +242,7 @@ static int receive_mergeable(struct virt
> >  static void receive_buf(struct net_device *dev, void *buf, unsigned int len)
> >  {
> >  	struct virtnet_info *vi = netdev_priv(dev);
> > +	struct virtnet_stats __percpu *stats = this_cpu_ptr(vi->stats);
> >  	struct sk_buff *skb;
> >  	struct page *page;
> >  	struct skb_vnet_hdr *hdr;
> > @@ -265,8 +278,11 @@ static void receive_buf(struct net_devic
> >  
> >  	hdr = skb_vnet_hdr(skb);
> >  	skb->truesize += skb->data_len;
> > -	dev->stats.rx_bytes += skb->len;
> > -	dev->stats.rx_packets++;
> > +
> > +	u64_stats_update_begin(&stats->syncp);
> > +	stats->rx_bytes += skb->len;
> > +	stats->rx_packets++;
> > +	u64_stats_update_begin(&stats->syncp);
> >  
> >  	if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> >  		pr_debug("Needs csum!\n");
> > @@ -515,11 +531,16 @@ static unsigned int free_old_xmit_skbs(s
> >  {
> >  	struct sk_buff *skb;
> >  	unsigned int len, tot_sgs = 0;
> > +	struct virtnet_stats __percpu *stats = this_cpu_ptr(vi->stats);
> >  
> >  	while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) {
> >  		pr_debug("Sent skb %p\n", skb);
> > -		vi->dev->stats.tx_bytes += skb->len;
> > -		vi->dev->stats.tx_packets++;
> > +
> > +		u64_stats_update_begin(&stats->syncp);
> > +		stats->tx_bytes += skb->len;
> > +		stats->tx_packets++;
> > +		u64_stats_update_begin(&stats->syncp);
> > +
> >  		tot_sgs += skb_vnet_hdr(skb)->num_sg;
> >  		dev_kfree_skb_any(skb);
> >  	}
> > @@ -641,6 +662,40 @@ static int virtnet_set_mac_address(struc
> >  	return 0;
> >  }
> >  
> > +static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev,
> > +					       struct rtnl_link_stats64 *tot)
> > +{
> > +	struct virtnet_info *vi = netdev_priv(dev);
> > +	int cpu;
> > +	unsigned int start;
> > +
> > +	for_each_possible_cpu(cpu) {
> > +		struct virtnet_stats __percpu *stats
> > +			= per_cpu_ptr(vi->stats, cpu);
> > +		u64 tpackets, tbytes, rpackets, rbytes;
> > +
> > +		do {
> > +			start = u64_stats_fetch_begin(&stats->syncp);
> > +			tpackets = stats->tx_packets;
> > +			tbytes   = stats->tx_bytes;
> > +			rpackets = stats->rx_packets;
> > +			rbytes   = stats->rx_bytes;
> > +		} while (u64_stats_fetch_retry(&stats->syncp, start));
> > +
> > +		tot->rx_packets += rpackets;
> > +		tot->tx_packets += tpackets;
> > +		tot->rx_bytes   += rbytes;
> > +		tot->tx_bytes   += tbytes;
> > +	}
> > +
> > +	tot->tx_dropped = dev->stats.tx_dropped;
> > +	tot->rx_dropped = dev->stats.rx_dropped;
> > +	tot->rx_length_errors = dev->stats.rx_length_errors;
> > +	tot->rx_frame_errors = dev->stats.rx_frame_errors;
> > +
> > +	return tot;
> > +}
> > +
> >  #ifdef CONFIG_NET_POLL_CONTROLLER
> >  static void virtnet_netpoll(struct net_device *dev)
> >  {
> > @@ -650,6 +705,14 @@ static void virtnet_netpoll(struct net_d
> >  }
> >  #endif
> >  
> > +static void virtnet_free(struct net_device *dev)
> > +{
> > +	struct virtnet_info *vi = netdev_priv(dev);
> > +
> > +	free_percpu(vi->stats);
> > +	free_netdev(dev);
> > +}
> > +
> >  static int virtnet_open(struct net_device *dev)
> >  {
> >  	struct virtnet_info *vi = netdev_priv(dev);
> > @@ -835,6 +898,7 @@ static const struct net_device_ops virtn
> >  	.ndo_set_mac_address = virtnet_set_mac_address,
> >  	.ndo_set_rx_mode     = virtnet_set_rx_mode,
> >  	.ndo_change_mtu	     = virtnet_change_mtu,
> > +	.ndo_get_stats64     = virtnet_stats,
> >  	.ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid,
> >  	.ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
> >  #ifdef CONFIG_NET_POLL_CONTROLLER
> > @@ -895,6 +959,8 @@ static int virtnet_probe(struct virtio_d
> >  	/* Set up network device as normal. */
> >  	dev->netdev_ops = &virtnet_netdev;
> >  	dev->features = NETIF_F_HIGHDMA;
> > +	dev->destructor = virtnet_free;
> > +
> >  	SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops);
> >  	SET_NETDEV_DEV(dev, &vdev->dev);
> >  
> > @@ -939,6 +1005,11 @@ static int virtnet_probe(struct virtio_d
> >  	vi->vdev = vdev;
> >  	vdev->priv = vi;
> >  	vi->pages = NULL;
> > +	vi->stats = alloc_percpu(struct virtnet_stats);
> > +	err = -ENOMEM;
> > +	if (vi->stats == NULL)
> > +		goto free;
> > +
> >  	INIT_DELAYED_WORK(&vi->refill, refill_work);
> >  	sg_init_table(vi->rx_sg, ARRAY_SIZE(vi->rx_sg));
> >  	sg_init_table(vi->tx_sg, ARRAY_SIZE(vi->tx_sg));
> > @@ -958,7 +1029,7 @@ static int virtnet_probe(struct virtio_d
> >  
> >  	err = vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names);
> >  	if (err)
> > -		goto free;
> > +		goto free_stats;
> >  
> >  	vi->rvq = vqs[0];
> >  	vi->svq = vqs[1];
> > @@ -1003,6 +1074,8 @@ unregister:
> >  	cancel_delayed_work_sync(&vi->refill);
> >  free_vqs:
> >  	vdev->config->del_vqs(vdev);
> > +free_stats:
> > +	free_percpu(vi->stats);
> >  free:
> >  	free_netdev(dev);
> >  	return err;

Haven't done any performance tests on this.

^ permalink raw reply

* Re: [PATCH] virtio-net: per cpu 64 bit stats (v2)
From: David Miller @ 2011-06-17 19:18 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, virtualization, eric.dumazet, mst
In-Reply-To: <20110615123629.6efae8aa@s6510.ftrdhcpuser.net>

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Wed, 15 Jun 2011 12:36:29 -0400

> Use per-cpu variables to maintain 64 bit statistics.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

I'll apply this, thanks.

^ permalink raw reply

* Re: [RFC] virtio: Support releasing lock during kick
From: Michael S. Tsirkin @ 2011-06-19  7:14 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: kvm, virtualization
In-Reply-To: <1277328242-10685-1-git-send-email-stefanha@linux.vnet.ibm.com>

On Wed, Jun 23, 2010 at 10:24:02PM +0100, Stefan Hajnoczi wrote:
> The virtio block device holds a lock during I/O request processing.
> Kicking the virtqueue while the lock is held results in long lock hold
> times and increases contention for the lock.
> 
> This patch modifies virtqueue_kick() to optionally release a lock while
> notifying the host.  Virtio block is modified to pass in its lock.  This
> allows other vcpus to queue I/O requests during the time spent servicing
> the virtqueue notify in the host.
> 
> The virtqueue_kick() function is modified to know about locking because
> it changes the state of the virtqueue and should execute with the lock
> held (it would not be correct for virtio block to release the lock
> before calling virtqueue_kick()).
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

While the optimization makes sense, the API's pretty hairy IMHO.
Why don't we split the kick functionality instead?
E.g.
	/* Report whether host notification is necessary. */
	bool virtqueue_kick_prepare(struct virtqueue *vq)
	/* Can be done in parallel with add_buf/get_buf */
	void virtqueue_kick_notify(struct virtqueue *vq)

And users can
	
	r = virtqueue_kick_prepare(vq);
	spin_unlock_irqrestore(...);
	if (r)
		virtqueue_kick_notify(struct virtqueue *vq)

-- 
MST

^ permalink raw reply

* Re: [RFC] virtio: Support releasing lock during kick
From: Michael S. Tsirkin @ 2011-06-19  7:48 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: axboe, hch, linux-kernel, kvm, virtualization
In-Reply-To: <1277328242-10685-1-git-send-email-stefanha@linux.vnet.ibm.com>

On Wed, Jun 23, 2010 at 10:24:02PM +0100, Stefan Hajnoczi wrote:
> The virtio block device holds a lock during I/O request processing.
> Kicking the virtqueue while the lock is held results in long lock hold
> times and increases contention for the lock.

As you point out the problem with dropping
and getting this lock in the request function is
that we double the number of atomics here.

How about we teach the block core to call a separate
function with spinlock not held? This way we don't need
to do extra lock/unlock operations, and kick can be
done with lock not held and interrupts enabled.


diff --git a/block/blk-core.c b/block/blk-core.c
index 4ce953f..a8672ec 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -433,6 +433,8 @@ void blk_run_queue(struct request_queue *q)
 	spin_lock_irqsave(q->queue_lock, flags);
 	__blk_run_queue(q);
 	spin_unlock_irqrestore(q->queue_lock, flags);
+	if (q->request_done)
+		q->request_done(q);
 }
 EXPORT_SYMBOL(blk_run_queue);
 

-- 
MST

^ permalink raw reply related

* Re: [PATCHv2 RFC 0/4] virtio and vhost-net capacity handling
From: Michael S. Tsirkin @ 2011-06-19  8:53 UTC (permalink / raw)
  To: Krishna Kumar2
  Cc: habanero, lguest, Shirley Ma, kvm, Carsten Otte, linux-s390,
	Heiko Carstens, linux-kernel, virtualization, steved,
	Christian Borntraeger, Tom Lendacky, netdev, Martin Schwidefsky,
	linux390
In-Reply-To: <OFE36F9C2B.43D9DB04-ON652578AE.0048E1AB-652578AE.004A1462@in.ibm.com>

On Mon, Jun 13, 2011 at 07:02:27PM +0530, Krishna Kumar2 wrote:
> "Michael S. Tsirkin" <mst@redhat.com> wrote on 06/07/2011 09:38:30 PM:
> 
> > > This is on top of the patches applied by Rusty.
> > >
> > > Warning: untested. Posting now to give people chance to
> > > comment on the API.
> >
> > OK, this seems to have survived some testing so far,
> > after I dropped patch 4 and fixed build for patch 3
> > (build fixup patch sent in reply to the original).
> >
> > I'll be mostly offline until Sunday, would appreciate
> > testing reports.
> 
> Hi Michael,
> 
> I ran the latest patches with 1K I/O (guest->local host) and
> the results are (60 sec run for each test case):
> 
> ______________________________
> #sessions   BW%       SD%
> ______________________________
> 1           -25.6     47.0
> 2           -29.3     22.9
> 4              .8     1.6
> 8             1.6     0
> 16          -1.6      4.1
> 32          -5.3      2.1
> 48           11.3    -7.8
> 64          -2.8      .7
> 96          -6.2      .6
> 128         -10.6     12.7
> ______________________________
> BW: -4.8     SD: 5.4
> 
> I tested it again to see if the regression is fleeting (since
> the numbers vary quite a bit for 1K I/O even between guest->
> local host), but:
> 
> ______________________________
> #sessions  BW%     SD%
> ______________________________
> 1          14.0    -17.3
> 2          19.9    -11.1
> 4          7.9     -15.3
> 8          9.6     -13.1
> 16         1.2     -7.3
> 32        -.6      -13.5
> 48        -28.7     10.0
> 64        -5.7     -.7
> 96        -9.4     -8.1
> 128       -9.4      .7
> ______________________________
> BW: -3.7     SD: -2.0
> 
> 
> With 16K, there was an improvement in SD, but
> higher sessions seem to slightly degrade BW/SD:
> 
> ______________________________
> #sessions  BW%      SD%
> ______________________________
> 1          30.9    -25.0
> 2          16.5    -19.4
> 4         -1.3      7.9
> 8          1.4      6.2
> 16         3.9     -5.4
> 32         0        4.3
> 48        -.5        .1
> 64         32.1    -1.5
> 96        -2.1      23.2
> 128       -7.4      3.8
> ______________________________
> BW: 5.0          SD: 7.5
> 
> 
> Thanks,
> 
> - KK

I think I see one scenario where we do extra work:
when TX ring overflows, the first attempt to
add buf will fail, so the work to format the s/g
list is then wasted. So it might make sense to
free up buffers up to capacity first thing after all,
which will still do nothing typically, add buf afterwards.

-- 
MST

^ permalink raw reply

* RFT: virtio_net: limit xmit polling
From: Michael S. Tsirkin @ 2011-06-19 10:27 UTC (permalink / raw)
  To: Krishna Kumar2
  Cc: habanero, lguest, Shirley Ma, kvm, Carsten Otte, linux-s390,
	Heiko Carstens, linux-kernel, virtualization, steved,
	Christian Borntraeger, Tom Lendacky, netdev, Martin Schwidefsky,
	linux390

OK, different people seem to test different trees.  In the hope to get
everyone on the same page, I created several variants of this patch so
they can be compared. Whoever's interested, please check out the
following, and tell me how these compare:

kernel:

git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

virtio-net-limit-xmit-polling/base - this is net-next baseline to test against
virtio-net-limit-xmit-polling/v0 - fixes checks on out of capacity
virtio-net-limit-xmit-polling/v1 - previous revision of the patch
		this does xmit,free,xmit,2*free,free
virtio-net-limit-xmit-polling/v2 - new revision of the patch
		this does free,xmit,2*free,free

There's also this on top:
virtio-net-limit-xmit-polling/v3 -> don't delay avail index update
I don't think it's important to test this one, yet

Userspace to use: event index work is not yet merged upstream
so the revision to use is still this:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu-kvm.git
virtio-net-event-idx-v3

-- 
MST

^ permalink raw reply


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