Add netdump hooks to alc(4).
Tested with an AR8162. Reviewed by: julian, sbruno MFC after: 1 month Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D15255
This commit is contained in:
parent
0ff40d3d29
commit
8a4665833d
@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
|
#include <netinet/netdump/netdump.h>
|
||||||
|
|
||||||
#include <dev/mii/mii.h>
|
#include <dev/mii/mii.h>
|
||||||
#include <dev/mii/miivar.h>
|
#include <dev/mii/miivar.h>
|
||||||
@ -199,6 +200,7 @@ static int alc_shutdown(device_t);
|
|||||||
static void alc_start(struct ifnet *);
|
static void alc_start(struct ifnet *);
|
||||||
static void alc_start_locked(struct ifnet *);
|
static void alc_start_locked(struct ifnet *);
|
||||||
static void alc_start_queue(struct alc_softc *);
|
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_clear(struct alc_softc *);
|
||||||
static void alc_stats_update(struct alc_softc *);
|
static void alc_stats_update(struct alc_softc *);
|
||||||
static void alc_stop(struct alc_softc *);
|
static void alc_stop(struct alc_softc *);
|
||||||
@ -213,6 +215,8 @@ static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int);
|
|||||||
static int sysctl_hw_alc_proc_limit(SYSCTL_HANDLER_ARGS);
|
static int sysctl_hw_alc_proc_limit(SYSCTL_HANDLER_ARGS);
|
||||||
static int sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS);
|
static int sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS);
|
||||||
|
|
||||||
|
NETDUMP_DEFINE(alc);
|
||||||
|
|
||||||
static device_method_t alc_methods[] = {
|
static device_method_t alc_methods[] = {
|
||||||
/* Device interface. */
|
/* Device interface. */
|
||||||
DEVMETHOD(device_probe, alc_probe),
|
DEVMETHOD(device_probe, alc_probe),
|
||||||
@ -227,7 +231,7 @@ static device_method_t alc_methods[] = {
|
|||||||
DEVMETHOD(miibus_writereg, alc_miibus_writereg),
|
DEVMETHOD(miibus_writereg, alc_miibus_writereg),
|
||||||
DEVMETHOD(miibus_statchg, alc_miibus_statchg),
|
DEVMETHOD(miibus_statchg, alc_miibus_statchg),
|
||||||
|
|
||||||
{ NULL, NULL }
|
DEVMETHOD_END
|
||||||
};
|
};
|
||||||
|
|
||||||
static driver_t alc_driver = {
|
static driver_t alc_driver = {
|
||||||
@ -1651,6 +1655,9 @@ alc_attach(device_t dev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attach driver netdump methods. */
|
||||||
|
NETDUMP_SET(ifp, alc);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
alc_detach(dev);
|
alc_detach(dev);
|
||||||
@ -2974,22 +2981,28 @@ alc_start_locked(struct ifnet *ifp)
|
|||||||
ETHER_BPF_MTAP(ifp, m_head);
|
ETHER_BPF_MTAP(ifp, m_head);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enq > 0) {
|
if (enq > 0)
|
||||||
/* Sync descriptors. */
|
alc_start_tx(sc);
|
||||||
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. */
|
static void
|
||||||
if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0)
|
alc_start_tx(struct alc_softc *sc)
|
||||||
CSR_WRITE_2(sc, ALC_MBOX_TD_PRI0_PROD_IDX,
|
{
|
||||||
(uint16_t)sc->alc_cdata.alc_tx_prod);
|
|
||||||
else
|
/* Sync descriptors. */
|
||||||
CSR_WRITE_4(sc, ALC_MBOX_TD_PROD_IDX,
|
bus_dmamap_sync(sc->alc_cdata.alc_tx_ring_tag,
|
||||||
(sc->alc_cdata.alc_tx_prod <<
|
sc->alc_cdata.alc_tx_ring_map, BUS_DMASYNC_PREWRITE);
|
||||||
MBOX_TD_PROD_LO_IDX_SHIFT) &
|
/* Kick. Assume we're using normal Tx priority queue. */
|
||||||
MBOX_TD_PROD_LO_IDX_MASK);
|
if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0)
|
||||||
/* Set a timeout in case the chip goes out to lunch. */
|
CSR_WRITE_2(sc, ALC_MBOX_TD_PRI0_PROD_IDX,
|
||||||
sc->alc_watchdog_timer = ALC_TX_TIMEOUT;
|
(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
|
static void
|
||||||
@ -4642,3 +4655,54 @@ sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS)
|
|||||||
return (sysctl_int_range(oidp, arg1, arg2, req,
|
return (sysctl_int_range(oidp, arg1, arg2, req,
|
||||||
ALC_IM_TIMER_MIN, ALC_IM_TIMER_MAX));
|
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 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user