summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2004-08-08 19:01:21 +0000
committerBrad Smith <brad@cvs.openbsd.org>2004-08-08 19:01:21 +0000
commit8a0c24c71f1196b735373a9d574c7bfb8c7e2ee8 (patch)
treec5f51cdf945bb50e393d9dac90223fda19a6d31c
parentbadf9a5ca2736f560550a0544450d6a099cf391b (diff)
do not reset the chip (and subsequently the phy) when unnecessary; that is,
for address changes, multicast filter changes, or adjusting promiscuous mode. Fixes resetting the phy for things like start/stopping tcpdump. From NetBSD tested by me, miod@, otto@ and a few others. ok deraadt@
-rw-r--r--sys/arch/sparc/dev/hme.c32
-rw-r--r--sys/arch/sparc/dev/hmevar.h4
-rw-r--r--sys/dev/ic/hme.c30
-rw-r--r--sys/dev/ic/hmevar.h3
4 files changed, 53 insertions, 16 deletions
diff --git a/sys/arch/sparc/dev/hme.c b/sys/arch/sparc/dev/hme.c
index d25c807bf94..d020ff8290b 100644
--- a/sys/arch/sparc/dev/hme.c
+++ b/sys/arch/sparc/dev/hme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hme.c,v 1.42 2003/06/18 19:11:49 jason Exp $ */
+/* $OpenBSD: hme.c,v 1.43 2004/08/08 19:01:20 brad Exp $ */
/*
* Copyright (c) 1998 Jason L. Wright (jason@thought.net)
@@ -248,6 +248,7 @@ hmeattach(parent, self, aux)
ifp->if_watchdog = hmewatchdog;
ifp->if_flags =
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
+ sc->sc_if_flags = ifp->if_flags;
ifp->if_capabilities |= IFCAP_VLAN_MTU;
IFQ_SET_MAXLEN(&ifp->if_snd, HME_TX_RING_SIZE);
IFQ_SET_READY(&ifp->if_snd);
@@ -391,11 +392,15 @@ hmeioctl(ifp, cmd, data)
switch (cmd) {
case SIOCSIFADDR:
- ifp->if_flags |= IFF_UP;
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- hmeinit(sc);
+ if (ifp->if_flags & IFF_UP)
+ hme_mcreset(sc);
+ else {
+ ifp->if_flags |= IFF_UP;
+ hmeinit(sc);
+ }
arp_ifinit(&sc->sc_arpcom, ifa);
break;
#endif /* INET */
@@ -418,6 +423,7 @@ hmeioctl(ifp, cmd, data)
}
#endif /* NS */
default:
+ ifp->if_flags |= IFF_UP;
hmeinit(sc);
break;
}
@@ -441,11 +447,19 @@ hmeioctl(ifp, cmd, data)
hmeinit(sc);
} else {
/*
- * Reset the interface to pick up changes in any other
- * flags that affect hardware registers.
+ * If setting debug or promiscuous mode, do not reset
+ * the chip; for everything else, call hmeinit()
+ * which will trigger a reset.
*/
- hmestop(sc);
- hmeinit(sc);
+#define RESETIGN (IFF_CANTCHANGE | IFF_DEBUG)
+ if (ifp->if_flags == sc->sc_if_flags)
+ break;
+ if ((ifp->if_flags & (~RESETIGN))
+ == (sc->sc_if_flags & (~RESETIGN)))
+ hme_mcreset(sc);
+ else
+ hmeinit(sc);
+#undef RESETIGN
}
break;
@@ -471,6 +485,8 @@ hmeioctl(ifp, cmd, data)
default:
error = EINVAL;
}
+
+ sc->sc_if_flags = ifp->if_flags;
splx(s);
return (error);
}
@@ -610,6 +626,7 @@ hmeinit(sc)
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
+ sc->sc_if_flags = ifp->if_flags;
ifp->if_timer = 0;
}
@@ -1137,4 +1154,5 @@ hme_mii_statchg(self)
cr->tx_cfg &= ~CR_TXCFG_FULLDPLX;
sc->sc_arpcom.ac_if.if_flags &= ~IFF_SIMPLEX;
}
+ sc->sc_if_flags = sc->sc_arpcom.ac_if.if_flags;
}
diff --git a/sys/arch/sparc/dev/hmevar.h b/sys/arch/sparc/dev/hmevar.h
index eff7e00fb60..a6e6a749755 100644
--- a/sys/arch/sparc/dev/hmevar.h
+++ b/sys/arch/sparc/dev/hmevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hmevar.h,v 1.9 2003/06/18 19:13:01 jason Exp $ */
+/* $OpenBSD: hmevar.h,v 1.10 2004/08/08 19:01:20 brad Exp $ */
/*
* Copyright (c) 1998 Jason L. Wright (jason@thought.net)
@@ -50,6 +50,8 @@ struct hme_softc {
u_int32_t sc_flags; /* status flags */
+ short sc_if_flags;
+
/*
* RX/TX ring buffers, descriptors, and counters
*/
diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c
index 199b00769a8..ecfc99b537f 100644
--- a/sys/dev/ic/hme.c
+++ b/sys/dev/ic/hme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hme.c,v 1.31 2004/05/31 01:51:30 mcbride Exp $ */
+/* $OpenBSD: hme.c,v 1.32 2004/08/08 19:01:20 brad Exp $ */
/* $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */
/*-
@@ -239,6 +239,7 @@ hme_config(sc)
ifp->if_watchdog = hme_watchdog;
ifp->if_flags =
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
+ sc->sc_if_flags = ifp->if_flags;
IFQ_SET_READY(&ifp->if_snd);
ifp->if_capabilities |= IFCAP_VLAN_MTU;
@@ -621,6 +622,7 @@ hme_init(sc)
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
+ sc->sc_if_flags = ifp->if_flags;
ifp->if_timer = 0;
hme_start(ifp);
}
@@ -1045,6 +1047,7 @@ hme_mii_statchg(dev)
v &= ~HME_MAC_TXCFG_FULLDPLX;
sc->sc_arpcom.ac_if.if_flags &= ~IFF_SIMPLEX;
}
+ sc->sc_if_flags = sc->sc_arpcom.ac_if.if_flags;
bus_space_write_4(t, mac, HME_MACI_TXCFG, v);
}
@@ -1123,12 +1126,15 @@ hme_ioctl(ifp, cmd, data)
switch (cmd) {
case SIOCSIFADDR:
- ifp->if_flags |= IFF_UP;
-
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- hme_init(sc);
+ if (ifp->if_flags & IFF_UP)
+ hme_setladrf(sc);
+ else {
+ ifp->if_flags |= IFF_UP;
+ hme_init(sc);
+ }
arp_ifinit(&sc->sc_arpcom, ifa);
break;
#endif
@@ -1156,10 +1162,19 @@ hme_ioctl(ifp, cmd, data)
hme_init(sc);
} else if ((ifp->if_flags & IFF_UP) != 0) {
/*
- * Reset the interface to pick up changes in any other
- * flags that affect hardware registers.
+ * If setting debug or promiscuous mode, do not reset
+ * the chip; for everything else, call hme_init()
+ * which will trigger a reset.
*/
- hme_init(sc);
+#define RESETIGN (IFF_CANTCHANGE | IFF_DEBUG)
+ if (ifp->if_flags == sc->sc_if_flags)
+ break;
+ if ((ifp->if_flags & (~RESETIGN))
+ == (sc->sc_if_flags & (~RESETIGN)))
+ hme_setladrf(sc);
+ else
+ hme_init(sc);
+#undef RESETIGN
}
#ifdef HMEDEBUG
sc->sc_debug = (ifp->if_flags & IFF_DEBUG) != 0 ? 1 : 0;
@@ -1192,6 +1207,7 @@ hme_ioctl(ifp, cmd, data)
break;
}
+ sc->sc_if_flags = ifp->if_flags;
splx(s);
return (error);
}
diff --git a/sys/dev/ic/hmevar.h b/sys/dev/ic/hmevar.h
index 59d53def1fb..0e1b02fd42a 100644
--- a/sys/dev/ic/hmevar.h
+++ b/sys/dev/ic/hmevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hmevar.h,v 1.7 2002/11/20 22:07:45 jason Exp $ */
+/* $OpenBSD: hmevar.h,v 1.8 2004/08/08 19:01:20 brad Exp $ */
/* $NetBSD: hmevar.h,v 1.6 2000/09/28 10:56:57 tsutsui Exp $ */
/*-
@@ -87,6 +87,7 @@ struct hme_softc {
int sc_debug;
void *sc_sh; /* shutdownhook cookie */
+ short sc_if_flags;
u_int8_t sc_enaddr[ETHER_ADDR_LEN]; /* MAC address */
/* Special hardware hooks */