Commit 53b42ae2 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7615: introduce mt7615_check_offload_capability routine

Introduce mt7615_check_offload_capability routine to set hw/wiphy
offload capabilities according to the running firmware
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 0fe96975
...@@ -130,6 +130,32 @@ void mt7615_mac_init(struct mt7615_dev *dev) ...@@ -130,6 +130,32 @@ void mt7615_mac_init(struct mt7615_dev *dev)
} }
EXPORT_SYMBOL_GPL(mt7615_mac_init); 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) bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev)
{ {
flush_work(&dev->mcu_work); flush_work(&dev->mcu_work);
......
...@@ -370,6 +370,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, ...@@ -370,6 +370,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
int irq, const u32 *map); int irq, const u32 *map);
u32 mt7615_reg_map(struct mt7615_dev *dev, u32 addr); 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); void mt7615_init_device(struct mt7615_dev *dev);
int mt7615_register_device(struct mt7615_dev *dev); int mt7615_register_device(struct mt7615_dev *dev);
void mt7615_unregister_device(struct mt7615_dev *dev); void mt7615_unregister_device(struct mt7615_dev *dev);
......
...@@ -16,7 +16,6 @@ static void mt7615_init_work(struct work_struct *work) ...@@ -16,7 +16,6 @@ static void mt7615_init_work(struct work_struct *work)
{ {
struct mt7615_dev *dev = container_of(work, struct mt7615_dev, struct mt7615_dev *dev = container_of(work, struct mt7615_dev,
mcu_work); mcu_work);
struct ieee80211_hw *hw = mt76_hw(dev);
if (mt7615_mcu_init(dev)) if (mt7615_mcu_init(dev))
return; return;
...@@ -25,25 +24,7 @@ static void mt7615_init_work(struct work_struct *work) ...@@ -25,25 +24,7 @@ static void mt7615_init_work(struct work_struct *work)
mt7615_mac_init(dev); mt7615_mac_init(dev);
mt7615_phy_init(dev); mt7615_phy_init(dev);
mt7615_mcu_del_wtbl_all(dev); mt7615_mcu_del_wtbl_all(dev);
mt7615_check_offload_capability(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;
}
} }
static int mt7615_init_hardware(struct mt7615_dev *dev) static int mt7615_init_hardware(struct mt7615_dev *dev)
......
...@@ -103,6 +103,7 @@ static void mt7663u_init_work(struct work_struct *work) ...@@ -103,6 +103,7 @@ static void mt7663u_init_work(struct work_struct *work)
mt7615_mac_init(dev); mt7615_mac_init(dev);
mt7615_phy_init(dev); mt7615_phy_init(dev);
mt7615_mcu_del_wtbl_all(dev); mt7615_mcu_del_wtbl_all(dev);
mt7615_check_offload_capability(dev);
} }
int mt7663u_register_device(struct mt7615_dev *dev) int mt7663u_register_device(struct mt7615_dev *dev)
...@@ -119,9 +120,6 @@ int mt7663u_register_device(struct mt7615_dev *dev) ...@@ -119,9 +120,6 @@ int mt7663u_register_device(struct mt7615_dev *dev)
if (err) if (err)
return 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; hw->extra_tx_headroom += MT_USB_HDR_SIZE + MT_USB_TXD_SIZE;
/* check hw sg support in order to enable AMSDU */ /* 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; hw->max_tx_fragments = dev->mt76.usb.sg_en ? MT_HW_TXP_MAX_BUF_NUM : 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment