Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp504934yba; Thu, 9 May 2019 01:13:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpqqByXIXICHcVFY1zR642oVVDWY3/ZVxUX1779E0nsNAbUCeJ0RbdW4FEZHkBoCpmIdZE X-Received: by 2002:a17:902:2beb:: with SMTP id l98mr1163482plb.290.1557389617939; Thu, 09 May 2019 01:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557389617; cv=none; d=google.com; s=arc-20160816; b=0td6UtDZYSeSeCT+g84K0lq9iw5ZGa2wg9zeWeelpz96RLnYJzNMv7tf6dkDcbWh9i 9G51irfTpk3jeaale5Lyg2+Epn4Il+kxTI/HHnqu1yeRghpyRwDRO11uNMjdBEYM94aK /XBQBVKDORi9EoWR/bVB2LbnTbvGZXoCkh96IXnQawoTObgMHBHmCCBW/ukABaQ6LA1r gcBg5Itkbj2lJ8bTRd/zIUhrWuEyzxMsjI6KO+7HJYSSbAeAI3ZtO7wHBYFD8csR/e9X WHpnQ/qapH2VEifcqH28txMYIVXtRzDq6d81EJ7tEA5mOfxKZgIihVTeIU0SSRDS+wS8 A9Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=MZ9j8DW6C0QPBPihBypnn3DlkomTOJO7L08Uqx5vJYU=; b=BLmbArHOt3bV8K1OxCMfBUF+yNeT2duvtQV6SgslBN//SrbHtI2/zOkdXBQsqwM3Gn QLgYFhmP7Z2bMhObY5Wi6QsixlSCSs+8p05N6QkD/UHSiKEF8T+HVEP67J9h8dHgsvMI pOwfLNhEXMPhl6Hx7kmTBPYrwZr3mAfdcnQLlruLtniulaRRkMP1p5nfIBDhj5psLhup qNCkuhZ1ATCAMjULECx26+V2Mk9zVI5kwreZYbdGJIYJr8woOShosYH3XFQcaCpFN6Sl xm5nZbAqF/n2vLAZXjgmoUWClmgzNuSzANTPocEADqlX259YRifyBi6LKTMd7K+L4n5W U8qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=HHGeg5nT; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si2027146pgp.256.2019.05.09.01.13.23; Thu, 09 May 2019 01:13:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=HHGeg5nT; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbfEIILi (ORCPT + 99 others); Thu, 9 May 2019 04:11:38 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:43967 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbfEIILh (ORCPT ); Thu, 9 May 2019 04:11:37 -0400 Received: by mail-qk1-f195.google.com with SMTP id z6so70947qkl.10 for ; Thu, 09 May 2019 01:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MZ9j8DW6C0QPBPihBypnn3DlkomTOJO7L08Uqx5vJYU=; b=HHGeg5nTEZtwEihgdWHuHLbrIH9mh0jmv2zT7N0nIbOS1yqrPGZ2oFF/SS3Mfox+Ua kEE3TnCfDG6KOYuxxu41TjHEZcHan75RCtjB4NNkc5SbI/60fMcRJD8xAWPNyn0N7zRg bZrLmt53b43Ac/AXmG3idX2X83a6knJF3Y41TYfk7LqV+JHK7pHRPI/VKXw2hqmJtwaM 7+5Pripdq3aP16Kxu8SYSw1phMZpr9uBzFEYRIN2vMB5Z00zQQ+Cb/I/SqhG/D/T3pFP ct9nyhk/MCwyWZttZ2Hv2IYBdLBJAfEfi2cljj2ixY4Rb27iULi317KtEKem1Hy3vzT2 OU5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MZ9j8DW6C0QPBPihBypnn3DlkomTOJO7L08Uqx5vJYU=; b=TQ+sc/8SBq0aSaMTjjXGXAMvedO43rHr+hbajpQupMUsO3uTSHtsMxFEKg17BpxAFH rIeFwER9j8F4Pry30joTR4itHSkMz1UZ+DYKEbRkB3t2EodZi1iIO0scCdmeonwpl/+i m+FiQuPGw4y5WwjVMeTonbhmXOOt7imzGd//UYN1iByTpfZL+csVUqk/pL6fb3ENYGbl TTjg4jgL93XbMLcKYASRBvychMrkWRh2spqH0WUEwAm7simr5yaQmGq+5hogYFeOkttU N4N21E5LWeiCIwCsPGb6dfl8GH5iR55/8B5TS8XJ6zXwHi/9uh8IQJtNDl4r7Bhw2vY1 iOCA== X-Gm-Message-State: APjAAAU4YGwCBhBzpVbTRorwALH5gJSf9yZPMhi58tHaytC5Jl2RYL60 E83cvUGNmlpU+3dLSW1RCkb30OSCl7Oh6YyGKPg87A== X-Received: by 2002:ae9:dcc3:: with SMTP id q186mr2136160qkf.114.1557389496781; Thu, 09 May 2019 01:11:36 -0700 (PDT) MIME-Version: 1.0 References: <20190503072146.49999-1-chiu@endlessm.com> <20190503072146.49999-2-chiu@endlessm.com> In-Reply-To: <20190503072146.49999-2-chiu@endlessm.com> From: Daniel Drake Date: Thu, 9 May 2019 16:11:25 +0800 Message-ID: Subject: Re: [RFC PATCH 1/2] rtl8xxxu: Add rate adaptive related data To: Chris Chiu Cc: jes.sorensen@gmail.com, Kalle Valo , David Miller , linux-wireless , netdev , Linux Kernel , Linux Upstreaming Team , Larry Finger Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Chris, Thanks for this! Some suggestions below, although let me know if any don't make sense. On Fri, May 3, 2019 at 3:22 PM Chris Chiu wrote: > > Add wireless mode, signal strength level, and rate table index > to tell the firmware that we need to adjust the tx rate bitmap > accordingly. > --- > .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 45 +++++++++++++++++++ > .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 45 ++++++++++++++++++- > 2 files changed, 89 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > index 8828baf26e7b..771f58aa7cae 100644 > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > @@ -1195,6 +1195,50 @@ struct rtl8723bu_c2h { > > struct rtl8xxxu_fileops; > > +/*mlme related.*/ > +enum wireless_mode { > + WIRELESS_MODE_UNKNOWN = 0, > + //Sub-Element Run these patches through checkpatch.pl, it'll have some suggestions to bring the coding style in line, for example not using // style comments. > + WIRELESS_MODE_B = BIT(0), // tx: cck only , rx: cck only, hw: cck > + WIRELESS_MODE_G = BIT(1), // tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm > + WIRELESS_MODE_A = BIT(2), // tx: ofdm only, rx: ofdm only, hw: ofdm only > + WIRELESS_MODE_N_24G = BIT(3), // tx: MCS only, rx: MCS & cck, hw: MCS & cck > + WIRELESS_MODE_N_5G = BIT(4), // tx: MCS only, rx: MCS & ofdm, hw: ofdm only > + WIRELESS_AUTO = BIT(5), > + WIRELESS_MODE_AC = BIT(6), > + WIRELESS_MODE_MAX = (WIRELESS_MODE_B|WIRELESS_MODE_G|WIRELESS_MODE_A|WIRELESS_MODE_N_24G|WIRELESS_MODE_N_5G|WIRELESS_MODE_AC), > +}; > + > +/* from rtlwifi/wifi.h */ > +enum ratr_table_mode_new { > + RATEID_IDX_BGN_40M_2SS = 0, > + RATEID_IDX_BGN_40M_1SS = 1, > + RATEID_IDX_BGN_20M_2SS_BN = 2, > + RATEID_IDX_BGN_20M_1SS_BN = 3, > + RATEID_IDX_GN_N2SS = 4, > + RATEID_IDX_GN_N1SS = 5, > + RATEID_IDX_BG = 6, > + RATEID_IDX_G = 7, > + RATEID_IDX_B = 8, > + RATEID_IDX_VHT_2SS = 9, > + RATEID_IDX_VHT_1SS = 10, > + RATEID_IDX_MIX1 = 11, > + RATEID_IDX_MIX2 = 12, > + RATEID_IDX_VHT_3SS = 13, > + RATEID_IDX_BGN_3SS = 14, > +}; > + > +#define RTL8XXXU_RATR_STA_INIT 0 > +#define RTL8XXXU_RATR_STA_HIGH 1 > +#define RTL8XXXU_RATR_STA_MID 2 > +#define RTL8XXXU_RATR_STA_LOW 3 > + > +struct rtl8xxxu_rate_adaptive { > + u16 wireless_mode; > + u8 ratr_index; > + u8 rssi_level; /* INIT, HIGH, MIDDLE, LOW */ > +} __packed; It would be better/cleaner to avoid storing data in per-device structures if at all possible. For wireless_mode, I think you should just call rtl8xxxu_wireless_mode() every time from rtl8723b_refresh_rate_mask(). The work done there is simple (i.e. it's not expensive to call) and then we avoid having to store data (which might become stale etc). For ratr_index, I believe you can just make it a parameter passed to rtl8xxxu_gen2_update_rate_mask which is the only consumer of this variable. The two callsites (rtl8xxxu_bss_info_changed and rtl8723b_refresh_rate_mask) already know which value they want to be used. rssi_level is the one that you probably do want to store, since I see the logic in patch 2 - if the rssi level hasn't changed then you don't need to set the rate mask again, and that's a good idea since it reduces bus traffic. You could move this into rtl8xxxu_priv rather than having its own separate structure. After making those changes it might even make sense to collapse this all into a single patch; you can judge!