ath10k: dump tx stats in rate table format
authorAnilkumar Kolli <akolli@codeaurora.org>
Fri, 12 Oct 2018 06:03:28 +0000 (11:33 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 5 Nov 2018 10:07:12 +0000 (12:07 +0200)
This patch adds the tx statistics pkts/bytes dump
in rate table format.

Dump format table is similar to http://mcsindex.com/

Tested on QCA9984/QCA4019/QCA988x
Firmware: 10.4-3.5.3-00057
  10.2.4-1.0-00037
command:
cat /sys/kernel/debug/ieee80211/phy0/netdev\:wlan0/
    stations/<MACADDR>/tx_stats

Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath10k/debugfs_sta.c
drivers/net/wireless/ath/ath10k/htt_rx.c
drivers/net/wireless/ath/ath10k/wmi.h

index 009a4936a7edbbef8b7e63f9f4c75555c7adcf26..7d8d4e004e316acc98d957ec8adc6204c6513ba1 100644 (file)
@@ -474,6 +474,7 @@ struct ath10k_htt_data_stats {
        u64 bw[ATH10K_COUNTER_TYPE_MAX][ATH10K_BW_NUM];
        u64 nss[ATH10K_COUNTER_TYPE_MAX][ATH10K_NSS_NUM];
        u64 gi[ATH10K_COUNTER_TYPE_MAX][ATH10K_GI_NUM];
+       u64 rate_table[ATH10K_COUNTER_TYPE_MAX][ATH10K_RATE_TABLE_NUM];
 };
 
 struct ath10k_htt_tx_stats {
index b09cdc699c69856b0e07442fb6b256d0f1d911d8..0f3fd65a459e2454c32cda1875c2515f77476711 100644 (file)
@@ -665,7 +665,7 @@ static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,
                                                       "retry", "ampdu"};
        const char *str[ATH10K_COUNTER_TYPE_MAX] = {"bytes", "packets"};
        int len = 0, i, j, k, retval = 0;
-       const int size = 2 * 4096;
+       const int size = 16 * 4096;
        char *buf;
 
        buf = kzalloc(size, GFP_KERNEL);
@@ -719,6 +719,16 @@ static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,
                                len += scnprintf(buf + len, size - len, "%llu ",
                                                 stats->legacy[j][i]);
                        len += scnprintf(buf + len, size - len, "\n");
+                       len += scnprintf(buf + len, size - len,
+                                        " Rate table %s (1,2 ... Mbps)\n  ",
+                                        str[j]);
+                       for (i = 0; i < ATH10K_RATE_TABLE_NUM; i++) {
+                               len += scnprintf(buf + len, size - len, "%llu ",
+                                                stats->rate_table[j][i]);
+                               if (!((i + 1) % 8))
+                                       len +=
+                                       scnprintf(buf + len, size - len, "\n  ");
+                       }
                }
        }
 
index ffec98f7be5054d5ed1d0d9855755b02eb99aaf6..984b0458d07707b55d3f6812da70f336f0a43775 100644 (file)
@@ -2650,7 +2650,7 @@ ath10k_accumulate_per_peer_tx_stats(struct ath10k *ar,
 {
        struct rate_info *txrate = &arsta->txrate;
        struct ath10k_htt_tx_stats *tx_stats;
-       int ht_idx, gi, mcs, bw, nss;
+       int idx, ht_idx, gi, mcs, bw, nss;
 
        if (!arsta->tx_stats)
                return;
@@ -2661,6 +2661,8 @@ ath10k_accumulate_per_peer_tx_stats(struct ath10k *ar,
        mcs = txrate->mcs;
        bw = txrate->bw;
        nss = txrate->nss;
+       idx = mcs * 8 + 8 * 10 * nss;
+       idx += bw * 2 + gi;
 
 #define STATS_OP_FMT(name) tx_stats->stats[ATH10K_STATS_TYPE_##name]
 
@@ -2709,12 +2711,16 @@ ath10k_accumulate_per_peer_tx_stats(struct ath10k *ar,
                        pstats->succ_bytes + pstats->retry_bytes;
                STATS_OP_FMT(AMPDU).gi[0][gi] +=
                        pstats->succ_bytes + pstats->retry_bytes;
+               STATS_OP_FMT(AMPDU).rate_table[0][idx] +=
+                       pstats->succ_bytes + pstats->retry_bytes;
                STATS_OP_FMT(AMPDU).bw[1][bw] +=
                        pstats->succ_pkts + pstats->retry_pkts;
                STATS_OP_FMT(AMPDU).nss[1][nss] +=
                        pstats->succ_pkts + pstats->retry_pkts;
                STATS_OP_FMT(AMPDU).gi[1][gi] +=
                        pstats->succ_pkts + pstats->retry_pkts;
+               STATS_OP_FMT(AMPDU).rate_table[1][idx] +=
+                       pstats->succ_pkts + pstats->retry_pkts;
        } else {
                tx_stats->ack_fails +=
                                ATH10K_HW_BA_FAIL(pstats->flags);
@@ -2743,6 +2749,15 @@ ath10k_accumulate_per_peer_tx_stats(struct ath10k *ar,
        STATS_OP_FMT(RETRY).bw[1][bw] += pstats->retry_pkts;
        STATS_OP_FMT(RETRY).nss[1][nss] += pstats->retry_pkts;
        STATS_OP_FMT(RETRY).gi[1][gi] += pstats->retry_pkts;
+
+       if (txrate->flags >= RATE_INFO_FLAGS_MCS) {
+               STATS_OP_FMT(SUCC).rate_table[0][idx] += pstats->succ_bytes;
+               STATS_OP_FMT(SUCC).rate_table[1][idx] += pstats->succ_pkts;
+               STATS_OP_FMT(FAIL).rate_table[0][idx] += pstats->failed_bytes;
+               STATS_OP_FMT(FAIL).rate_table[1][idx] += pstats->failed_pkts;
+               STATS_OP_FMT(RETRY).rate_table[0][idx] += pstats->retry_bytes;
+               STATS_OP_FMT(RETRY).rate_table[1][idx] += pstats->retry_pkts;
+       }
 }
 
 static void
index f7badd079051d35601ca1fa6400601d4109604ad..4971d610f567db388fc115a248c347f653ba0808 100644 (file)
@@ -4991,6 +4991,7 @@ enum wmi_rate_preamble {
 #define ATH10K_LEGACY_NUM      12
 #define ATH10K_GI_NUM          2
 #define ATH10K_HT_MCS_NUM      32
+#define ATH10K_RATE_TABLE_NUM  320
 
 /* Value to disable fixed rate setting */
 #define WMI_FIXED_RATE_NONE    (0xff)