Search Linux Wireless

[PATCH 2/3] mac80211: add rate_control_ops::get_max_tp() and implement it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This new API is aimed to return the maximum throughput
estimated by a rate control algorithm towards a given peer.

The API is implemented for minstrel and minstrel_ht.

Signed-off-by: Antonio Quartulli <antonio@xxxxxxxxxxxxx>
---
 include/net/mac80211.h             |  2 ++
 net/mac80211/rc80211_minstrel.c    |  9 +++++++++
 net/mac80211/rc80211_minstrel_ht.c | 21 +++++++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 64faf01..5a1b7c2 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4147,6 +4147,8 @@ struct rate_control_ops {
 	void (*add_sta_debugfs)(void *priv, void *priv_sta,
 				struct dentry *dir);
 	void (*remove_sta_debugfs)(void *priv, void *priv_sta);
+
+	void (*get_max_tp)(void *priv_sta, u32 *tp);
 };
 
 static inline int rate_supported(struct ieee80211_sta *sta,
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 1c36c9b..7af6884 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -604,6 +604,14 @@ minstrel_free(void *priv)
 	kfree(priv);
 }
 
+static void minstrel_get_max_tp(void *priv_sta, u32 *tp)
+{
+	struct minstrel_sta_info *mi = priv_sta;
+	int idx = mi->max_tp_rate[0];
+
+	*tp = MINSTREL_TRUNC(mi->r[idx].cur_tp / 10);
+}
+
 struct rate_control_ops mac80211_minstrel = {
 	.name = "minstrel",
 	.tx_status = minstrel_tx_status,
@@ -617,6 +625,7 @@ struct rate_control_ops mac80211_minstrel = {
 	.add_sta_debugfs = minstrel_add_sta_debugfs,
 	.remove_sta_debugfs = minstrel_remove_sta_debugfs,
 #endif
+	.get_max_tp = minstrel_get_max_tp,
 };
 
 int __init
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index d2b264d..421c770 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -960,6 +960,26 @@ error:
 	return NULL;
 }
 
+static void minstrel_ht_get_max_tp(void *priv_sta, u32 *tp)
+{
+	struct minstrel_ht_sta_priv *msp = priv_sta;
+	struct minstrel_ht_sta *mi = &msp->ht;
+	struct minstrel_rate_stats *mr;
+	int i, j;
+
+	if (!msp->is_ht) {
+		mac80211_minstrel.get_max_tp(priv_sta, tp);
+		return;
+	}
+
+	i = mi->max_tp_rate / MCS_GROUP_RATES;
+	j = mi->max_tp_rate % MCS_GROUP_RATES;
+
+	mr = &mi->groups[i].rates[j];
+
+	*tp = mr->cur_tp / 10;
+}
+
 static void
 minstrel_ht_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta)
 {
@@ -996,6 +1016,7 @@ static struct rate_control_ops mac80211_minstrel_ht = {
 	.add_sta_debugfs = minstrel_ht_add_sta_debugfs,
 	.remove_sta_debugfs = minstrel_ht_remove_sta_debugfs,
 #endif
+	.get_max_tp = minstrel_ht_get_max_tp,
 };
 
 
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux