From patchwork Fri Mar 20 13:54:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 6056961 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9FE68BF910 for ; Fri, 20 Mar 2015 13:57:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B92992052C for ; Fri, 20 Mar 2015 13:57:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B393320528 for ; Fri, 20 Mar 2015 13:57:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYxQV-0006q1-HN; Fri, 20 Mar 2015 13:57:27 +0000 Received: from mail-lb0-x236.google.com ([2a00:1450:4010:c04::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYxQN-0006dt-HV for ath10k@lists.infradead.org; Fri, 20 Mar 2015 13:57:20 +0000 Received: by lbbsy1 with SMTP id sy1so75919509lbb.1 for ; Fri, 20 Mar 2015 06:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=isvfbgFnyzqXT5yFyd3uRaaJdzsc4jr4IdRszoVH690=; b=kC3RiOUf5YPsxvAoAs2TtOVWoKkBuur2RTUNPthdG6TGyKfm3KSsW5Bf5a1n48oUj5 9SZKbaMZz4APF9AMFrim2wkGB8MHmtud4iu5tK5cnz9hydwTfCzXbtw/Oq2LtCYwtYDz H4LtqLi+ePtJJkNayDXsbQBPRsR3+Ic1EEL0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=isvfbgFnyzqXT5yFyd3uRaaJdzsc4jr4IdRszoVH690=; b=apenb2eQV/4dxIWvfxSFm3Hx+kfEwh0OKyA2bn+pyUjbX1ZLjc7YH9/KBPMHMgiT0K ojrp6HeuEsCmiNT94gG7L8N4T8mnTtP1i6masadnGjCw0CmZlKJ/edYynTk2MUOqh3ac 3tBPytJ9PC0iDorGIm7ydYnsNGdaivaN6GR32YYDVztlpxCL5VJwi79DuSlSbAw1SoXH DxrCh5JLWxC/nWD4+DIUPHvyJRHdJz3rLod+RrD4Z8hfIZZBsLHomLCFhYMFYBgBGH1c Be3eXSH8bN7q9/i2wLsuinwQTKOVLBgmWQwtAvwW1rZLNM9qMf4Wx9GFca31iO8azLwj Hi+Q== X-Gm-Message-State: ALoCoQkG9kh7ai6V24rp6hMh3bnUZFrteyTdEglq6Udnqfut74A2EbGhhdbhV9bAgClZFwZk/BVDkVa6CRi3wN9Z66lLbvHKh4cH/Dt41a0BFrmsCI987gJ9OP/jBb45lRD2nhjnwasqru2id9XQjneuUNj+0+Hk0MurZDACl6bpQtzrHEWe27s= X-Received: by 10.152.178.197 with SMTP id da5mr75090991lac.56.1426859817219; Fri, 20 Mar 2015 06:56:57 -0700 (PDT) Received: from bob.homerouter.cpe (apn-77-113-71-242.dynamic.gprs.plus.pl. [77.113.71.242]) by mx.google.com with ESMTPSA id us1sm955771lbc.1.2015.03.20.06.56.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Mar 2015 06:56:56 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Subject: [PATCH 8/9] ath10k: deduplicate bitrate to rate idx conversion Date: Fri, 20 Mar 2015 13:54:14 +0000 Message-Id: <1426859655-11797-9-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426859655-11797-1-git-send-email-michal.kazior@tieto.com> References: <1426859655-11797-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150320_065719_859432_ABAF998E X-CRM114-Status: GOOD ( 13.50 ) X-Spam-Score: -0.8 (/) Cc: linux-wireless@vger.kernel.org, Michal Kazior X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 It's possible to derive rate index from bitrate without any additional mapping structures/logic. This should have little to none impact on performance since this is only done for management frames and the previous approach wasn't particularly optimized. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/mac.c | 12 +++++++ drivers/net/wireless/ath/ath10k/mac.h | 3 ++ drivers/net/wireless/ath/ath10k/wmi.c | 62 +++-------------------------------- 3 files changed, 19 insertions(+), 58 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index e1902e3..c39a300 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -103,6 +103,18 @@ u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband, return 0; } +u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband, + u32 bitrate) +{ + int i; + + for (i = 0; i < sband->n_bitrates; i++) + if (sband->bitrates[i].bitrate == bitrate) + return i; + + return 0; +} + /**********/ /* Crypto */ /**********/ diff --git a/drivers/net/wireless/ath/ath10k/mac.h b/drivers/net/wireless/ath/ath10k/mac.h index e615490..e7df017 100644 --- a/drivers/net/wireless/ath/ath10k/mac.h +++ b/drivers/net/wireless/ath/ath10k/mac.h @@ -47,8 +47,11 @@ bool ath10k_mac_is_peer_wep_key_set(struct ath10k *ar, const u8 *addr, u8 keyidx); void ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb); void ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id); + u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband, u8 hw_rate); +u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband, + u32 bitrate); static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif) { diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 54430a1..bd7a119 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -1352,63 +1352,6 @@ static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode) return band; } -static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band) -{ - u8 rate_idx = 0; - - /* rate in Kbps */ - switch (rate) { - case 1000: - rate_idx = 0; - break; - case 2000: - rate_idx = 1; - break; - case 5500: - rate_idx = 2; - break; - case 11000: - rate_idx = 3; - break; - case 6000: - rate_idx = 4; - break; - case 9000: - rate_idx = 5; - break; - case 12000: - rate_idx = 6; - break; - case 18000: - rate_idx = 7; - break; - case 24000: - rate_idx = 8; - break; - case 36000: - rate_idx = 9; - break; - case 48000: - rate_idx = 10; - break; - case 54000: - rate_idx = 11; - break; - default: - break; - } - - if (band == IEEE80211_BAND_5GHZ) { - if (rate_idx > 3) - /* Omit CCK rates */ - rate_idx -= 4; - else - rate_idx = 0; - } - - return rate_idx; -} - /* If keys are configured, HW decrypts all frames * with protected bit set. Mark such frames as decrypted. */ @@ -1490,6 +1433,7 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) struct wmi_mgmt_rx_ev_arg arg = {}; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); struct ieee80211_hdr *hdr; + struct ieee80211_supported_band *sband; u32 rx_status; u32 channel; u32 phy_mode; @@ -1560,9 +1504,11 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ) ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n"); + sband = &ar->mac.sbands[status->band]; + status->freq = ieee80211_channel_to_frequency(channel, status->band); status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR; - status->rate_idx = get_rate_idx(rate, status->band); + status->rate_idx = ath10k_mac_bitrate_to_idx(sband, rate / 100); hdr = (struct ieee80211_hdr *)skb->data; fc = le16_to_cpu(hdr->frame_control);