@@ -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 */
@@ -1406,7 +1406,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
1406
1406
sinfo -> tx_bytes = vif -> stats .tx_bytes ;
1407
1407
sinfo -> rx_bytes = vif -> stats .rx_bytes ;
1408
1408
1409
- /* Log byte counters for debugging */
1409
+ /* Log byte counters for debugging */
1410
1410
pr_info (
1411
1411
"vwifi: Station %pM tx_bytes %llu, rx_bytes %llu, tx_packets %u, "
1412
1412
"rx_packets %u, tx_failed %u\n" ,
@@ -1415,8 +1415,7 @@ static int vwifi_get_station(struct wiphy *wiphy,
1415
1415
1416
1416
/* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */
1417
1417
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 );
1420
1419
sinfo -> inactive_time = jiffies_to_msecs (jiffies - vif -> active_time );
1421
1420
/*
1422
1421
* Using 802.11n (HT) as the PHY, configure as follows:
@@ -1437,52 +1436,79 @@ static int vwifi_get_station(struct wiphy *wiphy,
1437
1436
* https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
1438
1437
* IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
1439
1438
*/
1439
+
1440
1440
/* Check vif->manual_mcs_set to use vif->manual_mcs if set;
1441
1441
* Assign modulation string for manual MCS ; else auto change based
1442
1442
* on signal strength
1443
1443
*/
1444
1444
int mcs_index ;
1445
1445
const char * modulation ;
1446
+ const char * coding_rate ;
1446
1447
if (vif -> manual_mcs_set ) {
1447
1448
mcs_index = vif -> manual_mcs ;
1448
1449
switch (mcs_index ) {
1449
- case 7 :
1450
+ case 24 :
1450
1451
modulation = "BPSK" ;
1452
+ coding_rate = "1/2" ;
1451
1453
break ;
1452
- case 15 :
1454
+ case 25 :
1453
1455
modulation = "QPSK" ;
1456
+ coding_rate = "1/2" ;
1454
1457
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 :
1456
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" ;
1457
1477
break ;
1458
1478
case 31 :
1459
1479
modulation = "64-QAM" ;
1480
+ coding_rate = "5/6" ;
1460
1481
break ;
1461
1482
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" ;
1463
1487
break ;
1464
1488
}
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 );
1467
1491
} else {
1468
1492
if (sinfo -> signal > -50 ) {
1469
1493
mcs_index = 31 ;
1470
1494
modulation = "64-QAM" ;
1495
+ coding_rate = "5/6" ;
1471
1496
} else if (sinfo -> signal > -70 && sinfo -> signal <= -50 ) {
1472
- mcs_index = 23 ;
1497
+ mcs_index = 28 ;
1473
1498
modulation = "16-QAM" ;
1499
+ coding_rate = "3/4" ;
1474
1500
} else if (sinfo -> signal > -90 && sinfo -> signal <= -70 ) {
1475
- mcs_index = 15 ;
1501
+ mcs_index = 25 ;
1476
1502
modulation = "QPSK" ;
1503
+ coding_rate = "1/2" ;
1477
1504
} else {
1478
- mcs_index = 7 ;
1505
+ mcs_index = 24 ;
1479
1506
modulation = "BPSK" ;
1507
+ coding_rate = "1/2" ;
1480
1508
}
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 );
1484
1511
}
1485
-
1486
1512
/* Configure RX and TX rates */
1487
1513
sinfo -> rxrate .flags = RATE_INFO_FLAGS_MCS ;
1488
1514
sinfo -> rxrate .mcs = mcs_index ;
@@ -1497,7 +1523,6 @@ static int vwifi_get_station(struct wiphy *wiphy,
1497
1523
/* Log rate configuration for verification */
1498
1524
pr_info ("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n" , mac ,
1499
1525
sinfo -> txrate .mcs , sinfo -> rxrate .mcs );
1500
-
1501
1526
return 0 ;
1502
1527
}
1503
1528
@@ -2262,8 +2287,8 @@ static int vwifi_set_bitrate_mask(struct wiphy *wiphy,
2262
2287
return - EINVAL ;
2263
2288
}
2264
2289
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 ) {
2267
2292
pr_err ("vwifi: Unsupported MCS index %d\n" , mcs_index );
2268
2293
return - EINVAL ;
2269
2294
}
@@ -2353,7 +2378,6 @@ static const struct ieee80211_rate vwifi_supported_rates[] = {
2353
2378
RATE_ENT (360 , 0x200 ), RATE_ENT (480 , 0x400 ), RATE_ENT (540 , 0x800 ),
2354
2379
};
2355
2380
2356
- /* Describes supported band of 2GHz. */
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