Index: head/sys/dev/alc/if_alc.c =================================================================== --- head/sys/dev/alc/if_alc.c +++ head/sys/dev/alc/if_alc.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -199,6 +200,7 @@ static void alc_start(struct ifnet *); static void alc_start_locked(struct ifnet *); static void alc_start_queue(struct alc_softc *); +static void alc_start_tx(struct alc_softc *); static void alc_stats_clear(struct alc_softc *); static void alc_stats_update(struct alc_softc *); static void alc_stop(struct alc_softc *); @@ -213,6 +215,8 @@ static int sysctl_hw_alc_proc_limit(SYSCTL_HANDLER_ARGS); static int sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS); +NETDUMP_DEFINE(alc); + static device_method_t alc_methods[] = { /* Device interface. */ DEVMETHOD(device_probe, alc_probe), @@ -227,7 +231,7 @@ DEVMETHOD(miibus_writereg, alc_miibus_writereg), DEVMETHOD(miibus_statchg, alc_miibus_statchg), - { NULL, NULL } + DEVMETHOD_END }; static driver_t alc_driver = { @@ -1651,6 +1655,9 @@ goto fail; } + /* Attach driver netdump methods. */ + NETDUMP_SET(ifp, alc); + fail: if (error != 0) alc_detach(dev); @@ -2974,25 +2981,31 @@ ETHER_BPF_MTAP(ifp, m_head); } - if (enq > 0) { - /* Sync descriptors. */ - bus_dmamap_sync(sc->alc_cdata.alc_tx_ring_tag, - sc->alc_cdata.alc_tx_ring_map, BUS_DMASYNC_PREWRITE); - /* Kick. Assume we're using normal Tx priority queue. */ - if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) - CSR_WRITE_2(sc, ALC_MBOX_TD_PRI0_PROD_IDX, - (uint16_t)sc->alc_cdata.alc_tx_prod); - else - CSR_WRITE_4(sc, ALC_MBOX_TD_PROD_IDX, - (sc->alc_cdata.alc_tx_prod << - MBOX_TD_PROD_LO_IDX_SHIFT) & - MBOX_TD_PROD_LO_IDX_MASK); - /* Set a timeout in case the chip goes out to lunch. */ - sc->alc_watchdog_timer = ALC_TX_TIMEOUT; - } + if (enq > 0) + alc_start_tx(sc); } static void +alc_start_tx(struct alc_softc *sc) +{ + + /* Sync descriptors. */ + bus_dmamap_sync(sc->alc_cdata.alc_tx_ring_tag, + sc->alc_cdata.alc_tx_ring_map, BUS_DMASYNC_PREWRITE); + /* Kick. Assume we're using normal Tx priority queue. */ + if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) + CSR_WRITE_2(sc, ALC_MBOX_TD_PRI0_PROD_IDX, + (uint16_t)sc->alc_cdata.alc_tx_prod); + else + CSR_WRITE_4(sc, ALC_MBOX_TD_PROD_IDX, + (sc->alc_cdata.alc_tx_prod << + MBOX_TD_PROD_LO_IDX_SHIFT) & + MBOX_TD_PROD_LO_IDX_MASK); + /* Set a timeout in case the chip goes out to lunch. */ + sc->alc_watchdog_timer = ALC_TX_TIMEOUT; +} + +static void alc_watchdog(struct alc_softc *sc) { struct ifnet *ifp; @@ -4642,3 +4655,54 @@ return (sysctl_int_range(oidp, arg1, arg2, req, ALC_IM_TIMER_MIN, ALC_IM_TIMER_MAX)); } + +#ifdef NETDUMP +static void +alc_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize) +{ + struct alc_softc *sc; + + sc = if_getsoftc(ifp); + KASSERT(sc->alc_buf_size <= MCLBYTES, ("incorrect cluster size")); + + *nrxr = ALC_RX_RING_CNT; + *ncl = NETDUMP_MAX_IN_FLIGHT; + *clsize = MCLBYTES; +} + +static void +alc_netdump_event(struct ifnet *ifp __unused, enum netdump_ev event __unused) +{ +} + +static int +alc_netdump_transmit(struct ifnet *ifp, struct mbuf *m) +{ + struct alc_softc *sc; + int error; + + sc = if_getsoftc(ifp); + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) + return (EBUSY); + + error = alc_encap(sc, &m); + if (error == 0) + alc_start_tx(sc); + return (error); +} + +static int +alc_netdump_poll(struct ifnet *ifp, int count) +{ + struct alc_softc *sc; + + sc = if_getsoftc(ifp); + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) + return (EBUSY); + + alc_txeof(sc); + return (alc_rxintr(sc, count)); +} +#endif /* NETDUMP */