From 58a18179022340c8b0f577067d932f7629741c37 Mon Sep 17 00:00:00 2001 From: horseface Date: Fri, 30 May 2025 09:43:45 +0000 Subject: [PATCH 1/2] Use timer_delete_sync() on Linux >= 6.1.84 Update timer deletion to use the new timer_delete_sync() interface introduced in Linux commit 9b13df3f ("timers: Rename del_timer_sync() to timer_delete_sync()"), which replaces the older del_timer_sync() for naming consistency. The legacy del_timer_sync() interface remains as an inline wrapper but is discouraged for new code. Compatibility is maintained using a version check against KERNEL_VERSION(6, 1, 84). --- vwifi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vwifi.c b/vwifi.c index a4fd676..0ec7bd8 100644 --- a/vwifi.c +++ b/vwifi.c @@ -1974,7 +1974,11 @@ static int vwifi_delete_interface(struct vwifi_vif *vif) cancel_work_sync(&vif->ws_scan); cancel_work_sync(&vif->ws_scan_timeout); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 84) + timer_delete_sync(&vif->scan_complete); +#else del_timer_sync(&vif->scan_complete); +#endif /* If there's a pending scan, call cfg80211_scan_done to finish it. */ if (vif->scan_request) { @@ -1985,7 +1989,11 @@ static int vwifi_delete_interface(struct vwifi_vif *vif) } /* Make sure that no work is queued */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 84) + timer_delete_sync(&vif->scan_timeout); +#else del_timer_sync(&vif->scan_timeout); +#endif cancel_work_sync(&vif->ws_connect); cancel_work_sync(&vif->ws_disconnect); From f49060e4cf1758a81c2202a039a822a3f03d2bb8 Mon Sep 17 00:00:00 2001 From: horseface Date: Sat, 21 Jun 2025 14:41:17 +0000 Subject: [PATCH 2/2] Add HT MCS table and bitrate lookup helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- vwifi.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/vwifi.c b/vwifi.c index 0ec7bd8..7700b1e 100644 --- a/vwifi.c +++ b/vwifi.c @@ -200,6 +200,8 @@ struct vwifi_vif { /* Transmit power */ s32 tx_power; + + struct cfg80211_bitrate_mask bitrate_mask; }; static int station = 2; @@ -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)) @@ -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);