From nobody Wed Feb 26 19:31:42 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 4Z34NH4RyJz5nl4b; Wed, 26 Feb 2025 19:31: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z34NG6TjWz3dLR; Wed, 26 Feb 2025 19:31:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740598302; 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=1WQZEy+Cw2D4wUmf5EMx4im6lOTn8tWDC0SSTbmXOM4=; b=iuMDvwvHMVMXyFfvWmzvcQ0WyscpFOMzvStPV2ubbuDTtowbHicOUy+HLX9jvO/xTyaS1U GNhhce4tqbxEryrdXRcL5o93sDDFgjD0WDztHK6WW/t8rW4ZB0B5k67qTOZJECGYftQYrb 5wG+kHRvtKXCnGLUtBJg6gvGiwi999jwAx4qD/9KoZbbEv2LsUFyiKnGjN0A1+D6gY71mj GUCh8KobKDWNe9tFGPfQjQCXfkWW/MIFEVjJBouUXYQJ8j7GL25+UZN+h1PTEMVI3AReKc DcIyjKJ7Kt563WmVg7LGhE3t/JSdgbtkIaoVfV5skRe2c+iuLk0TscmkXGk0ZA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740598302; a=rsa-sha256; cv=none; b=YGSNeK2+swBmgF1cLah0uosf1zkynZ4JIRL7GhypAKn530CS0KNn8jmLvOyzRROCbcIU/v 16x2SaL1lVhUOQjJTuv6ydVYd3cYMjEujo6dwO1Hq1/InuFj1AlCM8Sp/rYrSW3PhBkvns e8W6CPAZ323xnKHg+zT7dikgJn1u0gEmK7W6iHwF9E7GPtldn2AJ7lKiipBrnZdt5x5Qh+ R0Xq27m3gC9Ckl74ncX5l5kYGpCuVNRqfZvWBoRyoAk+IsICrrVoQC9NN7Xfkq6ZeJgY3o fw+uXnqy7CKk0P+vunEg1AhbA0zw8NRNkSCRyo6bpRpfh9GdQn7tcz7Bwk6kSw== 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=1740598302; 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=1WQZEy+Cw2D4wUmf5EMx4im6lOTn8tWDC0SSTbmXOM4=; b=Hy16R00bGc8tKXcH7VV/AOStlRCUhGYfuOVJjQ/QFNSUoB/054VGhkgsYIlyOIwirBj5K3 yOGumCQFvExw2ajV7sv5lYk3czeX2rQyymkakNJGieOs4Fr8bKSNgGhLr4cnzIZh//tTP3 OofjQkPnpPQ4s23dccscp9JVMT8YH54VxV5wyxOBeOe55oYxv22vR50Ww3JvaoMB7aVVfh OESpCAHfnipmsKY0XOE7f2AceKqatJ99EqdQFQb8v/cRO3xJm+cf85o6fWmvEvACm8oo7O fYGyySXYOgiEc7buoBySyFuNuY7BRqZSM/63g6gfSBTy+Iyx2uZ9UMTD1Ob4gw== 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 4Z34NG5qspz1NX8; Wed, 26 Feb 2025 19:31:42 +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 51QJVgGv017725; Wed, 26 Feb 2025 19:31:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51QJVgTT017722; Wed, 26 Feb 2025 19:31:42 GMT (envelope-from git) Date: Wed, 26 Feb 2025 19:31:42 GMT Message-Id: <202502261931.51QJVgTT017722@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: 1568caaf5721 - main - net80211: add valid VHT MCS combinations and helper functions 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: 1568caaf572125b883aa6d0ed7f87b87ab0c9d45 Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=1568caaf572125b883aa6d0ed7f87b87ab0c9d45 commit 1568caaf572125b883aa6d0ed7f87b87ab0c9d45 Author: Adrian Chadd AuthorDate: 2025-01-13 05:47:37 +0000 Commit: Adrian Chadd CommitDate: 2025-02-26 19:30:51 +0000 net80211: add valid VHT MCS combinations and helper functions Not all NSS / MCS / channel bandwidth combinations are valid. This will be important for rate control and transmit rate setup (eg static management, unicast, multicast rates.) This is based on 802.11-2020 Section 21.5 (Parameters for VHT-MCSs.) Differential Revision: https://reviews.freebsd.org/D48608 Reviewed by: bz --- sys/net80211/ieee80211_phy.c | 86 ++++++++++++++++++++++++++++++++++++++++++++ sys/net80211/ieee80211_phy.h | 7 ++++ 2 files changed, 93 insertions(+) diff --git a/sys/net80211/ieee80211_phy.c b/sys/net80211/ieee80211_phy.c index eaad7dde0653..9c2b1197564a 100644 --- a/sys/net80211/ieee80211_phy.c +++ b/sys/net80211/ieee80211_phy.c @@ -621,3 +621,89 @@ ieee80211_compute_duration_ht(uint32_t frameLen, uint16_t rate, #undef HT_L_LTF #undef HT_L_STF #undef OFDM_PLCP_BITS + + +/* + * A bitmask of allowable rates for each spatial stream + * and bandwidth. + * + * This is based on 802.11-2020 21.5 (Parameters for VHT-MCSs.) + * + * Not all MCS rate / channel widths are valid, as there needs + * to be an integer number of symbols and the number of tones + * available for each channel bandwidth doesn't result in + * an integer value. + */ +static uint16_t ieee80211_vht_mcs_allowed_list_20[] = { + 0x01ff, 0x01ff, 0x03ff, 0x01ff, 0x01ff, 0x03ff, 0x01ff, 0x01ff, +}; + +static uint16_t ieee80211_vht_mcs_allowed_list_40[] = { + 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, +}; + +static uint16_t ieee80211_vht_mcs_allowed_list_80[] = { + 0x03ff, 0x03ff, 0x03bf, 0x03ff, 0x03ff, 0x01ff, 0x03bf, 0x03ff, +}; + +static uint16_t ieee80211_vht_mcs_allowed_list_160[] = { + 0x03ff, 0x03ff, 0x01ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x03ff, +}; + +/** + * @brief Fetch the allowable MCS mask for the given channel bandwidth and NSS + * + * Return a bitmask of valid MCS rates from 0..9 given a channel bandwith + * and number of spatial streams. + * + * See 802.11-2020 21.5 (Parameters for VHT-MCSs) for more details. + * + * @param bw channel bandwidth, via enum ieee80211_sta_rx_bw + * @param nss number of spatial streams, 1..8 + * @returns bitmask of valid MCS rates from 0..9 + */ +uint16_t +ieee80211_phy_vht_get_mcs_mask(enum ieee80211_sta_rx_bw bw, uint8_t nss) +{ + if (nss == 0 || nss > 8) + return (0); + + switch (bw) { + case IEEE80211_STA_RX_BW_20: + return (ieee80211_vht_mcs_allowed_list_20[nss - 1]); + case IEEE80211_STA_RX_BW_40: + return (ieee80211_vht_mcs_allowed_list_40[nss - 1]); + case IEEE80211_STA_RX_BW_80: + return (ieee80211_vht_mcs_allowed_list_80[nss - 1]); + case IEEE80211_STA_RX_BW_160: + return (ieee80211_vht_mcs_allowed_list_160[nss - 1]); + case IEEE80211_STA_RX_BW_320: + /* invalid for VHT */ + return (0); + } +} + +/** + * @brief Check if the given NSS/MCS combination is valid for the given channel + * bandwidth + * + * See 802.11-2020 21.5 (Parameters for VHT-MCSs) for more details. + * + * @param bw channel bandwidth, via enum ieee80211_sta_rx_bw + * @param nss number of spatial streams, 1..8 + * @param mcs MCS rate, 0..9 + * @retval true if the NSS / MCS / bandwidth combination is valid + * @retval false if the NSS / MCS / bandwidth combination is not valid + */ +bool +ieee80211_phy_vht_validate_mcs(enum ieee80211_sta_rx_bw bw, uint8_t nss, + uint8_t mcs) +{ + uint16_t mask; + + mask = ieee80211_phy_vht_get_mcs_mask(bw, nss); + if (mask == 0) + return (false); + + return ((mask & (1 << mcs)) != 0); +} diff --git a/sys/net80211/ieee80211_phy.h b/sys/net80211/ieee80211_phy.h index f73abaff85d0..466f59584f2c 100644 --- a/sys/net80211/ieee80211_phy.h +++ b/sys/net80211/ieee80211_phy.h @@ -221,5 +221,12 @@ uint32_t ieee80211_compute_duration_ht(uint32_t frameLen, uint16_t rate, int streams, int isht40, int isShortGI); +enum ieee80211_sta_rx_bw; + +uint16_t ieee80211_phy_vht_get_mcs_mask(enum ieee80211_sta_rx_bw, + uint8_t); +bool ieee80211_phy_vht_validate_mcs(enum ieee80211_sta_rx_bw, + uint8_t, uint8_t); + #endif /* _KERNEL */ #endif /* !_NET80211_IEEE80211_PHY_H_ */