[PATCH net-next,1/1] hyperv: Remove unnecessary comments in rndis_filter_receive_data()

2012-10-18 Thread Haiyang Zhang
Checked with Windows networking team, there is only one RNDIS message
in each netvsc packet.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 928148c..7fdeb52 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -363,11 +363,6 @@ static void rndis_filter_receive_data(struct rndis_device 
*dev,
 
rndis_pkt = msg-msg.pkt;
 
-   /*
-* FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this
-* netvsc packet (ie TotalDataBufferLength != MessageLength)
-*/
-
/* Remove the rndis header and pass it back up the stack */
data_offset = RNDIS_HEADER_SIZE + rndis_pkt-data_offset;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net] hyperv: Fix a compiler warning in netvsc_send()

2013-04-16 Thread Haiyang Zhang
Fixed: warning: cast from pointer to integer of different size

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/netvsc.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index f5f0f09..8c03033 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -500,7 +500,7 @@ int netvsc_send(struct hv_device *device,
int ret = 0;
struct nvsp_message sendMessage;
struct net_device *ndev;
-   u64 req_id;
+   ulong req_id;
 
net_device = get_outbound_net_device(device);
if (!net_device)
@@ -522,7 +522,7 @@ int netvsc_send(struct hv_device *device,
sendMessage.msg.v1_msg.send_rndis_pkt.send_buf_section_size = 0;
 
if (packet-completion.send.send_completion)
-   req_id = (u64)packet;
+   req_id = (ulong)packet;
else
req_id = 0;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()

2013-04-16 Thread Haiyang Zhang
 -Original Message-
 From: David Miller [mailto:da...@davemloft.net] 
 Sent: Tuesday, April 16, 2013 3:12 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de; 
 jasow...@redhat.com; linux-kernel@vger.kernel.org; 
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()

 From: Haiyang Zhang haiya...@microsoft.com
 Date: Tue, 16 Apr 2013 12:03:51 -0700

  Fixed: warning: cast from pointer to integer of different size
  
  Reported-by: kbuild test robot fengguang...@intel.com
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com

 If you're coding pointers into request IDs you better make that explicit and 
 add lots of comments explaining 
 why that's OK and why it's going to work  fine in these circumstances.

 I'm not applying this patch, it just makes a bad situation even worse.  
 Either your request IDs are 64-bit or they are not, it can't be both.

The Hyper-V hosts always use 64 bit request id. The guests can have 32 or 64 
bit pointers which equal to
the ulong type size. So we cast it to ulong type. And, assigning 32bit integer 
to 64 bit variable works fine.

Actually, before the recent patch (f1ea3cd7011), the packet pointer was casted 
to ulong. And this patch
restore the same type casting as the old code.

The VMBus returns the same id in the completion packet. But the value has no 
effect on the host side.

Does these comments sound good?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()

2013-04-16 Thread Haiyang Zhang
 -Original Message-
 From: David Miller [mailto:da...@davemloft.net] 
 Sent: Tuesday, April 16, 2013 3:49 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de; 
 jasow...@redhat.com; linux-kernel@vger.kernel.org; 
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()

 From: Haiyang Zhang haiya...@microsoft.com
 Date: Tue, 16 Apr 2013 19:34:52 +

  The Hyper-V hosts always use 64 bit request id. The guests can have
  32 or 64 bit pointers which equal to the ulong type size. So we cast 
  it to ulong type. And, assigning 32bit integer to 64 bit variable 
  works fine.

 It works fine, but it's unclean.

 Keep the req_id type as u64, because that's what it is, a 64-bit request ID.

I will make this update and submit a new patch, with the added comments.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()

2013-04-16 Thread Haiyang Zhang
 -Original Message-
 From: Joe Perches [mailto:j...@perches.com]
 Sent: Tuesday, April 16, 2013 4:31 PM
 To: Haiyang Zhang
 Cc: David Miller; net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()
 
 On Tue, 2013-04-16 at 20:18 +, Haiyang Zhang wrote:
   From: David Miller [mailto:da...@davemloft.net] It works fine, but
   it's unclean.
   Keep the req_id type as u64, because that's what it is, a 64-bit request
 ID.
  I will make this update and submit a new patch, with the added comments.
 
 Do you mean you'll use this to avoid compiler warnings?
 
   req_id = (u64)(unsigned long)packet;

I will use:
req_id = (ulong)packet;

Assigning 32 bit integer to 64 bit variable is fine.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net] hyperv: Fix a compiler warning in netvsc_send()

2013-04-16 Thread Haiyang Zhang
Fixed: warning: cast from pointer to integer of different size

The Hyper-V hosts always use 64 bit request id. The guests can have 32 or 64
bit pointers which equal to the ulong type size. So we cast it to ulong type.
And, assigning 32bit integer to 64 bit variable works fine.

The VMBus returns the same id in the completion packet. But the value has no
effect on the host side.

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/netvsc.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index f5f0f09..2b04804 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -522,7 +522,7 @@ int netvsc_send(struct hv_device *device,
sendMessage.msg.v1_msg.send_rndis_pkt.send_buf_section_size = 0;
 
if (packet-completion.send.send_completion)
-   req_id = (u64)packet;
+   req_id = (ulong)packet;
else
req_id = 0;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()

2013-04-19 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Friday, April 19, 2013 4:50 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net] hyperv: Fix a compiler warning in netvsc_send()
 
 From: Haiyang Zhang haiya...@microsoft.com
 Date: Tue, 16 Apr 2013 15:25:50 -0700
 
  Fixed: warning: cast from pointer to integer of different size
 
  The Hyper-V hosts always use 64 bit request id. The guests can have 32
  or 64 bit pointers which equal to the ulong type size. So we cast it to 
  ulong
 type.
  And, assigning 32bit integer to 64 bit variable works fine.
 
  The VMBus returns the same id in the completion packet. But the value
  has no effect on the host side.
 
  Reported-by: kbuild test robot fengguang...@intel.com
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 
 Such build warning fixes are not appropriate for 'net' at this time, and this
 patch does not apply to 'net-next', so I'm dropping this entirely.

OK. I will re-submit it to net-next after the recent patch causing the warning
is merged into the net-next tree.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: hv_netvsc: WARNING in softirq.c

2013-04-05 Thread Haiyang Zhang


 -Original Message-
 From: Richard Genoud [mailto:richard.gen...@gmail.com]
 Sent: Friday, April 05, 2013 7:00 AM
 To: Haiyang Zhang
 Cc: KY Srinivasan; de...@linuxdriverproject.org; net...@vger.kernel.org;
 linux-kernel@vger.kernel.org
 Subject: Re: hv_netvsc: WARNING in softirq.c
 
 Ok, it has been a little bit more than 2 weeks now, and I did not see this
 warning any more, just the
 hv_vmbus: child device vmbus_0_8 unregistered sometimes.
 
 so it seems to be fixed !
 
 Thanks !
 
 
 Reported-by: Richard Genoud richard.gen...@gmail.com
 Tested-by: Richard Genoud richard.gen...@gmail.com
 

Thank you! I will submit the patch soon.

- Haiyang


[PATCH net,1/2] hyperv: Fix a kernel warning from netvsc_linkstatus_callback()

2013-04-05 Thread Haiyang Zhang
The warning about local_bh_enable inside IRQ happens when disconnecting a
virtual NIC.

The reason for the warning is -- netif_tx_disable() is called when the NIC
is disconnected. And it's called within irq context. netif_tx_disable() calls
local_bh_enable() which displays warning if in irq.

The fix is to remove the unnecessary netif_tx_disable  wake_queue() in the
netvsc_linkstatus_callback().

Reported-by: Richard Genoud richard.gen...@gmail.com
Tested-by: Long Li lon...@microsoft.com
Tested-by: Richard Genoud richard.gen...@gmail.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/netvsc_drv.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 5f85205..8341b62 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -241,13 +241,11 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 
if (status == 1) {
netif_carrier_on(net);
-   netif_wake_queue(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);
-   netif_tx_disable(net);
}
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net,2/2] hyperv: Fix RNDIS send_completion code path

2013-04-05 Thread Haiyang Zhang
In some cases, the VM_PKT_COMP message can arrive later than RNDIS completion
message, which will free the packet memory. This may cause panic due to access
to freed memory in netvsc_send_completion().

This patch fixes this problem by removing rndis_filter_send_request_completion()
from the code path. The function was a no-op.

