Skip to content

Add HT MCS table and bitrate lookup helper #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions vwifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ struct vwifi_vif {

/* Transmit power */
s32 tx_power;

struct cfg80211_bitrate_mask bitrate_mask;
};

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

static struct sock *nl_sk = NULL;

struct ht_mcs_entry {
int mcs_index;
int bitrate_20mhz_gi08; // in kbps
int bitrate_20mhz_gi04; // in kbps
};

static const struct ht_mcs_entry ht_mcs_table[32] = {
{0, 6500, 7200}, {1, 13000, 14400}, {2, 19500, 21700},
{3, 26000, 28900}, {4, 39000, 43300}, {5, 52000, 57800},
{6, 58500, 65000}, {7, 65000, 72200}, {8, 13000, 14400},
{9, 26000, 28900}, {10, 39000, 43300}, {11, 52000, 57800},
{12, 78000, 86700}, {13, 104000, 115600}, {14, 117000, 130000},
{15, 130000, 144400}, {16, 19500, 21700}, {17, 39000, 43300},
{18, 58500, 65000}, {19, 78000, 86700}, {20, 117000, 130000},
{21, 156000, 173300}, {22, 175500, 195000}, {23, 195000, 216700},
{24, 26000, 28900}, {25, 52000, 57800}, {26, 78000, 86700},
{27, 104000, 115600}, {28, 156000, 173300}, {29, 208000, 231100},
{30, 234000, 260000}, {31, 260000, 288900},
};


static int denylist_check(char *dest, char *source)
{
if (!vwifi->denylist || !*(vwifi->denylist))
Expand Down Expand Up @@ -702,6 +725,20 @@ static int vwifi_ndo_stop(struct net_device *dev)
return 0;
}

static inline int get_ht_bitrate_kbps(const struct vwifi_vif *vif,
int mcs_index)
{
enum nl80211_txrate_gi gi = vif->bitrate_mask.control[NL80211_BAND_2GHZ].gi;

if (mcs_index < 0 || mcs_index >= 32)
return 0; // fallback for invalid index

if (gi == NL80211_TXRATE_FORCE_SGI)
return ht_mcs_table[mcs_index].bitrate_20mhz_gi04;
else
return ht_mcs_table[mcs_index].bitrate_20mhz_gi08;
}

static struct net_device_stats *vwifi_ndo_get_stats(struct net_device *dev)
{
struct vwifi_vif *vif = ndev_get_vwifi_vif(dev);
Expand Down