From nobody Thu Oct 29 05:06:59 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jFXK019kJz6xmtT for ; Thu, 29 Oct 2026 05:07:00 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jFXJz6bfZz4jNh for ; Thu, 29 Oct 2026 05:06:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793250419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rZXQMIxpIv1ETBYij3wy6pIUclU0ZIHyU7tS1T29e80=; b=ZzPLatbSbOuie+j1CKCn86erSb4KU/tfzCG7bfZSh2/RqaQbe4pZUy/Kp1xbenOarV/RFe ns7XheLEx7KDc5HrFlStVkXS27Hn89Lu8pzMPEV1pC861NFTSntf8zLS+4xa3lNR3F0aO/ eYeX2BH8Q5UW3cnzKFgJaFPbwQ5SgnOTm3Dt2kCgzc1hR39GsH/oEA8zDoIlfAZyAuVKGw 6MD578MxXt6KR+0+TNexr7MzG71I2ypg51IpymII3FSR0mJp9WE5jMXs1KXAzQ8+3H+VS+ FnvLfGkS+8NoVQQ8NASBo4n8iAeqJ4btFdcSgUhiuTksNEW7nxT7awyyB6tavw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793250419; b=mgx/5OKhZHuLaX+G4HF0Vy+ZVZn4oUJ6VSv70tLmEDi6C1FGLE6ucfPpIcmUCwnQmTnuOj 8mOLSgeHP9PuBH8WzD/+9KFCKmbnFeNoMQ2dL19Bw4pxuw2A9PB4ri/vD8R3J3kpjdximL nxcvwAOH1Yv0+sYVU7AX1ekb290HLP8MmIXiBLyc5T4PPmBSrj8Px8Y4UTlDkrB9hWITXq XCpcezakhz4tv85nAWYXgSMYS3bgaxBZcns+LoaTWkWjZ546/Ha99m4L/WBvBk3D+W/AiV hNcHotys20DZrpzKFSzharxvmZu1b104knUmJA1jbtjysDW13mXsx/oNo9fKyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793250419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rZXQMIxpIv1ETBYij3wy6pIUclU0ZIHyU7tS1T29e80=; b=OdRghU6bdCQAB/8mKLdV3VWXqwlw4AdjVG4sdkZfpltY5YGSNhSPWhTiF6WmERvGBrEvWb VZpE9AtcOX6ulvgxxM+3fDAIC8TOxwI1TOvrabGmO4y+yr4lOFVgQFNAvGbKAD2pBckkye bDg56RZavULAuBjqwkCesYzUYk7C0fEy7kgamBYuXFofJaFRSSgE/bXbOmntTskmHq1QIm cwfP81ILRNYK/vduCcOTLV3/OmAZleeK29lg4lXZ4b5ih5I5PEVWFT+cH/iGLf5x6Hjyvy /5PAnzMRdITNOlRGVxFtH3tDJxHo58SqFPtiPUCXi/yoAps8B5kyMJWQYtX2aw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jFXJz65kzzPV8 for ; Thu, 29 Oct 2026 05:06:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 315ce by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 29 Oct 2026 05:06:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 0fdb7f3d30e0 - stable/15 - iflib: Use private lifecycle state for control work List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/15 X-Git-Reftype: branch X-Git-Commit: 0fdb7f3d30e065011fd346f70d067ba54845c55d Auto-Submitted: auto-generated Date: Thu, 29 Oct 2026 05:06:59 +0000 Message-Id: <6ae2d473.315ce.31e063c3@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=0fdb7f3d30e065011fd346f70d067ba54845c55d commit 0fdb7f3d30e065011fd346f70d067ba54845c55d Author: Kevin Bowling AuthorDate: 2026-09-11 18:57:42 +0000 Commit: Kevin Bowling CommitDate: 2026-10-29 05:06:50 +0000 iflib: Use private lifecycle state for control work Use the context-locked datapath state for netmap initialization results, resume completion and administrative work eligibility. Keep stopped and failed interfaces eligible for link and mailbox recovery without using IFF_DRV_OACTIVE as an implicit indication that initialization has been attempted. Evaluate media and deferred admin eligibility under the context lock rather than from an earlier IFF_DRV_ flag snapshot. Always pass through iflib_stop() before an IOV-init callback which changes the PF queue layout, as the IOV-uninit counterpart already does. Neither administrative down nor a cleared IFF_DRV_RUNNING proves that queue DMA is stopped. The private lifecycle state decides whether the hardware stop is necessary; IFF_UP only decides whether to initialize again afterward. Reviewed by: iflib (gallatin) Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59597 (cherry picked from commit 7fb00406ebf53e07273d0914a5f36ff6fb78c185) --- sys/net/iflib.c | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 2fff221023d2..c008d915fd6d 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -539,6 +539,20 @@ typedef struct if_rxsd { #define CALLOUT_LOCK(txq) mtx_lock(&txq->ift_mtx) #define CALLOUT_UNLOCK(txq) mtx_unlock(&txq->ift_mtx) +static bool +iflib_admin_enabled(if_ctx_t ctx) +{ + + sx_assert(&ctx->ifc_ctx_sx, SA_XLOCKED); + /* + * Before the first stop/init, only drivers with an always-running + * admin path need deferred updates. Stopped and failed datapaths + * still need link, mailbox and recovery work after that point. + */ + return (ctx->ifc_datapath_state != IFLIB_DP_UNKNOWN || + (ctx->ifc_sctx->isc_flags & IFLIB_ADMIN_ALWAYS_RUN) != 0); +} + /* Our boot-time initialization hook */ static int iflib_module_event_handler(module_t, int, void *); @@ -833,7 +847,7 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff) iflib_init_locked(ctx); IFDI_CRCSTRIP_SET(ctx, onoff, iflib_crcstrip); // XXX why twice ? - status = if_getdrvflags(ifp) & IFF_DRV_RUNNING ? 0 : 1; + status = ctx->ifc_datapath_state == IFLIB_DP_RUNNING ? 0 : 1; if (status) nm_clear_native_flags(na); CTX_UNLOCK(ctx); @@ -2621,12 +2635,6 @@ static void iflib_media_status(if_t ifp, struct ifmediareq *ifmr) { if_ctx_t ctx = if_getsoftc(ifp); - bool oactive, running; - - STATE_LOCK(ctx); - running = (if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_RUNNING); - oactive = (if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_OACTIVE); - STATE_UNLOCK(ctx); CTX_LOCK(ctx); if (ctx->ifc_pm_state != IFLIB_PM_ACTIVE) { @@ -2640,8 +2648,7 @@ iflib_media_status(if_t ifp, struct ifmediareq *ifmr) * _task_fn_admin(), so only do it if that's not running. That can be quite * expensive on some drivers. */ - if ((!running && !oactive) && - !(ctx->ifc_sctx->isc_flags & IFLIB_ADMIN_ALWAYS_RUN)) { + if (!iflib_admin_enabled(ctx)) { IFDI_UPDATE_ADMIN_STATUS(ctx); } IFDI_MEDIA_STATUS(ctx, ifmr); @@ -4190,12 +4197,10 @@ _task_fn_admin(void *context, int pending) if_softc_ctx_t sctx = &ctx->ifc_softc_ctx; iflib_txq_t txq; int i; - bool oactive, running, do_reset, do_reset_if_up, do_watchdog; + bool do_reset, do_reset_if_up, do_watchdog; bool in_detach; STATE_LOCK(ctx); - running = (if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_RUNNING); - oactive = (if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_OACTIVE); do_reset = (ctx->ifc_flags & IFC_DO_RESET); do_reset_if_up = (ctx->ifc_flags & IFC_DO_RESET_IF_UP); do_watchdog = (ctx->ifc_flags & IFC_DO_WATCHDOG); @@ -4204,8 +4209,6 @@ _task_fn_admin(void *context, int pending) IFC_DO_WATCHDOG); STATE_UNLOCK(ctx); - if ((!running && !oactive) && !(ctx->ifc_sctx->isc_flags & IFLIB_ADMIN_ALWAYS_RUN)) - return; if (in_detach) return; KFAIL_POINT_CODE_COND(_debug_fail_point_iflib, @@ -4215,7 +4218,8 @@ _task_fn_admin(void *context, int pending) iflib_admin_task_fail_device) == 0, FAIL_POINT_NONSLEEPABLE, {}); CTX_LOCK(ctx); - if (ctx->ifc_pm_state != IFLIB_PM_ACTIVE) { + if (ctx->ifc_pm_state != IFLIB_PM_ACTIVE || + !iflib_admin_enabled(ctx)) { CTX_UNLOCK(ctx); return; } @@ -5853,7 +5857,7 @@ iflib_device_resume(device_t dev) CTX_LOCK(ctx); error = iflib_device_resume_locked(ctx); - running = (if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_RUNNING) != 0; + running = ctx->ifc_datapath_state == IFLIB_DP_RUNNING; CTX_UNLOCK(ctx); if (running) { for (int i = 0; i < NTXQSETS(ctx); i++, txq++) @@ -5883,7 +5887,7 @@ iflib_device_iov_init_restart(device_t dev, uint16_t num_vfs, { if_ctx_t ctx; if_t ifp; - bool restart, running; + bool restart; int error; ctx = device_get_softc(dev); @@ -5892,15 +5896,14 @@ iflib_device_iov_init_restart(device_t dev, uint16_t num_vfs, CTX_LOCK(ctx); /* * Drivers which change the PF queue layout need the complete iflib - * stop/init sequence around their IOV callback when the interface is - * active. An administratively-down interface has no live queues to - * quiesce, and must remain down after the new layout is installed. - * Keep the transition within one context-lock critical section. + * stop/init sequence around their IOV callback. Administrative state + * and IFF_DRV_RUNNING do not establish that the queues are stopped: + * failed initialization or a pending watchdog reset can leave DMA + * active. Let iflib_stop() decide whether hardware needs quiescing, + * and preserve administrative state across the layout change. */ restart = (if_getflags(ifp) & IFF_UP) != 0; - running = (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0; - if (restart || running) - iflib_stop(ctx); + iflib_stop(ctx); error = IFDI_IOV_INIT(ctx, num_vfs, params); if (restart) iflib_init_locked(ctx);