From f0441f9daadc6285252d3865017a445206a2961b Mon Sep 17 00:00:00 2001 From: elian Date: Thu, 30 May 2024 23:30:05 +0800 Subject: [PATCH 1/4] Support data rate and MCS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using 802.11n (HT) as the PHY, configure as follows: Modulation: 64-QAM Data Bandwidth: 20MHz Number of Spatial Streams: 4 According to the 802.11n (HT) modulation table, we have: Number of Data Subcarriers: 52 Number of Coded Bits per Subcarrier per Stream: 6 Coding: 5/6 OFDM Symbol Duration: 3.2 µs Guard Interval Duration: 0.8 µs Using these parameters and the formula, the calculated data rate is 260 Mbps, which matches the displayed result. --- vwifi.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/vwifi.c b/vwifi.c index 4dba8e9..0526b8b 100644 --- a/vwifi.c +++ b/vwifi.c @@ -1219,7 +1219,9 @@ static int vwifi_get_station(struct wiphy *wiphy, BIT_ULL(NL80211_STA_INFO_TX_BYTES) | BIT_ULL(NL80211_STA_INFO_RX_BYTES) | BIT_ULL(NL80211_STA_INFO_SIGNAL) | - BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME); + BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME)| + BIT_ULL(NL80211_STA_INFO_RX_BITRATE)| + BIT_ULL(NL80211_STA_INFO_TX_BITRATE); if (vif->sme_state == SME_CONNECTED) { sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CONNECTED_TIME); @@ -1245,8 +1247,31 @@ static int vwifi_get_station(struct wiphy *wiphy, /* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */ sinfo->signal = rand_int_smooth(-100, -30, jiffies); sinfo->inactive_time = jiffies_to_msecs(jiffies - vif->active_time); - /* TODO: Emulate rate and mcs */ - + /* + * Using 802.11n (HT) as the PHY, configure as follows: + * + * Modulation: 64-QAM + * Data Bandwidth: 20MHz + * Number of Spatial Streams: 4 + * + * According to the 802.11n (HT) modulation table, we have: + * + * Number of Data Subcarriers: 52 + * Number of Coded Bits per Subcarrier per Stream: 6 + * Coding: 6 + * OFDM Symbol Duration: 3.2 µs + * Guard Interval Duration: 0.8 µs + * Thus, the data rate is 260 Mbps. + */ + sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS; + sinfo->rxrate.mcs = 31; + sinfo->rxrate.bw = RATE_INFO_BW_20; + sinfo->rxrate.n_bonded_ch = 1; + + sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; + sinfo->txrate.mcs = 31; + sinfo->txrate.bw = RATE_INFO_BW_20; + sinfo->txrate.n_bonded_ch = 1; return 0; } From 4bdc6b29f004a4a39f371928d1d0c98df06dfa3d Mon Sep 17 00:00:00 2001 From: elian Date: Thu, 30 May 2024 23:43:57 +0800 Subject: [PATCH 2/4] Fix typo --- vwifi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vwifi.c b/vwifi.c index 0526b8b..54dd0e5 100644 --- a/vwifi.c +++ b/vwifi.c @@ -1258,7 +1258,7 @@ static int vwifi_get_station(struct wiphy *wiphy, * * Number of Data Subcarriers: 52 * Number of Coded Bits per Subcarrier per Stream: 6 - * Coding: 6 + * Coding: 5/6 * OFDM Symbol Duration: 3.2 µs * Guard Interval Duration: 0.8 µs * Thus, the data rate is 260 Mbps. From 8ede81393c06e8137a6506afc7c53b5a48c1e4e9 Mon Sep 17 00:00:00 2001 From: elian Date: Thu, 30 May 2024 23:46:19 +0800 Subject: [PATCH 3/4] Adjust coding style --- vwifi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vwifi.c b/vwifi.c index 54dd0e5..138324c 100644 --- a/vwifi.c +++ b/vwifi.c @@ -1219,8 +1219,8 @@ static int vwifi_get_station(struct wiphy *wiphy, BIT_ULL(NL80211_STA_INFO_TX_BYTES) | BIT_ULL(NL80211_STA_INFO_RX_BYTES) | BIT_ULL(NL80211_STA_INFO_SIGNAL) | - BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME)| - BIT_ULL(NL80211_STA_INFO_RX_BITRATE)| + BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) | + BIT_ULL(NL80211_STA_INFO_RX_BITRATE) | BIT_ULL(NL80211_STA_INFO_TX_BITRATE); if (vif->sme_state == SME_CONNECTED) { @@ -1247,20 +1247,20 @@ static int vwifi_get_station(struct wiphy *wiphy, /* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */ sinfo->signal = rand_int_smooth(-100, -30, jiffies); sinfo->inactive_time = jiffies_to_msecs(jiffies - vif->active_time); - /* + /* * Using 802.11n (HT) as the PHY, configure as follows: * * Modulation: 64-QAM * Data Bandwidth: 20MHz * Number of Spatial Streams: 4 - * + * * According to the 802.11n (HT) modulation table, we have: * * Number of Data Subcarriers: 52 * Number of Coded Bits per Subcarrier per Stream: 6 * Coding: 5/6 * OFDM Symbol Duration: 3.2 µs - * Guard Interval Duration: 0.8 µs + * Guard Interval Duration: 0.8 µs * Thus, the data rate is 260 Mbps. */ sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS; From dde36068e4cba9100a0269a5cac6aa344f76bb92 Mon Sep 17 00:00:00 2001 From: elian Date: Fri, 31 May 2024 10:42:19 +0800 Subject: [PATCH 4/4] Modify comment Add MCS table and data rate formula references. --- vwifi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vwifi.c b/vwifi.c index 138324c..afdfb2b 100644 --- a/vwifi.c +++ b/vwifi.c @@ -1262,6 +1262,9 @@ static int vwifi_get_station(struct wiphy *wiphy, * OFDM Symbol Duration: 3.2 µs * Guard Interval Duration: 0.8 µs * Thus, the data rate is 260 Mbps. + * MCS table, Data Rate Formula : + * https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/ + * IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n */ sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS; sinfo->rxrate.mcs = 31;