Skip to content

Commit 48d23ac

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 fe2deb6 commit 48d23ac

File tree

2 files changed

+49
-20
lines changed

2 files changed

+49
-20
lines changed

scripts/hostapd.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ interface=vw0
22
driver=nl80211
33
debug=1
44
ctrl_interface=/var/run/hostapd
5-
ctrl_interface_group=root
5+
ctrl_interface_group=0
66
channel=6
77
ssid=test
88
wpa=2

vwifi.c

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
13461346
struct station_info *sinfo)
13471347
{
13481348
struct vwifi_vif *vif = ndev_get_vwifi_vif(dev);
1349+
13491350
bool found_sta = false;
13501351
switch (dev->ieee80211_ptr->iftype) {
13511352
case NL80211_IFTYPE_AP:;
@@ -1438,52 +1439,81 @@ static int vwifi_get_station(struct wiphy *wiphy,
14381439

14391440

14401441

1442+
14411443
/* Checks vif->manual_mcs_set to use vif->manual_mcs if set;
1442-
* Assigns modulation string for manual MCS ; else auto change based
1444+
* Assign modulation string for manual MCS ; else auto change based
14431445
* on signal strength
14441446
*/
14451447
int mcs_index;
14461448
const char *modulation;
1449+
const char *coding_rate;
14471450
if (vif->manual_mcs_set) {
14481451
mcs_index = vif->manual_mcs;
14491452
switch (mcs_index) {
1450-
case 7:
1453+
case 24:
14511454
modulation = "BPSK";
1455+
coding_rate = "1/2";
1456+
break;
1457+
case 25:
1458+
modulation = "QPSK";
1459+
coding_rate = "1/2";
14521460
break;
1453-
case 15:
1461+
case 26:
14541462
modulation = "QPSK";
1463+
coding_rate = "3/4";
14551464
break;
1456-
case 23:
1465+
case 27:
14571466
modulation = "16-QAM";
1467+
coding_rate = "1/2";
1468+
break;
1469+
case 28:
1470+
modulation = "16-QAM";
1471+
coding_rate = "3/4";
1472+
break;
1473+
case 29:
1474+
modulation = "64-QAM";
1475+
coding_rate = "2/3";
1476+
break;
1477+
case 30:
1478+
modulation = "64-QAM";
1479+
coding_rate = "3/4";
14581480
break;
14591481
case 31:
14601482
modulation = "64-QAM";
1483+
coding_rate = "5/6";
14611484
break;
14621485
default:
1463-
modulation = "Unknown";
1486+
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
1487+
mcs_index = 24; /* Default to lowest 4-stream MCS */
1488+
modulation = "BPSK";
1489+
coding_rate = "1/2";
14641490
break;
14651491
}
1466-
pr_info("vwifi: Station %pM using manual MCS %d (%s)\n", mac, mcs_index,
1467-
modulation);
1492+
pr_info("vwifi: Station %pM using manual MCS %d (%s, %s)\n", mac,
1493+
mcs_index, modulation, coding_rate);
14681494
} else {
14691495
if (sinfo->signal > -50) {
14701496
mcs_index = 31;
14711497
modulation = "64-QAM";
1498+
coding_rate = "5/6";
14721499
} else if (sinfo->signal > -70 && sinfo->signal <= -50) {
1473-
mcs_index = 23;
1500+
mcs_index = 28;
14741501
modulation = "16-QAM";
1502+
coding_rate = "3/4";
14751503
} else if (sinfo->signal > -90 && sinfo->signal <= -70) {
1476-
mcs_index = 15;
1504+
mcs_index = 25;
14771505
modulation = "QPSK";
1506+
coding_rate = "1/2";
14781507
} else {
1479-
mcs_index = 7;
1508+
mcs_index = 24;
14801509
modulation = "BPSK";
1510+
coding_rate = "1/2";
14811511
}
1482-
pr_info(
1483-
"vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d)\n",
1484-
mac, sinfo->signal, modulation, mcs_index);
1512+
pr_info("vwifi: Station %pM signal %d dBm, using MCS %d (%s, %s)\n",
1513+
mac, sinfo->signal, mcs_index, modulation, coding_rate);
14851514
}
14861515

1516+
14871517
/* Configure RX and TX rates */
14881518
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
14891519
sinfo->rxrate.mcs = mcs_index;
@@ -2262,8 +2292,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22622292
return -EINVAL;
22632293
}
22642294

2265-
if (mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2266-
mcs_index != 31) {
2295+
/* Restrict to supported 4-stream MCS indices 24–31 */
2296+
if (mcs_index < 24 || mcs_index > 31) {
22672297
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
22682298
return -EINVAL;
22692299
}
@@ -2316,15 +2346,14 @@ static struct cfg80211_ops vwifi_cfg_ops = {
23162346
.center_freq = 5000 + (5 * (channel)), \
23172347
}
23182348

2319-
23202349
/* Macro for defining rate table */
23212350
#define RATE_ENT(_rate, _hw_value) \
23222351
{ \
23232352
.bitrate = (_rate), .hw_value = (_hw_value), \
23242353
}
23252354

23262355
/* Array of "supported" channels in 2GHz band. It is required for wiphy. */
2327-
static struct ieee80211_channel vwifi_supported_channels_2ghz[] = {
2356+
static const struct ieee80211_channel vwifi_supported_channels_2ghz[] = {
23282357
CHAN_2GHZ(1, 2412), CHAN_2GHZ(2, 2417), CHAN_2GHZ(3, 2422),
23292358
CHAN_2GHZ(4, 2427), CHAN_2GHZ(5, 2432), CHAN_2GHZ(6, 2437),
23302359
CHAN_2GHZ(7, 2442), CHAN_2GHZ(8, 2447), CHAN_2GHZ(9, 2452),
@@ -2347,13 +2376,13 @@ static const struct ieee80211_channel vwifi_supported_channels_5ghz[] = {
23472376
/* Array of supported rates, required to support those next rates
23482377
* for 2GHz and 5GHz band.
23492378
*/
2350-
static struct ieee80211_rate vwifi_supported_rates[] = {
2379+
static const struct ieee80211_rate vwifi_supported_rates[] = {
23512380
RATE_ENT(10, 0x1), RATE_ENT(20, 0x2), RATE_ENT(55, 0x4),
23522381
RATE_ENT(110, 0x8), RATE_ENT(60, 0x10), RATE_ENT(90, 0x20),
23532382
RATE_ENT(120, 0x40), RATE_ENT(180, 0x80), RATE_ENT(240, 0x100),
23542383
RATE_ENT(360, 0x200), RATE_ENT(480, 0x400), RATE_ENT(540, 0x800),
23552384
};
2356-
2385+
/* Describes supported band of 2GHz. */
23572386
static struct ieee80211_supported_band nf_band_2ghz = {
23582387
.band = NL80211_BAND_2GHZ,
23592388
.channels = vwifi_supported_channels_2ghz,

0 commit comments

Comments
 (0)