Skip to content

Commit 3033ca3

Browse files
committed
Add HT MCS table and bitrate lookup helper
Introduce a static table for 802.11n HT MCS indexes 0 to 31, covering 20 MHz bandwidth with both 0.8 µs and 0.4 µs guard intervals. This table defines the modulation and coding scheme parameters used for HT mode. Provide a helper function to compute bitrate in Kbps based on the currently selected MCS index and guard interval from the bitrate mask. This update lays the groundwork for features such as transmission delay simulation and reporting bitrate via station information
1 parent bb2350b commit 3033ca3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

vwifi.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ struct vwifi_vif {
200200

201201
/* Transmit power */
202202
s32 tx_power;
203+
204+
struct cfg80211_bitrate_mask bitrate_mask;
203205
};
204206

205207
static int station = 2;
@@ -214,6 +216,27 @@ static struct vwifi_context *vwifi = NULL;
214216

215217
static struct sock *nl_sk = NULL;
216218

219+
struct ht_mcs_entry {
220+
int mcs_index;
221+
int bitrate_20mhz_gi08; // in kbps
222+
int bitrate_20mhz_gi04; // in kbps
223+
};
224+
225+
static const struct ht_mcs_entry ht_mcs_table[32] = {
226+
{0, 6500, 7200}, {1, 13000, 14400}, {2, 19500, 21700},
227+
{3, 26000, 28900}, {4, 39000, 43300}, {5, 52000, 57800},
228+
{6, 58500, 65000}, {7, 65000, 72200}, {8, 13000, 14400},
229+
{9, 26000, 28900}, {10, 39000, 43300}, {11, 52000, 57800},
230+
{12, 78000, 86700}, {13, 104000, 115600}, {14, 117000, 130000},
231+
{15, 130000, 144400}, {16, 19500, 21700}, {17, 39000, 43300},
232+
{18, 58500, 65000}, {19, 78000, 86700}, {20, 117000, 130000},
233+
{21, 156000, 173300}, {22, 175500, 195000}, {23, 195000, 216700},
234+
{24, 26000, 28900}, {25, 52000, 57800}, {26, 78000, 86700},
235+
{27, 104000, 115600}, {28, 156000, 173300}, {29, 208000, 231100},
236+
{30, 234000, 260000}, {31, 260000, 288900},
237+
};
238+
239+
217240
static int denylist_check(char *dest, char *source)
218241
{
219242
if (!vwifi->denylist || !*(vwifi->denylist))
@@ -702,6 +725,20 @@ static int vwifi_ndo_stop(struct net_device *dev)
702725
return 0;
703726
}
704727

728+
static inline int get_ht_bitrate_kbps(const struct vwifi_vif *vif,
729+
int mcs_index)
730+
{
731+
enum nl80211_txrate_gi gi = vif->bitrate_mask.control[NL80211_BAND_2GHZ].gi;
732+
733+
if (mcs_index < 0 || mcs_index >= 32)
734+
return 0; // fallback for invalid index
735+
736+
if (gi == NL80211_TXRATE_FORCE_SGI)
737+
return ht_mcs_table[mcs_index].bitrate_20mhz_gi04;
738+
else
739+
return ht_mcs_table[mcs_index].bitrate_20mhz_gi08;
740+
}
741+
705742
static struct net_device_stats *vwifi_ndo_get_stats(struct net_device *dev)
706743
{
707744
struct vwifi_vif *vif = ndev_get_vwifi_vif(dev);

0 commit comments

Comments
 (0)