--- src/sys/dev/netif/fxp/if_fxp.c 2005/05/24 20:59:01 1.26 +++ src/sys/dev/netif/fxp/if_fxp.c 2005/05/25 01:44:24 1.27 @@ -234,6 +234,10 @@ static int sysctl_int_range(SYSCTL_HAND int low, int high); static int sysctl_hw_fxp_bundle_max(SYSCTL_HANDLER_ARGS); static int sysctl_hw_fxp_int_delay(SYSCTL_HANDLER_ARGS); +#ifdef DEVICE_POLLING +static poll_handler_t fxp_poll; +#endif + static __inline void fxp_lwcopy(volatile u_int32_t *src, volatile u_int32_t *dst); static __inline void fxp_scb_wait(struct fxp_softc *sc); @@ -656,6 +660,9 @@ fxp_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = fxp_ioctl; ifp->if_start = fxp_start; +#ifdef DEVICE_POLLING + ifp->if_poll = fxp_poll; +#endif ifp->if_watchdog = fxp_watchdog; /* @@ -1157,7 +1164,6 @@ tbdinit: } #ifdef DEVICE_POLLING -static poll_handler_t fxp_poll; static void fxp_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) @@ -1165,26 +1171,35 @@ fxp_poll(struct ifnet *ifp, enum poll_cm struct fxp_softc *sc = ifp->if_softc; u_int8_t statack; - if (cmd == POLL_DEREGISTER) { /* final call, enable interrupts */ + switch(cmd) { + case POLL_REGISTER: + /* disable interrupts */ + CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE); + break; + case POLL_DEREGISTER: + /* 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; + break; + default: + 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); + break; } - fxp_intr_body(sc, statack, count); } + #endif /* DEVICE_POLLING */ /* @@ -1196,19 +1211,6 @@ fxp_intr(void *xsc) struct fxp_softc *sc = xsc; u_int8_t statack; -#ifdef DEVICE_POLLING - struct ifnet *ifp = &sc->arpcom.ac_if; - - if (ifp->if_flags & 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; } @@ -1495,9 +1497,6 @@ 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. */