Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp329319pxj; Tue, 1 Jun 2021 23:42:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRpOKF8DYMC4lWIfbsBAPrFHnhCAwDaX9GG5xfsi+STHoIFLPR4EPYU4CqJNA8UywloKb4 X-Received: by 2002:a05:6602:18:: with SMTP id b24mr24081356ioa.1.1622616122564; Tue, 01 Jun 2021 23:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622616122; cv=none; d=google.com; s=arc-20160816; b=kzlGN3ADYtjK6TaK5O+iF2VljVqQo5/YjQdl0pqOMayz3QSvJANG6ktqo4UtsB0Kuz Fyuhhihwy/WpWigvVF866WVdJU0XBUL1+ZWFSsVXjbn4bpd0O2JFS0u9qd5sU18xBit9 GHSJXAEBQM6oJxrSp58ZJTiwyrF/kmwBDPgiFUTgi0nL/Ph/nzGQOFznAlDZZN1e42hi /2i+bKBmauSYu0+Qgk1mS9ZYlSLgTWHH7Hb1PPEAZ2FTX6UOyOLwJ1BbCEJ+TyYKQ2dI QoOSUwNs+wxSFuAugaRAPg3wAYQJAMbK6527+aYvrvbjqaoIgU8FPCo1pC14IJWh6lAZ sSwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=BhXjT4mq2Ze86zZ10vMpxV/CO3j3TsK+lkIDNaa6nJ4=; b=K4JH5wao4rMuzVpJqPxjAIjO8/NwKy7DToVOKYh63pRZ+0byN80FUxn5irpmjSq1V3 E0wLXnqfdE2Y9++8IgmjY1iheZ5N2PfdK/ZNYY7Cca4j/+3+T4VpY7S8rG0n21R/M9At hmyXI0GQjLZPlunCr2ixt355c/+gPl/aaaojr9H/7p9bhdgaQSF8gSSw3C5xRn5V/T12 zlHuzYK7uLfsT/7I5VlkVub44MV/kdXJLlSfk7OkbnGYI85ZZ1TizU2SyMyVtJDxQA+w 79+rBWbsl7ZHBW7moXCyurOPIh3h9eiO1mkuaC4nZuKLWK4PX8tGfUkiU4NUeWJ7BUw5 ODEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si8815793ilj.40.2021.06.01.23.41.49; Tue, 01 Jun 2021 23:42:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbhFBF0z (ORCPT + 99 others); Wed, 2 Jun 2021 01:26:55 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:33088 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229637AbhFBF0y (ORCPT ); Wed, 2 Jun 2021 01:26:54 -0400 X-UUID: e5a2a709d29747ab92056f8f00aea4fa-20210602 X-UUID: e5a2a709d29747ab92056f8f00aea4fa-20210602 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 749572742; Wed, 02 Jun 2021 13:25:09 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 2 Jun 2021 13:25:07 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 2 Jun 2021 13:25:07 +0800 From: To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH v2 3/3] mt76: mt7921: fix sta_state incorrect implementation Date: Wed, 2 Jun 2021 13:24:53 +0800 Message-ID: <129b40e5ff277efc0a1b0ff9b8c3dfb8a44ad7fe.1622610746.git.objelf@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang When .sta_state is implemented, mac80211 assumes that the station entry is usable after the NOTEXIST->NONE transition. So we should create the sta entry as early as possible in order that mac80211 pass assoc/auth frames to mt76 with the newly created sta entry, and add .sta_assoc to mt76 core to refresh the sta entry again when sta is being associated. Fixes: 8aa5a9b7361c ("mt76: mt7921: enable deep sleep at runtime") Signed-off-by: Sean Wang --- v1->v2: Put back the careless change not belonged to the patch to keep mt7921_mcu_sta_add for BC entry and mt76_connac_mcu_uni_add_bss on the association. --- .../net/wireless/mediatek/mt76/mt7921/main.c | 53 ++++++++----------- .../wireless/mediatek/mt76/mt7921/mt7921.h | 2 + .../net/wireless/mediatek/mt76/mt7921/pci.c | 1 + 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index ece0cecf049d..ae07367a091a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -610,15 +610,11 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, if (ret) return ret; - if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) - mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid, - true); - mt7921_mac_wtbl_update(dev, idx, MT_WTBL_UPDATE_ADM_COUNT_CLEAR); ret = mt7921_mcu_sta_add(dev, sta, vif, true, - MT76_STA_INFO_STATE_3); + MT76_STA_INFO_STATE_1); if (ret) return ret; @@ -627,6 +623,27 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, return 0; } +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); + struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv; + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + + mt76_connac_pm_wake(&dev->mphy, &dev->pm); + + if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) + mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid, + true); + + mt7921_mac_wtbl_update(dev, msta->wcid.idx, + MT_WTBL_UPDATE_ADM_COUNT_CLEAR); + + mt7921_mcu_sta_update(dev, sta, vif, MT76_STA_INFO_STATE_3); + + mt76_connac_power_save_sched(&dev->mphy, &dev->pm); +} + void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { @@ -781,22 +798,6 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return ret; } -static int -mt7921_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST, - IEEE80211_STA_NONE); -} - -static int -mt7921_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE, - IEEE80211_STA_NOTEXIST); -} - static int mt7921_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, @@ -811,15 +812,7 @@ static int mt7921_sta_state(struct ieee80211_hw *hw, mt7921_mutex_release(dev); } - if (old_state == IEEE80211_STA_AUTH && - new_state == IEEE80211_STA_ASSOC) { - return mt7921_sta_add(hw, vif, sta); - } else if (old_state == IEEE80211_STA_ASSOC && - new_state == IEEE80211_STA_AUTH) { - return mt7921_sta_remove(hw, vif, sta); - } - - return 0; + return mt76_sta_state(hw, vif, sta, old_state, new_state); } static int diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 13d0f472b043..e97a74341ccd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -264,6 +264,8 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta, struct ieee80211_vif *vif, bool enable, u8 state); int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta, struct ieee80211_vif *vif, u8 state); +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, + struct ieee80211_sta *sta); int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd); int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif); int mt7921_mcu_set_eeprom(struct mt7921_dev *dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index 13263f50dc00..27906b2cd912 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -106,6 +106,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev, .rx_poll_complete = mt7921_rx_poll_complete, .sta_ps = mt7921_sta_ps, .sta_add = mt7921_mac_sta_add, + .sta_assoc = mt7921_mac_sta_assoc, .sta_remove = mt7921_mac_sta_remove, .update_survey = mt7921_update_channel, }; -- 2.25.1