main.c (20249e1a853c412f452aa6ee0beb752360e69f17) main.c (c74df1c067f2af0a3758a5ab02806f501473797c)
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/etherdevice.h>
5#include <linux/platform_device.h>
6#include <linux/pci.h>
7#include <linux/module.h>
8#include <net/ipv6.h>

--- 230 unchanged lines hidden (view full) ---

239 err = mt7921_set_tx_sar_pwr(mphy->hw, NULL);
240 if (err)
241 return err;
242
243 mt7921_mac_reset_counters(phy);
244 set_bit(MT76_STATE_RUNNING, &mphy->state);
245
246 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/etherdevice.h>
5#include <linux/platform_device.h>
6#include <linux/pci.h>
7#include <linux/module.h>
8#include <net/ipv6.h>

--- 230 unchanged lines hidden (view full) ---

239 err = mt7921_set_tx_sar_pwr(mphy->hw, NULL);
240 if (err)
241 return err;
242
243 mt7921_mac_reset_counters(phy);
244 set_bit(MT76_STATE_RUNNING, &mphy->state);
245
246 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
247 MT7921_WATCHDOG_TIME);
247 MT792x_WATCHDOG_TIME);
248
249 return 0;
250}
251EXPORT_SYMBOL_GPL(__mt7921_start);
252
253static int mt7921_start(struct ieee80211_hw *hw)
254{
248
249 return 0;
250}
251EXPORT_SYMBOL_GPL(__mt7921_start);
252
253static int mt7921_start(struct ieee80211_hw *hw)
254{
255 struct mt792x_phy *phy = mt7921_hw_phy(hw);
255 struct mt792x_phy *phy = mt792x_hw_phy(hw);
256 int err;
257
258 mt792x_mutex_acquire(phy->dev);
259 err = __mt7921_start(phy);
260 mt792x_mutex_release(phy->dev);
261
262 return err;
263}
264
265void mt7921_stop(struct ieee80211_hw *hw)
266{
267 struct mt792x_dev *dev = mt792x_hw_dev(hw);
256 int err;
257
258 mt792x_mutex_acquire(phy->dev);
259 err = __mt7921_start(phy);
260 mt792x_mutex_release(phy->dev);
261
262 return err;
263}
264
265void mt7921_stop(struct ieee80211_hw *hw)
266{
267 struct mt792x_dev *dev = mt792x_hw_dev(hw);
268 struct mt792x_phy *phy = mt7921_hw_phy(hw);
268 struct mt792x_phy *phy = mt792x_hw_phy(hw);
269
270 cancel_delayed_work_sync(&phy->mt76->mac_work);
271
272 cancel_delayed_work_sync(&dev->pm.ps_work);
273 cancel_work_sync(&dev->pm.wake_work);
274 cancel_work_sync(&dev->reset_work);
275 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
276
277 mt792x_mutex_acquire(dev);
278 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
279 mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
280 mt792x_mutex_release(dev);
281}
282EXPORT_SYMBOL_GPL(mt7921_stop);
283
269
270 cancel_delayed_work_sync(&phy->mt76->mac_work);
271
272 cancel_delayed_work_sync(&dev->pm.ps_work);
273 cancel_work_sync(&dev->pm.wake_work);
274 cancel_work_sync(&dev->reset_work);
275 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
276
277 mt792x_mutex_acquire(dev);
278 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
279 mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
280 mt792x_mutex_release(dev);
281}
282EXPORT_SYMBOL_GPL(mt7921_stop);
283
284static int mt7921_add_interface(struct ieee80211_hw *hw,
285 struct ieee80211_vif *vif)
284static int
285mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
286{
287 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
288 struct mt792x_dev *dev = mt792x_hw_dev(hw);
286{
287 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
288 struct mt792x_dev *dev = mt792x_hw_dev(hw);
289 struct mt792x_phy *phy = mt7921_hw_phy(hw);
289 struct mt792x_phy *phy = mt792x_hw_phy(hw);
290 struct mt76_txq *mtxq;
291 int idx, ret = 0;
292
293 mt792x_mutex_acquire(dev);
294
295 mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
290 struct mt76_txq *mtxq;
291 int idx, ret = 0;
292
293 mt792x_mutex_acquire(dev);
294
295 mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
296 if (mvif->mt76.idx >= MT7921_MAX_INTERFACES) {
296 if (mvif->mt76.idx >= MT792x_MAX_INTERFACES) {
297 ret = -ENOSPC;
298 goto out;
299 }
300
301 mvif->mt76.omac_idx = mvif->mt76.idx;
302 mvif->phy = phy;
303 mvif->mt76.band_idx = 0;
304 mvif->mt76.wmm_idx = mvif->mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
305
306 ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid,
307 true);
308 if (ret)
309 goto out;
310
311 dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
312 phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
313
297 ret = -ENOSPC;
298 goto out;
299 }
300
301 mvif->mt76.omac_idx = mvif->mt76.idx;
302 mvif->phy = phy;
303 mvif->mt76.band_idx = 0;
304 mvif->mt76.wmm_idx = mvif->mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
305
306 ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid,
307 true);
308 if (ret)
309 goto out;
310
311 dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
312 phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
313
314 idx = MT7921_WTBL_RESERVED - mvif->mt76.idx;
314 idx = MT792x_WTBL_RESERVED - mvif->mt76.idx;
315
316 INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
317 mvif->sta.wcid.idx = idx;
318 mvif->sta.wcid.phy_idx = mvif->mt76.band_idx;
319 mvif->sta.wcid.hw_key_idx = -1;
320 mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
321 mt76_packet_id_init(&mvif->sta.wcid);
322

--- 10 unchanged lines hidden (view full) ---

333
334 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
335out:
336 mt792x_mutex_release(dev);
337
338 return ret;
339}
340
315
316 INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
317 mvif->sta.wcid.idx = idx;
318 mvif->sta.wcid.phy_idx = mvif->mt76.band_idx;
319 mvif->sta.wcid.hw_key_idx = -1;
320 mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
321 mt76_packet_id_init(&mvif->sta.wcid);
322

--- 10 unchanged lines hidden (view full) ---

