netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Stephen Hemminger <sthemmin@microsoft.com>
Subject: [PATCH] hv_netvsc: update VF after name has changed.
Date: Wed, 20 Dec 2017 14:33:23 -0800	[thread overview]
Message-ID: <20171220223323.21125-1-sthemmin@microsoft.com> (raw)

Since commit 6123c66854c1 ("netvsc: delay setup of VF device")
the automatic bring up of the VF is delayed to allow userspace (udev)
a chance to rename the device. This delay is problematic because
it delays boot and may not be long enough for some cases.

Instead, use the rename can be used to trigger the next step
in setup to happen immediately.

The VF initialization sequence now looks like:
   * hotplug causes VF network device probe to create network device
   * netvsc notifier joins VF with netvsc and schedules VF to be
     setup after timer expires
   * udev in userspace renames device
   * if netvsc notifier detects rename, it can cancel timer
     and do immediate setup

The delay can also be increased to allow for slower rules.
Still need the delayed work to handle the case where rename is
not done.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index c5584c2d440e..7771d6c54b55 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -49,7 +49,7 @@
 #define RING_SIZE_MIN		64
 
 #define LINKCHANGE_INT (2 * HZ)
-#define VF_TAKEOVER_INT (HZ / 10)
+#define VF_TAKEOVER_INT (HZ / 4)
 
 static unsigned int ring_size __ro_after_init = 128;
 module_param(ring_size, uint, S_IRUGO);
@@ -1894,6 +1894,26 @@ static int netvsc_vf_changed(struct net_device *vf_netdev)
 	return NOTIFY_OK;
 }
 
+/* If VF was renamed, then udev (or other tool) has done its
+ * work and the VF can be brought up.
+ */
+static int netvsc_vf_renamed(struct net_device *vf_netdev)
+{
+	struct net_device_context *ndev_ctx;
+	struct net_device *ndev;
+
+	ndev = get_netvsc_byref(vf_netdev);
+	if (!ndev)
+		return NOTIFY_DONE;
+
+	ndev_ctx = netdev_priv(ndev);
+
+	if (cancel_delayed_work(&ndev_ctx->vf_takeover))
+		__netvsc_vf_setup(ndev, vf_netdev);
+
+	return NOTIFY_OK;
+}
+
 static int netvsc_unregister_vf(struct net_device *vf_netdev)
 {
 	struct net_device *ndev;
@@ -2110,6 +2130,8 @@ static int netvsc_netdev_event(struct notifier_block *this,
 	case NETDEV_UP:
 	case NETDEV_DOWN:
 		return netvsc_vf_changed(event_dev);
+	case NETDEV_CHANGENAME:
+		return netvsc_vf_renamed(event_dev);
 	default:
 		return NOTIFY_DONE;
 	}
-- 
2.11.0

             reply	other threads:[~2017-12-20 22:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 22:33 Stephen Hemminger [this message]
2017-12-26 17:25 ` [PATCH] hv_netvsc: update VF after name has changed David Miller
2017-12-26 21:51   ` Stephen Hemminger
2017-12-26 22:11     ` David Miller
2017-12-26 23:46       ` Stephen Hemminger
2018-01-25 19:19       ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171220223323.21125-1-sthemmin@microsoft.com \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=sthemmin@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).