-/* $OpenBSD: elink3.c,v 1.81 2014/12/22 02:28:51 tedu Exp $ */
+/* $OpenBSD: elink3.c,v 1.82 2014/12/29 02:33:13 brad Exp $ */
/* $NetBSD: elink3.c,v 1.32 1997/05/14 00:22:00 thorpej Exp $ */
/*
switch (cmd) {
case SIOCSIFADDR:
ifp->if_flags |= IFF_UP;
-
- switch (ifa->ifa_addr->sa_family) {
- case AF_INET:
+ if (!(ifp->if_flags & IFF_RUNNING))
epinit(sc);
+ if (ifa->ifa_addr->sa_family == AF_INET)
arp_ifinit(&sc->sc_arpcom, ifa);
- break;
- default:
- epinit(sc);
- break;
- }
break;
+ case SIOCSIFFLAGS:
+ if (ifp->if_flags & IFF_UP) {
+ if (ifp->if_flags & IFF_RUNNING)
+ error = ENETRESET;
+ else
+ epinit(sc);
+ } else {
+ if (ifp->if_flags & IFF_RUNNING)
+ epstop(sc);
+ }
+ break;
+
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd);
break;
- case SIOCSIFFLAGS:
- if ((ifp->if_flags & IFF_UP) == 0 &&
- (ifp->if_flags & IFF_RUNNING) != 0) {
- /*
- * If interface is marked down and it is running, then
- * stop it.
- */
- epstop(sc);
- ifp->if_flags &= ~IFF_RUNNING;
- } else if ((ifp->if_flags & IFF_UP) != 0 &&
- (ifp->if_flags & IFF_RUNNING) == 0) {
- /*
- * If interface is marked up and it is stopped, then
- * start it.
- */
- epinit(sc);
- } else if ((ifp->if_flags & IFF_UP) != 0) {
- /*
- * Reset the interface to pick up changes in any other
- * flags that affect hardware registers.
- */
- epinit(sc);
- }
- break;
-
default:
error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data);
}
void
epstop(struct ep_softc *sc)
{
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
bus_space_tag_t iot = sc->sc_iot;
bus_space_handle_t ioh = sc->sc_ioh;
+ ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+
if (sc->ep_flags & EP_FLAGS_MII) {
mii_down(&sc->sc_mii);
}