Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/le/lance.c
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
| #include <net/if_types.h> | #include <net/if_types.h> | ||||
| #include <net/if_vlan_var.h> | #include <net/if_vlan_var.h> | ||||
| #include <machine/bus.h> | #include <machine/bus.h> | ||||
| #include <dev/le/lancereg.h> | #include <dev/le/lancereg.h> | ||||
| #include <dev/le/lancevar.h> | #include <dev/le/lancevar.h> | ||||
| static void lance_start(struct ifnet *); | static void lance_start(if_t); | ||||
| static void lance_stop(struct lance_softc *); | static void lance_stop(struct lance_softc *); | ||||
| static void lance_init(void *); | static void lance_init(void *); | ||||
| static void lance_watchdog(void *s); | static void lance_watchdog(void *s); | ||||
| static int lance_mediachange(struct ifnet *); | static int lance_mediachange(if_t); | ||||
| static void lance_mediastatus(struct ifnet *, struct ifmediareq *); | static void lance_mediastatus(if_t, struct ifmediareq *); | ||||
| static int lance_ioctl(struct ifnet *, u_long, caddr_t); | static int lance_ioctl(if_t, u_long, caddr_t); | ||||
| int | int | ||||
| lance_config(struct lance_softc *sc, const char* name, int unit) | lance_config(struct lance_softc *sc, const char* name, int unit) | ||||
| { | { | ||||
| struct ifnet *ifp; | if_t ifp; | ||||
| int i, nbuf; | int i, nbuf; | ||||
| if (LE_LOCK_INITIALIZED(sc) == 0) | if (LE_LOCK_INITIALIZED(sc) == 0) | ||||
| return (ENXIO); | return (ENXIO); | ||||
| ifp = sc->sc_ifp = if_alloc(IFT_ETHER); | ifp = sc->sc_ifp = if_alloc(IFT_ETHER); | ||||
| if (ifp == NULL) | if (ifp == NULL) | ||||
| return (ENOSPC); | return (ENOSPC); | ||||
| callout_init_mtx(&sc->sc_wdog_ch, &sc->sc_mtx, 0); | callout_init_mtx(&sc->sc_wdog_ch, &sc->sc_mtx, 0); | ||||
| /* Initialize ifnet structure. */ | /* Initialize ifnet structure. */ | ||||
| ifp->if_softc = sc; | if_setsoftc(ifp, sc); | ||||
| if_initname(ifp, name, unit); | if_initname(ifp, name, unit); | ||||
| ifp->if_start = lance_start; | if_setstartfn(ifp, lance_start); | ||||
| ifp->if_ioctl = lance_ioctl; | if_setioctlfn(ifp, lance_ioctl); | ||||
| ifp->if_init = lance_init; | if_setinitfn(ifp, lance_init); | ||||
| ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; | if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); | ||||
| #ifdef LANCE_REVC_BUG | #ifdef LANCE_REVC_BUG | ||||
| ifp->if_flags &= ~IFF_MULTICAST; | if_setflagsbit(ifp, 0, IFF_MULTICAST); | ||||
| #endif | #endif | ||||
| ifp->if_baudrate = IF_Mbps(10); | if_setbaudrate(ifp, IF_Mbps(10)); | ||||
| IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); | if_setsendqlen(ifp, ifqmaxlen); | ||||
| ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; | if_setsendqready(ifp); | ||||
| IFQ_SET_READY(&ifp->if_snd); | |||||
| /* Initialize ifmedia structures. */ | /* Initialize ifmedia structures. */ | ||||
| ifmedia_init(&sc->sc_media, 0, lance_mediachange, lance_mediastatus); | ifmedia_init(&sc->sc_media, 0, lance_mediachange, lance_mediastatus); | ||||
| if (sc->sc_supmedia != NULL) { | if (sc->sc_supmedia != NULL) { | ||||
| for (i = 0; i < sc->sc_nsupmedia; i++) | for (i = 0; i < sc->sc_nsupmedia; i++) | ||||
| ifmedia_add(&sc->sc_media, sc->sc_supmedia[i], 0, NULL); | ifmedia_add(&sc->sc_media, sc->sc_supmedia[i], 0, NULL); | ||||
| ifmedia_set(&sc->sc_media, sc->sc_defaultmedia); | ifmedia_set(&sc->sc_media, sc->sc_defaultmedia); | ||||
| } else { | } else { | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | #endif | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| void | void | ||||
| lance_attach(struct lance_softc *sc) | lance_attach(struct lance_softc *sc) | ||||
| { | { | ||||
| struct ifnet *ifp = sc->sc_ifp; | if_t ifp = sc->sc_ifp; | ||||
| /* Attach the interface. */ | /* Attach the interface. */ | ||||
| ether_ifattach(ifp, sc->sc_enaddr); | ether_ifattach(ifp, sc->sc_enaddr); | ||||
| /* Claim 802.1q capability. */ | /* Claim 802.1q capability. */ | ||||
| ifp->if_hdrlen = sizeof(struct ether_vlan_header); | if_setifheaderlen(ifp, sizeof(struct ether_vlan_header)); | ||||
| ifp->if_capabilities |= IFCAP_VLAN_MTU; | if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0); | ||||
| ifp->if_capenable |= IFCAP_VLAN_MTU; | if_setcapenablebit(ifp, IFCAP_VLAN_MTU, 0); | ||||
| } | } | ||||
| void | void | ||||
| lance_detach(struct lance_softc *sc) | lance_detach(struct lance_softc *sc) | ||||
| { | { | ||||
| struct ifnet *ifp = sc->sc_ifp; | if_t ifp = sc->sc_ifp; | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| lance_stop(sc); | lance_stop(sc); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| callout_drain(&sc->sc_wdog_ch); | callout_drain(&sc->sc_wdog_ch); | ||||
| ether_ifdetach(ifp); | ether_ifdetach(ifp); | ||||
| if_free(ifp); | if_free(ifp); | ||||
| } | } | ||||
| void | void | ||||
| lance_suspend(struct lance_softc *sc) | lance_suspend(struct lance_softc *sc) | ||||
| { | { | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| lance_stop(sc); | lance_stop(sc); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| } | } | ||||
| void | void | ||||
| lance_resume(struct lance_softc *sc) | lance_resume(struct lance_softc *sc) | ||||
| { | { | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| if (sc->sc_ifp->if_flags & IFF_UP) | if (if_getflags(sc->sc_ifp) & IFF_UP) | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| } | } | ||||
| static void | static void | ||||
| lance_start(struct ifnet *ifp) | lance_start(if_t ifp) | ||||
| { | { | ||||
| struct lance_softc *sc = ifp->if_softc; | struct lance_softc *sc = if_getsoftc(ifp); | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| (*sc->sc_start_locked)(sc); | (*sc->sc_start_locked)(sc); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| } | } | ||||
| static void | static void | ||||
| lance_stop(struct lance_softc *sc) | lance_stop(struct lance_softc *sc) | ||||
| { | { | ||||
| struct ifnet *ifp = sc->sc_ifp; | if_t ifp = sc->sc_ifp; | ||||
| LE_LOCK_ASSERT(sc, MA_OWNED); | LE_LOCK_ASSERT(sc, MA_OWNED); | ||||
| /* | /* | ||||
| * Mark the interface down and cancel the watchdog timer. | * Mark the interface down and cancel the watchdog timer. | ||||
| */ | */ | ||||
| ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); | if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); | ||||
| callout_stop(&sc->sc_wdog_ch); | callout_stop(&sc->sc_wdog_ch); | ||||
| sc->sc_wdog_timer = 0; | sc->sc_wdog_timer = 0; | ||||
| (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_STOP); | (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_STOP); | ||||
| } | } | ||||
| static void | static void | ||||
| lance_init(void *xsc) | lance_init(void *xsc) | ||||
| { | { | ||||
| struct lance_softc *sc = (struct lance_softc *)xsc; | struct lance_softc *sc = (struct lance_softc *)xsc; | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| } | } | ||||
| /* | /* | ||||
| * Initialization of interface; set up initialization block | * Initialization of interface; set up initialization block | ||||
| * and transmit/receive descriptor rings. | * and transmit/receive descriptor rings. | ||||
| */ | */ | ||||
| void | void | ||||
| lance_init_locked(struct lance_softc *sc) | lance_init_locked(struct lance_softc *sc) | ||||
| { | { | ||||
| struct ifnet *ifp = sc->sc_ifp; | if_t ifp = sc->sc_ifp; | ||||
| u_long a; | u_long a; | ||||
| int timo; | int timo; | ||||
| LE_LOCK_ASSERT(sc, MA_OWNED); | LE_LOCK_ASSERT(sc, MA_OWNED); | ||||
| (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_STOP); | (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_STOP); | ||||
| DELAY(100); | DELAY(100); | ||||
| /* Newer LANCE chips have a reset register. */ | /* Newer LANCE chips have a reset register. */ | ||||
| if (sc->sc_hwreset) | if (sc->sc_hwreset) | ||||
| (*sc->sc_hwreset)(sc); | (*sc->sc_hwreset)(sc); | ||||
| /* Set the correct byte swapping mode, etc. */ | /* Set the correct byte swapping mode, etc. */ | ||||
| (*sc->sc_wrcsr)(sc, LE_CSR3, sc->sc_conf3); | (*sc->sc_wrcsr)(sc, LE_CSR3, sc->sc_conf3); | ||||
| /* Set the current media. This may require the chip to be stopped. */ | /* Set the current media. This may require the chip to be stopped. */ | ||||
| if (sc->sc_mediachange) | if (sc->sc_mediachange) | ||||
| (void)(*sc->sc_mediachange)(sc); | (void)(*sc->sc_mediachange)(sc); | ||||
| /* | /* | ||||
| * Update our private copy of the Ethernet address. | * Update our private copy of the Ethernet address. | ||||
| * We NEED the copy so we can ensure its alignment! | * We NEED the copy so we can ensure its alignment! | ||||
| */ | */ | ||||
| memcpy(sc->sc_enaddr, IF_LLADDR(ifp), ETHER_ADDR_LEN); | memcpy(sc->sc_enaddr, if_getlladdr(ifp), ETHER_ADDR_LEN); | ||||
| /* Set up LANCE init block. */ | /* Set up LANCE init block. */ | ||||
| (*sc->sc_meminit)(sc); | (*sc->sc_meminit)(sc); | ||||
| /* Give LANCE the physical address of its init block. */ | /* Give LANCE the physical address of its init block. */ | ||||
| a = sc->sc_addr + LE_INITADDR(sc); | a = sc->sc_addr + LE_INITADDR(sc); | ||||
| (*sc->sc_wrcsr)(sc, LE_CSR1, a & 0xffff); | (*sc->sc_wrcsr)(sc, LE_CSR1, a & 0xffff); | ||||
| (*sc->sc_wrcsr)(sc, LE_CSR2, a >> 16); | (*sc->sc_wrcsr)(sc, LE_CSR2, a >> 16); | ||||
| /* Try to initialize the LANCE. */ | /* Try to initialize the LANCE. */ | ||||
| DELAY(100); | DELAY(100); | ||||
| (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INIT); | (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INIT); | ||||
| /* Wait for initialization to finish. */ | /* Wait for initialization to finish. */ | ||||
| for (timo = 100000; timo; timo--) | for (timo = 100000; timo; timo--) | ||||
| if ((*sc->sc_rdcsr)(sc, LE_CSR0) & LE_C0_IDON) | if ((*sc->sc_rdcsr)(sc, LE_CSR0) & LE_C0_IDON) | ||||
| break; | break; | ||||
| if ((*sc->sc_rdcsr)(sc, LE_CSR0) & LE_C0_IDON) { | if ((*sc->sc_rdcsr)(sc, LE_CSR0) & LE_C0_IDON) { | ||||
| /* Start the LANCE. */ | /* Start the LANCE. */ | ||||
| (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA | LE_C0_STRT); | (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA | LE_C0_STRT); | ||||
| ifp->if_drv_flags |= IFF_DRV_RUNNING; | if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0); | ||||
| ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; | if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); | ||||
| sc->sc_wdog_timer = 0; | sc->sc_wdog_timer = 0; | ||||
| callout_reset(&sc->sc_wdog_ch, hz, lance_watchdog, sc); | callout_reset(&sc->sc_wdog_ch, hz, lance_watchdog, sc); | ||||
| (*sc->sc_start_locked)(sc); | (*sc->sc_start_locked)(sc); | ||||
| } else | } else | ||||
| if_printf(ifp, "controller failed to initialize\n"); | if_printf(ifp, "controller failed to initialize\n"); | ||||
| if (sc->sc_hwinit) | if (sc->sc_hwinit) | ||||
| (*sc->sc_hwinit)(sc); | (*sc->sc_hwinit)(sc); | ||||
| Show All 35 Lines | |||||
| * Pull data off an interface. | * Pull data off an interface. | ||||
| * Len is length of data, with local net header stripped. | * Len is length of data, with local net header stripped. | ||||
| * We copy the data into mbufs. When full cluster sized units are present | * We copy the data into mbufs. When full cluster sized units are present | ||||
| * we copy into clusters. | * we copy into clusters. | ||||
| */ | */ | ||||
| struct mbuf * | struct mbuf * | ||||
| lance_get(struct lance_softc *sc, int boff, int totlen) | lance_get(struct lance_softc *sc, int boff, int totlen) | ||||
| { | { | ||||
| struct ifnet *ifp = sc->sc_ifp; | if_t ifp = sc->sc_ifp; | ||||
| struct mbuf *m, *m0, *newm; | struct mbuf *m, *m0, *newm; | ||||
| caddr_t newdata; | caddr_t newdata; | ||||
| int len; | int len; | ||||
| if (totlen <= ETHER_HDR_LEN || totlen > LEBLEN - ETHER_CRC_LEN) { | if (totlen <= ETHER_HDR_LEN || totlen > LEBLEN - ETHER_CRC_LEN) { | ||||
| #ifdef LEDEBUG | #ifdef LEDEBUG | ||||
| if_printf(ifp, "invalid packet size %d; dropping\n", totlen); | if_printf(ifp, "invalid packet size %d; dropping\n", totlen); | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | bad: | ||||
| m_freem(m0); | m_freem(m0); | ||||
| return (NULL); | return (NULL); | ||||
| } | } | ||||
| static void | static void | ||||
| lance_watchdog(void *xsc) | lance_watchdog(void *xsc) | ||||
| { | { | ||||
| struct lance_softc *sc = (struct lance_softc *)xsc; | struct lance_softc *sc = (struct lance_softc *)xsc; | ||||
| struct ifnet *ifp = sc->sc_ifp; | if_t ifp = sc->sc_ifp; | ||||
| LE_LOCK_ASSERT(sc, MA_OWNED); | LE_LOCK_ASSERT(sc, MA_OWNED); | ||||
| if (sc->sc_wdog_timer == 0 || --sc->sc_wdog_timer != 0) { | if (sc->sc_wdog_timer == 0 || --sc->sc_wdog_timer != 0) { | ||||
| callout_reset(&sc->sc_wdog_ch, hz, lance_watchdog, sc); | callout_reset(&sc->sc_wdog_ch, hz, lance_watchdog, sc); | ||||
| return; | return; | ||||
| } | } | ||||
| if_printf(ifp, "device timeout\n"); | if_printf(ifp, "device timeout\n"); | ||||
| if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| } | } | ||||
| static int | static int | ||||
| lance_mediachange(struct ifnet *ifp) | lance_mediachange(if_t ifp) | ||||
| { | { | ||||
| struct lance_softc *sc = ifp->if_softc; | struct lance_softc *sc = if_getsoftc(ifp); | ||||
| if (sc->sc_mediachange) { | if (sc->sc_mediachange) { | ||||
| /* | /* | ||||
| * For setting the port in LE_CSR15 the PCnet chips must | * For setting the port in LE_CSR15 the PCnet chips must | ||||
| * be powered down or stopped and unlike documented may | * be powered down or stopped and unlike documented may | ||||
| * not take effect without an initialization. So don't | * not take effect without an initialization. So don't | ||||
| * invoke (*sc_mediachange) directly here but go through | * invoke (*sc_mediachange) directly here but go through | ||||
| * lance_init_locked(). | * lance_init_locked(). | ||||
| */ | */ | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| lance_stop(sc); | lance_stop(sc); | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) | if (!if_sendq_empty(ifp)) | ||||
| (*sc->sc_start_locked)(sc); | (*sc->sc_start_locked)(sc); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static void | static void | ||||
| lance_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) | lance_mediastatus(if_t ifp, struct ifmediareq *ifmr) | ||||
| { | { | ||||
| struct lance_softc *sc = ifp->if_softc; | struct lance_softc *sc = if_getsoftc(ifp); | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| if (!(ifp->if_flags & IFF_UP)) { | if (!(if_getflags(ifp) & IFF_UP)) { | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| return; | return; | ||||
| } | } | ||||
| ifmr->ifm_status = IFM_AVALID; | ifmr->ifm_status = IFM_AVALID; | ||||
| if (sc->sc_flags & LE_CARRIER) | if (sc->sc_flags & LE_CARRIER) | ||||
| ifmr->ifm_status |= IFM_ACTIVE; | ifmr->ifm_status |= IFM_ACTIVE; | ||||
| if (sc->sc_mediastatus) | if (sc->sc_mediastatus) | ||||
| (*sc->sc_mediastatus)(sc, ifmr); | (*sc->sc_mediastatus)(sc, ifmr); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| } | } | ||||
| /* | /* | ||||
| * Process an ioctl request. | * Process an ioctl request. | ||||
| */ | */ | ||||
| static int | static int | ||||
| lance_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) | lance_ioctl(if_t ifp, u_long cmd, caddr_t data) | ||||
| { | { | ||||
| struct lance_softc *sc = ifp->if_softc; | struct lance_softc *sc = if_getsoftc(ifp); | ||||
| struct ifreq *ifr = (struct ifreq *)data; | struct ifreq *ifr = (struct ifreq *)data; | ||||
| int error = 0; | int error = 0; | ||||
| switch (cmd) { | switch (cmd) { | ||||
| case SIOCSIFFLAGS: | case SIOCSIFFLAGS: | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| if (ifp->if_flags & IFF_PROMISC) { | if (if_getflags(ifp) & IFF_PROMISC) { | ||||
| if (!(sc->sc_flags & LE_PROMISC)) { | if (!(sc->sc_flags & LE_PROMISC)) { | ||||
| sc->sc_flags |= LE_PROMISC; | sc->sc_flags |= LE_PROMISC; | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| } | } | ||||
| } else if (sc->sc_flags & LE_PROMISC) { | } else if (sc->sc_flags & LE_PROMISC) { | ||||
| sc->sc_flags &= ~LE_PROMISC; | sc->sc_flags &= ~LE_PROMISC; | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| } | } | ||||
| if ((ifp->if_flags & IFF_ALLMULTI) && | if ((if_getflags(ifp) & IFF_ALLMULTI) && | ||||
| !(sc->sc_flags & LE_ALLMULTI)) { | !(sc->sc_flags & LE_ALLMULTI)) { | ||||
| sc->sc_flags |= LE_ALLMULTI; | sc->sc_flags |= LE_ALLMULTI; | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| } else if (!(ifp->if_flags & IFF_ALLMULTI) && | } else if (!(if_getflags(ifp) & IFF_ALLMULTI) && | ||||
| (sc->sc_flags & LE_ALLMULTI)) { | (sc->sc_flags & LE_ALLMULTI)) { | ||||
| sc->sc_flags &= ~LE_ALLMULTI; | sc->sc_flags &= ~LE_ALLMULTI; | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| } | } | ||||
| if (!(ifp->if_flags & IFF_UP) && | if (!(if_getflags(ifp) & IFF_UP) && | ||||
| ifp->if_drv_flags & IFF_DRV_RUNNING) { | if_getdrvflags(ifp) & IFF_DRV_RUNNING) { | ||||
| /* | /* | ||||
| * If interface is marked down and it is running, then | * If interface is marked down and it is running, then | ||||
| * stop it. | * stop it. | ||||
| */ | */ | ||||
| lance_stop(sc); | lance_stop(sc); | ||||
| } else if (ifp->if_flags & IFF_UP && | } else if (if_getflags(ifp) & IFF_UP && | ||||
| !(ifp->if_drv_flags & IFF_DRV_RUNNING)) { | !(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { | ||||
| /* | /* | ||||
| * If interface is marked up and it is stopped, then | * If interface is marked up and it is stopped, then | ||||
| * start it. | * start it. | ||||
| */ | */ | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| } | } | ||||
| #ifdef LEDEBUG | #ifdef LEDEBUG | ||||
| if (ifp->if_flags & IFF_DEBUG) | if (if_getflags(ifp) & IFF_DEBUG) | ||||
| sc->sc_flags |= LE_DEBUG; | sc->sc_flags |= LE_DEBUG; | ||||
| else | else | ||||
| sc->sc_flags &= ~LE_DEBUG; | sc->sc_flags &= ~LE_DEBUG; | ||||
| #endif | #endif | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| break; | break; | ||||
| case SIOCADDMULTI: | case SIOCADDMULTI: | ||||
| case SIOCDELMULTI: | case SIOCDELMULTI: | ||||
| /* | /* | ||||
| * Multicast list has changed; set the hardware filter | * Multicast list has changed; set the hardware filter | ||||
| * accordingly. | * accordingly. | ||||
| */ | */ | ||||
| LE_LOCK(sc); | LE_LOCK(sc); | ||||
| if (ifp->if_drv_flags & IFF_DRV_RUNNING) | if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) | ||||
| lance_init_locked(sc); | lance_init_locked(sc); | ||||
| LE_UNLOCK(sc); | LE_UNLOCK(sc); | ||||
| break; | break; | ||||
| case SIOCGIFMEDIA: | case SIOCGIFMEDIA: | ||||
| case SIOCSIFMEDIA: | case SIOCSIFMEDIA: | ||||
| error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); | error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); | ||||
| break; | break; | ||||
| Show All 28 Lines | |||||
| } | } | ||||
| /* | /* | ||||
| * Set up the logical address filter. | * Set up the logical address filter. | ||||
| */ | */ | ||||
| void | void | ||||
| lance_setladrf(struct lance_softc *sc, uint16_t *af) | lance_setladrf(struct lance_softc *sc, uint16_t *af) | ||||
| { | { | ||||
| struct ifnet *ifp = sc->sc_ifp; | if_t ifp = sc->sc_ifp; | ||||
| struct lance_hash_maddr_ctx ctx = { sc, af }; | struct lance_hash_maddr_ctx ctx = { sc, af }; | ||||
| /* | /* | ||||
| * Set up multicast address filter by passing all multicast addresses | * Set up multicast address filter by passing all multicast addresses | ||||
| * through a crc generator, and then using the high order 6 bits as an | * through a crc generator, and then using the high order 6 bits as an | ||||
| * index into the 64 bit logical address filter. The high order bit | * index into the 64 bit logical address filter. The high order bit | ||||
| * selects the word, while the rest of the bits select the bit within | * selects the word, while the rest of the bits select the bit within | ||||
| * the word. | * the word. | ||||
| */ | */ | ||||
| if (ifp->if_flags & IFF_PROMISC || sc->sc_flags & LE_ALLMULTI) { | if (if_getflags(ifp) & IFF_PROMISC || sc->sc_flags & LE_ALLMULTI) { | ||||
| af[0] = af[1] = af[2] = af[3] = 0xffff; | af[0] = af[1] = af[2] = af[3] = 0xffff; | ||||
| return; | return; | ||||
| } | } | ||||
| af[0] = af[1] = af[2] = af[3] = 0x0000; | af[0] = af[1] = af[2] = af[3] = 0x0000; | ||||
| if_foreach_llmaddr(ifp, lance_hash_maddr, &ctx); | if_foreach_llmaddr(ifp, lance_hash_maddr, &ctx); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines | |||||