netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary
@ 2012-02-02 17:17 Haiyang Zhang
  2012-02-02 17:18 ` [PATCH 2/2] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary Haiyang Zhang
  2012-02-02 19:44 ` [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Haiyang Zhang @ 2012-02-02 17:17 UTC (permalink / raw)
  To: haiyangz, kys, davem, netdev, linux-kernel

For code path not on the xmit, use netif_tx_disable() instead of
netif_stop_queue() to ensure other CPUs are not doing xmit.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9dccc7a..69193fc 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -123,7 +123,7 @@ static int netvsc_close(struct net_device *net)
 	struct hv_device *device_obj = net_device_ctx->device_ctx;
 	int ret;
 
-	netif_stop_queue(net);
+	netif_tx_disable(net);
 
 	ret = rndis_filter_close(device_obj);
 	if (ret != 0)
@@ -256,7 +256,7 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
 		schedule_delayed_work(&ndev_ctx->dwork, msecs_to_jiffies(20));
 	} else {
 		netif_carrier_off(net);
-		netif_stop_queue(net);
+		netif_tx_disable(net);
 	}
 }
 
@@ -337,7 +337,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 
 	nvdev->start_remove = true;
 	cancel_delayed_work_sync(&ndevctx->dwork);
-	netif_stop_queue(ndev);
+	netif_tx_disable(ndev);
 	rndis_filter_device_remove(hdev);
 
 	ndev->mtu = mtu;
@@ -460,7 +460,7 @@ static int netvsc_remove(struct hv_device *dev)
 	cancel_delayed_work_sync(&ndev_ctx->dwork);
 
 	/* Stop outbound asap */
-	netif_stop_queue(net);
+	netif_tx_disable(net);
 
 	unregister_netdev(net);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary
  2012-02-02 17:17 [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary Haiyang Zhang
@ 2012-02-02 17:18 ` Haiyang Zhang
  2012-02-02 19:50   ` David Miller
  2012-02-02 19:44 ` [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Haiyang Zhang @ 2012-02-02 17:18 UTC (permalink / raw)
  To: haiyangz, kys, davem, netdev, linux-kernel

There is a possible data corruption if an RNDIS message goes beyond page
boundary in the sending code path. This patch fixes the problem.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c   |    8 ++++----
 drivers/net/hyperv/rndis_filter.c |   13 +++++++++++++
 include/linux/hyperv.h            |    2 +-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 69193fc..466c58a 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -151,10 +151,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 	int ret;
 	unsigned int i, num_pages, npg_data;
 
-	/* Add multipage for skb->data and additional one for RNDIS */
+	/* Add multipages for skb->data and additional 2 for RNDIS */
 	npg_data = (((unsigned long)skb->data + skb_headlen(skb) - 1)
 		>> PAGE_SHIFT) - ((unsigned long)skb->data >> PAGE_SHIFT) + 1;
-	num_pages = skb_shinfo(skb)->nr_frags + npg_data + 1;
+	num_pages = skb_shinfo(skb)->nr_frags + npg_data + 2;
 
 	/* Allocate a netvsc packet based on # of frags. */
 	packet = kzalloc(sizeof(struct hv_netvsc_packet) +
@@ -173,8 +173,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 				sizeof(struct hv_netvsc_packet) +
 				    (num_pages * sizeof(struct hv_page_buffer));
 
-	/* Setup the rndis header */
-	packet->page_buf_cnt = num_pages;
+	/* If the rndis msg goes beyond 1 page, we will add 1 later */
+	packet->page_buf_cnt = num_pages - 1;
 
 	/* Initialize it from the skb */
 	packet->total_data_buflen = skb->len;
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index dc2e384..133b7fb 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -797,6 +797,19 @@ int rndis_filter_send(struct hv_device *dev,
 			(unsigned long)rndisMessage & (PAGE_SIZE-1);
 	pkt->page_buf[0].len = rndisMessageSize;
 
+	/* Add one page_buf if the rndis msg goes beyond page boundary */
+	if (pkt->page_buf[0].offset + rndisMessageSize > PAGE_SIZE) {
+		int i;
+		for (i = pkt->page_buf_cnt; i > 1; i--)
+			pkt->page_buf[i] = pkt->page_buf[i-1];
+		pkt->page_buf_cnt++;
+		pkt->page_buf[0].len = PAGE_SIZE - pkt->page_buf[0].offset;
+		pkt->page_buf[1].pfn = virt_to_phys((void *)((ulong)
+			rndisMessage + pkt->page_buf[0].len)) >> PAGE_SHIFT;
+		pkt->page_buf[1].offset = 0;
+		pkt->page_buf[1].len = rndisMessageSize - pkt->page_buf[0].len;
+	}
+
 	/* Save the packet send completion and context */
 	filterPacket->completion = pkt->completion.send.send_completion;
 	filterPacket->completion_ctx =
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 62b908e..0ae065a 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -35,7 +35,7 @@
 #include <linux/mod_devicetable.h>
 
 
-#define MAX_PAGE_BUFFER_COUNT				18
+#define MAX_PAGE_BUFFER_COUNT				19
 #define MAX_MULTIPAGE_BUFFER_COUNT			32 /* 128K */
 
 #pragma pack(push, 1)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary
  2012-02-02 17:17 [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary Haiyang Zhang
  2012-02-02 17:18 ` [PATCH 2/2] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary Haiyang Zhang
@ 2012-02-02 19:44 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2012-02-02 19:44 UTC (permalink / raw)
  To: haiyangz; +Cc: kys, netdev, linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Thu,  2 Feb 2012 09:17:59 -0800

> For code path not on the xmit, use netif_tx_disable() instead of
> netif_stop_queue() to ensure other CPUs are not doing xmit.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary
  2012-02-02 17:18 ` [PATCH 2/2] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary Haiyang Zhang
@ 2012-02-02 19:50   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-02-02 19:50 UTC (permalink / raw)
  To: haiyangz; +Cc: kys, netdev, linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Thu,  2 Feb 2012 09:18:00 -0800

> There is a possible data corruption if an RNDIS message goes beyond page
> boundary in the sending code path. This patch fixes the problem.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-02 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-02 17:17 [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary Haiyang Zhang
2012-02-02 17:18 ` [PATCH 2/2] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary Haiyang Zhang
2012-02-02 19:50   ` David Miller
2012-02-02 19:44 ` [PATCH 1/2] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).