ath10k: Added support to reset HTT stats in debugfs
authorMaharaja Kennadyrajan <mkenna@codeaurora.org>
Wed, 27 Feb 2019 11:24:42 +0000 (16:54 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 7 May 2019 13:37:26 +0000 (16:37 +0300)
Reset HTT stats helps to get the aggregated HTT stats via
tracing and also we can clear the accumulated HTT stats with
this debugfs file.

Signed-off-by: Maharaja Kennadyrajan <mkenna@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath10k/debug.c
drivers/net/wireless/ath/ath10k/htt.h
drivers/net/wireless/ath/ath10k/htt_tx.c

index 02e53fb85814bd6f390ec04ea7074426c8fb10d4..cbb9ff4d1707f26921e879a138e0598b17bc9c05 100644 (file)
@@ -622,6 +622,7 @@ struct ath10k_debug {
        bool fw_stats_done;
 
        unsigned long htt_stats_mask;
+       unsigned long reset_htt_stats;
        struct delayed_work htt_stats_dwork;
        struct ath10k_dfs_stats dfs_stats;
        struct ath_dfs_pool_stats dfs_pool_stats;
index 2da8611778a265a7979e4dbaf82c0e4e8a7555d0..f828fd81027048d7a026fed2ebec43c68f88d313 100644 (file)
@@ -873,7 +873,7 @@ static int ath10k_debug_htt_stats_req(struct ath10k *ar)
        cookie = get_jiffies_64();
 
        ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask,
-                                      cookie);
+                                      ar->debug.reset_htt_stats, cookie);
        if (ret) {
                ath10k_warn(ar, "failed to send htt stats request: %d\n", ret);
                return ret;
@@ -2469,6 +2469,44 @@ static const struct file_operations fops_ps_state_enable = {
        .llseek = default_llseek,
 };
 
+static ssize_t ath10k_write_reset_htt_stats(struct file *file,
+                                           const char __user *user_buf,
+                                           size_t count, loff_t *ppos)
+{
+       struct ath10k *ar = file->private_data;
+       unsigned long reset;
+       int ret;
+
+       ret = kstrtoul_from_user(user_buf, count, 0, &reset);
+       if (ret)
+               return ret;
+
+       if (reset == 0 || reset > 0x1ffff)
+               return -EINVAL;
+
+       mutex_lock(&ar->conf_mutex);
+
+       ar->debug.reset_htt_stats = reset;
+
+       ret = ath10k_debug_htt_stats_req(ar);
+       if (ret)
+               goto out;
+
+       ar->debug.reset_htt_stats = 0;
+       ret = count;
+
+out:
+       mutex_unlock(&ar->conf_mutex);
+       return ret;
+}
+
+static const struct file_operations fops_reset_htt_stats = {
+       .write = ath10k_write_reset_htt_stats,
+       .owner = THIS_MODULE,
+       .open = simple_open,
+       .llseek = default_llseek,
+};
+
 int ath10k_debug_create(struct ath10k *ar)
 {
        ar->debug.cal_data = vzalloc(ATH10K_DEBUG_CAL_DATA_LEN);
@@ -2609,6 +2647,9 @@ int ath10k_debug_register(struct ath10k *ar)
        debugfs_create_file("ps_state_enable", 0600, ar->debug.debugfs_phy, ar,
                            &fops_ps_state_enable);
 
+       debugfs_create_file("reset_htt_stats", 0200, ar->debug.debugfs_phy, ar,
+                           &fops_reset_htt_stats);
+
        return 0;
 }
 
index 10c13c2974c817d3d6802bd1f8d191c9ef1ce128..19cd0cb5875f5c33dc6c895eef2a518f173ef47d 100644 (file)
@@ -2244,7 +2244,8 @@ void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
 void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
 bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
 int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
-int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u64 cookie);
+int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u32 reset_mask,
+                            u64 cookie);
 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
                                u8 max_subfrms_ampdu,
                                u8 max_subfrms_amsdu);
index 1f07bed5e6eb5452ee9f0742ba153d3155cf4a17..1f391c739e40d9466bdf7737297630b03aae9d2f 100644 (file)
@@ -580,7 +580,8 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt)
        return 0;
 }
 
-int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u64 cookie)
+int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u32 reset_mask,
+                            u64 cookie)
 {
        struct ath10k *ar = htt->ar;
        struct htt_stats_req *req;
@@ -607,7 +608,7 @@ int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u64 cookie)
         * about endian support
         */
        memcpy(req->upload_types, &mask, 3);
-       memcpy(req->reset_types, &mask, 3);
+       memcpy(req->reset_types, &reset_mask, 3);
        req->stat_type = HTT_STATS_REQ_CFG_STAT_TYPE_INVALID;
        req->cookie_lsb = cpu_to_le32(cookie & 0xffffffff);
        req->cookie_msb = cpu_to_le32((cookie & 0xffffffff00000000ULL) >> 32);