From owner-dev-commits-src-all@freebsd.org Sun Jan 10 14:49:09 2021 Return-Path: Delivered-To: dev-commits-src-all@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 224A44CF1C3; Sun, 10 Jan 2021 14:49:09 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DDKVC72tVz4lHs; Sun, 10 Jan 2021 14:49:07 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.229.168]) by shaw.ca with ESMTPA id yc1gkajjIktFkyc1hk6JXf; Sun, 10 Jan 2021 07:49:06 -0700 X-Authority-Analysis: v=2.4 cv=NYRYa0P4 c=1 sm=1 tr=0 ts=5ffb13e2 a=7AlCcx2GqMg+lh9P3BclKA==:117 a=7AlCcx2GqMg+lh9P3BclKA==:17 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=EmqxpYm9HcoA:10 a=VxmjJ2MpAAAA:8 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=hkcPmCClcqprY-XaVP8A:9 a=CjuIK1q_8ugA:10 a=1gNDDdWnnLUA:10 a=7gXAzLPJhVmCkEl4_tsf:22 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [IPv6:fc00:1:1:1::5b]) by spqr.komquats.com (Postfix) with ESMTPS id A1969610; Sun, 10 Jan 2021 06:49:03 -0800 (PST) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 10AEn3Gt075605; Sun, 10 Jan 2021 06:49:03 -0800 (PST) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202101101449.10AEn3Gt075605@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Cy Schubert cc: Vincenzo Maffione , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 3d65fd97e85a - main - netmap: iflib: enable/disable krings on any interface reinit In-reply-to: <202101101433.10AEXkaX075355@slippy.cwsent.com> References: <202101101205.10AC5ZrS084658@gitrepo.freebsd.org> <202101101433.10AEXkaX075355@slippy.cwsent.com> Comments: In-reply-to Cy Schubert message dated "Sun, 10 Jan 2021 06:33:46 -0800." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 10 Jan 2021 06:49:03 -0800 X-CMAE-Envelope: MS4xfDfLoW22xE61/kD4+bj+xqgQJs8uoTUvg1XaVjpA1npz8Wsp8nzsAgyGa6RzEqbgMROWnaB51J5ov3XD9gO833eo9htw2uVpsGmyHo+gTk1u6lNlerCt ZgVHinIEc7PNDS7B8QiqvHLqyuCmRMa0IsYAfSNh96ZOBgluSDfMMFvtaBRtyzEZ0tmavDedVgTyISiNyuCkGl7U86LqGEXhLirc/UddKnZq+4Tqj5t4xLal pyNu9SQ57aatKI49pqVdW6ZtJbXJMZkje7T0esRXmJdIymTXV/PpzsGRtVoKCx+KHsAi3lbDxKxguWEpZNIJCBmeq+R3IsO4C7szhHwts1Q= X-Rspamd-Queue-Id: 4DDKVC72tVz4lHs X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of cy.schubert@cschubert.com has no SPF policy when checking 64.59.136.137) smtp.mailfrom=cy.schubert@cschubert.com X-Spamd-Result: default: False [-1.70 / 15.00]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; RWL_MAILSPIKE_GOOD(0.00)[64.59.136.137:from]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[4]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RECEIVED_SPAMHAUS_PBL(0.00)[70.67.229.168:received]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[64.59.136.137:from]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:6327, ipnet:64.59.128.0/20, country:CA]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[cschubert.com: no valid DMARC record]; AUTH_NA(1.00)[]; SPAMHAUS_ZRD(0.00)[64.59.136.137:from:127.0.2.255]; RCVD_IN_DNSWL_LOW(-0.10)[64.59.136.137:from]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_NA(0.00)[no SPF record]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jan 2021 14:49:09 -0000 In message <202101101433.10AEXkaX075355@slippy.cwsent.com>, Cy Schubert writes: > In message <202101101205.10AC5ZrS084658@gitrepo.freebsd.org>, Vincenzo > Maffione > writes: > > The branch main has been updated by vmaffione: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3d65fd97e85ab807f3baa62aa979ae > 52 > > 7914a3ea > > > > commit 3d65fd97e85ab807f3baa62aa979ae527914a3ea > > Author: Vincenzo Maffione > > AuthorDate: 2021-01-10 12:00:30 +0000 > > Commit: Vincenzo Maffione > > CommitDate: 2021-01-10 12:04:08 +0000 > > > > netmap: iflib: enable/disable krings on any interface reinit > > > > Since 1d238b07d5d4d9660ae0e0, krings are disabled before > > a reinit cycle triggered by iflib_netmap_register. > > However, this operation is actually necessary also for > > any interface reinit triggered by other causes (i.e., > > ifconfig commands). > > We achieve this goal by moving the krings enable/disable > > operation inside iflib_stop() and iflib_init_locked(). > > > > Once here, this change also removes some redundant operations > > from iflib_netmap_register(), that are already performed by > > iflib_stop(). > > > > PR: 252453 > > MFC after: 1 week > > --- > > sys/net/iflib.c | 35 ++++++++++++++++++++--------------- > > 1 file changed, 20 insertions(+), 15 deletions(-) > > > > diff --git a/sys/net/iflib.c b/sys/net/iflib.c > > index cf02b1574c10..3de80ecaeb0c 100644 > > --- a/sys/net/iflib.c > > +++ b/sys/net/iflib.c > > @@ -801,27 +801,18 @@ iflib_netmap_register(struct netmap_adapter *na, int > on > > off) > > int status; > > > > CTX_LOCK(ctx); > > - IFDI_INTR_DISABLE(ctx); > > - > > - /* Tell the stack that the interface is no longer active */ > > - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); > > - > > if (!CTX_IS_VF(ctx)) > > IFDI_CRCSTRIP_SET(ctx, onoff, iflib_crcstrip); > > > > - /* > > - * Stop any pending txsync/rxsync and prevent new ones > > - * form starting. Processes blocked in poll() will get > > - * POLLERR. > > - */ > > - netmap_disable_all_rings(ifp); > > - > > iflib_stop(ctx); > > > > /* > > * Enable (or disable) netmap flags, and intercept (or restore) > > * ifp->if_transmit. This is done once the device has been stopped > > - * to prevent race conditions. > > + * to prevent race conditions. Also, this must be done after > > + * calling netmap_disable_all_rings() and before calling > > + * netmap_enable_all_rings(), so that these two functions see the > > + * updated state of the NAF_NETMAP_ON bit. > > */ > > if (onoff) { > > nm_set_native_flags(na); > > @@ -835,8 +826,6 @@ iflib_netmap_register(struct netmap_adapter *na, int on > of > > f) > > if (status) > > nm_clear_native_flags(na); > > CTX_UNLOCK(ctx); > > - /* Re-enable txsync/rxsync. */ > > - netmap_enable_all_rings(ifp); > > return (status); > > } > > > > @@ -2388,6 +2377,12 @@ iflib_init_locked(if_ctx_t ctx) > > if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING); > > IFDI_INTR_DISABLE(ctx); > > > > + /* > > + * See iflib_stop(). Useful in case iflib_init_locked() is > > + * called without first calling iflib_stop(). > > + */ > > + netmap_disable_all_rings(ifp); > > + > > tx_ip_csum_flags = scctx->isc_tx_csum_flags & (CSUM_IP | CSUM_TCP | CSU > > M_UDP | CSUM_SCTP); > > tx_ip6_csum_flags = scctx->isc_tx_csum_flags & (CSUM_IP6_TCP | CSUM_IP6 > > _UDP | CSUM_IP6_SCTP); > > /* Set hardware offload abilities */ > > @@ -2444,6 +2439,9 @@ done: > > for (i = 0; i < sctx->isc_ntxqsets; i++, txq++) > > callout_reset_on(&txq->ift_timer, iflib_timer_default, iflib_ti > > mer, txq, > > txq->ift_timer.c_cpu); > > + > > + /* Re-enable txsync/rxsync. */ > > + netmap_enable_all_rings(ifp); > > } > > > > static int > > @@ -2489,6 +2487,13 @@ iflib_stop(if_ctx_t ctx) > > IFDI_STOP(ctx); > > DELAY(1000); > > > > + /* > > + * Stop any pending txsync/rxsync and prevent new ones > > + * form starting. Processes blocked in poll() will get > > + * POLLERR. > > + */ > > + netmap_disable_all_rings(ctx->ifc_ifp); > > + > > iflib_debug_reset(); > > /* Wait for current tx queue users to exit to disarm watchdog timer. */ > > for (i = 0; i < scctx->isc_ntxqsets; i++, txq++) { > > > > This commit makes a couple of assumptions > > 1. It's missing definition in a header for netmap_disable_all_rings() and > netmap_enable_all_rings(). > > 2. It assumes that all kernels include device, that it is not loaded as a > kld. > > The first assumption causes a build failure. > > The second assumption might require at the very least an UPDATING entry to > warn people not to remove netmap from their kernels or rely on the module. > And probably needs a __FreeBSD_version bump. Nevermnd. I see what's going on. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few.