Reported-by: Long Li lon...@microsoft.com
Tested-by: Long Li lon...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/netvsc.c   |   17 -
 drivers/net/hyperv/rndis_filter.c |   14 +-
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 1cd7748..f5f0f09 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -470,8 +470,10 @@ static void netvsc_send_completion(struct hv_device 
*device,
packet-trans_id;
 
/* Notify the layer above us */
-   nvsc_packet-completion.send.send_completion(
-   nvsc_packet-completion.send.send_completion_ctx);
+   if (nvsc_packet)
+   nvsc_packet-completion.send.send_completion(
+   nvsc_packet-completion.send.
+   send_completion_ctx);
 
num_outstanding_sends =
atomic_dec_return(net_device-num_outstanding_sends);
@@ -498,6 +500,7 @@ int netvsc_send(struct hv_device *device,
int ret = 0;
struct nvsp_message sendMessage;
struct net_device *ndev;
+   u64 req_id;
 
net_device = get_outbound_net_device(device);
if (!net_device)
@@ -518,20 +521,24 @@ int netvsc_send(struct hv_device *device,
0x;
sendMessage.msg.v1_msg.send_rndis_pkt.send_buf_section_size = 0;
 
+   if (packet-completion.send.send_completion)
+   req_id = (u64)packet;
+   else
+   req_id = 0;
+
if (packet-page_buf_cnt) {
ret = vmbus_sendpacket_pagebuffer(device-channel,
  packet-page_buf,
  packet-page_buf_cnt,
  sendMessage,
  sizeof(struct nvsp_message),
- (unsigned long)packet);
+ req_id);
} else {
ret = vmbus_sendpacket(device-channel, sendMessage,
sizeof(struct nvsp_message),
-   (unsigned long)packet,
+   req_id,
VM_PKT_DATA_INBAND,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-
}
 
if (ret == 0) {
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 2b657d4..0775f0a 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -61,9 +61,6 @@ struct rndis_request {
 
 static void rndis_filter_send_completion(void *ctx);
 
-static void rndis_filter_send_request_completion(void *ctx);
-
-
 
 static struct rndis_device *get_rndis_device(void)
 {
@@ -241,10 +238,7 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
packet-page_buf[0].len;
}
 
-   packet-completion.send.send_completion_ctx = req;/* packet; */
-   packet-completion.send.send_completion =
-   rndis_filter_send_request_completion;
-   packet-completion.send.send_completion_tid = (unsigned long)dev;
+   packet-completion.send.send_completion = NULL;
 
ret = netvsc_send(dev-net_dev-dev, packet);
return ret;
@@ -999,9 +993,3 @@ static void rndis_filter_send_completion(void *ctx)
/* Pass it back to the original handler */
filter_pkt-completion(filter_pkt-completion_ctx);
 }
-
-
-static void rndis_filter_send_request_completion(void *ctx)
-{
-   /* Noop */
-}
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: linux-next: manual merge of the akpm tree with the char-misc tree

2013-03-20 Thread Haiyang Zhang


 -Original Message-
 From: Stephen Rothwell [mailto:s...@canb.auug.org.au]
 Sent: Wednesday, March 20, 2013 12:20 AM
 To: Andrew Morton
 Cc: linux-n...@vger.kernel.org; linux-kernel@vger.kernel.org; Haiyang
 Zhang; KY Srinivasan; Greg KH; Arnd Bergmann
 Subject: linux-next: manual merge of the akpm tree with the char-misc
 tree
 
 Hi Andrew,
 
 Today's linux-next merge of the akpm tree got a conflict in
 include/linux/hyperv.h between commit 96dd86fa5881 (Drivers: hv: Add a
 new driver to support host initiated backup) from the char-misc  tree
 and commit drivers/video: add Hyper-V Synthetic Video Frame Buffer
 Driver from the akpm tree.
 
 I fixed it up (see below) and can carry the fix as necessary (no action
 is required).

Thank you for fixing it!

- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] video: fix a type warning in hyperv_fb.c

2013-03-21 Thread Haiyang Zhang
Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/video/hyperv_fb.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index ceb33b0..d4d2c5f 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -624,7 +624,7 @@ static int hvfb_getmem(struct fb_info *info)
 {
struct pci_dev *pdev;
ulong fb_phys;
-   void *fb_virt;
+   void __iomem *fb_virt;
 
pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
  PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-08 Thread Haiyang Zhang
This is the driver for the Hyper-V Synthetic Video, which supports screen
resolution up to Full HD 1920x1080 on Windows Server 2012 host, and 1600x1200
on  Windows Server 2008 R2 or earlier.
It also solves the double mouse cursor issue of the emulated video mode.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
v3:
According to the comment from Greg Kroah-Hartman gre...@linuxfoundation.org,
moved pci ids back to the hyperv_fb.c, because it is the only driver using
them.

v2:
Made changes based on reviews from Olaf Hering o...@aepfle.de, Geert
Uytterhoeven ge...@linux-m68k.org.

Renamed the Kconfig string to FB_HYPERV. And, use KBUILD_MODNAME in two
additional places to keep consistency in naming.

Switched fb from system RAM to PCI mmio space, so the workaround for large
memory allocation is not necessary. The fb ops and screen refresh mechanism is
updated accordingly.

Added aperture setting so that VESA fb can be disabled automatically without
code change on the vesafb.c.
---
 drivers/video/Kconfig |9 +
 drivers/video/Makefile|1 +
 drivers/video/hyperv_fb.c |  829 +
 include/linux/hyperv.h|   11 +
 4 files changed, 850 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/hyperv_fb.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4c1546f..5d1a35e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2451,6 +2451,15 @@ config FB_PUV3_UNIGFX
  Choose this option if you want to use the Unigfx device as a
  framebuffer device. Without the support of PCI  AGP.
 
+config FB_HYPERV
+   tristate Microsoft Hyper-V Synthetic Video support
+   depends on FB  HYPERV
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   help
+ This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
+
 source drivers/video/omap/Kconfig
 source drivers/video/omap2/Kconfig
 source drivers/video/exynos/Kconfig
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 9df3873..97f7b6d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -149,6 +149,7 @@ obj-$(CONFIG_FB_MSM)  += msm/
 obj-$(CONFIG_FB_NUC900)   += nuc900fb.o
 obj-$(CONFIG_FB_JZ4740)  += jz4740_fb.o
 obj-$(CONFIG_FB_PUV3_UNIGFX)  += fb-puv3.o
+obj-$(CONFIG_FB_HYPERV)  += hyperv_fb.o
 
 # Platform or fallback drivers go here
 obj-$(CONFIG_FB_UVESA)+= uvesafb.o
diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
new file mode 100644
index 000..ceb33b0
--- /dev/null
+++ b/drivers/video/hyperv_fb.c
@@ -0,0 +1,829 @@
+/*
+ * Copyright (c) 2012, Microsoft Corporation.
+ *
+ * Author:
+ *   Haiyang Zhang haiya...@microsoft.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ * Hyper-V Synthetic Video Frame Buffer Driver
+ *
+ * This is the driver for the Hyper-V Synthetic Video, which supports
+ * screen resolution up to Full HD 1920x1080 with 32 bit color on Windows
+ * Server 2012, and 1600x1200 with 16 bit color on Windows Server 2008 R2
+ * or earlier.
+ *
+ * It also solves the double mouse cursor issue of the emulated video mode.
+ *
+ * The default screen resolution is 1152x864, which may be changed by a
+ * kernel parameter:
+ * video=hyperv_fb:widthxheight
+ * For example: video=hyperv_fb:1280x1024
+ *
+ * Portrait orientation is also supported:
+ * For example: video=hyperv_fb:864x1152
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/completion.h
+#include linux/fb.h
+#include linux/pci.h
+
+#include linux/hyperv.h
+
+
+/* Hyper-V Synthetic Video Protocol definitions and structures */
+#define MAX_VMBUS_PKT_SIZE 0x4000
+
+#define SYNTHVID_VERSION(major, minor) ((minor)  16 | (major))
+#define SYNTHVID_VERSION_WIN7 SYNTHVID_VERSION(3, 0)
+#define SYNTHVID_VERSION_WIN8 SYNTHVID_VERSION(3, 2)
+
+#define SYNTHVID_DEPTH_WIN7 16
+#define SYNTHVID_DEPTH_WIN8 32
+
+#define SYNTHVID_FB_SIZE_WIN7 (4 * 1024 * 1024)
+#define SYNTHVID_WIDTH_MAX_WIN7 1600
+#define SYNTHVID_HEIGHT_MAX_WIN7 1200
+
+#define SYNTHVID_FB_SIZE_WIN8 (8 * 1024 * 1024)
+
+#define PCI_VENDOR_ID_MICROSOFT 0x1414
+#define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
+
+
+enum pipe_msg_type {
+   PIPE_MSG_INVALID,
+   PIPE_MSG_DATA,
+   PIPE_MSG_MAX
+};
+
+struct pipe_msg_hdr {
+   u32 type;
+   u32 size

RE: [PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-12 Thread Haiyang Zhang


 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Haiyang Zhang
 Sent: Friday, March 08, 2013 4:46 PM
 To: florianschandi...@gmx.de; linux-fb...@vger.kernel.org
 Cc: Haiyang Zhang; KY Srinivasan; o...@aepfle.de; jasow...@redhat.com;
 linux-kernel@vger.kernel.org; de...@linuxdriverproject.org
 Subject: [PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer
 Driver
 
 This is the driver for the Hyper-V Synthetic Video, which supports
 screen
 resolution up to Full HD 1920x1080 on Windows Server 2012 host, and
 1600x1200
 on  Windows Server 2008 R2 or earlier.
 It also solves the double mouse cursor issue of the emulated video mode.
 
 Signed-off-by: Haiyang Zhang haiya...@microsoft.com
 Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 

Hi, Florian and Andrew,

So far, I have responded to all comments from the community, and made the
recommended updates. Do you have any additional comments on this driver?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-04 Thread Haiyang Zhang
This is the driver for the Hyper-V Synthetic Video, which supports screen
resolution up to Full HD 1920x1080 on Windows Server 2012 host, and 1600x1200
on  Windows Server 2008 R2 or earlier.
It also solves the double mouse cursor issue of the emulated video mode.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
v2:
Made changes based on reviews from Olaf Hering o...@aepfle.de, Geert
Uytterhoeven ge...@linux-m68k.org.

Renamed the Kconfig string to FB_HYPERV. And, use KBUILD_MODNAME in two
additional places to keep consistency in naming.

Switched fb from system RAM to PCI mmio space, so the workaround for large
memory allocation is not necessary. The fb ops and screen refresh mechanism is
updated accordingly.

Added aperture setting so that VESA fb can be disabled automatically without
code change on the vesafb.c.

---
 drivers/video/Kconfig |9 +
 drivers/video/Makefile|1 +
 drivers/video/hyperv_fb.c |  826 +
 include/linux/hyperv.h|   11 +
 include/linux/pci_ids.h   |3 +
 5 files changed, 850 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/hyperv_fb.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4c1546f..5d1a35e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2451,6 +2451,15 @@ config FB_PUV3_UNIGFX
  Choose this option if you want to use the Unigfx device as a
  framebuffer device. Without the support of PCI  AGP.
 
+config FB_HYPERV
+   tristate Microsoft Hyper-V Synthetic Video support
+   depends on FB  HYPERV
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   help
+ This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
+
 source drivers/video/omap/Kconfig
 source drivers/video/omap2/Kconfig
 source drivers/video/exynos/Kconfig
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 9df3873..97f7b6d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -149,6 +149,7 @@ obj-$(CONFIG_FB_MSM)  += msm/
 obj-$(CONFIG_FB_NUC900)   += nuc900fb.o
 obj-$(CONFIG_FB_JZ4740)  += jz4740_fb.o
 obj-$(CONFIG_FB_PUV3_UNIGFX)  += fb-puv3.o
+obj-$(CONFIG_FB_HYPERV)  += hyperv_fb.o
 
 # Platform or fallback drivers go here
 obj-$(CONFIG_FB_UVESA)+= uvesafb.o
diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
new file mode 100644
index 000..52ce02c
--- /dev/null
+++ b/drivers/video/hyperv_fb.c
@@ -0,0 +1,826 @@
+/*
+ * Copyright (c) 2012, Microsoft Corporation.
+ *
+ * Author:
+ *   Haiyang Zhang haiya...@microsoft.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ * Hyper-V Synthetic Video Frame Buffer Driver
+ *
+ * This is the driver for the Hyper-V Synthetic Video, which supports
+ * screen resolution up to Full HD 1920x1080 with 32 bit color on Windows
+ * Server 2012, and 1600x1200 with 16 bit color on Windows Server 2008 R2
+ * or earlier.
+ *
+ * It also solves the double mouse cursor issue of the emulated video mode.
+ *
+ * The default screen resolution is 1152x864, which may be changed by a
+ * kernel parameter:
+ * video=hyperv_fb:widthxheight
+ * For example: video=hyperv_fb:1280x1024
+ *
+ * Portrait orientation is also supported:
+ * For example: video=hyperv_fb:864x1152
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/completion.h
+#include linux/fb.h
+#include linux/pci.h
+
+#include linux/hyperv.h
+
+
+/* Hyper-V Synthetic Video Protocol definitions and structures */
+#define MAX_VMBUS_PKT_SIZE 0x4000
+
+#define SYNTHVID_VERSION(major, minor) ((minor)  16 | (major))
+#define SYNTHVID_VERSION_WIN7 SYNTHVID_VERSION(3, 0)
+#define SYNTHVID_VERSION_WIN8 SYNTHVID_VERSION(3, 2)
+
+#define SYNTHVID_DEPTH_WIN7 16
+#define SYNTHVID_DEPTH_WIN8 32
+
+#define SYNTHVID_FB_SIZE_WIN7 (4 * 1024 * 1024)
+#define SYNTHVID_WIDTH_MAX_WIN7 1600
+#define SYNTHVID_HEIGHT_MAX_WIN7 1200
+
+#define SYNTHVID_FB_SIZE_WIN8 (8 * 1024 * 1024)
+
+
+enum pipe_msg_type {
+   PIPE_MSG_INVALID,
+   PIPE_MSG_DATA,
+   PIPE_MSG_MAX
+};
+
+struct pipe_msg_hdr {
+   u32 type;
+   u32 size; /* size of message after this field */
+} __packed;
+
+
+enum synthvid_msg_type {
+   SYNTHVID_ERROR  = 0,
+   SYNTHVID_VERSION_REQUEST= 1,
+   SYNTHVID_VERSION_RESPONSE

RE: [PATCH v2] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-04 Thread Haiyang Zhang


 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Greg KH
 Sent: Monday, March 04, 2013 8:16 PM
 To: Haiyang Zhang
 Cc: florianschandi...@gmx.de; linux-fb...@vger.kernel.org;
 o...@aepfle.de; jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH v2] video: Add Hyper-V Synthetic Video Frame Buffer
 Driver
 
 On Mon, Mar 04, 2013 at 01:56:12PM -0800, Haiyang Zhang wrote:
  --- a/include/linux/pci_ids.h
  +++ b/include/linux/pci_ids.h
  @@ -2951,3 +2951,6 @@
   #define PCI_DEVICE_ID_XEN_PLATFORM 0x0001
 
   #define PCI_VENDOR_ID_OCZ  0x1b85
  +
  +#define PCI_VENDOR_ID_MICROSOFT0x1414
  +#define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
 
 Please see the top of this while for why you shouldn't be adding any lines to
 this file.

I will move the defines back to the hyperv_fb.c.
Thanks for pointing this out.

- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: hv_netvsc: WARNING in softirq.c

2013-03-06 Thread Haiyang Zhang


 -Original Message-
 From: Richard Genoud [mailto:richard.gen...@gmail.com]
 Sent: Friday, March 01, 2013 3:39 AM
 To: Haiyang Zhang
 Cc: KY Srinivasan; de...@linuxdriverproject.org; net...@vger.kernel.org;
 linux-kernel@vger.kernel.org
 Subject: Re: hv_netvsc: WARNING in softirq.c
 
 2013/2/28 Haiyang Zhang haiya...@microsoft.com:
  We will look into this. And further info around the time will also be
 helpful.
 
  Thanks,
  - Haiyang
 
 The only thing the admin sys could think about is a rsync process
 between the windows host and ANOTHER linux guest that ends at 22h30
 more or less.
 (the other linux guest is a debian 6, without any HV driver)

I have found a simple way to reproduce this kind of warning:
1) reboot the VM (because this warning can be displayed only once.)
2) login to the host and open the VM [Settings]
3) Temporarily change the Network adapter's option [Virtual Switch] to Not 
connected.
4) run dmesg, you should see the warning.

The reason for the warning is -- netif_tx_disable() is called when the NIC
is disconnected. And it's called within irq context. netif_tx_disable()
calls local_bh_enable() which displays warning if in irq.

The fix is to remove the unnecessary netif_tx_disable() in the 
netvsc_linkstatus_callback().
I attached a patch. Would you like to test it on your side as well?

Thanks,
- Haiyang



net_stat_warn_test.patch
Description: net_stat_warn_test.patch


[PATCH net-next,1/1] hyperv: Add an error message to rndis_filter_set_device_mac()

2012-11-30 Thread Haiyang Zhang
This message indicates an error returned from the host when changing MAC 
address.

Reported-by: Michal Kubecek mkube...@suse.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 7fdeb52..2b657d4 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -605,8 +605,11 @@ int rndis_filter_set_device_mac(struct hv_device *hdev, 
char *mac)
return -EBUSY;
} else {
set_complete = request-response_msg.msg.set_complete;
-   if (set_complete-status != RNDIS_STATUS_SUCCESS)
+   if (set_complete-status != RNDIS_STATUS_SUCCESS) {
+   netdev_err(ndev, Fail to set MAC on host side:0x%x\n,
+  set_complete-status);
ret = -EINVAL;
+   }
}
 
 cleanup:
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-02-28 Thread Haiyang Zhang
 -Original Message-
 From: Olaf Hering [mailto:o...@aepfle.de]
 Sent: Thursday, February 28, 2013 10:17 AM
 To: Haiyang Zhang
 Cc: florianschandi...@gmx.de; linux-fb...@vger.kernel.org; KY Srinivasan;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer
 Driver
 
 On Fri, Feb 15, Haiyang Zhang wrote:
 
  +   if (fb_get_options(hyperv_fb, opt) || !opt || !*opt)
 
  +   strcpy(info-fix.id, hyperv);
 
 
 Here is a mismatch between video=optname and /proc/fb output.
 Both should have the same string IMO.

I will make both of them to be KBUILD_MODNAME.

Thanks,
- Haiyang


RE: hv_netvsc: WARNING in softirq.c

2013-02-28 Thread Haiyang Zhang


 -Original Message-
 From: Richard GENOUD [mailto:richard.gen...@gmail.com]
 Sent: Thursday, February 28, 2013 3:35 AM
 To: KY Srinivasan
 Cc: Haiyang Zhang; de...@linuxdriverproject.org; net...@vger.kernel.org;
 linux-kernel@vger.kernel.org
 Subject: hv_netvsc: WARNING in softirq.c
 
 Hi,
 
 Here is the kernel trace I got this morning (kern.log):
 Feb 27 22:32:59 devlabo kernel: [10688.187062] hv_vmbus: child device
 vmbus_0_8 unregistered
 Feb 27 22:34:37 devlabo kernel: [10688.187196] [ cut here 
 ]---
 -
 Feb 27 22:34:37 devlabo kernel: [10688.187203] WARNING: at /build/buildd-
 linux_3.2.35-2-amd64-v9djlH/linux-3.2.35/kernel/softirq.c:159
 _local_bh_enable_ip.isra.11+0x3d/0x88()
 Feb 27 22:34:37 devlabo kernel: [10688.187206] Hardware name: Virtual
 Machine
 Feb 27 22:34:37 devlabo kernel: [10688.187208] Modules linked in:
 des_generic ecb md4 hmac nls_utf8 cifs nfsd nfs nfs_acl auth_rpcgss fscache
 lockd sunrpc loop snd_pcm snd_page_alloc snd_timer snd joydev processor
 hid_hyperv crc32c_intel hid thermal_sys i2c_piix4 evdev button soundcore
 hv_utils i2c_core psmouse serio_raw pcspkr ext4 crc16 jbd2 mbcache
 sd_mod crc_t10dif hv_netvsc hv_storvsc sg sr_mod cdrom ata_generic
 floppy hv_vmbus ata_piix libata scsi_mod [last unloaded: scsi_wait_scan]
 Feb 27 22:34:37 devlabo kernel: [10688.187244] Pid: 0, comm: swapper/0 Not
 tainted 3.2.0-4-amd64 #1 Debian 3.2.35-2
 Feb 27 22:34:37 devlabo kernel: [10688.187246] Call Trace:
 Feb 27 22:34:37 devlabo kernel: [10688.187248]  IRQ  [81046a75] ?
 warn_slowpath_common+0x78/0x8c
 Feb 27 22:34:37 devlabo kernel: [10688.187257]  [8104bf76] ?
 _local_bh_enable_ip.isra.11+0x3d/0x88
 Feb 27 22:34:37 devlabo kernel: [10688.187262]  [a00a59b5] ?
 rndis_filter_receive+0x236/0x259 [hv_netvsc]
 Feb 27 22:34:37 devlabo kernel: [10688.187267]  [a00a4e5f] ?
 netvsc_channel_cb+0x37a/0x449 [hv_netvsc]
 Feb 27 22:34:37 devlabo kernel: [10688.187273]  [a006211b] ?
 vmbus_on_event+0x91/0xdd [hv_vmbus]
 Feb 27 22:34:37 devlabo kernel: [10688.187277]  [812432d5] ?
 add_interrupt_randomness+0x38/0x155
 Feb 27 22:34:37 devlabo kernel: [10688.187283]  [8104b89a] ?
 tasklet_action+0x73/0xc2
 Feb 27 22:34:37 devlabo kernel: [10688.187287]  [8104c084] ?
 __do_softirq+0xb9/0x177
 Feb 27 22:34:37 devlabo kernel: [10688.187292]  [8135426c] ?
 call_softirq+0x1c/0x30
 Feb 27 22:34:37 devlabo kernel: [10688.187297]  [8100f8dd] ?
 do_softirq+0x3c/0x7b
 Feb 27 22:34:37 devlabo kernel: [10688.187300]  [8104c2ec] ?
 irq_exit+0x3c/0x9a
 Feb 27 22:34:37 devlabo kernel: [10688.187303]  [8100f60d] ?
 do_IRQ+0x82/0x98
 Feb 27 22:34:37 devlabo kernel: [10688.187307]  [8134d32e] ?
 common_interrupt+0x6e/0x6e
 Feb 27 22:34:37 devlabo kernel: [10688.187309]  EOI  [81065dbd] ?
 timekeeping_get_ns+0xd/0x2a
 Feb 27 22:34:37 devlabo kernel: [10688.187317]  [8106bc20] ?
 arch_local_irq_enable+0x4/0x8
 Feb 27 22:34:37 devlabo kernel: [10688.187321]  [8100d286] ?
 cpu_idle+0xe8/0xf2
 Feb 27 22:34:37 devlabo kernel: [10688.187324]  [816abb33] ?
 start_kernel+0x3b3/0x3be
 Feb 27 22:34:37 devlabo kernel: [10688.187328]  [816ab140] ?
 early_idt_handlers+0x140/0x140
 Feb 27 22:34:37 devlabo kernel: [10688.187331]  [816ab3c4] ?
 x86_64_start_kernel+0x104/0x111
 Feb 27 22:34:37 devlabo kernel: [10688.187333] ---[ end trace
 39158641c6e4b495 ]---
 
 and there was a lot of them :
 Feb 26 22:35:14 devlabo kernel: [37398.788119] [ cut here 
 ]---
 -
 Feb 26 22:35:14 devlabo kernel: [37398.788129] WARNING: at /build/buildd-
 linux_3.2.35-2-amd64-v9djlH/linux-3.2.35/kernel/softirq.c:159
 _local_bh_enable_ip.isra.11+0x3d/0x88()
 Feb 26 22:35:14 devlabo kernel: [37398.788132] Hardware name: Virtual
 Machine
 Feb 26 22:35:14 devlabo kernel: [37398.788133] Modules linked in: nfsd nfs
 nfs_acl auth_rpcgss lockd sunrpc des_generic ecb md4 hmac nls_utf8 cifs
 fscache loop snd_pcm snd_page_alloc snd_timer joydev crc32c_intel
 i2c_piix4 snd processor hid_hyperv hid hv_utils soundcore button
 thermal_sys pcspkr i2c_core psmouse evdev serio_raw ext4 crc16 jbd2
 mbcache sd_mod crc_t10dif hv_netvsc hv_storvsc sg sr_mod cdrom
 ata_generic ata_piix libata scsi_mod floppy hv_vmbus [last unloaded:
 scsi_wait_scan]
 Feb 26 22:35:14 devlabo kernel: [37398.788169] Pid: 0, comm: swapper/0 Not
 tainted 3.2.0-4-amd64 #1 Debian 3.2.35-2
 Feb 26 22:35:14 devlabo kernel: [37398.788171] Call Trace:
 Feb 26 22:35:14 devlabo kernel: [37398.788172]  IRQ  [81046a75] ?
 warn_slowpath_common+0x78/0x8c
 Feb 26 22:35:14 devlabo kernel: [37398.788181]  [8104bf76] ?
 _local_bh_enable_ip.isra.11+0x3d/0x88
 Feb 26 22:35:14 devlabo kernel: [37398.788186]  [a009e9b5] ?
 rndis_filter_receive+0x236/0x259 [hv_netvsc]
 Feb 26 22:35:14 devlabo kernel: [37398.788190]  [a009de5f] ?
 netvsc_channel_cb+0x37a/0x449 [hv_netvsc]
 Feb 26 22:35:14

[PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-02-15 Thread Haiyang Zhang
This is the driver for the Hyper-V Synthetic Video, which supports screen
resolution up to Full HD 1920x1080 on Windows Server 2012 host, and 1600x1200
on  Windows Server 2008 R2 or earlier.
It also solves the double mouse cursor issue of the emulated video mode.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/video/Kconfig |   11 +
 drivers/video/Makefile|1 +
 drivers/video/hyperv_fb.c |  983 +
 drivers/video/vesafb.c|   48 +++
 include/linux/hyperv.h|   11 +
 5 files changed, 1054 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/hyperv_fb.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 1e2f2d8..7d2a721 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2449,6 +2449,17 @@ config FB_PUV3_UNIGFX
  Choose this option if you want to use the Unigfx device as a
  framebuffer device. Without the support of PCI  AGP.
 
+config HYPERV_FB
+   tristate Microsoft Hyper-V Synthetic Video support
+   depends on FB  HYPERV
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
+   select FB_SYS_FOPS
+   select FB_DEFERRED_IO
+   help
+ This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
+
 source drivers/video/omap/Kconfig
 source drivers/video/omap2/Kconfig
 source drivers/video/exynos/Kconfig
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 136af7d..dd1c6da 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -148,6 +148,7 @@ obj-$(CONFIG_FB_MSM)  += msm/
 obj-$(CONFIG_FB_NUC900)   += nuc900fb.o
 obj-$(CONFIG_FB_JZ4740)  += jz4740_fb.o
 obj-$(CONFIG_FB_PUV3_UNIGFX)  += fb-puv3.o
+obj-$(CONFIG_HYPERV_FB)  += hyperv_fb.o
 
 # Platform or fallback drivers go here
 obj-$(CONFIG_FB_UVESA)+= uvesafb.o
diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
new file mode 100644
index 000..d7c660f
--- /dev/null
+++ b/drivers/video/hyperv_fb.c
@@ -0,0 +1,983 @@
+/*
+ * Copyright (c) 2012, Microsoft Corporation.
+ *
+ * Author:
+ *   Haiyang Zhang haiya...@microsoft.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ * Hyper-V Synthetic Video Frame Buffer Driver
+ *
+ * This is the driver for the Hyper-V Synthetic Video, which supports
+ * screen resolution up to Full HD 1920x1080 with 32 bit color on Windows
+ * Server 2012, and 1600x1200 with 16 bit color on Windows Server 2008 R2
+ * or earlier.
+ *
+ * It also solves the double mouse cursor issue of the emulated video mode.
+ *
+ * The default screen resolution is 1152x864, which may be changed by a
+ * kernel parameter:
+ * video=hyperv_fb:widthxheight
+ * For example: video=hyperv_fb:1280x1024
+ *
+ * Portrait orientation is also supported:
+ * For example: video=hyperv_fb:864x1152
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/completion.h
+#include linux/fb.h
+
+#include linux/hyperv.h
+
+
+/* Hyper-V Synthetic Video Protocol definitions and structures */
+#define MAX_VMBUS_PKT_SIZE 0x4000
+
+#define SYNTHVID_VERSION(major, minor) ((minor)  16 | (major))
+#define SYNTHVID_VERSION_WIN7 SYNTHVID_VERSION(3, 0)
+#define SYNTHVID_VERSION_WIN8 SYNTHVID_VERSION(3, 2)
+
+#define SYNTHVID_DEPTH_WIN7 16
+#define SYNTHVID_DEPTH_WIN8 32
+
+#define SYNTHVID_FB_SIZE_WIN7 (4 * 1024 * 1024)
+#define SYNTHVID_WIDTH_MAX_WIN7 1600
+#define SYNTHVID_HEIGHT_MAX_WIN7 1200
+
+#define SYNTHVID_FB_SIZE_WIN8 (8 * 1024 * 1024)
+
+
+enum pipe_msg_type {
+   PIPE_MSG_INVALID,
+   PIPE_MSG_DATA,
+   PIPE_MSG_MAX
+};
+
+struct pipe_msg_hdr {
+   u32 type;
+   u32 size; /* size of message after this field */
+} __packed;
+
+
+enum synthvid_msg_type {
+   SYNTHVID_ERROR  = 0,
+   SYNTHVID_VERSION_REQUEST= 1,
+   SYNTHVID_VERSION_RESPONSE   = 2,
+   SYNTHVID_VRAM_LOCATION  = 3,
+   SYNTHVID_VRAM_LOCATION_ACK  = 4,
+   SYNTHVID_SITUATION_UPDATE   = 5,
+   SYNTHVID_SITUATION_UPDATE_ACK   = 6,
+   SYNTHVID_POINTER_POSITION   = 7,
+   SYNTHVID_POINTER_SHAPE  = 8,
+   SYNTHVID_FEATURE_CHANGE = 9,
+   SYNTHVID_DIRT   = 10,
+
+   SYNTHVID_MAX= 11
+};
+
+struct synthvid_msg_hdr {
+   u32 type;
+   u32

RE: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-02-17 Thread Haiyang Zhang
 From: Olaf Hering
 Sent: Sunday, February 17, 2013 9:32 AM
 To: Haiyang Zhang
 Cc: florianschandi...@gmx.de; linux-fb...@vger.kernel.org; KY Srinivasan; 
 jasow...@redhat.com; linux-kernel@vger.kernel.org; 
 de...@linuxdriverproject.org
 Subject: Re: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer 
 Driver

 On Fri, Feb 15, Haiyang Zhang wrote:

 +config HYPERV_FB

 This should probably be FB_HYPERB to follow the naming of all other
 drivers.

Will do.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-02-18 Thread Haiyang Zhang
 -Original Message-
 From: geert.uytterhoe...@gmail.com
 [mailto:geert.uytterhoe...@gmail.com] On Behalf Of Geert Uytterhoeven
 Sent: Monday, February 18, 2013 5:29 AM
 To: Haiyang Zhang
 Cc: florianschandi...@gmx.de; linux-fb...@vger.kernel.org; KY Srinivasan;
 o...@aepfle.de; jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer
 Driver
 
 On Fri, Feb 15, 2013 at 8:09 PM, Haiyang Zhang haiya...@microsoft.com
 wrote:
  +/* Allocate framebuffer memory */

 Please instead reserve some memory at boot time, or allocate it very early
 (cfr. ps3fb).

I will look into this.

Thanks,
- Haiyang

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�j:+v���zZ+��+zf���h���~i���z��w���?��)ߢf��^jǫy�m��@A�a���
0��h���i

RE: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-02-19 Thread Haiyang Zhang
 -Original Message-
 From: Olaf Hering [mailto:o...@aepfle.de]
 Sent: Tuesday, February 19, 2013 11:51 AM
 To: Haiyang Zhang
 Cc: florianschandi...@gmx.de; linux-fb...@vger.kernel.org; KY Srinivasan;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer
 Driver
 
 On Fri, Feb 15, Haiyang Zhang wrote:
 
  @@ -508,6 +544,18 @@ static int __init vesafb_init(void)
  int ret;
  char *option = NULL;
 
  +#if IS_ENABLED(CONFIG_HYPERV_FB)
  +   /*
  +* On Hyper-V both the emulated and synthetic video devices are
  +* available. To avoid conflicts, we disable vesafb for the
 emulated
  +* video if hyperv_fb is configured.
  +*/
  +   if (is_hyperv()) {
  +   pr_info(Disabled vesafb on Hyper-V.\n);
  +   return -ENODEV;
  +   }
  +#endif
 
 What is the reason for this hook? Is it not possible to claim the
 display like its appearently done by other drivers (like radeonfb can
 take over display from vesafb)?

The emulated video device is a separate device from the synthetic video.
The synthetic driver can only take control of the synthetic video, but not
the emulated video.

Actually, we already have a similar mechanism in ata/ata_piix.c to disable
emulated IDE drive on Hyper-V, so it won't conflict with the synthetic drive.

Thanks,
- Haiyang



RE: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-02-19 Thread Haiyang Zhang
 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Olaf Hering
 Sent: Tuesday, February 19, 2013 1:40 PM
 To: Haiyang Zhang
 Cc: florianschandi...@gmx.de; linux-fb...@vger.kernel.org; KY Srinivasan;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer
 Driver
 
 On Tue, Feb 19, Haiyang Zhang wrote:
 
  The emulated video device is a separate device from the synthetic
 video.
  The synthetic driver can only take control of the synthetic video, but
 not
  the emulated video.
 
 Please add this to the comment above.

Will do.

  Actually, we already have a similar mechanism in ata/ata_piix.c to
 disable
  emulated IDE drive on Hyper-V, so it won't conflict with the synthetic
 drive.
 
 I havent read the vesafb code, but I think it can kind of give up the
 hardware, something ata_piix can not do.

In my test, the vesafb doesn't automatically give up the emulated video device,
unless I add the DMI based mechanism to let it exit on Hyper-V.

Thanks,
- Haiyang



RE: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-02-21 Thread Haiyang Zhang

 From: Olaf Hering
 Sent: Thursday, February 21, 2013 10:53 AM
 To: Haiyang Zhang
 Cc: florianschandi...@gmx.de; linux-fb...@vger.kernel.org; KY Srinivasan; 
 jasow...@redhat.com; linux-kernel@vger.kernel.org; 
 de...@linuxdriverproject.org
 Subject: Re: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer 
 Driver
 
 On Tue, Feb 19, Haiyang Zhang wrote:
 
  In my test, the vesafb doesn't automatically give up the emulated video 
  device,
  unless I add the DMI based mechanism to let it exit on Hyper-V.
 
 From reading the code, it seems to do that via
 do_remove_conflicting_framebuffers(). hypervfb does not set apertures
 etc, so that function is a noop.

We are currently allocating a new framebuffer for hyperv_fb, which is different
from the framebuffer for the emulated video. So this cannot be detected by
do_remove_conflicting_framebuffers() based on apertures_overlap().

 My point is that with this new driver distro kernel will have no console
 output until hypervfb is loaded. On native hardware there is at least
 vesafb which can display something until initrd is running. So if the
 hypervisor allows that hypervfb can shutdown the emulated vesa hardware
 then it should do that.

Since the generic vga driver starts to work early in the boot process, the 
console
messages are still displayed without vesafb. Actually, I didn't see any console 
messages missing when comparing it to the original VM before my patch.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,1/2] hyperv: Add a check for ring_size value

2012-07-25 Thread Haiyang Zhang
It prevents ring_size being set to a too small value.

Reported-by: Jason Wang jasow...@redhat.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/netvsc_drv.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 8e23c08..8c5a1c4 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -47,7 +47,7 @@ struct net_device_context {
struct work_struct work;
 };
 
-
+#define RING_SIZE_MIN 64
 static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, Ring buffer size (# of pages));
@@ -518,6 +518,11 @@ static void __exit netvsc_drv_exit(void)
 
 static int __init netvsc_drv_init(void)
 {
+   if (ring_size  RING_SIZE_MIN) {
+   ring_size = RING_SIZE_MIN;
+   pr_info(Increased ring_size to %d (min allowed)\n,
+   ring_size);
+   }
return vmbus_driver_register(netvsc_drv);
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,2/2] hyperv: Add error handling to rndis_filter_device_add()

2012-07-25 Thread Haiyang Zhang
Reported-by: Jason Wang jasow...@redhat.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/rndis_filter.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index fbf5394..e5d6146 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -804,18 +804,15 @@ int rndis_filter_device_add(struct hv_device *dev,
/* Send the rndis initialization message */
ret = rndis_filter_init_device(rndis_device);
if (ret != 0) {
-   /*
-* TODO: If rndis init failed, we will need to shut down the
-* channel
-*/
+   rndis_filter_device_remove(dev);
+   return ret;
}
 
/* Get the mac address */
ret = rndis_filter_query_device_mac(rndis_device);
if (ret != 0) {
-   /*
-* TODO: shutdown rndis device and the channel
-*/
+   rndis_filter_device_remove(dev);
+   return ret;
}
 
memcpy(device_info-mac_adr, rndis_device-hw_mac_adr, ETH_ALEN);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net,1/1] hyperv: Add support for setting MAC from within guests

2012-07-30 Thread Haiyang Zhang


 -Original Message-
 From: Olaf Hering [mailto:o...@aepfle.de]
 Sent: Monday, July 30, 2012 8:39 AM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; KY Srinivasan; linux-
 ker...@vger.kernel.org; de...@linuxdriverproject.org
 Subject: Re: [PATCH net,1/1] hyperv: Add support for setting MAC from
 within guests
 
 On Tue, Jul 10, Haiyang Zhang wrote:
 
  diff --git a/drivers/net/hyperv/rndis_filter.c
  b/drivers/net/hyperv/rndis_filter.c
  index 981ebb1..fbf5394 100644
  --- a/drivers/net/hyperv/rndis_filter.c
  +++ b/drivers/net/hyperv/rndis_filter.c
  @@ -47,6 +48,7 @@ struct rndis_request {
  struct hv_page_buffer buf;
  /* FIXME: We assumed a fixed size request here. */
  struct rndis_message request_msg;
  +   u8 ext[100];
 
 This array is not referenced in the patch.
 Please add a comment to the code what the purpose of this array is, and why
 its size is 100 bytes.

It's a buffer for the extended info after the RNDIS message. It's referenced 
based
on the data offset in the RNDIS message. 100 byte size is enough for current 
needs, 
and should be sufficient for the near future.

I will add a comment to the code.

Thanks,
- Haiyang



RE: [PATCH 5/5] net/hyperv: Call netif_carrier_off() after register_netdev()

2012-08-14 Thread Haiyang Zhang


 -Original Message-
 From: Ilya Shchepetkov [mailto:shchepet...@ispras.ru]
 Sent: Tuesday, August 14, 2012 6:29 AM
 To: KY Srinivasan
 Cc: Ilya Shchepetkov; Haiyang Zhang; David S. Miller;
 de...@linuxdriverproject.org; net...@vger.kernel.org; linux-
 ker...@vger.kernel.org; ldv-proj...@ispras.ru
 Subject: [PATCH 5/5] net/hyperv: Call netif_carrier_off() after
 register_netdev()
 
 For carrier detection to work properly when binding the driver with a
 cable unplugged, netif_carrier_off() should be called after
 register_netdev(), not before.
 
 Calling netif_carrier_off() before register_netdev() was causing the
 network interface to miss a linkwatch pending event leading to an
 inconsistent state if the link is not up when interface is initialized.
 
 Found by Linux Driver Verification project (linuxtesting.org).
 
 Signed-off-by: Ilya Shchepetkov shchepet...@ispras.ru
 ---
  drivers/net/hyperv/netvsc_drv.c |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/net/hyperv/netvsc_drv.c
 b/drivers/net/hyperv/netvsc_drv.c
 index 8c5a1c4..5734ad0 100644
 --- a/drivers/net/hyperv/netvsc_drv.c
 +++ b/drivers/net/hyperv/netvsc_drv.c
 @@ -416,9 +416,6 @@ static int netvsc_probe(struct hv_device *dev,
   if (!net)
   return -ENOMEM;
 
 - /* Set initial state */
 - netif_carrier_off(net);
 -
   net_device_ctx = netdev_priv(net);
   net_device_ctx-device_ctx = dev;
   hv_set_drvdata(dev, net);
 @@ -441,6 +438,9 @@ static int netvsc_probe(struct hv_device *dev,
   goto out;
   }
 
 + /* Set initial state */
 + netif_carrier_off(net);
 +
   /* Notify the netvsc driver of the new device */
   device_info.ring_size = ring_size;
   ret = rndis_filter_device_add(dev, device_info);

Thanks.

Reviewed-by: Haiyang Zhang haiya...@microsoft.com



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,1/1] hyperv: Add comments for the extended buffer after RNDIS message

2012-08-09 Thread Haiyang Zhang
Reported-by: Olaf Hering o...@aepfle.de
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/net/hyperv/rndis_filter.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 1e88a10..06f8601 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -46,8 +46,14 @@ struct rndis_request {
/* Simplify allocation by having a netvsc packet inline */
struct hv_netvsc_packet pkt;
struct hv_page_buffer buf;
-   /* FIXME: We assumed a fixed size request here. */
+
struct rndis_message request_msg;
+   /*
+* The buffer for the extended info after the RNDIS message. It's
+* referenced based on the data offset in the RNDIS message. Its size
+* is enough for current needs, and should be sufficient for the near
+* future.
+*/
u8 ext[100];
 };
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,1/1] hyperv: Move wait completion msg code into rndis_filter_halt_device()

2012-08-03 Thread Haiyang Zhang
We need to wait for send_completion msg before put_rndis_request() at
the end of rndis_filter_halt_device(). Otherwise, netvsc_send_completion()
may reference freed memory which is overwritten, and cause panic.

Reported-by: Long Li lon...@microsoft.com
Reported-by: Jason Wang jasow...@redhat.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/net/hyperv/netvsc.c   |7 ---
 drivers/net/hyperv/rndis_filter.c |   11 +++
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 6cee291..4a1a5f5 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -383,13 +383,6 @@ int netvsc_device_remove(struct hv_device *device)
unsigned long flags;
 
net_device = hv_get_drvdata(device);
-   spin_lock_irqsave(device-channel-inbound_lock, flags);
-   net_device-destroy = true;
-   spin_unlock_irqrestore(device-channel-inbound_lock, flags);
-
-   /* Wait for all send completions */
-   wait_event(net_device-wait_drain,
-  atomic_read(net_device-num_outstanding_sends) == 0);
 
netvsc_disconnect_vsp(net_device);
 
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index e5d6146..1e88a10 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -718,6 +718,9 @@ static void rndis_filter_halt_device(struct rndis_device 
*dev)
 {
struct rndis_request *request;
struct rndis_halt_request *halt;
+   struct netvsc_device *nvdev = dev-net_dev;
+   struct hv_device *hdev = nvdev-dev;
+   ulong flags;
 
/* Attempt to do a rndis device halt */
request = get_rndis_request(dev, RNDIS_MSG_HALT,
@@ -735,6 +738,14 @@ static void rndis_filter_halt_device(struct rndis_device 
*dev)
dev-state = RNDIS_DEV_UNINITIALIZED;
 
 cleanup:
+   spin_lock_irqsave(hdev-channel-inbound_lock, flags);
+   nvdev-destroy = true;
+   spin_unlock_irqrestore(hdev-channel-inbound_lock, flags);
+
+   /* Wait for all send completions */
+   wait_event(nvdev-wait_drain,
+   atomic_read(nvdev-num_outstanding_sends) == 0);
+
if (request)
put_rndis_request(dev, request);
return;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next,1/1] hyperv: Move wait completion msg code into rndis_filter_halt_device()

2012-08-05 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Friday, August 03, 2012 7:52 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next,1/1] hyperv: Move wait completion msg code
 into rndis_filter_halt_device()
 
 From: Haiyang Zhang haiya...@microsoft.com
 Date: Fri,  3 Aug 2012 12:32:18 -0700
 
  We need to wait for send_completion msg before put_rndis_request() at
  the end of rndis_filter_halt_device(). Otherwise,
  netvsc_send_completion() may reference freed memory which is
 overwritten, and cause panic.
 
  Reported-by: Long Li lon...@microsoft.com
  Reported-by: Jason Wang jasow...@redhat.com
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
 
 This is a bug fix, so applied to 'net'.  Please target your patches properly.
 
 Don't just be afraid that I'll reject the patch if you target it at 'net', and
 therefore just target everything at 'net-next'.  That is certainly worse.

I see. 

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net,1/1] hyperv: Add support for setting MAC from within guests

2012-07-06 Thread Haiyang Zhang
This adds support for setting synthetic NIC MAC address from within Linux
guests. Before using this feature, the option spoofing of MAC address
should be enabled at the Hyper-V manager / Settings of the synthetic
NIC.

Thanks to Kin Cho k...@infoblox.com for the initial implementation and
tests. And, thanks to Long Li lon...@microsoft.com for the debugging
works.

Reported-and-tested-by: Kin Cho k...@infoblox.com
Reported-by: Long Li lon...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h   |1 +
 drivers/net/hyperv/netvsc_drv.c   |   30 +-
 drivers/net/hyperv/rndis_filter.c |   79 +
 3 files changed, 109 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 2857ab0..95ceb35 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -131,6 +131,7 @@ int rndis_filter_send(struct hv_device *dev,
struct hv_netvsc_packet *pkt);
 
 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
+int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
 
 
 #define NVSP_INVALID_PROTOCOL_VERSION  ((u32)0x)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 8f8ed33..8e23c08 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -341,6 +341,34 @@ static int netvsc_change_mtu(struct net_device *ndev, int 
mtu)
return 0;
 }
 
