From patchwork Mon Nov 28 19:27:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 629464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE4F9C4332F for ; Mon, 28 Nov 2022 19:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233179AbiK1T2E (ORCPT ); Mon, 28 Nov 2022 14:28:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbiK1T2C (ORCPT ); Mon, 28 Nov 2022 14:28:02 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF751D323 for ; Mon, 28 Nov 2022 11:28:01 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id vp12so27170868ejc.8 for ; Mon, 28 Nov 2022 11:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=nWXcY6gAbmfVg7KCDcfT+9csscwbs+7BfaV1oEKjQLY=; b=N4nhKYQwFMQAKSssUvrGAC/i3t29r6D+B2Yy9JZdsZNi4EDmVmwsyo5xafyVewNT+K qOlxuDooaE0+shPjP/0Qjx6JRA0Ixz2Kh06dWePC+C+KoyHujAEnHUAeCyQj0TdZW7fz QNRkbRgqmsbwI4f3I82EhqHcKsbBzUSJZxcf/kzyA7DwbphJvS4j/JbSSNitwZwcgPgi tDSiyXyAUY9f2nmzYGHxbclX6oatjvw3xUcWfMuZIKUYfL9OK9tc7x1yCixHoANuOJwk OOnu5Ocg7gDfnFZqS3hxvOzjNZXF7e63bCg6OXZ9lj4YzFCEtKOsO00eArQ+JCvJCQ8+ Kiqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=nWXcY6gAbmfVg7KCDcfT+9csscwbs+7BfaV1oEKjQLY=; b=eZsJi14/2H2otBudJNyLRfSvCk3EuObRSpUCDW+u6Uve58jrlbcJgldaQFJUxhY+j9 B/63LO/gRY8ko0i6mDnZqotUoDk/asr2p+N7QoqIbjXWk2rXmTQE8rCt1J4BgtZTrEmC m85bIvwU0Zm5s/2TSHwvach1M3IpwGy2SlGPmH/ErugCu1/EEfrs6cWzv3Cn05KQUnyS fIOEprLarjFQS9tFst1KwsS1eu99ym3CyQjI7UdTqI+9MYVPmNMD69ZDfFFC3lUtNoVn 4Bf/4q7puGLNV2lS6ioo7PJepN31FEREoEI1oXy5Z0vhRh3A0d6QlJ3rvINJYzKwELbJ +gKA== X-Gm-Message-State: ANoB5pmj1d/UI7OQaPz2yGY/vMgwv8bpBhlESXA6aq97HFxzgXwjxv+y Rb7OCKOpxJNkehpLAVKaD+B78w6Bqbg= X-Google-Smtp-Source: AA0mqf45FHwhwNtnUnFgiV+k5kQyT4jAzp/ERn/3kdow2kHMAFgQ4h9Qt9fm59Ex7ZHRAIoVTlRevg== X-Received: by 2002:a17:906:5583:b0:78d:b3ef:656c with SMTP id y3-20020a170906558300b0078db3ef656cmr28618024ejp.627.1669663680201; Mon, 28 Nov 2022 11:28:00 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.254]) by smtp.gmail.com with ESMTPSA id 17-20020a170906219100b007bda90a0c99sm3431552eju.58.2022.11.28.11.27.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 11:27:59 -0800 (PST) Message-ID: Date: Mon, 28 Nov 2022 21:27:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Content-Language: en-US To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih From: Bitterblue Smith Subject: [PATCH v2 1/3] wifi: rtl8xxxu: Add __packed to struct rtl8723bu_c2h Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This struct is used to access a sequence of bytes received from the wifi chip. It must not have any padding bytes between the members. This doesn't change anything on my system, possibly because currently none of the members need more than byte alignment. Fixes: b2b43b7837ba ("rtl8xxxu: Initial functionality to handle C2H events for 8723bu") Signed-off-by: Bitterblue Smith --- v2: - Patch is new in v2. --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h index 136992f0200c..d26df4095da0 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h @@ -1240,7 +1240,7 @@ struct rtl8723bu_c2h { u8 bw; } __packed ra_report; }; -}; +} __packed; struct rtl8xxxu_fileops; From patchwork Mon Nov 28 19:30:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 629158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 350ECC4321E for ; Mon, 28 Nov 2022 19:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233050AbiK1TaP (ORCPT ); Mon, 28 Nov 2022 14:30:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233481AbiK1TaG (ORCPT ); Mon, 28 Nov 2022 14:30:06 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D1092CC85 for ; Mon, 28 Nov 2022 11:30:05 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id ml11so3566691ejb.6 for ; Mon, 28 Nov 2022 11:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=UQUa92xLDXtcofb3/NG/Eqz814eKmIgItrI0x4KT1rM=; b=obMFQlYRVDD5JEaZc6W877va/3DIaQIreyZ+vSoso1zQjiiTX1HoYAADaCjB0HcHeL R3Un0c7iqy5TNfLgruDP0ipfOGFDltUtAkFfY7arNqrwMZVYmWbcrLKwCJpoWR91O8XO i/ITCdpGljml8jn10KZ1PzYwJCjy8Y3C4SuDcs2yoToKz46WFbx5U7RmQr+pgfdjEhhV pFZMKR7e0HKQBXpq5IImDuOVSFv2WE5vm851deH+e76qZEkmV3EOf4OqKfh3ukx+qnZb r6V6Cnep++kK5OkZprye2eMWIK0ESdI1RuXdvNkHyYxdCxg8OQVUteOczXt0W07CB175 yXuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UQUa92xLDXtcofb3/NG/Eqz814eKmIgItrI0x4KT1rM=; b=M65EUQskdodyqiO+ZUwgrqBfxV3EnVufL7nxFH/DDKL7EBYCFPTQWW0XA0Q9SiNIY4 VuZq8rRDTPMcMfC0Qc/KHn17ddHU7GppcN46JS+wKTRgJco8X/HpgE8i5+tSN46zJ6Vp 7SDbcyhbijDPUcH8ilBJY7cDMmEmmWmbZFZyHEqD34r5SBvgzjCfOdfP5S3C1X3nSFqt TXDPluTXgCZfvPOgV15hMoflQ0uj758bw7GBdAbqTPFzt5KSG3bBUTTTolKsr9HNpP7M 63xzInj3Ftzdh5pl4SjIbsNwTLPmvwZ1GiKcvCnnCnjWuYHDsfmFUBQ+6s2tjCBLRhSG N+FA== X-Gm-Message-State: ANoB5pmaXHvyGVdT4L/5nAWV4kzSxzrI62zILkpEpNnS/OTEbYHSB/Q6 /rh+3E8eewcgxmHrDiMgORjSBMzuSZA= X-Google-Smtp-Source: AA0mqf7RB/PRH5iCC/k5kjARWV69FXSleNdAgc6fqgKJbwAdt7gRb7YDKYuQYNrBDJP84meyRDNKjg== X-Received: by 2002:a17:906:f281:b0:7ae:3b9e:1d8a with SMTP id gu1-20020a170906f28100b007ae3b9e1d8amr42917962ejb.581.1669663803601; Mon, 28 Nov 2022 11:30:03 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.254]) by smtp.gmail.com with ESMTPSA id la26-20020a170907781a00b007bed316a6d9sm2505898ejc.18.2022.11.28.11.30.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 11:30:03 -0800 (PST) Message-ID: Date: Mon, 28 Nov 2022 21:30:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: [PATCH v2 2/3] wifi: rtl8xxxu: Fix the channel width reporting Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The gen 2 chips RTL8192EU and RTL8188FU periodically send the driver reports about the TX rate, and the driver passes these reports to sta_statistics. The reports from RTL8192EU may or may not include the channel width. The reports from RTL8188FU do not include it. Only access the c2h->ra_report.bw field if the report (skb) is big enough. The other problem fixed here is that the code was actually never changing the channel width initially reported by rtl8xxxu_bss_info_changed because the value of RATE_INFO_BW_20 is 0. Fixes: 0985d3a410ac ("rtl8xxxu: Feed current txrate information for mac80211") Signed-off-by: Bitterblue Smith --- v2: - Eliminate the magic numbers. --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 2 ++ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h index d26df4095da0..9be53e0f25cc 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h @@ -1187,6 +1187,8 @@ enum rtl8xxxu_bw_mode { RTL8XXXU_CHANNEL_WIDTH_MAX = 5, }; +#define RTL8XXXU_C2H_HDR_LEN 2 /* id and seq */ + struct rtl8723bu_c2h { u8 id; u8 seq; diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 28f136064297..352779fe4b78 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -5569,7 +5569,6 @@ static void rtl8xxxu_c2hcmd_callback(struct work_struct *work) rarpt->txrate.flags = 0; rate = c2h->ra_report.rate; sgi = c2h->ra_report.sgi; - bw = c2h->ra_report.bw; if (rate < DESC_RATE_MCS0) { rarpt->txrate.legacy = @@ -5586,8 +5585,14 @@ static void rtl8xxxu_c2hcmd_callback(struct work_struct *work) RATE_INFO_FLAGS_SHORT_GI; } - if (bw == RATE_INFO_BW_20) - rarpt->txrate.bw |= RATE_INFO_BW_20; + if (skb->len > RTL8XXXU_C2H_HDR_LEN + + offsetof(typeof(c2h->ra_report), bw)) { + if (c2h->ra_report.bw == RTL8XXXU_CHANNEL_WIDTH_40) + bw = RATE_INFO_BW_40; + else + bw = RATE_INFO_BW_20; + rarpt->txrate.bw = bw; + } } bit_rate = cfg80211_calculate_bitrate(&rarpt->txrate); rarpt->bit_rate = bit_rate; From patchwork Mon Nov 28 19:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 629463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5AF7C4332F for ; Mon, 28 Nov 2022 19:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233689AbiK1TcR (ORCPT ); Mon, 28 Nov 2022 14:32:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234002AbiK1TcD (ORCPT ); Mon, 28 Nov 2022 14:32:03 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7C52CE3A for ; Mon, 28 Nov 2022 11:31:53 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id e27so28427796ejc.12 for ; Mon, 28 Nov 2022 11:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QPtWop0zQR7b6iubkYm91IKzEzaXliBDnDgM8lzYTmY=; b=kFU1lXRi65sTHjc8JlvI/dOGg/S5nfnzcFHjYrMeB8mlBytAW48Yk24Ab3UIYHxl+5 UyRxmV/8u/L1RvaOC5/OhAAf3ZUAkr3hCDn20Mkpk/8QVZiqfKYOBgNiqKlJ+bRTso2V RoTZlBmyy5EYUVSfCWG9IbO7e0P60mIweuWozmj6/xOJKB1UTuqerxgcO7jdTY4SEcqs oZEo4rQOcvI9tjHmKmCvBqWqiBKjU08bPNb8gYiP5dUJ331J32TL+A8cjW3rYTjoXKdD L+vqKuF+TuRNs9uh9pULyng8blIgfyjtKzFWlZUESJsaFtE3Tslmd7XMi3CFRoT7Zyym Psdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QPtWop0zQR7b6iubkYm91IKzEzaXliBDnDgM8lzYTmY=; b=ZWims/PLo4QleWnAzB+T4tS8QNbMpUMKoR4iobpBn05fDYhkdXil29TxaDHJOshHNJ 3hh7fxESCab8I7CMQ/8Hl2SAz9alOY82vQtvv5Tp/N6+LLm1ycbfq3e4brTqClUNS+Ua WRx+MDKziAQkBPVXdxuxkVN9EwQRdhb3S5usLtEKarJjYY1TOTxjJbtGyeA7lO5PO0Oc aF/pSjCc07i1OLXaqRcGguOYt0e6e2TjbvTH6C1RbC5F1Nz1U00MBXtQT3ROpAj6UcYo BV6wIXLIUnk7cjLja5qHoT/oh46i9H5D0JcBD42fen8EZSM6wIj3z4B8Vpua4FbI1Kje sp0w== X-Gm-Message-State: ANoB5pk2enZTHVXHPbNj3GunuD46uU0kNvqd2fzhQdxt/D7RhKewJuuL h1oWfRMakhEMzFqDoXSkOiMwz2zaM/w= X-Google-Smtp-Source: AA0mqf5Gf/PQ4qylFcOqmNzTNlzKgw9o/Sq5CrG827TVAWRLEl4ACDfAPAMDJZGs0adnUvCeWVyJbQ== X-Received: by 2002:a17:906:81cd:b0:7ad:beb3:91b6 with SMTP id e13-20020a17090681cd00b007adbeb391b6mr29215468ejx.159.1669663911900; Mon, 28 Nov 2022 11:31:51 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.254]) by smtp.gmail.com with ESMTPSA id hz13-20020a1709072ced00b007c00323cc23sm1571112ejc.27.2022.11.28.11.31.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 11:31:51 -0800 (PST) Message-ID: <7d6ac89d-0144-1508-439a-bc8ff35c086f@gmail.com> Date: Mon, 28 Nov 2022 21:31:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: [PATCH v2 3/3] wifi: rtl8xxxu: Introduce rtl8xxxu_update_ra_report Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The ra_report struct is used for reporting the TX rate via sta_statistics. The code which fills it out is duplicated in two places, and the RTL8188EU will need it in a third place. Move this code into a new function rtl8xxxu_update_ra_report. Signed-off-by: Bitterblue Smith --- v2: - Compare against DESC_RATE_54M instead of DESC_RATE_MCS0. --- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 107 ++++++++---------- 1 file changed, 46 insertions(+), 61 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 352779fe4b78..4d067e9b9c8a 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -4598,6 +4598,32 @@ static void rtl8xxxu_set_aifs(struct rtl8xxxu_priv *priv, u8 slot_time) } } +static void rtl8xxxu_update_ra_report(struct rtl8xxxu_ra_report *rarpt, + u8 rate, u8 sgi, u8 bw) +{ + u8 mcs, nss; + + rarpt->txrate.flags = 0; + + if (rate <= DESC_RATE_54M) { + rarpt->txrate.legacy = rtl8xxxu_legacy_ratetable[rate].bitrate; + } else { + rtl8xxxu_desc_to_mcsrate(rate, &mcs, &nss); + rarpt->txrate.flags |= RATE_INFO_FLAGS_MCS; + + rarpt->txrate.mcs = mcs; + rarpt->txrate.nss = nss; + + if (sgi) + rarpt->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; + + rarpt->txrate.bw = bw; + } + + rarpt->bit_rate = cfg80211_calculate_bitrate(&rarpt->txrate); + rarpt->desc_rate = rate; +} + static void rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u64 changed) @@ -4620,9 +4646,7 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u32 ramask; int sgi = 0; u8 highest_rate; - u8 mcs = 0, nss = 0; - u32 bit_rate; - + u8 bw; rcu_read_lock(); sta = ieee80211_find_sta(vif, bss_conf->bssid); @@ -4647,37 +4671,19 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, sgi = 1; highest_rate = fls(ramask) - 1; - if (highest_rate < DESC_RATE_MCS0) { - rarpt->txrate.legacy = - rtl8xxxu_legacy_ratetable[highest_rate].bitrate; - } else { - rtl8xxxu_desc_to_mcsrate(highest_rate, - &mcs, &nss); - rarpt->txrate.flags |= RATE_INFO_FLAGS_MCS; - - rarpt->txrate.mcs = mcs; - rarpt->txrate.nss = nss; - - if (sgi) { - rarpt->txrate.flags |= - RATE_INFO_FLAGS_SHORT_GI; - } - - if (rtl8xxxu_ht40_2g && - (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)) - rarpt->txrate.bw = RATE_INFO_BW_40; - else - rarpt->txrate.bw = RATE_INFO_BW_20; - } + if (rtl8xxxu_ht40_2g && + (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)) + bw = RATE_INFO_BW_40; + else + bw = RATE_INFO_BW_20; rcu_read_unlock(); - bit_rate = cfg80211_calculate_bitrate(&rarpt->txrate); - rarpt->bit_rate = bit_rate; - rarpt->desc_rate = highest_rate; + + rtl8xxxu_update_ra_report(rarpt, highest_rate, sgi, bw); priv->vif = vif; priv->rssi_level = RTL8XXXU_RATR_STA_INIT; - priv->fops->update_rate_mask(priv, ramask, 0, sgi, rarpt->txrate.bw == RATE_INFO_BW_40); + priv->fops->update_rate_mask(priv, ramask, 0, sgi, bw == RATE_INFO_BW_40); rtl8xxxu_write8(priv, REG_BCN_MAX_ERR, 0xff); @@ -5538,9 +5544,7 @@ static void rtl8xxxu_c2hcmd_callback(struct work_struct *work) u8 bt_info = 0; struct rtl8xxxu_btcoex *btcoex; struct rtl8xxxu_ra_report *rarpt; - u8 rate, sgi, bw; - u32 bit_rate; - u8 mcs = 0, nss = 0; + u8 bw; priv = container_of(work, struct rtl8xxxu_priv, c2hcmd_work); btcoex = &priv->bt_coex; @@ -5566,37 +5570,18 @@ static void rtl8xxxu_c2hcmd_callback(struct work_struct *work) rtl8723bu_handle_bt_info(priv); break; case C2H_8723B_RA_REPORT: - rarpt->txrate.flags = 0; - rate = c2h->ra_report.rate; - sgi = c2h->ra_report.sgi; - - if (rate < DESC_RATE_MCS0) { - rarpt->txrate.legacy = - rtl8xxxu_legacy_ratetable[rate].bitrate; - } else { - rtl8xxxu_desc_to_mcsrate(rate, &mcs, &nss); - rarpt->txrate.flags |= RATE_INFO_FLAGS_MCS; + bw = rarpt->txrate.bw; - rarpt->txrate.mcs = mcs; - rarpt->txrate.nss = nss; - - if (sgi) { - rarpt->txrate.flags |= - RATE_INFO_FLAGS_SHORT_GI; - } - - if (skb->len > RTL8XXXU_C2H_HDR_LEN + - offsetof(typeof(c2h->ra_report), bw)) { - if (c2h->ra_report.bw == RTL8XXXU_CHANNEL_WIDTH_40) - bw = RATE_INFO_BW_40; - else - bw = RATE_INFO_BW_20; - rarpt->txrate.bw = bw; - } + if (skb->len > RTL8XXXU_C2H_HDR_LEN + + offsetof(typeof(c2h->ra_report), bw)) { + if (c2h->ra_report.bw == RTL8XXXU_CHANNEL_WIDTH_40) + bw = RATE_INFO_BW_40; + else + bw = RATE_INFO_BW_20; } - bit_rate = cfg80211_calculate_bitrate(&rarpt->txrate); - rarpt->bit_rate = bit_rate; - rarpt->desc_rate = rate; + + rtl8xxxu_update_ra_report(rarpt, c2h->ra_report.rate, + c2h->ra_report.sgi, bw); break; default: break;