Skip to content

Commit a34bba7

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.the bit error rate should also based on the channel state info.
1 parent 687bcf3 commit a34bba7

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed

vwifi.c

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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",
@@ -1438,55 +1438,78 @@ static int vwifi_get_station(struct wiphy *wiphy,
14381438
* https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
14391439
* IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
14401440
*/
1441-
1442-
1443-
14441441
/* Checks vif->manual_mcs_set to use vif->manual_mcs if set;
1445-
* Assigns modulation string for manual MCS ; else auto change based
1442+
* Assign modulation string for manual MCS ; else auto change based
14461443
* on signal strength
14471444
*/
14481445
int mcs_index;
14491446
const char *modulation;
1447+
const char *coding_rate;
14501448
if (vif->manual_mcs_set) {
14511449
mcs_index = vif->manual_mcs;
14521450
switch (mcs_index) {
1453-
case 7:
1451+
case 24:
14541452
modulation = "BPSK";
1453+
coding_rate = "1/2";
1454+
break;
1455+
case 25:
1456+
modulation = "QPSK";
1457+
coding_rate = "1/2";
14551458
break;
1456-
case 15:
1459+
case 26:
14571460
modulation = "QPSK";
1461+
coding_rate = "3/4";
1462+
break;
1463+
case 27:
1464+
modulation = "16-QAM";
1465+
coding_rate = "1/2";
14581466
break;
1459-
case 23:
1467+
case 28:
14601468
modulation = "16-QAM";
1469+
coding_rate = "3/4";
1470+
break;
1471+
case 29:
1472+
modulation = "64-QAM";
1473+
coding_rate = "2/3";
1474+
break;
1475+
case 30:
1476+
modulation = "64-QAM";
1477+
coding_rate = "3/4";
14611478
break;
14621479
case 31:
14631480
modulation = "64-QAM";
1481+
coding_rate = "5/6";
14641482
break;
14651483
default:
1466-
modulation = "Unknown";
1484+
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
1485+
mcs_index = 24; /* Default to lowest 4-stream MCS */
1486+
modulation = "BPSK";
1487+
coding_rate = "1/2";
14671488
break;
14681489
}
1469-
pr_info("vwifi: Station %pM using manual MCS %d (%s)\n", mac, mcs_index,
1470-
modulation);
1490+
pr_info("vwifi: Station %pM using manual MCS %d (%s, %s)\n", mac,
1491+
mcs_index, modulation, coding_rate);
14711492
} else {
14721493
if (sinfo->signal > -50) {
14731494
mcs_index = 31;
14741495
modulation = "64-QAM";
1496+
coding_rate = "5/6";
14751497
} else if (sinfo->signal > -70 && sinfo->signal <= -50) {
1476-
mcs_index = 23;
1498+
mcs_index = 28;
14771499
modulation = "16-QAM";
1500+
coding_rate = "3/4";
14781501
} else if (sinfo->signal > -90 && sinfo->signal <= -70) {
1479-
mcs_index = 15;
1502+
mcs_index = 25;
14801503
modulation = "QPSK";
1504+
coding_rate = "1/2";
14811505
} else {
1482-
mcs_index = 7;
1506+
mcs_index = 24;
14831507
modulation = "BPSK";
1508+
coding_rate = "1/2";
14841509
}
1485-
pr_info(
1486-
"vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d)\n",
1487-
mac, sinfo->signal, modulation, mcs_index);
1510+
pr_info("vwifi: Station %pM signal %d dBm, using MCS %d (%s, %s)\n",
1511+
mac, sinfo->signal, mcs_index, modulation, coding_rate);
14881512
}
1489-
14901513
/* Configure RX and TX rates */
14911514
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
14921515
sinfo->rxrate.mcs = mcs_index;
@@ -1501,7 +1524,6 @@ static int vwifi_get_station(struct wiphy *wiphy,
15011524
/* Log rate configuration for verification */
15021525
pr_info("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n", mac,
15031526
sinfo->txrate.mcs, sinfo->rxrate.mcs);
1504-
15051527
return 0;
15061528
}
15071529

@@ -2266,8 +2288,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22662288
return -EINVAL;
22672289
}
22682290

2269-
if (mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2270-
mcs_index != 31) {
2291+
/* Restrict to supported 4-stream MCS indices 24–31 */
2292+
if (mcs_index < 24 || mcs_index > 31) {
22712293
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
22722294
return -EINVAL;
22732295
}
@@ -2356,7 +2378,7 @@ static const struct ieee80211_rate vwifi_supported_rates[] = {
23562378
RATE_ENT(120, 0x40), RATE_ENT(180, 0x80), RATE_ENT(240, 0x100),
23572379
RATE_ENT(360, 0x200), RATE_ENT(480, 0x400), RATE_ENT(540, 0x800),
23582380
};
2359-
/* Describes supported band of 2GHz. */
2381+
23602382
static struct ieee80211_supported_band nf_band_2ghz = {
23612383
.band = NL80211_BAND_2GHZ,
23622384
.channels = vwifi_supported_channels_2ghz,

0 commit comments

Comments
 (0)