333
334 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
335out:
336 mt792x_mutex_release(dev);
337
338 return ret;
339}
340
341static void mt7921_remove_interface(struct ieee80211_hw *hw,
342 struct ieee80211_vif *vif)
343{
344 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
345 struct mt792x_sta *msta = &mvif->sta;
346 struct mt792x_dev *dev = mt792x_hw_dev(hw);
347 struct mt792x_phy *phy = mt7921_hw_phy(hw);
348 int idx = msta->wcid.idx;
349
350 mt792x_mutex_acquire(dev);
351 mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
352 mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, false);
353
354 rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
355
356 dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
357 phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
358 mt792x_mutex_release(dev);
359
360 spin_lock_bh(&dev->mt76.sta_poll_lock);
361 if (!list_empty(&msta->wcid.poll_list))
362 list_del_init(&msta->wcid.poll_list);
363 spin_unlock_bh(&dev->mt76.sta_poll_lock);
364
365 mt76_packet_id_flush(&dev->mt76, &msta->wcid);
366}
367
368static void mt7921_roc_iter(void *priv, u8 *mac,
369 struct ieee80211_vif *vif)
370{
371 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
372 struct mt792x_phy *phy = priv;
373
374 mt7921_mcu_abort_roc(phy, mvif, phy->roc_token_id);
375}

--- 11 unchanged lines hidden (view full) ---

387 mt792x_mutex_acquire(phy->dev);
388 ieee80211_iterate_active_interfaces(phy->mt76->hw,
389 IEEE80211_IFACE_ITER_RESUME_ALL,
390 mt7921_roc_iter, phy);
391 mt792x_mutex_release(phy->dev);
392 ieee80211_remain_on_channel_expired(phy->mt76->hw);
393}
394
341static void mt7921_roc_iter(void *priv, u8 *mac,
342 struct ieee80211_vif *vif)
343{
344 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
345 struct mt792x_phy *phy = priv;
346
347 mt7921_mcu_abort_roc(phy, mvif, phy->roc_token_id);
348}

--- 11 unchanged lines hidden (view full) ---

360 mt792x_mutex_acquire(phy->dev);
361 ieee80211_iterate_active_interfaces(phy->mt76->hw,
362 IEEE80211_IFACE_ITER_RESUME_ALL,
363 mt7921_roc_iter, phy);
364 mt792x_mutex_release(phy->dev);
365 ieee80211_remain_on_channel_expired(phy->mt76->hw);
366}
367
395void mt7921_roc_timer(struct timer_list *timer)
396{
397 struct mt792x_phy *phy = from_timer(phy, timer, roc_timer);
398
399 ieee80211_queue_work(phy->mt76->hw, &phy->roc_work);
400}
401
402static int mt7921_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif)
403{
404 int err = 0;
405
406 del_timer_sync(&phy->roc_timer);
407 cancel_work_sync(&phy->roc_work);
408
409 mt792x_mutex_acquire(phy->dev);

--- 36 unchanged lines hidden (view full) ---

446
447static int mt7921_remain_on_channel(struct ieee80211_hw *hw,
448 struct ieee80211_vif *vif,
449 struct ieee80211_channel *chan,
450 int duration,
451 enum ieee80211_roc_type type)
452{
453 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
368static int mt7921_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif)
369{
370 int err = 0;
371
372 del_timer_sync(&phy->roc_timer);
373 cancel_work_sync(&phy->roc_work);
374
375 mt792x_mutex_acquire(phy->dev);

--- 36 unchanged lines hidden (view full) ---

412
413static int mt7921_remain_on_channel(struct ieee80211_hw *hw,
414 struct ieee80211_vif *vif,
415 struct ieee80211_channel *chan,
416 int duration,
417 enum ieee80211_roc_type type)
418{
419 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
454 struct mt792x_phy *phy = mt7921_hw_phy(hw);
420 struct mt792x_phy *phy = mt792x_hw_phy(hw);
455 int err;
456
457 mt792x_mutex_acquire(phy->dev);
458 err = mt7921_set_roc(phy, mvif, chan, duration, MT7921_ROC_REQ_ROC);
459 mt792x_mutex_release(phy->dev);
460
461 return err;
462}
463
464static int mt7921_cancel_remain_on_channel(struct ieee80211_hw *hw,
465 struct ieee80211_vif *vif)
466{
467 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
421 int err;
422
423 mt792x_mutex_acquire(phy->dev);
424 err = mt7921_set_roc(phy, mvif, chan, duration, MT7921_ROC_REQ_ROC);
425 mt792x_mutex_release(phy->dev);
426
427 return err;
428}
429
430static int mt7921_cancel_remain_on_channel(struct ieee80211_hw *hw,
431 struct ieee80211_vif *vif)
432{
433 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
468 struct mt792x_phy *phy = mt7921_hw_phy(hw);
434 struct mt792x_phy *phy = mt792x_hw_phy(hw);
469
470 return mt7921_abort_roc(phy, mvif);
471}
472
473static int mt7921_set_channel(struct mt792x_phy *phy)
474{
475 struct mt792x_dev *dev = phy->dev;
476 int ret;

--- 4 unchanged lines hidden (view full) ---

481 set_bit(MT76_RESET, &phy->mt76->state);
482
483 mt76_set_channel(phy->mt76);
484
485 ret = mt7921_mcu_set_chan_info(phy, MCU_EXT_CMD(CHANNEL_SWITCH));
486 if (ret)
487 goto out;
488
435
436 return mt7921_abort_roc(phy, mvif);
437}
438
439static int mt7921_set_channel(struct mt792x_phy *phy)
440{
441 struct mt792x_dev *dev = phy->dev;
442 int ret;

--- 4 unchanged lines hidden (view full) ---

447 set_bit(MT76_RESET, &phy->mt76->state);
448
449 mt76_set_channel(phy->mt76);
450
451 ret = mt7921_mcu_set_chan_info(phy, MCU_EXT_CMD(CHANNEL_SWITCH));
452 if (ret)
453 goto out;
454
489 mt7921_mac_set_timing(phy);
455 mt792x_mac_set_timeing(phy);
490
491 mt7921_mac_reset_counters(phy);
492 phy->noise = 0;
493
494out:
495 clear_bit(MT76_RESET, &phy->mt76->state);
496 mt792x_mutex_release(dev);
497
498 mt76_worker_schedule(&dev->mt76.tx_worker);
499 ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mt76->mac_work,
456
457 mt7921_mac_reset_counters(phy);
458 phy->noise = 0;
459
460out:
461 clear_bit(MT76_RESET, &phy->mt76->state);
462 mt792x_mutex_release(dev);
463
464 mt76_worker_schedule(&dev->mt76.tx_worker);
465 ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mt76->mac_work,
500 MT7921_WATCHDOG_TIME);
466 MT792x_WATCHDOG_TIME);
501
502 return ret;
503}
504
505static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
506 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
507 struct ieee80211_key_conf *key)
508{

--- 117 unchanged lines hidden (view full) ---

626 mt7921_pm_interface_iter, dev);
627 pm->ds_enable = pm->ds_enable_user && !monitor;
628 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
629}
630
631static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
632{
633 struct mt792x_dev *dev = mt792x_hw_dev(hw);
467
468 return ret;
469}
470
471static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
472 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
473 struct ieee80211_key_conf *key)
474{

--- 117 unchanged lines hidden (view full) ---

592 mt7921_pm_interface_iter, dev);
593 pm->ds_enable = pm->ds_enable_user && !monitor;
594 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
595}
596
597static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
598{
599 struct mt792x_dev *dev = mt792x_hw_dev(hw);
634 struct mt792x_phy *phy = mt7921_hw_phy(hw);
600 struct mt792x_phy *phy = mt792x_hw_phy(hw);
635 int ret = 0;
636
637 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
638 ieee80211_stop_queues(hw);
639 ret = mt7921_set_channel(phy);
640 if (ret)
641 return ret;
642 ieee80211_wake_queues(hw);

--- 14 unchanged lines hidden (view full) ---

657 }
658
659out:
660 mt792x_mutex_release(dev);
661
662 return ret;
663}
664
601 int ret = 0;
602
603 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
604 ieee80211_stop_queues(hw);
605 ret = mt7921_set_channel(phy);
606 if (ret)
607 return ret;
608 ieee80211_wake_queues(hw);

--- 14 unchanged lines hidden (view full) ---

623 }
624
625out:
626 mt792x_mutex_release(dev);
627
628 return ret;
629}
630
665static int
666mt7921_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
667 unsigned int link_id, u16 queue,
668 const struct ieee80211_tx_queue_params *params)
669{
670 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
671
672 /* no need to update right away, we'll get BSS_CHANGED_QOS */
673 queue = mt76_connac_lmac_mapping(queue);
674 mvif->queue_params[queue] = *params;
675
676 return 0;
677}
678
679static void mt7921_configure_filter(struct ieee80211_hw *hw,
680 unsigned int changed_flags,
681 unsigned int *total_flags,
682 u64 multicast)
683{
684#define MT7921_FILTER_FCSFAIL BIT(2)
685#define MT7921_FILTER_CONTROL BIT(5)
686#define MT7921_FILTER_OTHER_BSS BIT(6)

--- 18 unchanged lines hidden (view full) ---

705 *total_flags &= (FIF_OTHER_BSS | FIF_FCSFAIL | FIF_CONTROL);
706}
707
708static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
709 struct ieee80211_vif *vif,
710 struct ieee80211_bss_conf *info,
711 u64 changed)
712{
631static void mt7921_configure_filter(struct ieee80211_hw *hw,
632 unsigned int changed_flags,
633 unsigned int *total_flags,
634 u64 multicast)
635{
636#define MT7921_FILTER_FCSFAIL BIT(2)
637#define MT7921_FILTER_CONTROL BIT(5)
638#define MT7921_FILTER_OTHER_BSS BIT(6)

--- 18 unchanged lines hidden (view full) ---

657 *total_flags &= (FIF_OTHER_BSS | FIF_FCSFAIL | FIF_CONTROL);
658}
659
660static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
661 struct ieee80211_vif *vif,
662 struct ieee80211_bss_conf *info,
663 u64 changed)
664{
713 struct mt792x_phy *phy = mt7921_hw_phy(hw);
665 struct mt792x_phy *phy = mt792x_hw_phy(hw);
714 struct mt792x_dev *dev = mt792x_hw_dev(hw);
715
716 mt792x_mutex_acquire(dev);
717
718 if (changed & BSS_CHANGED_ERP_SLOT) {
719 int slottime = info->use_short_slot ? 9 : 20;
720
721 if (slottime != phy->slottime) {
722 phy->slottime = slottime;
666 struct mt792x_dev *dev = mt792x_hw_dev(hw);
667
668 mt792x_mutex_acquire(dev);
669
670 if (changed & BSS_CHANGED_ERP_SLOT) {
671 int slottime = info->use_short_slot ? 9 : 20;
672
673 if (slottime != phy->slottime) {
674 phy->slottime = slottime;
723 mt7921_mac_set_timing(phy);
675 mt792x_mac_set_timeing(phy);
724 }
725 }
726
727 if (changed & (BSS_CHANGED_BEACON |
728 BSS_CHANGED_BEACON_ENABLED))
729 mt7921_mcu_uni_add_beacon_offload(dev, hw, vif,
730 info->enable_beacon);
731

--- 23 unchanged lines hidden (view full) ---

755int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
756 struct ieee80211_sta *sta)
757{
758 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
759 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
760 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
761 int ret, idx;
762
676 }
677 }
678
679 if (changed & (BSS_CHANGED_BEACON |
680 BSS_CHANGED_BEACON_ENABLED))
681 mt7921_mcu_uni_add_beacon_offload(dev, hw, vif,
682 info->enable_beacon);
683

--- 23 unchanged lines hidden (view full) ---

707int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
708 struct ieee80211_sta *sta)
709{
710 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
711 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
712 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
713 int ret, idx;
714
763 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
715 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT792x_WTBL_STA - 1);
764 if (idx < 0)
765 return -ENOSPC;
766
767 INIT_LIST_HEAD(&msta->wcid.poll_list);
768 msta->vif = mvif;
769 msta->wcid.sta = 1;
770 msta->wcid.idx = idx;
771 msta->wcid.phy_idx = mvif->mt76.band_idx;

--- 74 unchanged lines hidden (view full) ---

846 if (!list_empty(&msta->wcid.poll_list))
847 list_del_init(&msta->wcid.poll_list);
848 spin_unlock_bh(&dev->mt76.sta_poll_lock);
849
850 mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
851}
852EXPORT_SYMBOL_GPL(mt7921_mac_sta_remove);
853
716 if (idx < 0)
717 return -ENOSPC;
718
719 INIT_LIST_HEAD(&msta->wcid.poll_list);
720 msta->vif = mvif;
721 msta->wcid.sta = 1;
722 msta->wcid.idx = idx;
723 msta->wcid.phy_idx = mvif->mt76.band_idx;

--- 74 unchanged lines hidden (view full) ---

798 if (!list_empty(&msta->wcid.poll_list))
799 list_del_init(&msta->wcid.poll_list);
800 spin_unlock_bh(&dev->mt76.sta_poll_lock);
801
802 mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
803}
804EXPORT_SYMBOL_GPL(mt7921_mac_sta_remove);
805
854void mt7921_tx_worker(struct mt76_worker *w)
855{
856 struct mt792x_dev *dev = container_of(w, struct mt792x_dev,
857 mt76.tx_worker);
858
859 if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) {
860 queue_work(dev->mt76.wq, &dev->pm.wake_work);
861 return;
862 }
863
864 mt76_txq_schedule_all(&dev->mphy);
865 mt76_connac_pm_unref(&dev->mphy, &dev->pm);
866}
867
868static void mt7921_tx(struct ieee80211_hw *hw,
869 struct ieee80211_tx_control *control,
870 struct sk_buff *skb)
871{
872 struct mt792x_dev *dev = mt792x_hw_dev(hw);
873 struct mt76_phy *mphy = hw->priv;
874 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
875 struct ieee80211_vif *vif = info->control.vif;
876 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
877 int qid;
878
879 if (control->sta) {
880 struct mt792x_sta *sta;
881
882 sta = (struct mt792x_sta *)control->sta->drv_priv;
883 wcid = &sta->wcid;
884 }
885
886 if (vif && !control->sta) {
887 struct mt792x_vif *mvif;
888
889 mvif = (struct mt792x_vif *)vif->drv_priv;
890 wcid = &mvif->sta.wcid;
891 }
892
893 if (mt76_connac_pm_ref(mphy, &dev->pm)) {
894 mt76_tx(mphy, control->sta, wcid, skb);
895 mt76_connac_pm_unref(mphy, &dev->pm);
896 return;
897 }
898
899 qid = skb_get_queue_mapping(skb);
900 if (qid >= MT_TXQ_PSD) {
901 qid = IEEE80211_AC_BE;
902 skb_set_queue_mapping(skb, qid);
903 }
904
905 mt76_connac_pm_queue_skb(hw, &dev->pm, wcid, skb);
906}
907
908static int mt7921_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
909{
910 struct mt792x_dev *dev = mt792x_hw_dev(hw);
911
912 mt792x_mutex_acquire(dev);
913 mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, 0);
914 mt792x_mutex_release(dev);
915

--- 69 unchanged lines hidden (view full) ---

985 mt792x_mutex_acquire(dev);
986 mt76_connac_sta_state_dp(&dev->mt76, old_state, new_state);
987 mt792x_mutex_release(dev);
988 }
989
990 return mt76_sta_state(hw, vif, sta, old_state, new_state);
991}
992
806static int mt7921_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
807{
808 struct mt792x_dev *dev = mt792x_hw_dev(hw);
809
810 mt792x_mutex_acquire(dev);
811 mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, 0);
812 mt792x_mutex_release(dev);
813

--- 69 unchanged lines hidden (view full) ---

