From patchwork Thu Apr 18 12:24:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karl Beldan X-Patchwork-Id: 2460381 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 05C643FD8C for ; Thu, 18 Apr 2013 12:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754450Ab3DRM3B (ORCPT ); Thu, 18 Apr 2013 08:29:01 -0400 Received: from mail-ea0-f178.google.com ([209.85.215.178]:59727 "EHLO mail-ea0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753903Ab3DRM3A (ORCPT ); Thu, 18 Apr 2013 08:29:00 -0400 Received: by mail-ea0-f178.google.com with SMTP id o10so1256512eaj.37 for ; Thu, 18 Apr 2013 05:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=IqcWbwvcR1/kaYR5U2jo2pV3wog0UNvk0bREQ5SBpR4=; b=LMYi+mFhU3+bLGnGcnsEnRberOEq1uoQVG1Q6ZQ1OdDXpwld0wG1jXv3HJTIRoIDXc 04vlgiqLo6RyJB8/8RRJjZ/Kc2q/aj8q7eufqoxm86XD3rqr3FCDB6R/fRb1qBkaaL7f Zo/ZMH8aWsekOXJB084kB4LdjqsDtD89y6RaCO98Qwchx/5vRWQnbmCjCE3Kthd2CUzC GZi8Y9CyKF1eQVrYFLWwp+wTjVXMiX9z1qzlOmnW0izEWJ2HOt78AUINoDJrxlD4VQX4 qM+iVei4p/G+UMFHsJk6gwa/fg6Y67SL6/D2t788SFNS4hSUKldzlZoXd57xzqCBd9xo B4ng== X-Received: by 10.14.104.6 with SMTP id h6mr29746655eeg.5.1366288139300; Thu, 18 Apr 2013 05:28:59 -0700 (PDT) Received: from magnum.frso.rivierawaves.com (vpn.rivierawaves.com. [91.151.119.162]) by mx.google.com with ESMTPS id u44sm15495974eel.7.2013.04.18.05.28.58 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 05:28:58 -0700 (PDT) From: Karl Beldan To: Johannes Berg Cc: linux-wireless , Karl Beldan , Karl Beldan , Felix Fietkau Subject: [PATCH 1/2] mac80211: minstrel_ht: pick only supported rates for sta and group max*rates Date: Thu, 18 Apr 2013 14:24:42 +0200 Message-Id: <1366287883-24054-1-git-send-email-karl.beldan@gmail.com> X-Mailer: git-send-email 1.8.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Karl Beldan minstrel_ht initializes max_tp_rate max_tp_rate2 and max_prob_rate to zero both for minstrel_ht_sta and minstrel_mcs_group_data. This is wrong since there is no guarantee that the 1st rate of any group is supported. Signed-off-by: Karl Beldan Acked-by: Felix Fietkau --- net/mac80211/rc80211_minstrel_ht.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index d2b264d..eb6dc3f 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -244,6 +244,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) struct minstrel_rate_stats *mr; int cur_prob, cur_prob_tp, cur_tp, cur_tp2; int group, i, index; + bool mi_rates_valid = false; if (mi->ampdu_packets > 0) { mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len, @@ -254,11 +255,10 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) mi->sample_slow = 0; mi->sample_count = 0; - mi->max_tp_rate = 0; - mi->max_tp_rate2 = 0; - mi->max_prob_rate = 0; for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { + bool mg_rates_valid = false; + cur_prob = 0; cur_prob_tp = 0; cur_tp = 0; @@ -268,15 +268,24 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) if (!mg->supported) continue; - mg->max_tp_rate = 0; - mg->max_tp_rate2 = 0; - mg->max_prob_rate = 0; mi->sample_count++; for (i = 0; i < MCS_GROUP_RATES; i++) { if (!(mg->supported & BIT(i))) continue; + /* initialize rates selections starting indexes */ + if (!mg_rates_valid) { + mg->max_tp_rate = mg->max_tp_rate2 = + mg->max_prob_rate = i; + if (!mi_rates_valid) { + mi->max_tp_rate = mi->max_tp_rate2 = + mi->max_prob_rate = i; + mi_rates_valid = true; + } + mg_rates_valid = true; + } + mr = &mg->rates[i]; mr->retry_updated = false; index = MCS_GROUP_RATES * group + i;