From nobody Sat Jun 20 19:10:41 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 4gjPDx6yPvz6hNm4 for ; Sat, 20 Jun 2026 19:10:41 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gjPDx1rKjz3vCX for ; Sat, 20 Jun 2026 19:10:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781982641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QRON3HXA4s/3S2XOZz9FDer7xnnUuK20NEwC0YFlJrU=; b=Ohib76JU2goPtP+X7p9qglXy7U8GFJSl8XoG4ZbcLEZyDJkWdnQ9Ak0Hn2GO8dTFdWfpXN 1T8auQBbTXnGom5V+A3/QakIYGbq5DS0rOYJQRA9aKoHN1sysei508Kv0Q2EzitjdIw13/ wfFmyWIJVXAY/miB48ISdbWzm4nmrC7CNTsCVzpAKyL+oFAgu3DbFpkGgbkCrJieyDHHdN In1FRph8VXYFPhsTCfj/51AG8zEmZociSL0laOcfOVoXDdylSLSEvIEiTj5Kb+agiYNnUN KYgZ5F2Eeuiutm24Wek1OvOx05QrTEu5M/YzeOi3bcD4Ok5MoQFKb5lXqyLrQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781982641; a=rsa-sha256; cv=none; b=rZfMIgg2zDqhTwWFe2eCEysMq+U+tzwXTl5c8A59VEKTeukYAksYXjkDaUWdEB/z1Im7VI H1tsf8JtrzfliiFzS6iEftKYkwcj7a7o+6rQRY7Kq7BELlGUHlfCJpsj7PRBrEvSbn1DAi y/7KFuPBxPXCH/8s4i2Slqr0Ta3UYEX31MA3zhReEmZhjRe0JFKlOSKjnEH/1PZicjHaHZ GKR1Rpw07L31OBc3snW9m77Bo0LGZJkKbUCMgYpsHyi+fdbIYgubTxfSAsW7J9/xoCM2rO tUjzhPIpjUn2BVpE/vTgYWA04s5Xv7c8Hz+suATPBX6EYEdKYEwpGRJYeSBuWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781982641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QRON3HXA4s/3S2XOZz9FDer7xnnUuK20NEwC0YFlJrU=; b=DL6n+rCGJt9Ijxr+4QjI2eggPLScPp21nNp3e/ODdilQTRJ+z51jNiQJ93dglaAOk5LdGv FpPt2+smmA+SFhZStJvYnktpBsEbt2XrZH8eQR1msb9SecN16geBUDA+dGuiU40VO+bCby n/2Iu3/VhuKM6wW377QkDci5C4ystzAFXR5WfcmnX/dC73ecGFqMDQk4k0vb2nlSFsKaW+ 9IF6VrOs0+7Y+lPsXKI91ItkHqYxR4xocVWZJMk1iIn5+6LRxHlsusnPsdcscw/dAAWeBT xMbm4v5yNNpi3eRPknubegLMT1a8Ppg84d15EKvKlrSY4veXG7WaRStUs5r32Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gjPDx0dgzzkNw for ; Sat, 20 Jun 2026 19:10:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 343ca by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 20 Jun 2026 19:10:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Nick Price From: Adrian Chadd Subject: git: a10151fa662c - main - aq(4): take F/W statistics off the iflib core lock (kick-and-read) 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: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a10151fa662c1d370861154e2f83e88a20be149c Auto-Submitted: auto-generated Date: Sat, 20 Jun 2026 19:10:41 +0000 Message-Id: <6a36e5b1.343ca.2e38d973@gitrepo.freebsd.org> The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=a10151fa662c1d370861154e2f83e88a20be149c commit a10151fa662c1d370861154e2f83e88a20be149c Author: Nick Price AuthorDate: 2026-06-20 19:03:18 +0000 Commit: Adrian Chadd CommitDate: 2026-06-20 19:10:16 +0000 aq(4): take F/W statistics off the iflib core lock (kick-and-read) The once-per-second statistics refresh ran the whole F/W-mailbox transaction under iflib's CTX (sx) lock: fw2x_get_stats toggled the MPI STATISTICS control bit and busy-polled the state register for the acknowledgement (up to ~25 ms) before downloading the counters, so a slow F/W response blocked datapath reconfigure / ioctls for the duration. The per-cast and error counters have no direct-register source -- the reference Linux atlantic driver and our port both read them out of the F/W mailbox, and the MSM registers the chip exposes are never used for the periodic counters. So rather than poll, adopt the kick-and-read shape the iflib peer with the same constraint uses (vmxnet3): consume the snapshot the F/W produced for the *previous* request, then toggle the bit to request the next one -- no wait. The F/W finished that previous refresh ~1 s ago, so the download needs no poll, and the toggle write stays serialized against set_mode by the CTX lock exactly as before. This removes the 25 ms poll (and the toggle_mpi_ctrl_and_wait_ helper) from under the lock; only the fast 16-dword download remains. Cost: the counters lag one 1 s cycle, invisible for monitoring, and a torn read is already rejected by aq_update_hw_stats' monotonic-delta check. Validated on AQC107: a fixed 500 MiB RX transfer advances good_octets_rcvd by 549.6 MB -- 500 MiB plus the ~4.8% Ethernet framing overhead -- with rx_err=0 and traffic at line rate. Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D57439 --- sys/dev/aq/aq_fw2x.c | 61 ++++++---------------------------------------------- 1 file changed, 7 insertions(+), 54 deletions(-) diff --git a/sys/dev/aq/aq_fw2x.c b/sys/dev/aq/aq_fw2x.c index 04935e9368d4..339644d0c8e1 100644 --- a/sys/dev/aq/aq_fw2x.c +++ b/sys/dev/aq/aq_fw2x.c @@ -422,69 +422,19 @@ fw2x_stats_to_fw_stats_(struct aq_hw_stats* dst, } -static bool -toggle_mpi_ctrl_and_wait_(struct aq_hw* hw, uint64_t mask, uint32_t timeout_ms, - uint32_t try_count) -{ - uint64_t ctrl = get_mpi_ctrl_(hw); - uint64_t state = get_mpi_state_(hw); - - // AQ_DBG_ENTER(); - // First, check that control and state values are consistent - if ((ctrl & mask) != (state & mask)) { - trace_warn(dbg_fw, - "fw2x> MPI control (%#llx) and state (%#llx) are not consistent for mask %#llx!", - (unsigned long long)ctrl, (unsigned long long)state, - (unsigned long long)mask); - AQ_DBG_EXIT(false); - return (false); - } - - // Invert bits (toggle) in control register - ctrl ^= mask; - set_mpi_ctrl_(hw, ctrl); - - // Clear all bits except masked - ctrl &= mask; - - // Wait for FW reflecting change in state register - while (try_count-- != 0) { - if ((get_mpi_state_(hw) & mask) == ctrl) - { -// AQ_DBG_EXIT(true); - return (true); - } - DELAY((timeout_ms) * 1000); - } - - trace_detail(dbg_fw, - "f/w2x> timeout while waiting for response in state register for bit %#llx!", - (unsigned long long)mask); - // AQ_DBG_EXIT(false); - return (false); -} - - int fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats* stats) { - int err = 0; struct fw2x_msm_statistics fw2x_stats = {0}; - -// AQ_DBG_ENTER(); + uint64_t mpi_ctrl; + int err; if ((hw->fw_caps & FW2X_CAP_STATISTICS) == 0) { trace_warn(dbg_fw, "fw2x> statistics not supported by F/W"); return (ENOTSUP); } - // Tell F/W to update the statistics. - if (!toggle_mpi_ctrl_and_wait_(hw, FW2X_CAP_STATISTICS, 1, 25)) { - trace_error(dbg_fw, "fw2x> statistics update timeout"); - AQ_DBG_EXIT(ETIMEDOUT); - return (ETIMEDOUT); - } - + /* Kick-and-read: take the F/W's previous snapshot, request the next. */ err = aq_hw_fw_downld_dwords(hw, hw->mbox_addr + offsetof(struct fw2x_mailbox, msm), (uint32_t*)&fw2x_stats, sizeof fw2x_stats/sizeof(uint32_t)); @@ -495,7 +445,10 @@ fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats* stats) trace_error(dbg_fw, "fw2x> download statistics data FAILED, error %d", err); -// AQ_DBG_EXIT(err); + mpi_ctrl = get_mpi_ctrl_(hw); + mpi_ctrl ^= FW2X_CAP_STATISTICS; + set_mpi_ctrl_(hw, mpi_ctrl); + return (err); }