diff options
| author | jdolecek <jdolecek@NetBSD.org> | 2001-06-18 11:06:26 +0000 |
|---|---|---|
| committer | jdolecek <jdolecek@NetBSD.org> | 2001-06-18 11:06:26 +0000 |
| commit | e65b619faa3acd39cda8c58a9eba2bef8d2f3263 (patch) | |
| tree | 2521a781bf3b1ff3b69405fc18503ed18657fa90 | |
| parent | 684e89f355f1690be1b9d55223b802431ed6dbb0 (diff) | |
Convert to use ether_ioctl() for SIOCSIFADDR and SIOCSIFFLAGS.
| -rw-r--r-- | sys/dev/ic/lance.c | 121 | ||||
| -rw-r--r-- | sys/dev/ic/lancevar.h | 4 | ||||
| -rw-r--r-- | sys/dev/pci/if_le_pci.c | 4 |
3 files changed, 30 insertions, 99 deletions
diff --git a/sys/dev/ic/lance.c b/sys/dev/ic/lance.c index d2c4bd28cdb..fccfcd88856 100644 --- a/sys/dev/ic/lance.c +++ b/sys/dev/ic/lance.c @@ -1,4 +1,4 @@ -/* $NetBSD: lance.c,v 1.19 2001/05/30 11:46:33 mrg Exp $ */ +/* $NetBSD: lance.c,v 1.20 2001/06/18 11:06:26 jdolecek Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -75,10 +75,8 @@ * @(#)if_le.c 8.2 (Berkeley) 11/16/93 */ -#include "opt_inet.h" #include "opt_ccitt.h" #include "opt_llc.h" -#include "opt_ns.h" #include "bpfilter.h" #include "rnd.h" @@ -100,19 +98,6 @@ #include <net/if_ether.h> #include <net/if_media.h> -#ifdef INET -#include <netinet/in.h> -#include <netinet/if_inarp.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> -#endif - -#ifdef NS -#include <netns/ns.h> -#include <netns/ns_if.h> -#endif - #if defined(CCITT) && defined(LLC) #include <sys/socketvar.h> #include <netccitt/x25.h> @@ -150,7 +135,7 @@ void lance_mediastatus __P((struct ifnet *, struct ifmediareq *)); static inline u_int16_t ether_cmp __P((void *, void *)); -void lance_stop __P((struct lance_softc *)); +void lance_stop __P((struct ifnet *, int)); int lance_ioctl __P((struct ifnet *, u_long, caddr_t)); void lance_watchdog __P((struct ifnet *)); @@ -204,16 +189,12 @@ ether_cmp(one, two) static u_int16_t bcast_enaddr[3] = { ~0, ~0, ~0 }; #endif -#define ifp (&sc->sc_ethercom.ec_if) - void lance_config(sc) struct lance_softc *sc; { int i, nbuf; - - /* Make sure the chip is stopped. */ - lance_stop(sc); + struct ifnet *ifp = &sc->sc_ethercom.ec_if; /* Initialize ifnet structure. */ bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); @@ -221,6 +202,8 @@ lance_config(sc) ifp->if_start = sc->sc_start; ifp->if_ioctl = lance_ioctl; ifp->if_watchdog = lance_watchdog; + ifp->if_init = lance_init; + ifp->if_stop = lance_stop; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; #ifdef LANCE_REVC_BUG @@ -276,13 +259,16 @@ lance_config(sc) printf("%s: %d receive buffers, %d transmit buffers\n", sc->sc_dev.dv_xname, sc->sc_nrbuf, sc->sc_ntbuf); + /* Make sure the chip is stopped. */ + lance_stop(ifp, 0); + /* claim 802.1q capability */ sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; /* Attach the interface. */ if_attach(ifp); ether_ifattach(ifp, sc->sc_enaddr); - sc->sc_sh = shutdownhook_establish(lance_shutdown, sc); + sc->sc_sh = shutdownhook_establish(lance_shutdown, ifp); if (sc->sc_sh == NULL) panic("lance_config: can't establish shutdownhook"); sc->sc_rbufaddr = malloc(sc->sc_nrbuf * sizeof(int), M_DEVBUF, @@ -303,14 +289,16 @@ lance_reset(sc) int s; s = splnet(); - lance_init(sc); + lance_init(&sc->sc_ethercom.ec_if); splx(s); } void -lance_stop(sc) - struct lance_softc *sc; +lance_stop(ifp, disable) + struct ifnet *ifp; + int disable; { + struct lance_softc *sc = ifp->if_softc; (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_STOP); } @@ -319,10 +307,11 @@ lance_stop(sc) * Initialization of interface; set up initialization block * and transmit/receive descriptor rings. */ -void -lance_init(sc) - struct lance_softc *sc; +int +lance_init(ifp) + struct ifnet *ifp; { + struct lance_softc *sc = ifp->if_softc; int timo; u_long a; @@ -366,6 +355,8 @@ lance_init(sc) sc->sc_dev.dv_xname); if (sc->sc_hwinit) (*sc->sc_hwinit)(sc); + + return (0); } /* @@ -416,7 +407,7 @@ lance_get(sc, boff, totlen) MGETHDR(m0, M_DONTWAIT, MT_DATA); if (m0 == 0) return (0); - m0->m_pkthdr.rcvif = ifp; + m0->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if; m0->m_pkthdr.len = totlen; len = MHLEN; m = m0; @@ -467,6 +458,7 @@ lance_read(sc, boff, len) int boff, len; { struct mbuf *m; + struct ifnet *ifp = &sc->sc_ethercom.ec_if; #ifdef LANCE_REVC_BUG struct ether_header *eh; #endif @@ -583,37 +575,8 @@ lance_ioctl(ifp, cmd, data) switch (cmd) { case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - lance_init(sc); - arp_ifinit(ifp, ifa); - break; -#endif -#ifdef NS - case AF_NS: - { - struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)LLADDR(ifp->if_sadl); - else { - bcopy(ina->x_host.c_host, - LLADDR(ifp->if_sadl), - sizeof(sc->sc_enaddr)); - } - /* Set new address. */ - lance_init(sc); - break; - } -#endif - default: - lance_init(sc); - break; - } + case SIOCSIFFLAGS: + error = ether_ioctl(ifp, cmd, data); break; #if defined(CCITT) && defined(LLC) @@ -622,42 +585,10 @@ lance_ioctl(ifp, cmd, data) ifa->ifa_rtrequest = cons_rtrequest; /* XXX */ error = x25_llcglue(PRC_IFUP, ifa->ifa_addr); if (error == 0) - lance_init(sc); + lance_init(&sc->sc_ethercom.ec_if); break; #endif /* CCITT && LLC */ - 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. - */ - lance_stop(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. - */ - lance_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. - */ - /*lance_stop(sc);*/ - lance_init(sc); - } -#ifdef LEDEBUG - if (ifp->if_flags & IFF_DEBUG) - sc->sc_debug = 1; - else - sc->sc_debug = 0; -#endif - break; - case SIOCADDMULTI: case SIOCDELMULTI: error = (cmd == SIOCADDMULTI) ? @@ -693,7 +624,7 @@ lance_shutdown(arg) void *arg; { - lance_stop((struct lance_softc *)arg); + lance_stop((struct ifnet *)arg, 0); } /* diff --git a/sys/dev/ic/lancevar.h b/sys/dev/ic/lancevar.h index 03e778782e2..0e0c38fcefc 100644 --- a/sys/dev/ic/lancevar.h +++ b/sys/dev/ic/lancevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: lancevar.h,v 1.3 2000/09/28 10:56:57 tsutsui Exp $ */ +/* $NetBSD: lancevar.h,v 1.4 2001/06/18 11:06:26 jdolecek Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -135,7 +135,7 @@ struct lance_softc { void lance_config __P((struct lance_softc *)); void lance_reset __P((struct lance_softc *)); -void lance_init __P((struct lance_softc *)); +int lance_init __P((struct ifnet *)); int lance_put __P((struct lance_softc *, int, struct mbuf *)); void lance_read __P((struct lance_softc *, int, int)); void lance_setladrf __P((struct ethercom *, u_int16_t *)); diff --git a/sys/dev/pci/if_le_pci.c b/sys/dev/pci/if_le_pci.c index 38c96272091..aed402fc3a6 100644 --- a/sys/dev/pci/if_le_pci.c +++ b/sys/dev/pci/if_le_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le_pci.c,v 1.32 2001/06/12 22:28:16 thorpej Exp $ */ +/* $NetBSD: if_le_pci.c,v 1.33 2001/06/18 11:06:27 jdolecek Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -200,7 +200,7 @@ le_pci_mediachange(sc) sc->sc_initmodemedia = 1; /* UTP */ else sc->sc_initmodemedia = 0; /* AUI */ - lance_init(sc); + lance_init(&sc->sc_ethercom.ec_if); if (IFM_SUBTYPE(lesc->sc_currentmedia) == IFM_AUTO) { /* take away autoselect - BCR2 bit 1 */ |