+
+static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
+{
+   struct net_device_context *ndevctx = netdev_priv(ndev);
+   struct hv_device *hdev =  ndevctx-device_ctx;
+   struct sockaddr *addr = p;
+   char save_adr[14];
+   unsigned char save_aatype;
+   int err;
+
+   memcpy(save_adr, ndev-dev_addr, ETH_ALEN);
+   save_aatype = ndev-addr_assign_type;
+
+   err = eth_mac_addr(ndev, p);
+   if (err != 0)
+   return err;
+
+   err = rndis_filter_set_device_mac(hdev, addr-sa_data);
+   if (err != 0) {
+   /* roll back to saved MAC */
+   memcpy(ndev-dev_addr, save_adr, ETH_ALEN);
+   ndev-addr_assign_type = save_aatype;
+   }
+
+   return err;
+}
+
+
 static const struct ethtool_ops ethtool_ops = {
.get_drvinfo= netvsc_get_drvinfo,
.get_link   = ethtool_op_get_link,
@@ -353,7 +381,7 @@ static const struct net_device_ops device_ops = {
.ndo_set_rx_mode =  netvsc_set_multicast_list,
.ndo_change_mtu =   netvsc_change_mtu,
.ndo_validate_addr =eth_validate_addr,
-   .ndo_set_mac_address =  eth_mac_addr,
+   .ndo_set_mac_address =  netvsc_set_mac_addr,
 };
 
 /*
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 981ebb1..fbf5394 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -27,6 +27,7 @@
 #include linux/if_ether.h
 #include linux/netdevice.h
 #include linux/if_vlan.h
+#include linux/nls.h
 
 #include hyperv_net.h
 
@@ -47,6 +48,7 @@ struct rndis_request {
struct hv_page_buffer buf;
/* FIXME: We assumed a fixed size request here. */
struct rndis_message request_msg;
+   u8 ext[100];
 };
 
 static void rndis_filter_send_completion(void *ctx);
@@ -511,6 +513,83 @@ static int rndis_filter_query_device_mac(struct 
rndis_device *dev)
  dev-hw_mac_adr, size);
 }
 
+#define NWADR_STR NetworkAddress
+#define NWADR_STRLEN 14
+
+int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac)
+{
+   struct netvsc_device *nvdev = hv_get_drvdata(hdev);
+   struct rndis_device *rdev = nvdev-extension;
+   struct net_device *ndev = nvdev-ndev;
+   struct rndis_request *request;
+   struct rndis_set_request *set;
+   struct rndis_config_parameter_info *cpi;
+   wchar_t *cfg_nwadr, *cfg_mac;
+   struct rndis_set_complete *set_complete;
+   char macstr[2*ETH_ALEN+1];
+   u32 extlen = sizeof(struct rndis_config_parameter_info) +
+   2*NWADR_STRLEN + 4*ETH_ALEN;
+   int ret, t;
+
+   request = get_rndis_request(rdev, RNDIS_MSG_SET,
+   RNDIS_MESSAGE_SIZE(struct rndis_set_request) + extlen);
+   if (!request)
+   return -ENOMEM;
+
+   set = request-request_msg.msg.set_req;
+   set-oid = RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER;
+   set-info_buflen = extlen;
+   set-info_buf_offset = sizeof(struct rndis_set_request);
+   set-dev_vc_handle = 0;
+
+   cpi = (struct rndis_config_parameter_info *)((ulong)set +
+   set-info_buf_offset);
+   cpi-parameter_name_offset =
+   sizeof(struct rndis_config_parameter_info);
+   /* Multiply by 2 because host needs 2

RE: [PATCH net,1/1] hyperv: Add support for setting MAC from within guests

2012-07-07 Thread Haiyang Zhang


 -Original Message-
 From: Ben Hutchings [mailto:bhutchi...@solarflare.com]
 Sent: Friday, July 06, 2012 8:19 PM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; KY Srinivasan;
 o...@aepfle.de; linux-kernel@vger.kernel.org; de...@linuxdriverproject.org
 Subject: Re: [PATCH net,1/1] hyperv: Add support for setting MAC from
 within guests
 
 On Fri, 2012-07-06 at 14:25 -0700, Haiyang Zhang wrote:
  This adds support for setting synthetic NIC MAC address from within
  Linux guests. Before using this feature, the option spoofing of MAC
 address
  should be enabled at the Hyper-V manager / Settings of the synthetic
  NIC.
 [...]
  +int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac) {
 [...]
  +   t = wait_for_completion_timeout(request-wait_event, 5*HZ);
  +   if (t == 0) {
  +   netdev_err(ndev, timeout before we got a set
 response...\n);
  +   /*
  +* can't put_rndis_request, since we may still receive a
  +* send-completion.
  +*/
  +   return -EBUSY;
  +   } else {
  +   set_complete = request-response_msg.msg.set_complete;
  +   if (set_complete-status != RNDIS_STATUS_SUCCESS)
  +   ret = -EINVAL;
 [...]
 
 Is there a specific error code that indicates the hypervisor is configured not
 to allow MAC address changes?  If so, shouldn't that be translated to return
 EPERM rather than EINVAL?

Will do. 

Thanks,
- Haiyang

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�j:+v���zZ+��+zf���h���~i���z��w���?��)ߢf��^jǫy�m��@A�a���
0��h���i

RE: [PATCH net,1/1] hyperv: Add support for setting MAC from within guests

2012-07-10 Thread Haiyang Zhang


 -Original Message-
 From: Ben Hutchings [mailto:bhutchi...@solarflare.com]
 Sent: Friday, July 06, 2012 8:19 PM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; KY Srinivasan;
 o...@aepfle.de; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net,1/1] hyperv: Add support for setting MAC from
 within guests
 
 On Fri, 2012-07-06 at 14:25 -0700, Haiyang Zhang wrote:
  This adds support for setting synthetic NIC MAC address from within
 Linux
  guests. Before using this feature, the option spoofing of MAC
 address
  should be enabled at the Hyper-V manager / Settings of the synthetic
  NIC.
 [...]
  +int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac)
  +{
 [...]
  +   t = wait_for_completion_timeout(request-wait_event, 5*HZ);
  +   if (t == 0) {
  +   netdev_err(ndev, timeout before we got a set
 response...\n);
  +   /*
  +* can't put_rndis_request, since we may still receive a
  +* send-completion.
  +*/
  +   return -EBUSY;
  +   } else {
  +   set_complete = request-response_msg.msg.set_complete;
  +   if (set_complete-status != RNDIS_STATUS_SUCCESS)
  +   ret = -EINVAL;
 [...]
 
 Is there a specific error code that indicates the hypervisor is
 configured not to allow MAC address changes?  If so, shouldn't that be
 translated to return EPERM rather than EINVAL?

I have check the return code, 0xc00d, which is returned both when MAC
spoofing is not enabled or the parameter contains other errors. So we can't
tell if it permission error or not. I will re-submit this patch still
using EINVAL.

Thanks,
- Haiyang



[PATCH net,1/1] hyperv: Add support for setting MAC from within guests

2012-07-10 Thread Haiyang Zhang
This adds support for setting synthetic NIC MAC address from within Linux
guests. Before using this feature, the option spoofing of MAC address
should be enabled at the Hyper-V manager / Settings of the synthetic
NIC.

Thanks to Kin Cho k...@infoblox.com for the initial implementation and
tests. And, thanks to Long Li lon...@microsoft.com for the debugging
works.

Reported-and-tested-by: Kin Cho k...@infoblox.com
Reported-by: Long Li lon...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h   |1 +
 drivers/net/hyperv/netvsc_drv.c   |   30 +-
 drivers/net/hyperv/rndis_filter.c |   79 +
 3 files changed, 109 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 2857ab0..95ceb35 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -131,6 +131,7 @@ int rndis_filter_send(struct hv_device *dev,
struct hv_netvsc_packet *pkt);
 
 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
+int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
 
 
 #define NVSP_INVALID_PROTOCOL_VERSION  ((u32)0x)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 8f8ed33..8e23c08 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -341,6 +341,34 @@ static int netvsc_change_mtu(struct net_device *ndev, int 
mtu)
return 0;
 }
 
+
+static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
+{
+   struct net_device_context *ndevctx = netdev_priv(ndev);
+   struct hv_device *hdev =  ndevctx-device_ctx;
+   struct sockaddr *addr = p;
+   char save_adr[14];
+   unsigned char save_aatype;
+   int err;
+
+   memcpy(save_adr, ndev-dev_addr, ETH_ALEN);
+   save_aatype = ndev-addr_assign_type;
+
+   err = eth_mac_addr(ndev, p);
+   if (err != 0)
+   return err;
+
+   err = rndis_filter_set_device_mac(hdev, addr-sa_data);
+   if (err != 0) {
+   /* roll back to saved MAC */
+   memcpy(ndev-dev_addr, save_adr, ETH_ALEN);
+   ndev-addr_assign_type = save_aatype;
+   }
+
+   return err;
+}
+
+
 static const struct ethtool_ops ethtool_ops = {
.get_drvinfo= netvsc_get_drvinfo,
.get_link   = ethtool_op_get_link,
@@ -353,7 +381,7 @@ static const struct net_device_ops device_ops = {
.ndo_set_rx_mode =  netvsc_set_multicast_list,
.ndo_change_mtu =   netvsc_change_mtu,
.ndo_validate_addr =eth_validate_addr,
-   .ndo_set_mac_address =  eth_mac_addr,
+   .ndo_set_mac_address =  netvsc_set_mac_addr,
 };
 
 /*
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 981ebb1..fbf5394 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -27,6 +27,7 @@
 #include linux/if_ether.h
 #include linux/netdevice.h
 #include linux/if_vlan.h
+#include linux/nls.h
 
 #include hyperv_net.h
 
@@ -47,6 +48,7 @@ struct rndis_request {
struct hv_page_buffer buf;
/* FIXME: We assumed a fixed size request here. */
struct rndis_message request_msg;
+   u8 ext[100];
 };
 
 static void rndis_filter_send_completion(void *ctx);
@@ -511,6 +513,83 @@ static int rndis_filter_query_device_mac(struct 
rndis_device *dev)
  dev-hw_mac_adr, size);
 }
 
+#define NWADR_STR NetworkAddress
+#define NWADR_STRLEN 14
+
+int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac)
+{
+   struct netvsc_device *nvdev = hv_get_drvdata(hdev);
+   struct rndis_device *rdev = nvdev-extension;
+   struct net_device *ndev = nvdev-ndev;
+   struct rndis_request *request;
+   struct rndis_set_request *set;
+   struct rndis_config_parameter_info *cpi;
+   wchar_t *cfg_nwadr, *cfg_mac;
+   struct rndis_set_complete *set_complete;
+   char macstr[2*ETH_ALEN+1];
+   u32 extlen = sizeof(struct rndis_config_parameter_info) +
+   2*NWADR_STRLEN + 4*ETH_ALEN;
+   int ret, t;
+
+   request = get_rndis_request(rdev, RNDIS_MSG_SET,
+   RNDIS_MESSAGE_SIZE(struct rndis_set_request) + extlen);
+   if (!request)
+   return -ENOMEM;
+
+   set = request-request_msg.msg.set_req;
+   set-oid = RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER;
+   set-info_buflen = extlen;
+   set-info_buf_offset = sizeof(struct rndis_set_request);
+   set-dev_vc_handle = 0;
+
+   cpi = (struct rndis_config_parameter_info *)((ulong)set +
+   set-info_buf_offset);
+   cpi-parameter_name_offset =
+   sizeof(struct rndis_config_parameter_info);
+   /* Multiply by 2 because host needs 2

[PATCH net,1/3] hyperv: Fix the max_xfer_size in RNDIS initialization

2012-10-01 Thread Haiyang Zhang
According to RNDIS specs, Windows sets this size to
0x4000. I use the same value here.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 1e88a10..3cb7486 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -678,8 +678,7 @@ static int rndis_filter_init_device(struct rndis_device 
*dev)
init = request-request_msg.msg.init_req;
init-major_ver = RNDIS_MAJOR_VERSION;
init-minor_ver = RNDIS_MINOR_VERSION;
-   /* FIXME: Use 1536 - rounded ethernet frame size */
-   init-max_xfer_size = 2048;
+   init-max_xfer_size = 0x4000;
 
dev-state = RNDIS_DEV_INITIALIZING;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net,2/3] hyperv: Fix the missing return value in rndis_filter_set_packet_filter()

2012-10-01 Thread Haiyang Zhang
Return ETIMEDOUT when the reply message is not received in time.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 3cb7486..2909dd8 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -641,6 +641,7 @@ int rndis_filter_set_packet_filter(struct rndis_device 
*dev, u32 new_filter)
if (t == 0) {
netdev_err(ndev,
timeout before we got a set response...\n);
+   ret = -ETIMEDOUT;
/*
 * We can't deallocate the request since we may still receive a
 * send completion for it.
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net,3/3] hyperv: Fix page buffer handling in rndis_filter_send_request()

2012-10-01 Thread Haiyang Zhang
Add another page buffer if the request message crossed page boundary.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |   16 +++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 2909dd8..1cd8d45 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -45,7 +45,9 @@ struct rndis_request {
 
/* Simplify allocation by having a netvsc packet inline */
struct hv_netvsc_packet pkt;
-   struct hv_page_buffer buf;
+   /* Set 2 pages for rndis requests crossing page boundary */
+   struct hv_page_buffer buf[2];
+
/* FIXME: We assumed a fixed size request here. */
struct rndis_message request_msg;
u8 ext[100];
@@ -221,6 +223,18 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
packet-page_buf[0].offset =
(unsigned long)req-request_msg  (PAGE_SIZE - 1);
 
+   /* Add one page_buf when request_msg crossing page boundary */
+   if (packet-page_buf[0].offset + packet-page_buf[0].len  PAGE_SIZE) {
+   packet-page_buf_cnt++;
+   packet-page_buf[0].len = PAGE_SIZE -
+   packet-page_buf[0].offset;
+   packet-page_buf[1].pfn = virt_to_phys((void *)req-request_msg
+   + packet-page_buf[0].len)  PAGE_SHIFT;
+   packet-page_buf[1].offset = 0;
+   packet-page_buf[1].len = req-request_msg.msg_len -
+   packet-page_buf[0].len;
+   }
+
packet-completion.send.send_completion_ctx = req;/* packet; */
packet-completion.send.send_completion =
rndis_filter_send_request_completion;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net,1/3] hyperv: Fix the max_xfer_size in RNDIS initialization

