From patchwork Fri Aug 4 14:54:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 797839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="fzbVTxbM"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xP92R189yz9t24; Sat, 5 Aug 2017 00:55:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dde0K-0007J2-6G; Fri, 04 Aug 2017 14:55:08 +0000 Received: from mail-qt0-f177.google.com ([209.85.216.177]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dde0E-0007Gc-UY for kernel-team@lists.ubuntu.com; Fri, 04 Aug 2017 14:55:03 +0000 Received: by mail-qt0-f177.google.com with SMTP id p3so10500485qtg.2 for ; Fri, 04 Aug 2017 07:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ONEYza4SzpKkat8cSlNkpZCKRgKEhK3KNl8jeSJs2gk=; b=fzbVTxbML9N2OUOOyeMHoqRRY/oLb3NxaJiVrpnwXlwsV/tvUL38eluDxX/cfMakT2 1ikst200C+zFlJo3jSdyCqSKMpl5VLHegw+sC+0gnFNp/kK3qaNCNioRR+D5Z7SD7bW1 rC/F9YGdj3nxAjw0zme949LaKFzo/Eo6G/LqeYQznz77//JTVmAYeBXMY7hn8mRCX5Sv P3nY7B81qS24AX0aKJR4djq9IOC4amc04K37l4hBOp17o/ZoSIMWRZ0sS6aLzaizfbc3 fowDK6XMmhPeyNZy7fZmZZiyAljQdtlT2QxntirRjltd8I004Vfzvx3EpTB90kU4Y0wk ZxJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ONEYza4SzpKkat8cSlNkpZCKRgKEhK3KNl8jeSJs2gk=; b=CMpkNZgMM1zSo7jboFLnGQtEQfRlQ+VPgZaqd/dbj0zb837uOg3YJNp11H0EZP+vUp rEoxRWqLPsZSf0+G0AF5xLI7v6hprpdrHgsN+BT7kEayyrsumy/CSO1OTtCAMV6kCJjr HUZrizxWV1lw5wbG2wLA8n4TTCPLhf++IjoP7vsPlcxWlBMLtBx8LWFBw4lRVgsp2YT/ 4qYlQWYl1Hwx1KrDe+Dt0VSdKmrSMZVN5sla2pbxd5LJbLAFFHuMrYLjb4E7EXjesN6R rYkBhP7KwUEJ+IsQzGG7qSlv29BRIXoZMoAWNxWAuQrARn3uKLA3t7W35TRt9r/VbpDu OJFg== X-Gm-Message-State: AHYfb5gqzKSSrRRliidm1j0ccc+nii1OaUwZ2lauJ77teLCAvO8CWUcB CFs/GBKlOffETb4khgc= X-Received: by 10.200.51.244 with SMTP id d49mr3519728qtb.32.1501858501613; Fri, 04 Aug 2017 07:55:01 -0700 (PDT) Received: from localhost.localdomain ([191.8.84.147]) by smtp.gmail.com with ESMTPSA id z47sm1194750qth.87.2017.08.04.07.54.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Aug 2017 07:55:00 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure][PATCH v1 4/9] hv_netvsc: Fix the carrier state error when data path is off Date: Fri, 4 Aug 2017 11:54:39 -0300 Message-Id: <1501858484-28849-5-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501858484-28849-1-git-send-email-marcelo.cerri@canonical.com> References: <1501858484-28849-1-git-send-email-marcelo.cerri@canonical.com> Cc: Josh Poulson , Stephen Hemminger X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Haiyang Zhang BugLink: http://bugs.launchpad.net/bugs/1708469 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 Signed-off-by: David S. Miller (cherry picked from commit 53fa1a6f33520f01f9dbee48369074b34d77616b) Signed-off-by: Marcelo Henrique Cerri --- 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 880572765b5d..27b71b701e2d 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -722,6 +722,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 6a2f295d94df..de3aa1cb2611 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -60,6 +60,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 1825929db52a..c506033c0c1b 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -76,7 +76,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; @@ -92,7 +93,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; @@ -1317,7 +1318,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;