Skip to content

Commit c96febb

Browse files
Expand MCS support manual 24–31 range for 4-stream
Update the vwifi_set_bitrate_mask callback to support the full range of MCS indices 24 through 31, aligning with the 4-spatial-stream configuration in nf_band_2ghz. This change enabling support for manual MCS from 24-31 coding schemes (1/2, 3/4, 2/3, 5/6) and modulations (BPSK, QPSK,16-QAM, 64-QAM) as defined by the IEEE 802.11n specification. The callback now rejects indices outside 24–31, ensuring compliance with 4-stream capabilities and allowing comprehensive rate testing (26–260 Mbps). The auto MCS selection ,due to this function is based on only signal strength, while the MCS should construct with modulation and coding scheme ,which the coding scheme is related with BER (bite error rate),previous vWiFI only implement random signal strength,meaning that bit error rate should also based on the channel state info.
1 parent af67f1d commit c96febb

File tree

1 file changed

+47
-23
lines changed

1 file changed

+47
-23
lines changed

vwifi.c

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ struct vwifi_vif {
8888
struct wireless_dev wdev;
8989
struct net_device *ndev;
9090
struct net_device_stats stats;
91-
int manual_mcs;
92-
bool manual_mcs_set;
91+
int manual_mcs;
92+
bool manual_mcs_set;
9393

9494
size_t ssid_len;
9595
/* Currently connected BSS id */
@@ -1407,7 +1407,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
14071407
sinfo->rx_bytes = vif->stats.rx_bytes;
14081408

14091409

1410-
/* Log byte counters for debugging */
1410+
/* Log byte counters for debugging */
14111411
pr_info(
14121412
"vwifi: Station %pM tx_bytes %llu, rx_bytes %llu, tx_packets %u, "
14131413
"rx_packets %u, tx_failed %u\n",
@@ -1416,8 +1416,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
14161416

14171417
/* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */
14181418
sinfo->signal = rand_int_smooth(-100, -30, jiffies);
1419-
pr_info("vwifi: Station %pM signal %d dBm (raw)\n", mac,
1420-
sinfo->signal);
1419+
pr_info("vwifi: Station %pM signal %d dBm (raw)\n", mac, sinfo->signal);
14211420
sinfo->inactive_time = jiffies_to_msecs(jiffies - vif->active_time);
14221421
/*
14231422
* Using 802.11n (HT) as the PHY, configure as follows:
@@ -1438,52 +1437,78 @@ static int vwifi_get_station(struct wiphy *wiphy,
14381437
* https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
14391438
* IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
14401439
*/
1441-
/* Checks vif->manual_mcs_set to use vif->manual_mcs if set;
1440+
/* Check vif->manual_mcs_set to use vif->manual_mcs if set;
14421441
* Assign modulation string for manual MCS ; else auto change based
14431442
* on signal strength
14441443
*/
14451444
int mcs_index;
14461445
const char *modulation;
1446+
const char *coding_rate;
14471447
if (vif->manual_mcs_set) {
14481448
mcs_index = vif->manual_mcs;
14491449
switch (mcs_index) {
1450-
case 7:
1450+
case 24:
14511451
modulation = "BPSK";
1452+
coding_rate = "1/2";
14521453
break;
1453-
case 15:
1454+
case 25:
14541455
modulation = "QPSK";
1456+
coding_rate = "1/2";
14551457
break;
1456-
case 23:
1458+
case 26:
1459+
modulation = "QPSK";
1460+
coding_rate = "3/4";
1461+
break;
1462+
case 27:
1463+
modulation = "16-QAM";
1464+
coding_rate = "1/2";
1465+
break;
1466+
case 28:
14571467
modulation = "16-QAM";
1468+
coding_rate = "3/4";
1469+
break;
1470+
case 29:
1471+
modulation = "64-QAM";
1472+
coding_rate = "2/3";
1473+
break;
1474+
case 30:
1475+
modulation = "64-QAM";
1476+
coding_rate = "3/4";
14581477
break;
14591478
case 31:
14601479
modulation = "64-QAM";
1480+
coding_rate = "5/6";
14611481
break;
14621482
default:
1463-
modulation = "Unknown";
1483+
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
1484+
mcs_index = 24; /* Default to lowest 4-stream MCS */
1485+
modulation = "BPSK";
1486+
coding_rate = "1/2";
14641487
break;
14651488
}
1466-
pr_info("vwifi: Station %pM using manual MCS %d (%s)\n", mac, mcs_index,
1467-
modulation);
1489+
pr_info("vwifi: Station %pM using manual MCS %d (%s, %s)\n", mac,
1490+
mcs_index, modulation, coding_rate);
14681491
} else {
14691492
if (sinfo->signal > -50) {
14701493
mcs_index = 31;
14711494
modulation = "64-QAM";
1495+
coding_rate = "5/6";
14721496
} else if (sinfo->signal > -70 && sinfo->signal <= -50) {
1473-
mcs_index = 23;
1497+
mcs_index = 28;
14741498
modulation = "16-QAM";
1499+
coding_rate = "3/4";
14751500
} else if (sinfo->signal > -90 && sinfo->signal <= -70) {
1476-
mcs_index = 15;
1501+
mcs_index = 25;
14771502
modulation = "QPSK";
1503+
coding_rate = "1/2";
14781504
} else {
1479-
mcs_index = 7;
1505+
mcs_index = 24;
14801506
modulation = "BPSK";
1507+
coding_rate = "1/2";
14811508
}
1482-
pr_info(
1483-
"vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d)\n",
1484-
mac, sinfo->signal, modulation, mcs_index);
1509+
pr_info("vwifi: Station %pM signal %d dBm, using MCS %d (%s, %s)\n",
1510+
mac, sinfo->signal, mcs_index, modulation, coding_rate);
14851511
}
1486-
14871512
/* Configure RX and TX rates */
14881513
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
14891514
sinfo->rxrate.mcs = mcs_index;
@@ -1498,7 +1523,6 @@ static int vwifi_get_station(struct wiphy *wiphy,
14981523
/* Log rate configuration for verification */
14991524
pr_info("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n", mac,
15001525
sinfo->txrate.mcs, sinfo->rxrate.mcs);
1501-
15021526
return 0;
15031527
}
15041528

@@ -2263,8 +2287,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22632287
return -EINVAL;
22642288
}
22652289

2266-
if (mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2267-
mcs_index != 31) {
2290+
/* Restrict to supported 4-stream MCS indices 24–31 */
2291+
if (mcs_index < 24 || mcs_index > 31) {
22682292
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
22692293
return -EINVAL;
22702294
}
@@ -2353,7 +2377,7 @@ static const struct ieee80211_rate vwifi_supported_rates[] = {
23532377
RATE_ENT(120, 0x40), RATE_ENT(180, 0x80), RATE_ENT(240, 0x100),
23542378
RATE_ENT(360, 0x200), RATE_ENT(480, 0x400), RATE_ENT(540, 0x800),
23552379
};
2356-
/* Describes supported band of 2GHz. */
2380+
23572381
static struct ieee80211_supported_band nf_band_2ghz = {
23582382
.band = NL80211_BAND_2GHZ,
23592383
.channels = vwifi_supported_channels_2ghz,

0 commit comments

Comments
 (0)