2012-10-01 Thread Haiyang Zhang

 From: David Miller [da...@davemloft.net]
 Sent: Monday, October 01, 2012 6:39 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de; 
 jasow...@redhat.com; linux-kernel@vger.kernel.org; 
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net,1/3] hyperv: Fix the max_xfer_size in RNDIS 
 initialization

 These patches do not apply cleanly to the current net-next tree
 which is the only place where patches should be targetted right
 now.

I will rebase the patch set to the net-next tree soon.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net, 3/3] hyperv: Fix page buffer handling in rndis_filter_send_request()

2012-10-02 Thread Haiyang Zhang


 -Original Message-
 From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
 Sent: Tuesday, October 02, 2012 4:39 AM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net, 3/3] hyperv: Fix page buffer handling in
 rndis_filter_send_request()
 
 On Mon, Oct 01, 2012 at 03:30:57PM -0700, Haiyang Zhang wrote:
  Add another page buffer if the request message crossed page boundary.
 
 
 What are the user visible effects of this bug fix?  Please put that
 in the commit message.

Will do.

Thanks,
- Haiyang


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,1/6] hyperv: Fix the max_xfer_size in RNDIS initialization

2012-10-02 Thread Haiyang Zhang
According to RNDIS specs, Windows sets this size to
0x4000. I use the same value here.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 06f8601..1337b64 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -684,8 +684,7 @@ static int rndis_filter_init_device(struct rndis_device 
*dev)
init = request-request_msg.msg.init_req;
init-major_ver = RNDIS_MAJOR_VERSION;
init-minor_ver = RNDIS_MINOR_VERSION;
-   /* FIXME: Use 1536 - rounded ethernet frame size */
-   init-max_xfer_size = 2048;
+   init-max_xfer_size = 0x4000;
 
dev-state = RNDIS_DEV_INITIALIZING;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,2/6] hyperv: Fix the missing return value in rndis_filter_set_packet_filter()

2012-10-02 Thread Haiyang Zhang
Return ETIMEDOUT when the reply message is not received in time.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 1337b64..617eb2e 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -647,6 +647,7 @@ int rndis_filter_set_packet_filter(struct rndis_device 
*dev, u32 new_filter)
if (t == 0) {
netdev_err(ndev,
timeout before we got a set response...\n);
+   ret = -ETIMEDOUT;
/*
 * We can't deallocate the request since we may still receive a
 * send completion for it.
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,4/6] hyperv: Remove extra allocated space for recv_pkt_list elements

2012-10-02 Thread Haiyang Zhang
The receive code path doesn't use the page buffer, so remove the
extra allocated space here.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/hyperv_net.h |2 --
 drivers/net/hyperv/netvsc.c |4 +---
 2 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 95ceb35..d58f28c 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -465,8 +465,6 @@ struct nvsp_message {
 
 #define NETVSC_RECEIVE_BUFFER_ID   0xcafe
 
-#define NETVSC_RECEIVE_SG_COUNT1
-
 /* Preallocated receive packets */
 #define NETVSC_RECEIVE_PACKETLIST_COUNT256
 
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 4a1a5f5..d9c4c03 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -904,9 +904,7 @@ int netvsc_device_add(struct hv_device *device, void 
*additional_info)
INIT_LIST_HEAD(net_device-recv_pkt_list);
 
for (i = 0; i  NETVSC_RECEIVE_PACKETLIST_COUNT; i++) {
-   packet = kzalloc(sizeof(struct hv_netvsc_packet) +
-(NETVSC_RECEIVE_SG_COUNT *
- sizeof(struct hv_page_buffer)), GFP_KERNEL);
+   packet = kzalloc(sizeof(struct hv_netvsc_packet), GFP_KERNEL);
if (!packet)
break;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,6/6] hyperv: Add buffer for extended info after the RNDIS response message.

2012-10-02 Thread Haiyang Zhang
In some response messages, there may be some extended info after the
message.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |   22 --
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index e7e12cf..928148c 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -32,16 +32,19 @@
 #include hyperv_net.h
 
 
+#define RNDIS_EXT_LEN 100
 struct rndis_request {
struct list_head list_ent;
struct completion  wait_event;
 
+   struct rndis_message response_msg;
/*
-* FIXME: We assumed a fixed size response here. If we do ever need to
-* handle a bigger response, we can either define a max response
-* message or add a response buffer variable above this field
+* The buffer for extended info after the RNDIS response message. It's
+* referenced based on the data offset in the RNDIS message. Its size
+* is enough for current needs, and should be sufficient for the near
+* future.
 */
-   struct rndis_message response_msg;
+   u8 response_ext[RNDIS_EXT_LEN];
 
/* Simplify allocation by having a netvsc packet inline */
struct hv_netvsc_packet pkt;
@@ -50,12 +53,10 @@ struct rndis_request {
 
struct rndis_message request_msg;
/*
-* The buffer for the extended info after the RNDIS message. It's
-* referenced based on the data offset in the RNDIS message. Its size
-* is enough for current needs, and should be sufficient for the near
-* future.
+* The buffer for the extended info after the RNDIS request message.
+* It is referenced and sized in a similar way as response_ext.
 */
-   u8 ext[100];
+   u8 request_ext[RNDIS_EXT_LEN];
 };
 
 static void rndis_filter_send_completion(void *ctx);
@@ -274,7 +275,8 @@ static void rndis_filter_receive_response(struct 
rndis_device *dev,
spin_unlock_irqrestore(dev-request_lock, flags);
 
if (found) {
-   if (resp-msg_len = sizeof(struct rndis_message)) {
+   if (resp-msg_len =
+   sizeof(struct rndis_message) + RNDIS_EXT_LEN) {
memcpy(request-response_msg, resp,
   resp-msg_len);
} else {
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,5/6] hyperv: Report actual status in receive completion packet

2012-10-02 Thread Haiyang Zhang
The existing code always reports NVSP_STAT_SUCCESS. This patch adds the
mechanism to report failure when it happens.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/hyperv_net.h   |2 ++
 drivers/net/hyperv/netvsc.c   |   18 --
 drivers/net/hyperv/netvsc_drv.c   |2 ++
 drivers/net/hyperv/rndis_filter.c |   19 ++-
 4 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index d58f28c..5fd6f46 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -35,6 +35,7 @@ struct hv_netvsc_packet;
 /* Represent the xfer page packet which contains 1 or more netvsc packet */
 struct xferpage_packet {
struct list_head list_ent;
+   u32 status;
 
/* # of netvsc packets this xfer packet contains */
u32 count;
@@ -47,6 +48,7 @@ struct xferpage_packet {
 struct hv_netvsc_packet {
/* Bookkeeping stuff */
struct list_head list_ent;
+   u32 status;
 
struct hv_device *device;
bool is_data_pkt;
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index d9c4c03..1cd7748 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -558,7 +558,7 @@ int netvsc_send(struct hv_device *device,
 }
 
 static void netvsc_send_recv_completion(struct hv_device *device,
-   u64 transaction_id)
+   u64 transaction_id, u32 status)
 {
struct nvsp_message recvcompMessage;
int retries = 0;
@@ -571,9 +571,7 @@ static void netvsc_send_recv_completion(struct hv_device 
*device,
recvcompMessage.hdr.msg_type =
NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE;
 
-   /* FIXME: Pass in the status */
-   recvcompMessage.msg.v1_msg.send_rndis_pkt_complete.status =
-   NVSP_STAT_SUCCESS;
+   recvcompMessage.msg.v1_msg.send_rndis_pkt_complete.status = status;
 
 retry_send_cmplt:
/* Send the completion */
@@ -613,6 +611,7 @@ static void netvsc_receive_completion(void *context)
bool fsend_receive_comp = false;
unsigned long flags;
struct net_device *ndev;
+   u32 status = NVSP_STAT_NONE;
 
/*
 * Even though it seems logical to do a GetOutboundNetDevice() here to
@@ -627,6 +626,9 @@ static void netvsc_receive_completion(void *context)
/* Overloading use of the lock. */
spin_lock_irqsave(net_device-recv_pkt_list_lock, flags);
 
+   if (packet-status != NVSP_STAT_SUCCESS)
+   packet-xfer_page_pkt-status = NVSP_STAT_FAIL;
+
packet-xfer_page_pkt-count--;
 
/*
@@ -636,6 +638,7 @@ static void netvsc_receive_completion(void *context)
if (packet-xfer_page_pkt-count == 0) {
fsend_receive_comp = true;
transaction_id = packet-completion.recv.recv_completion_tid;
+   status = packet-xfer_page_pkt-status;
list_add_tail(packet-xfer_page_pkt-list_ent,
  net_device-recv_pkt_list);
 
@@ -647,7 +650,7 @@ static void netvsc_receive_completion(void *context)
 
/* Send a receive completion for the xfer page packet */
if (fsend_receive_comp)
-   netvsc_send_recv_completion(device, transaction_id);
+   netvsc_send_recv_completion(device, transaction_id, status);
 
 }
 
@@ -736,7 +739,8 @@ static void netvsc_receive(struct hv_device *device,
   flags);
 
netvsc_send_recv_completion(device,
-   vmxferpage_packet-d.trans_id);
+   vmxferpage_packet-d.trans_id,
+   NVSP_STAT_FAIL);
 
return;
}
@@ -744,6 +748,7 @@ static void netvsc_receive(struct hv_device *device,
/* Remove the 1st packet to represent the xfer page packet itself */
xferpage_packet = (struct xferpage_packet *)listHead.next;
list_del(xferpage_packet-list_ent);
+   xferpage_packet-status = NVSP_STAT_SUCCESS;
 
/* This is how much we can satisfy */
xferpage_packet-count = count - 1;
@@ -760,6 +765,7 @@ static void netvsc_receive(struct hv_device *device,
list_del(netvsc_packet-list_ent);
 
/* Initialize the netvsc packet */
+   netvsc_packet-status = NVSP_STAT_SUCCESS;
netvsc_packet-xfer_page_pkt = xferpage_packet;
netvsc_packet-completion.recv.recv_completion =
netvsc_receive_completion;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index e9a..f825a62 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -265,6

[PATCH net-next,3/6] hyperv: Fix page buffer handling in rndis_filter_send_request()

2012-10-02 Thread Haiyang Zhang
To prevent possible data corruption in RNDIS requests, add another
page buffer if the request message crossed page boundary.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/rndis_filter.c |   15 ++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 617eb2e..f25f41e 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -45,7 +45,8 @@ struct rndis_request {
 
/* Simplify allocation by having a netvsc packet inline */
struct hv_netvsc_packet pkt;
-   struct hv_page_buffer buf;
+   /* Set 2 pages for rndis requests crossing page boundary */
+   struct hv_page_buffer buf[2];
 
struct rndis_message request_msg;
/*
@@ -227,6 +228,18 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
packet-page_buf[0].offset =
(unsigned long)req-request_msg  (PAGE_SIZE - 1);
 
+   /* Add one page_buf when request_msg crossing page boundary */
+   if (packet-page_buf[0].offset + packet-page_buf[0].len  PAGE_SIZE) {
+   packet-page_buf_cnt++;
+   packet-page_buf[0].len = PAGE_SIZE -
+   packet-page_buf[0].offset;
+   packet-page_buf[1].pfn = virt_to_phys((void *)req-request_msg
+   + packet-page_buf[0].len)  PAGE_SHIFT;
+   packet-page_buf[1].offset = 0;
+   packet-page_buf[1].len = req-request_msg.msg_len -
+   packet-page_buf[0].len;
+   }
+
packet-completion.send.send_completion_ctx = req;/* packet; */
packet-completion.send.send_completion =
rndis_filter_send_request_completion;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net] hyperv: Fix the NETIF_F_SG flag setting in netvsc

2013-07-16 Thread Haiyang Zhang
SG mode is not currently supported by netvsc, so remove this flag for now.
Otherwise, it will be unconditionally enabled by commit ec5f0615642
Kill link between CSUM and SG features
Previously, the SG feature is disabled because CSUM is not set here.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/netvsc_drv.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 4dccead..23a0fff 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -431,8 +431,8 @@ static int netvsc_probe(struct hv_device *dev,
net-netdev_ops = device_ops;
 
/* TODO: Add GSO and Checksum offload */
-   net-hw_features = NETIF_F_SG;
-   net-features = NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_TX;
+   net-hw_features = 0;
+   net-features = NETIF_F_HW_VLAN_CTAG_TX;
 
SET_ETHTOOL_OPS(net, ethtool_ops);
SET_NETDEV_DEV(net, dev-device);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [Regression][v3.10][v3.11] net: Kill link between CSUM and SG features.

2013-07-17 Thread Haiyang Zhang


 -Original Message-
 From: Joseph Salisbury [mailto:joseph.salisb...@canonical.com]
 Sent: Wednesday, July 17, 2013 8:31 AM
 To: Pravin Shelar
 Cc: da...@davemloft.net; ben.how...@canonical.com;
 eduma...@google.com; xiyou.wangc...@gmail.com;
 alexander.h.du...@intel.com; j...@resnulli.us; net...@vger.kernel.org;
 LKML; KY Srinivasan; Haiyang Zhang
 Subject: Re: [Regression][v3.10][v3.11] net: Kill link between CSUM and SG
 features.
 
 On 07/16/2013 04:50 PM, Pravin Shelar wrote:
  On Tue, Jul 16, 2013 at 12:53 PM, Joseph Salisbury
  joseph.salisb...@canonical.com wrote:
  On 07/16/2013 02:29 PM, Pravin Shelar wrote:
  On Tue, Jul 16, 2013 at 11:09 AM, Joseph Salisbury
  joseph.salisb...@canonical.com wrote:
  Hi Pravin,
 
  A bug was opened against the Ubuntu kernel[0].  After a kernel
  bisect, it was found that reverting the following commit resolved this
 bug:
 
  commit ec5f061564238892005257c83565a0b58ec79295
  Author: Pravin B Shelar pshe...@nicira.com
  Date:   Thu Mar 7 09:28:01 2013 +
 
  net: Kill link between CSUM and SG features.
 
 
  The regression was introduced as of v3.10-rc1.
 
  I see that you are the author of this patch, so I wanted to run
  this by you.  I was thinking of requesting a revert for v3.11, but
  I wanted to get your feedback first.
 
 
  This issue was reported before and turning off sg solves problem for
  HyperV driver. Drivers (intel and bnx2x) that I tested works fine
  with this patch. Have you seen the issue on any other NIC?
  Thanks for the feedback.  We have only seen it on Intel hardware.
  Can you send a pointer to the patch? If so, we can provide some
  additional testing.  Do you plan on submitting the patch for inclusion in
 3.11?
 
 
  What I mean is I do not see any problem with the patch that you have
  pointed out on ixgbe and bnx2x platforms. HyperV problem went away
  with disabling sg by ethtool utility.
 Yes, we also see that the problem goes away when disabling sg with ethtool.
 There was a significant improvement in throughput with sg enabled, so it's
 unfortunate it must be disabled.
 
 
  Can you also give me more information about regression you are seeing
  like driver name, features of the NIC set and features of device
  without this patch. Does any other NIC than HyperV having this issue?
 
 Some details info about the HyperV guest can be seen here:
 http://paste.ubuntu.com/5884549/
 
 In that output, you will see that scatter-gather is off, which was done
 manually.
 
 Only a HyperV NIC is having this issue.
I have submitted a patch which has been accepted, and queued for -stable branch
as well: http://patchwork.ozlabs.org/patch/259596/
It removes the NETIF_F_SG flag from the hv_netvsc driver, which doesn't 
currently
support SG mode.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/2] hyperv-fb: add pci stub

2013-10-02 Thread Haiyang Zhang


 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Gerd Hoffmann
 Sent: Wednesday, October 2, 2013 7:55 AM
 Cc: Gerd Hoffmann; KY Srinivasan; Haiyang Zhang; Jean-Christophe Plagniol-
 Villard; Tomi Valkeinen; open list:Hyper-V CORE AND...; open
 list:FRAMEBUFFER LAYER; open list
 Subject: [PATCH 1/2] hyperv-fb: add pci stub
 
 This patch adds a pci stub driver to hyper-fb.  The hyperv framebuffer driver
 will bind to the pci device then, so linux kernel and userspace know there is 
 a
 proper kernel driver for the device active.  lspci shows this for example:
 
 [root@dhcp231 ~]# lspci -vs8
 00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual
 VGA (prog-if 00 [VGA controller])
 Flags: bus master, fast devsel, latency 0, IRQ 11
 Memory at f800 (32-bit, non-prefetchable) [size=64M]
 Expansion ROM at unassigned [disabled]
 Kernel driver in use: hyperv_fb
 
 Another effect is that the xorg vesa driver will not attach to the device and
 thus the Xorg server will automatically use the fbdev driver instead.
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com

Acked-by: Haiyang Zhang haiya...@microsoft.com

Thank you for fixing this!

- Haiyang


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 2/2] hyperv-fb: add blanking support

2013-10-02 Thread Haiyang Zhang
 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Gerd Hoffmann
 Sent: Wednesday, October 2, 2013 7:55 AM
 Cc: Gerd Hoffmann; KY Srinivasan; Haiyang Zhang; Jean-Christophe Plagniol-
 Villard; Tomi Valkeinen; open list:Hyper-V CORE AND...; open
 list:FRAMEBUFFER LAYER; open list
 Subject: [PATCH 2/2] hyperv-fb: add blanking support
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com

Acked-by: Haiyang Zhang haiya...@microsoft.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,v2,0/1] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-15 Thread Haiyang Zhang
In this updated version, I have re-written the send queue selection, which is
based on ndo_select_queue now. I also applied the stop/wake queue for each
queue separately as suggested by reviewers.

Tom Herbert therb...@google.com has submitted a Toeplitz library function with
some optimization. But it's not accepted yet. I'm still using my Toeplitz
implementation in netvsc module. Please accept my patch if no other issues, 
because it already provides significant performance enhancement at current
state. I will be happy to switch to the Toeplitz library function when it's
accepted in the future.

Haiyang Zhang (1):
  hyperv: Add support for virtual Receive Side Scaling (vRSS)

 drivers/net/hyperv/hyperv_net.h   |  111 ++-
 drivers/net/hyperv/netvsc.c   |  132 +-
 drivers/net/hyperv/netvsc_drv.c   |  104 -
 drivers/net/hyperv/rndis_filter.c |  186 -
 4 files changed, 500 insertions(+), 33 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,v2,1/1] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-15 Thread Haiyang Zhang
This feature allows multiple channels to be used by each virtual NIC.
It is available on Hyper-V host 2012 R2.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h   |  111 ++-
 drivers/net/hyperv/netvsc.c   |  132 +-
 drivers/net/hyperv/netvsc_drv.c   |  104 -
 drivers/net/hyperv/rndis_filter.c |  186 -
 4 files changed, 500 insertions(+), 33 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 13010b4..f67292f 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -28,6 +28,98 @@
 #include linux/hyperv.h
 #include linux/rndis.h
 
+/* RSS related */
+#define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203  /* query only */
+#define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204  /* query and set */
+
+#define NDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88
+#define NDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89
+
+#define NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2
+#define NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2
+
+struct ndis_obj_header {
+   u8 type;
+   u8 rev;
+   u16 size;
+} __packed;
+
+
+/* ndis_recv_scale_cap/cap_flag */
+#define NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x0100
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR   0x0200
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_DPC   0x0400
+#define NDIS_RSS_CAPS_USING_MSI_X 0x0800
+#define NDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS  0x1000
+#define NDIS_RSS_CAPS_SUPPORTS_MSI_X  0x2000
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4  0x0100
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6  0x0200
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX   0x0400
+
+struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
+   struct ndis_obj_header hdr;
+   u32 cap_flag;
+   u32 num_int_msg;
+   u32 num_recv_que;
+   u16 num_indirect_tabent;
+} __packed;
+
+
+/* ndis_recv_scale_param flags */
+#define NDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001
+#define NDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED0x0002
+#define NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED   0x0004
+#define NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008
+#define NDIS_RSS_PARAM_FLAG_DISABLE_RSS0x0010
+
+/* Hash info bits */
+#define NDIS_HASH_FUNC_TOEPLITZ 0x0001
+#define NDIS_HASH_IPV4  0x0100
+#define NDIS_HASH_TCP_IPV4  0x0200
+#define NDIS_HASH_IPV6  0x0400
+#define NDIS_HASH_IPV6_EX   0x0800
+#define NDIS_HASH_TCP_IPV6  0x1000
+#define NDIS_HASH_TCP_IPV6_EX   0x2000
+
+#define NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4)
+#define NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2   40
+
+#define ITAB_NUM 128
+#define HASH_KEYLEN NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
+extern u8 hash_key[];
+
+struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
+   struct ndis_obj_header hdr;
+
+   /* Qualifies the rest of the information */
+   u16 flag;
+
+   /* The base CPU number to do receive processing. not used */
+   u16 base_cpu_number;
+
+   /* This describes the hash function and type being enabled */
+   u32 hashinfo;
+
+   /* The size of indirection table array */
+   u16 indirect_tabsize;
+
+   /* The offset of the indirection table from the beginning of this
+* structure
+*/
+   u32 indirect_taboffset;
+
+   /* The size of the hash secret key */
+   u16 hashkey_size;
+
+   /* The offset of the secret key from the beginning of this structure */
+   u32 kashkey_offset;
+
+   u32 processor_masks_offset;
+   u32 num_processor_masks;
+   u32 processor_masks_entry_size;
+};
+
+
 /* Fwd declaration */
 struct hv_netvsc_packet;
 struct ndis_tcp_ip_checksum_info;
@@ -39,6 +131,8 @@ struct xferpage_packet {
 
/* # of netvsc packets this xfer packet contains */
u32 count;
+
+   struct vmbus_channel *channel;
 };
 
 /*
@@ -54,6 +148,9 @@ struct hv_netvsc_packet {
bool is_data_pkt;
u16 vlan_tci;
 
+   u16 q_idx;
+   struct vmbus_channel *channel;
+
/*
 * Valid only for receives when we break a xfer page packet
 * into multiple netvsc packets
@@ -120,6 +217,7 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
struct ndis_tcp_ip_checksum_info *csum_info);
+extern void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
 int rndis_filter_device_add(struct hv_device *dev,
@@ -131,6 +229,7 @@ int rndis_filter_receive(struct hv_device *dev,
 int rndis_filter_set_packet_filter(struct

RE: [PATCH net-next,v2,1/1] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-17 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Monday, March 17, 2014 4:20 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next,v2,1/1] hyperv: Add support for virtual Receive
 Side Scaling (vRSS)
 
 From: Haiyang Zhang haiya...@microsoft.com
 Date: Sat, 15 Mar 2014 10:18:07 -0700
 
  -   if (netif_queue_stopped(ndev)  !net_device-start_remove
 
  -   (hv_ringbuf_avail_percent(device-channel-
 outbound)
  -RING_AVAIL_PERCENT_HIWATER ||
  -   num_outstanding_sends  1))
  -   netif_wake_queue(ndev);
  +   if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx))
  +!net_device-start_remove 
  +   (hv_ringbuf_avail_percent(channel-outbound)
  +RING_AVAIL_PERCENT_HIWATER || queue_sends 
 1))
  +   netif_tx_wake_queue(netdev_get_tx_queue(
  +   ndev, q_idx));
 
 This is not indented properly, make it:
 
   if (A  B 
   (C 
  D || E  1))
 
 Never put operators at the beginning of a conditional line, always at the end.

I will do. 

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next,v2,1/1] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-17 Thread Haiyang Zhang


 -Original Message-
 From: Ben Hutchings [mailto:b...@decadent.org.uk]
 Sent: Monday, March 17, 2014 4:28 PM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; KY Srinivasan;
 o...@aepfle.de; jasow...@redhat.com; linux-kernel@vger.kernel.org;
 driverdev-de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next,v2,1/1] hyperv: Add support for virtual Receive
 Side Scaling (vRSS)
 
 On Sat, 2014-03-15 at 10:18 -0700, Haiyang Zhang wrote:
 [...]
   #define RING_SIZE_MIN 64
  -static int ring_size = 128;
  +int ring_size = 128;
   module_param(ring_size, int, S_IRUGO);  MODULE_PARM_DESC(ring_size,
  Ring buffer size (# of pages));
 
 You have to add some driver-specific prefix to the variable name if it is 
 going to
 be extern.  (And use module_param_named to avoid changing the parameter
 name too.)
 
 [...]
  +u8 hash_key[HASH_KEYLEN] = {
  +   0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
  +   0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
  +   0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
  +   0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
  +   0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa };
 [...]
 
 Same for this one.
 
I will do.

Thanks,
- Haiyang


RE: [PATCH v3 3/4] hyperv-fb: add support for generation 2 virtual machines.

2014-02-24 Thread Haiyang Zhang


 -Original Message-
 From: Gerd Hoffmann [mailto:kra...@redhat.com]
 Sent: Monday, February 24, 2014 8:17 AM
 To: linux-fb...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org; gre...@linuxfoundation.org; KY Srinivasan;
 Abhishek Gupta (LIS); Haiyang Zhang; jasow...@redhat.com;
 tomi.valkei...@ti.com; de...@linuxdriverproject.org; Gerd Hoffmann; Jean-
 Christophe Plagniol-Villard
 Subject: [PATCH v3 3/4] hyperv-fb: add support for generation 2 virtual
 machines.
 
 UEFI-based generation 2 virtual machines support vmbus devices only.
 There is no pci bus.  Thus they use a different mechanism for the graphics
 framebuffer:  Instead of using the vga pci bar a chunk of memory muct be
 allocated from the hyperv mmio region declared using APCI.  This patch
 implements support for it.
 
 Based on a patch by Haiyang Zhang haiya...@microsoft.com
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com
 ---
  drivers/video/hyperv_fb.c | 86 +-
 -
  1 file changed, 60 insertions(+), 26 deletions(-)
 
 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c index
 130708f..135d8cd 100644
 --- a/drivers/video/hyperv_fb.c
 +++ b/drivers/video/hyperv_fb.c
 @@ -42,6 +42,7 @@
  #include linux/completion.h
  #include linux/fb.h
  #include linux/pci.h
 +#include linux/efi.h
 
  #include linux/hyperv.h
 
 @@ -212,6 +213,7 @@ struct synthvid_msg {
 
  struct hvfb_par {
   struct fb_info *info;
 + struct resource mem;
   bool fb_ready; /* fb device is ready */
   struct completion wait;
   u32 synthvid_version;
 @@ -460,13 +462,13 @@ static int synthvid_connect_vsp(struct hv_device
 *hdev)
   goto error;
   }
 
 - if (par-synthvid_version == SYNTHVID_VERSION_WIN7) {
 + if (par-synthvid_version == SYNTHVID_VERSION_WIN7)
   screen_depth = SYNTHVID_DEPTH_WIN7;
 - screen_fb_size = SYNTHVID_FB_SIZE_WIN7;
 - } else {
 + else
   screen_depth = SYNTHVID_DEPTH_WIN8;
 - screen_fb_size = SYNTHVID_FB_SIZE_WIN8;
 - }
 +
 + screen_fb_size = hdev-channel-offermsg.offer.
 + mmio_megabytes * 1024 * 1024;
 
   return 0;
 
 @@ -627,26 +629,46 @@ static void hvfb_get_option(struct fb_info *info)
  /* Get framebuffer memory from Hyper-V video pci space */  static int
 hvfb_getmem(struct fb_info *info)  {
 - struct pci_dev *pdev;
 - ulong fb_phys;
 + struct hvfb_par *par = info-par;
 + struct pci_dev *pdev  = NULL;
   void __iomem *fb_virt;
 + int gen2vm = efi_enabled(EFI_BOOT);
 + int ret;
 
 - pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
 + par-mem.name = hyperv_fb;

Please use KBUILD_MODNAME, so that the naming is consistent.

Thanks,
- Haiyang

 + par-mem.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 + if (gen2vm) {
 + ret = allocate_resource(hyperv_mmio, par-mem,
 + screen_fb_size,
 + 0, -1,
 + screen_fb_size,
 + NULL, NULL);
 + if (ret != 0) {
 + pr_err(Unable to allocate framebuffer memory\n);
 + return -ENODEV;
 + }
 + } else {
 + pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
 PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
 - if (!pdev) {
 - pr_err(Unable to find PCI Hyper-V video\n);
 - return -ENODEV;
 - }
 + if (!pdev) {
 + pr_err(Unable to find PCI Hyper-V video\n);
 + return -ENODEV;
 + }
 
 - if (!(pci_resource_flags(pdev, 0)  IORESOURCE_MEM) ||
 - pci_resource_len(pdev, 0)  screen_fb_size)
 - goto err1;
 + if (!(pci_resource_flags(pdev, 0)  IORESOURCE_MEM) ||
 + pci_resource_len(pdev, 0)  screen_fb_size)
 + goto err1;
 
 - fb_phys = pci_resource_end(pdev, 0) - screen_fb_size + 1;
 - if (!request_mem_region(fb_phys, screen_fb_size,
 KBUILD_MODNAME))
 - goto err1;
 + par-mem.end = pci_resource_end(pdev, 0);
 + par-mem.start = par-mem.end - screen_fb_size + 1;
 + ret = request_resource(pdev-resource[0], par-mem);
 + if (ret != 0) {
 + pr_err(Unable to request framebuffer memory\n);
 + goto err1;
 + }
 + }
 
 - fb_virt = ioremap(fb_phys, screen_fb_size);
 + fb_virt = ioremap(par-mem.start, screen_fb_size);
   if (!fb_virt)
   goto err2;
 
 @@ -654,30 +676,42 @@ static int hvfb_getmem(struct fb_info *info)
   if (!info-apertures)
   goto err3;
 
 - info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
 - info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
 - info-fix.smem_start = fb_phys

RE: [PATCH v3 4/4] hyperv-fb: kick off efifb early

2014-02-24 Thread Haiyang Zhang


 -Original Message-
 From: Gerd Hoffmann [mailto:kra...@redhat.com]
 Sent: Monday, February 24, 2014 8:17 AM
 To: linux-fb...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org; gre...@linuxfoundation.org; KY Srinivasan;
 Abhishek Gupta (LIS); Haiyang Zhang; jasow...@redhat.com;
 tomi.valkei...@ti.com; de...@linuxdriverproject.org; Gerd Hoffmann; Jean-
 Christophe Plagniol-Villard
 Subject: [PATCH v3 4/4] hyperv-fb: kick off efifb early
 
 Remove firmware framebuffer before initializing hyperv-fb.  Needed
 on gen2 virtual machines.   Letting register_framebuffer handle the
 switchover results in efifb still being active while hyperv graphics are
 initialized, which in turn can make the linux kernel hang.
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com
 ---
  drivers/video/hyperv_fb.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c index
 135d8cd..a570836 100644
 --- a/drivers/video/hyperv_fb.c
 +++ b/drivers/video/hyperv_fb.c
 @@ -683,6 +683,7 @@ static int hvfb_getmem(struct fb_info *info)
   info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
   info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
   }
 + remove_conflicting_framebuffers(info-apertures, hyperv-fb, false);

Please use KBUILD_MODNAME, so that the naming is consistent.

Thanks,
- Haiyang

 
   info-fix.smem_start = par-mem.start;
   info-fix.smem_len = screen_fb_size;
 --
 1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v4 2/2] hyperv-fb: kick off efifb early

2014-02-25 Thread Haiyang Zhang


 -Original Message-
 From: Gerd Hoffmann [mailto:kra...@redhat.com]
 Sent: Tuesday, February 25, 2014 7:29 AM
 To: linux-fb...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org; gre...@linuxfoundation.org; KY Srinivasan;
 Abhishek Gupta (LIS); Haiyang Zhang; jasow...@redhat.com;
 tomi.valkei...@ti.com; de...@linuxdriverproject.org; Gerd Hoffmann; Jean-
 Christophe Plagniol-Villard
 Subject: [PATCH v4 2/2] hyperv-fb: kick off efifb early
 
 Remove firmware framebuffer before initializing hyperv-fb.  Needed
 on gen2 virtual machines.   Letting register_framebuffer handle the
 switchover results in efifb still being active while hyperv graphics are
 initialized, which in turn can make the linux kernel hang.
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com
 ---
  drivers/video/hyperv_fb.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c index
 b7b3dd0..1b11886 100644
 --- a/drivers/video/hyperv_fb.c
 +++ b/drivers/video/hyperv_fb.c
 @@ -683,6 +683,7 @@ static int hvfb_getmem(struct fb_info *info)
   info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
   info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
   }
 + remove_conflicting_framebuffers(info-apertures,
 KBUILD_MODNAME,
 +false);

Thanks for the updates. I'm concerned about, after removing efifb, 
if synthvid_send_config(hdev) fails, then there will be no video driver
available. Is there a way to bring the generic driver back if 
synthvid_send_config(hdev) fails?

If no way to recover the generic driver, please limit the early
remove_conflicting_framebuffers() to Gen2 VM only.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v5 1/2] hyperv-fb: add support for generation 2 virtual machines.

2014-02-26 Thread Haiyang Zhang


 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Gerd Hoffmann
 Sent: Wednesday, February 26, 2014 5:51 AM
 To: linux-fb...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org; gre...@linuxfoundation.org; KY Srinivasan;
 Abhishek Gupta (LIS); Haiyang Zhang; jasow...@redhat.com;
 tomi.valkei...@ti.com; de...@linuxdriverproject.org; Gerd Hoffmann; Jean-
 Christophe Plagniol-Villard
 Subject: [PATCH v5 1/2] hyperv-fb: add support for generation 2 virtual
 machines.
 
 UEFI-based generation 2 virtual machines support vmbus devices only.
 There is no pci bus.  Thus they use a different mechanism for the
 graphics framebuffer:  Instead of using the vga pci bar a chunk of
 memory muct be allocated from the hyperv mmio region declared using
 APCI.  This patch implements support for it.
 
 Based on a patch by Haiyang Zhang haiya...@microsoft.com
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com

Thank you!

Signed-off-by: Haiyang Zhang haiya...@microsoft.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v5 2/2] hyperv-fb: kick off efifb early

2014-02-26 Thread Haiyang Zhang


 -Original Message-
 From: Gerd Hoffmann [mailto:kra...@redhat.com]
 Sent: Wednesday, February 26, 2014 5:51 AM
 To: linux-fb...@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org; gre...@linuxfoundation.org; KY Srinivasan;
 Abhishek Gupta (LIS); Haiyang Zhang; jasow...@redhat.com;
 tomi.valkei...@ti.com; de...@linuxdriverproject.org; Gerd Hoffmann; Jean-
 Christophe Plagniol-Villard
 Subject: [PATCH v5 2/2] hyperv-fb: kick off efifb early
 
 Remove firmware framebuffer before initializing hyperv-fb.  Needed
 on gen2 virtual machines.   Letting register_framebuffer handle the
 switchover results in efifb still being active while hyperv graphics
 are initialized, which in turn can make the linux kernel hang.
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com

Thank you!

Signed-off-by: Haiyang Zhang haiya...@microsoft.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next] hyperv: Move state setting for link query

2014-03-03 Thread Haiyang Zhang
It moves the state setting for query into rndis_filter_receive_response().
All callbacks including query-complete and status-callback are synchronized
by channel-inbound_lock. This prevents pentential race between them.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/net/hyperv/rndis_filter.c |   21 -
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index f0cc8ef..6a9f602 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -240,6 +240,22 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
return ret;
 }
 
+static void rndis_set_link_state(struct rndis_device *rdev,
+struct rndis_request *request)
+{
+   u32 link_status;
+   struct rndis_query_complete *query_complete;
+
+   query_complete = request-response_msg.msg.query_complete;
+
+   if (query_complete-status == RNDIS_STATUS_SUCCESS 
+   query_complete-info_buflen == sizeof(u32)) {
+   memcpy(link_status, (void *)((unsigned long)query_complete +
+  query_complete-info_buf_offset), sizeof(u32));
+   rdev-link_state = link_status != 0;
+   }
+}
+
 static void rndis_filter_receive_response(struct rndis_device *dev,
   struct rndis_message *resp)
 {
@@ -269,6 +285,10 @@ static void rndis_filter_receive_response(struct 
rndis_device *dev,
sizeof(struct rndis_message) + RNDIS_EXT_LEN) {
memcpy(request-response_msg, resp,
   resp-msg_len);
+   if (request-request_msg.ndis_msg_type ==
+   RNDIS_MSG_QUERY  request-request_msg.msg.
+   query_req.oid == RNDIS_OID_GEN_MEDIA_CONNECT_STATUS)
+   rndis_set_link_state(dev, request);
} else {
netdev_err(ndev,
rndis response buffer overflow 
@@ -617,7 +637,6 @@ static int rndis_filter_query_device_link_status(struct 
rndis_device *dev)
ret = rndis_filter_query_device(dev,
  RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
  link_status, size);
-   dev-link_state = (link_status != 0) ? true : false;
 
return ret;
 }
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next] hyperv: Move state setting for link query

2014-03-04 Thread Haiyang Zhang


 -Original Message-
 From: Jason Wang [mailto:jasow...@redhat.com]
 Sent: Monday, March 3, 2014 10:10 PM
 To: Haiyang Zhang; da...@davemloft.net; net...@vger.kernel.org
 Cc: KY Srinivasan; o...@aepfle.de; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next] hyperv: Move state setting for link query
 
 On 03/04/2014 07:54 AM, Haiyang Zhang wrote:
  It moves the state setting for query into rndis_filter_receive_response().
  All callbacks including query-complete and status-callback are
  synchronized by channel-inbound_lock. This prevents pentential race
 between them.
 
 This still looks racy to me. The problem is workqueue is not synchronized with
 those here.
 
 Consider the following case in netvsc_link_change():
 
 if (rdev-link_state) {
 ... receive interrupt ...
 rndis_filter_receice_response() which changes rdev-link_state
 ...
 netif_carrier_off()
 }
 
 And also it need to schedule a work otherwise the link status is out of sync.

The rndis_filter_query_device_link_status() makes the query and wait for the
complete message, including set state, before returning.

The rndis_filter_query_device_link_status() is called from 
rndis_filter_device_add(),
which is called from either netvsc_change_mtu() or netvsc_probe().

The change_mtu() and netvsc_link_change() are synchronized by rtnl_lock().
In netvsc_probe(), the status query  complete happens before 
register_netdev(), and
the netvsc_linkstatus_callback() schedules the work only after netdevice is 
registered.
So, there are no race in either case.

The carrier_on/off work will be scheduled when netvsc_open() is called. Then,
the status will be updated based on the latest link_state.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next] hyperv: Move state setting for link query

2014-03-04 Thread Haiyang Zhang


 -Original Message-
 From: Jason Wang [mailto:jasow...@redhat.com]
 Sent: Monday, March 3, 2014 10:10 PM
 To: Haiyang Zhang; da...@davemloft.net; net...@vger.kernel.org
 Cc: KY Srinivasan; o...@aepfle.de; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next] hyperv: Move state setting for link query
 
 On 03/04/2014 07:54 AM, Haiyang Zhang wrote:
  It moves the state setting for query into rndis_filter_receive_response().
  All callbacks including query-complete and status-callback are
  synchronized by channel-inbound_lock. This prevents pentential race
 between them.
 
 This still looks racy to me. The problem is workqueue is not synchronized with
 those here.
 
 Consider the following case in netvsc_link_change():
 
 if (rdev-link_state) {
 ... receive interrupt ...
 rndis_filter_receice_response() which changes rdev-link_state
 ...
 netif_carrier_off()
 }
 
 And also it need to schedule a work otherwise the link status is out of sync.

I will update this patch to schedule a work by the end of probe function.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,v2] hyperv: Move state setting for link query

2014-03-04 Thread Haiyang Zhang
It moves the state setting for query into rndis_filter_receive_response().
All callbacks including query-complete and status-callback are synchronized
by channel-inbound_lock. This prevents pentential race between them.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/net/hyperv/netvsc_drv.c   |4 
 drivers/net/hyperv/rndis_filter.c |   21 -
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9ef6be9..bb27b3e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -442,6 +442,8 @@ static int netvsc_probe(struct hv_device *dev,
if (!net)
return -ENOMEM;
 
+   netif_carrier_off(net);
+
net_device_ctx = netdev_priv(net);
net_device_ctx-device_ctx = dev;
hv_set_drvdata(dev, net);
@@ -473,6 +475,8 @@ static int netvsc_probe(struct hv_device *dev,
pr_err(Unable to register netdev.\n);
rndis_filter_device_remove(dev);
free_netdev(net);
+   } else {
+   schedule_delayed_work(net_device_ctx-dwork, 0);
}
 
return ret;
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index f0cc8ef..6a9f602 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -240,6 +240,22 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
return ret;
 }
 
+static void rndis_set_link_state(struct rndis_device *rdev,
+struct rndis_request *request)
+{
+   u32 link_status;
+   struct rndis_query_complete *query_complete;
+
+   query_complete = request-response_msg.msg.query_complete;
+
+   if (query_complete-status == RNDIS_STATUS_SUCCESS 
+   query_complete-info_buflen == sizeof(u32)) {
+   memcpy(link_status, (void *)((unsigned long)query_complete +
+  query_complete-info_buf_offset), sizeof(u32));
+   rdev-link_state = link_status != 0;
+   }
+}
+
 static void rndis_filter_receive_response(struct rndis_device *dev,
   struct rndis_message *resp)
 {
@@ -269,6 +285,10 @@ static void rndis_filter_receive_response(struct 
rndis_device *dev,
sizeof(struct rndis_message) + RNDIS_EXT_LEN) {
memcpy(request-response_msg, resp,
   resp-msg_len);
+   if (request-request_msg.ndis_msg_type ==
+   RNDIS_MSG_QUERY  request-request_msg.msg.
+   query_req.oid == RNDIS_OID_GEN_MEDIA_CONNECT_STATUS)
+   rndis_set_link_state(dev, request);
} else {
netdev_err(ndev,
rndis response buffer overflow 
@@ -617,7 +637,6 @@ static int rndis_filter_query_device_link_status(struct 
rndis_device *dev)
ret = rndis_filter_query_device(dev,
  RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
  link_status, size);
-   dev-link_state = (link_status != 0) ? true : false;
 
return ret;
 }
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next] hyperv: Move state setting for link query

2014-03-05 Thread Haiyang Zhang


 -Original Message-
 From: Jason Wang [mailto:jasow...@redhat.com]
 Sent: Wednesday, March 5, 2014 12:57 AM
 To: Haiyang Zhang; da...@davemloft.net; net...@vger.kernel.org
 Cc: KY Srinivasan; o...@aepfle.de; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next] hyperv: Move state setting for link query
 
 On 03/05/2014 12:57 AM, Haiyang Zhang wrote:
 
  -Original Message-
  From: Jason Wang [mailto:jasow...@redhat.com]
  Sent: Monday, March 3, 2014 10:10 PM
  To: Haiyang Zhang; da...@davemloft.net; net...@vger.kernel.org
  Cc: KY Srinivasan; o...@aepfle.de; linux-kernel@vger.kernel.org;
  driverdev- de...@linuxdriverproject.org
  Subject: Re: [PATCH net-next] hyperv: Move state setting for link
  query
 
  On 03/04/2014 07:54 AM, Haiyang Zhang wrote:
  It moves the state setting for query into rndis_filter_receive_response().
  All callbacks including query-complete and status-callback are
  synchronized by channel-inbound_lock. This prevents pentential race
  between them.
 
  This still looks racy to me. The problem is workqueue is not
  synchronized with those here.
 
  Consider the following case in netvsc_link_change():
 
  if (rdev-link_state) {
  ... receive interrupt ...
  rndis_filter_receice_response() which changes rdev-link_state
  ...
  netif_carrier_off()
  }
 
  And also it need to schedule a work otherwise the link status is out of 
  sync.
  The rndis_filter_query_device_link_status() makes the query and wait
  for the complete message, including set state, before returning.
 
  The rndis_filter_query_device_link_status() is called from
  rndis_filter_device_add(), which is called from either netvsc_change_mtu()
 or netvsc_probe().
 
  The change_mtu() and netvsc_link_change() are synchronized by
 rtnl_lock().
  In netvsc_probe(), the status query  complete happens before
  register_netdev(), and the netvsc_linkstatus_callback() schedules the work
 only after netdevice is registered.
  So, there are no race in either case.
 
  The carrier_on/off work will be scheduled when netvsc_open() is
  called. Then, the status will be updated based on the latest link_state.
 
  Thanks,
  - Haiyang
 
 
 I see. Then if the link status is changing during mtu changing in guest.
 Looks like we may miss a link status updating?

