Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144217535
D48612.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48612.id.diff
View Options
diff --git a/sys/net80211/ieee80211_phy.h b/sys/net80211/ieee80211_phy.h
--- a/sys/net80211/ieee80211_phy.h
+++ b/sys/net80211/ieee80211_phy.h
@@ -227,6 +227,8 @@
uint8_t);
bool ieee80211_phy_vht_validate_mcs(enum ieee80211_sta_rx_bw,
uint8_t, uint8_t);
+uint32_t ieee80211_phy_vht_get_mcs_kbit(enum ieee80211_sta_rx_bw,
+ uint8_t, uint8_t, bool);
#endif /* _KERNEL */
#endif /* !_NET80211_IEEE80211_PHY_H_ */
diff --git a/sys/net80211/ieee80211_phy.c b/sys/net80211/ieee80211_phy.c
--- a/sys/net80211/ieee80211_phy.c
+++ b/sys/net80211/ieee80211_phy.c
@@ -707,3 +707,88 @@
return ((mask & (1 << mcs)) != 0);
}
+
+struct mcs_entry {
+ int n_sym; /* Number of bits per symbol */
+ int cod_n; /* Coding rate numerator */
+ int cod_d; /* Coding rate denominator */
+};
+
+/*
+ * These parameters are taken from 802.11-2020 Table 21-29
+ * (VHT-MCSs for Mandatory 20 MHZ, Nss=1).
+ *
+ * n_sym corresponds to "Nbpscs", cod_n/cod_d corresponds to
+ * "R".
+ */
+static struct mcs_entry mcs_entries[] = {
+ { 1, 1, 2 }, /* MCS0 */
+ { 2, 1, 2 },
+ { 2, 3, 4 },
+ { 4, 1, 2 },
+ { 4, 3, 4 },
+ { 6, 2, 3 },
+ { 6, 3, 4 },
+ { 6, 5, 6 },
+ { 8, 3, 4 },
+ { 8, 5, 6 }, /* MCS9 */
+};
+
+/**
+ * @brief Calculate the bitrate of the given VHT MCS rate.
+ *
+ * @param bw Channel bandwidth (enum ieee80211_sta_rx_bw)
+ * @param nss Number of spatial streams, 1..8
+ * @param mcs MCS, 0..9
+ * @param is_shortgi True if short guard-interval (400nS)
+ * false otherwise (800nS)
+ *
+ * @returns The bitrate in kbit/sec.
+ */
+uint32_t
+ieee80211_phy_vht_get_mcs_kbit(enum ieee80211_sta_rx_bw bw,
+ uint8_t nss, uint8_t mcs, bool is_shortgi)
+{
+ uint32_t sym_len, n_carriers;
+
+ /* Validate MCS 0..9, NSS 1..8 */
+ if (mcs > 9)
+ return (0);
+ if (nss == 0 || nss > 8)
+ return (0);
+
+ /*
+ * Short-GI - 3.6uS symbol time, long-GI - 4.0uS symbol time
+ *
+ * See 802.11-2020 Table 21-5 (Timing-related constraints.)
+ */
+ if (is_shortgi)
+ sym_len = 36;
+ else
+ sym_len = 40;
+
+ /*
+ * Calculate the number of carriers for the given channel bandwidth
+ *
+ * See 802.11-2020 Table 21-5 (Timing-related constraints.)
+ */
+ switch (bw) {
+ case IEEE80211_STA_RX_BW_20:
+ n_carriers = 52;
+ break;
+ case IEEE80211_STA_RX_BW_40:
+ n_carriers = 108;
+ break;
+ case IEEE80211_STA_RX_BW_80:
+ n_carriers = 234;
+ break;
+ case IEEE80211_STA_RX_BW_160:
+ n_carriers = 468;
+ break;
+ default:
+ return (0);
+ }
+
+ return ((n_carriers * mcs_entries[mcs].n_sym * mcs_entries[mcs].cod_n *
+ nss * 10000) / (mcs_entries[mcs].cod_d * sym_len));
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 7, 3:40 PM (5 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28457134
Default Alt Text
D48612.id.diff (2 KB)
Attached To
Mode
D48612: net80211: add ieee80211_phy_vht_get_mcs_kbit()
Attached
Detach File
Event Timeline
Log In to Comment