svn commit: r333291 - head/sys/net
Mark Johnston
markj at FreeBSD.org
Sun May 6 00:57:53 UTC 2018
Author: markj
Date: Sun May 6 00:57:52 2018
New Revision: 333291
URL: https://svnweb.freebsd.org/changeset/base/333291
Log:
Add netdump support to iflib.
em(4) and igb(4) were tested by me, and ixgbe(4) and bnxt(4) were
tested by sbruno.
Reviewed by: mmacy, shurd
MFC after: 1 month
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D15262
Modified:
head/sys/net/iflib.c
Modified: head/sys/net/iflib.c
==============================================================================
--- head/sys/net/iflib.c Sun May 6 00:53:52 2018 (r333290)
+++ head/sys/net/iflib.c Sun May 6 00:57:52 2018 (r333291)
@@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
#include <sys/taskqueue.h>
#include <sys/limits.h>
-
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_types.h>
@@ -71,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
+#include <netinet/netdump/netdump.h>
#include <netinet6/ip6_var.h>
#include <machine/bus.h>
@@ -735,6 +735,8 @@ static void iflib_if_init_locked(if_ctx_t ctx);
static struct mbuf * iflib_fixup_rx(struct mbuf *m);
#endif
+NETDUMP_DEFINE(iflib);
+
#ifdef DEV_NETMAP
#include <sys/selinfo.h>
#include <net/netmap.h>
@@ -3381,7 +3383,7 @@ iflib_tx_desc_free(iflib_txq_t txq, int n)
ifsd_map = txq->ift_sds.ifsd_map;
do_prefetch = (txq->ift_ctx->ifc_flags & IFC_PREFETCH);
- while (n--) {
+ while (n-- > 0) {
if (do_prefetch) {
prefetch(ifsd_m[(cidx + 3) & mask]);
prefetch(ifsd_m[(cidx + 4) & mask]);
@@ -4438,6 +4440,8 @@ iflib_device_register(device_t dev, void *sc, if_share
}
*ctxp = ctx;
+ NETDUMP_SET(ctx->ifc_ifp, iflib);
+
if_setgetcounterfn(ctx->ifc_ifp, iflib_if_get_counter);
iflib_add_device_sysctl_post(ctx);
ctx->ifc_flags |= IFC_INIT_DONE;
@@ -6015,3 +6019,88 @@ iflib_fixup_rx(struct mbuf *m)
return (n);
}
#endif
+
+#ifdef NETDUMP
+static void
+iflib_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+{
+ if_ctx_t ctx;
+
+ ctx = if_getsoftc(ifp);
+ CTX_LOCK(ctx);
+ *nrxr = NRXQSETS(ctx);
+ *ncl = ctx->ifc_rxqs[0].ifr_fl->ifl_size;
+ *clsize = ctx->ifc_rxqs[0].ifr_fl->ifl_buf_size;
+ CTX_UNLOCK(ctx);
+}
+
+static void
+iflib_netdump_event(struct ifnet *ifp, enum netdump_ev event)
+{
+ if_ctx_t ctx;
+ if_softc_ctx_t scctx;
+ iflib_fl_t fl;
+ iflib_rxq_t rxq;
+ int i, j;
+
+ ctx = if_getsoftc(ifp);
+ scctx = &ctx->ifc_softc_ctx;
+
+ switch (event) {
+ case NETDUMP_START:
+ for (i = 0; i < scctx->isc_nrxqsets; i++) {
+ rxq = &ctx->ifc_rxqs[i];
+ for (j = 0; j < rxq->ifr_nfl; j++) {
+ fl = rxq->ifr_fl;
+ fl->ifl_zone = m_getzone(fl->ifl_buf_size);
+ }
+ }
+ iflib_no_tx_batch = 1;
+ break;
+ default:
+ break;
+ }
+}
+
+static int
+iflib_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
+{
+ if_ctx_t ctx;
+ iflib_txq_t txq;
+ int error;
+
+ ctx = if_getsoftc(ifp);
+ if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
+ IFF_DRV_RUNNING)
+ return (EBUSY);
+
+ txq = &ctx->ifc_txqs[0];
+ error = iflib_encap(txq, &m);
+ if (error == 0)
+ (void)iflib_txd_db_check(ctx, txq, true, txq->ift_in_use);
+ return (error);
+}
+
+static int
+iflib_netdump_poll(struct ifnet *ifp, int count)
+{
+ if_ctx_t ctx;
+ if_softc_ctx_t scctx;
+ iflib_txq_t txq;
+ int i;
+
+ ctx = if_getsoftc(ifp);
+ scctx = &ctx->ifc_softc_ctx;
+
+ if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
+ IFF_DRV_RUNNING)
+ return (EBUSY);
+
+ txq = &ctx->ifc_txqs[0];
+ (void)iflib_completed_tx_reclaim(txq, RECLAIM_THRESH(ctx));
+
+ for (i = 0; i < scctx->isc_nrxqsets; i++)
+ (void)iflib_rxeof(&ctx->ifc_rxqs[i], 16 /* XXX */);
+ return (0);
+}
+#endif /* NETDUMP */
More information about the svn-src-head
mailing list