diff options
Diffstat (limited to 'sys/dev/fxp/if_fxp.c')
-rw-r--r-- | sys/dev/fxp/if_fxp.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 840ed87..27b7843 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -1141,6 +1141,38 @@ tbdinit: } } +static void fxp_intr_body(struct fxp_softc *sc, u_int8_t statack, int count); + +#ifdef DEVICE_POLLING +static poll_handler_t fxp_poll; + +static void +fxp_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) +{ + struct fxp_softc *sc = ifp->if_softc; + u_int8_t statack ; + + if (cmd == POLL_DEREGISTER) { /* final call, enable interrupts */ + CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, 0); + return; + } + statack = FXP_SCB_STATACK_CXTNO | FXP_SCB_STATACK_CNA | + FXP_SCB_STATACK_FR ; + if (cmd == POLL_AND_CHECK_STATUS) { + u_int8_t tmp ; + tmp = CSR_READ_1(sc, FXP_CSR_SCB_STATACK); + if (tmp == 0xff || tmp == 0) + return ; /* nothing to do */ + tmp &= ~statack ; + /* ack what we can */ + if (tmp != 0) + CSR_WRITE_1(sc, FXP_CSR_SCB_STATACK, tmp); + statack |= tmp ; + } + fxp_intr_body(sc, statack, count); +} +#endif /* DEVICE_POLLING */ + /* * Process interface interrupts. */ @@ -1148,9 +1180,21 @@ static void fxp_intr(void *xsc) { struct fxp_softc *sc = xsc; - struct ifnet *ifp = &sc->sc_if; u_int8_t statack; +#ifdef DEVICE_POLLING + struct ifnet *ifp = &sc->sc_if; + + if (ifp->if_ipending & IFF_POLLING) + return ; + if (ether_poll_register(fxp_poll, ifp)) { + /* disable interrupts */ + CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE); + fxp_poll(ifp, 0, 1); + return ; + } +#endif + if (sc->suspended) { return; } @@ -1169,6 +1213,14 @@ fxp_intr(void *xsc) * First ACK all the interrupts in this pass. */ CSR_WRITE_1(sc, FXP_CSR_SCB_STATACK, statack); + fxp_intr_body(sc, statack, -1); + } +} + +static void +fxp_intr_body(struct fxp_softc *sc, u_int8_t statack, int count) +{ + struct ifnet *ifp = &sc->sc_if; /* * Free any finished transmit mbuf chains. @@ -1220,6 +1272,9 @@ rcvloop: rfa = (struct fxp_rfa *)(m->m_ext.ext_buf + RFA_ALIGNMENT_FUDGE); +#ifdef DEVICE_POLLING /* loop at most count times if count >=0 */ + if (count < 0 || count-- > 0) +#endif if (rfa->rfa_status & FXP_RFA_STATUS_C) { /* * Remove first packet from the chain. @@ -1276,7 +1331,6 @@ rcvloop: fxp_scb_cmd(sc, FXP_SCB_COMMAND_RU_START); } } - } } /* @@ -1404,6 +1458,9 @@ fxp_stop(struct fxp_softc *sc) ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); ifp->if_timer = 0; +#ifdef DEVICE_POLLING + ether_poll_deregister(ifp); +#endif /* * Cancel stats updater. */ |