883 mt792x_mutex_acquire(dev);
884 mt76_connac_sta_state_dp(&dev->mt76, old_state, new_state);
885 mt792x_mutex_release(dev);
886 }
887
888 return mt76_sta_state(hw, vif, sta, old_state, new_state);
889}
890
993static int
994mt7921_get_stats(struct ieee80211_hw *hw,
995 struct ieee80211_low_level_stats *stats)
996{
997 struct mt792x_phy *phy = mt7921_hw_phy(hw);
998 struct mt76_mib_stats *mib = &phy->mib;
999
1000 mt792x_mutex_acquire(phy->dev);
1001
1002 stats->dot11RTSSuccessCount = mib->rts_cnt;
1003 stats->dot11RTSFailureCount = mib->rts_retries_cnt;
1004 stats->dot11FCSErrorCount = mib->fcs_err_cnt;
1005 stats->dot11ACKFailureCount = mib->ack_fail_cnt;
1006
1007 mt792x_mutex_release(phy->dev);
1008
1009 return 0;
1010}
1011
1012static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = {
1013 /* tx counters */
1014 "tx_ampdu_cnt",
1015 "tx_mpdu_attempts",
1016 "tx_mpdu_success",
1017 "tx_pkt_ebf_cnt",
1018 "tx_pkt_ibf_cnt",
1019 "tx_ampdu_len:0-1",
1020 "tx_ampdu_len:2-10",
1021 "tx_ampdu_len:11-19",
1022 "tx_ampdu_len:20-28",
1023 "tx_ampdu_len:29-37",
1024 "tx_ampdu_len:38-46",
1025 "tx_ampdu_len:47-55",
1026 "tx_ampdu_len:56-79",
1027 "tx_ampdu_len:80-103",
1028 "tx_ampdu_len:104-127",
1029 "tx_ampdu_len:128-151",
1030 "tx_ampdu_len:152-175",
1031 "tx_ampdu_len:176-199",
1032 "tx_ampdu_len:200-223",
1033 "tx_ampdu_len:224-247",
1034 "ba_miss_count",
1035 "tx_beamformer_ppdu_iBF",
1036 "tx_beamformer_ppdu_eBF",
1037 "tx_beamformer_rx_feedback_all",
1038 "tx_beamformer_rx_feedback_he",
1039 "tx_beamformer_rx_feedback_vht",
1040 "tx_beamformer_rx_feedback_ht",
1041 "tx_msdu_pack_1",
1042 "tx_msdu_pack_2",
1043 "tx_msdu_pack_3",
1044 "tx_msdu_pack_4",
1045 "tx_msdu_pack_5",
1046 "tx_msdu_pack_6",
1047 "tx_msdu_pack_7",
1048 "tx_msdu_pack_8",
1049 /* rx counters */
1050 "rx_mpdu_cnt",
1051 "rx_ampdu_cnt",
1052 "rx_ampdu_bytes_cnt",
1053 "rx_ba_cnt",
1054 /* per vif counters */
1055 "v_tx_mode_cck",
1056 "v_tx_mode_ofdm",
1057 "v_tx_mode_ht",
1058 "v_tx_mode_ht_gf",
1059 "v_tx_mode_vht",
1060 "v_tx_mode_he_su",
1061 "v_tx_mode_he_ext_su",
1062 "v_tx_mode_he_tb",
1063 "v_tx_mode_he_mu",
1064 "v_tx_bw_20",
1065 "v_tx_bw_40",
1066 "v_tx_bw_80",
1067 "v_tx_bw_160",
1068 "v_tx_mcs_0",
1069 "v_tx_mcs_1",
1070 "v_tx_mcs_2",
1071 "v_tx_mcs_3",
1072 "v_tx_mcs_4",
1073 "v_tx_mcs_5",
1074 "v_tx_mcs_6",
1075 "v_tx_mcs_7",
1076 "v_tx_mcs_8",
1077 "v_tx_mcs_9",
1078 "v_tx_mcs_10",
1079 "v_tx_mcs_11",
1080 "v_tx_nss_1",
1081 "v_tx_nss_2",
1082 "v_tx_nss_3",
1083 "v_tx_nss_4",
1084};
1085
1086static void
1087mt7921_get_et_strings(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1088 u32 sset, u8 *data)
1089{
1090 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1091
1092 if (sset != ETH_SS_STATS)
1093 return;
1094
1095 memcpy(data, *mt7921_gstrings_stats, sizeof(mt7921_gstrings_stats));
1096
1097 if (mt76_is_sdio(&dev->mt76))
1098 return;
1099
1100 data += sizeof(mt7921_gstrings_stats);
1101 page_pool_ethtool_stats_get_strings(data);
1102}
1103
1104static int
1105mt7921_get_et_sset_count(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1106 int sset)
1107{
1108 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1109
1110 if (sset != ETH_SS_STATS)
1111 return 0;
1112
1113 if (mt76_is_sdio(&dev->mt76))
1114 return ARRAY_SIZE(mt7921_gstrings_stats);
1115
1116 return ARRAY_SIZE(mt7921_gstrings_stats) +
1117 page_pool_ethtool_stats_get_count();
1118}
1119
1120static void
1121mt7921_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
1122{
1123 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
1124 struct mt76_ethtool_worker_info *wi = wi_data;
1125
1126 if (msta->vif->mt76.idx != wi->idx)
1127 return;
1128
1129 mt76_ethtool_worker(wi, &msta->wcid.stats, false);
1130}
1131
1132static
1133void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1134 struct ethtool_stats *stats, u64 *data)
1135{
1136 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1137 int stats_size = ARRAY_SIZE(mt7921_gstrings_stats);
1138 struct mt792x_phy *phy = mt7921_hw_phy(hw);
1139 struct mt792x_dev *dev = phy->dev;
1140 struct mt76_mib_stats *mib = &phy->mib;
1141 struct mt76_ethtool_worker_info wi = {
1142 .data = data,
1143 .idx = mvif->mt76.idx,
1144 };
1145 int i, ei = 0;
1146
1147 mt792x_mutex_acquire(dev);
1148
1149 mt7921_mac_update_mib_stats(phy);
1150
1151 data[ei++] = mib->tx_ampdu_cnt;
1152 data[ei++] = mib->tx_mpdu_attempts_cnt;
1153 data[ei++] = mib->tx_mpdu_success_cnt;
1154 data[ei++] = mib->tx_pkt_ebf_cnt;
1155 data[ei++] = mib->tx_pkt_ibf_cnt;
1156
1157 /* Tx ampdu stat */
1158 for (i = 0; i < 15; i++)
1159 data[ei++] = phy->mt76->aggr_stats[i];
1160
1161 data[ei++] = phy->mib.ba_miss_cnt;
1162
1163 /* Tx Beamformer monitor */
1164 data[ei++] = mib->tx_bf_ibf_ppdu_cnt;
1165 data[ei++] = mib->tx_bf_ebf_ppdu_cnt;
1166
1167 /* Tx Beamformer Rx feedback monitor */
1168 data[ei++] = mib->tx_bf_rx_fb_all_cnt;
1169 data[ei++] = mib->tx_bf_rx_fb_he_cnt;
1170 data[ei++] = mib->tx_bf_rx_fb_vht_cnt;
1171 data[ei++] = mib->tx_bf_rx_fb_ht_cnt;
1172
1173 /* Tx amsdu info (pack-count histogram) */
1174 for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++)
1175 data[ei++] = mib->tx_amsdu[i];
1176
1177 /* rx counters */
1178 data[ei++] = mib->rx_mpdu_cnt;
1179 data[ei++] = mib->rx_ampdu_cnt;
1180 data[ei++] = mib->rx_ampdu_bytes_cnt;
1181 data[ei++] = mib->rx_ba_cnt;
1182
1183 /* Add values for all stations owned by this vif */
1184 wi.initial_stat_idx = ei;
1185 ieee80211_iterate_stations_atomic(hw, mt7921_ethtool_worker, &wi);
1186
1187 mt792x_mutex_release(dev);
1188
1189 if (!wi.sta_count)
1190 return;
1191
1192 ei += wi.worker_stat_count;
1193
1194 if (!mt76_is_sdio(&dev->mt76)) {
1195 mt76_ethtool_page_pool_stats(&dev->mt76, &data[ei], &ei);
1196 stats_size += page_pool_ethtool_stats_get_count();
1197 }
1198
1199 if (ei != stats_size)
1200 dev_err(dev->mt76.dev, "ei: %d SSTATS_LEN: %d", ei, stats_size);
1201}
1202
1203static u64
1204mt7921_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1205{
1206 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1207 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1208 u8 omac_idx = mvif->mt76.omac_idx;
1209 union {
1210 u64 t64;
1211 u32 t32[2];
1212 } tsf;
1213 u16 n;
1214
1215 mt792x_mutex_acquire(dev);
1216
1217 n = omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : omac_idx;
1218 /* TSF software read */
1219 mt76_set(dev, MT_LPON_TCR(0, n), MT_LPON_TCR_SW_MODE);
1220 tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(0));
1221 tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(0));
1222
1223 mt792x_mutex_release(dev);
1224
1225 return tsf.t64;
1226}
1227
1228static void
1229mt7921_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1230 u64 timestamp)
1231{
1232 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1233 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1234 u8 omac_idx = mvif->mt76.omac_idx;
1235 union {
1236 u64 t64;
1237 u32 t32[2];
1238 } tsf = { .t64 = timestamp, };
1239 u16 n;
1240
1241 mt792x_mutex_acquire(dev);
1242
1243 n = omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : omac_idx;
1244 mt76_wr(dev, MT_LPON_UTTR0(0), tsf.t32[0]);
1245 mt76_wr(dev, MT_LPON_UTTR1(0), tsf.t32[1]);
1246 /* TSF software overwrite */
1247 mt76_set(dev, MT_LPON_TCR(0, n), MT_LPON_TCR_SW_WRITE);
1248
1249 mt792x_mutex_release(dev);
1250}
1251
1252static void
1253mt7921_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
1254{
1255 struct mt792x_phy *phy = mt7921_hw_phy(hw);
1256 struct mt792x_dev *dev = phy->dev;
1257
1258 mt792x_mutex_acquire(dev);
1259 phy->coverage_class = max_t(s16, coverage_class, 0);
1260 mt7921_mac_set_timing(phy);
1261 mt792x_mutex_release(dev);
1262}
1263
1264void mt7921_scan_work(struct work_struct *work)
1265{
1266 struct mt792x_phy *phy;
1267
1268 phy = (struct mt792x_phy *)container_of(work, struct mt792x_phy,
1269 scan_work.work);
1270
1271 while (true) {

--- 83 unchanged lines hidden (view full) ---

1355
1356 return err;
1357}
1358
1359static int
1360mt7921_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
1361{
1362 struct mt792x_dev *dev = mt792x_hw_dev(hw);
891void mt7921_scan_work(struct work_struct *work)
892{
893 struct mt792x_phy *phy;
894
895 phy = (struct mt792x_phy *)container_of(work, struct mt792x_phy,
896 scan_work.work);
897
898 while (true) {

--- 83 unchanged lines hidden (view full) ---

982
983 return err;
984}
985
986static int
987mt7921_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
988{
989 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1363 struct mt792x_phy *phy = mt7921_hw_phy(hw);
990 struct mt792x_phy *phy = mt792x_hw_phy(hw);
1364 int max_nss = hweight8(hw->wiphy->available_antennas_tx);
1365
1366 if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss)
1367 return -EINVAL;
1368
1369 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)
1370 return -EINVAL;
1371

--- 5 unchanged lines hidden (view full) ---

1377 mt76_set_stream_caps(phy->mt76, true);
1378 mt7921_set_stream_he_caps(phy);
1379
1380 mt792x_mutex_release(dev);
1381
1382 return 0;
1383}
1384
991 int max_nss = hweight8(hw->wiphy->available_antennas_tx);
992
993 if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss)
994 return -EINVAL;
995
996 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)
997 return -EINVAL;
998

