Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5667406ybg; Tue, 22 Oct 2019 06:44:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzP+zGKYv6mQA8uvwSKG+oDjD4oJKHQ/jhBUJquhg8H8y+8F12iCgOWvIo/Woehey1ljWNd X-Received: by 2002:a50:b558:: with SMTP id z24mr17866610edd.67.1571751857433; Tue, 22 Oct 2019 06:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571751857; cv=none; d=google.com; s=arc-20160816; b=dS6oJ8dcuKWf1ZmOtwxnc9TwtX+3wDPe7nNw61F0VfGwtYJPjlnYBUBH1OhAqomzdT 2QlbVkmfoP5gvhZkud1bAsoXBII5eD3RsfhmXlVm/2XBrRdhljBeANTv2DFx+/J0iGza hQJ3acX/1/rXnsHXxGmKNOjZ8mFEv7cfCo3IIYgA2A8Em+Pn/uE+gLTbNHx5kQQdfSQG wWbW9eKCut2C9942VL9tqiWXZyLjFvhc54jFK8uKeRIvZ+0BgXZUBRBLDd0fKiICCf7e ehMvha4gphwOuPCUwpvBdRopYXL4FhuZO0a14W9yt5F6gViArjvSbg5mnS6s+6HWOf69 B4ew== 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=NVF1a4sqfTg/qvlmXrv43POYUsL2YuC6+2CUMmBXnEA=; b=lFtOPH/I6107oA7BMozJ8Ro58EDkWLc66sd9DQslmQ+2aCEZgKKghS1aH2yl7lxN7N 2yPkheC5/XqYz6omz9a4VTK/FgPQHFNw+iGnNdHAVpv5SDzk6d/zASUs4i1PrlT21kAC dfEi8HZaDg2g9SmP0kWkyQUVrxvTUjunanKSqHopySTxoVE2YGbO4ubQgYrokuYYEdPL JU0hCVd96fyNlucwe+VtR8srUf9f3wo8pVfjdLn6fpokXUBojJfOVfvEt/aclsuhhvNJ vuuvb1ER/RvMO/A680LeJHSAN0lwIksGLwsViLHBrLe3oQSt1LU70L8bjEql8wU1UkiV CfKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=jxTKricf; 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 k25si10554419ejs.189.2019.10.22.06.43.52; Tue, 22 Oct 2019 06:44:17 -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=jxTKricf; 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 S2388688AbfJVMtj (ORCPT + 99 others); Tue, 22 Oct 2019 08:49:39 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:43923 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388655AbfJVMti (ORCPT ); Tue, 22 Oct 2019 08:49:38 -0400 Received: by mail-qk1-f195.google.com with SMTP id a194so11987930qkg.10 for ; Tue, 22 Oct 2019 05:49:38 -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=NVF1a4sqfTg/qvlmXrv43POYUsL2YuC6+2CUMmBXnEA=; b=jxTKricf4UGdQP8/+NpAKTS9l6cT5QXnIvCA6kvJaB1Ft3ITDjS2AzHclemTuux7e3 aNlE1wAqV0ut4k0bzKths0CRjrZ/1dbX2NPCQrA4QiYW+5SEox9QYHqCH4G+f09ugZNf LaJyMT6QRfM+VsVVEh1ThMDmfkILMCPfBT0EjAkIwcBjx0AUggYgM2fEAlbg96yuxrv0 /eF0I6GnrWRX+sGNNqE5/XUJ+CXyZOwhP3SG5WpEugTwdE4NGn52lXEy42tl0NgNYBwU 838TsbeH2caUVrW1qy+PSr1+S8yTTTmPXjMr7S6nMnZoYX+YobNeaRliAy75chJlPsb+ oGdg== 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=NVF1a4sqfTg/qvlmXrv43POYUsL2YuC6+2CUMmBXnEA=; b=OxnWvRMLI8Qkgd6XiohboxlSB/QAih3FZHF8OqpGsIkUa9jUdBYdkc6yXB0kFCb8do WiZOnY/2otLgcwbt1lz1Hy/VjrvXCN4xJkXM95yDUS7tuUQkcB9kNUkg+0HpK6ZBdLFZ wG//iLpCwXLorv1rbIEq8aMCJfmpmxm6fU2K+eoHVOZYMN9V17n9ZMix0Dlm3D2Tbh+p 6TNB1AL+rIKuqgyA0jbuUGjYt+6V4hr8vDpw+o9qOyAkKrj8JpGVz0oF5hosOYyZVyEy xQ6iXDiGPOS4jV4Pz9oR/oiz9npMEbgvljXy9WfqiahekUD/9uDrpHBHwVWz+ud8tpwE L3zQ== X-Gm-Message-State: APjAAAXJCTrt6G6BmzweQ3maIO5sYBRWvIUeWuaTc2F+8PIhM+KqYYB/ VdV/JLLys4Zg2Rn6H3l6Mo+iWTDyvZ94cDaGVnYbTQ== X-Received: by 2002:a37:5f46:: with SMTP id t67mr2634677qkb.220.1571748577648; Tue, 22 Oct 2019 05:49:37 -0700 (PDT) MIME-Version: 1.0 References: <20191022100420.25116-1-yhchuang@realtek.com> <20191022100420.25116-5-yhchuang@realtek.com> In-Reply-To: <20191022100420.25116-5-yhchuang@realtek.com> From: Chris Chiu Date: Tue, 22 Oct 2019 20:49:26 +0800 Message-ID: Subject: Re: [PATCH v3 4/5] rtw88: add set_bitrate_mask support To: Tony Chuang Cc: Kalle Valo , linux-wireless , Brian Norris 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 On Tue, Oct 22, 2019 at 6:04 PM wrote: > > From: Tzu-En Huang > > Support setting bit rate from upper layer. > After configuring the original rate control result in the driver, the > result is then masked by the bit rate mask received from the ops > set_bitrate_mask. Lastly, the masked result will be sent to firmware. > > Signed-off-by: Tzu-En Huang > Signed-off-by: Yan-Hsuan Chuang > --- > > v1 -> v2 > * No change > > v2 -> v3 > * use u64_encode_bits > > drivers/net/wireless/realtek/rtw88/mac80211.c | 53 +++++++++++++ > drivers/net/wireless/realtek/rtw88/main.c | 78 +++++++++++++++---- > drivers/net/wireless/realtek/rtw88/main.h | 3 + > 3 files changed, 118 insertions(+), 16 deletions(-) > > diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c > index bc04cc280a96..2247bd61e716 100644 > --- a/drivers/net/wireless/realtek/rtw88/mac80211.c > +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c > @@ -684,6 +686,56 @@ static void rtw_ops_flush(struct ieee80211_hw *hw, > mutex_unlock(&rtwdev->mutex); > } > > +struct rtw_iter_bitrate_mask_data { > + struct rtw_dev *rtwdev; > + struct ieee80211_vif *vif; > + const struct cfg80211_bitrate_mask *mask; > +}; > + > +static void rtw_ra_mask_info_update_iter(void *data, struct ieee80211_sta *sta) > +{ > + struct rtw_iter_bitrate_mask_data *br_data = data; > + struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; > + > + if (si->vif != br_data->vif) > + return; > + > + /* free previous mask setting */ > + kfree(si->mask); You may want to do NULL check for si->mask before kfree. > + si->mask = kmemdup(br_data->mask, sizeof(struct cfg80211_bitrate_mask), > + GFP_ATOMIC); > + if (!si->mask) { > + si->use_cfg_mask = false; > + return; > + } > + > + si->use_cfg_mask = true; > + rtw_update_sta_info(br_data->rtwdev, si); > +} > + > diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c > index 47e74f0aec06..e53143132a9b 100644 > --- a/drivers/net/wireless/realtek/rtw88/main.c > +++ b/drivers/net/wireless/realtek/rtw88/main.c > @@ -612,12 +612,71 @@ static u8 get_rate_id(u8 wireless_set, enum rtw_bandwidth bw_mode, u8 tx_num) > #define RA_MASK_OFDM_IN_HT_2G 0x00010 > #define RA_MASK_OFDM_IN_HT_5G 0x00030 > > +static u64 rtw_update_rate_mask(struct rtw_dev *rtwdev, > + struct rtw_sta_info *si, > + u64 ra_mask, bool is_vht_enable, > + u8 wireless_set) > +{ > + struct rtw_hal *hal = &rtwdev->hal; > + const struct cfg80211_bitrate_mask *mask = si->mask; > + u64 cfg_mask = GENMASK(63, 0); > + u8 rssi_level, band; > + > + if (wireless_set != WIRELESS_CCK) { > + rssi_level = si->rssi_level; > + if (rssi_level == 0) > + ra_mask &= 0xffffffffffffffffULL; > + else if (rssi_level == 1) > + ra_mask &= 0xfffffffffffffff0ULL; > + else if (rssi_level == 2) > + ra_mask &= 0xffffffffffffefe0ULL; > + else if (rssi_level == 3) > + ra_mask &= 0xffffffffffffcfc0ULL; > + else if (rssi_level == 4) > + ra_mask &= 0xffffffffffff8f80ULL; > + else if (rssi_level >= 5) > + ra_mask &= 0xffffffffffff0f00ULL; > + } Would be better to enumerate rssi_level instead of 0 to 5. Does level 0 means bad rssi or good? > -- > 2.17.1 >