Module Name:    src
Committed By:   tsutsui
Date:           Sun Apr 12 11:10:29 UTC 2009

Modified Files:
        src/sys/dev/sbus: if_le_ledma.c

Log Message:
Don't immediately switch UTP/AUI ports on lost carrior.
It may take a while for modern switches to set 10baseT media.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sbus/if_le_ledma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sbus/if_le_ledma.c
diff -u src/sys/dev/sbus/if_le_ledma.c:1.30 src/sys/dev/sbus/if_le_ledma.c:1.31
--- src/sys/dev/sbus/if_le_ledma.c:1.30	Mon Apr 28 20:23:57 2008
+++ src/sys/dev/sbus/if_le_ledma.c	Sun Apr 12 11:10:28 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_le_ledma.c,v 1.30 2008/04/28 20:23:57 martin Exp $	*/
+/*	$NetBSD: if_le_ledma.c,v 1.31 2009/04/12 11:10:28 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_ledma.c,v 1.30 2008/04/28 20:23:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_ledma.c,v 1.31 2009/04/12 11:10:28 tsutsui Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -83,6 +83,8 @@
 	bus_space_handle_t	sc_reg;		/* LANCE registers */
 	struct	lsi64854_softc	*sc_dma;	/* pointer to my dma */
 	u_int			sc_laddr;	/* LANCE DMA address */
+	u_int			sc_lostcount;
+#define LE_LOSTTHRESH	5	/* lost carrior count to switch media */
 };
 
 #define MEMSIZE		(16*1024)	/* LANCE memory size */
@@ -277,6 +279,12 @@
 {
 	struct le_softc *lesc = (struct le_softc *)sc;
 
+	/* it may take a while for modern switches to set 10baseT media */
+	if (lesc->sc_lostcount++ < LE_LOSTTHRESH)
+		return;
+
+	lesc->sc_lostcount = 0;
+
 	/*
 	 * Check if the user has requested a certain cable type, and
 	 * if so, honor that request.
@@ -379,7 +387,7 @@
 	lesc->sc_laddr = lesc->sc_dmamap->dm_segs[0].ds_addr;
 	sc->sc_addr = lesc->sc_laddr & 0xffffff;
 	sc->sc_conf3 = LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON;
-
+	lesc->sc_lostcount = 0;
 
 	/* Assume SBus is grandparent */
 	lesc->sc_sd.sd_reset = (void *)lance_reset;

Reply via email to