--- 5 unchanged lines hidden (view full) ---

1004 mt76_set_stream_caps(phy->mt76, true);
1005 mt7921_set_stream_he_caps(phy);
1006
1007 mt792x_mutex_release(dev);
1008
1009 return 0;
1010}
1011
1385static void mt7921_sta_statistics(struct ieee80211_hw *hw,
1386 struct ieee80211_vif *vif,
1387 struct ieee80211_sta *sta,
1388 struct station_info *sinfo)
1389{
1390 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
1391 struct rate_info *txrate = &msta->wcid.rate;
1392
1393 if (!txrate->legacy && !txrate->flags)
1394 return;
1395
1396 if (txrate->legacy) {
1397 sinfo->txrate.legacy = txrate->legacy;
1398 } else {
1399 sinfo->txrate.mcs = txrate->mcs;
1400 sinfo->txrate.nss = txrate->nss;
1401 sinfo->txrate.bw = txrate->bw;
1402 sinfo->txrate.he_gi = txrate->he_gi;
1403 sinfo->txrate.he_dcm = txrate->he_dcm;
1404 sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc;
1405 }
1406 sinfo->tx_failed = msta->wcid.stats.tx_failed;
1407 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
1408
1409 sinfo->tx_retries = msta->wcid.stats.tx_retries;
1410 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
1411
1412 sinfo->txrate.flags = txrate->flags;
1413 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
1414
1415 sinfo->ack_signal = (s8)msta->ack_signal;
1416 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL);
1417
1418 sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&msta->avg_ack_signal);
1419 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG);
1420}
1421
1422#ifdef CONFIG_PM
1423static int mt7921_suspend(struct ieee80211_hw *hw,
1424 struct cfg80211_wowlan *wowlan)
1425{
1426 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1012#ifdef CONFIG_PM
1013static int mt7921_suspend(struct ieee80211_hw *hw,
1014 struct cfg80211_wowlan *wowlan)
1015{
1016 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1427 struct mt792x_phy *phy = mt7921_hw_phy(hw);
1017 struct mt792x_phy *phy = mt792x_hw_phy(hw);
1428
1429 cancel_delayed_work_sync(&phy->scan_work);
1430 cancel_delayed_work_sync(&phy->mt76->mac_work);
1431
1432 cancel_delayed_work_sync(&dev->pm.ps_work);
1433 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
1434
1435 mt792x_mutex_acquire(dev);

--- 7 unchanged lines hidden (view full) ---

1443 mt792x_mutex_release(dev);
1444
1445 return 0;
1446}
1447
1448static int mt7921_resume(struct ieee80211_hw *hw)
1449{
1450 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1018
1019 cancel_delayed_work_sync(&phy->scan_work);
1020 cancel_delayed_work_sync(&phy->mt76->mac_work);
1021
1022 cancel_delayed_work_sync(&dev->pm.ps_work);
1023 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
1024
1025 mt792x_mutex_acquire(dev);

--- 7 unchanged lines hidden (view full) ---

1033 mt792x_mutex_release(dev);
1034
1035 return 0;
1036}
1037
1038static int mt7921_resume(struct ieee80211_hw *hw)
1039{
1040 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1451 struct mt792x_phy *phy = mt7921_hw_phy(hw);
1041 struct mt792x_phy *phy = mt792x_hw_phy(hw);
1452
1453 mt792x_mutex_acquire(dev);
1454
1455 set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
1456 ieee80211_iterate_active_interfaces(hw,
1457 IEEE80211_IFACE_ITER_RESUME_ALL,
1458 mt76_connac_mcu_set_suspend_iter,
1459 &dev->mphy);
1460
1461 ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
1042
1043 mt792x_mutex_acquire(dev);
1044
1045 set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
1046 ieee80211_iterate_active_interfaces(hw,
1047 IEEE80211_IFACE_ITER_RESUME_ALL,
1048 mt76_connac_mcu_set_suspend_iter,
1049 &dev->mphy);
1050
1051 ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
1462 MT7921_WATCHDOG_TIME);
1052 MT792x_WATCHDOG_TIME);
1463
1464 mt792x_mutex_release(dev);
1465
1466 return 0;
1467}
1468
1053
1054 mt792x_mutex_release(dev);
1055
1056 return 0;
1057}
1058
1469static void mt7921_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1470{
1471 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1472 struct mt76_dev *mdev = &dev->mt76;
1473
1474 device_set_wakeup_enable(mdev->dev, enabled);
1475}
1476
1477static void mt7921_set_rekey_data(struct ieee80211_hw *hw,
1478 struct ieee80211_vif *vif,
1479 struct cfg80211_gtk_rekey_data *data)
1480{
1481 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1482
1483 mt792x_mutex_acquire(dev);
1484 mt76_connac_mcu_update_gtk_rekey(hw, vif, data);
1485 mt792x_mutex_release(dev);
1486}
1487#endif /* CONFIG_PM */
1488
1059static void mt7921_set_rekey_data(struct ieee80211_hw *hw,
1060 struct ieee80211_vif *vif,
1061 struct cfg80211_gtk_rekey_data *data)
1062{
1063 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1064
1065 mt792x_mutex_acquire(dev);
1066 mt76_connac_mcu_update_gtk_rekey(hw, vif, data);
1067 mt792x_mutex_release(dev);
1068}
1069#endif /* CONFIG_PM */
1070
1489static void mt7921_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1490 u32 queues, bool drop)
1491{
1492 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1493
1494 wait_event_timeout(dev->mt76.tx_wait, !mt76_has_tx_pending(&dev->mphy),
1495 HZ / 2);
1496}
1497
1498static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
1499 struct ieee80211_vif *vif,
1500 struct ieee80211_sta *sta,
1501 bool enabled)
1502{
1503 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
1504 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1505

--- 77 unchanged lines hidden (view full) ---

1583 int err;
1584
1585 if (sar) {
1586 err = mt76_init_sar_power(hw, sar);
1587 if (err)
1588 return err;
1589 }
1590
1071static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
1072 struct ieee80211_vif *vif,
1073 struct ieee80211_sta *sta,
1074 bool enabled)
1075{
1076 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
1077 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1078

--- 77 unchanged lines hidden (view full) ---

1156 int err;
1157
1158 if (sar) {
1159 err = mt76_init_sar_power(hw, sar);
1160 if (err)
1161 return err;
1162 }
1163
1591 mt7921_init_acpi_sar_power(mt7921_hw_phy(hw), !sar);
1164 mt7921_init_acpi_sar_power(mt792x_hw_phy(hw), !sar);
1592
1593 err = mt76_connac_mcu_set_rate_txpower(mphy);
1594
1595 return err;
1596}
1597
1598static int mt7921_set_sar_specs(struct ieee80211_hw *hw,
1599 const struct cfg80211_sar_specs *sar)