When changing mtu, rndis_filter_device_add() is called, and host will send a 
link
status call back immediately after connect-to-netvsp, no matter the link is 
changing
or not. This will schedule a work to update the status.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: Hyper-V Synthetic Video Frame Buffer Driver may distort top two lines of console

2014-03-06 Thread Haiyang Zhang


 -Original Message-
 From: KY Srinivasan
 Sent: Thursday, March 6, 2014 4:51 PM
 To: Brian Wong; linux-kernel@vger.kernel.org; Haiyang Zhang
 Subject: RE: Hyper-V Synthetic Video Frame Buffer Driver may distort top
 two lines of console
 
 
 
  -Original Message-
  From: Brian Wong [mailto:draconicpengu...@yahoo.com]
  Sent: Friday, March 7, 2014 3:19 AM
  To: KY Srinivasan; linux-kernel@vger.kernel.org
  Subject: Re: Hyper-V Synthetic Video Frame Buffer Driver may distort
  top two lines of console
 
  On 3/6/2014 4:05 PM, Brian Wong wrote:
   On 3/6/2014 3:41 PM, Brian Wong wrote:
   I've identified another possible bug in the Hyper-V drivers: When
   the Hyper-V Synthetic Video Frame Buffer Driver is built into the
   kernel, and the VM is paused and continued, the top two lines of
   the console may become distorted. See the image at
 http://imgur.com/kIExFP3.
  
   Can someone look into it?
 Haiyang (copied here) will look into it.
 

It's a known issue. The root cause is not very clear yet.
It doesn't affect system functions. But we will look into it 
further.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next] hyperv: Change the receive buffer size for legacy hosts

2014-03-09 Thread Haiyang Zhang
Due to a bug in the Hyper-V host verion 2008R2, we need to use a slightly 
smaller
receive buffer size, otherwise the buffer will not be accepted by the legacy 
hosts.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h |1 +
 drivers/net/hyperv/netvsc.c |6 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 39fc230..ea5f182 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -516,6 +516,7 @@ struct nvsp_message {
 #define NETVSC_MTU 65536
 
 #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16)  /* 16MB */
+#define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY  (1024*1024*15)  /* 15MB */
 
 #define NETVSC_RECEIVE_BUFFER_ID   0xcafe
 
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 1a0280d..daddea2 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -365,6 +365,11 @@ static int netvsc_connect_vsp(struct hv_device *device)
goto cleanup;
 
/* Post the big receive buffer to NetVSP */
+   if (net_device-nvsp_version = NVSP_PROTOCOL_VERSION_2)
+   net_device-recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY;
+   else
+   net_device-recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
+
ret = netvsc_init_recv_buf(device);
 
 cleanup:
@@ -898,7 +903,6 @@ int netvsc_device_add(struct hv_device *device, void 
*additional_info)
ndev = net_device-ndev;
 
/* Initialize the NetVSC channel extension */
-   net_device-recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
spin_lock_init(net_device-recv_pkt_list_lock);
 
INIT_LIST_HEAD(net_device-recv_pkt_list);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] hyperv_fb: Add screen refresh after pause/resume operation

2014-01-13 Thread Haiyang Zhang
This is necessary because after VM is pause/resumed, some portion of
the screen may need refresh.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/video/hyperv_fb.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..bbcc8c0 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -218,6 +218,7 @@ struct hvfb_par {
 
struct delayed_work dwork;
bool update;
+   bool xrefresh;
 
u32 pseudo_palette[16];
u8 init_buf[MAX_VMBUS_PKT_SIZE];
@@ -369,7 +370,7 @@ static void synthvid_recv_sub(struct hv_device *hdev)
synthvid_send_situ(hdev);
}
 
-   par-update = msg-feature_chg.is_dirt_needed;
+   par-xrefresh = par-update = msg-feature_chg.is_dirt_needed;
if (par-update)
schedule_delayed_work(par-dwork, HVFB_UPDATE_DELAY);
}
@@ -522,6 +523,13 @@ static void hvfb_update_work(struct work_struct *w)
 {
struct hvfb_par *par = container_of(w, struct hvfb_par, dwork.work);
struct fb_info *info = par-info;
+   char *argv[] = {/usr/bin/xrefresh, -display, :0.0, NULL};
+   char *envp[] = {HOME=/, PATH=/sbin:/usr/sbin:/bin:/usr/bin, NULL };
+
+   if (par-xrefresh) {
+   par-xrefresh = false;
+   call_usermodehelper(argv[0], argv, envp, UMH_NO_WAIT);
+   }
 
if (par-fb_ready)
synthvid_update(info);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net,v3] hyperv: Fix the carrier status setting

2014-02-13 Thread Haiyang Zhang


 -Original Message-
 From: Jason Wang [mailto:jasow...@redhat.com]
 Sent: Wednesday, February 12, 2014 10:52 PM
 To: Haiyang Zhang; da...@davemloft.net; net...@vger.kernel.org
 Cc: KY Srinivasan; o...@aepfle.de; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net,v3] hyperv: Fix the carrier status setting
 
 On 02/13/2014 08:54 AM, Haiyang Zhang wrote:
  Without this patch, the cat /sys/class/net/ethN/operstate shows
  unknown, and ethtool ethN shows Link detected: yes, when VM
  boots up with or without vNIC connected.
 
  This patch fixed the problem.
 
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
  ---
   drivers/net/hyperv/netvsc_drv.c |   53
 ---
   1 files changed, 38 insertions(+), 15 deletions(-)
 
  diff --git a/drivers/net/hyperv/netvsc_drv.c
  b/drivers/net/hyperv/netvsc_drv.c index 7756118..7141a19 100644
  --- a/drivers/net/hyperv/netvsc_drv.c
  +++ b/drivers/net/hyperv/netvsc_drv.c
  @@ -88,8 +88,12 @@ static int netvsc_open(struct net_device *net)  {
  struct net_device_context *net_device_ctx = netdev_priv(net);
  struct hv_device *device_obj = net_device_ctx-device_ctx;
  +   struct netvsc_device *nvdev;
  +   struct rndis_device *rdev;
  int ret = 0;
 
  +   netif_carrier_off(net);
  +
  /* Open up the device */
  ret = rndis_filter_open(device_obj);
  if (ret != 0) {
  @@ -99,6 +103,11 @@ static int netvsc_open(struct net_device *net)
 
  netif_start_queue(net);
 
  +   nvdev = hv_get_drvdata(device_obj);
  +   rdev = nvdev-extension;
  +   if (!rdev-link_state)
  +   netif_carrier_on(net);
  +
 
 Maybe you can just schedule the work here and then you can drop the
 rtnl_lock in netvsc_link_change() ?

The rtnl_lock will still be necessary in the netvsc_link_change(), because 
we want to prevent it getting wrong rdev pointer when netvsc_change_mtu
is removing/adding rndis device.

  +
  +   if (notify)
  +   netdev_notify_peers(net);
   }
 
 
 Looks like this forces arp_notify here. Is it expected?

Yes, this is expected. It's required after live migration.

Thanks,
- Haiyang


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] hyperv_fb: Add screen refresh after pause/resume operation

2014-02-14 Thread Haiyang Zhang


 -Original Message-
 From: Haiyang Zhang [mailto:haiya...@microsoft.com]
 Sent: Monday, January 13, 2014 7:21 PM
 To: florianschandi...@gmx.de; a...@linux-foundation.org; linux-
 fb...@vger.kernel.org
 Cc: Haiyang Zhang; KY Srinivasan; o...@aepfle.de; jasow...@redhat.com;
 linux-kernel@vger.kernel.org; driverdev-de...@linuxdriverproject.org
 Subject: [PATCH] hyperv_fb: Add screen refresh after pause/resume
 operation
 
 This is necessary because after VM is pause/resumed, some portion of the
 screen may need refresh.
 
 Signed-off-by: Haiyang Zhang haiya...@microsoft.com
 Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 ---

Hi Tomi and Andrew,

This patch has been submitted for a while. Do I need to re-submit it, or make
any changes?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] hyperv_fb: Add support for Gen2 VM

2014-02-14 Thread Haiyang Zhang


 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Haiyang Zhang
 Sent: Saturday, February 8, 2014 12:26 PM
 To: florianschandi...@gmx.de; a...@linux-foundation.org; linux-
 fb...@vger.kernel.org
 Cc: Haiyang Zhang; KY Srinivasan; o...@aepfle.de; jasow...@redhat.com;
 gre...@linuxfoundation.org; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: [PATCH] hyperv_fb: Add support for Gen2 VM
 
 This patch enables Hyper-V FB driver to run on Gen2 VM.
 
 The Gen2 VM provides MMIO area for synthetic video from ACPI module,
 which is exported by vmbus. The generic video is provided by UEFI. PCI video
 in Gen1 is no longer available.
 
 To support synthetic video on Hyper-V Gen2 VM, this patch updated code
 related to the changes above.
 
 Signed-off-by: Haiyang Zhang haiya...@microsoft.com
 Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 ---

Hi Tomi and Andrew,

This patch has been submitted for a while. Do I need to re-submit it, or 
make any changes?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next] hyperv: Add latest NetVSP versions to auto negotiation

2014-02-18 Thread Haiyang Zhang
It auto negotiates the highest NetVSP version supported by both guest and host.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h |   53 +++
 drivers/net/hyperv/netvsc.c |   26 --
 drivers/net/hyperv/netvsc_drv.c |2 +-
 3 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 01a16ea..39fc230 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -139,6 +139,8 @@ int rndis_filter_set_device_mac(struct hv_device *hdev, 
char *mac);
 
 #define NVSP_PROTOCOL_VERSION_12
 #define NVSP_PROTOCOL_VERSION_20x30002
+#define NVSP_PROTOCOL_VERSION_40x4
+#define NVSP_PROTOCOL_VERSION_50x5
 
 enum {
NVSP_MSG_TYPE_NONE = 0,
@@ -193,6 +195,23 @@ enum {
 
NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE,
NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
+
+   NVSP_MSG2_MAX = NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
+
+   /* Version 4 messages */
+   NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION,
+   NVSP_MSG4_TYPE_SWITCH_DATA_PATH,
+   NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
+
+   NVSP_MSG4_MAX = NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
+
+   /* Version 5 messages */
+   NVSP_MSG5_TYPE_OID_QUERY_EX,
+   NVSP_MSG5_TYPE_OID_QUERY_EX_COMP,
+   NVSP_MSG5_TYPE_SUBCHANNEL,
+   NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
+
+   NVSP_MSG5_MAX = NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
 };
 
 enum {
@@ -447,10 +466,44 @@ union nvsp_2_message_uber {
struct nvsp_2_free_rxbuf free_rxbuf;
 } __packed;
 
+enum nvsp_subchannel_operation {
+   NVSP_SUBCHANNEL_NONE = 0,
+   NVSP_SUBCHANNEL_ALLOCATE,
+   NVSP_SUBCHANNEL_MAX
+};
+
+struct nvsp_5_subchannel_request {
+   u32 op;
+   u32 num_subchannels;
+} __packed;
+
+struct nvsp_5_subchannel_complete {
+   u32 status;
+   u32 num_subchannels; /* Actual number of subchannels allocated */
+} __packed;
+
+struct nvsp_5_send_indirect_table {
+   /* The number of entries in the send indirection table */
+   u32 count;
+
+   /* The offset of the send indireciton table from top of this struct.
+* The send indirection table tells which channel to put the send
+* traffic on. Each entry is a channel number.
+*/
+   u32 offset;
+} __packed;
+
+union nvsp_5_message_uber {
+   struct nvsp_5_subchannel_request subchn_req;
+   struct nvsp_5_subchannel_complete subchn_comp;
+   struct nvsp_5_send_indirect_table send_table;
+} __packed;
+
 union nvsp_all_messages {
union nvsp_message_init_uber init_msg;
union nvsp_1_message_uber v1_msg;
union nvsp_2_message_uber v2_msg;
+   union nvsp_5_message_uber v5_msg;
 } __packed;
 
 /* ALL Messages */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 9a0e9c6..fc2941c 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -290,7 +290,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
NVSP_STAT_SUCCESS)
return -EINVAL;
 
-   if (nvsp_ver != NVSP_PROTOCOL_VERSION_2)
+   if (nvsp_ver == NVSP_PROTOCOL_VERSION_1)
return 0;
 
/* NVSPv2 only: Send NDIS config */
@@ -314,6 +314,10 @@ static int netvsc_connect_vsp(struct hv_device *device)
struct nvsp_message *init_packet;
int ndis_version;
struct net_device *ndev;
+   u32 ver_list[] = {NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
+   NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5};
+   int i, num_ver = 4; /* number of different NVSP versions */
+
 
net_device = get_outbound_net_device(device);
if (!net_device)
@@ -323,13 +327,14 @@ static int netvsc_connect_vsp(struct hv_device *device)
init_packet = net_device-channel_init_pkt;
 
/* Negotiate the latest NVSP protocol supported */
-   if (negotiate_nvsp_ver(device, net_device, init_packet,
-  NVSP_PROTOCOL_VERSION_2) == 0) {
-   net_device-nvsp_version = NVSP_PROTOCOL_VERSION_2;
-   } else if (negotiate_nvsp_ver(device, net_device, init_packet,
-   NVSP_PROTOCOL_VERSION_1) == 0) {
-   net_device-nvsp_version = NVSP_PROTOCOL_VERSION_1;
-   } else {
+   for (i = num_ver - 1; i = 0; i--)
+   if (negotiate_nvsp_ver(device, net_device, init_packet,
+   ver_list[i])  == 0) {
+   net_device-nvsp_version = ver_list[i];
+   break;
+   }
+
+   if (i  0) {
ret = -EPROTO;
goto cleanup;
}
@@ -339,7 +344,10 @@ static int netvsc_connect_vsp(struct hv_device *device

[PATCH 0/2] Re-sending two patches for hyperv_fb

2014-02-18 Thread Haiyang Zhang
They were sent out during tree closing, I'm re-sending them now.

Haiyang Zhang (2):
  hyperv_fb: Add screen refresh after pause/resume operation
  hyperv_fb: Add support for Gen2 VM

 drivers/video/hyperv_fb.c |   70 -
 1 files changed, 50 insertions(+), 20 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] hyperv_fb: Add screen refresh after pause/resume operation

2014-02-18 Thread Haiyang Zhang
This is necessary because after VM is pause/resumed, some portion of
the screen may need refresh.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/video/hyperv_fb.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..bbcc8c0 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -218,6 +218,7 @@ struct hvfb_par {
 
struct delayed_work dwork;
bool update;
+   bool xrefresh;
 
u32 pseudo_palette[16];
u8 init_buf[MAX_VMBUS_PKT_SIZE];
@@ -369,7 +370,7 @@ static void synthvid_recv_sub(struct hv_device *hdev)
synthvid_send_situ(hdev);
}
 
-   par-update = msg-feature_chg.is_dirt_needed;
+   par-xrefresh = par-update = msg-feature_chg.is_dirt_needed;
if (par-update)
schedule_delayed_work(par-dwork, HVFB_UPDATE_DELAY);
}
@@ -522,6 +523,13 @@ static void hvfb_update_work(struct work_struct *w)
 {
struct hvfb_par *par = container_of(w, struct hvfb_par, dwork.work);
struct fb_info *info = par-info;
+   char *argv[] = {/usr/bin/xrefresh, -display, :0.0, NULL};
+   char *envp[] = {HOME=/, PATH=/sbin:/usr/sbin:/bin:/usr/bin, NULL };
+
+   if (par-xrefresh) {
+   par-xrefresh = false;
+   call_usermodehelper(argv[0], argv, envp, UMH_NO_WAIT);
+   }
 
if (par-fb_ready)
synthvid_update(info);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] hyperv_fb: Add support for Gen2 VM

2014-02-18 Thread Haiyang Zhang
This patch enables Hyper-V FB driver to run on Gen2 VM.

The Gen2 VM provides MMIO area for synthetic video from ACPI module,
which is exported by vmbus. The generic video is provided by UEFI. PCI
video in Gen1 is no longer available.

To support synthetic video on Hyper-V Gen2 VM, this patch updated
code related to the changes above.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/video/hyperv_fb.c |   60 ++--
 1 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index bbcc8c0..5db1f20 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -42,6 +42,7 @@
 #include linux/completion.h
 #include linux/fb.h
 #include linux/pci.h
+#include linux/efi.h
 
 #include linux/hyperv.h
 
@@ -461,13 +462,13 @@ static int synthvid_connect_vsp(struct hv_device *hdev)
goto error;
}
 
-   if (par-synthvid_version == SYNTHVID_VERSION_WIN7) {
+   if (par-synthvid_version == SYNTHVID_VERSION_WIN7)
screen_depth = SYNTHVID_DEPTH_WIN7;
-   screen_fb_size = SYNTHVID_FB_SIZE_WIN7;
-   } else {
+   else
screen_depth = SYNTHVID_DEPTH_WIN8;
-   screen_fb_size = SYNTHVID_FB_SIZE_WIN8;
-   }
+
+   screen_fb_size = hdev-channel-offermsg.offer.
+   mmio_megabytes * 1024 * 1024;
 
return 0;
 
@@ -635,22 +636,33 @@ static void hvfb_get_option(struct fb_info *info)
 /* Get framebuffer memory from Hyper-V video pci space */
 static int hvfb_getmem(struct fb_info *info)
 {
-   struct pci_dev *pdev;
+   struct pci_dev *pdev  = NULL;
ulong fb_phys;
void __iomem *fb_virt;
+   bool gen2vm = efi_enabled(EFI_BOOT);
 
-   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
+   if (gen2vm) {
+   if (!hyperv_mmio_start || hyperv_mmio_size  screen_fb_size) {
+   pr_err(Unable to find ACPI MMIO area\n);
+   return -ENODEV;
+   }
+
+   fb_phys = hyperv_mmio_start;
+   } else {
+   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
  PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
-   if (!pdev) {
-   pr_err(Unable to find PCI Hyper-V video\n);
-   return -ENODEV;
-   }
+   if (!pdev) {
+   pr_err(Unable to find PCI Hyper-V video\n);
+   return -ENODEV;
+   }
 
-   if (!(pci_resource_flags(pdev, 0)  IORESOURCE_MEM) ||
-   pci_resource_len(pdev, 0)  screen_fb_size)
-   goto err1;
+   if (!(pci_resource_flags(pdev, 0)  IORESOURCE_MEM) ||
+   pci_resource_len(pdev, 0)  screen_fb_size)
+   goto err1;
+
+   fb_phys = pci_resource_end(pdev, 0) - screen_fb_size + 1;
+   }
 
-   fb_phys = pci_resource_end(pdev, 0) - screen_fb_size + 1;
if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME))
goto err1;
 
@@ -662,14 +674,22 @@ static int hvfb_getmem(struct fb_info *info)
if (!info-apertures)
goto err3;
 
-   info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
-   info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
+   if (gen2vm) {
+   info-apertures-ranges[0].base = screen_info.lfb_base;
+   info-apertures-ranges[0].size = screen_info.lfb_size;
+   } else {
+   info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
+   info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
+   }
+
info-fix.smem_start = fb_phys;
info-fix.smem_len = screen_fb_size;
info-screen_base = fb_virt;
info-screen_size = screen_fb_size;
 
-   pci_dev_put(pdev);
+   if (!gen2vm)
+   pci_dev_put(pdev);
+
return 0;
 
 err3:
@@ -677,7 +697,9 @@ err3:
 err2:
release_mem_region(fb_phys, screen_fb_size);
 err1:
-   pci_dev_put(pdev);
+   if (!gen2vm)
+   pci_dev_put(pdev);
+
return -ENOMEM;
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,v2] hyperv: Add latest NetVSP versions to auto negotiation

2014-02-19 Thread Haiyang Zhang
It auto negotiates the highest NetVSP version supported by both guest and host.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h |   53 +++
 drivers/net/hyperv/netvsc.c |   25 +++--
 drivers/net/hyperv/netvsc_drv.c |2 +-
 3 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 01a16ea..39fc230 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -139,6 +139,8 @@ int rndis_filter_set_device_mac(struct hv_device *hdev, 
char *mac);
 
 #define NVSP_PROTOCOL_VERSION_12
 #define NVSP_PROTOCOL_VERSION_20x30002
+#define NVSP_PROTOCOL_VERSION_40x4
+#define NVSP_PROTOCOL_VERSION_50x5
 
 enum {
NVSP_MSG_TYPE_NONE = 0,
@@ -193,6 +195,23 @@ enum {
 
NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE,
NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
+
+   NVSP_MSG2_MAX = NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
+
+   /* Version 4 messages */
+   NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION,
+   NVSP_MSG4_TYPE_SWITCH_DATA_PATH,
+   NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
+
+   NVSP_MSG4_MAX = NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
+
+   /* Version 5 messages */
+   NVSP_MSG5_TYPE_OID_QUERY_EX,
+   NVSP_MSG5_TYPE_OID_QUERY_EX_COMP,
+   NVSP_MSG5_TYPE_SUBCHANNEL,
+   NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
+
+   NVSP_MSG5_MAX = NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
 };
 
 enum {
@@ -447,10 +466,44 @@ union nvsp_2_message_uber {
struct nvsp_2_free_rxbuf free_rxbuf;
 } __packed;
 
+enum nvsp_subchannel_operation {
+   NVSP_SUBCHANNEL_NONE = 0,
+   NVSP_SUBCHANNEL_ALLOCATE,
+   NVSP_SUBCHANNEL_MAX
+};
+
+struct nvsp_5_subchannel_request {
+   u32 op;
+   u32 num_subchannels;
+} __packed;
+
+struct nvsp_5_subchannel_complete {
+   u32 status;
+   u32 num_subchannels; /* Actual number of subchannels allocated */
+} __packed;
+
+struct nvsp_5_send_indirect_table {
+   /* The number of entries in the send indirection table */
+   u32 count;
+
+   /* The offset of the send indireciton table from top of this struct.
+* The send indirection table tells which channel to put the send
+* traffic on. Each entry is a channel number.
+*/
+   u32 offset;
+} __packed;
+
+union nvsp_5_message_uber {
+   struct nvsp_5_subchannel_request subchn_req;
+   struct nvsp_5_subchannel_complete subchn_comp;
+   struct nvsp_5_send_indirect_table send_table;
+} __packed;
+
 union nvsp_all_messages {
union nvsp_message_init_uber init_msg;
union nvsp_1_message_uber v1_msg;
union nvsp_2_message_uber v2_msg;
+   union nvsp_5_message_uber v5_msg;
 } __packed;
 
 /* ALL Messages */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 9a0e9c6..1a0280d 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -290,7 +290,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
NVSP_STAT_SUCCESS)
return -EINVAL;
 
-   if (nvsp_ver != NVSP_PROTOCOL_VERSION_2)
+   if (nvsp_ver == NVSP_PROTOCOL_VERSION_1)
return 0;
 
/* NVSPv2 only: Send NDIS config */
@@ -314,6 +314,9 @@ static int netvsc_connect_vsp(struct hv_device *device)
struct nvsp_message *init_packet;
int ndis_version;
struct net_device *ndev;
+   u32 ver_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
+   NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 };
+   int i, num_ver = 4; /* number of different NVSP versions */
 
