Skip to content

Commit

Permalink
mt76: mt7615: introduce mt7615_check_offload_capability routine
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed May 5, 2020
1 parent 9636177 commit d4ba139
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
26 changes: 26 additions & 0 deletions mt7615/init.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions mt7615/mt7615.h
Expand Up @@ -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);
Expand Down
21 changes: 1 addition & 20 deletions mt7615/pci_init.c
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions mt7615/usb_init.c
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit d4ba139

Please sign in to comment.