--- 26 unchanged lines hidden (view full) ---

1626 mt792x_mutex_release(dev);
1627}
1628
1629static int
1630mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1631 struct ieee80211_bss_conf *link_conf)
1632{
1633 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1165
1166 err = mt76_connac_mcu_set_rate_txpower(mphy);
1167
1168 return err;
1169}
1170
1171static int mt7921_set_sar_specs(struct ieee80211_hw *hw,
1172 const struct cfg80211_sar_specs *sar)

--- 26 unchanged lines hidden (view full) ---

1199 mt792x_mutex_release(dev);
1200}
1201
1202static int
1203mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1204 struct ieee80211_bss_conf *link_conf)
1205{
1206 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1634 struct mt792x_phy *phy = mt7921_hw_phy(hw);
1207 struct mt792x_phy *phy = mt792x_hw_phy(hw);
1635 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1636 int err;
1637
1638 mt792x_mutex_acquire(dev);
1639
1640 err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
1641 true, mvif->ctx);
1642 if (err)

--- 11 unchanged lines hidden (view full) ---

1654 return err;
1655}
1656
1657static void
1658mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1659 struct ieee80211_bss_conf *link_conf)
1660{
1661 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1208 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1209 int err;
1210
1211 mt792x_mutex_acquire(dev);
1212
1213 err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
1214 true, mvif->ctx);
1215 if (err)

--- 11 unchanged lines hidden (view full) ---

