From patchwork Fri Aug 10 11:16:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sujith Manoharan X-Patchwork-Id: 1305021 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F0BBADF215 for ; Fri, 10 Aug 2012 11:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751804Ab2HJLR7 (ORCPT ); Fri, 10 Aug 2012 07:17:59 -0400 Received: from wolverine01.qualcomm.com ([199.106.114.254]:63219 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151Ab2HJLR6 (ORCPT ); Fri, 10 Aug 2012 07:17:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qca.qualcomm.com; i=@qca.qualcomm.com; q=dns/txt; s=qcdkim; t=1344597479; x=1376133479; h=from:mime-version:content-transfer-encoding:message-id: date:to:cc:subject; bh=JlNXSOuGZkH1DlqUlNx/fh1+uCCz+d9IV7B/mUtKLew=; b=anZn7fOmZTDJ/xNqHD43zSPQCwr5bAqr62vkrOVbBHLpwcFgeUwXSRWh zSQ2AoO6riOhVVFDCm4T/uqMKxEch6kcOstKezmIzpjiikak5AuL39bZw wVq6uJlJAVL03DhF02Y3hDI1hcL7vB0zIUnCmk9dV5N5l6i1lMp3GrPl2 s=; X-IronPort-AV: E=McAfee;i="5400,1158,6798"; a="223736244" Received: from ironmsg02-r.qualcomm.com ([172.30.46.16]) by wolverine01.qualcomm.com with ESMTP; 10 Aug 2012 04:17:59 -0700 X-IronPort-AV: E=Sophos;i="4.77,745,1336374000"; d="scan'208";a="160382245" Received: from nasanexhc04.na.qualcomm.com ([172.30.48.17]) by ironmsg02-R.qualcomm.com with ESMTP/TLS/RC4-SHA; 10 Aug 2012 04:17:59 -0700 Received: from alfalfa (172.30.48.1) by qcmail1.qualcomm.com (172.30.48.17) with Microsoft SMTP Server (TLS) id 14.2.309.2; Fri, 10 Aug 2012 04:17:57 -0700 From: Sujith Manoharan MIME-Version: 1.0 Message-ID: <20516.60828.201025.657272@gargle.gargle.HOWL> Date: Fri, 10 Aug 2012 16:46:44 +0530 To: X-Mailer: VM 8.2.0b under 24.1.1 (x86_64-unknown-linux-gnu) CC: Subject: [PATCH 08/15] ath9k: Unify valid rate calculation routines X-Originating-IP: [172.30.48.1] Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Sujith Manoharan --- drivers/net/wireless/ath/ath9k/rc.c | 74 +++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index 8a5fc62..ed48d3d 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -504,50 +504,49 @@ static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv) return hi; } -static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv) +static inline bool ath_rc_check_legacy(u8 rate, u8 dot11rate, u16 rate_flags, + u32 phy, u32 capflag) { - const struct ath_rate_table *rate_table = ath_rc_priv->rate_table; - struct ath_rateset *rateset = &ath_rc_priv->neg_rates; - u32 phy, capflag = ath_rc_priv->ht_cap; - u16 rate_flags; - u8 i, j, hi = 0, rate, dot11rate, valid_rate_count; + if (rate != dot11rate || WLAN_RC_PHY_HT(phy)) + return false; - for (i = 0; i < rateset->rs_nrates; i++) { - for (j = 0; j < rate_table->rate_cnt; j++) { - phy = rate_table->info[j].phy; - rate_flags = rate_table->info[j].rate_flags; - rate = rateset->rs_rates[i]; - dot11rate = rate_table->info[j].dot11rate; + if ((rate_flags & WLAN_RC_CAP_MODE(capflag)) != WLAN_RC_CAP_MODE(capflag)) + return false; - if (rate != dot11rate - || ((rate_flags & WLAN_RC_CAP_MODE(capflag)) != - WLAN_RC_CAP_MODE(capflag)) - || !(rate_flags & WLAN_RC_CAP_STREAM(capflag)) - || WLAN_RC_PHY_HT(phy)) - continue; + if (!(rate_flags & WLAN_RC_CAP_STREAM(capflag))) + return false; - if (!ath_rc_valid_phyrate(phy, capflag, 0)) - continue; + return true; +} - valid_rate_count = ath_rc_priv->valid_phy_ratecnt[phy]; - ath_rc_priv->valid_phy_rateidx[phy][valid_rate_count] = j; - ath_rc_priv->valid_phy_ratecnt[phy] += 1; - ath_rc_priv->valid_rate_index[j] = true; - hi = max(hi, j); - } - } +static inline bool ath_rc_check_ht(u8 rate, u8 dot11rate, u16 rate_flags, + u32 phy, u32 capflag) +{ + if (rate != dot11rate || !WLAN_RC_PHY_HT(phy)) + return false; - return hi; + if (!WLAN_RC_PHY_HT_VALID(rate_flags, capflag)) + return false; + + if (!(rate_flags & WLAN_RC_CAP_STREAM(capflag))) + return false; + + return true; } -static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv) +static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv, bool legacy) { const struct ath_rate_table *rate_table = ath_rc_priv->rate_table; - struct ath_rateset *rateset = &ath_rc_priv->neg_ht_rates; + struct ath_rateset *rateset; u32 phy, capflag = ath_rc_priv->ht_cap; u16 rate_flags; u8 i, j, hi = 0, rate, dot11rate, valid_rate_count; + if (legacy) + rateset = &ath_rc_priv->neg_rates; + else + rateset = &ath_rc_priv->neg_ht_rates; + for (i = 0; i < rateset->rs_nrates; i++) { for (j = 0; j < rate_table->rate_cnt; j++) { phy = rate_table->info[j].phy; @@ -555,9 +554,14 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv) rate = rateset->rs_rates[i]; dot11rate = rate_table->info[j].dot11rate; - if ((rate != dot11rate) || !WLAN_RC_PHY_HT(phy) || - !(rate_flags & WLAN_RC_CAP_STREAM(capflag)) || - !WLAN_RC_PHY_HT_VALID(rate_flags, capflag)) + if (legacy && + !ath_rc_check_legacy(rate, dot11rate, + rate_flags, phy, capflag)) + continue; + + if (!legacy && + !ath_rc_check_ht(rate, dot11rate, + rate_flags, phy, capflag)) continue; if (!ath_rc_valid_phyrate(phy, capflag, 0)) @@ -1181,10 +1185,10 @@ static void ath_rc_init(struct ath_softc *sc, if (!rateset->rs_nrates) { hi = ath_rc_init_validrates(ath_rc_priv); } else { - hi = ath_rc_setvalid_rates(ath_rc_priv); + hi = ath_rc_setvalid_rates(ath_rc_priv, true); if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG) - hthi = ath_rc_setvalid_htrates(ath_rc_priv); + hthi = ath_rc_setvalid_rates(ath_rc_priv, false); hi = max(hi, hthi); }