From nobody Fri Apr 11 21:26:24 2025 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 4ZZ8rJ6yhjz5shpd; Fri, 11 Apr 2025 21:26:24 +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 4ZZ8rJ2CFqz3tnm; Fri, 11 Apr 2025 21:26:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744406784; 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=Ej/SnT3SXLJoqaAm9dG4FUHiXBELRXPldoW9bHUc+ls=; b=ccHhLVpqH9VGIbn+bVB/Xwcby/DWbL2o53ItLDHLW4gHdo1ryA7Y7sJcIC8f2nEnW54nti M+pRTwZRK9tHZvx4fmzrt5av4gIdct9LFUL9/WWmhmSL3JhxzgoWtY5eOEqVhCOcpcW1H3 cSQhI+FDhLZmLv8IcyUKzATUJX0Wgevkxn94MA60W8ukZORyAQlNWGVy/2GSn6PA1zPKu2 wOsC6zP+SwsykMvdRGMamN+6jklmEBrzgT7eEPS71TAdACQtfaIijafwvLfKGa3F1xV4XE cE35ZuA6wTj5CEte3fI6cMKgDhr6MVHqz+i2yCr3TKaNVz+R0Fn+v4luCzV7bw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744406784; a=rsa-sha256; cv=none; b=GnzmWnO1mRwxTA8gx6jlQH4U2BERvaycE05bslJRmiqLB/r8jW7KiGu1P3JHVIwJc66Atn Dm6QzsreswTAwu1jy879LCAiomms2qMau+hC1wVnNMxNk65VKMgXeGGcZOhK+P1w63mz6U X4SQ1f7jRm4nHeFwwiYj+FuxO5JJIdwFErtUJstlLe5UwDF+3n3EaNTsf/mZ/CSxoD7qPj /lSdzlSSEHi+Rv1K3+UHMuSXQ386AG+sOoQiPWC/jgt4SnWB8rj7pEBke86X7zpxGS8WYf +ze5A6BozMX1tRY3lDUOZqvpSyzWrWci+zNZmVmliaEj+gwofX6UJOVVTJxwRQ== 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=1744406784; 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=Ej/SnT3SXLJoqaAm9dG4FUHiXBELRXPldoW9bHUc+ls=; b=GzS1elGGNQOAZrjZt5UvKXhxE6FRiDJOHJt13gbLF0IfjoG9tTfeyWO4w7gKyunta+bMQp 28O7vFItSNYdI+gMyFQ7JGM+/mN5Czc6usxjSukbtXRWLFjYU1OwGl1YslMP0pPn8KGDHA zRiezKlEEFxgO6he3HBsHSryMsKi/T81XFzHi2Spr5aSiLkV+Wak9/khaQjlK9aApcz/tY XwsOGQRVJ/XTOB7Wbp+XXlFzj23NpnnYBYTcLeLiSnbnwxDreK642Gy/UKO1JTVofULj1n dO1F0wCBHgZfvu367GOlLTQzEOsY/Faowddn0Z99b21Er/Cl9/C5OfMsAcauIg== 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 4ZZ8rJ1khvzqHd; Fri, 11 Apr 2025 21:26:24 +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 53BLQOkO078344; Fri, 11 Apr 2025 21:26:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53BLQOX1078341; Fri, 11 Apr 2025 21:26:24 GMT (envelope-from git) Date: Fri, 11 Apr 2025 21:26:24 GMT Message-Id: <202504112126.53BLQOX1078341@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: a8a47a41775b - main - LinuxKPI: 802.11: add a lchanctx list to lhw 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 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/main X-Git-Reftype: branch X-Git-Commit: a8a47a41775b0320606f90b3ac2048bc23494615 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=a8a47a41775b0320606f90b3ac2048bc23494615 commit a8a47a41775b0320606f90b3ac2048bc23494615 Author: Bjoern A. Zeeb AuthorDate: 2025-04-08 23:05:43 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-11 21:26:05 +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 MFC after: 3 days Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734 --- sys/compat/linuxkpi/common/src/linux_80211.c | 39 ++++++++++++++++++---------- sys/compat/linuxkpi/common/src/linux_80211.h | 5 ++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 891714fb75db..65f203c0eec9 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -1757,6 +1757,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); } @@ -1943,6 +1944,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. */ @@ -1957,6 +1959,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; } @@ -5458,6 +5461,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); @@ -5521,6 +5527,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); @@ -5955,8 +5977,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, @@ -5964,22 +5984,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 7028e05e9b20..da377280b1c0 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -216,6 +216,8 @@ struct lkpi_hw { /* name it mac80211_sc? */ TAILQ_HEAD(, lkpi_vif) lvif_head; struct sx lvif_sx; + struct list_head lchanctx_list; + struct mtx txq_mtx; uint32_t txq_generation[IEEE80211_NUM_ACS]; TAILQ_HEAD(, lkpi_txq) scheduled_txqs[IEEE80211_NUM_ACS]; @@ -282,7 +284,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) \