From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbdFUXmG (ORCPT ); Wed, 21 Jun 2017 19:42:06 -0400 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:58274 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751835AbdFUXmD (ORCPT ); Wed, 21 Jun 2017 19:42:03 -0400 x-originating-ip: 107.180.71.197 From: Haiyang Zhang To: davem@davemloft.net, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off Date: Wed, 21 Jun 2017 16:40:47 -0700 Message-Id: <1498088447-27282-2-git-send-email-haiyangz@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1498088447-27282-1-git-send-email-haiyangz@exchange.microsoft.com> References: <1498088447-27282-1-git-send-email-haiyangz@exchange.microsoft.com> Reply-To: haiyangz@microsoft.com X-CMAE-Envelope: MS4wfPyRGYnRa0Op0rvZLBinvpF0vKbzPin08Rf8kGm1LdttAqflS1W+v6Ng0KL20NEds688Uorg2PfcIySYC6AK8DfAgOOmecMzF3Ti9whDydsesofQJYYx QgRvrD5RnvhxHcd2iGWQLPmZ+3LaSEjMjcN5RjZPpYf9MqSWWbub5UrNJhebsREQ70lMQov9QiQd3Gyr9oG2y35tHQ0wr7ogo2Aw7hxSqF/hfKSNHgxndkdQ +l8MhSUDpNC3AzMzOvqzjrI1TtzEZjgFouVUJlE+GfOj+qsqfauiceYc/vZt/4g/3NiP7+xAmVAGmgKioTBGmolQZJYaSEn9XOuzt+fB0RnkRg7NUVTdeLDg CTE3+7CoDk7C4ONrr2u8qSRUA6iFwg== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haiyang Zhang When the VF NIC is opened, the synthetic NIC's carrier state is set to off. This tells the host to transitions data path to the VF device. But if startup script or user manipulates the admin state of the netvsc device directly for example: # ifconfig eth0 down # ifconfig eth0 up Then the carrier state of the synthetic NIC would be on, even though the data path was still over the VF NIC. This patch sets the carrier state of synthetic NIC with consideration of the related VF state. Signed-off-by: Haiyang Zhang Reviewed-by: Stephen Hemminger --- drivers/net/hyperv/hyperv_net.h | 2 ++ drivers/net/hyperv/netvsc.c | 2 ++ drivers/net/hyperv/netvsc_drv.c | 8 +++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index ced947d..d6c2558 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -717,6 +717,8 @@ struct net_device_context { u32 vf_alloc; /* Serial number of the VF to team with */ u32 vf_serial; + + bool datapath; /* 0 - synthetic, 1 - VF nic */ }; /* Per channel data */ diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 7c5ed8f..0a9167d 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -57,6 +57,8 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf) sizeof(struct nvsp_message), (unsigned long)init_pkt, VM_PKT_DATA_INBAND, 0); + + net_device_ctx->datapath = vf; } static struct netvsc_device *alloc_net_device(void) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 9a6c586..9913721 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -68,7 +68,8 @@ static void netvsc_set_multicast_list(struct net_device *net) static int netvsc_open(struct net_device *net) { - struct netvsc_device *nvdev = net_device_to_netvsc_device(net); + struct net_device_context *ndev_ctx = netdev_priv(net); + struct netvsc_device *nvdev = ndev_ctx->nvdev; struct rndis_device *rdev; int ret = 0; @@ -84,7 +85,7 @@ static int netvsc_open(struct net_device *net) netif_tx_wake_all_queues(net); rdev = nvdev->extension; - if (!rdev->link_state) + if (!rdev->link_state && !ndev_ctx->datapath) netif_carrier_on(net); return ret; @@ -1284,7 +1285,8 @@ static void netvsc_link_change(struct work_struct *w) case RNDIS_STATUS_MEDIA_CONNECT: if (rdev->link_state) { rdev->link_state = false; - netif_carrier_on(net); + if (!ndev_ctx->datapath) + netif_carrier_on(net); netif_tx_wake_all_queues(net); } else { notify = true; -- 1.7.1