From nobody Tue Sep 15 18:30:30 2026 X-Original-To: dev-commits-src-main@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 4hkrDR2NRgz6sbTp for ; Tue, 15 Sep 2026 18:30:31 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hkrDR1k06z548G for ; Tue, 15 Sep 2026 18:30:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789497031; 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=1kibS0bo40Psbe6cUNfJKoqu4b6D+8ogVgfFI/GTmsU=; b=WQp44Hx3GZ/vmcwaVhwtb+a5yEclVou/g9E3j8b2Rjoq1aWdOyTntNs7Ei3v90/1xvMgLQ Iv5ktCiLnxtgWGBFimL0TIyPGYHqe/QihbPqwhYyf4pr5pmWeWLwwk2Py2Z0m52AhytO7X oM/QcgyWFOTT2VQOeHr3Zh5ZnPHRsHYwKBdwBPV05gBpo5KbwBpupAmUWeD/ATXb78qsea 9XqJJGDGsKsqEC/eeM7OgW7f13b82/qDeQMZteFaNxVpMmdh/kv5V/SjkpjTzmFWxB7NGC rWnNnd9E3yDrhiR/bE/i0vnRE2u4BYk1efx6o5CF5GykSlVDg0i2AShoF1I+jQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789497031; b=vACaaOL22NOztgwCoRuXT3rEszuA1r9Vf3XxbP43Sd7q48mlkHv2+4/MnKZgnb+q/T5exz uXIZx2g40C3Yz8fO7PljJKoTw3BNiVfxu3k6Rk+SIsE0IVAQpW3zkCi7IIzS5+rj3npb9u 1Ff87KTrX7EFKET712NbbFie76VPxLX1iXsX877ls7vHMeAQMgTimYlBFqNVfGqy0xxPOb JMigCLTrhchF3hq7EW4w0zqqrQcmF/5Bsi5O+HjGEN80LDjBKoYJVWT1hY8wW+XuxOrokP tP1puxeX4SJsIu/Jh8t1abdl3vzyWYReS9XykDoeA0+RGRyxVd1n54wyI3cfbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789497031; 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=1kibS0bo40Psbe6cUNfJKoqu4b6D+8ogVgfFI/GTmsU=; b=OJcBGXP0i7C5bu2FLcsL5aJLa994BV8ZPgLTIZKhdHfAT35Elo6sLovCg2gy9MV+C3zfW8 uoXy+1YdAmX7ZWcWJauKQTNJ9TpfLPfY23uviAef/2g5CEnniNywVeM5niDSJvd9fzOgsb kCUFGHwLu4v3KAoHd9Y6wdRaM5WaqwTdaa6LfizQ5iON+0QiZz4GUHW8/OVJ9OrHmx6tR9 ne21C53xz/3W/2E4SdfRYBEb0j1aXVoORSezRmvj5Zwd3/vPy6FEIy5wKXUPn7U8rV4NH9 ClJxVNI06JxkOBwxGJK9E3euIwFwlkmR1az89Czg8JKRWIkacBdDHcvnFOF++g== 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 4hkrDR0VPdz1BKq for ; Tue, 15 Sep 2026 18:30:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 20608 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 15 Sep 2026 18:30:30 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 7fb00406ebf5 - main - iflib: Use private lifecycle state for control work List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: 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/main X-Git-Reftype: branch X-Git-Commit: 7fb00406ebf53e07273d0914a5f36ff6fb78c185 Auto-Submitted: auto-generated Date: Tue, 15 Sep 2026 18:30:30 +0000 Message-Id: <6aa98ec6.20608.42f4e44d@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=7fb00406ebf53e07273d0914a5f36ff6fb78c185 commit 7fb00406ebf53e07273d0914a5f36ff6fb78c185 Author: Kevin Bowling AuthorDate: 2026-09-11 18:57:42 +0000 Commit: Kevin Bowling CommitDate: 2026-09-15 18:29:18 +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) MFC after: 2 weeks Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59597 --- 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 9979d17777ef..012c4ab5f54a 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -600,6 +600,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 *); @@ -952,7 +966,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); @@ -2843,12 +2857,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) { @@ -2862,8 +2870,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); @@ -4441,12 +4448,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); @@ -4455,8 +4460,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, @@ -4466,7 +4469,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; } @@ -6147,7 +6151,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++) @@ -6177,7 +6181,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); @@ -6186,15 +6190,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);