Skip to contentSkip to conversation

mt76: mt7615: set hw scan limits only for firmware with offload support

PATCH New Felix Fietkau 1 participant 2 messages Apr 9, 2020

Subsystems (2)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH 1/2 mt76: mt7615: set hw scan limits only for firmware with offload support

They do not apply to software scan

---
 .../net/wireless/mediatek/mt76/mt7615/init.c  | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +13 -10
index 07d4b259fe8a..b5d5e28b61b4 100644
@@ -349,18 +349,21 @@ mt7615_init_wiphy(struct ieee80211_hw *hw)
 	wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
 	wiphy->reg_notifier = mt7615_regd_notifier;
 
-	wiphy->max_sched_scan_plan_interval = MT7615_MAX_SCHED_SCAN_INTERVAL;
-	wiphy->max_sched_scan_ie_len = IEEE80211_MAX_DATA_LEN;
-	wiphy->max_scan_ie_len = MT7615_SCAN_IE_LEN;
-	wiphy->max_sched_scan_ssids = MT7615_MAX_SCHED_SCAN_SSID;
-	wiphy->max_match_sets = MT7615_MAX_SCAN_MATCH;
-	wiphy->max_sched_scan_reqs = 1;
-	wiphy->max_scan_ssids = 4;
-
-	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_SET_SCAN_DWELL);
+	if (mt7615_firmware_offload(phy->dev)) {
+		wiphy->max_sched_scan_plan_interval = MT7615_MAX_SCHED_SCAN_INTERVAL;
+		wiphy->max_sched_scan_ie_len = IEEE80211_MAX_DATA_LEN;
+		wiphy->max_scan_ie_len = MT7615_SCAN_IE_LEN;
+		wiphy->max_sched_scan_ssids = MT7615_MAX_SCHED_SCAN_SSID;
+		wiphy->max_match_sets = MT7615_MAX_SCAN_MATCH;
+		wiphy->max_sched_scan_reqs = 1;
+		wiphy->max_scan_ssids = 4;
+
+		wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_SET_SCAN_DWELL);
+		ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
+	}
+
 	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
 
-	ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
 	ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN);
 
 	if (is_mt7615(&phy->dev->mt76))
Signature · 1 line
2.24.0
author maintainer
#1 lore raw

PATCH 2/2 mt76: mt7615: disable hw/sched scan ops for non-offload firmware

Avoid having to attempt hw scan and fall back to software for every scan on devices/firmware without hw scan support

---
 drivers/net/wireless/mediatek/mt76/mt7615/init.c   | 7 +++++++
 drivers/net/wireless/mediatek/mt76/mt7615/mmio.c   | 8 +++++++-
 drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h | 1 +
 3 files changed, 15 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +7 -0
index b5d5e28b61b4..a529ec2eca7d 100644
@@ -143,6 +143,13 @@ static void mt7615_init_work(struct work_struct *work)
 	mt7615_mac_init(dev);
 	mt7615_phy_init(dev);
 	mt7615_mcu_del_wtbl_all(dev);
+
+	if (!mt7615_firmware_offload(dev)) {
+		dev->ops->hw_scan = NULL;
+		dev->ops->cancel_hw_scan = NULL;
+		dev->ops->sched_scan_start = NULL;
+		dev->ops->sched_scan_stop = NULL;
+	}
 }
 
 static int mt7615_init_hardware(struct mt7615_dev *dev)
drivers/net/wireless/mediatek/mt76/mt7615/mmio.c +7 -1
index d2eff5442824..3849bb6b49d0 100644
@@ -139,11 +139,16 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
 		.sta_remove = mt7615_mac_sta_remove,
 		.update_survey = mt7615_update_channel,
 	};
+	struct ieee80211_ops *ops;
 	struct mt7615_dev *dev;
 	struct mt76_dev *mdev;
 	int ret;
 
-	mdev = mt76_alloc_device(pdev, sizeof(*dev), &mt7615_ops, &drv_ops);
+	ops = devm_kmemdup(pdev, &mt7615_ops, sizeof(mt7615_ops), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
+	mdev = mt76_alloc_device(pdev, sizeof(*dev), ops, &drv_ops);
 	if (!mdev)
 		return -ENOMEM;
 
@@ -151,6 +156,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
 	mt76_mmio_init(&dev->mt76, mem_base);
 
 	dev->reg_map = map;
+	dev->ops = ops;
 	mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
 		    (mt76_rr(dev, MT_HW_REV) & 0xff);
 	dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +1 -0
index 65a2b30fc588..4f0d29e5e595 100644
@@ -235,6 +235,7 @@ struct mt7615_dev {
 
 	u16 chainmask;
 
+	struct ieee80211_ops *ops;
 	const struct mt7615_mcu_ops *mcu_ops;
 	struct regmap *infracfg;
 	const u32 *reg_map;
Signature · 1 line
2.24.0