From nobody Wed Apr 22 21:08:44 2026 X-Original-To: dev-commits-src-all@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 4g1BfP04zVz6bKyM for ; Wed, 22 Apr 2026 21:08:45 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g1BfN3NN0z3lKp for ; Wed, 22 Apr 2026 21:08:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776892124; 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=RVlev3XRTXNcJJYcdNJOIeXDzwHJZtJzgXHyQvqr6Qk=; b=qZ6X3gWsLq+kjp12Mpb3fjewM4TrepKYzJbMe8HJ0u3hP3TDvMYRz9JzaIVRyH5jP/RKpL LDkRgNB5XYuzzEdTe/7/gYlkSwT4gGQiLtIjiMMKOfjAaHgH7Vbh5Nzc7NQPFEJVd95T8X HyGYaYchDA0TDxut0CRlogeqP/wRzEzw+bHXY7ove9bknTZdDLRj9XRtfSSdJK/AkuT9KH QC5GotAFdiiDN5uuJ9KPp79ja3ib4y0xvX2NDTD1Rspfz/XiWpTKz/IScN8JHsQmpLuR5P IYyms8CtloNHUmkCkYBlpg/Yk5aPMJWpT42HPMqrjPcMr/sjb9u+oweC8WHmag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776892124; a=rsa-sha256; cv=none; b=rb7kZUalBDba6n5FqUP4Adi4H+Wi7Wwl3S3CQEOcOiRDBIdAlsQSpsiY3PR1CbFPqm1Iqd oOxT+qsbce8pa3Yc1Dg9sDSBTXtPY+pxECaxXYVLzLJiEe3Yu8uztLtKVqMd25yMkG/yL+ a3xf6GWYHPywXwBy0EghtnsxYuFhugGG3LwKEXhCInHDstrApMttgp3si7SRwuT0/cCthP McwgXotomTiCux+9zRGAsR80QFgw430849xwMFFMn4rKlJIvnWwQHfdiv5meQLkgMr04X1 ateEa6Sz2JQt13elQkYrzUsC9CRD6JXWaRvB79/YQBneFJ12pY5Pcz2jXUTiUQ== 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=1776892124; 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=RVlev3XRTXNcJJYcdNJOIeXDzwHJZtJzgXHyQvqr6Qk=; b=K0KxeQbphLy7R+k/pZKaOaD8SE4Re8jn7+9ILh45IsJVTe1kO/xFGnjgK+twIwqDtI6z7/ eIB6OlgHwR341SfqzJS59NEnBPQ7XBEDA59jXWXrjLEU71foZjliDmDhyLuZ5Y41WuYysW YNzCWhtyQka9SKyakUNFThl0SY1AK81UgOLsBagBDGk9iOjyRCihDVo4awH4ApkZ+xHQVM 8/rbExDCekE5d+pNRFVI5FOvnkRZahnhB9QwKKVgUYwz/xIGQnRWqreB5zD/RZX2yKo1qu QO2hlA5upmSW6WeQsLeXZ39wSBusRtndYARWlzdnhwn3aVUVpq94G3akUnZSYw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g1BfN2r3XznjV for ; Wed, 22 Apr 2026 21:08:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25efe by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 22 Apr 2026 21:08:44 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Bjoern A. Zeeb Subject: git: 5280ba4fcf55 - stable/15 - LinuxKPI: 802.11: factor out getting and setting a chanctx List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/15 X-Git-Reftype: branch X-Git-Commit: 5280ba4fcf55fe5b9f2a5071a47e991c329551e5 Auto-Submitted: auto-generated Date: Wed, 22 Apr 2026 21:08:44 +0000 Message-Id: <69e938dc.25efe.24c6ffef@gitrepo.freebsd.org> The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=5280ba4fcf55fe5b9f2a5071a47e991c329551e5 commit 5280ba4fcf55fe5b9f2a5071a47e991c329551e5 Author: Bjoern A. Zeeb AuthorDate: 2026-03-23 03:55:14 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-04-22 20:57:04 +0000 LinuxKPI: 802.11: factor out getting and setting a chanctx Further factor out acquiring the chanctx (either set or new), as well as populating a chanctx with information. This further simplifies lkpi_sta_scan_to_auth() and gives us more reusable function blocks. Sponsored by: The FreeBSD Foundation (cherry picked from commit 88cb1e17f471276e831c298c48acf9aca6ae29a6) --- sys/compat/linuxkpi/common/src/linux_80211.c | 148 +++++++++++++++++---------- 1 file changed, 92 insertions(+), 56 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 40a7dfa79fba..d7648f31d70d 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -2319,6 +2319,94 @@ lkpi_find_lchanctx_reserved(struct ieee80211_hw *hw, struct lkpi_vif *lvif) return (lchanctx); } +static struct ieee80211_chanctx_conf * +lkpi_get_chanctx_conf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct ieee80211_chanctx_conf *chanctx_conf; + + chanctx_conf = rcu_dereference_protected(vif->bss_conf.chanctx_conf, + lockdep_is_held(&hw->wiphy->mtx)); + if (chanctx_conf == NULL) { + struct lkpi_chanctx *lchanctx; + struct lkpi_vif *lvif; + + lvif = VIF_TO_LVIF(vif); + lchanctx = lkpi_find_lchanctx_reserved(hw, lvif); + KASSERT(lchanctx != NULL, ("%s: hw %p, vif %p no lchanctx\n", + __func__, hw, vif)); + list_del(&lchanctx->entry); + chanctx_conf = &lchanctx->chanctx_conf; + } + /* else { IMPROVE("diff changes for changed, working on live copy, rcu"); } */ + + return (chanctx_conf); +} + +static int +lkpi_set_chanctx_conf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_chanctx_conf *chanctx_conf, + uint32_t changed, bool changed_set) +{ + struct lkpi_hw *lhw; + struct lkpi_chanctx *lchanctx; + int error; + + if (vif->bss_conf.chanctx_conf == chanctx_conf) { + if (!changed_set) { + IMPROVE("OBSOLETE?"); + changed = IEEE80211_CHANCTX_CHANGE_MIN_WIDTH; + changed |= IEEE80211_CHANCTX_CHANGE_RADAR; + changed |= IEEE80211_CHANCTX_CHANGE_RX_CHAINS; + changed |= IEEE80211_CHANCTX_CHANGE_WIDTH; + } + lkpi_80211_mo_change_chanctx(hw, chanctx_conf, changed); + + return (0); + } + + lhw = HW_TO_LHW(hw); + + /* The device is no longer idle. */ + IMPROVE("Once we do multi-vif, only do for 1st chanctx"); + lkpi_hw_conf_idle(hw, false); + + error = lkpi_80211_mo_add_chanctx(hw, chanctx_conf); + if (error != 0 && error != EOPNOTSUPP) { + ic_printf(lhw->ic, "%s:%d: mo_add_chanctx " + "failed: %d\n", __func__, __LINE__, error); + return (error); + } + + vif->bss_conf.chanreq.oper.chan = chanctx_conf->def.chan; + vif->bss_conf.chanreq.oper.width = chanctx_conf->def.width; + vif->bss_conf.chanreq.oper.center_freq1 = + chanctx_conf->def.center_freq1; + vif->bss_conf.chanreq.oper.center_freq2 = + chanctx_conf->def.center_freq2; + + lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list); + rcu_assign_pointer(vif->bss_conf.chanctx_conf, chanctx_conf); + + /* Assign vif chanctx. */ + if (error == 0) + error = lkpi_80211_mo_assign_vif_chanctx(hw, vif, + &vif->bss_conf, chanctx_conf); + if (error == EOPNOTSUPP) + error = 0; + if (error != 0) { + ic_printf(lhw->ic, "%s:%d: mo_assign_vif_chanctx " + "failed: %d\n", __func__, __LINE__, error); + 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); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); + } + + return (error); +} + static void lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -2419,7 +2507,6 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int { struct linuxkpi_ieee80211_channel *chan; struct cfg80211_chan_def chandef; - struct lkpi_chanctx *lchanctx; struct ieee80211_chanctx_conf *chanctx_conf; struct lkpi_hw *lhw; struct ieee80211_hw *hw; @@ -2488,16 +2575,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int wiphy_lock(hw->wiphy); /* Add chanctx (or if exists, change it). */ - chanctx_conf = rcu_dereference_protected(vif->bss_conf.chanctx_conf, - lockdep_is_held(&hw->wiphy->mtx)); - if (chanctx_conf != NULL) { - lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); - IMPROVE("diff changes for changed, working on live copy, rcu"); - } else { - lchanctx = lkpi_find_lchanctx_reserved(hw, lvif); - list_del(&lchanctx->entry); - chanctx_conf = &lchanctx->chanctx_conf; - } + chanctx_conf = lkpi_get_chanctx_conf(hw, vif); KASSERT(ni->ni_chan != NULL && ni->ni_chan != IEEE80211_CHAN_ANYC, ("%s:%d: ni %p ni_chan %p\n", __func__, __LINE__, ni, ni->ni_chan)); @@ -2534,52 +2612,10 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int bss_changed |= lkpi_update_dtim_tsf(vif, ni, vap, __func__, __LINE__); - error = 0; - if (vif->bss_conf.chanctx_conf == chanctx_conf) { - changed = IEEE80211_CHANCTX_CHANGE_MIN_WIDTH; - changed |= IEEE80211_CHANCTX_CHANGE_RADAR; - changed |= IEEE80211_CHANCTX_CHANGE_RX_CHAINS; - changed |= IEEE80211_CHANCTX_CHANGE_WIDTH; - lkpi_80211_mo_change_chanctx(hw, chanctx_conf, changed); - } else { - /* The device is no longer idle. */ - IMPROVE("Once we do multi-vif, only do for 1st chanctx"); - lkpi_hw_conf_idle(hw, false); - - error = lkpi_80211_mo_add_chanctx(hw, chanctx_conf); - if (error == 0 || error == EOPNOTSUPP) { - vif->bss_conf.chanreq.oper.chan = chanctx_conf->def.chan; - vif->bss_conf.chanreq.oper.width = chanctx_conf->def.width; - vif->bss_conf.chanreq.oper.center_freq1 = - chanctx_conf->def.center_freq1; - vif->bss_conf.chanreq.oper.center_freq2 = - chanctx_conf->def.center_freq2; - } else { - ic_printf(vap->iv_ic, "%s:%d: mo_add_chanctx " - "failed: %d\n", __func__, __LINE__, error); - goto out; - } - - list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list); - rcu_assign_pointer(vif->bss_conf.chanctx_conf, chanctx_conf); + error = lkpi_set_chanctx_conf(hw, vif, chanctx_conf, changed, true); + if (error != 0) + goto out; - /* Assign vif chanctx. */ - if (error == 0) - error = lkpi_80211_mo_assign_vif_chanctx(hw, vif, - &vif->bss_conf, chanctx_conf); - if (error == EOPNOTSUPP) - error = 0; - if (error != 0) { - ic_printf(vap->iv_ic, "%s:%d: mo_assign_vif_chanctx " - "failed: %d\n", __func__, __LINE__, error); - 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); - list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); - goto out; - } - } IMPROVE("update radiotap chan fields too"); /* RATES */