All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhagavathi Perumal S <bperumal@codeaurora.org>
To: ath11k@lists.infradead.org
Cc: Bhagavathi Perumal S <bperumal@codeaurora.org>
Subject: [PATCH v2 3/3] ath11k: Add debugfs entry to support htt stats reset
Date: Wed, 24 Apr 2019 00:03:51 +0530	[thread overview]
Message-ID: <1556044431-32431-4-git-send-email-bperumal@codeaurora.org> (raw)
In-Reply-To: <1556044431-32431-1-git-send-email-bperumal@codeaurora.org>

This adds debugfs entry htt_stats_reset to reset htt stats.

Example to reset pdev tx stats and it's output logs are,

 $echo 1 >/sys/kernel/debug/ath11k/mac0/htt_stats_reset
 $cat /sys/kernel/debug/ath11k/mac0/htt_stats_reset
 1

 $echo 1 >/sys/kernel/debug/ath11k/mac0/htt_stats_type
 $cat /sys/kernel/debug/ath11k/mac0/htt_stats_type
 1

 $cat /sys/kernel/debug/ath11k/mac0/htt_stats
 HTT_TX_PDEV_STATS_CMN_TLV:
 mac_id = 0
 hw_queued = 112
 hw_reaped = 112
 ...

Signed-off-by: Bhagavathi Perumal S <bperumal@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/core.h            |  1 +
 drivers/net/wireless/ath/ath11k/debug_htt_stats.c | 61 +++++++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index c5f0a71..c2068b5 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -368,6 +368,7 @@ struct ath11k_fw_stats {
 
 struct ath11k_dbg_htt_stats {
 	u8 type;
+	u8 reset;
 	/* protects shared stats req buffer */
 	spinlock_t lock;
 };
diff --git a/drivers/net/wireless/ath/ath11k/debug_htt_stats.c b/drivers/net/wireless/ath/ath11k/debug_htt_stats.c
index c44ec49..876134a 100644
--- a/drivers/net/wireless/ath/ath11k/debug_htt_stats.c
+++ b/drivers/net/wireless/ath/ath11k/debug_htt_stats.c
@@ -4407,6 +4407,57 @@ static ssize_t ath11k_read_htt_stats(struct file *file,
 	return simple_read_from_buffer(user_buf, count, ppos, buf, length);
 }
 
+static ssize_t ath11k_read_htt_stats_reset(struct file *file,
+					   char __user *user_buf,
+					   size_t count, loff_t *ppos)
+{
+	struct ath11k *ar = file->private_data;
+	char buf[32];
+	size_t len;
+
+	len = scnprintf(buf, sizeof(buf), "%u\n", ar->debug.htt_stats.reset);
+
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t ath11k_write_htt_stats_reset(struct file *file,
+					    const char __user *user_buf,
+					    size_t count, loff_t *ppos)
+{
+	struct ath11k *ar = file->private_data;
+	u8 type;
+	struct htt_ext_stats_cfg_params cfg_params = { 0 };
+	int ret;
+
+	ret = kstrtou8_from_user(user_buf, count, 0, &type);
+	if (ret)
+		return ret;
+
+	if (type >= ATH11K_DBG_HTT_NUM_EXT_STATS ||
+	    type == ATH11K_DBG_HTT_EXT_STATS_RESET)
+		return -E2BIG;
+
+	mutex_lock(&ar->conf_mutex);
+	cfg_params.cfg0 = HTT_STAT_DEFAULT_RESET_START_OFFSET;
+	cfg_params.cfg1 = 1 << (cfg_params.cfg0 + type);
+	ret = ath11k_dp_htt_h2t_ext_stats_req(ar,
+					      ATH11K_DBG_HTT_EXT_STATS_RESET,
+					      &cfg_params,
+					      0ULL);
+	if (ret) {
+		ath11k_warn(ar->ab, "failed to send htt stats request: %d\n", ret);
+		mutex_unlock(&ar->conf_mutex);
+		return ret;
+	}
+
+	ar->debug.htt_stats.reset = type;
+	mutex_unlock(&ar->conf_mutex);
+
+	ret = count;
+
+	return ret;
+}
+
 static const struct file_operations fops_htt_stats_type = {
 	.read = ath11k_read_htt_stats_type,
 	.write = ath11k_write_htt_stats_type,
@@ -4423,6 +4474,14 @@ static ssize_t ath11k_read_htt_stats(struct file *file,
 	.llseek = default_llseek,
 };
 
+static const struct file_operations fops_htt_stats_reset = {
+	.read = ath11k_read_htt_stats_reset,
+	.write = ath11k_write_htt_stats_reset,
+	.open = simple_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
 void ath11k_htt_stats_debugfs_init(struct ath11k *ar)
 {
 	spin_lock_init(&ar->debug.htt_stats.lock);
@@ -4430,4 +4489,6 @@ void ath11k_htt_stats_debugfs_init(struct ath11k *ar)
 			    ar, &fops_htt_stats_type);
 	debugfs_create_file("htt_stats", 0400, ar->debug.debugfs_pdev,
 			    ar, &fops_dump_htt_stats);
+	debugfs_create_file("htt_stats_reset", 0600, ar->debug.debugfs_pdev,
+			    ar, &fops_htt_stats_reset);
 }
-- 
1.9.1


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

  parent reply	other threads:[~2019-04-23 18:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 18:33 [PATCH v2 0/3] ath11k: Add some bug fixes and enhancements in htt stats Bhagavathi Perumal S
2019-04-23 18:33 ` [PATCH v2 1/3] ath11k: Fix few coding bugs " Bhagavathi Perumal S
2019-04-23 18:33 ` [PATCH v2 2/3] ath11k: Add htt peer stats support Bhagavathi Perumal S
2019-04-23 18:33 ` Bhagavathi Perumal S [this message]
2019-05-02 13:22 ` [PATCH v2 0/3] ath11k: Add some bug fixes and enhancements in htt stats Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1556044431-32431-4-git-send-email-bperumal@codeaurora.org \
    --to=bperumal@codeaurora.org \
    --cc=ath11k@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.