From owner-svn-src-head@freebsd.org Sun May 6 00:57:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82BF4FC1B3C; Sun, 6 May 2018 00:57:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 327AD77A3E; Sun, 6 May 2018 00:57:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D58325379; Sun, 6 May 2018 00:57:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w460vr2u090207; Sun, 6 May 2018 00:57:53 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w460vr4x090206; Sun, 6 May 2018 00:57:53 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201805060057.w460vr4x090206@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 6 May 2018 00:57:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333291 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 333291 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2018 00:57:53 -0000 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 #include - #include #include #include @@ -71,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -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 #include @@ -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 */