wifi: rtw89: add to display hardware rates v1 histogram in debugfs
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 28 Jul 2023 07:02:51 +0000 (15:02 +0800)
committerKalle Valo <kvalo@kernel.org>
Tue, 1 Aug 2023 14:44:36 +0000 (17:44 +0300)
The upcoming WiFi 7 chips support EHT rates, and hardware rate codes are
changed too, so modify to adapt the changes. (EHT counters are still zeros
in below example)

RX count:
   Legacy: [0, 0, 0, 0]
     OFDM: [0, 0, 0, 0, 0, 0, 0, 0]
     HT 0: [0, 0, 0, 0, 0, 0, 0, 0]
     HT 1: [0, 0, 0, 0, 0, 0, 0, 0]
  VHT 1SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0]
  VHT 2SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0]
   HE 1SS: [0, 0, 42, 0, 43, 90, 75, 0, 26, 20, 260, 7]
   HE 2SS: [0, 96, 232, 84, 125, 184, 52, 0, 0, 0, 0, 0]
  EHT 1SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0]
  EHT 2SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-10-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/debug.c

index 24c1097467885b91363b25f80821c88ae5ad3b25..f3f7abddd3c0b50580dd0a6e878054a134743747 100644 (file)
@@ -584,6 +584,7 @@ enum rtw89_hw_rate {
        RTW89_HW_RATE_V1_EHT_NSS4_MCS13 = 0x46D,
 
        RTW89_HW_RATE_NR,
+       RTW89_HW_RATE_INVAL,
 
        RTW89_HW_RATE_MASK_MOD = GENMASK(8, 7),
        RTW89_HW_RATE_MASK_VAL = GENMASK(6, 0),
index ce5a9ac081457d75a4261b5b859a3da82c4bf8d9..f67af8aa2358f38462dd4b78e8a27efaed4590a3 100644 (file)
@@ -3325,20 +3325,26 @@ rtw89_debug_append_rx_rate(struct seq_file *m, struct rtw89_pkt_stat *pkt_stat,
                           pkt_stat->rx_rate_cnt[first_rate + i]);
 }
 
+#define FIRST_RATE_SAME(rate) {RTW89_HW_RATE_ ## rate, RTW89_HW_RATE_ ## rate}
+#define FIRST_RATE_ENUM(rate) {RTW89_HW_RATE_ ## rate, RTW89_HW_RATE_V1_ ## rate}
+#define FIRST_RATE_GEV1(rate) {RTW89_HW_RATE_INVAL, RTW89_HW_RATE_V1_ ## rate}
+
 static const struct rtw89_rx_rate_cnt_info {
-       enum rtw89_hw_rate first_rate;
+       enum rtw89_hw_rate first_rate[RTW89_CHIP_GEN_NUM];
        int len;
        int ext;
        const char *rate_mode;
 } rtw89_rx_rate_cnt_infos[] = {
-       {RTW89_HW_RATE_CCK1, 4, 0, "Legacy:"},
-       {RTW89_HW_RATE_OFDM6, 8, 0, "OFDM:"},
-       {RTW89_HW_RATE_MCS0, 8, 0, "HT 0:"},
-       {RTW89_HW_RATE_MCS8, 8, 0, "HT 1:"},
-       {RTW89_HW_RATE_VHT_NSS1_MCS0, 10, 2, "VHT 1SS:"},
-       {RTW89_HW_RATE_VHT_NSS2_MCS0, 10, 2, "VHT 2SS:"},
-       {RTW89_HW_RATE_HE_NSS1_MCS0, 12, 0, "HE 1SS:"},
-       {RTW89_HW_RATE_HE_NSS2_MCS0, 12, 0, "HE 2ss:"},
+       {FIRST_RATE_SAME(CCK1), 4, 0, "Legacy:"},
+       {FIRST_RATE_SAME(OFDM6), 8, 0, "OFDM:"},
+       {FIRST_RATE_ENUM(MCS0), 8, 0, "HT 0:"},
+       {FIRST_RATE_ENUM(MCS8), 8, 0, "HT 1:"},
+       {FIRST_RATE_ENUM(VHT_NSS1_MCS0), 10, 2, "VHT 1SS:"},
+       {FIRST_RATE_ENUM(VHT_NSS2_MCS0), 10, 2, "VHT 2SS:"},
+       {FIRST_RATE_ENUM(HE_NSS1_MCS0), 12, 0, "HE 1SS:"},
+       {FIRST_RATE_ENUM(HE_NSS2_MCS0), 12, 0, "HE 2SS:"},
+       {FIRST_RATE_GEV1(EHT_NSS1_MCS0), 14, 2, "EHT 1SS:"},
+       {FIRST_RATE_GEV1(EHT_NSS2_MCS0), 14, 0, "EHT 2SS:"},
 };
 
 static int rtw89_debug_priv_phy_info_get(struct seq_file *m, void *v)
@@ -3347,7 +3353,9 @@ static int rtw89_debug_priv_phy_info_get(struct seq_file *m, void *v)
        struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
        struct rtw89_traffic_stats *stats = &rtwdev->stats;
        struct rtw89_pkt_stat *pkt_stat = &rtwdev->phystat.last_pkt_stat;
+       const struct rtw89_chip_info *chip = rtwdev->chip;
        const struct rtw89_rx_rate_cnt_info *info;
+       enum rtw89_hw_rate first_rate;
        int i;
 
        seq_printf(m, "TP TX: %u [%u] Mbps (lv: %d), RX: %u [%u] Mbps (lv: %d)\n",
@@ -3359,15 +3367,20 @@ static int rtw89_debug_priv_phy_info_get(struct seq_file *m, void *v)
                   stats->rx_avg_len);
 
        seq_puts(m, "RX count:\n");
+
        for (i = 0; i < ARRAY_SIZE(rtw89_rx_rate_cnt_infos); i++) {
                info = &rtw89_rx_rate_cnt_infos[i];
+               first_rate = info->first_rate[chip->chip_gen];
+               if (first_rate >= RTW89_HW_RATE_NR)
+                       continue;
+
                seq_printf(m, "%10s [", info->rate_mode);
                rtw89_debug_append_rx_rate(m, pkt_stat,
-                                          info->first_rate, info->len);
+                                          first_rate, info->len);
                if (info->ext) {
                        seq_puts(m, "][");
                        rtw89_debug_append_rx_rate(m, pkt_stat,
-                                                  info->first_rate + info->len, info->ext);
+                                                  first_rate + info->len, info->ext);
                }
                seq_puts(m, "]\n");
        }