@@ -1403,8 +1403,19 @@ static int vwifi_get_station(struct wiphy *wiphy,
14031403 sinfo -> tx_failed = vif -> stats .tx_dropped ;
14041404 sinfo -> tx_bytes = vif -> stats .tx_bytes ;
14051405 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+
14061415 /* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in dBm */
14071416 sinfo -> signal = rand_int_smooth (-100 , -30 , jiffies );
1417+ pr_info ("vwifi: Station %pM signal %d dBm (raw)\n" , mac ,
1418+ sinfo -> signal ); /* ADDED */
14081419 sinfo -> inactive_time = jiffies_to_msecs (jiffies - vif -> active_time );
14091420 /*
14101421 * Using 802.11n (HT) as the PHY, configure as follows:
@@ -1425,18 +1436,58 @@ static int vwifi_get_station(struct wiphy *wiphy,
14251436 * https://semfionetworks.com/blog/mcs-table-updated-with-80211ax-data-rates/
14261437 * IEEE 802.11n : https://zh.wikipedia.org/zh-tw/IEEE_802.11n
14271438 */
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 ;
14301477 sinfo -> rxrate .bw = RATE_INFO_BW_20 ;
14311478 sinfo -> rxrate .n_bonded_ch = 1 ;
14321479
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 ;
14351482 sinfo -> txrate .bw = RATE_INFO_BW_20 ;
14361483 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+
14371489 return 0 ;
14381490}
1439-
14401491/* dump station callback -- resume dump at index @idx */
14411492static int vwifi_dump_station (struct wiphy * wiphy ,
14421493 struct net_device * dev ,
@@ -2178,23 +2229,26 @@ static struct cfg80211_ops vwifi_cfg_ops = {
21782229};
21792230
21802231/* 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), \
21852237 }
21862238
21872239/* 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)), \
21922245 }
21932246
21942247/* 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), \
21982252 }
21992253
22002254/* Array of "supported" channels in 2GHz band. It is required for wiphy. */
0 commit comments