From patchwork Mon Jul 17 15:09:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9845425 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 34CB660386 for ; Mon, 17 Jul 2017 15:10:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27A9927CF9 for ; Mon, 17 Jul 2017 15:10:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C62D28429; Mon, 17 Jul 2017 15:10:13 +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 866F728405 for ; Mon, 17 Jul 2017 15:10:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751362AbdGQPKL (ORCPT ); Mon, 17 Jul 2017 11:10:11 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36212 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751286AbdGQPKI (ORCPT ); Mon, 17 Jul 2017 11:10:08 -0400 Received: by mail-oi0-f65.google.com with SMTP id n2so18150635oig.3 for ; Mon, 17 Jul 2017 08:10:07 -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=loPe0ZXsPJm9E4itg5eMPnCfYtpg/lH+LsgOhZnXwf0=; b=dvIPUDk7Z4GkDUoMOJJ7gPKrC7MFY14OnBhbsY2CzMouMc8E+5hIVt6oLhthBneNNo 6eAC6jfIIV/P3cuLPU0Wl8drqZAjzLqujwzBa4UFNJYmww4WSYUP1CIRfoOx8PlYhtBX DXJEF4eRtbUfGUCeg3HTn1E3U7nyPMJhQ/0jmUEJsc6yVS/+1RkI605Cv+6kRx6JAhRQ o1fCJ5RLOCcljcvAiRN1Al1jdViCAvXgGv2uzTPX9/qbdYYr2uiFoLEDeij45JegzIRj Mccv9Bkm4q6szEqCvSm2ny0yZ8RLOKhdxm8eGcAO6GfSJNi1Pz0m4Mv9MRw29AdsHeXW WlcA== 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=loPe0ZXsPJm9E4itg5eMPnCfYtpg/lH+LsgOhZnXwf0=; b=PlrSeg2+VxjiFLV+PK0zuncB0Jlxjo/W+xGXv7ZsRxDCO/MfQsUiZFHO7pebwl4N4q F0UbM+iS9SrWxpuP0P+63lHn7aHHCM+e+59cg0XPMA5BiNG1OoaunoWjpnV9Nqw+ZQZx hZ4KHlFThI4jMpjQAz/QPMRqcv8+l7pyHD4P8Y8F9O2izGvwMFPQcdbjHeayOV5x1oUB awLfGpHH6a2+pDsAqcUn1BCH0XDJ+wrZ6DtioOJntesHLgkk2M17FGHMssRVKx5yoJSj 8JS7vBOttW3gtZD2UsPKvixCKAeY+HVED6dsn6S8u6eJdoDwB0BIy9ft94LqoA8bG+MH mGcg== X-Gm-Message-State: AIVw112UcHwhqZusZETwPY7Nm/8ctN9zkvBdUgag7uM6cJisCAN8ziCt NRn8t2b+1NFKHbR6 X-Received: by 10.202.237.215 with SMTP id l206mr14684473oih.167.1500304207589; Mon, 17 Jul 2017 08:10:07 -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 p65sm29370656oie.8.2017.07.17.08.10.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 08:10:07 -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 v2 05/11] rtlwifi: Implement rtl_get_tx_hw_rate to yield correct hw_rate Date: Mon, 17 Jul 2017 10:09:48 -0500 Message-Id: <20170717150954.1441-6-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170717150954.1441-1-Larry.Finger@lwfinger.net> References: <20170717150954.1441-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 --- v2 - no changes --- 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 0f36594da76c..f71b44c48ec0 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;