svn commit: r333285 - head/sys/dev/alc
Mark Johnston
markj at FreeBSD.org
Sun May 6 00:43:47 UTC 2018
Author: markj
Date: Sun May 6 00:43:46 2018
New Revision: 333285
URL: https://svnweb.freebsd.org/changeset/base/333285
Log:
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
Modified:
head/sys/dev/alc/if_alc.c
Modified: head/sys/dev/alc/if_alc.c
==============================================================================
--- head/sys/dev/alc/if_alc.c Sun May 6 00:42:30 2018 (r333284)
+++ head/sys/dev/alc/if_alc.c Sun May 6 00:43:46 2018 (r333285)
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
+#include <netinet/netdump/netdump.h>
#include <dev/mii/mii.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_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_int_range(SYSCTL_HANDLER_ARGS, int,
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 @@ static device_method_t alc_methods[] = {
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 @@ alc_attach(device_t dev)
goto fail;
}
+ /* Attach driver netdump methods. */
+ NETDUMP_SET(ifp, alc);
+
fail:
if (error != 0)
alc_detach(dev);
@@ -2974,25 +2981,31 @@ alc_start_locked(struct ifnet *ifp)
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 @@ sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS)
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 */
More information about the svn-src-all
mailing list