Current Netpoll init does not trust carrier detected 
right upon bringing  the NIC up and waits for a delay 
before allowing boot to continue.

The delay varied with the kernel version:
 10 seconds in 2.6.11
   3 seconds in 2.6.12
   4 seconds in 2.6.13 and later

Any significant delay is undesired in production 
environments as 3 seconds boot the entire kernel. 

The patch reduces the delay to about 300msec + 
NIC startup time.

The adjusted timeout mechanism polls the carrier every 100ms
and polls for a good carrier for N_CARRIER_POLL (3)
_consecutive_ cycles or 10s maximum.

The patch is in use on a dozen x86 systems with 2.6.11
since June. 

Signed-off-by: Michael Frank <[EMAIL PROTECTED]>

---

 netpoll.c |   54 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 31 insertions(+), 23 deletions(-)


Patch file: netp-timeout-mhfp16
--- linux-2.6.15-rc2-mhf260/net/core/netpoll.c.001      2005-11-21 
08:28:58.000000000 +0100
+++ linux-2.6.15-rc2-mhf260/net/core/netpoll.c  2005-11-21 09:08:15.000000000 
+0100
@@ -1,7 +1,8 @@
 /*
  * Common framework for low-level network console, dump, and debugger code
  *
- * Sep 8 2003  Matt Mackall <[EMAIL PROTECTED]>
+ * Sep 8  2003  Matt Mackall  <[EMAIL PROTECTED]>
+ * Jun 13 2005  Michael Frank <[EMAIL PROTECTED]> Adjust carrier timeout logic
  *
  * based on the netconsole code from:
  *
@@ -69,6 +70,8 @@
                                (MAX_UDP_CHUNK + sizeof(struct udphdr) + \
                                sizeof(struct iphdr) + sizeof(struct ethhdr))
 
+#define N_CARRIER_POLL 3 
+
 static void zap_completion_queue(void);
 
 static void queue_process(void *p)
@@ -673,6 +676,7 @@
 
        if (!netif_running(ndev)) {
                unsigned long atmost, atleast;
+               int pollcarrier;
 
                printk(KERN_INFO "%s: device %s not up yet, forcing it\n",
                                                        np->name, np->dev_name);
@@ -686,31 +690,35 @@
                }
                rtnl_shunlock();
 
-               atleast = jiffies + HZ/10;
-               atmost = jiffies + 4*HZ;
-               while (!netif_carrier_ok(ndev)) {
-                       if (time_after(jiffies, atmost)) {
-                               printk(KERN_NOTICE
-                                       "%s: timeout waiting for carrier\n",
-                                                               np->name);
-                               break;
-                       }
-                       cond_resched();
-               }
-
-               /* If carrier appears to come up instantly, we don't
-                * trust it and pause so that we don't pump all our
-                * queued console messages into the bitbucket.
+               /* Wait for carrier:
+                *      Until carrier detected for N_CARRIER_POLL
+                *      consecutive 100ms intervals.
+                *
+                *      At most 10s.
                 */
-
-               if (time_before(jiffies, atleast)) {
-                       printk(KERN_NOTICE "%s: carrier detect appears"
-                                       " untrustworthy, waiting 4 seconds\n",
-                                                               np->name);
-                       msleep(4000);
+               
+               pollcarrier = N_CARRIER_POLL;
+               atmost = jiffies + 10 * HZ;
+
+               while (pollcarrier--) {
+                       atleast = jiffies + HZ / 10;
+
+                       while (time_before(jiffies, atleast))
+                               cond_resched();
+
+                       while (!netif_carrier_ok(ndev)) {
+                               pollcarrier = N_CARRIER_POLL;
+                               if (time_after(jiffies, atmost)) {
+                                       printk(KERN_NOTICE "%s: timeout"
+                                                       "waiting for carrier",
+                                                       np->name);
+                                       goto out;
+                               }
+                               cond_resched();
+                       }
                }
        }
-
+out:
        if (!memcmp(np->local_mac, "\0\0\0\0\0\0", 6) && ndev->dev_addr)
                memcpy(np->local_mac, ndev->dev_addr, 6);
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to