From patchwork Fri Jan 26 07:46:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping-Ke Shih X-Patchwork-Id: 10185215 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 3A7F660383 for ; Fri, 26 Jan 2018 07:47:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B97928FFD for ; Fri, 26 Jan 2018 07:47:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 207CE290DB; Fri, 26 Jan 2018 07:47:21 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 8171E290BE for ; Fri, 26 Jan 2018 07:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752079AbeAZHrS (ORCPT ); Fri, 26 Jan 2018 02:47:18 -0500 Received: from rtits2.realtek.com ([211.75.126.72]:39012 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018AbeAZHrL (ORCPT ); Fri, 26 Jan 2018 02:47:11 -0500 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID w0Q7kvOr004307, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitexh01.realtek.com.tw [172.21.6.62]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTP id w0Q7kvOr004307; Fri, 26 Jan 2018 15:46:58 +0800 Received: from RTITCASV01.realtek.com.tw (172.21.6.18) by RTITEXH01.realtek.com.tw (172.21.6.62) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 26 Jan 2018 15:46:57 +0800 Received: from localhost.localdomain (172.21.69.107) by RTITCASV01.realtek.com.tw (172.21.6.18) with Microsoft SMTP Server id 14.3.294.0; Fri, 26 Jan 2018 15:46:57 +0800 From: To: CC: , Subject: [PATCH 06/10] rtlwifi: Fix VHT NSS in RC Date: Fri, 26 Jan 2018 15:46:41 +0800 Message-ID: <20180126074645.27201-7-pkshih@realtek.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180126074645.27201-1-pkshih@realtek.com> References: <20180126074645.27201-1-pkshih@realtek.com> MIME-Version: 1.0 X-Originating-IP: [172.21.69.107] 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 NSS is a argument of highest rate in RC, and it occupies bit 4-7 so use ieee80211_rate_set_vht() to fill the values. Since it got correct rate index, we don't need to check chips to assign NSS in set function anymore. Signed-off-by: Ping-Ke Shih Acked-by: Larry Finger --- drivers/net/wireless/realtek/rtlwifi/rc.c | 49 +++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rc.c b/drivers/net/wireless/realtek/rtlwifi/rc.c index d1cb7d405618..396bed8d3d51 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rc.c +++ b/drivers/net/wireless/realtek/rtlwifi/rc.c @@ -42,6 +42,17 @@ static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv, struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_sta_info *sta_entry = NULL; u16 wireless_mode = 0; + u8 nss; + struct ieee80211_tx_rate rate; + + if (get_rf_type(rtlphy) >= RF_4T4R) + nss = 4; + else if (get_rf_type(rtlphy) >= RF_3T3R) + nss = 3; + else if (get_rf_type(rtlphy) >= RF_2T2R) + nss = 2; + else + nss = 1; /* *this rate is no use for true rate, firmware @@ -66,28 +77,51 @@ static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv, } else if (wireless_mode == WIRELESS_MODE_G) { return G_MODE_MAX_RIX; } else if (wireless_mode == WIRELESS_MODE_N_24G) { - if (get_rf_type(rtlphy) != RF_2T2R) + if (nss == 1) return N_MODE_MCS7_RIX; else return N_MODE_MCS15_RIX; } else if (wireless_mode == WIRELESS_MODE_AC_24G) { - return AC_MODE_MCS9_RIX; + if (sta->bandwidth == IEEE80211_STA_RX_BW_20) { + ieee80211_rate_set_vht(&rate, + AC_MODE_MCS8_RIX, + nss); + goto out; + } else { + ieee80211_rate_set_vht(&rate, + AC_MODE_MCS9_RIX, + nss); + goto out; + } } return 0; } else { if (wireless_mode == WIRELESS_MODE_A) { return A_MODE_MAX_RIX; } else if (wireless_mode == WIRELESS_MODE_N_5G) { - if (get_rf_type(rtlphy) != RF_2T2R) + if (nss == 1) return N_MODE_MCS7_RIX; else return N_MODE_MCS15_RIX; } else if (wireless_mode == WIRELESS_MODE_AC_5G) { - return AC_MODE_MCS9_RIX; + if (sta->bandwidth == IEEE80211_STA_RX_BW_20) { + ieee80211_rate_set_vht(&rate, + AC_MODE_MCS8_RIX, + nss); + goto out; + } else { + ieee80211_rate_set_vht(&rate, + AC_MODE_MCS9_RIX, + nss); + goto out; + } } return 0; } } + +out: + return rate.idx; } static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv, @@ -111,9 +145,6 @@ static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv, } rate->count = tries; rate->idx = rix >= 0x00 ? rix : 0x00; - if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE && - wireless_mode == WIRELESS_MODE_AC_5G) - rate->idx += 0x10;/*2NSS for 8812AE*/ if (!not_data) { if (txrc->short_preamble) @@ -126,10 +157,10 @@ static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv, if (sta && sta->vht_cap.vht_supported) rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH; } else { - if (mac->bw_40) - rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; if (mac->bw_80) rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH; + else if (mac->bw_40) + rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; } if (sgi_20 || sgi_40 || sgi_80)