diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2006-08-05 21:38:21 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2006-08-05 21:38:21 +0000 |
commit | 5ac3d139747d44e46558780696f597f610738166 (patch) | |
tree | b5452b776d870db41ef2077fc09efbe1e3195250 /sys/dev/ic | |
parent | c1e52cec9c4ff6e5effd5ec092f354a270ec24e0 (diff) |
- move the promiscuous mode handling code into re_setpromisc().
- have the NIC track the state and only set the promisc filter
if IFF_PROMISC is adjusted, otherwise only init the NIC if it
is not already running.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/re.c | 63 | ||||
-rw-r--r-- | sys/dev/ic/rtl81x9reg.h | 3 |
2 files changed, 38 insertions, 28 deletions
diff --git a/sys/dev/ic/re.c b/sys/dev/ic/re.c index 8845422cdd6..5faa23d6f79 100644 --- a/sys/dev/ic/re.c +++ b/sys/dev/ic/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.38 2006/08/05 21:03:22 brad Exp $ */ +/* $OpenBSD: re.c,v 1.39 2006/08/05 21:38:20 brad Exp $ */ /* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -187,6 +187,7 @@ void re_miibus_writereg(struct device *, int, int, int); void re_miibus_statchg(struct device *); void re_setmulti(struct rl_softc *); +void re_setpromisc(struct rl_softc *); void re_reset(struct rl_softc *); #ifdef RE_DIAG @@ -520,6 +521,22 @@ re_setmulti(struct rl_softc *sc) } void +re_setpromisc(struct rl_softc *sc) +{ + struct ifnet *ifp; + u_int32_t rxcfg = 0; + + ifp = &sc->sc_arpcom.ac_if; + + rxcfg = CSR_READ_4(sc, RL_RXCFG); + if (ifp->if_flags & IFF_PROMISC) + rxcfg |= RL_RXCFG_RX_ALLPHYS; + else + rxcfg &= ~RL_RXCFG_RX_ALLPHYS; + CSR_WRITE_4(sc, RL_RXCFG, rxcfg); +} + +void re_reset(struct rl_softc *sc) { int i; @@ -886,11 +903,8 @@ re_attach(struct rl_softc *sc) ifp->if_start = re_start; ifp->if_watchdog = re_watchdog; ifp->if_init = re_init; - if (sc->rl_type == RL_8169) { - ifp->if_baudrate = 1000000000; + if (sc->rl_type == RL_8169) ifp->if_hardmtu = RL_JUMBO_MTU; - } else - ifp->if_baudrate = 100000000; IFQ_SET_MAXLEN(&ifp->if_snd, RL_TX_QLEN); IFQ_SET_READY(&ifp->if_snd); @@ -1754,13 +1768,6 @@ re_init(struct ifnet *ifp) rxcfg = CSR_READ_4(sc, RL_RXCFG); rxcfg |= RL_RXCFG_RX_INDIV; - /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) - rxcfg |= RL_RXCFG_RX_ALLPHYS; - else - rxcfg &= ~RL_RXCFG_RX_ALLPHYS; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - /* * Set capture broadcast bit to capture broadcast frames. */ @@ -1768,8 +1775,12 @@ re_init(struct ifnet *ifp) rxcfg |= RL_RXCFG_RX_BROAD; else rxcfg &= ~RL_RXCFG_RX_BROAD; + CSR_WRITE_4(sc, RL_RXCFG, rxcfg); + /* Set promiscuous mode. */ + re_setpromisc(sc); + /* * Program the multicast filter, if necessary. */ @@ -1888,36 +1899,34 @@ re_ioctl(struct ifnet *ifp, u_long command, caddr_t data) switch(command) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: + if (!(ifp->if_flags & IFF_RUNNING)) re_init(ifp); +#ifdef INET + if (ifa->ifa_addr->sa_family == AF_INET) arp_ifinit(&sc->sc_arpcom, ifa); - break; #endif /* INET */ - default: - re_init(ifp); - break; - } break; case SIOCSIFMTU: - if (ifr->ifr_mtu < ETHERMIN || - ((sc->rl_type == RL_8169 && - ifr->ifr_mtu > RL_JUMBO_MTU) || - (sc->rl_type == RL_8139 && - ifr->ifr_mtu > ETHERMTU))) + if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ifp->if_hardmtu) error = EINVAL; else if (ifp->if_mtu != ifr->ifr_mtu) ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { - re_init(ifp); + if (ifp->if_flags & IFF_RUNNING && + ((ifp->if_flags ^ sc->if_flags) & + IFF_PROMISC)) { + re_setpromisc(sc); + } else { + if (!(ifp->if_flags & IFF_RUNNING)) + re_init(ifp); + } } else { if (ifp->if_flags & IFF_RUNNING) re_stop(ifp, 1); } - error = 0; + sc->if_flags = ifp->if_flags; break; case SIOCADDMULTI: case SIOCDELMULTI: diff --git a/sys/dev/ic/rtl81x9reg.h b/sys/dev/ic/rtl81x9reg.h index 019a29ba450..a320021f009 100644 --- a/sys/dev/ic/rtl81x9reg.h +++ b/sys/dev/ic/rtl81x9reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl81x9reg.h,v 1.26 2006/08/05 21:03:22 brad Exp $ */ +/* $OpenBSD: rtl81x9reg.h,v 1.27 2006/08/05 21:38:20 brad Exp $ */ /* * Copyright (c) 1997, 1998 @@ -703,6 +703,7 @@ struct rl_softc { int sc_flags; /* misc flags */ struct rl_chain_data rl_cdata; struct timeout sc_tick_tmo; + int if_flags; struct rl_list_data rl_ldata; struct mbuf *rl_head; |