X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/9faed91670d13f72e0b1159a507ef81af78fe49b..78195a764d5e70464a6d4f49bc08332a2a8bb4d0:/sys/dev/netif/ex/if_ex.c diff --git a/sys/dev/netif/ex/if_ex.c b/sys/dev/netif/ex/if_ex.c index 401029c57e..3514d74483 100644 --- a/sys/dev/netif/ex/if_ex.c +++ b/sys/dev/netif/ex/if_ex.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ex/if_ex.c,v 1.26.2.3 2001/03/05 05:33:20 imp Exp $ - * $DragonFly: src/sys/dev/netif/ex/if_ex.c,v 1.12 2004/07/23 07:16:26 joerg Exp $ + * $DragonFly: src/sys/dev/netif/ex/if_ex.c,v 1.21 2005/11/28 17:13:42 dillon Exp $ * * MAINTAINER: Matthew N. Dodd * @@ -45,14 +45,18 @@ #include #include #include +#include #include #include +#include #include #include #include +#include +#include #include #include #include @@ -166,16 +170,16 @@ ex_alloc_resources (device_t dev) struct ex_softc * sc = device_get_softc(dev); int error = 0; - sc->ioport = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->ioport_rid, - 0, ~0, 1, RF_ACTIVE); + sc->ioport = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->ioport_rid, + RF_ACTIVE); if (!sc->ioport) { device_printf(dev, "No I/O space?!\n"); error = ENOMEM; goto bad; } - sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid, - 0, ~0, 1, RF_ACTIVE); + sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid, + RF_ACTIVE); if (!sc->irq) { device_printf(dev, "No IRQ?!\n"); @@ -243,7 +247,8 @@ ex_attach(device_t dev) ifp->if_ioctl = ex_ioctl; ifp->if_watchdog = ex_watchdog; ifp->if_init = ex_init; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN); + ifq_set_ready(&ifp->if_snd); ifmedia_init(&sc->ifmedia, 0, ex_ifmedia_upd, ex_ifmedia_sts); @@ -264,7 +269,7 @@ ex_attach(device_t dev) /* * Attach the interface. */ - ether_ifattach(ifp, sc->arpcom.ac_enaddr); + ether_ifattach(ifp, sc->arpcom.ac_enaddr, NULL); return(0); } @@ -274,17 +279,12 @@ ex_init(void *xsc) { struct ex_softc * sc = (struct ex_softc *) xsc; struct ifnet * ifp = &sc->arpcom.ac_if; - int s; int i; - register int iobase = sc->iobase; + int iobase = sc->iobase; unsigned short temp_reg; DODEBUG(Start_End, printf("ex_init%d: start\n", ifp->if_dunit);); - if (TAILQ_FIRST(&ifp->if_addrhead) == NULL) { - return; - } - s = splimp(); ifp->if_timer = 0; /* @@ -356,7 +356,6 @@ ex_init(void *xsc) outb(iobase + CMD_REG, Rcv_Enable_CMD); ex_start(ifp); - splx(s); DODEBUG(Start_End, printf("ex_init%d: finish\n", ifp->if_dunit);); } @@ -367,21 +366,21 @@ ex_start(struct ifnet *ifp) { struct ex_softc * sc = ifp->if_softc; int iobase = sc->iobase; - int i, s, len, data_len, avail, dest, next; + int i, len, data_len, avail, dest, next; unsigned char tmp16[2]; struct mbuf * opkt; struct mbuf * m; DODEBUG(Start_End, printf("ex_start%d: start\n", unit);); - s = splimp(); - /* * Main loop: send outgoing packets to network card until there are no * more packets left, or the card cannot accept any more yet. */ - while (((opkt = ifp->if_snd.ifq_head) != NULL) && - !(ifp->if_flags & IFF_OACTIVE)) { + while ((ifp->if_flags & IFF_OACTIVE) == 0) { + opkt = ifq_poll(&ifp->if_snd); + if (opkt == NULL) + break; /* * Ensure there is enough free transmit buffer space for @@ -414,7 +413,7 @@ ex_start(struct ifnet *ifp) DODEBUG(Sent_Pkts, printf("i=%d, avail=%d\n", i, avail);); if (avail >= len + XMT_HEADER_LEN) { - IF_DEQUEUE(&ifp->if_snd, opkt); + ifq_dequeue(&ifp->if_snd, opkt); #ifdef EX_PSA_INTR /* @@ -522,9 +521,7 @@ ex_start(struct ifnet *ifp) sc->tx_last = dest; sc->tx_tail = next; - if (ifp->if_bpf != NULL) { - bpf_mtap(ifp, opkt); - } + BPF_MTAP(ifp, opkt); ifp->if_timer = 2; ifp->if_opackets++; @@ -534,9 +531,6 @@ ex_start(struct ifnet *ifp) DODEBUG(Status, printf("OACTIVE start\n");); } } - - splx(s); - DODEBUG(Start_End, printf("ex_start%d: finish\n", unit);); } @@ -604,9 +598,8 @@ ex_intr(void *arg) * be sent, attempt to send more packets to the network card. */ - if (send_pkts && (ifp->if_snd.ifq_head != NULL)) { + if (send_pkts && !ifq_is_empty(&ifp->if_snd)) ex_start(ifp); - } #ifdef EXDEBUG exintr_count--; @@ -741,7 +734,7 @@ ex_rx_intr(struct ex_softc *sc) m->m_len = MLEN; } } - (*ifp->if_input)(ifp, ipkt); + ifp->if_input(ifp, ipkt); ifp->if_ipackets++; } } else { @@ -763,24 +756,15 @@ rx_another: ; static int -ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) +ex_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) { struct ex_softc * sc = ifp->if_softc; struct ifreq * ifr = (struct ifreq *)data; - int s; int error = 0; DODEBUG(Start_End, printf("ex_ioctl%d: start ", ifp->if_dunit);); - s = splimp(); - switch(cmd) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, cmd, data); - break; - case SIOCSIFFLAGS: DODEBUG(Start_End, printf("SIOCSIFFLAGS");); if ((ifp->if_flags & IFF_UP) == 0 && @@ -812,11 +796,10 @@ ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) break; default: DODEBUG(Start_End, printf("unknown");); - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } - splx(s); - DODEBUG(Start_End, printf("\nex_ioctl%d: finish\n", ifp->if_dunit);); return(error); @@ -826,20 +809,12 @@ ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) static void ex_reset(struct ex_softc *sc) { - int s; - DODEBUG(Start_End, printf("ex_reset%d: start\n", unit);); - - s = splimp(); ex_stop(sc); ex_init(sc); - splx(s); - DODEBUG(Start_End, printf("ex_reset%d: finish\n", unit);); - - return; } static void