All of lore.kernel.org
 help / color / mirror / Atom feed
From: <pkshih@realtek.com>
To: <kvalo@codeaurora.org>
Cc: <Larry.Finger@lwfinger.net>, <linux-wireless@vger.kernel.org>
Subject: [PATCH 06/10] rtlwifi: Fix VHT NSS in RC
Date: Fri, 26 Jan 2018 15:46:41 +0800	[thread overview]
Message-ID: <20180126074645.27201-7-pkshih@realtek.com> (raw)
In-Reply-To: <20180126074645.27201-1-pkshih@realtek.com>

From: Ping-Ke Shih <pkshih@realtek.com>

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 <pkshih@realtek.com>
---
 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)
-- 
2.15.1

  parent reply	other threads:[~2018-01-26  7:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26  7:46 [PATCH 00/10] rtlwifi: add more materials for 8822be pkshih
2018-01-26  7:46 ` [PATCH 01/10] rtlwifi: enable mac80211 fast-tx support pkshih
2018-01-27 18:32   ` Larry Finger
2018-01-26  7:46 ` [PATCH 02/10] rtlwifi: Add Support VHT to spec_ver pkshih
2018-01-29 18:18   ` Larry Finger
2018-01-26  7:46 ` [PATCH 03/10] rtlwifi: Use 6 bits as sequence number of TX report pkshih
2018-01-27 19:56   ` Larry Finger
2018-01-26  7:46 ` [PATCH 04/10] rtlwifi: Extend tx_power_by_rate_offset size for newer IC pkshih
2018-01-27 19:44   ` Larry Finger
2018-01-29  3:13     ` Pkshih
2018-01-26  7:46 ` [PATCH 05/10] rtlwifi: Add rate section and its related definition and comment pkshih
2018-01-27 19:41   ` Larry Finger
2018-01-26  7:46 ` pkshih [this message]
2018-01-27 19:39   ` [PATCH 06/10] rtlwifi: Fix VHT NSS in RC Larry Finger
2018-01-29  3:01     ` Pkshih
2018-01-26  7:46 ` [PATCH 07/10] rtlwifi: add definition radio_mask for RF and maximum bandwidth pkshih
2018-01-27 19:35   ` Larry Finger
2018-01-26  7:46 ` [PATCH 08/10] rtlwifi: add efuse ops for other components pkshih
2018-01-27 19:28   ` Larry Finger
2018-01-26  7:46 ` [PATCH 09/10] rtlwifi: btcoex: add routine to set default port id pkshih
2018-01-27 19:22   ` Larry Finger
2018-01-29  2:48     ` Pkshih
2018-01-26  7:46 ` [PATCH 10/10] rtlwifi: btcoex: Add 8822be btcoex supported files for wifi only pkshih
2018-01-27 19:24   ` Larry Finger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180126074645.27201-7-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.