From owner-dev-commits-src-branches@freebsd.org Thu Aug 26 00:03:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CC2A65DDA8; Thu, 26 Aug 2021 00:03:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gw32r1s4Lz4TJd; Thu, 26 Aug 2021 00:03:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C10825EA9; Thu, 26 Aug 2021 00:03:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q03GV7004108; Thu, 26 Aug 2021 00:03:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q03GEP004107; Thu, 26 Aug 2021 00:03:16 GMT (envelope-from git) Date: Thu, 26 Aug 2021 00:03:16 GMT Message-Id: <202108260003.17Q03GEP004107@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 477308acc5f0 - stable/12 - iflib: emulate counters in netmap mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 477308acc5f0c11940e98c4f278f2f4f1b072360 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 00:03:16 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=477308acc5f0c11940e98c4f278f2f4f1b072360 commit 477308acc5f0c11940e98c4f278f2f4f1b072360 Author: Stephan de Wit AuthorDate: 2021-08-18 07:17:43 +0000 Commit: Kevin Bowling CommitDate: 2021-08-26 00:01:26 +0000 iflib: emulate counters in netmap mode When iflib devices are in netmap mode the driver counters are no longer updated making it look from userspace tools that traffic has stopped. Reported by: Franco Fichtner Reviewed by: vmaffione, iflib (erj, gallatin) Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31550 (cherry picked from commit 66fa12d8fb61485780f32f0226e79d3389567496) --- sys/net/iflib.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 1976852209a1..fb43a62ba67f 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -994,6 +994,7 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) u_int const lim = kring->nkr_num_slots - 1; u_int const head = kring->rhead; struct if_pkt_info pi; + int tx_pkts = 0, tx_bytes = 0; /* * interrupts on every tx packet are expensive so request @@ -1077,6 +1078,10 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) ctx->isc_txd_encap(ctx->ifc_softc, &pi); DBG_COUNTER_INC(tx_encap); + /* Update transmit counters */ + tx_bytes += pi.ipi_len; + tx_pkts++; + /* Reinit per-packet info for the next one. */ flags = seg_idx = pkt_len = 0; nic_i_start = -1; @@ -1135,6 +1140,10 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) iflib_netmap_timer, txq, txq->ift_netmap_timer.c_cpu, 0); } + + if_inc_counter(ifp, IFCOUNTER_OBYTES, tx_bytes); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, tx_pkts); + return (0); } @@ -1162,7 +1171,7 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) u_int n; u_int const lim = kring->nkr_num_slots - 1; int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR; - int i = 0; + int i = 0, rx_bytes = 0, rx_pkts = 0; if_ctx_t ctx = ifp->if_softc; if_shared_ctx_t sctx = ctx->ifc_sctx; @@ -1233,6 +1242,10 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) if (i == (ri.iri_nfrags - 1)) { ring->slot[nm_i].len -= crclen; ring->slot[nm_i].flags = 0; + + /* Update receive counters */ + rx_bytes += ri.iri_len; + rx_pkts++; } else ring->slot[nm_i].flags = NS_MOREFRAG; } @@ -1270,6 +1283,9 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) */ netmap_fl_refill(rxq, kring, false); + if_inc_counter(ifp, IFCOUNTER_IBYTES, rx_bytes); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, rx_pkts); + return (0); }