From patchwork Wed Oct 22 16:20:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karl Beldan X-Patchwork-Id: 5135621 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41062C11AC for ; Wed, 22 Oct 2014 16:22:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16656201EF for ; Wed, 22 Oct 2014 16:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CE5820127 for ; Wed, 22 Oct 2014 16:21:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751445AbaJVQVz (ORCPT ); Wed, 22 Oct 2014 12:21:55 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:38201 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750754AbaJVQVy (ORCPT ); Wed, 22 Oct 2014 12:21:54 -0400 Received: by mail-wg0-f41.google.com with SMTP id b13so4190095wgh.12 for ; Wed, 22 Oct 2014 09:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=evcdTCmq5GbVYUUATnIL2CTHyQr2jWvGTwf2C6+9D14=; b=oFiEnp3xfAx+IjZj4/amk/UiFUg7aDF0ujjgXc0YYeaOsfRUqvQJ7K5LRSL9PbNSA6 8Cjs9MKsWDcXZ1vBzi/fKg507FMDS3KZErZqkhugZoRL3hLvbBKlA4gnP+D4WLrpZ6Uj FssE1eV+PZrWDW8K++aRTT25s/W2eS8Ih6M9x92oyJvbGzFuKS1IA0UbGgu3SWUWH0sr LIL7QJAxf6z02U0ubLUk4R13th1NJa8CelYpCfhr305tjVrI5zolxQxEYI6Jd+nKTXg8 aRdnd5viVuW58qR37S0HUU1hjsGdKZrK3+8puP8RSC52VEu+3jH4X6CSHU9yR6Yc8pF9 WaQw== X-Received: by 10.180.95.41 with SMTP id dh9mr4192475wib.0.1413994912055; Wed, 22 Oct 2014 09:21:52 -0700 (PDT) Received: from magnum.frso.rivierawaves.com (vpn.rivierawaves.com. [91.151.119.162]) by mx.google.com with ESMTPSA id fm10sm2424784wib.21.2014.10.22.09.21.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Oct 2014 09:21:51 -0700 (PDT) From: Karl Beldan To: Johannes Berg Cc: linux-wireless , Karl Beldan , Felix Fietkau Subject: [PATCH] mac80211: minstrel_ht: use group flags instead of index to display rates Date: Wed, 22 Oct 2014 18:20:37 +0200 Message-Id: <1413994837-3944-1-git-send-email-karl.beldan@gmail.com> X-Mailer: git-send-email 2.0.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Karl Beldan When displaying a rate through debugfs minstrel_ht guesses its flags comparing group indexes. Since 3ec373c421b6 ("mac80211: minstrel_ht: include type (cck/ht) in rates flag"), the rate flags of interest are present in the mcs_group-s, so use it. While improving the code, this also fixes a smatch false positive "error: testing array offset 'i' after use" in minstrel_ht_stats_dump. This warning only triggers after 9208247d74bc ("mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz") with CONFIG_MAC80211_RC_MINSTREL_VHT unset because then MINSTREL_VHT_GROUP_0 is above MINSTREL_GROUPS_NB and smatch only barks when the "testing array offset" seems to prevent possible out of bonds accesses (which does not happen here since i < ARRAY_SIZE(mi->groups)). Signed-off-by: Karl Beldan Cc: Felix Fietkau --- net/mac80211/rc80211_minstrel_ht_debugfs.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c index 52bb6ef..20c676b 100644 --- a/net/mac80211/rc80211_minstrel_ht_debugfs.c +++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c @@ -22,16 +22,19 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) unsigned int j, tp, prob, eprob; char htmode = '2'; char gimode = 'L'; + u32 gflags; if (!mi->groups[i].supported) return p; mg = &minstrel_mcs_groups[i]; - if (mg->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + gflags = mg->flags; + + if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) htmode = '4'; - else if (mg->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) + else if (gflags & IEEE80211_TX_RC_80_MHZ_WIDTH) htmode = '8'; - if (mg->flags & IEEE80211_TX_RC_SHORT_GI) + if (gflags & IEEE80211_TX_RC_SHORT_GI) gimode = 'S'; for (j = 0; j < MCS_GROUP_RATES; j++) { @@ -42,12 +45,12 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) if (!(mi->groups[i].supported & BIT(j))) continue; - if (i == MINSTREL_CCK_GROUP) - p += sprintf(p, " CCK/%cP ", j < 4 ? 'L' : 'S'); - else if (i >= MINSTREL_VHT_GROUP_0) + if (gflags & IEEE80211_TX_RC_MCS) + p += sprintf(p, " HT%c0/%cGI ", htmode, gimode); + else if (gflags & IEEE80211_TX_RC_VHT_MCS) p += sprintf(p, "VHT%c0/%cGI ", htmode, gimode); else - p += sprintf(p, " HT%c0/%cGI ", htmode, gimode); + p += sprintf(p, " CCK/%cP ", j < 4 ? 'L' : 'S'); *(p++) = (idx == mi->max_tp_rate[0]) ? 'A' : ' '; *(p++) = (idx == mi->max_tp_rate[1]) ? 'B' : ' '; @@ -55,13 +58,14 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) *(p++) = (idx == mi->max_tp_rate[3]) ? 'D' : ' '; *(p++) = (idx == mi->max_prob_rate) ? 'P' : ' '; - if (i == MINSTREL_CCK_GROUP) { - int r = bitrates[j % 4]; - p += sprintf(p, " %2u.%1uM ", r / 10, r % 10); - } else if (i >= MINSTREL_VHT_GROUP_0) { + if (gflags & IEEE80211_TX_RC_MCS) { + p += sprintf(p, " MCS%-2u ", (mg->streams - 1) * 8 + j); + } else if (gflags & IEEE80211_TX_RC_VHT_MCS) { p += sprintf(p, " MCS%-1u/%1u", j, mg->streams); } else { - p += sprintf(p, " MCS%-2u ", (mg->streams - 1) * 8 + j); + int r = bitrates[j % 4]; + + p += sprintf(p, " %2u.%1uM ", r / 10, r % 10); } tp = mr->cur_tp / 10;