From nobody Sat Apr 18 01:12:41 2026 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 4fyDJ92vjNz6ZTKg for ; Sat, 18 Apr 2026 01:12:41 +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 4fyDJ929srz3nTP for ; Sat, 18 Apr 2026 01:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776474761; 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=m6DyTys/AQLRhjiiapar/RwZTwbj8hyjE7NJxP0t/hgGiLa/yOaGEzwS6lCX+GGOuXHW+f IW9AVQuT3N7BP2OoywVwCe0zlIXMoG6d09OVlGp5dgxp+BWPHsC+9gB2J99ag6Ibj8cDfR VwU5Zr7lYVoedXw02gTVeSmXrucelDeXXs+sTC96XqYp5tnBHa1todU0ygMd9mwlkPIaOm mrVU7zCbLaSEwAS2txFnx3wnPFQb7QrVh/axbvXc89PTNcXzRoimcvHYxLlPCQoa/rSFoH NGcSMDaFhkfdqDvcdpMo/ih0X7H/oswq2ubIhm9zO4et/pb7Qbv+4nrF1Sshhg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776474761; a=rsa-sha256; cv=none; b=nWe5J7b8xCQy+FvSViE8zX4Q2ihDcQUw0Hh6R7V1zpnvtVrDWx3S9h8lP6fJjpT++kfU0g LGgvQFJfbiJ2nCn2uD0tH+kRYTS/hfiVTEhjH1nha2WFA5JoIYnbRuSXAhAm0bp0GNFtEY 97TyHDWK69duuNAh3tKMBimJ6sqYNj+kUP1NmxijVoNRbVhvRoiQJU0JBjXI0+3PwZxwfE yDSyvKFL0Vr3r233AdbOnZjs0qoG4hPyBiu5grHTzKSLQGwM0wHq3cnRl5hP659JeyBx5Z /jGPfVjhEji/EP9uz1iK4/X7GMcnl+AvtmIdyiXvejR7rQPPnPf0b1wpaFGdMA== 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=1776474761; 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=fonyJlX8HicXDaqWFB+p3qRX74ZUFXf6mtnOqW0y0p/Tb6q+oi1z0hS5wMNrlyNotBLrmp ehQvxsZoL2FWeSlKit1Lv1Bg6aKRI22QJooVuJrkoK0+HehYLHPZz/yPyIhoUYmfLm10Vx MIcQ6d8vq8nHG0quMMEaNafTlLzABkv2KI/rreWxHV03wCgT7wgHGVIrBa8zb8JT9qk34L 7rUDS4EkWb7VrPfYRifScHlxZFjQSUgUzKF3rkRurjCx5Cp7T161EAcphVWhA+NVsnM6k0 nBoiFkNlR/k/hp2NJiXmIQG62B8/TbnxRj7yFma5O+R24uDbg4R76Bs8DvLUjQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fyDJ91jYrz28D for ; Sat, 18 Apr 2026 01:12:41 +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 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: 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;