Lines Matching +full:hw +full:- +full:monitor
1 // SPDX-License-Identifier: ISC
17 int nss = hweight8(phy->mt76->chainmask); in mt7921_init_he_caps()
30 &he_cap->he_cap_elem; in mt7921_init_he_caps()
32 &he_cap->he_mcs_nss_supp; in mt7921_init_he_caps()
43 he_cap->has_he = true; in mt7921_init_he_caps()
45 he_cap_elem->mac_cap_info[0] = in mt7921_init_he_caps()
47 he_cap_elem->mac_cap_info[3] = in mt7921_init_he_caps()
50 he_cap_elem->mac_cap_info[4] = in mt7921_init_he_caps()
54 he_cap_elem->phy_cap_info[0] = in mt7921_init_he_caps()
57 he_cap_elem->phy_cap_info[0] = in mt7921_init_he_caps()
60 he_cap_elem->phy_cap_info[1] = in mt7921_init_he_caps()
62 he_cap_elem->phy_cap_info[2] = in mt7921_init_he_caps()
71 he_cap_elem->mac_cap_info[2] |= in mt7921_init_he_caps()
73 he_cap_elem->mac_cap_info[4] |= in mt7921_init_he_caps()
75 he_cap_elem->mac_cap_info[5] |= in mt7921_init_he_caps()
77 he_cap_elem->phy_cap_info[3] |= in mt7921_init_he_caps()
80 he_cap_elem->phy_cap_info[6] |= in mt7921_init_he_caps()
83 he_cap_elem->phy_cap_info[9] |= in mt7921_init_he_caps()
87 if (is_mt7922(phy->mt76->dev)) { in mt7921_init_he_caps()
88 he_cap_elem->phy_cap_info[0] |= in mt7921_init_he_caps()
93 he_cap_elem->mac_cap_info[1] |= in mt7921_init_he_caps()
97 he_cap_elem->phy_cap_info[0] |= in mt7921_init_he_caps()
100 he_cap_elem->phy_cap_info[0] |= in mt7921_init_he_caps()
103 he_cap_elem->phy_cap_info[1] |= in mt7921_init_he_caps()
106 he_cap_elem->phy_cap_info[3] |= in mt7921_init_he_caps()
109 he_cap_elem->phy_cap_info[4] |= in mt7921_init_he_caps()
112 he_cap_elem->phy_cap_info[5] |= in mt7921_init_he_caps()
115 he_cap_elem->phy_cap_info[6] |= in mt7921_init_he_caps()
121 he_cap_elem->phy_cap_info[7] |= in mt7921_init_he_caps()
124 he_cap_elem->phy_cap_info[8] |= in mt7921_init_he_caps()
127 he_cap_elem->phy_cap_info[9] |= in mt7921_init_he_caps()
135 if (is_mt7922(phy->mt76->dev)) { in mt7921_init_he_caps()
136 he_cap_elem->phy_cap_info[0] |= in mt7921_init_he_caps()
138 he_cap_elem->phy_cap_info[8] |= in mt7921_init_he_caps()
145 he_mcs->rx_mcs_80 = cpu_to_le16(mcs_map); in mt7921_init_he_caps()
146 he_mcs->tx_mcs_80 = cpu_to_le16(mcs_map); in mt7921_init_he_caps()
147 if (is_mt7922(phy->mt76->dev)) { in mt7921_init_he_caps()
148 he_mcs->rx_mcs_160 = cpu_to_le16(mcs_map); in mt7921_init_he_caps()
149 he_mcs->tx_mcs_160 = cpu_to_le16(mcs_map); in mt7921_init_he_caps()
152 memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres)); in mt7921_init_he_caps()
153 if (he_cap_elem->phy_cap_info[6] & in mt7921_init_he_caps()
155 mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band); in mt7921_init_he_caps()
157 he_cap_elem->phy_cap_info[9] |= in mt7921_init_he_caps()
164 &phy->mt76->sband_5g.sband; in mt7921_init_he_caps()
165 struct ieee80211_sta_vht_cap *vht_cap = &sband->vht_cap; in mt7921_init_he_caps()
166 struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; in mt7921_init_he_caps()
170 cap = u16_encode_bits(ht_cap->ampdu_density, in mt7921_init_he_caps()
172 exp = u32_get_bits(vht_cap->cap, in mt7921_init_he_caps()
176 exp = u32_get_bits(vht_cap->cap, in mt7921_init_he_caps()
180 if (vht_cap->cap & IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN) in mt7921_init_he_caps()
182 if (vht_cap->cap & IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN) in mt7921_init_he_caps()
199 if (phy->mt76->cap.has_2ghz) { in mt7921_set_stream_he_caps()
200 data = phy->iftype[NL80211_BAND_2GHZ]; in mt7921_set_stream_he_caps()
203 band = &phy->mt76->sband_2g.sband; in mt7921_set_stream_he_caps()
207 if (phy->mt76->cap.has_5ghz) { in mt7921_set_stream_he_caps()
208 data = phy->iftype[NL80211_BAND_5GHZ]; in mt7921_set_stream_he_caps()
211 band = &phy->mt76->sband_5g.sband; in mt7921_set_stream_he_caps()
214 if (phy->mt76->cap.has_6ghz) { in mt7921_set_stream_he_caps()
215 data = phy->iftype[NL80211_BAND_6GHZ]; in mt7921_set_stream_he_caps()
218 band = &phy->mt76->sband_6g.sband; in mt7921_set_stream_he_caps()
226 struct mt76_phy *mphy = phy->mt76; in __mt7921_start()
229 err = mt76_connac_mcu_set_mac_enable(mphy->dev, 0, true, false); in __mt7921_start()
241 err = mt7921_set_tx_sar_pwr(mphy->hw, NULL); in __mt7921_start()
246 set_bit(MT76_STATE_RUNNING, &mphy->state); in __mt7921_start()
248 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in __mt7921_start()
250 if (mt76_is_mmio(mphy->dev)) { in __mt7921_start()
251 err = mt7921_mcu_radio_led_ctrl(phy->dev, EXT_CMD_RADIO_LED_CTRL_ENABLE); in __mt7921_start()
255 err = mt7921_mcu_radio_led_ctrl(phy->dev, EXT_CMD_RADIO_ON_LED); in __mt7921_start()
260 if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) { in __mt7921_start()
262 wiphy_rfkill_start_polling(mphy->hw->wiphy); in __mt7921_start()
269 static int mt7921_start(struct ieee80211_hw *hw) in mt7921_start() argument
271 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_start()
274 mt792x_mutex_acquire(phy->dev); in mt7921_start()
276 mt792x_mutex_release(phy->dev); in mt7921_start()
281 static void mt7921_stop(struct ieee80211_hw *hw, bool suspend) in mt7921_stop() argument
283 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_stop()
286 if (mt76_is_mmio(&dev->mt76)) { in mt7921_stop()
294 mt792x_stop(hw, false); in mt7921_stop()
298 mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) in mt7921_add_interface() argument
300 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_add_interface()
301 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_add_interface()
302 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_add_interface()
308 mvif->bss_conf.mt76.idx = __ffs64(~dev->mt76.vif_mask); in mt7921_add_interface()
309 if (mvif->bss_conf.mt76.idx >= MT792x_MAX_INTERFACES) { in mt7921_add_interface()
310 ret = -ENOSPC; in mt7921_add_interface()
314 mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; in mt7921_add_interface()
315 mvif->phy = phy; in mt7921_add_interface()
316 mvif->bss_conf.vif = mvif; in mt7921_add_interface()
317 mvif->bss_conf.mt76.band_idx = 0; in mt7921_add_interface()
318 mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % MT76_CONNAC_MAX_WMM_SETS; in mt7921_add_interface()
320 ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf, in mt7921_add_interface()
321 &mvif->bss_conf.mt76, in mt7921_add_interface()
322 &mvif->sta.deflink.wcid, true); in mt7921_add_interface()
326 dev->mt76.vif_mask |= BIT_ULL(mvif->bss_conf.mt76.idx); in mt7921_add_interface()
327 phy->omac_mask |= BIT_ULL(mvif->bss_conf.mt76.omac_idx); in mt7921_add_interface()
329 idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx; in mt7921_add_interface()
331 INIT_LIST_HEAD(&mvif->sta.deflink.wcid.poll_list); in mt7921_add_interface()
332 mvif->sta.deflink.wcid.idx = idx; in mt7921_add_interface()
333 mvif->sta.deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7921_add_interface()
334 mt76_wcid_init(&mvif->sta.deflink.wcid, mvif->bss_conf.mt76.band_idx); in mt7921_add_interface()
339 ewma_rssi_init(&mvif->bss_conf.rssi); in mt7921_add_interface()
341 rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.deflink.wcid); in mt7921_add_interface()
342 if (vif->txq) { in mt7921_add_interface()
343 mtxq = (struct mt76_txq *)vif->txq->drv_priv; in mt7921_add_interface()
344 mtxq->wcid = idx; in mt7921_add_interface()
347 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; in mt7921_add_interface()
348 if (phy->chip_cap & MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN) in mt7921_add_interface()
349 vif->driver_flags |= IEEE80211_VIF_SUPPORTS_CQM_RSSI; in mt7921_add_interface()
351 INIT_WORK(&mvif->csa_work, mt7921_csa_work); in mt7921_add_interface()
352 timer_setup(&mvif->csa_timer, mt792x_csa_timer, 0); in mt7921_add_interface()
362 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_roc_iter()
365 mt7921_mcu_abort_roc(phy, mvif, phy->roc_token_id); in mt7921_roc_iter()
370 struct mt792x_phy *phy = &dev->phy; in mt7921_roc_abort_sync()
372 timer_delete_sync(&phy->roc_timer); in mt7921_roc_abort_sync()
373 cancel_work_sync(&phy->roc_work); in mt7921_roc_abort_sync()
374 if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7921_roc_abort_sync()
388 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7921_roc_work()
391 mt792x_mutex_acquire(phy->dev); in mt7921_roc_work()
392 ieee80211_iterate_active_interfaces(phy->mt76->hw, in mt7921_roc_work()
395 mt792x_mutex_release(phy->dev); in mt7921_roc_work()
396 ieee80211_remain_on_channel_expired(phy->mt76->hw); in mt7921_roc_work()
403 timer_delete_sync(&phy->roc_timer); in mt7921_abort_roc()
404 cancel_work_sync(&phy->roc_work); in mt7921_abort_roc()
406 mt792x_mutex_acquire(phy->dev); in mt7921_abort_roc()
407 if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7921_abort_roc()
408 err = mt7921_mcu_abort_roc(phy, vif, phy->roc_token_id); in mt7921_abort_roc()
409 mt792x_mutex_release(phy->dev); in mt7921_abort_roc()
422 if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7921_set_roc()
423 return -EBUSY; in mt7921_set_roc()
425 phy->roc_grant = false; in mt7921_set_roc()
428 ++phy->roc_token_id); in mt7921_set_roc()
430 clear_bit(MT76_STATE_ROC, &phy->mt76->state); in mt7921_set_roc()
434 if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, HZ)) { in mt7921_set_roc()
435 mt7921_mcu_abort_roc(phy, vif, phy->roc_token_id); in mt7921_set_roc()
436 clear_bit(MT76_STATE_ROC, &phy->mt76->state); in mt7921_set_roc()
437 err = -ETIMEDOUT; in mt7921_set_roc()
444 static int mt7921_remain_on_channel(struct ieee80211_hw *hw, in mt7921_remain_on_channel() argument
450 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_remain_on_channel()
451 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_remain_on_channel()
454 mt792x_mutex_acquire(phy->dev); in mt7921_remain_on_channel()
456 mt792x_mutex_release(phy->dev); in mt7921_remain_on_channel()
461 static int mt7921_cancel_remain_on_channel(struct ieee80211_hw *hw, in mt7921_cancel_remain_on_channel() argument
464 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_cancel_remain_on_channel()
465 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_cancel_remain_on_channel()
472 struct mt792x_phy *phy = mphy->priv; in mt7921_set_channel()
473 struct mt792x_dev *dev = phy->dev; in mt7921_set_channel()
476 mt76_connac_pm_wake(mphy, &dev->pm); in mt7921_set_channel()
483 phy->noise = 0; in mt7921_set_channel()
486 mt76_connac_power_save_sched(mphy, &dev->pm); in mt7921_set_channel()
488 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in mt7921_set_channel()
495 static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, in mt7921_set_key() argument
499 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_set_key()
500 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_set_key()
501 struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : in mt7921_set_key()
502 &mvif->sta; in mt7921_set_key()
503 struct mt76_wcid *wcid = &msta->deflink.wcid; in mt7921_set_key()
504 u8 *wcid_keyidx = &wcid->hw_key_idx; in mt7921_set_key()
505 int idx = key->keyidx, err = 0; in mt7921_set_key()
507 /* The hardware does not support per-STA RX GTK, fallback in mt7921_set_key()
510 if ((vif->type == NL80211_IFTYPE_ADHOC || in mt7921_set_key()
511 vif->type == NL80211_IFTYPE_MESH_POINT) && in mt7921_set_key()
512 (key->cipher == WLAN_CIPHER_SUITE_TKIP || in mt7921_set_key()
513 key->cipher == WLAN_CIPHER_SUITE_CCMP) && in mt7921_set_key()
514 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) in mt7921_set_key()
515 return -EOPNOTSUPP; in mt7921_set_key()
518 switch (key->cipher) { in mt7921_set_key()
520 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE; in mt7921_set_key()
521 wcid_keyidx = &wcid->hw_key_idx2; in mt7921_set_key()
525 if (!mvif->wep_sta) in mt7921_set_key()
526 return -EOPNOTSUPP; in mt7921_set_key()
536 return -EOPNOTSUPP; in mt7921_set_key()
545 *wcid_keyidx = -1; in mt7921_set_key()
551 if (vif->type != NL80211_IFTYPE_STATION || vif->cfg.assoc) in mt7921_set_key()
555 mt76_wcid_key_setup(&dev->mt76, wcid, key); in mt7921_set_key()
556 err = mt76_connac_mcu_add_key(&dev->mt76, vif, &msta->deflink.bip, in mt7921_set_key()
558 &msta->deflink.wcid, cmd); in mt7921_set_key()
562 if (key->cipher == WLAN_CIPHER_SUITE_WEP104 || in mt7921_set_key()
563 key->cipher == WLAN_CIPHER_SUITE_WEP40) in mt7921_set_key()
564 err = mt76_connac_mcu_add_key(&dev->mt76, vif, in mt7921_set_key()
565 &mvif->wep_sta->deflink.bip, in mt7921_set_key()
567 &mvif->wep_sta->deflink.wcid, cmd); in mt7921_set_key()
578 struct ieee80211_hw *hw = mt76_hw(dev); in mt7921_pm_interface_iter() local
579 bool pm_enable = dev->pm.enable; in mt7921_pm_interface_iter()
587 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; in mt7921_pm_interface_iter()
588 ieee80211_hw_set(hw, CONNECTION_MONITOR); in mt7921_pm_interface_iter()
590 vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; in mt7921_pm_interface_iter()
591 __clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags); in mt7921_pm_interface_iter()
599 struct ieee80211_hw *hw = mt76_hw(dev); in mt7921_sniffer_interface_iter() local
600 struct mt76_connac_pm *pm = &dev->pm; in mt7921_sniffer_interface_iter()
601 bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); in mt7921_sniffer_interface_iter() local
603 mt7921_mcu_set_sniffer(dev, vif, monitor); in mt7921_sniffer_interface_iter()
604 pm->enable = pm->enable_user && !monitor; in mt7921_sniffer_interface_iter()
605 pm->ds_enable = pm->ds_enable_user && !monitor; in mt7921_sniffer_interface_iter()
607 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable); in mt7921_sniffer_interface_iter()
609 if (monitor) in mt7921_sniffer_interface_iter()
615 struct ieee80211_hw *hw = mt76_hw(dev); in mt7921_set_runtime_pm() local
616 struct mt76_connac_pm *pm = &dev->pm; in mt7921_set_runtime_pm()
617 bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); in mt7921_set_runtime_pm() local
619 pm->enable = pm->enable_user && !monitor; in mt7921_set_runtime_pm()
620 ieee80211_iterate_active_interfaces(hw, in mt7921_set_runtime_pm()
623 pm->ds_enable = pm->ds_enable_user && !monitor; in mt7921_set_runtime_pm()
624 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable); in mt7921_set_runtime_pm()
627 static int mt7921_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) in mt7921_config() argument
629 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_config()
630 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_config()
634 ret = mt76_update_channel(phy->mt76); in mt7921_config()
642 ret = mt7921_set_tx_sar_pwr(hw, NULL); in mt7921_config()
648 ieee80211_iterate_active_interfaces(hw, in mt7921_config()
659 static void mt7921_configure_filter(struct ieee80211_hw *hw, in mt7921_configure_filter() argument
669 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_configure_filter()
688 static void mt7921_bss_info_changed(struct ieee80211_hw *hw, in mt7921_bss_info_changed() argument
693 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_bss_info_changed()
694 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_bss_info_changed()
699 int slottime = info->use_short_slot ? 9 : 20; in mt7921_bss_info_changed()
701 if (slottime != phy->slottime) { in mt7921_bss_info_changed()
702 phy->slottime = slottime; in mt7921_bss_info_changed()
709 mt7921_mcu_uni_add_beacon_offload(dev, hw, vif, in mt7921_bss_info_changed()
710 info->enable_beacon); in mt7921_bss_info_changed()
725 mt7921_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc); in mt7921_bss_info_changed()
729 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_bss_info_changed()
731 mt76_connac_mcu_update_arp_filter(&dev->mt76, &mvif->bss_conf.mt76, in mt7921_bss_info_changed()
746 switch (vif->type) { in mt7921_calc_vif_num()
761 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_regd_set_6ghz_power_type()
762 struct mt792x_phy *phy = mvif->phy; in mt7921_regd_set_6ghz_power_type()
763 struct mt792x_dev *dev = phy->dev; in mt7921_regd_set_6ghz_power_type()
771 phy->power_type = MT_AP_DEFAULT; in mt7921_regd_set_6ghz_power_type()
776 vif->bss_conf.power_type = IEEE80211_REG_UNSET_AP; in mt7921_regd_set_6ghz_power_type()
778 switch (vif->bss_conf.power_type) { in mt7921_regd_set_6ghz_power_type()
780 phy->power_type = MT_AP_SP; in mt7921_regd_set_6ghz_power_type()
783 phy->power_type = MT_AP_VLP; in mt7921_regd_set_6ghz_power_type()
786 phy->power_type = MT_AP_LPI; in mt7921_regd_set_6ghz_power_type()
789 phy->power_type = MT_AP_UNSET; in mt7921_regd_set_6ghz_power_type()
792 phy->power_type = MT_AP_DEFAULT; in mt7921_regd_set_6ghz_power_type()
797 mt7921_mcu_set_clc(dev, dev->mt76.alpha2, dev->country_ie_env); in mt7921_regd_set_6ghz_power_type()
804 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7921_mac_sta_add()
805 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_mac_sta_add()
808 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT792x_WTBL_STA - 1); in mt7921_mac_sta_add()
810 return -ENOSPC; in mt7921_mac_sta_add()
812 INIT_LIST_HEAD(&msta->deflink.wcid.poll_list); in mt7921_mac_sta_add()
813 msta->vif = mvif; in mt7921_mac_sta_add()
814 msta->deflink.wcid.sta = 1; in mt7921_mac_sta_add()
815 msta->deflink.wcid.idx = idx; in mt7921_mac_sta_add()
816 msta->deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx; in mt7921_mac_sta_add()
817 msta->deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7921_mac_sta_add()
818 msta->deflink.last_txs = jiffies; in mt7921_mac_sta_add()
819 msta->deflink.sta = msta; in mt7921_mac_sta_add()
821 ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm); in mt7921_mac_sta_add()
825 if (vif->type == NL80211_IFTYPE_STATION) in mt7921_mac_sta_add()
826 mvif->wep_sta = msta; in mt7921_mac_sta_add()
838 mt76_connac_power_save_sched(&dev->mphy, &dev->pm); in mt7921_mac_sta_add()
848 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7921_mac_sta_event()
849 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_mac_sta_event()
856 if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) in mt7921_mac_sta_event()
857 mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.deflink.wcid, in mt7921_mac_sta_event()
858 true, mvif->bss_conf.mt76.ctx); in mt7921_mac_sta_event()
860 ewma_avg_signal_init(&msta->deflink.avg_ack_signal); in mt7921_mac_sta_event()
862 mt7921_mac_wtbl_update(dev, msta->deflink.wcid.idx, in mt7921_mac_sta_event()
864 memset(msta->deflink.airtime_ac, 0, sizeof(msta->deflink.airtime_ac)); in mt7921_mac_sta_event()
878 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7921_mac_sta_remove()
881 mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid); in mt7921_mac_sta_remove()
882 mt76_connac_pm_wake(&dev->mphy, &dev->pm); in mt7921_mac_sta_remove()
885 mt7921_mac_wtbl_update(dev, msta->deflink.wcid.idx, in mt7921_mac_sta_remove()
888 if (vif->type == NL80211_IFTYPE_STATION) { in mt7921_mac_sta_remove()
889 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_mac_sta_remove()
891 mvif->wep_sta = NULL; in mt7921_mac_sta_remove()
892 ewma_rssi_init(&mvif->bss_conf.rssi); in mt7921_mac_sta_remove()
893 if (!sta->tdls) in mt7921_mac_sta_remove()
894 mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, in mt7921_mac_sta_remove()
895 &mvif->sta.deflink.wcid, false, in mt7921_mac_sta_remove()
896 mvif->bss_conf.mt76.ctx); in mt7921_mac_sta_remove()
899 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7921_mac_sta_remove()
900 if (!list_empty(&msta->deflink.wcid.poll_list)) in mt7921_mac_sta_remove()
901 list_del_init(&msta->deflink.wcid.poll_list); in mt7921_mac_sta_remove()
902 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7921_mac_sta_remove()
906 mt76_connac_power_save_sched(&dev->mphy, &dev->pm); in mt7921_mac_sta_remove()
910 static int mt7921_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx, in mt7921_set_rts_threshold() argument
913 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_set_rts_threshold()
916 mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, 0); in mt7921_set_rts_threshold()
923 mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7921_ampdu_action() argument
926 enum ieee80211_ampdu_mlme_action action = params->action; in mt7921_ampdu_action()
927 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_ampdu_action()
928 struct ieee80211_sta *sta = params->sta; in mt7921_ampdu_action()
929 struct ieee80211_txq *txq = sta->txq[params->tid]; in mt7921_ampdu_action()
930 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7921_ampdu_action()
931 u16 tid = params->tid; in mt7921_ampdu_action()
932 u16 ssn = params->ssn; in mt7921_ampdu_action()
937 return -EINVAL; in mt7921_ampdu_action()
939 mtxq = (struct mt76_txq *)txq->drv_priv; in mt7921_ampdu_action()
944 mt76_rx_aggr_start(&dev->mt76, &msta->deflink.wcid, tid, ssn, in mt7921_ampdu_action()
945 params->buf_size); in mt7921_ampdu_action()
949 mt76_rx_aggr_stop(&dev->mt76, &msta->deflink.wcid, tid); in mt7921_ampdu_action()
953 mtxq->aggr = true; in mt7921_ampdu_action()
954 mtxq->send_bar = false; in mt7921_ampdu_action()
959 mtxq->aggr = false; in mt7921_ampdu_action()
960 clear_bit(tid, &msta->deflink.wcid.ampdu_state); in mt7921_ampdu_action()
964 set_bit(tid, &msta->deflink.wcid.ampdu_state); in mt7921_ampdu_action()
968 mtxq->aggr = false; in mt7921_ampdu_action()
969 clear_bit(tid, &msta->deflink.wcid.ampdu_state); in mt7921_ampdu_action()
971 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in mt7921_ampdu_action()
979 static int mt7921_sta_state(struct ieee80211_hw *hw, in mt7921_sta_state() argument
985 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_sta_state()
987 if (dev->pm.ds_enable) { in mt7921_sta_state()
989 mt76_connac_sta_state_dp(&dev->mt76, old_state, new_state); in mt7921_sta_state()
993 return mt76_sta_state(hw, vif, sta, old_state, new_state); in mt7921_sta_state()
1007 spin_lock_bh(&phy->dev->mt76.lock); in mt7921_scan_work()
1008 skb = __skb_dequeue(&phy->scan_event_list); in mt7921_scan_work()
1009 spin_unlock_bh(&phy->dev->mt76.lock); in mt7921_scan_work()
1014 rxd = (struct mt76_connac2_mcu_rxd *)skb->data; in mt7921_scan_work()
1015 if (rxd->eid == MCU_EVENT_SCHED_SCAN_DONE) { in mt7921_scan_work()
1016 ieee80211_sched_scan_results(phy->mt76->hw); in mt7921_scan_work()
1018 &phy->mt76->state)) { in mt7921_scan_work()
1023 ieee80211_scan_completed(phy->mt76->hw, &info); in mt7921_scan_work()
1030 mt7921_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7921_hw_scan() argument
1033 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_hw_scan()
1034 struct mt76_phy *mphy = hw->priv; in mt7921_hw_scan()
1045 mt7921_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif) in mt7921_cancel_hw_scan() argument
1047 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_cancel_hw_scan()
1048 struct mt76_phy *mphy = hw->priv; in mt7921_cancel_hw_scan()
1056 mt7921_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7921_start_sched_scan() argument
1060 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_start_sched_scan()
1061 struct mt76_phy *mphy = hw->priv; in mt7921_start_sched_scan()
1078 mt7921_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif) in mt7921_stop_sched_scan() argument
1080 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_stop_sched_scan()
1081 struct mt76_phy *mphy = hw->priv; in mt7921_stop_sched_scan()
1092 mt7921_set_antenna(struct ieee80211_hw *hw, int radio_idx, in mt7921_set_antenna() argument
1095 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_set_antenna()
1096 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_set_antenna()
1097 int max_nss = hweight8(hw->wiphy->available_antennas_tx); in mt7921_set_antenna()
1100 return -EINVAL; in mt7921_set_antenna()
1102 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant) in mt7921_set_antenna()
1103 return -EINVAL; in mt7921_set_antenna()
1107 phy->mt76->antenna_mask = tx_ant; in mt7921_set_antenna()
1108 phy->mt76->chainmask = tx_ant; in mt7921_set_antenna()
1110 mt76_set_stream_caps(phy->mt76, true); in mt7921_set_antenna()
1119 static int mt7921_suspend(struct ieee80211_hw *hw, in mt7921_suspend() argument
1122 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_suspend()
1123 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_suspend()
1125 cancel_delayed_work_sync(&phy->scan_work); in mt7921_suspend()
1126 cancel_delayed_work_sync(&phy->mt76->mac_work); in mt7921_suspend()
1128 cancel_delayed_work_sync(&dev->pm.ps_work); in mt7921_suspend()
1129 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL); in mt7921_suspend()
1133 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state); in mt7921_suspend()
1134 ieee80211_iterate_active_interfaces(hw, in mt7921_suspend()
1137 &dev->mphy); in mt7921_suspend()
1144 static int mt7921_resume(struct ieee80211_hw *hw) in mt7921_resume() argument
1146 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_resume()
1147 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_resume()
1151 set_bit(MT76_STATE_RUNNING, &phy->mt76->state); in mt7921_resume()
1152 ieee80211_iterate_active_interfaces(hw, in mt7921_resume()
1155 &dev->mphy); in mt7921_resume()
1157 ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, in mt7921_resume()
1165 static void mt7921_set_rekey_data(struct ieee80211_hw *hw, in mt7921_set_rekey_data() argument
1169 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_set_rekey_data()
1172 mt76_connac_mcu_update_gtk_rekey(hw, vif, data); in mt7921_set_rekey_data()
1177 static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw, in mt7921_sta_set_decap_offload() argument
1182 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7921_sta_set_decap_offload()
1183 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_sta_set_decap_offload()
1185 if (!msta->deflink.wcid.sta) in mt7921_sta_set_decap_offload()
1191 set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->deflink.wcid.flags); in mt7921_sta_set_decap_offload()
1193 clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->deflink.wcid.flags); in mt7921_sta_set_decap_offload()
1195 mt76_connac_mcu_sta_update_hdr_trans(&dev->mt76, vif, &msta->deflink.wcid, in mt7921_sta_set_decap_offload()
1202 static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, in mt7921_ipv6_addr_change() argument
1206 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_ipv6_addr_change()
1207 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_ipv6_addr_change()
1221 .bss_idx = mvif->bss_conf.mt76.idx, in mt7921_ipv6_addr_change()
1230 read_lock_bh(&idev->lock); in mt7921_ipv6_addr_change()
1231 list_for_each_entry(ifa, &idev->addr_list, if_list) { in mt7921_ipv6_addr_change()
1232 if (ifa->flags & IFA_F_TENTATIVE) in mt7921_ipv6_addr_change()
1234 ns_addrs[idx] = ifa->addr; in mt7921_ipv6_addr_change()
1238 read_unlock_bh(&idev->lock); in mt7921_ipv6_addr_change()
1246 skb = __mt76_mcu_msg_alloc(&dev->mt76, &req_hdr, in mt7921_ipv6_addr_change()
1255 skb_queue_tail(&dev->ipv6_ns_list, skb); in mt7921_ipv6_addr_change()
1257 ieee80211_queue_work(dev->mt76.hw, &dev->ipv6_ns_work); in mt7921_ipv6_addr_change()
1261 int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw, in mt7921_set_tx_sar_pwr() argument
1264 struct mt76_phy *mphy = hw->priv; in mt7921_set_tx_sar_pwr()
1267 int err = mt76_init_sar_power(hw, sar); in mt7921_set_tx_sar_pwr()
1272 mt792x_init_acpi_sar_power(mt792x_hw_phy(hw), !sar); in mt7921_set_tx_sar_pwr()
1277 static int mt7921_set_sar_specs(struct ieee80211_hw *hw, in mt7921_set_sar_specs() argument
1280 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_set_sar_specs()
1284 err = mt7921_mcu_set_clc(dev, dev->mt76.alpha2, in mt7921_set_sar_specs()
1285 dev->country_ie_env); in mt7921_set_sar_specs()
1289 err = mt7921_set_tx_sar_pwr(hw, sar); in mt7921_set_sar_specs()
1297 mt7921_channel_switch_beacon(struct ieee80211_hw *hw, in mt7921_channel_switch_beacon() argument
1301 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_channel_switch_beacon()
1304 mt7921_mcu_uni_add_beacon_offload(dev, hw, vif, true); in mt7921_channel_switch_beacon()
1309 mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7921_start_ap() argument
1312 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_start_ap()
1313 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_start_ap()
1314 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_start_ap()
1319 err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.deflink.wcid, in mt7921_start_ap()
1320 true, mvif->bss_conf.mt76.ctx); in mt7921_start_ap()
1337 mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7921_stop_ap() argument
1340 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_stop_ap()
1341 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_stop_ap()
1342 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_stop_ap()
1351 mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.deflink.wcid, false, in mt7921_stop_ap()
1352 mvif->bss_conf.mt76.ctx); in mt7921_stop_ap()
1359 mt7921_add_chanctx(struct ieee80211_hw *hw, in mt7921_add_chanctx() argument
1362 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_add_chanctx()
1364 dev->new_ctx = ctx; in mt7921_add_chanctx()
1369 mt7921_remove_chanctx(struct ieee80211_hw *hw, in mt7921_remove_chanctx() argument
1372 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_remove_chanctx()
1374 if (dev->new_ctx == ctx) in mt7921_remove_chanctx()
1375 dev->new_ctx = NULL; in mt7921_remove_chanctx()
1379 mt7921_change_chanctx(struct ieee80211_hw *hw, in mt7921_change_chanctx() argument
1383 struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; in mt7921_change_chanctx()
1384 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_change_chanctx()
1388 if (!mctx->bss_conf) in mt7921_change_chanctx()
1391 mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf); in mt7921_change_chanctx()
1394 mt792x_mutex_acquire(phy->dev); in mt7921_change_chanctx()
1395 if (vif->type == NL80211_IFTYPE_MONITOR) in mt7921_change_chanctx()
1398 mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx); in mt7921_change_chanctx()
1399 mt792x_mutex_release(phy->dev); in mt7921_change_chanctx()
1402 static void mt7921_mgd_prepare_tx(struct ieee80211_hw *hw, in mt7921_mgd_prepare_tx() argument
1406 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_mgd_prepare_tx()
1407 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_mgd_prepare_tx()
1408 u16 duration = info->duration ? info->duration : in mt7921_mgd_prepare_tx()
1412 mt7921_set_roc(mvif->phy, mvif, mvif->bss_conf.mt76.ctx->def.chan, duration, in mt7921_mgd_prepare_tx()
1417 static void mt7921_mgd_complete_tx(struct ieee80211_hw *hw, in mt7921_mgd_complete_tx() argument
1421 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_mgd_complete_tx()
1423 mt7921_abort_roc(mvif->phy, mvif); in mt7921_mgd_complete_tx()
1426 static int mt7921_switch_vif_chanctx(struct ieee80211_hw *hw, in mt7921_switch_vif_chanctx() argument
1431 return mt792x_assign_vif_chanctx(hw, vifs->vif, vifs->link_conf, in mt7921_switch_vif_chanctx()
1432 vifs->new_ctx); in mt7921_switch_vif_chanctx()
1444 dev = mvif->phy->dev; in mt7921_csa_work()
1448 ret = mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, in mt7921_csa_work()
1449 dev->new_ctx); in mt7921_csa_work()
1455 static int mt7921_pre_channel_switch(struct ieee80211_hw *hw, in mt7921_pre_channel_switch() argument
1459 if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc) in mt7921_pre_channel_switch()
1460 return -EOPNOTSUPP; in mt7921_pre_channel_switch()
1462 if (!cfg80211_chandef_usable(hw->wiphy, &chsw->chandef, in mt7921_pre_channel_switch()
1464 return -EOPNOTSUPP; in mt7921_pre_channel_switch()
1469 static void mt7921_channel_switch(struct ieee80211_hw *hw, in mt7921_channel_switch() argument
1473 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_channel_switch()
1474 u16 beacon_interval = vif->bss_conf.beacon_int; in mt7921_channel_switch()
1476 mvif->csa_timer.expires = TU_TO_EXP_TIME(beacon_interval * chsw->count); in mt7921_channel_switch()
1477 add_timer(&mvif->csa_timer); in mt7921_channel_switch()
1480 static void mt7921_abort_channel_switch(struct ieee80211_hw *hw, in mt7921_abort_channel_switch() argument
1484 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_abort_channel_switch()
1486 timer_delete_sync(&mvif->csa_timer); in mt7921_abort_channel_switch()
1487 cancel_work_sync(&mvif->csa_work); in mt7921_abort_channel_switch()
1490 static void mt7921_channel_switch_rx_beacon(struct ieee80211_hw *hw, in mt7921_channel_switch_rx_beacon() argument
1494 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7921_channel_switch_rx_beacon()
1495 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7921_channel_switch_rx_beacon()
1496 u16 beacon_interval = vif->bss_conf.beacon_int; in mt7921_channel_switch_rx_beacon()
1498 if (cfg80211_chandef_identical(&chsw->chandef, in mt7921_channel_switch_rx_beacon()
1499 &dev->new_ctx->def) && in mt7921_channel_switch_rx_beacon()
1500 chsw->count) { in mt7921_channel_switch_rx_beacon()
1501 mod_timer(&mvif->csa_timer, in mt7921_channel_switch_rx_beacon()
1502 TU_TO_EXP_TIME(beacon_interval * chsw->count)); in mt7921_channel_switch_rx_beacon()
1506 static void mt7921_rfkill_poll(struct ieee80211_hw *hw) in mt7921_rfkill_poll() argument
1508 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7921_rfkill_poll()
1511 mt792x_mutex_acquire(phy->dev); in mt7921_rfkill_poll()
1513 mt792x_mutex_release(phy->dev); in mt7921_rfkill_poll()
1515 wiphy_rfkill_set_hw_state(hw->wiphy, ret ? false : true); in mt7921_rfkill_poll()