All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sujith Manoharan <sujith@msujith.org>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [PATCH 2/2] ath10k: Add host statistics
Date: Tue, 30 Apr 2013 15:42:47 +0530	[thread overview]
Message-ID: <1367316767-29559-2-git-send-email-sujith@msujith.org> (raw)
In-Reply-To: <1367316767-29559-1-git-send-email-sujith@msujith.org>

From: Sujith Manoharan <c_manoha@qca.qualcomm.com>

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/debug.c  | 55 +++++++++++++++++++++++++++++++-
 drivers/net/wireless/ath/ath10k/debug.h  | 22 +++++++++++++
 drivers/net/wireless/ath/ath10k/htt_rx.c | 30 +++++++++++++----
 3 files changed, 100 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 946185c..f334053 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -443,6 +443,58 @@ static const struct file_operations fops_fw_stats = {
 	.llseek = default_llseek,
 };
 
+static ssize_t ath10k_read_host_stats(struct file *file, char __user *user_buf,
+				      size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	struct ath10k_host_stats *host_stats = &ar->debug.host_stats;
+	unsigned int len = 0, buf_len = 1024;
+	char *buf;
+	ssize_t ret_cnt;
+
+	buf = kzalloc(buf_len, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT RX indication :", host_stats->htt_rx_ind);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT MSDUs :", host_stats->htt_msdu);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT A-MSDUs :", host_stats->htt_amsdu);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT MSDU early :", host_stats->htt_msdu_early);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT MSDU invalid length :", host_stats->htt_msdu_len_invalid);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT MSDU zero len :", host_stats->htt_msdu_zero_len);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT MSDU chained :", host_stats->htt_msdu_chained);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT MSDU no data :", host_stats->htt_msdu_no_data);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT decrypt error :", host_stats->htt_decrypt_err);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT invalid status :", host_stats->htt_invalid_status);
+	len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n",
+			 "HTT FCS error :", host_stats->htt_fcs_err);
+
+	if (len > buf_len)
+		len = buf_len;
+
+	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+
+	kfree(buf);
+	return ret_cnt;
+}
+
+static const struct file_operations fops_host_stats = {
+	.read = ath10k_read_host_stats,
+	.open = simple_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
 int ath10k_debug_create(struct ath10k *ar)
 {
 	ar->debug.debugfs_phy = debugfs_create_dir("ath10k",
@@ -455,9 +507,10 @@ int ath10k_debug_create(struct ath10k *ar)
 
 	debugfs_create_file("fw_stats", S_IRUSR, ar->debug.debugfs_phy, ar,
 			    &fops_fw_stats);
-
 	debugfs_create_file("wmi_services", S_IRUSR, ar->debug.debugfs_phy, ar,
 			    &fops_wmi_services);
+	debugfs_create_file("host_stats", S_IRUSR, ar->debug.debugfs_phy, ar,
+			    &fops_host_stats);
 
 	return 0;
 }
diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
index b0549cd..45866ab 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -106,9 +106,31 @@ struct ath10k_target_stats {
 
 };
 
+#ifdef CONFIG_ATH10K_DEBUGFS
+#define HOST_STAT_INC(c) ar->debug.host_stats.c++
+#else
+#define HOST_STAT_INC(c) do { } while (0)
+#endif
+
+struct ath10k_host_stats {
+	/* RX */
+	u64 htt_rx_ind;
+	u64 htt_msdu;
+	u64 htt_amsdu;
+	u64 htt_msdu_early;
+	u64 htt_msdu_len_invalid;
+	u64 htt_msdu_zero_len;
+	u64 htt_msdu_chained;
+	u64 htt_msdu_no_data;
+	u64 htt_decrypt_err;
+	u64 htt_invalid_status;
+	u64 htt_fcs_err;
+};
+
 struct ath10k_debug {
 	struct dentry *debugfs_phy;
 
+	struct ath10k_host_stats host_stats;
 	struct ath10k_target_stats target_stats;
 	u32 wmi_service_bitmap[WMI_SERVICE_BM_SIZE];
 
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 6b1ca2b..f771684 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -449,6 +449,7 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
 				   struct sk_buff **head_msdu,
 				   struct sk_buff **tail_msdu)
 {
+	struct ath10k *ar = htt->ar;
 	int msdu_len, msdu_chaining = 0;
 	struct sk_buff *msdu;
 	struct htt_rx_desc *rx_desc;
@@ -489,7 +490,8 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
 		 * just assert for now until we have a way to recover.
 		 */
 		if (!(__le32_to_cpu(rx_desc->attention.flags)
-				& RX_ATTENTION_FLAGS_MSDU_DONE)) {
+		      & RX_ATTENTION_FLAGS_MSDU_DONE)) {
+			HOST_STAT_INC(htt_msdu_early);
 			ath10k_htt_rx_free_msdu_chain(*head_msdu);
 			*head_msdu = NULL;
 			msdu = NULL;
@@ -541,14 +543,19 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
 		}
 
 		msdu_len_invalid = !!(__le32_to_cpu(rx_desc->attention.flags)
-					& (RX_ATTENTION_FLAGS_MPDU_LENGTH_ERR |
-					   RX_ATTENTION_FLAGS_MSDU_LENGTH_ERR));
+				      & (RX_ATTENTION_FLAGS_MPDU_LENGTH_ERR |
+					 RX_ATTENTION_FLAGS_MSDU_LENGTH_ERR));
 		msdu_len = MS(__le32_to_cpu(rx_desc->msdu_start.info0),
 			      RX_MSDU_START_INFO0_MSDU_LENGTH);
 		msdu_chained = rx_desc->frag_info.ring2_more_count;
 
-		if (msdu_len_invalid)
+		if (msdu_chained)
+			HOST_STAT_INC(htt_msdu_chained);
+
+		if (msdu_len_invalid) {
+			HOST_STAT_INC(htt_msdu_len_invalid);
 			msdu_len = 0;
+		}
 
 		skb_trim(msdu, 0);
 		skb_put(msdu, min(msdu_len, HTT_RX_MSDU_SIZE));
@@ -966,6 +973,7 @@ static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb)
 static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
 				  struct htt_rx_indication *rx)
 {
+	struct ath10k *ar = htt->ar;
 	struct htt_rx_info info;
 	struct htt_rx_indication_mpdu_range *mpdu_ranges;
 	int num_mpdu_ranges;
@@ -974,6 +982,8 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
 	int i, j;
 	int ret;
 
+	HOST_STAT_INC(htt_rx_ind);
+
 	memset(&info, 0, sizeof(info));
 
 	fw_desc_len = __le16_to_cpu(rx->prefix.fw_rx_desc_bytes);
@@ -1004,11 +1014,13 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
 							 &msdu_tail);
 
 			if (!msdu_head) {
+				HOST_STAT_INC(htt_msdu_no_data);
 				ath10k_warn("htt rx no data!\n");
 				continue;
 			}
 
 			if (msdu_head->len == 0) {
+				HOST_STAT_INC(htt_msdu_zero_len);
 				ath10k_dbg(ATH10K_DBG_HTT,
 					   "htt rx dropping due to zero-len\n");
 				ath10k_htt_rx_free_msdu_chain(msdu_head);
@@ -1016,6 +1028,7 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
 			}
 
 			if (ath10k_htt_rx_has_decrypt_err(msdu_head)) {
+				HOST_STAT_INC(htt_decrypt_err);
 				ath10k_htt_rx_free_msdu_chain(msdu_head);
 				continue;
 			}
@@ -1029,6 +1042,7 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
 			if (info.status != HTT_RX_IND_MPDU_STATUS_OK &&
 			    info.status != HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR &&
 			    !htt->ar->monitor_enabled) {
+				HOST_STAT_INC(htt_invalid_status);
 				ath10k_dbg(ATH10K_DBG_HTT,
 					   "htt rx ignoring frame w/ status %d\n",
 					   info.status);
@@ -1053,12 +1067,16 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
 			info.rate.info1 = __le32_to_cpu(rx->ppdu.info1);
 			info.rate.info2 = __le32_to_cpu(rx->ppdu.info2);
 
-			if (ath10k_htt_rx_hdr_is_amsdu(ath10k_htt_rx_skb_get_hdr(msdu_head)))
+			if (ath10k_htt_rx_hdr_is_amsdu(ath10k_htt_rx_skb_get_hdr(msdu_head))) {
+				HOST_STAT_INC(htt_amsdu);
 				ret = ath10k_htt_rx_amsdu(htt, &info);
-			else
+			} else {
+				HOST_STAT_INC(htt_msdu);
 				ret = ath10k_htt_rx_msdu(htt, &info);
+			}
 
 			if (ret && !info.fcs_err) {
+				HOST_STAT_INC(htt_fcs_err);
 				ath10k_warn("error processing msdus %d\n", ret);
 				dev_kfree_skb_any(info.skb);
 				continue;
-- 
1.8.2.2

  reply	other threads:[~2013-04-30 10:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-30 10:12 [ath9k-devel] [PATCH 1/2] ath10k: Move debug structures to debug.h Sujith Manoharan
2013-04-30 10:12 ` Sujith Manoharan [this message]
2013-05-02  7:10   ` [ath9k-devel] [PATCH 2/2] ath10k: Add host statistics Kalle Valo
2013-05-02  7:02 ` [ath9k-devel] [PATCH 1/2] ath10k: Move debug structures to debug.h Kalle Valo
2013-05-02  7:14   ` Sujith Manoharan
2013-05-02  7:36     ` Kalle Valo
2013-05-02  7:43       ` Sujith Manoharan
2013-05-03 10:59         ` Kalle Valo
2013-05-03 11:03           ` Sujith Manoharan
2013-05-03 11:07             ` Sujith Manoharan
2013-05-03 11:13               ` Sujith Manoharan

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=1367316767-29559-2-git-send-email-sujith@msujith.org \
    --to=sujith@msujith.org \
    --cc=ath9k-devel@lists.ath9k.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.