From owner-dev-commits-src-all@freebsd.org Sun Jan 10 14:48:45 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 27A534CF247; Sun, 10 Jan 2021 14:48:45 +0000 (UTC) (envelope-from vmaffione@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DDKTn0bc1z4kvj; Sun, 10 Jan 2021 14:48:45 +0000 (UTC) (envelope-from vmaffione@freebsd.org) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: vmaffione) by smtp.freebsd.org (Postfix) with ESMTPSA id E8A06271C3; Sun, 10 Jan 2021 14:48:44 +0000 (UTC) (envelope-from vmaffione@freebsd.org) Received: by mail-pf1-f172.google.com with SMTP id c79so9409976pfc.2; Sun, 10 Jan 2021 06:48:44 -0800 (PST) X-Gm-Message-State: AOAM530lJmOQmH90nWFQpi3APeFasDAZdftsl7ci2f1Frp3m/l9+fkec I/xlW1XZuCiYtq7ECSegzyb8Yin/33NzD3PDO/A= X-Google-Smtp-Source: ABdhPJzuDhzKVN1GJe65uR1FyQXNqrmSYzBFtH1JniyFvtJSP9Nf/7jKbrduXC73ZLHMEgnmaEroW13n6RiQYgFdjOA= X-Received: by 2002:aa7:8387:0:b029:1ae:72c6:e011 with SMTP id u7-20020aa783870000b02901ae72c6e011mr10558768pfm.81.1610290123772; Sun, 10 Jan 2021 06:48:43 -0800 (PST) MIME-Version: 1.0 References: <202101101205.10AC5ZrS084658@gitrepo.freebsd.org> <202101101433.10AEXkaX075355@slippy.cwsent.com> In-Reply-To: <202101101433.10AEXkaX075355@slippy.cwsent.com> From: Vincenzo Maffione Date: Sun, 10 Jan 2021 15:48:32 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: git: 3d65fd97e85a - main - netmap: iflib: enable/disable krings on any interface reinit To: Cy Schubert Cc: src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 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:48:45 -0000 Il giorno dom 10 gen 2021 alle ore 15:33 Cy Schubert < Cy.Schubert@cschubert.com> ha scritto: > 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=3d65fd97e85ab807f3baa62aa979ae52 > > 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 > onof > > 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++) { > > > > Sorry, that was not intentional. > 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(). > The header definitions are actually in sys/dev/netmap/netmap_kern.h > > 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. > I pushed another commit to (hopefully) fix the issue. I don't think any of this is necessary, because iflib already supports the case where DEV_NETMAP is not defined. I simply forgot to add a placeholder. Thanks > -- > 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. > > >