From nobody Thu Jan 09 00:59:11 2025 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 4YT5yl30Qgz5kLy1; Thu, 09 Jan 2025 00:59:11 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YT5yl26Htz4ygT; Thu, 9 Jan 2025 00:59:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736384351; 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=OBbGIdZv+PUZh5rQhrEyXJRNBmjbCPhCEHkRKZWw1LE=; b=r0NoJoODaJ4nid+ypKQ/tF4bjvLfRhhKr5Q4mUdBkHcrUyNdIZIhwfy5eunTGltcJu60p8 ds2UxAItVOpO0hP8GKcE71ImXD3zgsMvSh8kLSSSnVbVP0WFOJEA4AbmurdiXtiefnNzml OhzuJOeRTAPn+l5Xo5GO8PZJ7LxqlJphIhtyk2CI6B7p0LO7grZRd7IX3Fo1uQA1jhw7br v3zdkYcQ9tDkDMZNFzZVxMRJmlcSpB8RWQtBz6yftmpH15T5fT4TqjHl6UxLu3aoPCgE1D vzUXhbAA/BDTxEwP0MC106WeKOHmaxKWuqyEgekDo+xd1aCPZNANCiHQGqvHOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736384351; 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=OBbGIdZv+PUZh5rQhrEyXJRNBmjbCPhCEHkRKZWw1LE=; b=SS0Uyv3f2Ml9dnM87h4fcmIpgFgv65dzPJ07OwBYDf02VmXIPNIdINMvyusx3ypjc7e3UX tbDlJJ/do53oO4QhpNRr5tWgAFdioAv6WMCbKuMKKNLb7J1DjtvIk/RM8KbamDtb292Tf+ ouYWsRgAd1LketF47CnJIH1zYDllqXxiS+KN7FGonwPdOnQRugHEiYitIsIW6Q7k67X81v cfjFSnSnT0buvFGBHrmYnst99WUBfQfQvWiIKhxviqpGDqlyij4jLV8JhuvRapsL4szCJk 9iSkpfK15MZMwJXgl/txqactmmlE1XGitExe5/devlWIEUkvOHpu4JQCekYGfA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736384351; a=rsa-sha256; cv=none; b=FiYotTw8G4mBLjE9sRU2upeuSczlvoVBIuAOh90IETpfupJRlbfm+/CrRhRAXsCwmcm++B z/rI8RWJbtzRm8GsOaEFWLON6RJTfX2WgQcL/ozviATjuV13CVwUC5naStE1Mtc3DhhX7g WbaJsr01g9DLV5Rmk3SaRe8LgE2732VH+XPfd6O1FtcBDO9RRqmhRv0KJRuAokqaacEWOW 92EG2MfsIr7i+B5TgHGMrfGeXNUBX7Xm7jeAVNzHuCs8XgjNfrq3W2osSchQ9dx4yPkFIe mJetmOnUItD0ebQZwBgfBJw+E95g2klktW4mJQMphTlo/flrkRf1U+WRZ0pi0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YT5yl1k2gz1JHt; Thu, 09 Jan 2025 00:59:11 +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 5090xB2I075397; Thu, 9 Jan 2025 00:59:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5090xBuW075394; Thu, 9 Jan 2025 00:59:11 GMT (envelope-from git) Date: Thu, 9 Jan 2025 00:59:11 GMT Message-Id: <202501090059.5090xBuW075394@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 912a05670ed9 - main - net80211: add helper functions for VHT transmit 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: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 912a05670ed9545a1d1b010eedafb819e14eb1b8 Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=912a05670ed9545a1d1b010eedafb819e14eb1b8 commit 912a05670ed9545a1d1b010eedafb819e14eb1b8 Author: Adrian Chadd AuthorDate: 2024-12-16 02:29:33 +0000 Commit: Adrian Chadd CommitDate: 2025-01-09 00:51:51 +0000 net80211: add helper functions for VHT transmit * Add static helper functions for VHT TX for 20MHz, 40MHz and 80MHz. * Add a public function to check if the given VHT width is available for transmit. Differential Revision: https://reviews.freebsd.org/D48101 --- sys/net80211/ieee80211_vht.c | 137 +++++++++++++++++++++++++++++++++++++++++++ sys/net80211/ieee80211_vht.h | 4 ++ 2 files changed, 141 insertions(+) diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c index a05beb91216f..82879f90c67b 100644 --- a/sys/net80211/ieee80211_vht.c +++ b/sys/net80211/ieee80211_vht.c @@ -873,3 +873,140 @@ ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, { printf("%s: called; TODO!\n", __func__); } + +/* + * Return true if VHT rates can be used for the given node. + */ +bool +ieee80211_vht_check_tx_vht(const struct ieee80211_node *ni) +{ + const struct ieee80211vap *vap; + const struct ieee80211_channel *bss_chan; + + if (ni == NULL || ni->ni_chan == IEEE80211_CHAN_ANYC || + ni->ni_vap == NULL || ni->ni_vap->iv_bss == NULL) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + if (bss_chan == IEEE80211_CHAN_ANYC) + return (false); + + return (IEEE80211_IS_CHAN_VHT(ni->ni_chan)); +} + +/* + * Return true if VHT40 rates can be transmitted to the given node. + * + * This verifies that the BSS is VHT40 capable and the current + * node channel width is 40MHz. + */ +static bool +ieee80211_vht_check_tx_vht40(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + struct ieee80211_channel *bss_chan; + + if (!ieee80211_vht_check_tx_vht(ni)) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + return (IEEE80211_IS_CHAN_VHT40(bss_chan) && + IEEE80211_IS_CHAN_VHT40(ni->ni_chan) && + (ni->ni_chw == IEEE80211_STA_RX_BW_40)); +} + +/* + * Return true if VHT80 rates can be transmitted to the given node. + * + * This verifies that the BSS is VHT80 capable and the current + * node channel width is 80MHz. + */ +static bool +ieee80211_vht_check_tx_vht80(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + struct ieee80211_channel *bss_chan; + + if (!ieee80211_vht_check_tx_vht(ni)) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + return (IEEE80211_IS_CHAN_VHT80(bss_chan) && + IEEE80211_IS_CHAN_VHT80(ni->ni_chan) && + (ni->ni_chw == IEEE80211_STA_RX_BW_80)); +} + +/* + * Return true if VHT 160 rates can be transmitted to the given node. + * + * This verifies that the BSS is VHT80+80 or VHT160 capable and the current + * node channel width is 80+80MHz or 160MHz. + */ +static bool +ieee80211_vht_check_tx_vht160(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + struct ieee80211_channel *bss_chan; + + if (!ieee80211_vht_check_tx_vht(ni)) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + if (ni->ni_chw != IEEE80211_STA_RX_BW_160) + return (false); + + if (IEEE80211_IS_CHAN_VHT160(bss_chan) && + IEEE80211_IS_CHAN_VHT160(ni->ni_chan)) + return (true); + + if (IEEE80211_IS_CHAN_VHT80P80(bss_chan) && + IEEE80211_IS_CHAN_VHT80P80(ni->ni_chan)) + return (true); + + return (false); +} + +/** + * @brief Check if the given transmit bandwidth is available to the given node + * + * This checks that the node and BSS both allow the given bandwidth, + * and that the current node bandwidth (which can dynamically change) + * also allows said bandwidth. + * + * This relies on the channels having the flags for the narrower + * channels as well - eg a VHT160 channel will have the CHAN_VHT80, + * CHAN_VHT40, CHAN_VHT flags also set. + * + * @param ni the ieee80211_node to check + * @param bw the required bandwidth to check + * + * @returns true if it is allowed, false otherwise + */ +bool +ieee80211_vht_check_tx_bw(const struct ieee80211_node *ni, + enum ieee80211_sta_rx_bw bw) +{ + + switch (bw) { + case IEEE80211_STA_RX_BW_20: + return (ieee80211_vht_check_tx_vht(ni)); + case IEEE80211_STA_RX_BW_40: + return (ieee80211_vht_check_tx_vht40(ni)); + case IEEE80211_STA_RX_BW_80: + return (ieee80211_vht_check_tx_vht80(ni)); + case IEEE80211_STA_RX_BW_160: + return (ieee80211_vht_check_tx_vht160(ni)); + case IEEE80211_STA_RX_BW_320: + return (false); + default: + return (false); + } +} diff --git a/sys/net80211/ieee80211_vht.h b/sys/net80211/ieee80211_vht.h index f2d1706ea0f2..bcb61020c5a1 100644 --- a/sys/net80211/ieee80211_vht.h +++ b/sys/net80211/ieee80211_vht.h @@ -65,4 +65,8 @@ void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, struct ieee80211_vht_operation *, int); +bool ieee80211_vht_check_tx_vht(const struct ieee80211_node *); +bool ieee80211_vht_check_tx_bw(const struct ieee80211_node *, + enum ieee80211_sta_rx_bw); + #endif /* _NET80211_IEEE80211_VHT_H_ */