From patchwork Thu Jan 14 05:15:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 12018643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDCD5C433DB for ; Thu, 14 Jan 2021 05:21:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F739238E7 for ; Thu, 14 Jan 2021 05:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F739238E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=4TOFKnkH17pM+hvQqn0hWiOXoS8qV9dYsvc3P4Dx/hw=; b=YOdOYd6hRlOyM4hxjyYrYTO+Qq VUxLo1oncAH/o8SIZQ3p1zhpSudGNhyvGJ6Ol5zKvfTiBR587pjq1szvFLfzXyBv1fHvIro4sL15K Ev79asSmbMZUrWqwLiKO+vak7TRtYDh2ykFb/nySNyefOSRm9BXT0PsVc0nx/WaIdtP9kcVKSw+8k 7zn1qMVyA7G6eR+4WNNGptOR+K07s48/VfjoeRR7NCmX/3eTMFOwv+bkb+JpKuP6m5aRJ656tT6if LIcNWMBgG97TZKvyx95Mw30kJmLuOW6n2yklVtKhn4+a2qF6bsVIRTLGhFPg+UoS2Om3xHDFekrw5 sJhrtVIQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzv4P-0003pp-Cj; Thu, 14 Jan 2021 05:21:17 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzv4M-0003pI-HK for linux-mediatek@lists.infradead.org; Thu, 14 Jan 2021 05:21:15 +0000 X-UUID: 856e6d2e68e64a71b5bef17c9ad1a657-20210113 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=j2mMO6Hqn0t9r4XHecYTEglkL8dlgpE0WLQeuLJkr0A=; b=BADh/a9b8auGq1M6M0sjBoYxC/twmcIN40ctr31No5/QucPybqqdUQVlToZMdLNejeKIPC4XKpDBYBEJtbfH6HBU30jUFyD9uqui3qX5ipiiWGzPQUtUkUpFwp34uB7LUgMByFwWy+AAnz8dst9I4OQ/N4EY8hKSLYRQmeZtKzo=; X-UUID: 856e6d2e68e64a71b5bef17c9ad1a657-20210113 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1602980305; Wed, 13 Jan 2021 21:21:11 -0800 Received: from mtkmbs08n2.mediatek.inc (172.21.101.56) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 13 Jan 2021 21:15:47 -0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 14 Jan 2021 13:15:32 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 14 Jan 2021 13:15:32 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi Subject: [PATCH v2 1/2] mt76: mt7915: simplify peer's TxBF capability check Date: Thu, 14 Jan 2021 13:15:30 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-TM-SNTS-SMTP: 2510BC6834DDE253C9E3BB23986E2357DD0FE36B45062CFC3C31B538F29CCAB12000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210114_002114_726368_F28DFC32 X-CRM114-Status: GOOD ( 12.41 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, Ryder Lee , linux-wireless@vger.kernel.org, Shayne Chen Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org This is a preliminary patch for implicit beamforming support. Signed-off-by: Ryder Lee --- changes since v2: get condition directly from statement --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 67 ++++++------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 0baef70fc522..c79f3937f6ae 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -66,9 +66,6 @@ struct mt7915_fw_region { #define MCU_PATCH_ADDRESS 0x200000 -#define MT_STA_BFER BIT(0) -#define MT_STA_BFEE BIT(1) - #define FW_FEATURE_SET_ENCRYPT BIT(0) #define FW_FEATURE_SET_KEY_IDX GENMASK(2, 1) #define FW_FEATURE_OVERRIDE_ADDR BIT(5) @@ -1944,20 +1941,26 @@ mt7915_mcu_sta_bfee_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, } /* reply with identity matrix to avoid 2x2 BF negative gain */ - if (nr == 1 && tx_ant == 2) - bfee->fb_identity_matrix = true; + bfee->fb_identity_matrix = !!(nr == 1 && tx_ant == 2); } -static u8 -mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +static int +mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, bool enable) { - u8 type = 0; + struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; + struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; + struct mt7915_phy *phy; + struct sk_buff *skb; + int r, len; + bool ebfee = 0, ebf = 0; if (vif->type != NL80211_IFTYPE_STATION && vif->type != NL80211_IFTYPE_AP) return 0; + phy = mvif->band_idx ? mt7915_ext_phy(dev) : &dev->phy; + if (sta->he_cap.has_he) { struct ieee80211_he_cap_elem *pe; const struct ieee80211_he_cap_elem *ve; @@ -1967,15 +1970,12 @@ mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif, vc = mt7915_get_he_phy_cap(phy, vif); ve = &vc->he_cap_elem; - if ((HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]) || - HE_PHY(CAP4_MU_BEAMFORMER, pe->phy_cap_info[4])) && - HE_PHY(CAP4_SU_BEAMFORMEE, ve->phy_cap_info[4])) - type |= MT_STA_BFEE; - - if ((HE_PHY(CAP3_SU_BEAMFORMER, ve->phy_cap_info[3]) || - HE_PHY(CAP4_MU_BEAMFORMER, ve->phy_cap_info[4])) && - HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4])) - type |= MT_STA_BFER; + ebfee = !!((HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]) || + HE_PHY(CAP4_MU_BEAMFORMER, pe->phy_cap_info[4])) && + HE_PHY(CAP4_SU_BEAMFORMEE, ve->phy_cap_info[4])); + ebf = !!((HE_PHY(CAP3_SU_BEAMFORMER, ve->phy_cap_info[3]) || + HE_PHY(CAP4_MU_BEAMFORMER, ve->phy_cap_info[4])) && + HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4])); } else if (sta->vht_cap.vht_supported) { struct ieee80211_sta_vht_cap *pc; struct ieee80211_sta_vht_cap *vc; @@ -1988,37 +1988,14 @@ mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif, ce = IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; - if ((pc->cap & cr) && (vc->cap & ce)) - type |= MT_STA_BFEE; - - if ((vc->cap & cr) && (pc->cap & ce)) - type |= MT_STA_BFER; - } else if (sta->ht_cap.ht_supported) { - /* TODO: iBF */ + ebfee = !!((pc->cap & cr) && (vc->cap & ce)); + ebf = !!((vc->cap & cr) && (pc->cap & ce)); } - return type; -} - -static int -mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, bool enable) -{ - struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; - struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; - struct mt7915_phy *phy; - struct sk_buff *skb; - int r, len; - u8 type; - - phy = mvif->band_idx ? mt7915_ext_phy(dev) : &dev->phy; - - type = mt7915_mcu_sta_txbf_type(phy, vif, sta); - /* must keep each tag independent */ /* starec bf */ - if (type & MT_STA_BFER) { + if (ebf) { len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_bf); skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); @@ -2034,7 +2011,7 @@ mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif, } /* starec bfee */ - if (type & MT_STA_BFEE) { + if (ebfee) { len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_bfee); skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); From patchwork Thu Jan 14 05:15:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 12018641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5409DC433DB for ; Thu, 14 Jan 2021 05:16:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D5EAD238E7 for ; Thu, 14 Jan 2021 05:16:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5EAD238E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NpvannL3R/lUFv1tj9qIol4Nn2XuldBrgNcQF1r4LVI=; b=N8K1Mh+1SPFHFMc7+9MQPtppZ bbdSshRZNLtJN7PMDFbXXzf4iKGMSzJ8Yw8ID6XIa8VVonME7u4AsJwztR0eueAwl7KVxutZ3vP0h 2tTRRkhM173Yom55LHL6ja2HyPzBpfq8YvcVY/krA0EkU3XjaQdBX7H40NiykQrKYqwJ5UpQXT8Wb TokwooDGd2v+UdgAAhXbryX8nkw9HkQ5qKYkmvS+CPqLHtk9aUWxK+U/KGlmYbACRlRxIKb0Smkt4 x0VXXaSUvBh1N2NqI/Aiuo94+BWS8O+6aYWLv+9r6aL+/Lyw9PvrYG+eEq0nHRSwvmaFNtrqyGERW gqmDksCAg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzuzu-0003Sf-4c; Thu, 14 Jan 2021 05:16:38 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzuzp-0003S8-Py for linux-mediatek@lists.infradead.org; Thu, 14 Jan 2021 05:16:36 +0000 X-UUID: 856e71061a1d4b929337181e23227a38-20210113 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=hnNFmytvTZcGwrSTxhelZCDq899UtIaVl78wmTBOoHg=; b=MnYXIt7vx0HwLgYm97CdcVtPLSencmudKrXcv/rDZI7N7GCGBlbcDv93CV4qhkBIlNaFwbfyQ/CtZePt8WjoYV3GS5QI9RZsRzn6FCmJY+gzoHzHxGQoECEhUgNCviQ6bP0bQXc1vl+vOH9xNUfRD3w1wHUK5MBAidhM0BirCls=; X-UUID: 856e71061a1d4b929337181e23227a38-20210113 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 771074609; Wed, 13 Jan 2021 21:16:30 -0800 Received: from mtkmbs08n1.mediatek.inc (172.21.101.55) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 13 Jan 2021 21:15:34 -0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 14 Jan 2021 13:15:33 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 14 Jan 2021 13:15:33 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi Subject: [PATCH v2 2/2] mt76: mt7915: add implicit Tx beamforming support Date: Thu, 14 Jan 2021 13:15:31 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210114_001634_899004_881E4029 X-CRM114-Status: GOOD ( 17.93 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, Ryder Lee , linux-wireless@vger.kernel.org, Shayne Chen Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Add ht/vht implicit Tx beamforming support and enable it via debugfs. Tested-by: Shayne Chen Signed-off-by: Ryder Lee --- changes since v2: - use -EBUSY as the return value. - adjust flow. --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 28 +++++ .../net/wireless/mediatek/mt76/mt7915/init.c | 8 +- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 108 +++++++++--------- .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 + 4 files changed, 87 insertions(+), 58 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index 7d810fbf2862..77dcd71e49a5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -6,6 +6,32 @@ /** global debugfs **/ +static int +mt7915_implicit_txbf_set(void *data, u64 val) +{ + struct mt7915_dev *dev = data; + + if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state)) + return -EBUSY; + + dev->ibf = !!val; + + return mt7915_mcu_set_txbf_type(dev); +} + +static int +mt7915_implicit_txbf_get(void *data, u64 *val) +{ + struct mt7915_dev *dev = data; + + *val = dev->ibf; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_implicit_txbf, mt7915_implicit_txbf_get, + mt7915_implicit_txbf_set, "%lld\n"); + /* test knob of system layer 1/2 error recovery */ static int mt7915_ser_trigger_set(void *data, u64 val) { @@ -355,6 +381,8 @@ int mt7915_init_debugfs(struct mt7915_dev *dev) mt7915_queues_acq); debugfs_create_file("tx_stats", 0400, dir, dev, &fops_tx_stats); debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug); + debugfs_create_file("implicit_txbf", 0600, dir, dev, + &fops_implicit_txbf); debugfs_create_u32("dfs_hw_pattern", 0400, dir, &dev->hw_pattern); /* test knobs */ debugfs_create_file("radar_trigger", 0200, dir, dev, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index 255ccd7e3d27..cb501c5dc1cc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -169,18 +169,12 @@ static int mt7915_txbf_init(struct mt7915_dev *dev) { int ret; - /* - * TODO: DBDC & check whether iBF phase calibration data has - * been stored in eeprom offset 0x651~0x7b8, then write down - * 0x1111 into 0x651 and 0x651 to trigger iBF. - */ - /* trigger sounding packets */ ret = mt7915_mcu_set_txbf_sounding(dev); if (ret) return ret; - /* enable iBF & eBF */ + /* enable eBF */ return mt7915_mcu_set_txbf_type(dev); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index c79f3937f6ae..fca34322ed58 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -1729,6 +1729,7 @@ int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif, static void mt7915_mcu_sta_sounding_rate(struct sta_rec_bf *bf) { + bf->bf_cap = MT_EBF; bf->sounding_phy = MT_PHY_TYPE_OFDM; bf->ndp_rate = 0; /* mcs0 */ bf->ndpa_rate = MT7915_CFEND_RATE_DEFAULT; /* ofdm 24m */ @@ -1736,13 +1737,14 @@ mt7915_mcu_sta_sounding_rate(struct sta_rec_bf *bf) } static void -mt7915_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct sta_rec_bf *bf) +mt7915_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct mt7915_phy *phy, + struct sta_rec_bf *bf) { struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs; u8 n = 0; bf->tx_mode = MT_PHY_TYPE_HT; - bf->bf_cap |= MT_IBF; + bf->bf_cap = MT_IBF; if (mcs->tx_params & IEEE80211_HT_MCS_TX_RX_DIFF && (mcs->tx_params & IEEE80211_HT_MCS_TX_DEFINED)) @@ -1755,43 +1757,46 @@ mt7915_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct sta_rec_bf *bf) else if (mcs->rx_mask[1]) n = 1; + bf->nr = hweight8(phy->chainmask) - 1; bf->nc = min_t(u8, bf->nr, n); - bf->ibf_ncol = bf->nc; - - if (sta->bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->nc) - bf->ibf_timeout = 0x48; + bf->ibf_ncol = n; } static void mt7915_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7915_phy *phy, - struct sta_rec_bf *bf) + struct sta_rec_bf *bf, bool explicit) { struct ieee80211_sta_vht_cap *pc = &sta->vht_cap; struct ieee80211_sta_vht_cap *vc = &phy->mt76->sband_5g.sband.vht_cap; - u8 bfee_nr, bfer_nr, n, tx_ant = hweight8(phy->chainmask) - 1; - u16 mcs_map; + u16 mcs_map = le16_to_cpu(pc->vht_mcs.rx_mcs_map); + u8 nss_mcs = mt7915_mcu_get_sta_nss(mcs_map); + u8 tx_ant = hweight8(phy->chainmask) - 1; bf->tx_mode = MT_PHY_TYPE_VHT; - bf->bf_cap |= MT_EBF; - mt7915_mcu_sta_sounding_rate(bf); + if (explicit) { + u8 bfee_nr, bfer_nr; - bfee_nr = FIELD_GET(IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK, - pc->cap); - bfer_nr = FIELD_GET(IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK, - vc->cap); - mcs_map = le16_to_cpu(pc->vht_mcs.rx_mcs_map); + mt7915_mcu_sta_sounding_rate(bf); + bfee_nr = FIELD_GET(IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK, + pc->cap); + bfer_nr = FIELD_GET(IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK, + vc->cap); + bf->nr = min_t(u8, min_t(u8, bfer_nr, bfee_nr), tx_ant); + bf->nc = min_t(u8, nss_mcs, bf->nr); + bf->ibf_ncol = bf->nc; - n = min_t(u8, bfer_nr, bfee_nr); - bf->nr = min_t(u8, n, tx_ant); - n = mt7915_mcu_get_sta_nss(mcs_map); - - bf->nc = min_t(u8, n, bf->nr); - bf->ibf_ncol = bf->nc; + if (sta->bandwidth == IEEE80211_STA_RX_BW_160) + bf->nr = 1; + } else { + bf->bf_cap = MT_IBF; + bf->nr = tx_ant; + bf->nc = min_t(u8, nss_mcs, bf->nr); + bf->ibf_ncol = nss_mcs; - /* force nr from 4 to 2 */ - if (sta->bandwidth == IEEE80211_STA_RX_BW_160) - bf->nr = 1; + if (sta->bandwidth == IEEE80211_STA_RX_BW_160) + bf->ibf_nrow = 1; + } } static void @@ -1800,19 +1805,14 @@ mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, { struct ieee80211_sta_he_cap *pc = &sta->he_cap; struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; - const struct ieee80211_he_cap_elem *ve; - const struct ieee80211_sta_he_cap *vc; - u8 bfee_nr, bfer_nr, nss_mcs; - u16 mcs_map; - - vc = mt7915_get_he_phy_cap(phy, vif); - ve = &vc->he_cap_elem; + const struct ieee80211_sta_he_cap *vc = mt7915_get_he_phy_cap(phy, vif); + const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem; + u16 mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.rx_mcs_80); + u8 nss_mcs = mt7915_mcu_get_sta_nss(mcs_map); + u8 bfee_nr, bfer_nr; bf->tx_mode = MT_PHY_TYPE_HE_SU; - bf->bf_cap |= MT_EBF; - mt7915_mcu_sta_sounding_rate(bf); - bf->trigger_su = HE_PHY(CAP6_TRIG_SU_BEAMFORMER_FB, pe->phy_cap_info[6]); bf->trigger_mu = HE_PHY(CAP6_TRIG_MU_BEAMFORMER_FB, @@ -1821,10 +1821,6 @@ mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, ve->phy_cap_info[5]); bfee_nr = HE_PHY(CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK, pe->phy_cap_info[4]); - - mcs_map = le16_to_cpu(pc->he_mcs_nss_supp.tx_mcs_80); - nss_mcs = mt7915_mcu_get_sta_nss(mcs_map); - bf->nr = min_t(u8, bfer_nr, bfee_nr); bf->nc = min_t(u8, nss_mcs, bf->nr); bf->ibf_ncol = bf->nc; @@ -1863,7 +1859,7 @@ mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, static void mt7915_mcu_sta_bfer_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, struct ieee80211_vif *vif, struct mt7915_phy *phy, - bool enable) + bool enable, bool explicit) { struct sta_rec_bf *bf; struct tlv *tlv; @@ -1885,19 +1881,29 @@ mt7915_mcu_sta_bfer_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, return; } + /* he: eBF only, in accordance with spec + * vht: support eBF and iBF + * ht: iBF only, since mac80211 lacks of eBF support + */ + if (sta->he_cap.has_he && explicit) + mt7915_mcu_sta_bfer_he(sta, vif, phy, bf); + else if (sta->vht_cap.vht_supported) + mt7915_mcu_sta_bfer_vht(sta, phy, bf, explicit); + else if (sta->ht_cap.ht_supported) + mt7915_mcu_sta_bfer_ht(sta, phy, bf); + else + return; + bf->bw = sta->bandwidth; bf->ibf_dbw = sta->bandwidth; bf->ibf_nrow = tx_ant; - bf->ibf_timeout = 0x18; - if (sta->he_cap.has_he) - mt7915_mcu_sta_bfer_he(sta, vif, phy, bf); - else if (sta->vht_cap.vht_supported) - mt7915_mcu_sta_bfer_vht(sta, phy, bf); - else if (sta->ht_cap.ht_supported) - mt7915_mcu_sta_bfer_ht(sta, bf); + if (!explicit && sta->bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->nc) + bf->ibf_timeout = 0x48; + else + bf->ibf_timeout = 0x18; - if (bf->bf_cap & MT_EBF && bf->nr != tx_ant) + if (explicit && bf->nr != tx_ant) bf->mem_20m = matrix[tx_ant][bf->nc]; else bf->mem_20m = matrix[bf->nr][bf->nc]; @@ -1995,14 +2001,14 @@ mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif, /* must keep each tag independent */ /* starec bf */ - if (ebf) { + if (ebf || dev->ibf) { len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_bf); skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); if (IS_ERR(skb)) return PTR_ERR(skb); - mt7915_mcu_sta_bfer_tlv(skb, sta, vif, phy, enable); + mt7915_mcu_sta_bfer_tlv(skb, sta, vif, phy, enable, ebf); r = mt76_mcu_skb_send_msg(&dev->mt76, skb, MCU_EXT_CMD_STA_REC_UPDATE, true); @@ -3435,7 +3441,7 @@ int mt7915_mcu_set_txbf_type(struct mt7915_dev *dev) } __packed req = { .action = MT_BF_TYPE_UPDATE, .ebf = true, - .ibf = false, + .ibf = dev->ibf, }; return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_TXBF_ACTION, &req, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index df7ac2cf052f..63ad1f8199f2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -191,6 +191,7 @@ struct mt7915_dev { bool dbdc_support; bool flash_mode; bool fw_debug; + bool ibf; }; enum {