@@ -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 */ /* CHANGED */
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 ); /* ADDED */
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,18 +1436,58 @@ 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
+
1440
+
1441
+
1442
+ /* Log byte counters for debugging */
1443
+ pr_info ("vwifi: Station %pM tx_bytes %llu, rx_bytes %llu\n" , mac ,
1444
+ sinfo -> tx_bytes , sinfo -> rx_bytes );
1445
+
1446
+ /* Dynamic modulation based on signal strength */
1447
+ int mcs_index ;
1448
+ const char * modulation ;
1449
+ unsigned int data_rate_mbps ;
1450
+ if (sinfo -> signal > -50 ) {
1451
+ /* Strong signal: 64-QAM, MCS 31 */
1452
+ mcs_index = 31 ;
1453
+ modulation = "64-QAM" ;
1454
+ } else if (sinfo -> signal > -70 && sinfo -> signal <= -50 ) {
1455
+ /* Medium signal: 16-QAM, MCS 23 */
1456
+ mcs_index = 23 ;
1457
+ modulation = "16-QAM" ;
1458
+ } else if (sinfo -> signal > -90 && sinfo -> signal <= -70 ) {
1459
+ /* Weak signal: QPSK, MCS 15 */
1460
+ mcs_index = 15 ;
1461
+ modulation = "QPSK" ;
1462
+ } else {
1463
+ /* Very weak signal: BPSK, MCS 7 */
1464
+ mcs_index = 7 ;
1465
+ modulation = "BPSK" ;
1466
+ }
1467
+
1468
+ /* Log signal, modulation, and data rate for debugging */
1469
+ pr_info (
1470
+ "vwifi: Station %pM signal %d dBm, using modulation %s (MCS %d, %u "
1471
+ "Mbps)\n" ,
1472
+ mac , sinfo -> signal , modulation , mcs_index , data_rate_mbps );
1473
+
1474
+ /* Configure RX and TX rates */
1475
+ sinfo -> rxrate .flags = RATE_INFO_FLAGS_MCS ;
1476
+ sinfo -> rxrate .mcs = mcs_index ;
1430
1477
sinfo -> rxrate .bw = RATE_INFO_BW_20 ;
1431
1478
sinfo -> rxrate .n_bonded_ch = 1 ;
1432
1479
1433
- sinfo -> txrate .flags | = RATE_INFO_FLAGS_MCS ;
1434
- sinfo -> txrate .mcs = 31 ;
1480
+ sinfo -> txrate .flags = RATE_INFO_FLAGS_MCS ;
1481
+ sinfo -> txrate .mcs = mcs_index ;
1435
1482
sinfo -> txrate .bw = RATE_INFO_BW_20 ;
1436
1483
sinfo -> txrate .n_bonded_ch = 1 ;
1484
+
1485
+ /* Log rate configuration for verification */
1486
+ pr_info ("vwifi: Station %pM txrate MCS %d, rxrate MCS %d\n" , mac ,
1487
+ sinfo -> txrate .mcs , sinfo -> rxrate .mcs );
1488
+
1437
1489
return 0 ;
1438
1490
}
1439
-
1440
1491
/* dump station callback -- resume dump at index @idx */
1441
1492
static int vwifi_dump_station (struct wiphy * wiphy ,
1442
1493
struct net_device * dev ,
@@ -2178,23 +2229,26 @@ static struct cfg80211_ops vwifi_cfg_ops = {
2178
2229
};
2179
2230
2180
2231
/* Macro for defining 2GHZ channel array */
2181
- #define CHAN_2GHZ (channel , freq ) \
2182
- { \
2183
- .band = NL80211_BAND_2GHZ, .hw_value = (channel), \
2184
- .center_freq = (freq), \
2232
+ #define CHAN_2GHZ (channel , freq ) \
2233
+ { \
2234
+ .band = NL80211_BAND_2GHZ, \
2235
+ .hw_value = (channel), \
2236
+ .center_freq = (freq), \
2185
2237
}
2186
2238
2187
2239
/* Macro for defining 5GHZ channel array */
2188
- #define CHAN_5GHZ (channel ) \
2189
- { \
2190
- .band = NL80211_BAND_5GHZ, .hw_value = (channel), \
2191
- .center_freq = 5000 + (5 * (channel)), \
2240
+ #define CHAN_5GHZ (channel ) \
2241
+ { \
2242
+ .band = NL80211_BAND_5GHZ, \
2243
+ .hw_value = (channel), \
2244
+ .center_freq = 5000 + (5 * (channel)), \
2192
2245
}
2193
2246
2194
2247
/* Macro for defining rate table */
2195
- #define RATE_ENT (_rate , _hw_value ) \
2196
- { \
2197
- .bitrate = (_rate), .hw_value = (_hw_value), \
2248
+ #define RATE_ENT (_rate , _hw_value ) \
2249
+ { \
2250
+ .bitrate = (_rate), \
2251
+ .hw_value = (_hw_value), \
2198
2252
}
2199
2253
2200
2254
/* Array of "supported" channels in 2GHz band. It is required for wiphy. */
0 commit comments