Skip to content

Commit 5799346

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 af67f1d commit 5799346

File tree

1 file changed

+43
-18
lines changed

1 file changed

+43
-18
lines changed

vwifi.c

Lines changed: 43 additions & 18 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",
@@ -1444,46 +1444,72 @@ static int vwifi_get_station(struct wiphy *wiphy,
14441444
*/
14451445
int mcs_index;
14461446
const char *modulation;
1447+
const char *coding_rate;
14471448
if (vif->manual_mcs_set) {
14481449
mcs_index = vif->manual_mcs;
14491450
switch (mcs_index) {
1450-
case 7:
1451+
case 24:
14511452
modulation = "BPSK";
1453+
coding_rate = "1/2";
14521454
break;
1453-
case 15:
1455+
case 25:
14541456
modulation = "QPSK";
1457+
coding_rate = "1/2";
14551458
break;
1456-
case 23:
1459+
case 26:
1460+
modulation = "QPSK";
1461+
coding_rate = "3/4";
1462+
break;
1463+
case 27:
1464+
modulation = "16-QAM";
1465+
coding_rate = "1/2";
1466+
break;
1467+
case 28:
14571468
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";
14581478
break;
14591479
case 31:
14601480
modulation = "64-QAM";
1481+
coding_rate = "5/6";
14611482
break;
14621483
default:
1463-
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";
14641488
break;
14651489
}
1466-
pr_info("vwifi: Station %pM using manual MCS %d (%s)\n", mac, mcs_index,
1467-
modulation);
1490+
pr_info("vwifi: Station %pM using manual MCS %d (%s, %s)\n", mac,
1491+
mcs_index, modulation, coding_rate);
14681492
} else {
14691493
if (sinfo->signal > -50) {
14701494
mcs_index = 31;
14711495
modulation = "64-QAM";
1496+
coding_rate = "5/6";
14721497
} else if (sinfo->signal > -70 && sinfo->signal <= -50) {
1473-
mcs_index = 23;
1498+
mcs_index = 28;
14741499
modulation = "16-QAM";
1500+
coding_rate = "3/4";
14751501
} else if (sinfo->signal > -90 && sinfo->signal <= -70) {
1476-
mcs_index = 15;
1502+
mcs_index = 25;
14771503
modulation = "QPSK";
1504+
coding_rate = "1/2";
14781505
} else {
1479-
mcs_index = 7;
1506+
mcs_index = 24;
14801507
modulation = "BPSK";
1508+
coding_rate = "1/2";
14811509
}
1482-
pr_info(
1483-
"vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d)\n",
1484-
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);
14851512
}
1486-
14871513
/* Configure RX and TX rates */
14881514
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
14891515
sinfo->rxrate.mcs = mcs_index;
@@ -1498,7 +1524,6 @@ static int vwifi_get_station(struct wiphy *wiphy,
14981524
/* Log rate configuration for verification */
14991525
pr_info("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n", mac,
15001526
sinfo->txrate.mcs, sinfo->rxrate.mcs);
1501-
15021527
return 0;
15031528
}
15041529

@@ -2263,8 +2288,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22632288
return -EINVAL;
22642289
}
22652290

2266-
if (mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2267-
mcs_index != 31) {
2291+
/* Restrict to supported 4-stream MCS indices 24–31 */
2292+
if (mcs_index < 24 || mcs_index > 31) {
22682293
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
22692294
return -EINVAL;
22702295
}
@@ -2353,7 +2378,7 @@ static const struct ieee80211_rate vwifi_supported_rates[] = {
23532378
RATE_ENT(120, 0x40), RATE_ENT(180, 0x80), RATE_ENT(240, 0x100),
23542379
RATE_ENT(360, 0x200), RATE_ENT(480, 0x400), RATE_ENT(540, 0x800),
23552380
};
2356-
/* Describes supported band of 2GHz. */
2381+
23572382
static struct ieee80211_supported_band nf_band_2ghz = {
23582383
.band = NL80211_BAND_2GHZ,
23592384
.channels = vwifi_supported_channels_2ghz,

0 commit comments

Comments
 (0)