Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3060411rwl; Sun, 9 Apr 2023 07:11:51 -0700 (PDT) X-Google-Smtp-Source: AKy350aB0FFkAaExP1oi2GQVJxELvz5jE9pwdN3vMDilnbk7VWpICzpZS/4NarWzvM1u6ydtKfDI X-Received: by 2002:a17:906:2658:b0:878:61d8:d7c2 with SMTP id i24-20020a170906265800b0087861d8d7c2mr5412983ejc.39.1681049511345; Sun, 09 Apr 2023 07:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049511; cv=none; d=google.com; s=arc-20160816; b=G/x1JIT0l3BJBt7buY09UiFcPbhEocYFYiWiH8pw83BFJFaIAxdwaHp5MnYLFMeEPo s58I5nTj+8a0igxivV/3O5/DlKZe86chLKTRbTGrlBYgjnhFhhulelSyEUnBNOR/jGsk q/EhuMRQeMMe+eT1EChYtt5kDLfAqoldOTMK4if9irZVTu29oWjxvox/JXOTOOoYZmdq 5jKWO/dZUD+J8z53RZxPJlAHz4VMModxORUn4mGWiNJNebLAtcXI3l7FPRD9Fn3MvR3W Ro439LkTBJoDI6ZUTcTUwd18l949wYedLgP6bS3/t8YUCbmmLNMZu0DyDbANu/KUBIDZ ExoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=pMkoDGzFBMqLBLtmZMSvxcJNa+mnCxcNqzDW4ENsqtc=; b=xIGeADaVDGChJ0Ulb+7zqMedV9zJXvyRck50jPNFg3/toEpBHN0p1ect0xgOeJ/qi4 k9yohOmQdMSFU82RKjLzC/BtxuPfqqNWYjJwkkjzcln/6KxmMxzR5muqHioE3LTxRDRU ZsDZrlQbqA9okfq8IBniroLSuubw93+n0qvlkaLEKw345/IcYjJPdP9Z9WSn5IAkG6l9 IbU8IZX7XOKfJM98lt3hWMMLSDPsCO83O5WB+9wa/1kWCKreW1QVRiZAZnG7JwMKadOb ZuZTzKJXidPKtZQ4Khh/CEEDBf7jtoI1Gi0lejwuGlagcQ5UsvsVTmdv3Q7E2ESwLMM5 gItg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kUPJBYdk; 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=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jt12-20020a170906ca0c00b0092d01b8d3aasi5502298ejb.808.2023.04.09.07.11.32; Sun, 09 Apr 2023 07:11:51 -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=@gmail.com header.s=20210112 header.b=kUPJBYdk; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229657AbjDIOKs (ORCPT + 61 others); Sun, 9 Apr 2023 10:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjDIOKq (ORCPT ); Sun, 9 Apr 2023 10:10:46 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 419D040F3 for ; Sun, 9 Apr 2023 07:10:37 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id gw13so1626268wmb.3 for ; Sun, 09 Apr 2023 07:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681049436; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=pMkoDGzFBMqLBLtmZMSvxcJNa+mnCxcNqzDW4ENsqtc=; b=kUPJBYdk4T4lcXf4Mq+7EGDFXGt3l2natDgYHnzwMIdqtUXV8uyE7k0irZ4J/b2q2m sebxTZsYRWcfDPgwLmi5f5QCUNTTtKasv4BF6flux9xv4sy++Rzu5D93SyGBzDqcKOMr d1TukHhsnY2wBLR3poTp140QsUNNjrJDXyK97Lr0FNouQ3b3PF1zl1Z41kPDdRbUidqy 8wNF5O575uhf0St44lt9xdx3LySha/QyTergkEwnmG7PffUXYNzSEIt81l8EaQTv6z+x OgAYr+GGMZm7cLnJgikBubSjUa7LRJJJANFTo60Yo4TSd2UM85oW55eBFDEmaWu/BGl7 HC+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681049436; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pMkoDGzFBMqLBLtmZMSvxcJNa+mnCxcNqzDW4ENsqtc=; b=Loav1R2sARd7pEhDorzmjglHXUOlTXbHspH3SR/66oCm9HU55HKMeCAErSdlTM8EJF GyBrGnsgzePTHVYDsPRVQxYl0lMIxivFBWWzXrG5Eh8S8O8zaRikbbPheUoVScfeM4cE 5edHm/9NHpOHqM19pUnmsrD78twQbiZtrRbV+1tMmVkfqkADH4sa7RNs698fp4AOa8iS DSSOUgY9PvSRQvHDEVMWy9i8KpSWC2v6uuVb6TE8Z92LdPD9pNTERZfh/wTaQQ8FXffR nKv8SGE9tnvMYu/pLen3HK/E7ioYlYcVmbLw/M00plW/1Jc7Ouwk6x61LAGNZoGpg8BJ Mwsw== X-Gm-Message-State: AAQBX9cIwflOeZXGggvU+b5vJMqMKAjOkUOfkGnWeQ/nF+f0l5g91Skf 49FClFdccXUAx4Fk3hxis8E= X-Received: by 2002:a1c:770d:0:b0:3d0:6a57:66a5 with SMTP id t13-20020a1c770d000000b003d06a5766a5mr5582725wmi.0.1681049435575; Sun, 09 Apr 2023 07:10:35 -0700 (PDT) Received: from [192.168.1.50] ([81.196.40.55]) by smtp.gmail.com with ESMTPSA id iv15-20020a05600c548f00b003ef5b285f65sm14661025wmb.46.2023.04.09.07.10.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Apr 2023 07:10:35 -0700 (PDT) Message-ID: <541f26bb-5022-2c2d-200a-68dc2c6fb5fe@gmail.com> Date: Sun, 9 Apr 2023 17:10:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 1/2] wifi: rtl8xxxu: Clean up some messy ifs Content-Language: en-US To: Ping-Ke Shih , "linux-wireless@vger.kernel.org" Cc: Jes Sorensen References: <04d4ca3e27924ea6b2ad6e5b00ddb424@realtek.com> From: Bitterblue Smith In-Reply-To: <04d4ca3e27924ea6b2ad6e5b00ddb424@realtek.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On 06/04/2023 04:16, Ping-Ke Shih wrote: > > >> -----Original Message----- >> From: Bitterblue Smith >> Sent: Saturday, April 1, 2023 4:17 AM >> To: linux-wireless@vger.kernel.org >> Cc: Jes Sorensen ; Ping-Ke Shih >> Subject: [PATCH 1/2] wifi: rtl8xxxu: Clean up some messy ifs >> >> Add some new members to rtl8xxxu_fileops and use them instead of >> checking priv->rtl_chip. >> >> Signed-off-by: Bitterblue Smith >> --- > > [...] > >> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c >> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c >> index c152b228606f..62dd53a57659 100644 >> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c >> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c >> @@ -1916,7 +1916,7 @@ static int rtl8xxxu_start_firmware(struct rtl8xxxu_priv *priv) >> /* >> * Init H2C command >> */ >> - if (priv->rtl_chip == RTL8723B || priv->rtl_chip == RTL8188F || priv->rtl_chip == RTL8710B) >> + if (priv->fops->init_reg_hmtfr) >> rtl8xxxu_write8(priv, REG_HMTFR, 0x0f); >> exit: >> return ret; >> @@ -3864,11 +3864,8 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv) >> rtl8xxxu_write8(priv, REG_HT_SINGLE_AMPDU_8723B, val8); >> >> rtl8xxxu_write16(priv, REG_MAX_AGGR_NUM, 0x0c14); >> - if (priv->rtl_chip == RTL8723B || priv->rtl_chip == RTL8710B) >> - val8 = 0x5e; >> - else if (priv->rtl_chip == RTL8188F) >> - val8 = 0x70; /* 0x5e would make it very slow */ >> - rtl8xxxu_write8(priv, REG_AMPDU_MAX_TIME_8723B, val8); >> + rtl8xxxu_write8(priv, REG_AMPDU_MAX_TIME_8723B, >> + priv->fops->ampdu_max_time); > > Should it be > > if (priv->fops->ampdu_max_time) > val8 = priv->fops->ampdu_max_time;> > rtl8xxxu_write8(priv, REG_AMPDU_MAX_TIME_8723B, val8); // this line doesn't change? > > Because originally val8 is read from REG_HT_SINGLE_AMPDU_8723B and add > HT_SINGLE_AMPDU_ENABLE bit. No, the value read from REG_HT_SINGLE_AMPDU_8723B is not supposed to be written to REG_AMPDU_MAX_TIME_8723B. And it never was, because only RTL8723B, RTL8710B, and RTL8188F use this function. This was clearer in the original version of the code, when it was used only by RTL8723B: val8 = rtl8xxxu_read8(priv, REG_HT_SINGLE_AMPDU_8723B); val8 |= BIT(7); rtl8xxxu_write8(priv, REG_HT_SINGLE_AMPDU_8723B, val8); rtl8xxxu_write16(priv, REG_MAX_AGGR_NUM, 0x0c14); rtl8xxxu_write8(priv, REG_AMPDU_MAX_TIME_8723B, 0x5e); > > ... I review further and want to add similar comment. I wonder you do this > intentionally, so I find rtl8xxxu_init_burst() is only used by three chips > RTL8723B, RTL8710B and RTL8188F. I'm not sure if other people could misuse > this function in the future, any idea? > That will be their own mistake. :) >> rtl8xxxu_write32(priv, REG_AGGLEN_LMT, 0xffffffff); >> rtl8xxxu_write8(priv, REG_RX_PKT_LIMIT, 0x18); >> rtl8xxxu_write8(priv, REG_PIFS, 0x00); >> @@ -3876,16 +3873,8 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv) >> rtl8xxxu_write8(priv, REG_FWHW_TXQ_CTRL, FWHW_TXQ_CTRL_AMPDU_RETRY); >> rtl8xxxu_write32(priv, REG_FAST_EDCA_CTRL, 0x03086666); >> } >> - /* >> - * The RTL8710BU vendor driver uses 0x50 here and it works fine, >> - * but in rtl8xxxu 0x50 causes slow upload and random packet loss. Why? >> - */ >> - if (priv->rtl_chip == RTL8723B) >> - val8 = 0x50; >> - else if (priv->rtl_chip == RTL8188F || priv->rtl_chip == RTL8710B) >> - val8 = 0x28; /* 0x50 would make the upload slow */ >> - rtl8xxxu_write8(priv, REG_USTIME_TSF_8723B, val8); >> - rtl8xxxu_write8(priv, REG_USTIME_EDCA, val8); >> + rtl8xxxu_write8(priv, REG_USTIME_TSF_8723B, priv->fops->ustime_tsf_edca); >> + rtl8xxxu_write8(priv, REG_USTIME_EDCA, priv->fops->ustime_tsf_edca); >> >> /* to prevent mac is reseted by bus. */ >> val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL); >> @@ -4102,7 +4091,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw) >> RCR_APPEND_PHYSTAT | RCR_APPEND_ICV | RCR_APPEND_MIC; >> rtl8xxxu_write32(priv, REG_RCR, val32); >> >> - if (priv->rtl_chip == RTL8188F || priv->rtl_chip == RTL8710B) { >> + if (fops->init_reg_rxfltmap) { >> /* Accept all data frames */ >> rtl8xxxu_write16(priv, REG_RXFLTMAP2, 0xffff); >> >> @@ -4187,8 +4176,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw) >> if (fops->init_aggregation) >> fops->init_aggregation(priv); >> >> - if (priv->rtl_chip == RTL8188F || priv->rtl_chip == RTL8188E || >> - priv->rtl_chip == RTL8710B) { >> + if (fops->init_reg_pkt_life_time) { > > Originally, 8192E doesn't do this. Just make sure you want to do it? > I did want to do it. The RTL8192EU driver sets those registers. But maybe that change should be in a separate patch. I'll send v2 where RTL8192E doesn't set init_reg_pkt_life_time. >> rtl8xxxu_write16(priv, REG_PKT_VO_VI_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ >> rtl8xxxu_write16(priv, REG_PKT_BE_BK_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ >> } >> -- >> 2.39.2 >> >> ------Please consider the environment before printing this e-mail.