From patchwork Fri Sep 29 19:47:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9978585 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.web.codeaurora.org (Postfix) with ESMTP id 6061E60329 for ; Fri, 29 Sep 2017 19:48:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51466298AE for ; Fri, 29 Sep 2017 19:48:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 431CC298B1; Fri, 29 Sep 2017 19:48:18 +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=-4.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID, URIBL_BLACK 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 DA01C298AF for ; Fri, 29 Sep 2017 19:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752552AbdI2TsP (ORCPT ); Fri, 29 Sep 2017 15:48:15 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:33003 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752433AbdI2TsM (ORCPT ); Fri, 29 Sep 2017 15:48:12 -0400 Received: by mail-oi0-f68.google.com with SMTP id n129so297065oia.0 for ; Fri, 29 Sep 2017 12:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=aI9q38yN5VBlTNsKUUTr+M2BwFihZZ1/AmDw9PEPY1A=; b=gcAYTDRo7FFSA5TqcGqUdWkZDvLckdvP66uEP3GXfcz40wzdK93BiQjGG2c3tHsciJ tC5yLLd0gH0+oN/HLtmfb1znuvE5YrFl4DOO51Ey5ZudbdTqHA+5I3HATNBFQMUwAGjQ /Ma7TCxANKlHZE/SjA2fgE462AlCMZO564kte7nutxfbZxGFqMTJroOD5eCe0cCmo8b6 HxV3vJpUQ+vqBbIYp21r0PCyy0eHbzfS3khVH0922hCFGyRvvHj2mFOjMDcHzxQkYrRV 7XfLVTRKKC1Zf0gUXSU0l2Fqwujlz7LyPWsLhGimAOh6R6NClxGPKXr1KwpHG8RFltvU kHAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=aI9q38yN5VBlTNsKUUTr+M2BwFihZZ1/AmDw9PEPY1A=; b=pkO/9Z2Al2QGTwxrltNKznDj9+CeWfMfIhBEDm/r8J8s9ERCPGFxc2t3qjYX1DgcZP fJ/UKtvwZ7zh+Q6St/DqWahW6zpSO6Yml6Avae+CN0AMz2oZXaYwNVQOPq3rn6K+cxLf f6L4kJli5+LHlEENmVLmycvl1GK2rJiJh8AnKzoJ6lyJJq+EJ8IqvRrujD4Om06ELh5+ VnNAI2JFpZFAMlWSucHNwGu34NuP2SdrqYxbqXXdbfYITQxF3YuxxFMxwi76l0sf+2u3 bVRMs8O5xw8AmCJZY2CblJF8ueC9/gCntUs0jDxjILOFZyLaxKK/tJqnvOy52xzzcwPb fDYQ== X-Gm-Message-State: AMCzsaWceK/JqixdgKgX9aRHTfNLBUUc109dnwk/7++hOmQBWLj1hhPG +ftgTXgvJysSX+IYTHFDIy0= X-Google-Smtp-Source: AOwi7QC5fQffAfK1q9Y7OeUEtturuvFSaVCRBFc2bmCcy8DGV4/DHeid4eWadDkeWTpTKjS1YHicDQ== X-Received: by 10.157.5.10 with SMTP id 10mr4044557otw.350.1506714491552; Fri, 29 Sep 2017 12:48:11 -0700 (PDT) Received: from Larrylap.localdomain (cpe-24-31-251-255.kc.res.rr.com. [24.31.251.255]) by smtp.gmail.com with ESMTPSA id v14sm2311062oif.39.2017.09.29.12.48.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 12:48:11 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, Ping-Ke Shih , Larry Finger , Yan-Hsuan Chuang , Birming Chiu , Shaofu , Steven Ting Subject: [PATCH 04/10] rtlwifi: Implement rtl_get_tx_hw_rate to yield correct hw_rate Date: Fri, 29 Sep 2017 14:47:54 -0500 Message-Id: <20170929194800.15617-5-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170929194800.15617-1-Larry.Finger@lwfinger.net> References: <20170929194800.15617-1-Larry.Finger@lwfinger.net> 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: Ping-Ke Shih Originally, we get legacy rate only, so we extend to get HT and VHT rate. Signed-off-by: Ping-Ke Shih Signed-off-by: Larry Finger Cc: Yan-Hsuan Chuang Cc: Birming Chiu Cc: Shaofu Cc: Steven Ting --- drivers/net/wireless/realtek/rtlwifi/base.c | 42 ++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c index fcf6e31d0fb9..e37d4c765f87 100644 --- a/drivers/net/wireless/realtek/rtlwifi/base.c +++ b/drivers/net/wireless/realtek/rtlwifi/base.c @@ -1099,6 +1099,42 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht, bool isvht, } EXPORT_SYMBOL(rtlwifi_rate_mapping); +static u8 _rtl_get_tx_hw_rate(struct ieee80211_hw *hw, + struct ieee80211_tx_info *info) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct ieee80211_tx_rate *r = &info->status.rates[0]; + struct ieee80211_rate *txrate; + u8 hw_value = 0x0; + + if (r->flags & IEEE80211_TX_RC_MCS) { + /* HT MCS0-15 */ + hw_value = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15] - 15 + + r->idx; + } else if (r->flags & IEEE80211_TX_RC_VHT_MCS) { + /* VHT MCS0-9, NSS */ + if (ieee80211_rate_get_vht_nss(r) == 2) + hw_value = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9]; + else + hw_value = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9]; + + hw_value = hw_value - 9 + ieee80211_rate_get_vht_mcs(r); + } else { + /* legacy */ + txrate = ieee80211_get_tx_rate(hw, info); + + if (txrate) + hw_value = txrate->hw_value; + } + + /* check 5G band */ + if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G && + hw_value < rtlpriv->cfg->maps[RTL_RC_OFDM_RATE6M]) + hw_value = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE6M]; + + return hw_value; +} + void rtl_get_tcb_desc(struct ieee80211_hw *hw, struct ieee80211_tx_info *info, struct ieee80211_sta *sta, @@ -1107,12 +1143,10 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw)); struct ieee80211_hdr *hdr = rtl_get_hdr(skb); - struct ieee80211_rate *txrate; + __le16 fc = rtl_get_fc(skb); - txrate = ieee80211_get_tx_rate(hw, info); - if (txrate) - tcb_desc->hw_rate = txrate->hw_value; + tcb_desc->hw_rate = _rtl_get_tx_hw_rate(hw, info); if (rtl_is_tx_report_skb(hw, skb)) tcb_desc->use_spe_rpt = 1;