1227 return err;
1228}
1229
1230static void
1231mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1232 struct ieee80211_bss_conf *link_conf)
1233{
1234 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1662 struct mt792x_phy *phy = mt7921_hw_phy(hw);
1235 struct mt792x_phy *phy = mt792x_hw_phy(hw);
1663 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1664 int err;
1665
1666 mt792x_mutex_acquire(dev);
1667
1668 err = mt7921_mcu_set_bss_pm(dev, vif, false);
1669 if (err)
1670 goto out;

--- 33 unchanged lines hidden (view full) ---

1704 mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->mt76, ctx);
1705}
1706
1707static void
1708mt7921_change_chanctx(struct ieee80211_hw *hw,
1709 struct ieee80211_chanctx_conf *ctx,
1710 u32 changed)
1711{
1236 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1237 int err;
1238
1239 mt792x_mutex_acquire(dev);
1240
1241 err = mt7921_mcu_set_bss_pm(dev, vif, false);
1242 if (err)
1243 goto out;

--- 33 unchanged lines hidden (view full) ---

1277 mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->mt76, ctx);
1278}
1279
1280static void
1281mt7921_change_chanctx(struct ieee80211_hw *hw,
1282 struct ieee80211_chanctx_conf *ctx,
1283 u32 changed)
1284{
1712 struct mt792x_phy *phy = mt7921_hw_phy(hw);
1285 struct mt792x_phy *phy = mt792x_hw_phy(hw);
1713
1714 mt792x_mutex_acquire(phy->dev);
1715 ieee80211_iterate_active_interfaces(phy->mt76->hw,
1716 IEEE80211_IFACE_ITER_ACTIVE,
1717 mt7921_ctx_iter, ctx);
1718 mt792x_mutex_release(phy->dev);
1719}
1720
1286
1287 mt792x_mutex_acquire(phy->dev);
1288 ieee80211_iterate_active_interfaces(phy->mt76->hw,
1289 IEEE80211_IFACE_ITER_ACTIVE,
1290 mt7921_ctx_iter, ctx);
1291 mt792x_mutex_release(phy->dev);
1292}
1293
1721static int
1722mt7921_assign_vif_chanctx(struct ieee80211_hw *hw,
1723 struct ieee80211_vif *vif,
1724 struct ieee80211_bss_conf *link_conf,
1725 struct ieee80211_chanctx_conf *ctx)
1726{
1727 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1728 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1729
1730 mutex_lock(&dev->mt76.mutex);
1731 mvif->ctx = ctx;
1732 mutex_unlock(&dev->mt76.mutex);
1733
1734 return 0;
1735}
1736
1737static void
1738mt7921_unassign_vif_chanctx(struct ieee80211_hw *hw,
1739 struct ieee80211_vif *vif,
1740 struct ieee80211_bss_conf *link_conf,
1741 struct ieee80211_chanctx_conf *ctx)
1742{
1743 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1744 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1745
1746 mutex_lock(&dev->mt76.mutex);
1747 mvif->ctx = NULL;
1748 mutex_unlock(&dev->mt76.mutex);
1749}
1750
1751static void mt7921_mgd_prepare_tx(struct ieee80211_hw *hw,
1752 struct ieee80211_vif *vif,
1753 struct ieee80211_prep_tx_info *info)
1754{
1755 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1756 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1757 u16 duration = info->duration ? info->duration :
1758 jiffies_to_msecs(HZ);

--- 9 unchanged lines hidden (view full) ---

1768 struct ieee80211_prep_tx_info *info)
1769{
1770 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1771
1772 mt7921_abort_roc(mvif->phy, mvif);
1773}
1774
1775const struct ieee80211_ops mt7921_ops = {
1294static void mt7921_mgd_prepare_tx(struct ieee80211_hw *hw,
1295 struct ieee80211_vif *vif,
1296 struct ieee80211_prep_tx_info *info)
1297{
1298 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1299 struct mt792x_dev *dev = mt792x_hw_dev(hw);
1300 u16 duration = info->duration ? info->duration :
1301 jiffies_to_msecs(HZ);

--- 9 unchanged lines hidden (view full) ---

1311 struct ieee80211_prep_tx_info *info)
1312{
1313 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1314
1315 mt7921_abort_roc(mvif->phy, mvif);
1316}
1317
1318const struct ieee80211_ops mt7921_ops = {
1776 .tx = mt7921_tx,
1319 .tx = mt792x_tx,
1777 .start = mt7921_start,
1778 .stop = mt7921_stop,
1779 .add_interface = mt7921_add_interface,
1320 .start = mt7921_start,
1321 .stop = mt7921_stop,
1322 .add_interface = mt7921_add_interface,
1780 .remove_interface = mt7921_remove_interface,
1323 .remove_interface = mt792x_remove_interface,
1781 .config = mt7921_config,
1324 .config = mt7921_config,
1782 .conf_tx = mt7921_conf_tx,
1325 .conf_tx = mt792x_conf_tx,
1783 .configure_filter = mt7921_configure_filter,
1784 .bss_info_changed = mt7921_bss_info_changed,
1785 .start_ap = mt7921_start_ap,
1786 .stop_ap = mt7921_stop_ap,
1787 .sta_state = mt7921_sta_state,
1788 .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
1789 .set_key = mt7921_set_key,
1790 .sta_set_decap_offload = mt7921_sta_set_decap_offload,
1791#if IS_ENABLED(CONFIG_IPV6)
1792 .ipv6_addr_change = mt7921_ipv6_addr_change,
1793#endif /* CONFIG_IPV6 */
1794 .ampdu_action = mt7921_ampdu_action,
1795 .set_rts_threshold = mt7921_set_rts_threshold,
1796 .wake_tx_queue = mt76_wake_tx_queue,
1797 .release_buffered_frames = mt76_release_buffered_frames,
1798 .channel_switch_beacon = mt7921_channel_switch_beacon,
1799 .get_txpower = mt76_get_txpower,
1326 .configure_filter = mt7921_configure_filter,
1327 .bss_info_changed = mt7921_bss_info_changed,
1328 .start_ap = mt7921_start_ap,
1329 .stop_ap = mt7921_stop_ap,
1330 .sta_state = mt7921_sta_state,
1331 .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
1332 .set_key = mt7921_set_key,
1333 .sta_set_decap_offload = mt7921_sta_set_decap_offload,
1334#if IS_ENABLED(CONFIG_IPV6)
1335 .ipv6_addr_change = mt7921_ipv6_addr_change,
1336#endif /* CONFIG_IPV6 */
1337 .ampdu_action = mt7921_ampdu_action,
1338 .set_rts_threshold = mt7921_set_rts_threshold,
1339 .wake_tx_queue = mt76_wake_tx_queue,
1340 .release_buffered_frames = mt76_release_buffered_frames,
1341 .channel_switch_beacon = mt7921_channel_switch_beacon,
1342 .get_txpower = mt76_get_txpower,
1800 .get_stats = mt7921_get_stats,
1801 .get_et_sset_count = mt7921_get_et_sset_count,
1802 .get_et_strings = mt7921_get_et_strings,
1803 .get_et_stats = mt7921_get_et_stats,
1804 .get_tsf = mt7921_get_tsf,
1805 .set_tsf = mt7921_set_tsf,
1343 .get_stats = mt792x_get_stats,
1344 .get_et_sset_count = mt792x_get_et_sset_count,
1345 .get_et_strings = mt792x_get_et_strings,
1346 .get_et_stats = mt792x_get_et_stats,
1347 .get_tsf = mt792x_get_tsf,
1348 .set_tsf = mt792x_set_tsf,
1806 .get_survey = mt76_get_survey,
1807 .get_antenna = mt76_get_antenna,
1808 .set_antenna = mt7921_set_antenna,
1349 .get_survey = mt76_get_survey,
1350 .get_antenna = mt76_get_antenna,
1351 .set_antenna = mt7921_set_antenna,
1809 .set_coverage_class = mt7921_set_coverage_class,
1352 .set_coverage_class = mt792x_set_coverage_class,
1810 .hw_scan = mt7921_hw_scan,
1811 .cancel_hw_scan = mt7921_cancel_hw_scan,
1353 .hw_scan = mt7921_hw_scan,
1354 .cancel_hw_scan = mt7921_cancel_hw_scan,
1812 .sta_statistics = mt7921_sta_statistics,
1355 .sta_statistics = mt792x_sta_statistics,
1813 .sched_scan_start = mt7921_start_sched_scan,
1814 .sched_scan_stop = mt7921_stop_sched_scan,
1815 CFG80211_TESTMODE_CMD(mt7921_testmode_cmd)
1816 CFG80211_TESTMODE_DUMP(mt7921_testmode_dump)
1817#ifdef CONFIG_PM
1818 .suspend = mt7921_suspend,
1819 .resume = mt7921_resume,
1356 .sched_scan_start = mt7921_start_sched_scan,
1357 .sched_scan_stop = mt7921_stop_sched_scan,
1358 CFG80211_TESTMODE_CMD(mt7921_testmode_cmd)
1359 CFG80211_TESTMODE_DUMP(mt7921_testmode_dump)
1360#ifdef CONFIG_PM
1361 .suspend = mt7921_suspend,
1362 .resume = mt7921_resume,
1820 .set_wakeup = mt7921_set_wakeup,
1363 .set_wakeup = mt792x_set_wakeup,
1821 .set_rekey_data = mt7921_set_rekey_data,
1822#endif /* CONFIG_PM */
1364 .set_rekey_data = mt7921_set_rekey_data,
1365#endif /* CONFIG_PM */
1823 .flush = mt7921_flush,
1366 .flush = mt792x_flush,
1824 .set_sar_specs = mt7921_set_sar_specs,
1825 .remain_on_channel = mt7921_remain_on_channel,
1826 .cancel_remain_on_channel = mt7921_cancel_remain_on_channel,
1827 .add_chanctx = mt7921_add_chanctx,
1828 .remove_chanctx = mt7921_remove_chanctx,
1829 .change_chanctx = mt7921_change_chanctx,
1367 .set_sar_specs = mt7921_set_sar_specs,
1368 .remain_on_channel = mt7921_remain_on_channel,
1369 .cancel_remain_on_channel = mt7921_cancel_remain_on_channel,
1370 .add_chanctx = mt7921_add_chanctx,
1371 .remove_chanctx = mt7921_remove_chanctx,
1372 .change_chanctx = mt7921_change_chanctx,
1830 .assign_vif_chanctx = mt7921_assign_vif_chanctx,
1831 .unassign_vif_chanctx = mt7921_unassign_vif_chanctx,
1373 .assign_vif_chanctx = mt792x_assign_vif_chanctx,
1374 .unassign_vif_chanctx = mt792x_unassign_vif_chanctx,
1832 .mgd_prepare_tx = mt7921_mgd_prepare_tx,
1833 .mgd_complete_tx = mt7921_mgd_complete_tx,
1834};
1835EXPORT_SYMBOL_GPL(mt7921_ops);
1836
1837MODULE_LICENSE("Dual BSD/GPL");
1838MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
1375 .mgd_prepare_tx = mt7921_mgd_prepare_tx,
1376 .mgd_complete_tx = mt7921_mgd_complete_tx,
1377};
1378EXPORT_SYMBOL_GPL(mt7921_ops);
1379
1380MODULE_LICENSE("Dual BSD/GPL");
1381MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");