mt76: mt7615: introduce mt7615_check_offload_capability routine
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 29 Apr 2020 17:52:15 +0000 (19:52 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 12 May 2020 17:52:33 +0000 (19:52 +0200)
Introduce mt7615_check_offload_capability routine to set hw/wiphy
offload capabilities according to the running firmware

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/init.c
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c
drivers/net/wireless/mediatek/mt76/mt7615/usb_init.c

index 7e20152..145af8a 100644 (file)
@@ -130,6 +130,32 @@ void mt7615_mac_init(struct mt7615_dev *dev)
 }
 EXPORT_SYMBOL_GPL(mt7615_mac_init);
 
+void mt7615_check_offload_capability(struct mt7615_dev *dev)
+{
+       struct ieee80211_hw *hw = mt76_hw(dev);
+       struct wiphy *wiphy = hw->wiphy;
+
+       if (mt7615_firmware_offload(dev)) {
+               ieee80211_hw_set(hw, SUPPORTS_PS);
+               ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
+
+               wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
+       } else {
+               dev->ops->hw_scan = NULL;
+               dev->ops->cancel_hw_scan = NULL;
+               dev->ops->sched_scan_start = NULL;
+               dev->ops->sched_scan_stop = NULL;
+
+               wiphy->max_sched_scan_plan_interval = 0;
+               wiphy->max_sched_scan_ie_len = 0;
+               wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
+               wiphy->max_sched_scan_ssids = 0;
+               wiphy->max_match_sets = 0;
+               wiphy->max_sched_scan_reqs = 0;
+       }
+}
+EXPORT_SYMBOL_GPL(mt7615_check_offload_capability);
+
 bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev)
 {
        flush_work(&dev->mcu_work);
index 0476b94..2321a1f 100644 (file)
@@ -370,6 +370,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
                      int irq, const u32 *map);
 u32 mt7615_reg_map(struct mt7615_dev *dev, u32 addr);
 
+void mt7615_check_offload_capability(struct mt7615_dev *dev);
 void mt7615_init_device(struct mt7615_dev *dev);
 int mt7615_register_device(struct mt7615_dev *dev);
 void mt7615_unregister_device(struct mt7615_dev *dev);
index cd3ccaf..69cba86 100644 (file)
@@ -16,7 +16,6 @@ static void mt7615_init_work(struct work_struct *work)
 {
        struct mt7615_dev *dev = container_of(work, struct mt7615_dev,
                                              mcu_work);
-       struct ieee80211_hw *hw = mt76_hw(dev);
 
        if (mt7615_mcu_init(dev))
                return;
@@ -25,25 +24,7 @@ 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)) {
-               ieee80211_hw_set(hw, SUPPORTS_PS);
-               ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
-       } else {
-               struct wiphy *wiphy = hw->wiphy;
-
-               dev->ops->hw_scan = NULL;
-               dev->ops->cancel_hw_scan = NULL;
-               dev->ops->sched_scan_start = NULL;
-               dev->ops->sched_scan_stop = NULL;
-
-               wiphy->max_sched_scan_plan_interval = 0;
-               wiphy->max_sched_scan_ie_len = 0;
-               wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
-               wiphy->max_sched_scan_ssids = 0;
-               wiphy->max_match_sets = 0;
-               wiphy->max_sched_scan_reqs = 0;
-       }
+       mt7615_check_offload_capability(dev);
 }
 
 static int mt7615_init_hardware(struct mt7615_dev *dev)
index 3964206..1fbc960 100644 (file)
@@ -103,6 +103,7 @@ static void mt7663u_init_work(struct work_struct *work)
        mt7615_mac_init(dev);
        mt7615_phy_init(dev);
        mt7615_mcu_del_wtbl_all(dev);
+       mt7615_check_offload_capability(dev);
 }
 
 int mt7663u_register_device(struct mt7615_dev *dev)
@@ -119,9 +120,6 @@ int mt7663u_register_device(struct mt7615_dev *dev)
        if (err)
                return err;
 
-       ieee80211_hw_set(hw, SUPPORTS_PS);
-       ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
-
        hw->extra_tx_headroom += MT_USB_HDR_SIZE + MT_USB_TXD_SIZE;
        /* check hw sg support in order to enable AMSDU */
        hw->max_tx_fragments = dev->mt76.usb.sg_en ? MT_HW_TXP_MAX_BUF_NUM : 1;