All of lore.kernel.org
 help / color / mirror / Atom feed
From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH-v2 5/6] mac80211:  Add some additional tx-stats to debugfs
Date: Wed, 24 Mar 2021 11:14:40 -0700	[thread overview]
Message-ID: <20210324181441.13755-5-greearb@candelatech.com> (raw)
In-Reply-To: <20210324181441.13755-1-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

Give a better idea of TX behaviour.  Currently this code does not
deal with HE tx rates properly.  I'm not sure exactly where to
find that info, not sure that ax200 driver that I'm testing properly
provides it up to the tx-status logic.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 net/mac80211/debugfs_sta.c | 24 ++++++++++++++++++-
 net/mac80211/rx.c          |  1 +
 net/mac80211/sta_info.h    | 16 +++++++++++++
 net/mac80211/status.c      | 47 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 9dd29fe94bde..ed6380bb6270 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -107,7 +107,7 @@ static ssize_t sta_stats_read(struct file *file, char __user *userbuf,
 {
 	struct sta_info *sta = file->private_data;
 	unsigned int len = 0;
-	const int buf_len = 8000;
+	const int buf_len = 12000;
 	char *buf = kzalloc(buf_len, GFP_KERNEL);
 	unsigned long sum;
 	char tmp[60];
@@ -186,6 +186,7 @@ static ssize_t sta_stats_read(struct file *file, char __user *userbuf,
 	PRINT_MY_STATS("rx-bw-40", rx_stats.msdu_40);
 	PRINT_MY_STATS("rx-bw-80", rx_stats.msdu_80);
 	PRINT_MY_STATS("rx-bw-160", rx_stats.msdu_160);
+	PRINT_MY_STATS("rx-bw-he-ru", rx_stats.msdu_he_ru);
 
 	PRINT_MY_STATS("rx-he-total", rx_stats.msdu_he_tot);
 	PRINT_MY_STATS("rx-he-su", rx_stats.msdu_he_su);
@@ -213,6 +214,27 @@ static ssize_t sta_stats_read(struct file *file, char __user *userbuf,
 		sprintf(tmp, "rx-rate-idx[%3i]", i);
 		PRINT_MY_STATS(tmp, rx_stats.msdu_rate_idx[i]);
 	}
+
+	len += scnprintf(buf + len, buf_len - len, "\n");
+	PRINT_MY_STATS("tx-bw-20", sta->tx_stats.msdu_20);
+	PRINT_MY_STATS("tx-bw-40", sta->tx_stats.msdu_40);
+	PRINT_MY_STATS("tx-bw-80", sta->tx_stats.msdu_80);
+	PRINT_MY_STATS("tx-bw-160", sta->tx_stats.msdu_160);
+	PRINT_MY_STATS("tx-bw-he-ru", sta->tx_stats.msdu_he_ru);
+
+	PRINT_MY_STATS("tx-vht", sta->tx_stats.msdu_vht);
+	PRINT_MY_STATS("tx-ht", sta->tx_stats.msdu_ht);
+	PRINT_MY_STATS("tx-legacy", sta->tx_stats.msdu_legacy);
+
+	for (i = 0; i < ARRAY_SIZE(sta->tx_stats.msdu_nss); i++) {
+		sprintf(tmp, "tx-msdu-nss[%i]", i);
+		PRINT_MY_STATS(tmp, sta->tx_stats.msdu_nss[i]);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(sta->tx_stats.msdu_rate_idx); i++) {
+		sprintf(tmp, "tx-rate-idx[%3i]", i);
+		PRINT_MY_STATS(tmp, sta->tx_stats.msdu_rate_idx[i]);
+	}
 #endif
 
 #undef PRINT_MY_STATS
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index c83428b5bb5a..be05abc77292 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1767,6 +1767,7 @@ static void ieee80211_update_data_rx_stats(struct ieee80211_rx_data *rx,
 		stats->msdu_160++;
 		break;
 	case RATE_INFO_BW_HE_RU:
+		stats->msdu_he_ru++;
 		stats->msdu_he_ru_alloc[status->he_ru]++;
 		break;
 	};
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 90fcebf199ad..6fc6ad6248e6 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -445,6 +445,7 @@ struct ieee80211_sta_rx_stats {
 	u32 msdu_40;
 	u32 msdu_80;
 	u32 msdu_160;
+	u32 msdu_he_ru;
 	u32 msdu_he_ru_alloc[NL80211_RATE_INFO_HE_RU_ALLOC_LAST];
 	u32 msdu_he_tot;
 	u32 msdu_he_su;
@@ -636,6 +637,21 @@ struct sta_info {
 		struct ieee80211_tx_rate last_rate;
 		struct rate_info last_rate_info;
 		u64 msdu[IEEE80211_NUM_TIDS + 1];
+#ifdef CONFIG_MAC80211_DEBUG_STA_COUNTERS
+		/* these take liberty with how things are defined, and are
+		 * designed to give a rough idea of how things are going.
+		 */
+		u32 msdu_20;
+		u32 msdu_40;
+		u32 msdu_80;
+		u32 msdu_160;
+		u32 msdu_he_ru;
+		u32 msdu_vht;
+		u32 msdu_ht;
+		u32 msdu_legacy;
+		u32 msdu_nss[8];
+		u32 msdu_rate_idx[13];
+#endif
 	} tx_stats;
 	u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
 
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 3460154cf4fe..e7ee13f82355 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -1112,6 +1112,9 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
 
 	if (pubsta) {
 		struct ieee80211_sub_if_data *sdata = sta->sdata;
+#ifdef CONFIG_MAC80211_DEBUG_STA_COUNTERS
+		bool do_stats = false;
+#endif
 
 		if (!acked && !noack_success)
 			sta->status_stats.retry_failed++;
@@ -1124,6 +1127,9 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
 							acked, info->status.tx_time);
 
 			if (acked) {
+#ifdef CONFIG_MAC80211_DEBUG_STA_COUNTERS
+				do_stats = true;
+#endif
 				sta->status_stats.last_ack = jiffies;
 
 				if (sta->status_stats.lost_packets)
@@ -1154,11 +1160,52 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
 				return;
 			} else if (noack_success) {
 				/* nothing to do here, do not account as lost */
+#ifdef CONFIG_MAC80211_DEBUG_STA_COUNTERS
+				do_stats = true;
+#endif
 			} else {
 				ieee80211_lost_packet(sta, info);
 			}
 		}
 
+#ifdef CONFIG_MAC80211_DEBUG_STA_COUNTERS
+		if (do_stats && (rates_idx != -1)) {
+			u8 nss = 0;
+			u8 mcs = 0;
+			struct ieee80211_tx_rate *txrt = &(info->status.rates[rates_idx]);
+			if (txrt->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+				sta->tx_stats.msdu_40++;
+			else if (txrt->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
+				sta->tx_stats.msdu_80++;
+			else if (txrt->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
+				sta->tx_stats.msdu_160++;
+			else
+				sta->tx_stats.msdu_20++;
+
+			if (txrt->flags & IEEE80211_TX_RC_MCS) {
+				nss = (txrt->idx / 8);
+				mcs = txrt->idx - (nss * 8);
+				sta->tx_stats.msdu_ht++;
+			}
+			else if (txrt->flags & IEEE80211_TX_RC_VHT_MCS) {
+				mcs = ieee80211_rate_get_vht_mcs(txrt);
+				nss = ieee80211_rate_get_vht_nss(txrt);
+				nss -= 1;
+				sta->tx_stats.msdu_vht++;
+			}
+			else {
+				mcs = txrt->idx;
+				sta->tx_stats.msdu_legacy++;
+			}
+
+			if (nss > (ARRAY_SIZE(sta->tx_stats.msdu_nss) - 1))
+				nss = ARRAY_SIZE(sta->tx_stats.msdu_nss) - 1;
+			if (mcs > (ARRAY_SIZE(sta->tx_stats.msdu_rate_idx) - 1))
+				mcs = ARRAY_SIZE(sta->tx_stats.msdu_rate_idx) - 1;
+			sta->tx_stats.msdu_nss[nss]++;
+			sta->tx_stats.msdu_rate_idx[mcs]++;
+		}
+#endif
 		rate_control_tx_status(local, sband, status);
 		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
 			ieee80211s_update_metric(local, sta, status);
-- 
2.20.1


  parent reply	other threads:[~2021-03-24 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 18:14 [PATCH-v2 1/6] mac80211: Fix station rx-packets counters greearb
2021-03-24 18:14 ` [PATCH-v2 2/6] mac80211: Provide per-station stats in debugfs greearb
2021-03-24 18:14 ` [PATCH-v2 3/6] mac80211: Provide detailed station rx stats greearb
2021-03-24 18:14 ` [PATCH-v2 4/6] mac80211: Add counters for specific HE encoding types greearb
2021-03-24 18:14 ` greearb [this message]
2021-03-24 18:14 ` [PATCH-v2 6/6] mac80211: last_rate is 32-bit number greearb
2021-04-01  4:26 ` [PATCH-v2 1/6] mac80211: Fix station rx-packets counters Ben Greear

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=20210324181441.13755-5-greearb@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-wireless@vger.kernel.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.