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