Skip to content

Commit d48edde

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 2a63cb3 commit d48edde

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

vwifi.c

Lines changed: 46 additions & 22 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 */
@@ -1406,7 +1406,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
14061406
sinfo->tx_bytes = vif->stats.tx_bytes;
14071407
sinfo->rx_bytes = vif->stats.rx_bytes;
14081408

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

14161416
/* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */
14171417
sinfo->signal = rand_int_smooth(-100, -30, jiffies);
1418-
pr_info("vwifi: Station %pM signal %d dBm (raw)\n", mac,
1419-
sinfo->signal);
1418+
pr_info("vwifi: Station %pM signal %d dBm (raw)\n", mac, sinfo->signal);
14201419
sinfo->inactive_time = jiffies_to_msecs(jiffies - vif->active_time);
14211420
/*
14221421
* Using 802.11n (HT) as the PHY, configure as follows:
@@ -1437,52 +1436,79 @@ static int vwifi_get_station(struct wiphy *wiphy,
14371436
* https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
14381437
* IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
14391438
*/
1439+
14401440
/* Check vif->manual_mcs_set to use vif->manual_mcs if set;
14411441
* Assign modulation string for manual MCS ; else auto change based
14421442
* on signal strength
14431443
*/
14441444
int mcs_index;
14451445
const char *modulation;
1446+
const char *coding_rate;
14461447
if (vif->manual_mcs_set) {
14471448
mcs_index = vif->manual_mcs;
14481449
switch (mcs_index) {
1449-
case 7:
1450+
case 24:
14501451
modulation = "BPSK";
1452+
coding_rate = "1/2";
14511453
break;
1452-
case 15:
1454+
case 25:
14531455
modulation = "QPSK";
1456+
coding_rate = "1/2";
14541457
break;
1455-
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:
14561467
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";
14571477
break;
14581478
case 31:
14591479
modulation = "64-QAM";
1480+
coding_rate = "5/6";
14601481
break;
14611482
default:
1462-
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";
14631487
break;
14641488
}
1465-
pr_info("vwifi: Station %pM using manual MCS %d (%s)\n", mac, mcs_index,
1466-
modulation);
1489+
pr_info("vwifi: Station %pM using manual MCS %d (%s, %s)\n", mac,
1490+
mcs_index, modulation, coding_rate);
14671491
} else {
14681492
if (sinfo->signal > -50) {
14691493
mcs_index = 31;
14701494
modulation = "64-QAM";
1495+
coding_rate = "5/6";
14711496
} else if (sinfo->signal > -70 && sinfo->signal <= -50) {
1472-
mcs_index = 23;
1497+
mcs_index = 28;
14731498
modulation = "16-QAM";
1499+
coding_rate = "3/4";
14741500
} else if (sinfo->signal > -90 && sinfo->signal <= -70) {
1475-
mcs_index = 15;
1501+
mcs_index = 25;
14761502
modulation = "QPSK";
1503+
coding_rate = "1/2";
14771504
} else {
1478-
mcs_index = 7;
1505+
mcs_index = 24;
14791506
modulation = "BPSK";
1507+
coding_rate = "1/2";
14801508
}
1481-
pr_info(
1482-
"vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d)\n",
1483-
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);
14841511
}
1485-
14861512
/* Configure RX and TX rates */
14871513
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
14881514
sinfo->rxrate.mcs = mcs_index;
@@ -1497,7 +1523,6 @@ static int vwifi_get_station(struct wiphy *wiphy,
14971523
/* Log rate configuration for verification */
14981524
pr_info("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n", mac,
14991525
sinfo->txrate.mcs, sinfo->rxrate.mcs);
1500-
15011526
return 0;
15021527
}
15031528

@@ -2262,8 +2287,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22622287
return -EINVAL;
22632288
}
22642289

2265-
if (mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2266-
mcs_index != 31) {
2290+
/* Restrict to supported 4-stream MCS indices 24–31 */
2291+
if (mcs_index < 24 || mcs_index > 31) {
22672292
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
22682293
return -EINVAL;
22692294
}
@@ -2353,7 +2378,6 @@ static const struct ieee80211_rate vwifi_supported_rates[] = {
23532378
RATE_ENT(360, 0x200), RATE_ENT(480, 0x400), RATE_ENT(540, 0x800),
23542379
};
23552380

2356-
/* Describes supported band of 2GHz. */
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)