@@ -88,8 +88,8 @@ struct vwifi_vif {
88
88
struct wireless_dev wdev ;
89
89
struct net_device * ndev ;
90
90
struct net_device_stats stats ;
91
- int manual_mcs ;
92
- bool manual_mcs_set ;
91
+ int manual_mcs ;
92
+ bool manual_mcs_set ;
93
93
94
94
size_t ssid_len ;
95
95
/* Currently connected BSS id */
@@ -1407,7 +1407,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
1407
1407
sinfo -> rx_bytes = vif -> stats .rx_bytes ;
1408
1408
1409
1409
1410
- /* Log byte counters for debugging */
1410
+ /* Log byte counters for debugging */
1411
1411
pr_info (
1412
1412
"vwifi: Station %pM tx_bytes %llu, rx_bytes %llu, tx_packets %u, "
1413
1413
"rx_packets %u, tx_failed %u\n" ,
@@ -1416,8 +1416,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
1416
1416
1417
1417
/* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */
1418
1418
sinfo -> signal = rand_int_smooth (-100 , -30 , jiffies );
1419
- pr_info ("vwifi: Station %pM signal %d dBm (raw)\n" , mac ,
1420
- sinfo -> signal );
1419
+ pr_info ("vwifi: Station %pM signal %d dBm (raw)\n" , mac , sinfo -> signal );
1421
1420
sinfo -> inactive_time = jiffies_to_msecs (jiffies - vif -> active_time );
1422
1421
/*
1423
1422
* Using 802.11n (HT) as the PHY, configure as follows:
@@ -1438,52 +1437,78 @@ static int vwifi_get_station(struct wiphy *wiphy,
1438
1437
* https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
1439
1438
* IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
1440
1439
*/
1441
- /* Checks vif->manual_mcs_set to use vif->manual_mcs if set;
1440
+ /* Check vif->manual_mcs_set to use vif->manual_mcs if set;
1442
1441
* Assign modulation string for manual MCS ; else auto change based
1443
1442
* on signal strength
1444
1443
*/
1445
1444
int mcs_index ;
1446
1445
const char * modulation ;
1446
+ const char * coding_rate ;
1447
1447
if (vif -> manual_mcs_set ) {
1448
1448
mcs_index = vif -> manual_mcs ;
1449
1449
switch (mcs_index ) {
1450
- case 7 :
1450
+ case 24 :
1451
1451
modulation = "BPSK" ;
1452
+ coding_rate = "1/2" ;
1452
1453
break ;
1453
- case 15 :
1454
+ case 25 :
1454
1455
modulation = "QPSK" ;
1456
+ coding_rate = "1/2" ;
1455
1457
break ;
1456
- 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 :
1457
1467
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" ;
1458
1477
break ;
1459
1478
case 31 :
1460
1479
modulation = "64-QAM" ;
1480
+ coding_rate = "5/6" ;
1461
1481
break ;
1462
1482
default :
1463
- 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" ;
1464
1487
break ;
1465
1488
}
1466
- pr_info ("vwifi: Station %pM using manual MCS %d (%s)\n" , mac , mcs_index ,
1467
- modulation );
1489
+ pr_info ("vwifi: Station %pM using manual MCS %d (%s, %s )\n" , mac ,
1490
+ mcs_index , modulation , coding_rate );
1468
1491
} else {
1469
1492
if (sinfo -> signal > -50 ) {
1470
1493
mcs_index = 31 ;
1471
1494
modulation = "64-QAM" ;
1495
+ coding_rate = "5/6" ;
1472
1496
} else if (sinfo -> signal > -70 && sinfo -> signal <= -50 ) {
1473
- mcs_index = 23 ;
1497
+ mcs_index = 28 ;
1474
1498
modulation = "16-QAM" ;
1499
+ coding_rate = "3/4" ;
1475
1500
} else if (sinfo -> signal > -90 && sinfo -> signal <= -70 ) {
1476
- mcs_index = 15 ;
1501
+ mcs_index = 25 ;
1477
1502
modulation = "QPSK" ;
1503
+ coding_rate = "1/2" ;
1478
1504
} else {
1479
- mcs_index = 7 ;
1505
+ mcs_index = 24 ;
1480
1506
modulation = "BPSK" ;
1507
+ coding_rate = "1/2" ;
1481
1508
}
1482
- pr_info (
1483
- "vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d)\n" ,
1484
- 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 );
1485
1511
}
1486
-
1487
1512
/* Configure RX and TX rates */
1488
1513
sinfo -> rxrate .flags = RATE_INFO_FLAGS_MCS ;
1489
1514
sinfo -> rxrate .mcs = mcs_index ;
@@ -1498,7 +1523,6 @@ static int vwifi_get_station(struct wiphy *wiphy,
1498
1523
/* Log rate configuration for verification */
1499
1524
pr_info ("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n" , mac ,
1500
1525
sinfo -> txrate .mcs , sinfo -> rxrate .mcs );
1501
-
1502
1526
return 0 ;
1503
1527
}
1504
1528
@@ -2263,8 +2287,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
2263
2287
return - EINVAL ;
2264
2288
}
2265
2289
2266
- if ( mcs_index != 7 && mcs_index != 15 && mcs_index != 23 &&
2267
- mcs_index != 31 ) {
2290
+ /* Restrict to supported 4-stream MCS indices 24–31 */
2291
+ if ( mcs_index < 24 || mcs_index > 31 ) {
2268
2292
pr_err ("vwifi: Unsupported MCS index %d\n" , mcs_index );
2269
2293
return - EINVAL ;
2270
2294
}
@@ -2353,7 +2377,7 @@ static const struct ieee80211_rate vwifi_supported_rates[] = {
2353
2377
RATE_ENT (120 , 0x40 ), RATE_ENT (180 , 0x80 ), RATE_ENT (240 , 0x100 ),
2354
2378
RATE_ENT (360 , 0x200 ), RATE_ENT (480 , 0x400 ), RATE_ENT (540 , 0x800 ),
2355
2379
};
2356
- /* Describes supported band of 2GHz. */
2380
+
2357
2381
static struct ieee80211_supported_band nf_band_2ghz = {
2358
2382
.band = NL80211_BAND_2GHZ ,
2359
2383
.channels = vwifi_supported_channels_2ghz ,
0 commit comments