net_device = get_outbound_net_device(device);
if (!net_device)
@@ -323,13 +326,14 @@ static int netvsc_connect_vsp(struct hv_device *device)
init_packet = net_device-channel_init_pkt;
 
/* Negotiate the latest NVSP protocol supported */
-   if (negotiate_nvsp_ver(device, net_device, init_packet,
-  NVSP_PROTOCOL_VERSION_2) == 0) {
-   net_device-nvsp_version = NVSP_PROTOCOL_VERSION_2;
-   } else if (negotiate_nvsp_ver(device, net_device, init_packet,
-   NVSP_PROTOCOL_VERSION_1) == 0) {
-   net_device-nvsp_version = NVSP_PROTOCOL_VERSION_1;
-   } else {
+   for (i = num_ver - 1; i = 0; i--)
+   if (negotiate_nvsp_ver(device, net_device, init_packet,
+  ver_list[i])  == 0) {
+   net_device-nvsp_version = ver_list[i];
+   break;
+   }
+
+   if (i  0) {
ret = -EPROTO;
goto cleanup;
}
@@ -339,7 +343,10 @@ static int netvsc_connect_vsp(struct hv_device *device

RE: [PATCH net-next] hyperv: Add latest NetVSP versions to auto negotiation

2014-02-19 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Wednesday, February 19, 2014 4:23 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next] hyperv: Add latest NetVSP versions to auto
 negotiation
 
 From: Haiyang Zhang haiya...@microsoft.com
 Date: Tue, 18 Feb 2014 12:28:54 -0800
 
  +   u32 ver_list[] = {NVSP_PROTOCOL_VERSION_1,
 NVSP_PROTOCOL_VERSION_2,
  +   NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5};
 
 Please put a space after { and before }.
 
  +   int i, num_ver = 4; /* number of different NVSP versions */
  +
 
  net_device = get_outbound_net_device(device);
 
 Please delete the extraneous empty line.
 
  +   for (i = num_ver - 1; i = 0; i--)
  +   if (negotiate_nvsp_ver(device, net_device, init_packet,
  +   ver_list[i])  == 0) {
 
 This is not indented properly, ver_list[i]) should begin precisely after the
 openning parenthesis of the negotiate_nvsp_ver() function call.

I have sent out a new patch with the suggested updates.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2,0/2] Re-sending two patches for hyperv_fb

2014-02-20 Thread Haiyang Zhang
They were sent out during tree closing, I'm re-sending them now.
---
v2: 
  Updated the variable type gen2vm to int, because efi_enabled() returns int.

Haiyang Zhang (2):
  hyperv_fb: Add screen refresh after pause/resume operation
  hyperv_fb: Add support for Gen2 VM

 drivers/video/hyperv_fb.c |   70 -
 1 files changed, 50 insertions(+), 20 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2,2/2] hyperv_fb: Add support for Gen2 VM

2014-02-20 Thread Haiyang Zhang
This patch enables Hyper-V FB driver to run on Gen2 VM.

The Gen2 VM provides MMIO area for synthetic video from ACPI module,
which is exported by vmbus. The generic video is provided by UEFI. PCI
video in Gen1 is no longer available.

To support synthetic video on Hyper-V Gen2 VM, this patch updated
code related to the changes above.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/video/hyperv_fb.c |   60 ++--
 1 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index bbcc8c0..5db1f20 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -42,6 +42,7 @@
 #include linux/completion.h
 #include linux/fb.h
 #include linux/pci.h
+#include linux/efi.h
 
 #include linux/hyperv.h
 
@@ -461,13 +462,13 @@ static int synthvid_connect_vsp(struct hv_device *hdev)
goto error;
}
 
-   if (par-synthvid_version == SYNTHVID_VERSION_WIN7) {
+   if (par-synthvid_version == SYNTHVID_VERSION_WIN7)
screen_depth = SYNTHVID_DEPTH_WIN7;
-   screen_fb_size = SYNTHVID_FB_SIZE_WIN7;
-   } else {
+   else
screen_depth = SYNTHVID_DEPTH_WIN8;
-   screen_fb_size = SYNTHVID_FB_SIZE_WIN8;
-   }
+
+   screen_fb_size = hdev-channel-offermsg.offer.
+   mmio_megabytes * 1024 * 1024;
 
return 0;
 
@@ -635,22 +636,33 @@ static void hvfb_get_option(struct fb_info *info)
 /* Get framebuffer memory from Hyper-V video pci space */
 static int hvfb_getmem(struct fb_info *info)
 {
-   struct pci_dev *pdev;
+   struct pci_dev *pdev  = NULL;
ulong fb_phys;
void __iomem *fb_virt;
+   int gen2vm = efi_enabled(EFI_BOOT);
 
-   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
+   if (gen2vm) {
+   if (!hyperv_mmio_start || hyperv_mmio_size  screen_fb_size) {
+   pr_err(Unable to find ACPI MMIO area\n);
+   return -ENODEV;
+   }
+
+   fb_phys = hyperv_mmio_start;
+   } else {
+   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
  PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
-   if (!pdev) {
-   pr_err(Unable to find PCI Hyper-V video\n);
-   return -ENODEV;
-   }
+   if (!pdev) {
+   pr_err(Unable to find PCI Hyper-V video\n);
+   return -ENODEV;
+   }
 
-   if (!(pci_resource_flags(pdev, 0)  IORESOURCE_MEM) ||
-   pci_resource_len(pdev, 0)  screen_fb_size)
-   goto err1;
+   if (!(pci_resource_flags(pdev, 0)  IORESOURCE_MEM) ||
+   pci_resource_len(pdev, 0)  screen_fb_size)
+   goto err1;
+
+   fb_phys = pci_resource_end(pdev, 0) - screen_fb_size + 1;
+   }
 
-   fb_phys = pci_resource_end(pdev, 0) - screen_fb_size + 1;
if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME))
goto err1;
 
@@ -662,14 +674,22 @@ static int hvfb_getmem(struct fb_info *info)
if (!info-apertures)
goto err3;
 
-   info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
-   info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
+   if (gen2vm) {
+   info-apertures-ranges[0].base = screen_info.lfb_base;
+   info-apertures-ranges[0].size = screen_info.lfb_size;
+   } else {
+   info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
+   info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
+   }
+
info-fix.smem_start = fb_phys;
info-fix.smem_len = screen_fb_size;
info-screen_base = fb_virt;
info-screen_size = screen_fb_size;
 
-   pci_dev_put(pdev);
+   if (!gen2vm)
+   pci_dev_put(pdev);
+
return 0;
 
 err3:
@@ -677,7 +697,9 @@ err3:
 err2:
release_mem_region(fb_phys, screen_fb_size);
 err1:
-   pci_dev_put(pdev);
+   if (!gen2vm)
+   pci_dev_put(pdev);
+
return -ENOMEM;
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2,1/2] hyperv_fb: Add screen refresh after pause/resume operation

2014-02-20 Thread Haiyang Zhang
This is necessary because after VM is pause/resumed, some portion of
the screen may need refresh.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/video/hyperv_fb.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..bbcc8c0 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -218,6 +218,7 @@ struct hvfb_par {
 
struct delayed_work dwork;
bool update;
+   bool xrefresh;
 
u32 pseudo_palette[16];
u8 init_buf[MAX_VMBUS_PKT_SIZE];
@@ -369,7 +370,7 @@ static void synthvid_recv_sub(struct hv_device *hdev)
synthvid_send_situ(hdev);
}
 
-   par-update = msg-feature_chg.is_dirt_needed;
+   par-xrefresh = par-update = msg-feature_chg.is_dirt_needed;
if (par-update)
schedule_delayed_work(par-dwork, HVFB_UPDATE_DELAY);
}
@@ -522,6 +523,13 @@ static void hvfb_update_work(struct work_struct *w)
 {
struct hvfb_par *par = container_of(w, struct hvfb_par, dwork.work);
struct fb_info *info = par-info;
+   char *argv[] = {/usr/bin/xrefresh, -display, :0.0, NULL};
+   char *envp[] = {HOME=/, PATH=/sbin:/usr/sbin:/bin:/usr/bin, NULL };
+
+   if (par-xrefresh) {
+   par-xrefresh = false;
+   call_usermodehelper(argv[0], argv, envp, UMH_NO_WAIT);
+   }
 
if (par-fb_ready)
synthvid_update(info);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net] hyperv: Fix the carrier status setting

2014-02-10 Thread Haiyang Zhang


 -Original Message-
 From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
 Sent: Monday, February 10, 2014 4:04 AM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; o...@aepfle.de;
 jasow...@redhat.com; driverdev-de...@linuxdriverproject.org; linux-
 ker...@vger.kernel.org
 Subject: Re: [PATCH net] hyperv: Fix the carrier status setting
 
 On Sun, Feb 09, 2014 at 05:07:58PM -0800, Haiyang Zhang wrote:
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 
 Changelog sucks.  What are the user visible effects of this bug?
 
Without this patch, the cat /sys/class/net/ethN/operstate shows 
unknown, and ethtool ethN shows Link detected: yes, when VM
boots up with or without vNIC connected. This patch fixed the problem.

I will include the comments.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net] hyperv: Fix the carrier status setting

2014-02-10 Thread Haiyang Zhang


 -Original Message-
 From: Sergei Shtylyov [mailto:sergei.shtyl...@cogentembedded.com]
 Sent: Monday, February 10, 2014 8:29 AM
 To: Haiyang Zhang; da...@davemloft.net; net...@vger.kernel.org
 Cc: KY Srinivasan; o...@aepfle.de; jasow...@redhat.com; linux-
 ker...@vger.kernel.org; driverdev-de...@linuxdriverproject.org
 Subject: Re: [PATCH net] hyperv: Fix the carrier status setting
 
 Hello.
 
 On 10-02-2014 5:07, Haiyang Zhang wrote:
 
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
  ---
drivers/net/hyperv/netvsc_drv.c |   24 +++-
1 files changed, 15 insertions(+), 9 deletions(-)
 
  diff --git a/drivers/net/hyperv/netvsc_drv.c
  b/drivers/net/hyperv/netvsc_drv.c index 7756118..836211c 100644
  --- a/drivers/net/hyperv/netvsc_drv.c
  +++ b/drivers/net/hyperv/netvsc_drv.c
 [...]
  @@ -229,15 +238,17 @@ void netvsc_linkstatus_callback(struct hv_device
 *device_obj,
  struct net_device *net;
  struct net_device_context *ndev_ctx;
  struct netvsc_device *net_device;
  +   struct rndis_device *rdev;
 
  net_device = hv_get_drvdata(device_obj);
  +   rdev = net_device-extension;
  +
  +   rdev-link_state = !(status == 1);
 
 Why not just 'status != 1'?

I will simplify it.
Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net,v2] hyperv: Fix the carrier status setting

2014-02-10 Thread Haiyang Zhang
Without this patch, the cat /sys/class/net/ethN/operstate shows
unknown, and ethtool ethN shows Link detected: yes, when VM
boots up with or without vNIC connected.

