linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ventura <david@davidv.dev>
To: david@davidv.dev
Cc: Jonathan Corbet <corbet@lwn.net>,
	"David S. Miller" <davem@davemloft.net>,
	David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Xiongwei Song <xiongwei.song@windriver.com>,
	linux-doc@vger.kernel.org (open list:DOCUMENTATION),
	linux-kernel@vger.kernel.org (open list),
	netdev@vger.kernel.org (open list:NETWORKING [IPv4/IPv6])
Subject: [PATCH v2 1/2] net: make driver settling time configurable
Date: Thu,  8 Feb 2024 10:52:29 +0100	[thread overview]
Message-ID: <20240208095358.251381-1-david@davidv.dev> (raw)
In-Reply-To: <20240208093722.246930-1-david@davidv.dev>

During IP auto configuration, some drivers apparently need to wait a
certain length of time to settle; as this is not true for all drivers,
make this length of time configurable.

Signed-off-by: David Ventura <david@davidv.dev>
---
 .../admin-guide/kernel-parameters.txt         |  4 ++++
 Documentation/admin-guide/nfs/nfsroot.rst     |  3 +++
 net/ipv4/ipconfig.c                           | 23 ++++++++++++++++---
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b47940577c10..b07a035642fa 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2291,6 +2291,10 @@
 
 	ip=		[IP_PNP]
 			See Documentation/admin-guide/nfs/nfsroot.rst.
+	ip.dev_wait_ms=
+			[IP_PNP]
+			See Documentation/admin-guide/nfs/nfsroot.rst.
+
 
 	ipcmni_extend	[KNL,EARLY] Extend the maximum number of unique System V
 			IPC identifiers from 32,768 to 16,777,216.
diff --git a/Documentation/admin-guide/nfs/nfsroot.rst b/Documentation/admin-guide/nfs/nfsroot.rst
index 135218f33394..f26f7a342af6 100644
--- a/Documentation/admin-guide/nfs/nfsroot.rst
+++ b/Documentation/admin-guide/nfs/nfsroot.rst
@@ -223,6 +223,9 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns
   /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real
   root filesystem if it is on NFS).
 
+ip.dev_wait_ms=<value>
+  Set the number of milliseconds to delay after opening the network device
+  which will be autoconfigured. Defaults to 10 milliseconds.
 
 nfsrootdebug
   This parameter enables debugging messages to appear in the kernel
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index c56b6fe6f0d7..cbf35163b973 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -82,8 +82,6 @@
 #define IPCONFIG_DYNAMIC
 #endif
 
-/* Define the friendly delay before and after opening net devices */
-#define CONF_POST_OPEN		10	/* After opening: 10 msecs */
 
 /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
 #define CONF_OPEN_RETRIES 	2	/* (Re)open devices twice */
@@ -101,6 +99,7 @@
 
 /* Wait for carrier timeout default in seconds */
 static unsigned int carrier_timeout = 120;
+static unsigned int dev_wait_ms = 10;
 
 /*
  * Public IP configuration
@@ -1516,7 +1515,8 @@ static int __init ip_auto_config(void)
 		return err;
 
 	/* Give drivers a chance to settle */
-	msleep(CONF_POST_OPEN);
+	if(dev_wait_ms > 0)
+		msleep(dev_wait_ms);
 
 	/*
 	 * If the config information is insufficient (e.g., our IP address or
@@ -1849,3 +1849,20 @@ static int __init set_carrier_timeout(char *str)
 	return 1;
 }
 __setup("carrier_timeout=", set_carrier_timeout);
+
+
+static int __init set_dev_wait_ms(char *str)
+{
+	ssize_t ret;
+
+	if (!str)
+		return 0;
+
+	ret = kstrtouint(str, 0, &dev_wait_ms);
+	if (ret)
+		return 0;
+
+	return 1;
+}
+
+__setup("ip.dev_wait_ms=", set_dev_wait_ms);
-- 
2.39.2


  reply	other threads:[~2024-02-08  9:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-08  9:35 [PATCH v2 0/2] net: ipconfig: remove wait for drivers David Ventura
2024-02-08  9:52 ` David Ventura [this message]
2024-02-08 10:26   ` [PATCH v2 1/2] net: make driver settling time configurable Denis Kirjanov
2024-02-08 16:42     ` David
2024-02-09 21:59   ` Jakub Kicinski
2024-02-09 22:11     ` Andrew Lunn
2024-02-09 23:15       ` David
2024-02-14 17:47         ` Andrew Lunn
2024-02-08 10:03 ` [PATCH v2 2/2] net: Change default delay on IP autoconfig to 0ms David Ventura
2024-02-08 10:26 ` [PATCH v2 0/2] net: ipconfig: remove wait for drivers Denis Kirjanov
2024-02-09 21:55 ` Jakub Kicinski

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=20240208095358.251381-1-david@davidv.dev \
    --to=david@davidv.dev \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=xiongwei.song@windriver.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).