diff mbox

[net] hyperv: Fix the carrier status setting

Message ID 1391994478-25809-1-git-send-email-haiyangz@microsoft.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Haiyang Zhang Feb. 10, 2014, 1:07 a.m. UTC
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

Comments

Dan Carpenter Feb. 10, 2014, 9:03 a.m. UTC | #1
On Sun, Feb 09, 2014 at 05:07:58PM -0800, Haiyang Zhang wrote:
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>

Changelog sucks.  What are the user visible effects of this bug?

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov Feb. 10, 2014, 1:28 p.m. UTC | #2
Hello.

On 10-02-2014 5:07, Haiyang Zhang wrote:

> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@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'?

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Haiyang Zhang Feb. 10, 2014, 3:57 p.m. UTC | #3
> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Monday, February 10, 2014 4:04 AM
> To: Haiyang Zhang
> Cc: davem@davemloft.net; netdev@vger.kernel.org; olaf@aepfle.de;
> jasowang@redhat.com; driverdev-devel@linuxdriverproject.org; linux-
> kernel@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 <haiyangz@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Haiyang Zhang Feb. 10, 2014, 3:57 p.m. UTC | #4
> -----Original Message-----
> From: Sergei Shtylyov [mailto:sergei.shtylyov@cogentembedded.com]
> Sent: Monday, February 10, 2014 8:29 AM
> To: Haiyang Zhang; davem@davemloft.net; netdev@vger.kernel.org
> Cc: KY Srinivasan; olaf@aepfle.de; jasowang@redhat.com; linux-
> kernel@vger.kernel.org; driverdev-devel@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 <haiyangz@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@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 netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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
@@ -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");