Skip to content

Commit 189cc93

Browse files
Expand MCS support to manual full 24–31 range for 4-stream configuration,
and implement partly auto select MCS based on signal strength 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!),which previous vWiFI only implement random signal strength.the bit error rate should also based on the channel state info.
1 parent fe2deb6 commit 189cc93

File tree

2 files changed

+58
-26
lines changed

2 files changed

+58
-26
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: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,46 +1444,74 @@ 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
}
14861513

1514+
14871515
/* Configure RX and TX rates */
14881516
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
14891517
sinfo->rxrate.mcs = mcs_index;
@@ -2215,6 +2243,7 @@ static int vwifi_leave_ibss(struct wiphy *wiphy, struct net_device *ndev)
22152243
return 0;
22162244
}
22172245
/* Callback to handle manual bitrate configuration via iw */
2246+
/* Callback to handle manual bitrate configuration via iw */
22182247
static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22192248
struct net_device *dev,
22202249
unsigned int link_id,
@@ -2262,8 +2291,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22622291
return -EINVAL;
22632292
}
22642293

2265-
if (mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2266-
mcs_index != 31) {
2294+
/* Restrict to supported 4-stream MCS indices 24–31 */
2295+
if (mcs_index < 24 || mcs_index > 31) {
22672296
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
22682297
return -EINVAL;
22692298
}
@@ -2303,24 +2332,27 @@ static struct cfg80211_ops vwifi_cfg_ops = {
23032332
};
23042333

23052334
/* Macro for defining 2GHZ channel array */
2306-
#define CHAN_2GHZ(channel, freq) \
2307-
{ \
2308-
.band = NL80211_BAND_2GHZ, .hw_value = (channel), \
2309-
.center_freq = (freq), \
2335+
#define CHAN_2GHZ(channel, freq) \
2336+
{ \
2337+
.band = NL80211_BAND_2GHZ, \
2338+
.hw_value = (channel), \
2339+
.center_freq = (freq), \
23102340
}
23112341

23122342
/* Macro for defining 5GHZ channel array */
2313-
#define CHAN_5GHZ(channel) \
2314-
{ \
2315-
.band = NL80211_BAND_5GHZ, .hw_value = (channel), \
2316-
.center_freq = 5000 + (5 * (channel)), \
2343+
#define CHAN_5GHZ(channel) \
2344+
{ \
2345+
.band = NL80211_BAND_5GHZ, \
2346+
.hw_value = (channel), \
2347+
.center_freq = 5000 + (5 * (channel)), \
23172348
}
23182349

23192350

23202351
/* Macro for defining rate table */
2321-
#define RATE_ENT(_rate, _hw_value) \
2322-
{ \
2323-
.bitrate = (_rate), .hw_value = (_hw_value), \
2352+
#define RATE_ENT(_rate, _hw_value) \
2353+
{ \
2354+
.bitrate = (_rate), \
2355+
.hw_value = (_hw_value), \
23242356
}
23252357

23262358
/* Array of "supported" channels in 2GHz band. It is required for wiphy. */

0 commit comments

Comments
 (0)