Search Linux Wireless

[PATCH] wifi: mt76: mt7921: Allow disabling deep-sleep and beacon filtering.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ben Greear <greearb@xxxxxxxxxxxxxxx>

Semi permanently by use of module parameters.  This is helpful to me because
I want to see beacon RSSI reported without having to poke debugfs every
time a station re-associates.

Signed-off-by: Ben Greear <greearb@xxxxxxxxxxxxxxx>
---
 .../wireless/mediatek/mt76/mt7921/debugfs.c   | 16 +++++++++---
 .../net/wireless/mediatek/mt76/mt7921/init.c  | 10 +++++---
 .../net/wireless/mediatek/mt76/mt7921/main.c  | 25 +++++++++++++------
 .../net/wireless/mediatek/mt76/mt7921/mcu.c   |  2 ++
 .../wireless/mediatek/mt76/mt7921/mt7921.h    |  1 +
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
index e72d66e704af..a7eb80730d91 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
@@ -4,6 +4,9 @@
 #include "mt7921.h"
 #include "eeprom.h"
 
+extern bool mt7921_disable_pm;
+extern bool mt7921_disable_deep_sleep;
+
 static int
 mt7921_reg_set(void *data, u64 val)
 {
@@ -272,7 +275,7 @@ mt7921_pm_set(void *data, u64 val)
 
 	mutex_lock(&dev->mt76.mutex);
 
-	if (val == pm->enable_user)
+	if (val == pm->enable_user && val == pm->enable)
 		goto out;
 
 	if (!pm->enable_user) {
@@ -318,11 +321,11 @@ mt7921_deep_sleep_set(void *data, u64 val)
 		return -EOPNOTSUPP;
 
 	mt7921_mutex_acquire(dev);
-	if (pm->ds_enable_user == enable)
+	if (pm->ds_enable_user == enable && pm->ds_enable == enable)
 		goto out;
 
 	pm->ds_enable_user = enable;
-	pm->ds_enable = enable && !monitor;
+	pm->ds_enable = enable && !monitor && !mt7921_disable_deep_sleep;
 	mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
 out:
 	mt7921_mutex_release(dev);
@@ -362,6 +365,13 @@ mt7921_pm_stats(struct seq_file *s, void *data)
 		   jiffies_to_msecs(doze_time));
 
 	seq_printf(s, "low power wakes: %9d\n", pm->stats.lp_wake);
+	seq_printf(s, "\nlast-beacon-filter-setting: %d\n", dev->beacon_filter_setting);
+	seq_printf(s, "pm.enable: %d\n", pm->enable);
+	seq_printf(s, "pm.user_enable: %d\n", pm->enable_user);
+	seq_printf(s, "pm.deep_sleep_enable: %d\n", pm->ds_enable);
+	seq_printf(s, "pm.user_deep_sleep_enable: %d\n", pm->ds_enable_user);
+	seq_printf(s, "modparm-disable-pm: %d\n", mt7921_disable_pm);
+	seq_printf(s, "modparm-disable-deep-sleep-pm: %d\n", mt7921_disable_deep_sleep);
 
 	return 0;
 }
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
index aadb229003c9..cdefab4e7546 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
@@ -7,6 +7,9 @@
 #include "mcu.h"
 #include "eeprom.h"
 
