From nobody Fri Apr 18 14:37:18 2025 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 4ZfHR30Hn9z5stfP; Fri, 18 Apr 2025 14:37:19 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZfHR239ZPz3Kmy; Fri, 18 Apr 2025 14:37:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744987038; 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=mMopBGP4Yd7iyYogS36FtcfzbvJyl15xlFWsN8KKi2w=; b=AqvJCGKPrGEvpuDjAKJau21S/xm8/tKL+y0besRd+8F046670h98YmFTgh562nF46+6C7Z dGKm0D+yxkD0FbW7+C6goK7/6I4/ASJhT/Ok8/cGczp+IbdonlWqp4N3FByKbX5/v0oy/C 3auCZxSBt25xdYjVEqlPM7Ama0tuxCBDYq+FP1hsn/KvdtH/952GFLfIY3f8VCFNV+MGpz 900iy0aYp5WgKRfNtCTempOjAGeaqIptSJD9PKAXtU00BVJV/J6H7jMx4fA3KbnZo2sy0l gwgQiirO2TyRKO7sMMcKISMCV3uR3bGSH4dIGnu0mQCa0T41HECoJT3ZWO/y5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744987038; a=rsa-sha256; cv=none; b=bAG8QdxA3VExLZJzWAk8wtibwSOoVvhO9wciuIKNnyiIpAX0M7PYErJJGxnsL0K1W9MLDJ Zr1l7oIzssYei6DhiE12GqTIIUwG/aB0Bfao/Y0UYy4eImfUXapzxClqkFQnOanDZlKbOx HxBJmwvNC3BbpaOSUdb9GQYxRaAswqtR2No7wGeQ4OJXfwUGdNlcX7P+emSm6DLZIJ2k7p A+Wf0xP54GpMu2bSmcSyMSkIeKDLenzjv6q1dEKASU8pANXxIAKhg/LvOihuHJcwKFZJAy 8aJ1EKfQHSwBoCEDjiablqoYO4kKdGLx93gDPIHqzOghxTBDbqpFbeuQRtF9xw== 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=1744987038; 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=mMopBGP4Yd7iyYogS36FtcfzbvJyl15xlFWsN8KKi2w=; b=lpWPrHTZdmx7sl70RjJ51KJsEmq9wriERlEAnUlL/ecyRbev/q7jUsfhmw+Uty3E5xCiYg +fGhNnMKkW5CD3seYxTVvMeyW3A3W4Ntt6aI89gexY4a4b7im47+12HsZTt2cxQ6ec918I tje5fglofknVjTkDVBMVGlufEIpJkt0J8/hos7ruCBmukj3ZiXSKUnxYOUN14B3SGGG1Rq 7FFnYMkG0WSuw5dNdb72ZS9p4GU6N8c/f8otVTWnUR7dCHTl1j5t6VqrfsxzpBYCLHF7Tf +mt8mtYdL77/rrCJUsiOQzbIkutZ40zcwXigLlp6iDDofJGIjbB4NlCi21Eocg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZfHR229phzfHL; Fri, 18 Apr 2025 14:37:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53IEbIDw091987; Fri, 18 Apr 2025 14:37:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53IEbIR6091984; Fri, 18 Apr 2025 14:37:18 GMT (envelope-from git) Date: Fri, 18 Apr 2025 14:37:18 GMT Message-Id: <202504181437.53IEbIR6091984@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 3a35e07fa930 - stable/14 - LinuxKPI: 802.11: add a lchanctx list to lhw List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3a35e07fa9309a357f9f7d25e86aba6f93c0af84 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=3a35e07fa9309a357f9f7d25e86aba6f93c0af84 commit 3a35e07fa9309a357f9f7d25e86aba6f93c0af84 Author: Bjoern A. Zeeb AuthorDate: 2025-04-08 23:05:43 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-18 14:36:01 +0000 LinuxKPI: 802.11: add a lchanctx list to lhw While we are currently only supporting a single VAP (vif) it is less of a trouble but in order to get locking and rcu accesses [from drivers] more right add a list for all chanctx_conf we have for one hw. Use that list in the iterator function to avoid having to lock the vif but not protecting the chanctx list (against a parallel removal) due to different locking. Sponsored by: The FreeBSD Foundation PR: 280546 Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734 (cherry picked from commit a8a47a41775b0320606f90b3ac2048bc23494615) --- sys/compat/linuxkpi/common/src/linux_80211.c | 39 ++++++++++++++++++---------- sys/compat/linuxkpi/common/src/linux_80211.h | 4 +++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index bd1e60928144..f5f52101d367 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -1756,6 +1756,7 @@ lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) /* Cleanup. */ rcu_assign_pointer(vif->bss_conf.chanctx_conf, NULL); lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); + list_del(&lchanctx->entry); free(lchanctx, M_LKPI80211); } @@ -1942,6 +1943,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int goto out; } + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list); rcu_assign_pointer(vif->bss_conf.chanctx_conf, chanctx_conf); /* Assign vif chanctx. */ @@ -1956,6 +1958,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); rcu_assign_pointer(vif->bss_conf.chanctx_conf, NULL); lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); + list_del(&lchanctx->entry); free(lchanctx, M_LKPI80211); goto out; } @@ -5469,6 +5472,9 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) TAILQ_INIT(&lhw->scheduled_txqs[ac]); } + /* Chanctx_conf */ + INIT_LIST_HEAD(&lhw->lchanctx_list); + /* Deferred RX path. */ LKPI_80211_LHW_RXQ_LOCK_INIT(lhw); TASK_INIT(&lhw->rxq_task, 0, lkpi_80211_lhw_rxq_task, lhw); @@ -5532,6 +5538,22 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) __func__, lhw, mbufq_len(&lhw->rxq))); LKPI_80211_LHW_RXQ_LOCK_DESTROY(lhw); + /* Chanctx_conf. */ + if (!list_empty_careful(&lhw->lchanctx_list)) { + struct lkpi_chanctx *lchanctx, *next; + struct ieee80211_chanctx_conf *chanctx_conf; + + list_for_each_entry_safe(lchanctx, next, &lhw->lchanctx_list, entry) { + if (lchanctx->added_to_drv) { + /* In reality we should panic? */ + chanctx_conf = &lchanctx->chanctx_conf; + lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); + } + list_del(&lchanctx->entry); + free(lchanctx, M_LKPI80211); + } + } + /* Cleanup more of lhw here or in wiphy_free()? */ LKPI_80211_LHW_TXQ_LOCK_DESTROY(lhw); LKPI_80211_LHW_SCAN_LOCK_DESTROY(lhw); @@ -5967,8 +5989,6 @@ linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *hw, void *arg) { struct lkpi_hw *lhw; - struct lkpi_vif *lvif; - struct ieee80211_vif *vif; struct lkpi_chanctx *lchanctx; KASSERT(hw != NULL && iterfunc != NULL, @@ -5976,22 +5996,13 @@ linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *hw, lhw = HW_TO_LHW(hw); - IMPROVE("lchanctx should be its own list somewhere"); - - LKPI_80211_LHW_LVIF_LOCK(lhw); - TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { - - vif = LVIF_TO_VIF(lvif); - if (vif->bss_conf.chanctx_conf == NULL) /* XXX-BZ; FIXME see IMPROVE above. */ - continue; - - lchanctx = CHANCTX_CONF_TO_LCHANCTX(vif->bss_conf.chanctx_conf); + rcu_read_lock(); + list_for_each_entry_rcu(lchanctx, &lhw->lchanctx_list, entry) { if (!lchanctx->added_to_drv) continue; - iterfunc(hw, &lchanctx->chanctx_conf, arg); } - LKPI_80211_LHW_LVIF_UNLOCK(lhw); + rcu_read_unlock(); } void diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index c01a6cb0cd7c..8bc2a465f76f 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -217,6 +217,7 @@ struct lkpi_hw { /* name it mac80211_sc? */ struct sx lvif_sx; struct sx sx; /* XXX-BZ Can this be wiphy->mtx in the future? */ + struct list_head lchanctx_list; struct mtx txq_mtx; uint32_t txq_generation[IEEE80211_NUM_ACS]; @@ -284,7 +285,10 @@ struct lkpi_hw { /* name it mac80211_sc? */ #define HW_TO_LHW(_hw) container_of(_hw, struct lkpi_hw, hw) struct lkpi_chanctx { + struct list_head entry; + bool added_to_drv; /* Managed by MO */ + struct ieee80211_chanctx_conf chanctx_conf __aligned(CACHE_LINE_SIZE); }; #define LCHANCTX_TO_CHANCTX_CONF(_lchanctx) \