@@ -1403,8 +1403,18 @@ static int vwifi_get_station(struct wiphy *wiphy,
1403
1403
sinfo -> tx_failed = vif -> stats .tx_dropped ;
1404
1404
sinfo -> tx_bytes = vif -> stats .tx_bytes ;
1405
1405
sinfo -> rx_bytes = vif -> stats .rx_bytes ;
1406
+
1407
+ /* Log byte counters for debugging */
1408
+ pr_info (
1409
+ "vwifi: Station %pM tx_bytes %llu, rx_bytes %llu, tx_packets %u, "
1410
+ "rx_packets %u, tx_failed %u\n" ,
1411
+ mac , sinfo -> tx_bytes , sinfo -> rx_bytes , sinfo -> tx_packets ,
1412
+ sinfo -> rx_packets , sinfo -> tx_failed );
1413
+
1406
1414
/* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */
1407
1415
sinfo -> signal = rand_int_smooth (-100 , -30 , jiffies );
1416
+ pr_info ("vwifi: Station %pM signal %d dBm (raw)\n" , mac ,
1417
+ sinfo -> signal );
1408
1418
sinfo -> inactive_time = jiffies_to_msecs (jiffies - vif -> active_time );
1409
1419
/*
1410
1420
* Using 802.11n (HT) as the PHY, configure as follows:
@@ -1425,15 +1435,53 @@ static int vwifi_get_station(struct wiphy *wiphy,
1425
1435
* https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
1426
1436
* IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
1427
1437
*/
1428
- sinfo -> rxrate .flags |= RATE_INFO_FLAGS_MCS ;
1429
- sinfo -> rxrate .mcs = 31 ;
1438
+ /* Log byte counters for debugging */
1439
+ pr_info ("vwifi: Station %pM tx_bytes %llu, rx_bytes %llu\n" , mac ,
1440
+ sinfo -> tx_bytes , sinfo -> rx_bytes );
1441
+
1442
+ /* Dynamic modulation based on signal strength */
1443
+ int mcs_index ;
1444
+ const char * modulation ;
1445
+ unsigned int data_rate_mbps ;
1446
+ if (sinfo -> signal > -50 ) {
1447
+ /* Strong signal: 64-QAM, MCS 31 */
1448
+ mcs_index = 31 ;
1449
+ modulation = "64-QAM" ;
1450
+ } else if (sinfo -> signal > -70 && sinfo -> signal <= -50 ) {
1451
+ /* Medium signal: 16-QAM, MCS 23 */
1452
+ mcs_index = 23 ;
1453
+ modulation = "16-QAM" ;
1454
+ } else if (sinfo -> signal > -90 && sinfo -> signal <= -70 ) {
1455
+ /* Weak signal: QPSK, MCS 15 */
1456
+ mcs_index = 15 ;
1457
+ modulation = "QPSK" ;
1458
+ } else {
1459
+ /* Very weak signal: BPSK, MCS 7 */
1460
+ mcs_index = 7 ;
1461
+ modulation = "BPSK" ;
1462
+ }
1463
+
1464
+ /* Log signal, modulation, and data rate for debugging */
1465
+ pr_info (
1466
+ "vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d, %u "
1467
+ "Mbps)\n" ,
1468
+ mac , sinfo -> signal , modulation , mcs_index , data_rate_mbps );
1469
+
1470
+ /* Configure RX and TX rates */
1471
+ sinfo -> rxrate .flags = RATE_INFO_FLAGS_MCS ;
1472
+ sinfo -> rxrate .mcs = mcs_index ;
1430
1473
sinfo -> rxrate .bw = RATE_INFO_BW_20 ;
1431
1474
sinfo -> rxrate .n_bonded_ch = 1 ;
1432
1475
1433
- sinfo -> txrate .flags | = RATE_INFO_FLAGS_MCS ;
1434
- sinfo -> txrate .mcs = 31 ;
1476
+ sinfo -> txrate .flags = RATE_INFO_FLAGS_MCS ;
1477
+ sinfo -> txrate .mcs = mcs_index ;
1435
1478
sinfo -> txrate .bw = RATE_INFO_BW_20 ;
1436
1479
sinfo -> txrate .n_bonded_ch = 1 ;
1480
+
1481
+ /* Log rate configuration for verification */
1482
+ pr_info ("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n" , mac ,
1483
+ sinfo -> txrate .mcs , sinfo -> rxrate .mcs );
1484
+
1437
1485
return 0 ;
1438
1486
}
1439
1487
0 commit comments