From nobody Tue Dec 03 05:32:34 2024 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 4Y2TnG6Z40z5fnPH; Tue, 03 Dec 2024 05:32:34 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y2TnG66n3z468P; Tue, 3 Dec 2024 05:32:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733203954; 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=35rAvdL+jMnXufQWILsas7IILAvBMsonK1OR51Wh4xQ=; b=tLpNfzB5CbKNS9/B55ifas+cK9Rh3Wx7GJ8oy+R1ot54icv/0gg6aK/2MLA0TwIeCuMfyH qi1IQ2hK+pthtbFonrLnDqgp7HgbAIQb53Y1aCGLIcOomgrFdPBh4b01ItXtEHlP+bMTzk IvFjfY7nU2HfRO8TqqBeOLRQQXvsvHiPu4ArFF+kBd2v7N+67J9WRn0QwvuknD44OnpYY/ euXK4LEvj1MvJZGpLA7WGvsuftHevkfgFP2RKz02XfOkM6qzSxvFsh3s99rCJhwwNTnaOu TRc+wQ/bXQhly4wG9vUju/xRLmeA++VMWj5WlFTv5LpGcfDyHwSToL/XZTGl2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733203954; 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=35rAvdL+jMnXufQWILsas7IILAvBMsonK1OR51Wh4xQ=; b=ERtE+owLL8uy8ePatkKH0GJaKhZWqztnbQ8/r5eiSlzu3NlrNT2V0P3D0ga+YDq48jqs+Y sUzncdo8o6Vb3pOjbQeQm7KDS57jFNdgjADuAI24StuIBFnnBBqpbpKiYaoRqots83jQP9 Gck6+7gfk88guuXRG6+kadVxlAJsNiN/kSrvi46sz4DMDMbU0roV601VjSAXCd4nIa0qvD xjRCVdXFTqBrqSri6/4HpHb26XPbaEOtOQyJh9eig8apDFTsoAJlRwy+AlXvVSaLx8mmwq tzCVHUuzC76Ci+xOMwpYA+cTkiPFTSRm2R8NAVoHIpsJ3b1eC5qR5I7+p01Svw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733203954; a=rsa-sha256; cv=none; b=ksDvd1/fQwbamAthXBfH/RJ1fEHS86UfHvQY0k1suqWSuXs1HDVujAwuReVQCqxvhbpFwZ 2sb4gEkOCxdK98JOwtRnNisvlDlbtSO2H/d3DQPiHgOZZtsheNpCif/UF7C5VuTy7SKYiV mLUEgc3GH3o+iErQuOHW2YprhiOLoxl08aVABG5/AbQeVbiVhLTHrALn7RrNy2uFdEkwNJ H5zIR7tGJiXFGL934K/ZSfQYKuJ1prky0GS/zMaa3U8y0gRqGJ/ysNBLczKucjiDWoAFV3 0TZXuFGixduStpdTu+xEiGC9KNeqkuU1l/2LWUipFeflePtovkBxtevp6PDZlA== 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 4Y2TnG5k1tz18gF; Tue, 3 Dec 2024 05:32:34 +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 4B35WYRY041954; Tue, 3 Dec 2024 05:32:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B35WYLH041951; Tue, 3 Dec 2024 05:32:34 GMT (envelope-from git) Date: Tue, 3 Dec 2024 05:32:34 GMT Message-Id: <202412030532.4B35WYLH041951@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: c6b44f64c330 - main - net80211: add helper functions for determining HT transmit parameters 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: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c6b44f64c33010501aee2fd99016aeca54a09a1e Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c6b44f64c33010501aee2fd99016aeca54a09a1e commit c6b44f64c33010501aee2fd99016aeca54a09a1e Author: Adrian Chadd AuthorDate: 2024-11-25 23:00:24 +0000 Commit: Adrian Chadd CommitDate: 2024-12-03 05:30:45 +0000 net80211: add helper functions for determining HT transmit parameters This adds helper functions to determine a variety of HT related transmit parameters: * AMPDU density and size; * short-GI for 20 and 40MHz; * Whether 40MHz transmit is allowed; * Whether HT rates have been negotiated for transmit. It should be done here rather than drivers having to re-invent the wheel each time. This is doubly important for AP modes where each node will hvae different supported features and this needs to be used when assembling transmit frames / configuring transmit parameters. Differential Revision: https://reviews.freebsd.org/D47747 Reviewed by: bz --- sys/net80211/ieee80211_ht.c | 140 ++++++++++++++++++++++++++++++++++++++++++++ sys/net80211/ieee80211_ht.h | 6 ++ 2 files changed, 146 insertions(+) diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c index 28c329ce3d32..1f97b7b9927a 100644 --- a/sys/net80211/ieee80211_ht.c +++ b/sys/net80211/ieee80211_ht.c @@ -3604,3 +3604,143 @@ ieee80211_add_htinfo_vendor(uint8_t *frm, struct ieee80211_node *ni) frm[5] = BCM_OUI_HTINFO; return ieee80211_add_htinfo_body(frm + 6, ni); } + +/* + * Get the HT density for the given 802.11n node. + * + * Take into account the density advertised from the peer. + * Larger values are longer A-MPDU density spacing values, and + * we want to obey them per station if we get them. + */ +int +ieee80211_ht_get_node_ampdu_density(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + int peer_mpdudensity; + + vap = ni->ni_vap; + peer_mpdudensity = + _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); + if (vap->iv_ampdu_density > peer_mpdudensity) + peer_mpdudensity = vap->iv_ampdu_density; + return (peer_mpdudensity); +} + +/* + * Get the transmit A-MPDU limit for the given 802.11n node. + * + * Take into account the limit advertised from the peer. + * Smaller values indicate smaller maximum A-MPDU sizes, and + * should be used when forming an A-MPDU to the given peer. + */ +int +ieee80211_ht_get_node_ampdu_limit(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + int peer_mpdulimit; + + vap = ni->ni_vap; + peer_mpdulimit = + _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU); + + return (MIN(vap->iv_ampdu_limit, peer_mpdulimit)); +} + +/* + * Return true if short-GI is available when transmitting to + * the given node at 20MHz. + * + * Ensure it's configured and available in the VAP / driver as + * well as the node. + */ +bool +ieee80211_ht_check_tx_shortgi_20(const struct ieee80211_node *ni) +{ + const struct ieee80211vap *vap; + const struct ieee80211com *ic; + + if (! ieee80211_ht_check_tx_ht(ni)) + return (false); + + vap = ni->ni_vap; + ic = ni->ni_ic; + + return ((ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20) && + (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) && + (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20)); +} + +/* + * Return true if short-GI is available when transmitting to + * the given node at 40MHz. + * + * Ensure it's configured and available in the VAP / driver as + * well as the node and BSS. + */ +bool +ieee80211_ht_check_tx_shortgi_40(const struct ieee80211_node *ni) +{ + const struct ieee80211vap *vap; + const struct ieee80211com *ic; + + if (! ieee80211_ht_check_tx_ht40(ni)) + return (false); + + vap = ni->ni_vap; + ic = ni->ni_ic; + + return ((ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40) && + (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) && + (vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40)); +} + +/* + * Return true if HT rates can be used for the given node. + * + * There are some situations seen in the wild, wild past where + * HT APs would announce HT but no HT rates. + */ +bool +ieee80211_ht_check_tx_ht(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); + + if (IEEE80211_IS_CHAN_HT(ni->ni_chan) && + ni->ni_htrates.rs_nrates == 0) + return (false); + return (IEEE80211_IS_CHAN_HT(ni->ni_chan)); +} + +/* + * Return true if HT40 rates can be transmitted to the given node. + * + * This verifies that the BSS is HT40 capable and the current + * node channel width is 40MHz. + */ +bool +ieee80211_ht_check_tx_ht40(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + struct ieee80211_channel *bss_chan; + + if (! ieee80211_ht_check_tx_ht(ni)) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + return (IEEE80211_IS_CHAN_HT40(bss_chan) && + IEEE80211_IS_CHAN_HT40(ni->ni_chan) && + (ni->ni_chw == 40)); +} diff --git a/sys/net80211/ieee80211_ht.h b/sys/net80211/ieee80211_ht.h index 6ba791065d15..0f4c1025695e 100644 --- a/sys/net80211/ieee80211_ht.h +++ b/sys/net80211/ieee80211_ht.h @@ -240,5 +240,11 @@ int ieee80211_ampdu_tx_request_ext(struct ieee80211_node *ni, int tid); int ieee80211_ampdu_tx_request_active_ext(struct ieee80211_node *ni, int tid, int status); void ieee80211_htinfo_notify(struct ieee80211vap *vap); +int ieee80211_ht_get_node_ampdu_density(const struct ieee80211_node *ni); +int ieee80211_ht_get_node_ampdu_limit(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_shortgi_20(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_shortgi_40(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_ht40(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_ht(const struct ieee80211_node *ht); #endif /* _NET80211_IEEE80211_HT_H_ */