From patchwork Thu Apr 4 19:57:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2394691 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AD9303FD8C for ; Thu, 4 Apr 2013 20:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763613Ab3DDUDt (ORCPT ); Thu, 4 Apr 2013 16:03:49 -0400 Received: from ht2.myhostedexchange.com ([69.50.2.38]:20908 "EHLO ht1.hostedexchange.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1763426Ab3DDUDt (ORCPT ); Thu, 4 Apr 2013 16:03:49 -0400 X-Greylist: delayed 304 seconds by postgrey-1.27 at vger.kernel.org; Thu, 04 Apr 2013 16:03:49 EDT Received: from eagle4.ritirata.org (88.149.161.239) by ht2.hostedexchange.local (172.16.69.40) with Microsoft SMTP Server id 8.3.298.1; Thu, 4 Apr 2013 12:58:45 -0700 From: Antonio Quartulli To: Johannes Berg CC: , Antonio Quartulli Subject: [PATCH 2/3] mac80211: add rate_control_ops::get_max_tp() and implement it Date: Thu, 4 Apr 2013 21:57:21 +0200 Message-ID: <1365105442-31876-2-git-send-email-antonio@open-mesh.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1365105442-31876-1-git-send-email-antonio@open-mesh.com> References: <1365105442-31876-1-git-send-email-antonio@open-mesh.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- 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, };