From patchwork Mon Jul 3 18:40:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9823821 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 A6653604D9 for ; Mon, 3 Jul 2017 18:41:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B7052856D for ; Mon, 3 Jul 2017 18:41:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 903D0285F2; Mon, 3 Jul 2017 18:41:08 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 300142856D for ; Mon, 3 Jul 2017 18:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754318AbdGCSlG (ORCPT ); Mon, 3 Jul 2017 14:41:06 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34230 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754158AbdGCSku (ORCPT ); Mon, 3 Jul 2017 14:40:50 -0400 Received: by mail-oi0-f65.google.com with SMTP id d77so20095247oig.1 for ; Mon, 03 Jul 2017 11:40:50 -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=4hJOgP3DbJlOilB+pAcWnRzdctp/n74/9JBHOfKVW/k=; b=tm5HIiGV2WuybRiF4XSAGfRvCeFV4TgpjEdBpJTFPG1UVM53PAdhLihR21EvINYhBO jM7RUh4OSqD8OWXItUWyc3K8TfUTw+4MCA5gUeD/Fq5bD/9wspgZsB23lWo5pVcFTNsY DT2MhYFV/PifL/GCWnHi6PqEhPTY55EEe0iociP9T73b6QNQhqCgo4nfr7tu0+v52Jrg IOq1KiBh3BDoGfaxQb8VsmxjpN9VYRAdoXI9cxF1tSU2IVKcUw4TAVagMyJtOXjeZMKK 2SEjR7K86c7Wis28k5TY0y0wfS8taLNK+xOxFXECr1Qu0rAWFSieK32fu+yxGNBzAbXP 8muA== 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=4hJOgP3DbJlOilB+pAcWnRzdctp/n74/9JBHOfKVW/k=; b=pUo78t8hwu3AiAxyD6SfUws+DwxC1fDDU2Kes4pv0Y6kd9QBQ6nXW403H6iFU2sPx6 tiuNTHg7dium2q0UsIr6wsKKZ2rXidDur1nf4v+i5qU85kUE1Yrj4yFQB1WY5h8+SQqP Gd8pWFcW5ewNb+1uYLRPPcw8ZO6B4w2175Ol/DUrvFZdp6Tq2lP/BAzJGi9sF921jKDB x26ZGD1/Sp4mkmLFcopvlBjjkWdOBa/iKCA3giY7i5pdGvrClp+VDQ0gv77xs1Mrm3j1 84GsddgrD6hhb/jGCAl5WBrqRVOkbWjq3KFfAhkME/tJioJWtCgF/wZMuYCce/IQweyW 7Mvw== X-Gm-Message-State: AKS2vOxHRC7/ilV5BH4gLUJJTEOAV1AWWFdDr3j63OuZMUp9zVJQDhHZ y35ydZUiP2JTxQU/ X-Received: by 10.202.87.5 with SMTP id l5mr20492851oib.214.1499107249569; Mon, 03 Jul 2017 11:40:49 -0700 (PDT) Received: from linux-4v1g.suse (cpe-24-31-249-175.kc.res.rr.com. [24.31.249.175]) by smtp.gmail.com with ESMTPSA id o2sm14641309oik.16.2017.07.03.11.40.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Jul 2017 11:40:49 -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 05/11] rtlwifi: Implement rtl_get_tx_hw_rate to yield correct hw_rate Date: Mon, 3 Jul 2017 13:40:32 -0500 Message-Id: <20170703184038.24669-6-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170703184038.24669-1-Larry.Finger@lwfinger.net> References: <20170703184038.24669-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 40e281273a55..38c8e94d2d6b 100644 --- a/drivers/net/wireless/realtek/rtlwifi/base.c +++ b/drivers/net/wireless/realtek/rtlwifi/base.c @@ -1100,6 +1100,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, @@ -1108,12 +1144,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;