From patchwork Tue Sep 4 06:45:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anilkumar Kolli X-Patchwork-Id: 10586755 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E929D112B for ; Tue, 4 Sep 2018 06:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7D6D28C31 for ; Tue, 4 Sep 2018 06:43:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC3FE28F2B; Tue, 4 Sep 2018 06:43:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70E7228C31 for ; Tue, 4 Sep 2018 06:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727507AbeIDLHF (ORCPT ); Tue, 4 Sep 2018 07:07:05 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54972 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbeIDLHF (ORCPT ); Tue, 4 Sep 2018 07:07:05 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 76505607B5; Tue, 4 Sep 2018 06:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536043403; bh=FGe9qDTfwrav9MNx/VTeUF43s4A/pmuNINgPsFQ9pgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jVid0fK8MeStiWaq3luPwZ08Z67H7XrR/Uot5Np8blpvH7w+PK2i/+VAF2rq4J6V5 6G4lWd7Kj3ENDejpSXh6AwPUXTADoQemq4Iw25Hb9Lm0Nt9dUR5xaJcGefkFmc+FgE 5jrgxS3zdjO/DzHAZUVj0u/n6HvqPRpxmX46lSGw= Received: from localhost (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: akolli@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1B0EE606CF; Tue, 4 Sep 2018 06:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536043402; bh=FGe9qDTfwrav9MNx/VTeUF43s4A/pmuNINgPsFQ9pgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HUPgkMSSxGhA/e2/eVkF+DZjMY9X0hi0wWdVoKAaXi1f6WRFSKH0kuTZsk5humOnj uW6jXr9cK/Qxpzd2hTVoHZKwoURmYlIUmYVtua/3K5UcqGQYTSqHS2IDJRDOgJ8zl/ FACsJefjbr1cOyx5OvBGe67Z3UOVwuxuiLOUSGXw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1B0EE606CF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=akolli@codeaurora.org From: akolli@codeaurora.org To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Anilkumar Kolli Subject: [PATCHv2 1/4] ath10k: get the legacy rate index to update the txrate table Date: Tue, 4 Sep 2018 12:15:13 +0530 Message-Id: <1536043516-12462-2-git-send-email-akolli@codeaurora.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1536043516-12462-1-git-send-email-akolli@codeaurora.org> References: <1536043516-12462-1-git-send-email-akolli@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anilkumar Kolli Get the legacy rate index to update the pkts/bytes counter against each possible tx rate. Signed-off-by: Anilkumar Kolli --- drivers/net/wireless/ath/ath10k/htt_rx.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 4d1cd90d6d27..01eb4a7f4a69 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -2488,7 +2488,7 @@ void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) dev_kfree_skb_any(skb); } -static inline bool is_valid_legacy_rate(u8 rate) +static inline int ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate) { static const u8 legacy_rates[] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54}; @@ -2496,10 +2496,11 @@ static inline bool is_valid_legacy_rate(u8 rate) for (i = 0; i < ARRAY_SIZE(legacy_rates); i++) { if (rate == legacy_rates[i]) - return true; + return i; } - return false; + ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", rate); + return -EINVAL; } static void @@ -2508,7 +2509,7 @@ static inline bool is_valid_legacy_rate(u8 rate) struct ath10k_per_peer_tx_stats *peer_stats) { struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; - u8 rate = 0, sgi; + u8 rate = 0, rate_idx = 0, sgi; struct rate_info txrate; lockdep_assert_held(&ar->data_lock); @@ -2536,17 +2537,12 @@ static inline bool is_valid_legacy_rate(u8 rate) if (txrate.flags == WMI_RATE_PREAMBLE_CCK || txrate.flags == WMI_RATE_PREAMBLE_OFDM) { rate = ATH10K_HW_LEGACY_RATE(peer_stats->ratecode); - - if (!is_valid_legacy_rate(rate)) { - ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", - rate); - return; - } - /* This is hacky, FW sends CCK rate 5.5Mbps as 6 */ - rate *= 10; - if (rate == 60 && txrate.flags == WMI_RATE_PREAMBLE_CCK) - rate = rate - 5; + if (rate == 6 && txrate.flags == WMI_RATE_PREAMBLE_CCK) + rate = 5; + rate_idx = ath10k_get_legacy_rate_idx(ar, rate); + if (rate_idx < 0) + return; arsta->txrate.legacy = rate; } else if (txrate.flags == WMI_RATE_PREAMBLE_HT) { arsta->txrate.flags = RATE_INFO_FLAGS_MCS;