/* $NetBSD: if_de.c,v 1.86 1999/06/01 19:17:59 thorpej Exp $ */
/* $FreeBSD: src/sys/pci/if_de.c,v 1.123.2.4 2000/08/04 23:25:09 peter Exp $ */
-/* $DragonFly: src/sys/dev/netif/de/if_de.c,v 1.34 2005/05/12 01:41:07 drhodus Exp $ */
+/* $DragonFly: src/sys/dev/netif/de/if_de.c,v 1.39 2005/06/20 15:10:40 joerg Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/eventhandler.h>
-#include <machine/clock.h>
+#include <sys/thread2.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/bus.h>
tulip_timeout_callback(void *arg)
{
tulip_softc_t *sc = arg;
- int s = splimp();
+
+ crit_enter();
sc->tulip_flags &= ~TULIP_TIMEOUTPENDING;
sc->tulip_probe_timeout -= 1000 / TULIP_HZ;
(sc->tulip_boardsw->bd_media_poll)(sc, TULIP_MEDIAPOLL_TIMER);
- splx(s);
+
+ crit_exit();
}
static void
#endif
multicnt = 0;
- for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
-
+ LIST_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family == AF_LINK)
multicnt++;
}
*/
bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata));
- for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
-
+ LIST_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
/*
* Else can get perfect filtering for 16 addresses.
*/
- for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
+ LIST_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
*/
if (accept || ms == NULL) {
struct mbuf *m0;
- MGETHDR(m0, MB_DONTWAIT, MT_DATA);
- if (m0 != NULL) {
-#if defined(TULIP_COPY_RXDATA)
- if (!accept || total_len >= (MHLEN - 2)) {
-#endif
- MCLGET(m0, MB_DONTWAIT);
- if ((m0->m_flags & M_EXT) == 0) {
- m_freem(m0);
- m0 = NULL;
- }
+
#if defined(TULIP_COPY_RXDATA)
- }
+ if (!accept || total_len >= (MHLEN - 2))
+ m0 = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
+ else
+ m0 = m_gethdr(MB_DONTWAIT, MT_DATA);
+#else
+ m0 = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
#endif
- }
+
if (accept
#if defined(TULIP_COPY_RXDATA)
&& m0 != NULL
tulip_softc_t *sc = (tulip_softc_t *)ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
- int s;
int error = 0;
- s = splimp();
+ crit_enter();
+
switch (cmd) {
case SIOCSIFADDR: {
ifp->if_flags |= IFF_UP;
}
}
- splx(s);
+ crit_exit();
+
return error;
}
sc->tulip_if.if_softc = sc;
#if defined(TULIP_IOMAPPED)
rid = PCI_CBIO;
- res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE);
+ res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
#else
rid = PCI_CBMA;
- res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
- 0, ~0, 1, RF_ACTIVE);
+ res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
#endif
if (!res)
return ENXIO;
(sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F);
device_printf(dev, "address unknown\n");
} else {
- int s;
void (*intr_rtn)(void *) = tulip_intr_normal;
if (sc->tulip_features & TULIP_HAVE_SHAREDINTR)
void *ih;
rid = 0;
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
- 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
+ res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
+ RF_SHAREABLE | RF_ACTIVE);
if (res == 0 || bus_setup_intr(dev, res, INTR_TYPE_NET,
- intr_rtn, sc, &ih)) {
+ intr_rtn, sc, &ih, NULL)) {
device_printf(dev, "couldn't map interrupt\n");
free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
}
}
- s = splimp();
+ crit_enter();
tulip_attach(sc);
- splx(s);
+ crit_exit();
}
return 0;
}