linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org, Ping-Ke Shih <pkshih@realtek.com>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Yan-Hsuan Chuang <yhchuang@realtek.com>,
	Birming Chiu <birming@realtek.com>, Shaofu <shaofu@realtek.com>,
	Steven Ting <steventing@realtek.com>
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	[thread overview]
Message-ID: <20170703184038.24669-6-Larry.Finger@lwfinger.net> (raw)
In-Reply-To: <20170703184038.24669-1-Larry.Finger@lwfinger.net>

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

Originally, we get legacy rate only, so we extend to get HT and VHT rate.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Yan-Hsuan Chuang <yhchuang@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 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;
-- 
2.12.3

  parent reply	other threads:[~2017-07-03 18:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-03 18:40 [PATCH 00/11] Set 4 of changes related to updates of btcoexist Larry Finger
2017-07-03 18:40 ` [PATCH 01/11] rtlwifi: btcoex: Add power_on_setting routine Larry Finger
2017-07-03 18:40 ` [PATCH 02/11] rtlwifi: Fix MAX MPDU of VHT capability Larry Finger
2017-07-03 18:40 ` [PATCH 03/11] rtlwifi: Remove redundant semicolon in wifi.h Larry Finger
2017-07-03 18:40 ` [PATCH 04/11] rtlwifi: rtl8192ee: Make driver support 64bits DMA Larry Finger
2017-07-03 18:40 ` Larry Finger [this message]
2017-07-03 18:40 ` [PATCH 06/11] rtlwifi: Add rtl_get_hal_edca_param() to generate register's format of EDCA Larry Finger
2017-07-03 18:40 ` [PATCH 07/11] rtlwifi: Add TX/RX throughput statistics in period Larry Finger
2017-07-03 18:40 ` [PATCH 08/11] rtlwifi: Add RSSI and RF type to wifi.h for phydm Larry Finger
2017-07-03 18:40 ` [PATCH 09/11] rtlwifi: Remove BAND_NUM and related fields Larry Finger
2017-07-03 18:40 ` [PATCH 10/11] rtlwifi: Add bw_update parameter for RA mask update Larry Finger
2017-07-03 18:40 ` [PATCH 11/11] rtlwifi: Add module parameter ASPM 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=20170703184038.24669-6-Larry.Finger@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=birming@realtek.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=shaofu@realtek.com \
    --cc=steventing@realtek.com \
    --cc=yhchuang@realtek.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).