+extern bool mt7921_disable_pm;
+extern bool mt7921_disable_deep_sleep;
+
 static const struct ieee80211_iface_limit if_limits[] = {
 	{
 		.max = MT7921_MAX_INTERFACES,
@@ -98,7 +101,6 @@ mt7921_init_wiphy(struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, SUPPORTS_PS);
 	ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
 	ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW);
-	ieee80211_hw_set(hw, CONNECTION_MONITOR);
 
 	if (dev->pm.enable)
 		ieee80211_hw_set(hw, CONNECTION_MONITOR);
@@ -158,6 +160,8 @@ static int __mt7921_init_hardware(struct mt7921_dev *dev)
 {
 	int ret;
 
+	dev->beacon_filter_setting = -1; /* initialize to un-set */
+
 	/* force firmware operation mode into normal state,
 	 * which should be set before firmware download stage.
 	 */
@@ -286,9 +290,9 @@ int mt7921_register_device(struct mt7921_dev *dev)
 	dev->pm.stats.last_doze_event = jiffies;
 	if (!mt76_is_usb(&dev->mt76)) {
 		dev->pm.enable_user = true;
-		dev->pm.enable = true;
+		dev->pm.enable = !mt7921_disable_pm;
 		dev->pm.ds_enable_user = true;
-		dev->pm.ds_enable = true;
+		dev->pm.ds_enable = !mt7921_disable_deep_sleep;
 	}
 
 	if (!mt76_is_mmio(&dev->mt76))
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index be3bd1a78435..f95b54deee9e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -9,6 +9,15 @@
 #include "mt7921.h"
 #include "mcu.h"
 
+bool mt7921_disable_pm;
+module_param_named(disable_pm, mt7921_disable_pm, bool, 0644);
+MODULE_PARM_DESC(disable_pm, "disable runtime-pm");
+
+bool mt7921_disable_deep_sleep;
+module_param_named(disable_deep_sleep, mt7921_disable_deep_sleep, bool, 0644);
+MODULE_PARM_DESC(disable_deep_sleep, "disable runtime deep-sleep");
+
+
 static void
 mt7921_gen_ppe_thresh(u8 *he_ppet, int nss)
 {
@@ -352,7 +361,8 @@ static int mt7921_add_interface(struct ieee80211_hw *hw,
 		mtxq->wcid = idx;
 	}
 
-	vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
+	if (dev->pm.enable)
+		vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
 out:
 	mt7921_mutex_release(dev);
 
@@ -522,13 +532,12 @@ mt7921_sniffer_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
 	bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
 
 	mt7921_mcu_set_sniffer(dev, vif, monitor);
-	pm->enable = pm->enable_user && !monitor;
-	pm->ds_enable = pm->ds_enable_user && !monitor;
+	pm->enable = pm->enable_user && !monitor && !mt7921_disable_pm;
+	pm->ds_enable = pm->ds_enable_user && !monitor && !mt7921_disable_deep_sleep;
 
 	mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
 
-	if (monitor)
-		mt7921_mcu_set_beacon_filter(dev, vif, false);
+	mt7921_mcu_set_beacon_filter(dev, vif, pm->enable);
 }
 
 void mt7921_set_runtime_pm(struct mt7921_dev *dev)
@@ -537,11 +546,11 @@ void mt7921_set_runtime_pm(struct mt7921_dev *dev)
 	struct mt76_connac_pm *pm = &dev->pm;
 	bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
 
-	pm->enable = pm->enable_user && !monitor;
+	pm->enable = pm->enable_user && !monitor && !mt7921_disable_pm;
 	ieee80211_iterate_active_interfaces(hw,
 					    IEEE80211_IFACE_ITER_RESUME_ALL,
 					    mt7921_pm_interface_iter, dev);
-	pm->ds_enable = pm->ds_enable_user && !monitor;
+	pm->ds_enable = pm->ds_enable_user && !monitor && !mt7921_disable_deep_sleep;
 	mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
 }
 
@@ -682,7 +691,7 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
 	if (changed & BSS_CHANGED_ASSOC) {
 		mt7921_mcu_sta_update(dev, NULL, vif, true,
 				      MT76_STA_INFO_STATE_ASSOC);
-		mt7921_mcu_set_beacon_filter(dev, vif, info->assoc);
+		mt7921_mcu_set_beacon_filter(dev, vif, info->assoc && dev->pm.enable);
 	}
 
 	if (changed & BSS_CHANGED_ARP_FILTER) {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index c6224908b494..322f396d90be 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -812,6 +812,8 @@ int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev,
 {
 	int err;
 
+	dev->beacon_filter_setting = enable;
+
 	if (enable) {
 		err = mt7921_mcu_uni_bss_bcnft(dev, vif, true);
 		if (err)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index ab92537dabd6..bcb4da214688 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -232,6 +232,7 @@ struct mt7921_dev {
 	struct work_struct init_work;
 
 	u8 fw_debug;
+	s8 beacon_filter_setting; /* -1 not set, 0 disabled, 1 enabled */
 
 	struct mt76_connac_pm pm;
 	struct mt76_connac_coredump coredump;
-- 
2.39.0




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux