]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: debug: add beacon RSSI for debugging
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 27 Sep 2024 01:35:12 +0000 (09:35 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Sat, 5 Oct 2024 02:49:16 +0000 (10:49 +0800)
In range test, the RSSI is helpful to check attenuation of cable and align
difference between environments. Since data packets can be transmitted with
different rate and power, the RSSI of all packets can be variant.
Oppositely beacon is transmitted with the same rate and power, so beacon
RSSI will be relatively invariant, and more helpful to diagnose problems.

The output of beacon RSSI in unit of dBm looks like:

  Beacon: 19 (-33 dBm), TF: 0

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240927013512.7106-1-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/debug.c
drivers/net/wireless/realtek/rtw89/phy.c

index e5dc6d36245d1796db405cd3d5a5bf6ab4c682d0..bba5bde95bb4d199a3e2fb7684e1ef1841f90075 100644 (file)
@@ -2110,6 +2110,9 @@ static void rtw89_vif_rx_stats_iter(void *data, u8 *mac,
                        rtw89_fw_h2c_rssi_offload(rtwdev, phy_ppdu);
                }
                pkt_stat->beacon_nr++;
+
+               if (phy_ppdu)
+                       ewma_rssi_add(&rtwdev->phystat.bcn_rssi, phy_ppdu->rssi_avg);
        }
 
        if (!ether_addr_equal(bss_conf->addr, hdr->addr1))
index 598eee12339e76fa167283c7f6f408f500daa4d9..d9cf39cc4cec18a654cddc7278b814d664d4b9cf 100644 (file)
@@ -4747,6 +4747,7 @@ DECLARE_EWMA(thermal, 4, 4);
 
 struct rtw89_phy_stat {
        struct ewma_thermal avg_thermal[RF_PATH_MAX];
+       struct ewma_rssi bcn_rssi;
        struct rtw89_pkt_stat cur_pkt_stat;
        struct rtw89_pkt_stat last_pkt_stat;
 };
index 7391f131229a5802f961893dcf6a9db3f03d5998..74b0c722a5b890338ab5c03ff558bc79b911bcb4 100644 (file)
@@ -3673,13 +3673,16 @@ static int rtw89_debug_priv_phy_info_get(struct seq_file *m, void *v)
        const struct rtw89_chip_info *chip = rtwdev->chip;
        const struct rtw89_rx_rate_cnt_info *info;
        enum rtw89_hw_rate first_rate;
+       u8 rssi;
        int i;
 
+       rssi = ewma_rssi_read(&rtwdev->phystat.bcn_rssi);
+
        seq_printf(m, "TP TX: %u [%u] Mbps (lv: %d), RX: %u [%u] Mbps (lv: %d)\n",
                   stats->tx_throughput, stats->tx_throughput_raw, stats->tx_tfc_lv,
                   stats->rx_throughput, stats->rx_throughput_raw, stats->rx_tfc_lv);
-       seq_printf(m, "Beacon: %u, TF: %u\n", pkt_stat->beacon_nr,
-                  stats->rx_tf_periodic);
+       seq_printf(m, "Beacon: %u (%d dBm), TF: %u\n", pkt_stat->beacon_nr,
+                  RTW89_RSSI_RAW_TO_DBM(rssi), stats->rx_tf_periodic);
        seq_printf(m, "Avg packet length: TX=%u, RX=%u\n", stats->tx_avg_len,
                   stats->rx_avg_len);
 
index 7f90316a0f2fba92d9a8d59472f69e4c571cb31a..5a08e3d46bac02ef9bc6f3d79db0444dba75a70d 100644 (file)
@@ -4921,6 +4921,8 @@ static void rtw89_phy_stat_init(struct rtw89_dev *rtwdev)
 
        memset(&phystat->cur_pkt_stat, 0, sizeof(phystat->cur_pkt_stat));
        memset(&phystat->last_pkt_stat, 0, sizeof(phystat->last_pkt_stat));
+
+       ewma_rssi_init(&phystat->bcn_rssi);
 }
 
 void rtw89_phy_stat_track(struct rtw89_dev *rtwdev)