Skip to content

Commit 222746f

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 222746f

File tree

2 files changed

+48
-26
lines changed

2 files changed

+48
-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: 47 additions & 25 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:;
@@ -1403,8 +1404,6 @@ static int vwifi_get_station(struct wiphy *wiphy,
14031404
sinfo->tx_failed = vif->stats.tx_dropped;
14041405
sinfo->tx_bytes = vif->stats.tx_bytes;
14051406
sinfo->rx_bytes = vif->stats.rx_bytes;
1406-
1407-
14081407
/* Log byte counters for debugging */
14091408
pr_info(
14101409
"vwifi: Station %pM tx_bytes %llu, rx_bytes %llu, tx_packets %u, "
@@ -1435,55 +1434,78 @@ static int vwifi_get_station(struct wiphy *wiphy,
14351434
* https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
14361435
* IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
14371436
*/
1438-
1439-
1440-
14411437
/* Checks vif->manual_mcs_set to use vif->manual_mcs if set;
1442-
* Assigns modulation string for manual MCS ; else auto change based
1438+
* Assign modulation string for manual MCS ; else auto change based
14431439
* on signal strength
14441440
*/
14451441
int mcs_index;
14461442
const char *modulation;
1443+
const char *coding_rate;
14471444
if (vif->manual_mcs_set) {
14481445
mcs_index = vif->manual_mcs;
14491446
switch (mcs_index) {
1450-
case 7:
1447+
case 24:
14511448
modulation = "BPSK";
1449+
coding_rate = "1/2";
1450+
break;
1451+
case 25:
1452+
modulation = "QPSK";
1453+
coding_rate = "1/2";
14521454
break;
1453-
case 15:
1455+
case 26:
14541456
modulation = "QPSK";
1457+
coding_rate = "3/4";
1458+
break;
1459+
case 27:
1460+
modulation = "16-QAM";
1461+
coding_rate = "1/2";
14551462
break;
1456-
case 23:
1463+
case 28:
14571464
modulation = "16-QAM";
1465+
coding_rate = "3/4";
1466+
break;
1467+
case 29:
1468+
modulation = "64-QAM";
1469+
coding_rate = "2/3";
1470+
break;
1471+
case 30:
1472+
modulation = "64-QAM";
1473+
coding_rate = "3/4";
14581474
break;
14591475
case 31:
14601476
modulation = "64-QAM";
1477+
coding_rate = "5/6";
14611478
break;
14621479
default:
1463-
modulation = "Unknown";
1480+
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
1481+
mcs_index = 24; /* Default to lowest 4-stream MCS */
1482+
modulation = "BPSK";
1483+
coding_rate = "1/2";
14641484
break;
14651485
}
1466-
pr_info("vwifi: Station %pM using manual MCS %d (%s)\n", mac, mcs_index,
1467-
modulation);
1486+
pr_info("vwifi: Station %pM using manual MCS %d (%s, %s)\n", mac,
1487+
mcs_index, modulation, coding_rate);
14681488
} else {
14691489
if (sinfo->signal > -50) {
14701490
mcs_index = 31;
14711491
modulation = "64-QAM";
1492+
coding_rate = "5/6";
14721493
} else if (sinfo->signal > -70 && sinfo->signal <= -50) {
1473-
mcs_index = 23;
1494+
mcs_index = 28;
14741495
modulation = "16-QAM";
1496+
coding_rate = "3/4";
14751497
} else if (sinfo->signal > -90 && sinfo->signal <= -70) {
1476-
mcs_index = 15;
1498+
mcs_index = 25;
14771499
modulation = "QPSK";
1500+
coding_rate = "1/2";
14781501
} else {
1479-
mcs_index = 7;
1502+
mcs_index = 24;
14801503
modulation = "BPSK";
1504+
coding_rate = "1/2";
14811505
}
1482-
pr_info(
1483-
"vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d)\n",
1484-
mac, sinfo->signal, modulation, mcs_index);
1506+
pr_info("vwifi: Station %pM signal %d dBm, using MCS %d (%s, %s)\n",
1507+
mac, sinfo->signal, mcs_index, modulation, coding_rate);
14851508
}
1486-
14871509
/* Configure RX and TX rates */
14881510
sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
14891511
sinfo->rxrate.mcs = mcs_index;
@@ -1498,9 +1520,9 @@ static int vwifi_get_station(struct wiphy *wiphy,
14981520
/* Log rate configuration for verification */
14991521
pr_info("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n", mac,
15001522
sinfo->txrate.mcs, sinfo->rxrate.mcs);
1501-
15021523
return 0;
15031524
}
1525+
15041526
/* dump station callback -- resume dump at index @idx */
15051527
static int vwifi_dump_station(struct wiphy *wiphy,
15061528
struct net_device *dev,
@@ -2262,8 +2284,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
22622284
return -EINVAL;
22632285
}
22642286

2265-
if (mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2266-
mcs_index != 31) {
2287+
/* Restrict to supported 4-stream MCS indices 24–31 */
2288+
if (mcs_index < 24 || mcs_index > 31) {
22672289
pr_err("vwifi: Unsupported MCS index %d\n", mcs_index);
22682290
return -EINVAL;
22692291
}
@@ -2316,15 +2338,14 @@ static struct cfg80211_ops vwifi_cfg_ops = {
23162338
.center_freq = 5000 + (5 * (channel)), \
23172339
}
23182340

2319-
23202341
/* Macro for defining rate table */
23212342
#define RATE_ENT(_rate, _hw_value) \
23222343
{ \
23232344
.bitrate = (_rate), .hw_value = (_hw_value), \
23242345
}
23252346

23262347
/* Array of "supported" channels in 2GHz band. It is required for wiphy. */
2327-
static struct ieee80211_channel vwifi_supported_channels_2ghz[] = {
2348+
static const struct ieee80211_channel vwifi_supported_channels_2ghz[] = {
23282349
CHAN_2GHZ(1, 2412), CHAN_2GHZ(2, 2417), CHAN_2GHZ(3, 2422),
23292350
CHAN_2GHZ(4, 2427), CHAN_2GHZ(5, 2432), CHAN_2GHZ(6, 2437),
23302351
CHAN_2GHZ(7, 2442), CHAN_2GHZ(8, 2447), CHAN_2GHZ(9, 2452),
@@ -2347,13 +2368,14 @@ static const struct ieee80211_channel vwifi_supported_channels_5ghz[] = {
23472368
/* Array of supported rates, required to support those next rates
23482369
* for 2GHz and 5GHz band.
23492370
*/
2350-
static struct ieee80211_rate vwifi_supported_rates[] = {
2371+
static const struct ieee80211_rate vwifi_supported_rates[] = {
23512372
RATE_ENT(10, 0x1), RATE_ENT(20, 0x2), RATE_ENT(55, 0x4),
23522373
RATE_ENT(110, 0x8), RATE_ENT(60, 0x10), RATE_ENT(90, 0x20),
23532374
RATE_ENT(120, 0x40), RATE_ENT(180, 0x80), RATE_ENT(240, 0x100),
23542375
RATE_ENT(360, 0x200), RATE_ENT(480, 0x400), RATE_ENT(540, 0x800),
23552376
};
23562377

2378+
/* Describes supported band of 2GHz. */
23572379
static struct ieee80211_supported_band nf_band_2ghz = {
23582380
.band = NL80211_BAND_2GHZ,
23592381
.channels = vwifi_supported_channels_2ghz,

0 commit comments

Comments
 (0)