This patch fixed the problem.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/netvsc_drv.c |   24 +++-
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 7756118..18916f7 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -88,8 +88,12 @@ static int netvsc_open(struct net_device *net)
 {
struct net_device_context *net_device_ctx = netdev_priv(net);
struct hv_device *device_obj = net_device_ctx-device_ctx;
+   struct netvsc_device *nvdev;
+   struct rndis_device *rdev;
int ret = 0;
 
+   netif_carrier_off(net);
+
/* Open up the device */
ret = rndis_filter_open(device_obj);
if (ret != 0) {
@@ -99,6 +103,11 @@ static int netvsc_open(struct net_device *net)
 
netif_start_queue(net);
 
+   nvdev = hv_get_drvdata(device_obj);
+   rdev = nvdev-extension;
+   if (!rdev-link_state)
+   netif_carrier_on(net);
+
return ret;
 }
 
@@ -229,15 +238,17 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
struct net_device *net;
struct net_device_context *ndev_ctx;
struct netvsc_device *net_device;
+   struct rndis_device *rdev;
 
net_device = hv_get_drvdata(device_obj);
+   rdev = net_device-extension;
+
+   rdev-link_state = status != 1;
+
net = net_device-ndev;
 
-   if (!net) {
-   netdev_err(net, got link status but net device 
-   not initialized yet\n);
+   if (!net || net-reg_state != NETREG_REGISTERED)
return;
-   }
 
if (status == 1) {
netif_carrier_on(net);
@@ -414,9 +425,6 @@ static int netvsc_probe(struct hv_device *dev,
if (!net)
return -ENOMEM;
 
-   /* Set initial state */
-   netif_carrier_off(net);
-
net_device_ctx = netdev_priv(net);
net_device_ctx-device_ctx = dev;
hv_set_drvdata(dev, net);
@@ -443,8 +451,6 @@ static int netvsc_probe(struct hv_device *dev,
}
memcpy(net-dev_addr, device_info.mac_adr, ETH_ALEN);
 
-   netif_carrier_on(net);
-
ret = register_netdev(net);
if (ret != 0) {
pr_err(Unable to register netdev.\n);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] hyperv_fb: Add screen refresh after pause/resume operation

2014-02-10 Thread Haiyang Zhang


 -Original Message-
 From: Haiyang Zhang [mailto:haiya...@microsoft.com]
 Sent: Monday, January 13, 2014 7:21 PM
 To: florianschandi...@gmx.de; a...@linux-foundation.org; linux-
 fb...@vger.kernel.org
 Cc: Haiyang Zhang; KY Srinivasan; o...@aepfle.de; jasow...@redhat.com;
 linux-kernel@vger.kernel.org; driverdev-de...@linuxdriverproject.org
 Subject: [PATCH] hyperv_fb: Add screen refresh after pause/resume operation
 
 This is necessary because after VM is pause/resumed, some portion of the
 screen may need refresh.
 
 Signed-off-by: Haiyang Zhang haiya...@microsoft.com
 Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 ---
This was submitted before the tree re-opened. Is it still being considered?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net,v3] hyperv: Fix the carrier status setting

2014-02-12 Thread Haiyang Zhang
Without this patch, the cat /sys/class/net/ethN/operstate shows
unknown, and ethtool ethN shows Link detected: yes, when VM
boots up with or without vNIC connected.

This patch fixed the problem.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/netvsc_drv.c |   53 ---
 1 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 7756118..7141a19 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -88,8 +88,12 @@ static int netvsc_open(struct net_device *net)
 {
struct net_device_context *net_device_ctx = netdev_priv(net);
struct hv_device *device_obj = net_device_ctx-device_ctx;
+   struct netvsc_device *nvdev;
+   struct rndis_device *rdev;
int ret = 0;
 
+   netif_carrier_off(net);
+
/* Open up the device */
ret = rndis_filter_open(device_obj);
if (ret != 0) {
@@ -99,6 +103,11 @@ static int netvsc_open(struct net_device *net)
 
netif_start_queue(net);
 
+   nvdev = hv_get_drvdata(device_obj);
+   rdev = nvdev-extension;
+   if (!rdev-link_state)
+   netif_carrier_on(net);
+
return ret;
 }
 
@@ -229,23 +238,24 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
struct net_device *net;
struct net_device_context *ndev_ctx;
struct netvsc_device *net_device;
+   struct rndis_device *rdev;
 
net_device = hv_get_drvdata(device_obj);
+   rdev = net_device-extension;
+
+   rdev-link_state = status != 1;
+
net = net_device-ndev;
 
-   if (!net) {
-   netdev_err(net, got link status but net device 
-   not initialized yet\n);
+   if (!net || net-reg_state != NETREG_REGISTERED)
return;
-   }
 
+   ndev_ctx = netdev_priv(net);
if (status == 1) {
-   netif_carrier_on(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);
+   schedule_delayed_work(ndev_ctx-dwork, 0);
}
 }
 
@@ -388,17 +398,35 @@ static const struct net_device_ops device_ops = {
  * current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, add
  * another netif_notify_peers() into a delayed work, otherwise GARP packet
  * will not be sent after quick migration, and cause network disconnection.
+ * Also, we update the carrier status here.
  */
-static void netvsc_send_garp(struct work_struct *w)
+static void netvsc_link_change(struct work_struct *w)
 {
struct net_device_context *ndev_ctx;
struct net_device *net;
struct netvsc_device *net_device;
+   struct rndis_device *rdev;
+   bool notify;
+
+   rtnl_lock();
 
ndev_ctx = container_of(w, struct net_device_context, dwork.work);
net_device = hv_get_drvdata(ndev_ctx-device_ctx);
+   rdev = net_device-extension;
net = net_device-ndev;
-   netdev_notify_peers(net);
+
+   if (rdev-link_state) {
+   netif_carrier_off(net);
+   notify = false;
+   } else {
+   netif_carrier_on(net);
+   notify = true;
+   }
+
+   rtnl_unlock();
+
+   if (notify)
+   netdev_notify_peers(net);
 }
 
 
@@ -414,13 +442,10 @@ static int netvsc_probe(struct hv_device *dev,
if (!net)
return -ENOMEM;
 
-   /* Set initial state */
-   netif_carrier_off(net);
-
net_device_ctx = netdev_priv(net);
net_device_ctx-device_ctx = dev;
hv_set_drvdata(dev, net);
-   INIT_DELAYED_WORK(net_device_ctx-dwork, netvsc_send_garp);
+   INIT_DELAYED_WORK(net_device_ctx-dwork, netvsc_link_change);
INIT_WORK(net_device_ctx-work, do_set_multicast);
 
net-netdev_ops = device_ops;
@@ -443,8 +468,6 @@ static int netvsc_probe(struct hv_device *dev,
}
memcpy(net-dev_addr, device_info.mac_adr, ETH_ALEN);
 
-   netif_carrier_on(net);
-
ret = register_netdev(net);
if (ret != 0) {
pr_err(Unable to register netdev.\n);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net,v2] hyperv: Fix the carrier status setting

2014-02-12 Thread Haiyang Zhang


 -Original Message-
 From: Jason Wang [mailto:jasow...@redhat.com]
 Sent: Tuesday, February 11, 2014 4:51 AM
 To: Haiyang Zhang; da...@davemloft.net; net...@vger.kernel.org
 Cc: KY Srinivasan; o...@aepfle.de; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net,v2] hyperv: Fix the carrier status setting
 
 On 02/11/2014 02:15 AM, Haiyang Zhang wrote:
  Without this patch, the cat /sys/class/net/ethN/operstate shows
  unknown, and ethtool ethN shows Link detected: yes, when VM
  boots up with or without vNIC connected.
 
  This patch fixed the problem.
 
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
  ---
   drivers/net/hyperv/netvsc_drv.c |   24 +++-
   1 files changed, 15 insertions(+), 9 deletions(-)
 
  diff --git a/drivers/net/hyperv/netvsc_drv.c
  b/drivers/net/hyperv/netvsc_drv.c index 7756118..18916f7 100644
  --- a/drivers/net/hyperv/netvsc_drv.c
  +++ b/drivers/net/hyperv/netvsc_drv.c
  @@ -88,8 +88,12 @@ static int netvsc_open(struct net_device *net)  {
  struct net_device_context *net_device_ctx = netdev_priv(net);
  struct hv_device *device_obj = net_device_ctx-device_ctx;
  +   struct netvsc_device *nvdev;
  +   struct rndis_device *rdev;
  int ret = 0;
 
  +   netif_carrier_off(net);
  +
  /* Open up the device */
  ret = rndis_filter_open(device_obj);
  if (ret != 0) {
  @@ -99,6 +103,11 @@ static int netvsc_open(struct net_device *net)
 
  netif_start_queue(net);
 
  +   nvdev = hv_get_drvdata(device_obj);
  +   rdev = nvdev-extension;
  +   if (!rdev-link_state)
 
 What if the link status interrupt comes here at this time?

Thank you for pointing this out. I have submitted an updated patch.
- Haiyang



[PATCH net-next,v3] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-18 Thread Haiyang Zhang
This feature allows multiple channels to be used by each virtual NIC.
It is available on Hyper-V host 2012 R2.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h   |  112 ++-
 drivers/net/hyperv/netvsc.c   |  134 +-
 drivers/net/hyperv/netvsc_drv.c   |  102 +++-
 drivers/net/hyperv/rndis_filter.c |  187 -
 4 files changed, 503 insertions(+), 32 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 13010b4..c2d72f6 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -28,6 +28,98 @@
 #include linux/hyperv.h
 #include linux/rndis.h
 
+/* RSS related */
+#define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203  /* query only */
+#define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204  /* query and set */
+
+#define NDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88
+#define NDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89
+
+#define NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2
+#define NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2
+
+struct ndis_obj_header {
+   u8 type;
+   u8 rev;
+   u16 size;
+} __packed;
+
+
+/* ndis_recv_scale_cap/cap_flag */
+#define NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x0100
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR   0x0200
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_DPC   0x0400
+#define NDIS_RSS_CAPS_USING_MSI_X 0x0800
+#define NDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS  0x1000
+#define NDIS_RSS_CAPS_SUPPORTS_MSI_X  0x2000
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4  0x0100
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6  0x0200
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX   0x0400
+
+struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
+   struct ndis_obj_header hdr;
+   u32 cap_flag;
+   u32 num_int_msg;
+   u32 num_recv_que;
+   u16 num_indirect_tabent;
+} __packed;
+
+
+/* ndis_recv_scale_param flags */
+#define NDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001
+#define NDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED0x0002
+#define NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED   0x0004
+#define NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008
+#define NDIS_RSS_PARAM_FLAG_DISABLE_RSS0x0010
+
+/* Hash info bits */
+#define NDIS_HASH_FUNC_TOEPLITZ 0x0001
+#define NDIS_HASH_IPV4  0x0100
+#define NDIS_HASH_TCP_IPV4  0x0200
+#define NDIS_HASH_IPV6  0x0400
+#define NDIS_HASH_IPV6_EX   0x0800
+#define NDIS_HASH_TCP_IPV6  0x1000
+#define NDIS_HASH_TCP_IPV6_EX   0x2000
+
+#define NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4)
+#define NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2   40
+
+#define ITAB_NUM 128
+#define HASH_KEYLEN NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
+extern u8 netvsc_hash_key[];
+
+struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
+   struct ndis_obj_header hdr;
+
+   /* Qualifies the rest of the information */
+   u16 flag;
+
+   /* The base CPU number to do receive processing. not used */
+   u16 base_cpu_number;
+
+   /* This describes the hash function and type being enabled */
+   u32 hashinfo;
+
+   /* The size of indirection table array */
+   u16 indirect_tabsize;
+
+   /* The offset of the indirection table from the beginning of this
+* structure
+*/
+   u32 indirect_taboffset;
+
+   /* The size of the hash secret key */
+   u16 hashkey_size;
+
+   /* The offset of the secret key from the beginning of this structure */
+   u32 kashkey_offset;
+
+   u32 processor_masks_offset;
+   u32 num_processor_masks;
+   u32 processor_masks_entry_size;
+};
+
+
 /* Fwd declaration */
 struct hv_netvsc_packet;
 struct ndis_tcp_ip_checksum_info;
@@ -39,6 +131,8 @@ struct xferpage_packet {
 
/* # of netvsc packets this xfer packet contains */
u32 count;
+
+   struct vmbus_channel *channel;
 };
 
 /*
@@ -54,6 +148,9 @@ struct hv_netvsc_packet {
bool is_data_pkt;
u16 vlan_tci;
 
+   u16 q_idx;
+   struct vmbus_channel *channel;
+
/*
 * Valid only for receives when we break a xfer page packet
 * into multiple netvsc packets
@@ -120,6 +217,7 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
struct ndis_tcp_ip_checksum_info *csum_info);
+extern void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
 int rndis_filter_device_add(struct hv_device *dev,
@@ -522,6 +620,8 @@ struct nvsp_message {
 
 #define NETVSC_PACKET_SIZE  2048

RE: [PATCH net-next,v3] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-19 Thread Haiyang Zhang


 -Original Message-
  +
  +
  +/* ndis_recv_scale_cap/cap_flag */
 
 One empty line is sufficient, we don't need two of them here.

I will fix this and other formats you pointed out below, also check the whole 
patch 
for similar issues.

  -   net = alloc_etherdev(sizeof(struct net_device_context));
  +   net = alloc_etherdev_mq(sizeof(struct net_device_context),
  +   num_online_cpus());
  if (!net)
  return -ENOMEM;
 
 
 num_online_cpus() can change, will your driver accomodate this?

HyperV currently doesn't support hot-add/remove cpu, so this is constant for 
this driver.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-20 Thread Haiyang Zhang
This feature allows multiple channels to be used by each virtual NIC.
It is available on Hyper-V host 2012 R2.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h   |  110 +-
 drivers/net/hyperv/netvsc.c   |  136 +-
 drivers/net/hyperv/netvsc_drv.c   |  103 +++-
 drivers/net/hyperv/rndis_filter.c |  189 -
 4 files changed, 504 insertions(+), 34 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 13010b4..dcafa82 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -28,6 +28,96 @@
 #include linux/hyperv.h
 #include linux/rndis.h
 
+/* RSS related */
+#define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203  /* query only */
+#define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204  /* query and set */
+
+#define NDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88
+#define NDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89
+
+#define NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2
+#define NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2
+
+struct ndis_obj_header {
+   u8 type;
+   u8 rev;
+   u16 size;
+} __packed;
+
+/* ndis_recv_scale_cap/cap_flag */
+#define NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x0100
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR   0x0200
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_DPC   0x0400
+#define NDIS_RSS_CAPS_USING_MSI_X 0x0800
+#define NDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS  0x1000
+#define NDIS_RSS_CAPS_SUPPORTS_MSI_X  0x2000
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4  0x0100
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6  0x0200
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX   0x0400
+
+struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
+   struct ndis_obj_header hdr;
+   u32 cap_flag;
+   u32 num_int_msg;
+   u32 num_recv_que;
+   u16 num_indirect_tabent;
+} __packed;
+
+
+/* ndis_recv_scale_param flags */
+#define NDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001
+#define NDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED0x0002
+#define NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED   0x0004
+#define NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008
+#define NDIS_RSS_PARAM_FLAG_DISABLE_RSS0x0010
+
+/* Hash info bits */
+#define NDIS_HASH_FUNC_TOEPLITZ 0x0001
+#define NDIS_HASH_IPV4  0x0100
+#define NDIS_HASH_TCP_IPV4  0x0200
+#define NDIS_HASH_IPV6  0x0400
+#define NDIS_HASH_IPV6_EX   0x0800
+#define NDIS_HASH_TCP_IPV6  0x1000
+#define NDIS_HASH_TCP_IPV6_EX   0x2000
+
+#define NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4)
+#define NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2   40
+
+#define ITAB_NUM 128
+#define HASH_KEYLEN NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
+extern u8 netvsc_hash_key[];
+
+struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
+   struct ndis_obj_header hdr;
+
+   /* Qualifies the rest of the information */
+   u16 flag;
+
+   /* The base CPU number to do receive processing. not used */
+   u16 base_cpu_number;
+
+   /* This describes the hash function and type being enabled */
+   u32 hashinfo;
+
+   /* The size of indirection table array */
+   u16 indirect_tabsize;
+
+   /* The offset of the indirection table from the beginning of this
+* structure
+*/
+   u32 indirect_taboffset;
+
+   /* The size of the hash secret key */
+   u16 hashkey_size;
+
+   /* The offset of the secret key from the beginning of this structure */
+   u32 kashkey_offset;
+
+   u32 processor_masks_offset;
+   u32 num_processor_masks;
+   u32 processor_masks_entry_size;
+};
+
 /* Fwd declaration */
 struct hv_netvsc_packet;
 struct ndis_tcp_ip_checksum_info;
@@ -39,6 +129,8 @@ struct xferpage_packet {
 
/* # of netvsc packets this xfer packet contains */
u32 count;
+
+   struct vmbus_channel *channel;
 };
 
 /*
@@ -54,6 +146,9 @@ struct hv_netvsc_packet {
bool is_data_pkt;
u16 vlan_tci;
 
+   u16 q_idx;
+   struct vmbus_channel *channel;
+
/*
 * Valid only for receives when we break a xfer page packet
 * into multiple netvsc packets
@@ -120,6 +215,7 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
struct ndis_tcp_ip_checksum_info *csum_info);
+void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
 int rndis_filter_device_add(struct hv_device *dev,
@@ -522,6 +618,8 @@ struct nvsp_message {
 
 #define NETVSC_PACKET_SIZE  2048
 
+#define

RE: [PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-21 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Friday, March 21, 2014 2:55 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next,v4] hyperv: Add support for virtual Receive
 Side Scaling (vRSS)
 
 From: David Miller da...@davemloft.net
 Date: Fri, 21 Mar 2014 14:49:57 -0400 (EDT)
 
  From: Haiyang Zhang haiya...@microsoft.com
  Date: Thu, 20 Mar 2014 15:28:41 -0700
 
  This feature allows multiple channels to be used by each virtual NIC.
  It is available on Hyper-V host 2012 R2.
 
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 
  Applied, thanks.
 
 Actually I had to revert, this doesn't even compile.
 
 drivers/net/hyperv/netvsc.c: In function ‘netvsc_channel_cb’:
 drivers/net/hyperv/netvsc.c:891:2: error: implicit declaration of
 function ‘get_per_channel_state’ [-Werror=implicit-function-declaration]
 drivers/net/hyperv/netvsc.c:891:9: warning: assignment makes pointer
 from integer without a cast [enabled by default]
 drivers/net/hyperv/netvsc.c: In function ‘netvsc_device_add’:
 drivers/net/hyperv/netvsc.c:998:2: error: implicit declaration of
 function ‘set_per_channel_state’ [-Werror=implicit-function-declaration]
 cc1: some warnings being treated as errors
 make[3]: *** [drivers/net/hyperv/netvsc.o] Error 1
 make[3]: *** Waiting for unfinished jobs
 drivers/net/hyperv/rndis_filter.c: In function ‘netvsc_sc_open’:
 drivers/net/hyperv/rndis_filter.c:988:2: error: implicit declaration of
 function ‘set_per_channel_state’ [-Werror=implicit-function-declaration]
 cc1: some warnings being treated as errors
 make[3]: *** [drivers/net/hyperv/rndis_filter.o] Error 1
 make[2]: *** [drivers/net/hyperv] Error 2
 make[2]: *** Waiting for unfinished jobs
 make[1]: *** [drivers/net] Error 2
 make[1]: *** Waiting for unfinished jobs
 make: *** [drivers] Error 2

The per channel state variable and functions are defined by this patch,
which has been applied on 2/07:
Drivers: hv: vmbus: Support per-channel driver state
http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=8a7206a89f85c8439561b0eff85bb9440a2e97a9

Could it be merged into net-next tree?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-21 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Friday, March 21, 2014 3:33 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next,v4] hyperv: Add support for virtual Receive
 Side Scaling (vRSS)
 
 From: Haiyang Zhang haiya...@microsoft.com
 Date: Fri, 21 Mar 2014 19:12:43 +
 
  Could it be merged into net-next tree?
 
 You submitted a patch against net-next, that means you are implicitly
 stating that all dependencies are in place in _that_ tree and that
 you tested it in _that_ tree.
 
 If the situation is otherwise you must explicitly state this in your
 patch submission.

I will re-submit the vRSS patch with the dependency specified.
Thanks,
- Haiyang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-03-21 Thread Haiyang Zhang
This feature allows multiple channels to be used by each virtual NIC.
It is available on Hyper-V host 2012 R2.

(It depends on this commit:
Drivers: hv: vmbus: Support per-channel driver state
http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=8a7206a89f85c8439561b0eff85bb9440a2e97a9
)

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/hyperv_net.h   |  110 +-
 drivers/net/hyperv/netvsc.c   |  136 +-
 drivers/net/hyperv/netvsc_drv.c   |  103 +++-
 drivers/net/hyperv/rndis_filter.c |  189 -
 4 files changed, 504 insertions(+), 34 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 13010b4..dcafa82 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -28,6 +28,96 @@
 #include linux/hyperv.h
 #include linux/rndis.h
 
+/* RSS related */
+#define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203  /* query only */
+#define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204  /* query and set */
+
+#define NDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88
+#define NDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89
+
+#define NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2
+#define NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2
+
+struct ndis_obj_header {
+   u8 type;
+   u8 rev;
+   u16 size;
+} __packed;
+
+/* ndis_recv_scale_cap/cap_flag */
+#define NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x0100
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR   0x0200
+#define NDIS_RSS_CAPS_CLASSIFICATION_AT_DPC   0x0400
+#define NDIS_RSS_CAPS_USING_MSI_X 0x0800
+#define NDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS  0x1000
+#define NDIS_RSS_CAPS_SUPPORTS_MSI_X  0x2000
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4  0x0100
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6  0x0200
+#define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX   0x0400
+
+struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
+   struct ndis_obj_header hdr;
+   u32 cap_flag;
+   u32 num_int_msg;
+   u32 num_recv_que;
+   u16 num_indirect_tabent;
+} __packed;
+
+
+/* ndis_recv_scale_param flags */
+#define NDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001
+#define NDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED0x0002
+#define NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED   0x0004
+#define NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008
+#define NDIS_RSS_PARAM_FLAG_DISABLE_RSS0x0010
+
+/* Hash info bits */
+#define NDIS_HASH_FUNC_TOEPLITZ 0x0001
+#define NDIS_HASH_IPV4  0x0100
+#define NDIS_HASH_TCP_IPV4  0x0200
+#define NDIS_HASH_IPV6  0x0400
+#define NDIS_HASH_IPV6_EX   0x0800
+#define NDIS_HASH_TCP_IPV6  0x1000
+#define NDIS_HASH_TCP_IPV6_EX   0x2000
+
+#define NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4)
+#define NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2   40
+
+#define ITAB_NUM 128
+#define HASH_KEYLEN NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
+extern u8 netvsc_hash_key[];
+
+struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
+   struct ndis_obj_header hdr;
+
+   /* Qualifies the rest of the information */
+   u16 flag;
+
+   /* The base CPU number to do receive processing. not used */
+   u16 base_cpu_number;
+
+   /* This describes the hash function and type being enabled */
+   u32 hashinfo;
+
+   /* The size of indirection table array */
+   u16 indirect_tabsize;
+
+   /* The offset of the indirection table from the beginning of this
+* structure
+*/
+   u32 indirect_taboffset;
+
+   /* The size of the hash secret key */
+   u16 hashkey_size;
+
+   /* The offset of the secret key from the beginning of this structure */
+   u32 kashkey_offset;
+
+   u32 processor_masks_offset;
+   u32 num_processor_masks;
+   u32 processor_masks_entry_size;
+};
+
 /* Fwd declaration */
 struct hv_netvsc_packet;
 struct ndis_tcp_ip_checksum_info;
@@ -39,6 +129,8 @@ struct xferpage_packet {
 
/* # of netvsc packets this xfer packet contains */
u32 count;
+
+   struct vmbus_channel *channel;
 };
 
 /*
@@ -54,6 +146,9 @@ struct hv_netvsc_packet {
bool is_data_pkt;
u16 vlan_tci;
 
+   u16 q_idx;
+   struct vmbus_channel *channel;
+
/*
 * Valid only for receives when we break a xfer page packet
 * into multiple netvsc packets
@@ -120,6 +215,7 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
struct ndis_tcp_ip_checksum_info *csum_info);
+void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int

[PATCH] MAINTAINERS: update Hyper-V file list

2013-05-09 Thread Haiyang Zhang
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 MAINTAINERS |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7782b..315a63c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3865,9 +3865,16 @@ M:   K. Y. Srinivasan k...@microsoft.com
 M: Haiyang Zhang haiya...@microsoft.com
 L: de...@linuxdriverproject.org
 S: Maintained
-F: drivers/hv/
+F: arch/x86/include/asm/mshyperv.h
+F: arch/x86/include/uapi/asm/hyperv.h
+F: arch/x86/kernel/cpu/mshyperv.c
 F: drivers/hid/hid-hyperv.c
+F: drivers/hv/
 F: drivers/net/hyperv/
+F: drivers/scsi/storvsc_drv.c
+F: drivers/video/hyperv_fb.c
+F: include/linux/hyperv.h
+F: tools/hv/
 
 I2C OVER PARALLEL PORT
 M: Jean Delvare kh...@linux-fr.org
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net] hyperv: Fix vlan_proto setting in netvsc_recv_callback()

2013-06-14 Thread Haiyang Zhang


 -Original Message-
 From: Olaf Hering [mailto:o...@aepfle.de]
 Sent: Friday, June 14, 2013 11:29 AM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; KY Srinivasan;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net] hyperv: Fix vlan_proto setting in
 netvsc_recv_callback()
 
 On Tue, May 28, Haiyang Zhang wrote:
 
  Since the recent addition of 8021AD, we need to set the new field
  vlan_proto in sk_buff. Otherwise, it will trigger BUG() call in
 vlan_proto_idx().
 
  @@ -284,7 +285,7 @@ int netvsc_recv_callback(struct hv_device
  *device_obj,
 
  skb-protocol = eth_type_trans(skb, net);
  skb-ip_summed = CHECKSUM_NONE;
  -   skb-vlan_tci = packet-vlan_tci;
  +   __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet-
 vlan_tci);
 
 
 Just curious:
 
 Doesnt that change behaviour in the sense that __vlan_hwaccel_put_tag()
 now always adds VLAN_TAG_PRESENT to skb-vlan_tci, while before that
 change packet-vlan_tci may or may not had this flag?
 
 In other words, should a variant of this patch be backported if it was a bug
 not not use __vlan_hwaccel_put_tag right from the start?
 

Thanks for looking at this. Actually, the previous code was correct, because I 
add the VLAN_TAG_PRESENT if the packet comes from vlan in function
rndis_filter_receive_data():
if (vlan) {
pkt-vlan_tci = VLAN_TAG_PRESENT | vlan-vlanid |
(vlan-pri  VLAN_PRIO_SHIFT);
} else {
pkt-vlan_tci = 0;
}

But, the new code should be updated below, so the VLAN_TAG_PRESENT won't be set
when it's not from a vlan:
If (VLAN_TAG_PRESENT  packet-vlan_tci)
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet- vlan_tci);

I will submit a patch soon.

Thanks,
- Haiyang



[PATCH net] Fix the VLAN_TAG_PRESENT in netvsc_recv_callback()

2013-06-17 Thread Haiyang Zhang
We should call __vlan_hwaccel_put_tag() only if the packet
comes from vlan, otherwise VLAN_TAG_PRESENT will always be
added.

Reported-by: Olaf Hering o...@aepfle.de
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/netvsc_drv.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index ab2307b..4dccead 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -285,7 +285,9 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 
skb-protocol = eth_type_trans(skb, net);
skb-ip_summed = CHECKSUM_NONE;
-   __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet-vlan_tci);
+   if (packet-vlan_tci  VLAN_TAG_PRESENT)
+   __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
+  packet-vlan_tci);
 
net-stats.rx_packets++;
net-stats.rx_bytes += packet-total_data_buflen;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next] hyperv: Fix a compiler warning in netvsc_send()

2013-04-29 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Monday, April 29, 2013 2:10 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next] hyperv: Fix a compiler warning in
 netvsc_send()
 
 From: Haiyang Zhang haiya...@microsoft.com
 Date: Fri, 26 Apr 2013 11:25:55 -0700
 
  Fixed: warning: cast from pointer to integer of different size
 
  The Hyper-V hosts always use 64 bit request id. The guests can have 32
  or 64 bit pointers which equal to the ulong type size. So we cast it to 
  ulong
 type.
  And, assigning 32bit integer to 64 bit variable works fine.
 
  The VMBus returns the same id in the completion packet. But the value
  has no effect on the host side.
 
  Reported-by: kbuild test robot fengguang...@intel.com
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 
 Applied, but:
 
  -   req_id = (u64)packet;
  +   req_id = (ulong)packet;
 
 I really do not like these shorthands for fundamental C types, we generally
 do not use ulong, uint etc.  Please expand them out explicitly to
 unsigned long, unsigned int, etc.

Thanks for applying it. 

Going forward, I will use the long format, like unsigned long, instead of 
ulong, etc.

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next] hyperv: Fix a compiler warning in netvsc_send()

2013-04-26 Thread Haiyang Zhang
Fixed: warning: cast from pointer to integer of different size

The Hyper-V hosts always use 64 bit request id. The guests can have 32 or 64
bit pointers which equal to the ulong type size. So we cast it to ulong type.
And, assigning 32bit integer to 64 bit variable works fine.

The VMBus returns the same id in the completion packet. But the value has no
effect on the host side.

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com
---
 drivers/net/hyperv/netvsc.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index f5f0f09..2b04804 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -522,7 +522,7 @@ int netvsc_send(struct hv_device *device,
sendMessage.msg.v1_msg.send_rndis_pkt.send_buf_section_size = 0;
 
if (packet-completion.send.send_completion)
-   req_id = (u64)packet;
+   req_id = (ulong)packet;
else
req_id = 0;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net, 1/2] hyperv: Fix a kernel warning from netvsc_linkstatus_callback()

2013-05-23 Thread Haiyang Zhang


 -Original Message-
 From: Richard Genoud [mailto:richard.gen...@gmail.com]
 Sent: Thursday, May 23, 2013 4:44 AM
 To: Haiyang Zhang
 Cc: da...@davemloft.net; net...@vger.kernel.org; o...@aepfle.de;
 jasow...@redhat.com; linux-kernel@vger.kernel.org;
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net, 1/2] hyperv: Fix a kernel warning from
 netvsc_linkstatus_callback()
 
 2013/4/5 Haiyang Zhang haiya...@microsoft.com:
  The warning about local_bh_enable inside IRQ happens when
  disconnecting a virtual NIC.
 
  The reason for the warning is -- netif_tx_disable() is called when the
  NIC is disconnected. And it's called within irq context.
  netif_tx_disable() calls
  local_bh_enable() which displays warning if in irq.
 
  The fix is to remove the unnecessary netif_tx_disable  wake_queue()
  in the netvsc_linkstatus_callback().
 
  Reported-by: Richard Genoud richard.gen...@gmail.com
  Tested-by: Long Li lon...@microsoft.com
  Tested-by: Richard Genoud richard.gen...@gmail.com
  Signed-off-by: Haiyang Zhang haiya...@microsoft.com
  Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 
  ---
   drivers/net/hyperv/netvsc_drv.c |2 --
   1 files changed, 0 insertions(+), 2 deletions(-)
 
  diff --git a/drivers/net/hyperv/netvsc_drv.c
  b/drivers/net/hyperv/netvsc_drv.c index 5f85205..8341b62 100644
  --- a/drivers/net/hyperv/netvsc_drv.c
  +++ b/drivers/net/hyperv/netvsc_drv.c
  @@ -241,13 +241,11 @@ void netvsc_linkstatus_callback(struct hv_device
  *device_obj,
 
  if (status == 1) {
  netif_carrier_on(net);
  -   netif_wake_queue(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);
  -   netif_tx_disable(net);
  }
   }
 
  --
  1.7.4.1
 
 This should also go to the stable tree, shouldn't it ?
 At least 3.8, 3.7 and 3.4 (the 3.2 version is different, and it's in staging. 
 (at not
 used by distros anyway))

Cc: stable sta...@kernel.org

I agree. Adding sta...@kernel.org to Cc list.

Thanks,
- Haiyang

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�j:+v���zZ+��+zf���h���~i���z��w���?��)ߢf��^jǫy�m��@A�a���
0��h���i

[PATCH net] hyperv: Fix vlan_proto setting in netvsc_recv_callback()

2013-05-28 Thread Haiyang Zhang
Since the recent addition of 8021AD, we need to set the new field vlan_proto in
sk_buff. Otherwise, it will trigger BUG() call in vlan_proto_idx().

This patch fixes the problem.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
 drivers/net/hyperv/netvsc_drv.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 088c554..ab2307b 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -31,6 +31,7 @@
 #include linux/inetdevice.h
 #include linux/etherdevice.h
 #include linux/skbuff.h
+#include linux/if_vlan.h
 #include linux/in.h
 #include linux/slab.h
 #include net/arp.h
@@ -284,7 +285,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 
skb-protocol = eth_type_trans(skb, net);
skb-ip_summed = CHECKSUM_NONE;
-   skb-vlan_tci = packet-vlan_tci;
+   __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), packet-vlan_tci);
 
net-stats.rx_packets++;
net-stats.rx_bytes += packet-total_data_buflen;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   >