diff mbox series

[v2,3/8] mt76: mt7921: switch to new api for hardware beacon filter

Message ID 22be936230c356e9b57f541aaa40d6552783e92d.1613755428.git.lorenzo@kernel.org
State New
Headers show
Series [v2,1/8] mt76: mt7921: fix suspend/resume sequence | expand

Commit Message

Lorenzo Bianconi Feb. 19, 2021, 5:28 p.m. UTC
From: Sean Wang <sean.wang@mediatek.com>

Current firmware only supports new api for enabling hardware beacon filter.

Fixes: 1d8efc741df80 ("mt76: mt7921: introduce Runtime PM support")
Beacon filter cmd have to rely on the associatied access point's beacon
interval and DTIM information.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 .../net/wireless/mediatek/mt76/mt7921/main.c  | 49 +++++++++++++------
 .../net/wireless/mediatek/mt76/mt7921/mcu.c   |  8 ++-
 2 files changed, 40 insertions(+), 17 deletions(-)

Comments

Kalle Valo Feb. 24, 2021, 5:28 a.m. UTC | #1
Lorenzo Bianconi <lorenzo@kernel.org> writes:

> From: Sean Wang <sean.wang@mediatek.com>

>

> Current firmware only supports new api for enabling hardware beacon filter.

>

> Fixes: 1d8efc741df80 ("mt76: mt7921: introduce Runtime PM support")

> Beacon filter cmd have to rely on the associatied access point's beacon

> interval and DTIM information.

>

> Signed-off-by: Sean Wang <sean.wang@mediatek.com>

> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>


The Fixes tag is in odd place.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Lorenzo Bianconi Feb. 24, 2021, 8:36 a.m. UTC | #2
> Lorenzo Bianconi <lorenzo@kernel.org> writes:

> 

> > From: Sean Wang <sean.wang@mediatek.com>

> >

> > Current firmware only supports new api for enabling hardware beacon filter.

> >

> > Fixes: 1d8efc741df80 ("mt76: mt7921: introduce Runtime PM support")

> > Beacon filter cmd have to rely on the associatied access point's beacon

> > interval and DTIM information.

> >

> > Signed-off-by: Sean Wang <sean.wang@mediatek.com>

> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

> 

> The Fixes tag is in odd place.


yes, I agree :)

@Felix: do I need to resubmit or can you take care of this?

Regards,
Lorenzo

> 

> -- 

> https://patchwork.kernel.org/project/linux-wireless/list/

> 

> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 729f6c42cdde..11d85cf9cfb8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -295,15 +295,6 @@  static int mt7921_add_interface(struct ieee80211_hw *hw,
 	if (ret)
 		goto out;
 
-	if (dev->pm.enable) {
-		ret = mt7921_mcu_set_bss_pm(dev, vif, true);
-		if (ret)
-			goto out;
-
-		vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
-		mt76_set(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON);
-	}
-
 	dev->mt76.vif_mask |= BIT(mvif->mt76.idx);
 	phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
 
@@ -349,13 +340,6 @@  static void mt7921_remove_interface(struct ieee80211_hw *hw,
 		phy->monitor_vif = NULL;
 
 	mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
-
-	if (dev->pm.enable) {
-		mt7921_mcu_set_bss_pm(dev, vif, false);
-		mt76_clear(dev, MT_WF_RFCR(0),
-			   MT_WF_RFCR_DROP_OTHER_BEACON);
-	}
-
 	mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, false);
 
 	rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
@@ -561,6 +545,36 @@  static void mt7921_configure_filter(struct ieee80211_hw *hw,
 	mt7921_mutex_release(dev);
 }
 
+static int
+mt7921_bss_bcnft_apply(struct mt7921_dev *dev, struct ieee80211_vif *vif,
+		       bool assoc)
+{
+	int ret;
+
+	if (!dev->pm.enable)
+		return 0;
+
+	if (assoc) {
+		ret = mt7921_mcu_uni_bss_bcnft(dev, vif, true);
+		if (ret)
+			return ret;
+
+		vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
+		mt76_set(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON);
+
+		return 0;
+	}
+
+	ret = mt7921_mcu_set_bss_pm(dev, vif, false);
+	if (ret)
+		return ret;
+
+	vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
+	mt76_clear(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON);
+
+	return 0;
+}
+
 static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
 				    struct ieee80211_vif *vif,
 				    struct ieee80211_bss_conf *info,
@@ -587,6 +601,9 @@  static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
 	if (changed & BSS_CHANGED_PS)
 		mt7921_mcu_uni_bss_ps(dev, vif);
 
+	if (changed & BSS_CHANGED_ASSOC)
+		mt7921_bss_bcnft_apply(dev, vif, info->assoc);
+
 	mt7921_mutex_release(dev);
 }
 
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) {