From nobody Sat Apr 18 01:12:41 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 4fyDJG45Hnz6ZT7V for ; Sat, 18 Apr 2026 01:12:46 +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 4fyDJG2mntz3n9H for ; Sat, 18 Apr 2026 01:12:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776474766; 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=Ez1eRYTDlkV89+/2NnWs0Gc5wd/rShdLlL2dOSTY+i4=; b=sGti0Okco3lJQ+Fcea3R/gKZ9P5Dmn2r2D0Qy7VjeeyB1DCs6kxO/Giznn6O+z6YOUOJcV w7TuvaENCRrwVXThFjLyx4PiKF7qUmZwuSA63ehDLSduGKpXaEuMQ06UqzFw824NARIXan 4lMYLdXa1GYzmW6VDGRWg6zlSkDHS++cvYI2x2x0PgiZ/loeM+Dbr06rbBtfsDmSN92Uq8 8UGHQYPNsSIVDvsH00ftamyjhr7s3qkQK4pynBLRyJ+dEqL9xGiU88Y58pAam4VQoPo1wH wLSTyiaHFTUnptDV2BYgFn40iILnF0t2h0eDbaTEdb6Z0F9yurWooJsoYprHsA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776474766; a=rsa-sha256; cv=none; b=Z7XfIprpa1rSYqAs2JFudPf9UMvyp3JZqfP/Y4z+9uCpT+FEfWqKxHsloBDmPcssWxXEum O8GmgYQE9HH7JOzltu/MzQB8jgHoAXJRWms18iL3J0Me3N8ruqgGlSxqhfGtjY96uAPGgo +0/T4LAI3ehfF/gwGIEUP4Ffha1e/TTEsnMMalBgTpWYdUEfds1NU5nCLPzr4hbccb+PVJ M2GPgMgdEq/2i80sWQYq+ex5mtfTq+KqK5UrUevi54y/2NPu+GfyISx7oMjSllmPZ2C6uc vBz2IHMfkROP1iIiJzbhY/q5To4A+VMml3YCVclZAAhNgw/lTKzX1qQ4Ie1cDA== 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=1776474766; 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=Ez1eRYTDlkV89+/2NnWs0Gc5wd/rShdLlL2dOSTY+i4=; b=NRp0hbJ7R64+ut4cK38cIjpALWqsXfoYlJBKLARw+j1G9neHCdDOJ0xELTGkM0KuSSkUe6 LAeEq5ZL2hnfROLehPj725GBEK5nxyX73Tl0o+P6jN4DiOoCXFikiJNPgJR9YFUoRPvVa/ 8WuRrR7dG77gWLja1eU8r9vVdUX39x+8RwqGk3JvSGNqfaf8PtlAbqY0ZUHd5Q/okzSKGC Czg/T6yLXo0hcP4WrbvQ3o+8XLZ3YrmsGJ6VhaK1w06AJzeLRXv0TheNjIW6xNYgDdMFU3 rXgyCrkcgE0jLupaErsKbv8ZBXWXHuQKR7b8M2Yu+MNGxkVESTKhcbxh2MHwhQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fyDJG21f1z3Kk for ; Sat, 18 Apr 2026 01:12:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 456c1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 18 Apr 2026 01:12:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bjoern A. Zeeb Subject: git: 695f0f0d037a - main - LinuxKPI: 802.11: factor out chandef/chanctx initialization 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: 695f0f0d037a876fa27c0cdca9890e09fd75429e Auto-Submitted: auto-generated Date: Sat, 18 Apr 2026 01:12:41 +0000 Message-Id: <69e2da89.456c1.28fc7cc0@gitrepo.freebsd.org> The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=695f0f0d037a876fa27c0cdca9890e09fd75429e commit 695f0f0d037a876fa27c0cdca9890e09fd75429e Author: Bjoern A. Zeeb AuthorDate: 2026-01-03 20:10:24 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-04-18 01:12:07 +0000 LinuxKPI: 802.11: factor out chandef/chanctx initialization Factor out chandef and chanctx initialization from lkpi_sta_scan_to_auth(). This makes the code a lot more readable and prepares for the next steps that will re-use some of this. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 117 ++++++++++++++++++--------- 1 file changed, 78 insertions(+), 39 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 01347586ef63..8bb5bd4201ef 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -766,6 +766,7 @@ lkpi_sta_sync_from_ni(struct ieee80211_hw *hw, struct ieee80211_vif *vif, lkpi_sync_chanctx_cw_from_rx_bw(hw, vif, sta); } +#if 0 static uint8_t lkpi_get_max_rx_chains(struct ieee80211_node *ni) { @@ -792,6 +793,7 @@ lkpi_get_max_rx_chains(struct ieee80211_node *ni) return (chains); } +#endif static void lkpi_lsta_dump(struct lkpi_sta *lsta, struct ieee80211_node *ni, @@ -2214,6 +2216,70 @@ lkpi_80211_flush_tx(struct lkpi_hw *lhw, struct lkpi_sta *lsta) } } +static void +lkpi_init_chandef(struct cfg80211_chan_def *chandef, + struct linuxkpi_ieee80211_channel *chan, struct ieee80211_channel *c, + bool can_ht) +{ + + cfg80211_chandef_create(chandef, chan, + (can_ht) ? NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT); + chandef->center_freq1 = ieee80211_get_channel_center_freq1(c); + chandef->center_freq2 = ieee80211_get_channel_center_freq2(c); + + IMPROVE("Check ht/vht_cap from band not just chan? See lkpi_sta_sync_from_ni..."); +#ifdef LKPI_80211_HT + if (IEEE80211_IS_CHAN_HT(c)) { + if (IEEE80211_IS_CHAN_HT40(c)) + chandef->width = NL80211_CHAN_WIDTH_40; + else + chandef->width = NL80211_CHAN_WIDTH_20; + } +#endif +#ifdef LKPI_80211_VHT + if (IEEE80211_IS_CHAN_VHT_5GHZ(c)) { + if (IEEE80211_IS_CHAN_VHT80P80(c)) + chandef->width = NL80211_CHAN_WIDTH_80P80; + else if (IEEE80211_IS_CHAN_VHT160(c)) + chandef->width = NL80211_CHAN_WIDTH_160; + else if (IEEE80211_IS_CHAN_VHT80(c)) + chandef->width = NL80211_CHAN_WIDTH_80; + } +#endif +} + +static uint32_t +lkpi_init_chanctx_conf(struct ieee80211_hw *hw, + struct cfg80211_chan_def *chandef, + struct ieee80211_chanctx_conf *chanctx_conf) +{ + uint32_t changed; + + lockdep_assert_wiphy(hw->wiphy); + + changed = 0; + + chanctx_conf->rx_chains_static = 1; + chanctx_conf->rx_chains_dynamic = 1; + changed |= IEEE80211_CHANCTX_CHANGE_RX_CHAINS; + + if (chanctx_conf->radar_enabled != hw->conf.radar_enabled) { + chanctx_conf->radar_enabled = hw->conf.radar_enabled; + changed |= IEEE80211_CHANCTX_CHANGE_RADAR; + } + + chanctx_conf->def = *chandef; + changed |= IEEE80211_CHANCTX_CHANGE_WIDTH; + + /* One day we should figure this out; is for iwlwifi-only. */ + chanctx_conf->min_def = chanctx_conf->def; + changed |= IEEE80211_CHANCTX_CHANGE_MIN_WIDTH; + + /* chanctx_conf->ap = */ + + return (changed); +} + static void lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) @@ -2310,6 +2376,7 @@ static int lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) { struct linuxkpi_ieee80211_channel *chan; + struct cfg80211_chan_def chandef; struct lkpi_chanctx *lchanctx; struct ieee80211_chanctx_conf *chanctx_conf; struct lkpi_hw *lhw; @@ -2322,7 +2389,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int struct ieee80211_prep_tx_info prep_tx_info; uint32_t changed; int error; - bool synched; + bool synched, can_ht; /* * In here we use vap->iv_bss until lvif->lvif_bss is set. @@ -2391,50 +2458,22 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int chanctx_conf = &lchanctx->chanctx_conf; } - chanctx_conf->rx_chains_static = 1; - chanctx_conf->rx_chains_dynamic = 1; - chanctx_conf->radar_enabled = - (chan->flags & IEEE80211_CHAN_RADAR) ? true : false; - chanctx_conf->def.chan = chan; - chanctx_conf->def.width = NL80211_CHAN_WIDTH_20_NOHT; - chanctx_conf->def.center_freq1 = ieee80211_get_channel_center_freq1(ni->ni_chan); - chanctx_conf->def.center_freq2 = ieee80211_get_channel_center_freq2(ni->ni_chan); - IMPROVE("Check vht_cap from band not just chan?"); 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)); #ifdef LKPI_80211_HT - if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) { - if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) - chanctx_conf->def.width = NL80211_CHAN_WIDTH_40; - else - chanctx_conf->def.width = NL80211_CHAN_WIDTH_20; - } -#endif -#ifdef LKPI_80211_VHT - if (IEEE80211_IS_CHAN_VHT_5GHZ(ni->ni_chan)) { - if (IEEE80211_IS_CHAN_VHT80P80(ni->ni_chan)) - chanctx_conf->def.width = NL80211_CHAN_WIDTH_80P80; - else if (IEEE80211_IS_CHAN_VHT160(ni->ni_chan)) - chanctx_conf->def.width = NL80211_CHAN_WIDTH_160; - else if (IEEE80211_IS_CHAN_VHT80(ni->ni_chan)) - chanctx_conf->def.width = NL80211_CHAN_WIDTH_80; - } -#endif - chanctx_conf->rx_chains_dynamic = lkpi_get_max_rx_chains(ni); - /* Responder ... */ -#if 0 - chanctx_conf->min_def.chan = chanctx_conf->def.chan; - chanctx_conf->min_def.width = NL80211_CHAN_WIDTH_20_NOHT; -#ifdef LKPI_80211_HT - if (IEEE80211_IS_CHAN_HT(ni->ni_chan) || IEEE80211_IS_CHAN_VHT(ni->ni_chan)) - chanctx_conf->min_def.width = NL80211_CHAN_WIDTH_20; -#endif - chanctx_conf->min_def.center_freq1 = chanctx_conf->def.center_freq1; - chanctx_conf->min_def.center_freq2 = chanctx_conf->def.center_freq2; + can_ht = (vap->iv_ic->ic_flags_ht & IEEE80211_FHT_HT) != 0; #else - chanctx_conf->min_def = chanctx_conf->def; + can_ht = false; #endif + lkpi_init_chandef(&chandef, chan, ni->ni_chan, can_ht); + hw->conf.radar_enabled = + ((chan->flags & IEEE80211_CHAN_RADAR) != 0) ? true : false; + hw->conf.chandef = chandef; + vif->bss_conf.chanreq.oper = hw->conf.chandef; + changed = lkpi_init_chanctx_conf(hw, &chandef, chanctx_conf); + + /* Responder ... */ /* Set bss info (bss_info_changed). */ bss_changed = 0;