Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c
Show First 20 Lines • Show All 605 Lines • ▼ Show 20 Lines | nf10bmac_tick(void *xsc) | ||||
nf10bmac_watchdog(sc); | nf10bmac_watchdog(sc); | ||||
callout_reset(&sc->nf10bmac_tick, hz, nf10bmac_tick, sc); | callout_reset(&sc->nf10bmac_tick, hz, nf10bmac_tick, sc); | ||||
} | } | ||||
#endif | #endif | ||||
static void | static void | ||||
nf10bmac_intr(void *arg) | nf10bmac_intr(void *arg) | ||||
{ | { | ||||
struct epoch_tracker et; | |||||
struct nf10bmac_softc *sc; | struct nf10bmac_softc *sc; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
int rx_npkts; | int rx_npkts; | ||||
sc = (struct nf10bmac_softc *)arg; | sc = (struct nf10bmac_softc *)arg; | ||||
ifp = sc->nf10bmac_ifp; | ifp = sc->nf10bmac_ifp; | ||||
NF10BMAC_LOCK(sc); | NF10BMAC_LOCK(sc); | ||||
#ifdef DEVICE_POLLING | #ifdef DEVICE_POLLING | ||||
if (ifp->if_capenable & IFCAP_POLLING) { | if (ifp->if_capenable & IFCAP_POLLING) { | ||||
NF10BMAC_UNLOCK(sc); | NF10BMAC_UNLOCK(sc); | ||||
return; | return; | ||||
} | } | ||||
#endif | #endif | ||||
/* NF10BMAC_RX_INTR_DISABLE(sc); */ | /* NF10BMAC_RX_INTR_DISABLE(sc); */ | ||||
NF10BMAC_RX_INTR_CLEAR_DIS(sc); | NF10BMAC_RX_INTR_CLEAR_DIS(sc); | ||||
NET_EPOCH_ENTER(et); | |||||
/* We only have an RX interrupt and no status information. */ | /* We only have an RX interrupt and no status information. */ | ||||
rx_npkts = 0; | rx_npkts = 0; | ||||
while (rx_npkts < NF10BMAC_MAX_PKTS) { | while (rx_npkts < NF10BMAC_MAX_PKTS) { | ||||
int c; | int c; | ||||
c = nf10bmac_rx_locked(sc); | c = nf10bmac_rx_locked(sc); | ||||
rx_npkts += c; | rx_npkts += c; | ||||
if (c == 0) | if (c == 0) | ||||
break; | break; | ||||
} | } | ||||
NET_EPOCH_EXIT(et); | |||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) { | if (ifp->if_drv_flags & IFF_DRV_RUNNING) { | ||||
/* Re-enable interrupts. */ | /* Re-enable interrupts. */ | ||||
NF10BMAC_RX_INTR_ENABLE(sc); | NF10BMAC_RX_INTR_ENABLE(sc); | ||||
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) | if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) | ||||
nf10bmac_start_locked(ifp); | nf10bmac_start_locked(ifp); | ||||
} | } | ||||
NF10BMAC_UNLOCK(sc); | NF10BMAC_UNLOCK(sc); | ||||
} | } | ||||
#ifdef DEVICE_POLLING | #ifdef DEVICE_POLLING | ||||
static int | static int | ||||
nf10bmac_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) | nf10bmac_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) | ||||
{ | { | ||||
struct epoch_tracker et; | |||||
struct nf10bmac_softc *sc; | struct nf10bmac_softc *sc; | ||||
int rx_npkts = 0; | int rx_npkts = 0; | ||||
sc = ifp->if_softc; | sc = ifp->if_softc; | ||||
NF10BMAC_LOCK(sc); | NF10BMAC_LOCK(sc); | ||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { | if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { | ||||
NF10BMAC_UNLOCK(sc); | NF10BMAC_UNLOCK(sc); | ||||
return (rx_npkts); | return (rx_npkts); | ||||
} | } | ||||
NET_EPOCH_ENTER(et); | |||||
while (rx_npkts < count) { | while (rx_npkts < count) { | ||||
int c; | int c; | ||||
c = nf10bmac_rx_locked(sc); | c = nf10bmac_rx_locked(sc); | ||||
rx_npkts += c; | rx_npkts += c; | ||||
if (c == 0) | if (c == 0) | ||||
break; | break; | ||||
} | } | ||||
NET_EPOCH_EXIT(et); | |||||
nf10bmac_start_locked(ifp); | nf10bmac_start_locked(ifp); | ||||
if (rx_npkts > 0 || cmd == POLL_AND_CHECK_STATUS) { | if (rx_npkts > 0 || cmd == POLL_AND_CHECK_STATUS) { | ||||
/* We currently cannot do much. */ | /* We currently cannot do much. */ | ||||
; | ; | ||||
} | } | ||||
NF10BMAC_UNLOCK(sc); | NF10BMAC_UNLOCK(sc); | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |