From patchwork Tue Feb 9 10:54:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 379745 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=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 DB072C433E0 for ; Tue, 9 Feb 2021 10:58:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AC5864DE1 for ; Tue, 9 Feb 2021 10:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232051AbhBIK5Q (ORCPT ); Tue, 9 Feb 2021 05:57:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:42788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232147AbhBIKzG (ORCPT ); Tue, 9 Feb 2021 05:55:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C2D6560232; Tue, 9 Feb 2021 10:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612868065; bh=YYmCzokLVzN+NFU/pw6x+uMmp6N1ySVR7zhAyvx21TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N3yYrUpEalHGI/R8ct8a/9nZ3TrjMmTiYVGWDAzT7Rje9hgbw7Ni58qXHYifUgTsZ 31WaXgJD2wdo05xFujm9aAwC1tAXvgbwIZRCU0nksYU3UE3+fC+5AvBw4PP8MNSuD/ hUxhfC2a5awlotbRbyB1tuOhagzwXg+SxsyJgKxNn1VxNQiVyM2xNyW5tSMvMjyEHc mFWaI6YUKCyJZgwVvuvc8cwD6AQw1rZ+d+BTP3AUE7WCReX3PiQt7BAoI4qlI+CLuZ Gs5OBWEDXw1whLF+B07ph4LBRyFSwWKst/+yEqXyTvwiFY+O11OXWN3wkXG3x7faWo 5TYh/6q+RxG+A== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sean.wang@mediatek.com, lorenzo.bianconi@redhat.com Subject: [PATCH 1/6] mt76: mt7921: switch to new api for hardware beacon filter Date: Tue, 9 Feb 2021 11:54:02 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Current firmware only supports new api for enabling hardware beacon filter. Fixes: 1d8efc741df80 ("mt76: mt7921: introduce Runtime PM support") Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 729f6c42cdde..617e48f243f3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -296,7 +296,7 @@ static int mt7921_add_interface(struct ieee80211_hw *hw, goto out; if (dev->pm.enable) { - ret = mt7921_mcu_set_bss_pm(dev, vif, true); + ret = mt7921_mcu_uni_bss_bcnft(dev, vif, true); if (ret) goto out; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index db125cd22b91..d784c75d47bf 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -1294,8 +1294,14 @@ mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) { struct mt7921_phy *phy = priv; struct mt7921_dev *dev = phy->dev; + int ret; + + if (dev->pm.enable) + ret = mt7921_mcu_uni_bss_bcnft(dev, vif, true); + else + ret = mt7921_mcu_set_bss_pm(dev, vif, false); - if (mt7921_mcu_set_bss_pm(dev, vif, dev->pm.enable)) + if (ret) return; if (dev->pm.enable) { From patchwork Tue Feb 9 10:54:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 380662 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=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 843D0C4332B for ; Tue, 9 Feb 2021 10:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E3C764DE1 for ; Tue, 9 Feb 2021 10:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232227AbhBIK5l (ORCPT ); Tue, 9 Feb 2021 05:57:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:42796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbhBIKzK (ORCPT ); Tue, 9 Feb 2021 05:55:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1924864E26; Tue, 9 Feb 2021 10:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612868070; bh=sUaT1TUyWpsfR+t5Y9oclgAMSb5CMCWRXfH4IvhgAwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oa4L2arDXDUp6+/BIsx/qPstypjJSnMmy8WHaYE7CA+el7XsBtLz2jpDoQWoSJoE/ b2FyECqFvNqo0f42QxfyqehgEdfZMQHOdmPib1f1S6vKzhENQKe6nnc+kXMVu3rYHE HfkGeHn+bqMiVKexRFbxdsd3QJmCfJ9B/9fvHnfXVUIFHI9mIF4IKoh2x50AmnmrCq X6GOZdblBxhB3uoEpXPbK5hDlGmCGGFb33gd1YS37WRcNxBZTXP+3WzmVe/ulpNXKp Og6RQ1tLbw+UKYz6pCmTiCJxIJnIh3t3ujiC/HWclP6HOCZAP3xwwccy8e8nRHot8H YNIZ3rH2PMsqQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sean.wang@mediatek.com, lorenzo.bianconi@redhat.com Subject: [PATCH 2/6] mt76: connac: fix up the setting for ht40 mode in mt76_connac_mcu_uni_add_bss Date: Tue, 9 Feb 2021 11:54:03 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Use proper value for ht40 mode configuration in mt76_connac_mcu_uni_add_bss routine and not ht20 one Fixes: d0e274af2f2e4 ("mt76: mt76_connac: create mcu library") Co-developed-by: Soul Huang Signed-off-by: Soul Huang Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 6cbccfb05f8b..4356bf130dbd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -1195,6 +1195,7 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy, .center_chan = ieee80211_frequency_to_channel(freq1), .center_chan2 = ieee80211_frequency_to_channel(freq2), .tx_streams = hweight8(phy->antenna_mask), + .ht_op_info = 4, /* set HT 40M allowed */ .rx_streams = phy->chainmask, .short_st = true, }, @@ -1287,6 +1288,7 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy, case NL80211_CHAN_WIDTH_20: default: rlm_req.rlm.bw = CMD_CBW_20MHZ; + rlm_req.rlm.ht_op_info = 0; break; } From patchwork Tue Feb 9 10:54:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 380661 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=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 6B362C43381 for ; Tue, 9 Feb 2021 10:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 206F964EC9 for ; Tue, 9 Feb 2021 10:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232218AbhBIK5g (ORCPT ); Tue, 9 Feb 2021 05:57:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:42802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231886AbhBIKzN (ORCPT ); Tue, 9 Feb 2021 05:55:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F1C8364DE1; Tue, 9 Feb 2021 10:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612868072; bh=VpyPzIl+FfZvgfZ2czN0d55bLclEJLPqOVNYgs05AOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SmAKgfdeiZShBQTQTRzerspP1E+G06hG87iH4iyewVd3h091jN4HWAesq90k0kvMz 2uF8I1J3tgk0+hH3c1TJBBqZ0iwbclPbSuTceaP/ly6ZsR+qG02YbCYw2zLfBP9Og1 y/NzsX2gh2V4h/09jtih9wnIQFlt6PAjA0Ip23+jkfitAyljZfF1Q3kuoufgBobzcI K166c3wnv6gAT21Sa1hmCxbCtYu5R9kxq/gupPMu2oDnve58s88YRyrVhfybDlNrmp lsfbDOP4BUQe2Lf+25Z2i++VecJhEIthQjnsadKAzRrkwdTRSB4p6/9GP6VnDG0FN6 bAvTQRdh+XGzA== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sean.wang@mediatek.com, lorenzo.bianconi@redhat.com Subject: [PATCH 3/6] mt76: mt7921: fixup rx bitrate statistics Date: Tue, 9 Feb 2021 11:54:04 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Since the related rx bitrate fields have been moved to group3 in Rxv, fix rx bitrate statistics in mt7921_mac_fill_rx routine. Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support") Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/mac.c | 152 +++++++++--------- .../net/wireless/mediatek/mt76/mt7921/mac.h | 10 +- 2 files changed, 85 insertions(+), 77 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 3f9097481a5e..dca4878b9849 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -401,6 +401,8 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) /* RXD Group 3 - P-RXV */ if (rxd1 & MT_RXD1_NORMAL_GROUP_3) { u32 v0, v1, v2; + u8 stbc, gi; + bool cck; rxv = rxd; rxd += 2; @@ -429,87 +431,87 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) status->chain_signal[i]); } - /* RXD Group 5 - C-RXV */ - if (rxd1 & MT_RXD1_NORMAL_GROUP_5) { - u8 stbc = FIELD_GET(MT_CRXV_HT_STBC, v2); - u8 gi = FIELD_GET(MT_CRXV_HT_SHORT_GI, v2); - bool cck = false; + stbc = FIELD_GET(MT_PRXV_STBC, v0); + gi = FIELD_GET(MT_PRXV_SGI, v0); + cck = false; - rxd += 18; - if ((u8 *)rxd - skb->data >= skb->len) - return -EINVAL; + idx = i = FIELD_GET(MT_PRXV_TX_RATE, v0); + mode = FIELD_GET(MT_PRXV_TX_MODE, v0); - idx = i = FIELD_GET(MT_PRXV_TX_RATE, v0); - mode = FIELD_GET(MT_CRXV_TX_MODE, v2); - - switch (mode) { - case MT_PHY_TYPE_CCK: - cck = true; - fallthrough; - case MT_PHY_TYPE_OFDM: - i = mt76_get_rate(&dev->mt76, sband, i, cck); - break; - case MT_PHY_TYPE_HT_GF: - case MT_PHY_TYPE_HT: - status->encoding = RX_ENC_HT; - if (i > 31) - return -EINVAL; - break; - case MT_PHY_TYPE_VHT: - status->nss = - FIELD_GET(MT_PRXV_NSTS, v0) + 1; - status->encoding = RX_ENC_VHT; - if (i > 9) - return -EINVAL; - break; - case MT_PHY_TYPE_HE_MU: - status->flag |= RX_FLAG_RADIOTAP_HE_MU; - fallthrough; - case MT_PHY_TYPE_HE_SU: - case MT_PHY_TYPE_HE_EXT_SU: - case MT_PHY_TYPE_HE_TB: - status->nss = - FIELD_GET(MT_PRXV_NSTS, v0) + 1; - status->encoding = RX_ENC_HE; - status->flag |= RX_FLAG_RADIOTAP_HE; - i &= GENMASK(3, 0); - - if (gi <= NL80211_RATE_INFO_HE_GI_3_2) - status->he_gi = gi; - - status->he_dcm = !!(idx & MT_PRXV_TX_DCM); - break; - default: + switch (mode) { + case MT_PHY_TYPE_CCK: + cck = true; + fallthrough; + case MT_PHY_TYPE_OFDM: + i = mt76_get_rate(&dev->mt76, sband, i, cck); + break; + case MT_PHY_TYPE_HT_GF: + case MT_PHY_TYPE_HT: + status->encoding = RX_ENC_HT; + if (i > 31) return -EINVAL; - } - status->rate_idx = i; - - switch (FIELD_GET(MT_CRXV_FRAME_MODE, v2)) { - case IEEE80211_STA_RX_BW_20: - break; - case IEEE80211_STA_RX_BW_40: - if (mode & MT_PHY_TYPE_HE_EXT_SU && - (idx & MT_PRXV_TX_ER_SU_106T)) { - status->bw = RATE_INFO_BW_HE_RU; - status->he_ru = - NL80211_RATE_INFO_HE_RU_ALLOC_106; - } else { - status->bw = RATE_INFO_BW_40; - } - break; - case IEEE80211_STA_RX_BW_80: - status->bw = RATE_INFO_BW_80; - break; - case IEEE80211_STA_RX_BW_160: - status->bw = RATE_INFO_BW_160; - break; - default: + break; + case MT_PHY_TYPE_VHT: + status->nss = + FIELD_GET(MT_PRXV_NSTS, v0) + 1; + status->encoding = RX_ENC_VHT; + if (i > 9) return -EINVAL; + break; + case MT_PHY_TYPE_HE_MU: + status->flag |= RX_FLAG_RADIOTAP_HE_MU; + fallthrough; + case MT_PHY_TYPE_HE_SU: + case MT_PHY_TYPE_HE_EXT_SU: + case MT_PHY_TYPE_HE_TB: + status->nss = + FIELD_GET(MT_PRXV_NSTS, v0) + 1; + status->encoding = RX_ENC_HE; + status->flag |= RX_FLAG_RADIOTAP_HE; + i &= GENMASK(3, 0); + + if (gi <= NL80211_RATE_INFO_HE_GI_3_2) + status->he_gi = gi; + + status->he_dcm = !!(idx & MT_PRXV_TX_DCM); + break; + default: + return -EINVAL; + } + + status->rate_idx = i; + + switch (FIELD_GET(MT_PRXV_FRAME_MODE, v0)) { + case IEEE80211_STA_RX_BW_20: + break; + case IEEE80211_STA_RX_BW_40: + if (mode & MT_PHY_TYPE_HE_EXT_SU && + (idx & MT_PRXV_TX_ER_SU_106T)) { + status->bw = RATE_INFO_BW_HE_RU; + status->he_ru = + NL80211_RATE_INFO_HE_RU_ALLOC_106; + } else { + status->bw = RATE_INFO_BW_40; } + break; + case IEEE80211_STA_RX_BW_80: + status->bw = RATE_INFO_BW_80; + break; + case IEEE80211_STA_RX_BW_160: + status->bw = RATE_INFO_BW_160; + break; + default: + return -EINVAL; + } + + status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; + if (mode < MT_PHY_TYPE_HE_SU && gi) + status->enc_flags |= RX_ENC_FLAG_SHORT_GI; - status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; - if (mode < MT_PHY_TYPE_HE_SU && gi) - status->enc_flags |= RX_ENC_FLAG_SHORT_GI; + if (rxd1 & MT_RXD1_NORMAL_GROUP_5) { + rxd += 18; + if ((u8 *)rxd - skb->data >= skb->len) + return -EINVAL; } } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.h b/drivers/net/wireless/mediatek/mt76/mt7921/mac.h index a0c1fa0f20e4..109c8849d106 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.h @@ -97,18 +97,24 @@ enum rx_pkt_type { #define MT_RXD3_NORMAL_PF_MODE BIT(29) #define MT_RXD3_NORMAL_PF_STS GENMASK(31, 30) -/* P-RXV */ +/* P-RXV DW0 */ #define MT_PRXV_TX_RATE GENMASK(6, 0) #define MT_PRXV_TX_DCM BIT(4) #define MT_PRXV_TX_ER_SU_106T BIT(5) #define MT_PRXV_NSTS GENMASK(9, 7) #define MT_PRXV_HT_AD_CODE BIT(11) +#define MT_PRXV_FRAME_MODE GENMASK(14, 12) +#define MT_PRXV_SGI GENMASK(16, 15) +#define MT_PRXV_STBC GENMASK(23, 22) +#define MT_PRXV_TX_MODE GENMASK(27, 24) #define MT_PRXV_HE_RU_ALLOC_L GENMASK(31, 28) -#define MT_PRXV_HE_RU_ALLOC_H GENMASK(3, 0) + +/* P-RXV DW1 */ #define MT_PRXV_RCPI3 GENMASK(31, 24) #define MT_PRXV_RCPI2 GENMASK(23, 16) #define MT_PRXV_RCPI1 GENMASK(15, 8) #define MT_PRXV_RCPI0 GENMASK(7, 0) +#define MT_PRXV_HE_RU_ALLOC_H GENMASK(3, 0) /* C-RXV */ #define MT_CRXV_HT_STBC GENMASK(1, 0) From patchwork Tue Feb 9 10:54:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 379743 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=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 A89D6C433E9 for ; Tue, 9 Feb 2021 10:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7717E64DC3 for ; Tue, 9 Feb 2021 10:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232236AbhBIK5o (ORCPT ); Tue, 9 Feb 2021 05:57:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:42810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232164AbhBIKzO (ORCPT ); Tue, 9 Feb 2021 05:55:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D604164E30; Tue, 9 Feb 2021 10:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612868073; bh=ZPxHDBkx5wOh5HwxUhHGTm0f3SWVwQyBWDKIQdYsB+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkKQAcfYcb1VwCGKvZFcs0CtbEZKHb2+Dp5P+WnlFCSpz14W/EDhfebWhTobd6phI C/ItXv5qix07JgzaCt7EcJhFBFtMmuRfghT/uwwaAEggqCthSy91GEhcTdY7rXnzMi R3o35Q/5S+3NNyCeODwdNVGyJVBeJaDn7a+no/ohUzkwTu7YToMVgldi2cdPix0TO7 ypG7k4/iIR7dJp5uEzbhMCnpaghbjtjTywySzPZPQqaZOGge2rB6UHSVY1cUaYCPB0 D3IB4dWtJXBI0TlL6FZnzuckeNBEYUxORnA3O9uWfpi86QWuGanz92HVN08Nihj+B5 jqZLTBhd+Wqdg== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sean.wang@mediatek.com, lorenzo.bianconi@redhat.com Subject: [PATCH 4/6] mt76: mt7921: add flush operation Date: Tue, 9 Feb 2021 11:54:05 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang add flush operation to make sure cfg80211_mlme_deauth is able to flush the deauthtication frame into air immediately. Co-developed-by: YN Chen Signed-off-by: YN Chen Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 617e48f243f3..e6843c9ff145 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -1120,6 +1120,15 @@ static void mt7921_set_rekey_data(struct ieee80211_hw *hw, } #endif /* CONFIG_PM */ +static void mt7921_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u32 queues, bool drop) +{ + struct mt7921_dev *dev = mt7921_hw_dev(hw); + + wait_event_timeout(dev->mt76.tx_wait, !mt76_has_tx_pending(&dev->mphy), + HZ / 2); +} + const struct ieee80211_ops mt7921_ops = { .tx = mt7921_tx, .start = mt7921_start, @@ -1158,4 +1167,5 @@ const struct ieee80211_ops mt7921_ops = { .set_wakeup = mt7921_set_wakeup, .set_rekey_data = mt7921_set_rekey_data, #endif /* CONFIG_PM */ + .flush = mt7921_flush, }; From patchwork Tue Feb 9 10:54:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 379742 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=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 2555EC433E0 for ; Tue, 9 Feb 2021 11:00:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE9F960232 for ; Tue, 9 Feb 2021 11:00:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232282AbhBILAJ (ORCPT ); Tue, 9 Feb 2021 06:00:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:43308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232238AbhBIK5p (ORCPT ); Tue, 9 Feb 2021 05:57:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BE80564E4B; Tue, 9 Feb 2021 10:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612868075; bh=YTnXJxbp4iMFaJefTnGhcfF8ZD7Kl5z84Qdir6O6OTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fk+1OTjezpg3kUnNLxZXebk+pXoFqPg3GxXksluheWr1cgpRybFdEVhmTmR5AsRtz skOIHNBTRzUSQkejpzd4nfToYYzrqIFmd1q6Kt/DBsvbbveZHA4wJTTsDQPfF6R9I8 Lsfwnq8i/fBxlCs58v+xZLEBnNNOcJWvQKxhVk4nI5dqjFmjtHXhp3PH5nZ6Yqf51U 3x0CGEFwD10w9ghqqA/Fu9/bDUU+XvQhJb1mD2rnYiVv3DoaTSIt3IDbFGtOd8SI4Q PI++q9y4aHWLlmE/fGv9HETTZbTeCOI3SEICyXg4J8sWn7R8lrNIb5LyMx2hpvs8yS BO/+FUdx+o2cQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sean.wang@mediatek.com, lorenzo.bianconi@redhat.com Subject: [PATCH 5/6] mt76: mt7921: fix uninitialized pointer access in mt7921_get_wtbl_info Date: Tue, 9 Feb 2021 11:54:06 +0100 Message-Id: <857ff74f736d4e593f5ad602cee7ac67ebfca5ca.1612867656.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang fix possible uninitialized pointer access in mt7921_get_wtbl_info routine [ 270.073205] wlp1s0: deauthenticating from 9c:5c:8e:c9:93:14 by local choice (Reason: 3=DEAUTH_LEAVING) [ 270.094918] 8<--- cut here --- [ 270.097988] Unable to handle kernel NULL pointer dereference at virtual address 0000000a [ 270.106120] pgd = 7ac68838 [ 270.108842] [0000000a] *pgd=00000000 [ 270.112426] Internal error: Oops: 805 [#1] SMP ARM [ 270.117216] Modules linked in: mt7921e mt76_connac_lib mt76 [ 270.122803] CPU: 0 PID: 7 Comm: kworker/u8:0 Tainted: G W 5.11.0-rc2+ #67 [ 270.130891] Hardware name: Mediatek Cortex-A7 (Device Tree) [ 270.136459] Workqueue: phy0 mt7921_mac_work [mt7921e] [ 270.141557] PC is at mt7921_get_wtbl_info+0x224/0x2d8 [mt7921e] [ 270.147498] LR is at 0x0 [ 270.150026] pc : [] lr : [<00000000>] psr: 60000013 ... [ 270.317696] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 270.325869] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [ 270.334043] [] (mt7921_get_wtbl_info [mt7921e]) from [] (mt7921_mac_work+0x298/0x2c0 [mt7921e]) [ 270.344529] [] (mt7921_mac_work [mt7921e]) from [] (process_one_work+0x1f0/0x538) [ 270.353780] [] (process_one_work) from [] (worker_thread+0x4c/0x55c) [ 270.361874] [] (worker_thread) from [] (kthread+0x124/0x150) [ 270.369275] [] (kthread) from [] (ret_from_fork+0x14/0x24) [ 270.376501] Exception stack(0xc19c7fb0 to 0xc19c7ff8) [ 270.381550] 7fa0: 00000000 00000000 00000000 00000000 [ 270.389724] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 270.397896] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 270.404509] Code: e59de012 e1cdc1b6 e1cdc1b8 e59dc016 (e582e00a) Fixes: 1c099ab44727c ("mt76: mt7921: add MCU support") Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index d784c75d47bf..58de7f32a625 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -404,11 +404,10 @@ mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb, if (wlan_idx >= MT76_N_WCIDS) return; + wcid = rcu_dereference(dev->mt76.wcid[wlan_idx]); - if (!wcid) { - stats->tx_rate = rate; + if (!wcid) return; - } msta = container_of(wcid, struct mt7921_sta, wcid); stats = &msta->stats; From patchwork Tue Feb 9 10:54:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 380660 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=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 35E92C433DB for ; Tue, 9 Feb 2021 11:00:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFE6D64DC3 for ; Tue, 9 Feb 2021 11:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232191AbhBIK7z (ORCPT ); Tue, 9 Feb 2021 05:59:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:43306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232239AbhBIK5o (ORCPT ); Tue, 9 Feb 2021 05:57:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A603264E50; Tue, 9 Feb 2021 10:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612868077; bh=jvJmsvkjXBnY5thcyMdcgLFhIjSb6D2GbwDkba82v7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iSkUzIl8OcgXx/gnvxKvTdTYCFZm+v9N1N53hzgvXcRAMuiPxB5tjCHuiMT2DsWjS 6kQRKvpDAW8s/BBLBOcVK/F48AGp8azROeIPd8f2MEphOfVbjnJBLlpCsCbfZH7ytH KNDGg1KSpQ6iUTzu34hZnJ3w9dIQfCE6koItse4WGDxABAn0eOJUhI3InybAfFNrKM 4rP9vrSWrIuknj8omsKQnpkpk5b1YiorJ+fhny3x6eigTQIZeBq6CxOGyXW55xq31h fGQRItn6RdnZyYEDX10gbXgRbU9+jSiE1mNlatNhWohp+qUBV3W3xLfkdcNhIW+OKk OsQ5DC6SZY0UA== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sean.wang@mediatek.com, lorenzo.bianconi@redhat.com Subject: [PATCH 6/6] mt76: connac: update sched_scan cmd usage Date: Tue, 9 Feb 2021 11:54:07 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Update sched_scan command usage according to the current firmware submitted into linux-firmware.git. Fixes: 80fc1e37c0eb ("mt76: mt7921: rely on mt76_connac_mcu module for sched_scan and hw_scan") Co-developed-by: Soul Huang Signed-off-by: Soul Huang Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h | 5 ----- drivers/net/wireless/mediatek/mt76/mt76_connac.h | 5 +++++ .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 7 +++++-- .../net/wireless/mediatek/mt76/mt76_connac_mcu.h | 14 +++++++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index 491841bc6291..5ef19fbee6bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -408,11 +408,6 @@ static inline bool is_mt7615(struct mt76_dev *dev) return mt76_chip(dev) == 0x7615 || mt76_chip(dev) == 0x7611; } -static inline bool is_mt7663(struct mt76_dev *dev) -{ - return mt76_chip(dev) == 0x7663; -} - static inline bool is_mt7611(struct mt76_dev *dev) { return mt76_chip(dev) == 0x7611; diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac.h index 0d58606391b0..b811f3c410a1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac.h @@ -73,6 +73,11 @@ static inline bool is_mt7921(struct mt76_dev *dev) return mt76_chip(dev) == 0x7961; } +static inline bool is_mt7663(struct mt76_dev *dev) +{ + return mt76_chip(dev) == 0x7663; +} + int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm); void mt76_connac_power_save_sched(struct mt76_phy *phy, struct mt76_connac_pm *pm); diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 4356bf130dbd..1ee4e627ea00 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -1435,10 +1435,13 @@ int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy, req->version = 1; req->seq_num = mvif->scan_seq_num | ext_phy << 7; - if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { - get_random_mask_addr(req->random_mac, sreq->mac_addr, + if (is_mt7663(phy->dev) && + (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)) { + get_random_mask_addr(req->mt7663.random_mac, sreq->mac_addr, sreq->mac_addr_mask); req->scan_func = 1; + } else if (is_mt7921(phy->dev)) { + req->mt7921.bss_idx = mvif->idx; } req->ssids_num = sreq->n_ssids; diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index c1e1df5f7cd7..4dca07e4e8aa 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -759,11 +759,19 @@ struct mt76_connac_sched_scan_req { u8 channel_type; u8 channels_num; u8 intervals_num; - u8 scan_func; /* BIT(0) eable random mac address */ + u8 scan_func; /* MT7663: BIT(0) eable random mac address */ struct mt76_connac_mcu_scan_channel channels[64]; __le16 intervals[MT76_CONNAC_MAX_SCHED_SCAN_INTERVAL]; - u8 random_mac[ETH_ALEN]; /* valid when BIT(0) in scan_func is set */ - u8 pad2[58]; + union { + struct { + u8 random_mac[ETH_ALEN]; + u8 pad2[58]; + } mt7663; + struct { + u8 bss_idx; + u8 pad2[63]; + } mt7921; + }; } __packed; struct mt76_connac_sched_scan_done {