From nobody Sat Apr 18 01:12:43 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 4fyDJC5bSbz6ZTST for ; Sat, 18 Apr 2026 01:12:43 +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 4fyDJC3lG6z3nPq for ; Sat, 18 Apr 2026 01:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776474763; 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=c6/Rf0mPpXvTW2/9yfUpfOxMIglHHs9R3byMMnoBqhw=; b=WJvRgtgNuZwNM5k/ctErcYU21ITbw78w/JwHWR2TuFF81Od0Apklr5NUP0CfIqqlklkCbo Hh/Yf72HYJWKxxvcLgmTaJwjF0ztVHT/NJX7OUkDmhVWFNnWLy6kaTeIe6ml3h8qHRJQCv CXVBwXUW3mme31Hhbwv2aG6abQEhY2Bt7vY+LpBNUqSi4SDeQYuso55FA/9tO9pK7+xZvu ahevNIlRexW8MvyUKD5z0npqQ0ocle930u3vhLIz96JfBn+znmWRYVRZgVAxD3zanlnhd6 2OYNpO5oBt0UzzqR3YMJRIlUYtgmYzRWpJQrJLqVuYLkj0MzK5gyTWOItTKG+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776474763; a=rsa-sha256; cv=none; b=YdpKocKG0XjigrmlEehCBaChQ0z93LjpuFTaJlLIPF1vSmOZY4GI0faBtRJJ4GGx/Tghne Ifzh+J6M+15S917X68Mb+dSniLw5N+1hVRYdpi7GXhq4k2nmB5fynZ1C4RK3CQBljA4bEZ 91aUSPvoXGj/WAdb96lQOOlF75lcAy/5I5h5Od6VHCHy979gzNv4vZdvAW3/q+Udwjl04J ViM4T0qV/ih4UJ4h59ImZsTqIepv6QEQRru16CwDDoDIV+3kKA4bJOlRM2JUdNnNoDq8Mn 59cp2NdUt2/ZIRDhWYeRGOKpwf64uaWuLe8CFAD2lNmMxMXTzhqYX6z6s2Kw0w== 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=1776474763; 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=c6/Rf0mPpXvTW2/9yfUpfOxMIglHHs9R3byMMnoBqhw=; b=Rq0zaeoR2uAW4yZ6u8M/ewN35yvsJKxHHDcxMkHQVjgUdW9YRwz8UvJDSn/gthFSoirK44 9JDcUHEYcJw7G5rUbId4Ct2MKdfRmTUuNMKPQ+oopVAm5Lox240BY9Xu9362i1QVMgdIby pELhx65ipZCpDqGH8YmO7na+Q8vSLEe7n4xj6AVZiM+BEfMR1YimF86DqPEehCZxnvwu72 +Z2TGCxOVjWQs/MxlCaYAsPGcN/qMT3RkIMtUZr+mEF79qDUzGfZ1M8AqBTGs/k5aIgUdN huctVzh3LJCXVvsOtVLED6m3jxmygfdq29Op/ynnDSAfNsNshaSBb44Yre1ADg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fyDJC3Lkmz32Q for ; Sat, 18 Apr 2026 01:12:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 472f4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 18 Apr 2026 01:12:43 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bjoern A. Zeeb Subject: git: e62c92c0a5cf - main - LinuxKPI: 802.11: keep chanctx on a reserved list 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/main X-Git-Reftype: branch X-Git-Commit: e62c92c0a5cfc000cf3c200e43738834ccc6472e Auto-Submitted: auto-generated Date: Sat, 18 Apr 2026 01:12:43 +0000 Message-Id: <69e2da8b.472f4.60af80d0@gitrepo.freebsd.org> The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e62c92c0a5cfc000cf3c200e43738834ccc6472e commit e62c92c0a5cfc000cf3c200e43738834ccc6472e Author: Bjoern A. Zeeb AuthorDate: 2026-03-23 00:47:57 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-04-18 01:12:08 +0000 LinuxKPI: 802.11: keep chanctx on a reserved list Keep the chanctx around as we may swap them. In the future (11be) these lists likely need to be (a) limited to maximum number of chanctx possible (see struct ieee80211_iface_limit), and (b) with that also by radio. For the moment keep this simple and start with a single chanctx and build up from there when we get there. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 69 ++++++++++++++++++++++++++-- sys/compat/linuxkpi/common/src/linux_80211.h | 2 + 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 92eccefca078..40a7dfa79fba 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -2280,13 +2280,54 @@ lkpi_init_chanctx_conf(struct ieee80211_hw *hw, return (changed); } +static struct lkpi_chanctx * +lkpi_alloc_lchanctx(struct ieee80211_hw *hw, struct lkpi_vif *lvif) +{ + struct lkpi_chanctx *lchanctx; + + lchanctx = malloc(sizeof(*lchanctx) + hw->chanctx_data_size, + M_LKPI80211, M_WAITOK | M_ZERO); + lchanctx->lvif = lvif; + + return (lchanctx); +} + +static struct lkpi_chanctx * +lkpi_find_lchanctx_reserved(struct ieee80211_hw *hw, struct lkpi_vif *lvif) +{ + struct lkpi_hw *lhw; + struct lkpi_chanctx *lchanctx; + bool found; + + lhw = HW_TO_LHW(hw); + + found = false; + rcu_read_lock(); + list_for_each_entry_rcu(lchanctx, &lhw->lchanctx_list_reserved, entry) { + if (lchanctx->lvif == lvif) { + found = true; + break; + } + } + rcu_read_unlock(); + + if (!found) { + lchanctx = lkpi_alloc_lchanctx(hw, lvif); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); + } + + return (lchanctx); +} static void lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { + struct lkpi_hw *lhw; struct ieee80211_chanctx_conf *chanctx_conf; struct lkpi_chanctx *lchanctx; + lockdep_assert_wiphy(hw->wiphy); + chanctx_conf = rcu_dereference_protected(vif->bss_conf.chanctx_conf, lockdep_is_held(&hw->wiphy->mtx)); @@ -2305,7 +2346,8 @@ lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) rcu_assign_pointer(vif->bss_conf.chanctx_conf, NULL); lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); list_del(&lchanctx->entry); - free(lchanctx, M_LKPI80211); + lhw = HW_TO_LHW(hw); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); } /* -------------------------------------------------------------------------- */ @@ -2452,9 +2494,8 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); IMPROVE("diff changes for changed, working on live copy, rcu"); } else { - /* Keep separate alloc as in Linux this is rcu managed? */ - lchanctx = malloc(sizeof(*lchanctx) + hw->chanctx_data_size, - M_LKPI80211, M_WAITOK | M_ZERO); + lchanctx = lkpi_find_lchanctx_reserved(hw, lvif); + list_del(&lchanctx->entry); chanctx_conf = &lchanctx->chanctx_conf; } @@ -2535,7 +2576,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int rcu_assign_pointer(vif->bss_conf.chanctx_conf, NULL); lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); list_del(&lchanctx->entry); - free(lchanctx, M_LKPI80211); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); goto out; } } @@ -3954,6 +3995,10 @@ lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], /* Need to fill in other fields as well. */ IMPROVE(); + /* Create a chanctx to be used later. */ + IMPROVE("lkpi_alloc_lchanctx reserved as many as can be"); + (void) lkpi_find_lchanctx_reserved(hw, lvif); + /* XXX-BZ hardcoded for now! */ #if 1 RCU_INIT_POINTER(vif->bss_conf.chanctx_conf, NULL); @@ -6444,6 +6489,7 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) /* Chanctx_conf */ INIT_LIST_HEAD(&lhw->lchanctx_list); + INIT_LIST_HEAD(&lhw->lchanctx_list_reserved); /* Deferred RX path. */ LKPI_80211_LHW_RXQ_LOCK_INIT(lhw); @@ -6518,6 +6564,7 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) __func__, lhw, mbufq_len(&lhw->rxq))); LKPI_80211_LHW_RXQ_LOCK_DESTROY(lhw); + wiphy_lock(hw->wiphy); /* Chanctx_conf. */ if (!list_empty_careful(&lhw->lchanctx_list)) { struct lkpi_chanctx *lchanctx, *next; @@ -6530,9 +6577,21 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); } list_del(&lchanctx->entry); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); + } + } + if (!list_empty_careful(&lhw->lchanctx_list_reserved)) { + struct lkpi_chanctx *lchanctx, *next; + + list_for_each_entry_safe(lchanctx, next, &lhw->lchanctx_list_reserved, entry) { + list_del(&lchanctx->entry); + if (lchanctx->added_to_drv) + panic("%s: lchanctx %p on reserved list still added_to_drv\n", + __func__, lchanctx); free(lchanctx, M_LKPI80211); } } + wiphy_unlock(hw->wiphy); LKPI_80211_LHW_MC_LOCK(lhw); lkpi_cleanup_mcast_list_locked(lhw); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index a2945498e8df..e453cefa20f7 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -250,6 +250,7 @@ struct lkpi_hw { /* name it mac80211_sc? */ struct sx lvif_sx; struct list_head lchanctx_list; + struct list_head lchanctx_list_reserved; struct netdev_hw_addr_list mc_list; unsigned int mc_flags; struct sx mc_sx; @@ -330,6 +331,7 @@ struct lkpi_chanctx { struct list_head entry; bool added_to_drv; /* Managed by MO */ + struct lkpi_vif *lvif; /* Backpointer. */ struct ieee80211_chanctx_conf chanctx_conf __aligned(CACHE_LINE_SIZE); };