Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp37364rwr; Wed, 19 Apr 2023 03:05:26 -0700 (PDT) X-Google-Smtp-Source: AKy350Y8MtmMrI6/rMRiKEgfrepSxeBOg1Oe48XMIZuCow/Xo8YAkcodjcYv71qmkiZ/NVU58pyN X-Received: by 2002:a05:6a20:7f87:b0:f0:e2eb:64e7 with SMTP id d7-20020a056a207f8700b000f0e2eb64e7mr2964847pzj.50.1681898726062; Wed, 19 Apr 2023 03:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681898726; cv=none; d=google.com; s=arc-20160816; b=bmsC9JvyXp8FPOc2lW+F70m72G1ZdFiKsa3ylWjIayFp8HFj50KIOEPBzO5VDTOMit HOWO9b8oE8pURE9Vn03nu1AyQYFCB2jSPnzC7WFMXwhkc0beKA+/1+hlcAYIdn/b00zj 79ULAx8L7uGcnDCngDNBRdnqDuzCqpw8tm5vtRoyURZa9TJLfIXxrRMcGGwgAn5bZ94O XhwuK/YRzgcE4dy72yIbGNgNjO0Q7Y49q7U9F1yv19Hw/IQpDbLbW9rxKvbE7CycBgyC cuxYQvvg2Mf0v/HKEpbRL+0eSKt2BtdrMwH+pce9JBEIFAYptQ27QCbfTfRlSq2isWOs latw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=lq4n9Kh3SxjZHY31tRrdB8wgv2WOgaXBNyjQ/yvaZvA=; b=hbxq9SfCz/3VVkoyTKrOPaBKYbI0lxz1cVBQeQiwXEmZFhViCvkmWJdEfu0XsOVsJs cGV4WHGsEB8wAdnfFB89LO5iQX52ixdQ3NQD18vZmyNNlCajWOMPElmirsroI7xiuRAG q8FTrBg+HIT0AVkgkfDvEvU+EFUmfXlHmVyXdQPefsG5aH4PwLNToyk4uiXnrUzmeXEj oxrV83TMBucQ6kwyWJT7HXAmFZclRfkleSupr04Isnta7+i1QRPqQhhySniwIzGwYg/e DM3wg+beNP19Ow4PDtl0QgzxCbfHsHFTJLIeE3Nu3JCPhUoG9+pK3iSAmRFUtcSebliv 7nSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HJH7Mfeg; dkim=neutral (no key) header.i=@linutronix.de header.b=KgyTJZ2l; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u195-20020a6279cc000000b0063b7862ed1csi12073785pfc.397.2023.04.19.03.05.18; Wed, 19 Apr 2023 03:05:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HJH7Mfeg; dkim=neutral (no key) header.i=@linutronix.de header.b=KgyTJZ2l; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232558AbjDSKCo (ORCPT + 64 others); Wed, 19 Apr 2023 06:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232937AbjDSKCU (ORCPT ); Wed, 19 Apr 2023 06:02:20 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EF377DBA for ; Wed, 19 Apr 2023 03:02:18 -0700 (PDT) From: Martin Kaistra DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1681898534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lq4n9Kh3SxjZHY31tRrdB8wgv2WOgaXBNyjQ/yvaZvA=; b=HJH7Mfegv5n87rT09RPnbjmOYPn0/gNkgHuhn1nvQz8L20K+NILtAP6nDaGwE4Q4az4Pua vFufB0I29c9y4GPb5dLTuGmnz3Gm862hokZMpptbTSyhmraFxpPRxYFuuUHcqsgx1pSTOw cUJx+3fiHClUdkhl9KZDDcqUuAcjVlsPWt/rdenHbizTRjaV9xbP65Ee+kHt3aBCRM8i4b Ff1SpOd6+RwT9MKdfYn9GZcnQR0LZ6AJZyowU+Y1Y9eV+M+Ib/bOs6i9uldA5vlYholcME P/bRrcPUqbfwJ+XDgmSv2j0Kv7ziDlAsCdbYVtyJ/4OeJJ+HVaOMlpiFPDOqGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1681898534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lq4n9Kh3SxjZHY31tRrdB8wgv2WOgaXBNyjQ/yvaZvA=; b=KgyTJZ2luQQcwpJShJIXiPTsuxOi9e3FQDXB5Ctcph3cKZ8zOP/9ucYVBPnZHkQFSqtM+f 82geszazbU3u6WDw== To: linux-wireless@vger.kernel.org Cc: Jes Sorensen , Kalle Valo , Ping-Ke Shih , Bitterblue Smith , Sebastian Andrzej Siewior Subject: [PATCH v2 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags Date: Wed, 19 Apr 2023 12:01:43 +0200 Message-Id: <20230419100145.159191-17-martin.kaistra@linutronix.de> In-Reply-To: <20230419100145.159191-1-martin.kaistra@linutronix.de> References: <20230419100145.159191-1-martin.kaistra@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org As this driver uses HAS_RATE_CONTROL, rate_flags will not be provided by mac80211. Stop using tx_info->control.rates[0].flags and ieee80211_get_rts_cts_rate() and use rts_threshold and bss_conf.use_cts_prot instead to determine when to use RTS and CTS. Send RTS with 24M rate like the vendor drivers. Also set this RTS rate for ampdu_enable = true, because we also enable RTS for these frames. Signed-off-by: Martin Kaistra --- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index b60f90ea5187b..7ff6f4e6a0ff5 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -5185,7 +5185,6 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, u8 *qc = ieee80211_get_qos_ctl(hdr); u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; u32 rate = 0; - u16 rate_flags = tx_info->control.rates[0].flags; u16 seq_number; if (rtl8xxxu_debug & RTL8XXXU_DEBUG_TX) @@ -5226,10 +5225,10 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled */ tx_desc->txdw4 |= cpu_to_le32(rts_rate << TXDESC32_RTS_RATE_SHIFT); - if (ampdu_enable || (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS)) { + if (ampdu_enable || tx_info->control.use_rts) { tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE); tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE); - } else if (rate_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { + } else if (tx_info->control.use_cts_prot) { tx_desc->txdw4 |= cpu_to_le32(TXDESC32_CTS_SELF_ENABLE); tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE); } @@ -5252,7 +5251,6 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, u8 *qc = ieee80211_get_qos_ctl(hdr); u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; u32 rate = 0; - u16 rate_flags = tx_info->control.rates[0].flags; u16 seq_number; tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32; @@ -5293,13 +5291,14 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE); tx_desc40->txdw4 |= cpu_to_le32(rts_rate << TXDESC40_RTS_RATE_SHIFT); + /* * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled */ - if (ampdu_enable || (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS)) { + if (ampdu_enable || tx_info->control.use_rts) { tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE); tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE); - } else if (rate_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { + } else if (tx_info->control.use_cts_prot) { /* * For some reason the vendor driver doesn't set * TXDESC40_HW_RTS_ENABLE for CTS to SELF @@ -5326,7 +5325,6 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, u8 *qc = ieee80211_get_qos_ctl(hdr); u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; u32 rate = 0; - u16 rate_flags = tx_info->control.rates[0].flags; u16 seq_number; seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); @@ -5381,10 +5379,10 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled */ tx_desc->txdw4 |= cpu_to_le32(rts_rate << TXDESC32_RTS_RATE_SHIFT); - if (ampdu_enable || (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS)) { + if (ampdu_enable || tx_info->control.use_rts) { tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE); tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE); - } else if (rate_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { + } else if (tx_info->control.use_cts_prot) { tx_desc->txdw4 |= cpu_to_le32(TXDESC32_CTS_SELF_ENABLE); tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE); } @@ -5408,7 +5406,6 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw, struct device *dev = &priv->udev->dev; u32 queue, rts_rate; u16 pktlen = skb->len; - u16 rate_flag = tx_info->control.rates[0].flags; int tx_desc_size = priv->fops->tx_desc_size; u8 macid; int ret; @@ -5493,20 +5490,23 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw, } } - if (rate_flag & IEEE80211_TX_RC_SHORT_GI || - (ieee80211_is_data_qos(hdr->frame_control) && - sta && sta->deflink.ht_cap.cap & - (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))) + if (ieee80211_is_data_qos(hdr->frame_control) && + sta && sta->deflink.ht_cap.cap & + (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20)) sgi = true; - if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE || - (sta && vif && vif->bss_conf.use_short_preamble)) + if (sta && vif && vif->bss_conf.use_short_preamble) short_preamble = true; - if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) - rts_rate = ieee80211_get_rts_cts_rate(hw, tx_info)->hw_value; - else if (rate_flag & IEEE80211_TX_RC_USE_CTS_PROTECT) - rts_rate = ieee80211_get_rts_cts_rate(hw, tx_info)->hw_value; + if (skb->len > hw->wiphy->rts_threshold) + tx_info->control.use_rts = true; + + if (sta && vif && vif->bss_conf.use_cts_prot) + tx_info->control.use_cts_prot = true; + + if (ampdu_enable || tx_info->control.use_rts || + tx_info->control.use_cts_prot) + rts_rate = DESC_RATE_24M; else rts_rate = 0; -- 2.30.2