]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: rtw89: debug: add RX statistics in bb_info
authorKuan-Chung Chen <damon.chen@realtek.com>
Wed, 29 Apr 2026 13:26:24 +0000 (21:26 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Wed, 6 May 2026 08:10:43 +0000 (16:10 +0800)
Expand RX packet statistics including coding type, spatial
diversity, and beamforming. These statistics are accumulated
per PHY and displayed in bb_info debugfs.

RX statistics output:

  == RX General
  LDPC: 190, BCC: 0, STBC: 0, SU_NON_BF: 0, SU_BF: 190, MU: 0

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260429132625.1659182-7-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/txrx.h

index d8f83623e54a689e4efb4712675852ae7f461965..b85728ceb63cea7cea600ab13eb692fa46854358 100644 (file)
@@ -2097,11 +2097,8 @@ static void rtw89_core_parse_phy_status_ie01(struct rtw89_dev *rtwdev,
        u32 t;
 
        phy_ppdu->chan_idx = le32_get_bits(ie->w0, RTW89_PHY_STS_IE01_W0_CH_IDX);
-
-       if (rtwdev->hw->conf.flags & IEEE80211_CONF_MONITOR) {
-               phy_ppdu->ldpc = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_LDPC);
-               phy_ppdu->stbc = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_STBC);
-       }
+       phy_ppdu->ldpc = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_LDPC);
+       phy_ppdu->stbc = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_STBC);
 
        if (!phy_ppdu->hdr_2_en)
                phy_ppdu->rx_path_en =
@@ -2114,9 +2111,11 @@ static void rtw89_core_parse_phy_status_ie01(struct rtw89_dev *rtwdev,
                return;
 
        phy_ppdu->rpl_avg = le32_get_bits(ie->w0, RTW89_PHY_STS_IE01_W0_RSSI_AVG_FD);
+       phy_ppdu->su = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_SU);
        phy_ppdu->ofdm.avg_snr = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_AVG_SNR);
        phy_ppdu->ofdm.evm_max = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_EVM_MAX);
        phy_ppdu->ofdm.evm_min = le32_get_bits(ie->w2, RTW89_PHY_STS_IE01_W2_EVM_MIN);
+       phy_ppdu->bf = le32_get_bits(ie->w3, RTW89_PHY_STS_IE01_W3_BF);
        phy_ppdu->ofdm.has = true;
 
        /* sign conversion for S(12,2) */
@@ -3062,6 +3061,23 @@ static void rtw89_vif_rx_stats_iter(void *data, u8 *mac,
        if (desc_info->data_rate < RTW89_HW_RATE_NR)
                pkt_stat->rx_rate_cnt[desc_info->data_rate]++;
 
+       if (phy_ppdu && phy_ppdu->ofdm.has) {
+               if (phy_ppdu->ldpc)
+                       pkt_stat->rx.ldpc++;
+               else
+                       pkt_stat->rx.bcc++;
+
+               if (phy_ppdu->stbc)
+                       pkt_stat->rx.stbc++;
+
+               if (!phy_ppdu->su)
+                       pkt_stat->rx.mu++;
+               else if (phy_ppdu->bf)
+                       pkt_stat->rx.su_bf++;
+               else
+                       pkt_stat->rx.su_non_bf++;
+       }
+
        rtw89_traffic_stats_accu(rtwdev, rtwvif, skb, false, false);
 
 out:
index e8b03716d41e10b303fa0ddf71f1c2c5dffc880f..c0e176c4c3a6264e3db42f39b0da2a1e2d91e24a 100644 (file)
@@ -855,8 +855,10 @@ struct rtw89_rx_phy_ppdu {
        } ofdm;
        bool has_data;
        bool has_bcn;
+       bool su;
        bool ldpc;
        bool stbc;
+       bool bf;
        bool to_self;
        bool valid;
        bool hdr_2_en;
@@ -5378,6 +5380,14 @@ struct rtw89_pkt_stat {
        u8 beacon_rate;
        u32 beacon_len;
        u32 rx_rate_cnt[RTW89_HW_RATE_NR];
+       struct {
+               u32 ldpc;
+               u32 bcc;
+               u32 stbc;
+               u32 su_bf;
+               u32 su_non_bf;
+               u32 mu;
+       } rx;
 };
 
 #define RTW89_BCN_TRACK_STAT_NR 32
index d9a5bbae11f258c9ea72abfdc56f136b9ae64283..103948aee5cb89562cfb4126073608883982299d 100644 (file)
@@ -4303,6 +4303,7 @@ static int rtw89_get_bb_stat(struct rtw89_dev *rtwdev, struct rtw89_bb_ctx *bb,
                             char *buf, size_t bufsz)
 {
        const struct rtw89_phy_gen_def *phy = rtwdev->chip->phy_def;
+       struct rtw89_pkt_stat *pkt_stat = &bb->last_pkt_stat;
        const struct rtw89_physts_regs *physts = phy->physts;
        struct rtw89_pmac_stat_info *pmac = &bb->pmac_stat;
        struct rtw89_tx_stat_info *tx_stat = &bb->tx_stat;
@@ -4384,6 +4385,13 @@ static int rtw89_get_bb_stat(struct rtw89_dev *rtwdev, struct rtw89_bb_ctx *bb,
                               tx_stat->common_ctrl[i], (i < reg_nr - 1) ? ", " : "");
        p += scnprintf(p, end - p, "]\n\n");
 
+       p += scnprintf(p, end - p, "== RX General\n");
+       p += scnprintf(p, end - p,
+                      "LDPC: %d, BCC: %d, STBC: %d, SU_NON_BF: %d, SU_BF: %d, MU: %d\n\n",
+                      pkt_stat->rx.ldpc, pkt_stat->rx.bcc,
+                      pkt_stat->rx.stbc, pkt_stat->rx.su_non_bf,
+                      pkt_stat->rx.su_bf, pkt_stat->rx.mu);
+
        p += scnprintf(p, end - p, "== RSSI/RX Rate\n");
        p += rtw89_get_rx_pkt_stat(rtwdev, bb, p, end - p);
 
index b69a2529aefcce827bb9ae9f202e87eb3f5ff852..125ba2a9f1450415c010e0368c0bc365a8148e2f 100644 (file)
@@ -634,8 +634,10 @@ struct rtw89_phy_sts_ie01 {
 #define RTW89_PHY_STS_IE01_W2_AVG_SNR GENMASK(5, 0)
 #define RTW89_PHY_STS_IE01_W2_EVM_MAX GENMASK(15, 8)
 #define RTW89_PHY_STS_IE01_W2_EVM_MIN GENMASK(23, 16)
+#define RTW89_PHY_STS_IE01_W2_SU BIT(27)
 #define RTW89_PHY_STS_IE01_W2_LDPC BIT(28)
 #define RTW89_PHY_STS_IE01_W2_STBC BIT(30)
+#define RTW89_PHY_STS_IE01_W3_BF BIT(8)
 
 struct rtw89_phy_sts_ie01_v2 {
        __le32 w0;