Lines Matching +full:hw +full:- +full:monitor
1 // SPDX-License-Identifier: ISC
19 struct ieee80211_sta_he_cap *he_cap = &data->he_cap; in mt7925_init_he_caps()
20 struct ieee80211_he_cap_elem *he_cap_elem = &he_cap->he_cap_elem; in mt7925_init_he_caps()
21 struct ieee80211_he_mcs_nss_supp *he_mcs = &he_cap->he_mcs_nss_supp; in mt7925_init_he_caps()
22 int i, nss = hweight8(phy->mt76->antenna_mask); in mt7925_init_he_caps()
32 he_cap->has_he = true; in mt7925_init_he_caps()
34 he_cap_elem->mac_cap_info[0] = IEEE80211_HE_MAC_CAP0_HTC_HE; in mt7925_init_he_caps()
35 he_cap_elem->mac_cap_info[3] = IEEE80211_HE_MAC_CAP3_OMI_CONTROL | in mt7925_init_he_caps()
37 he_cap_elem->mac_cap_info[4] = IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU; in mt7925_init_he_caps()
40 he_cap_elem->phy_cap_info[0] = in mt7925_init_he_caps()
43 he_cap_elem->phy_cap_info[0] = in mt7925_init_he_caps()
47 he_cap_elem->phy_cap_info[1] = in mt7925_init_he_caps()
49 he_cap_elem->phy_cap_info[2] = in mt7925_init_he_caps()
58 he_cap_elem->mac_cap_info[2] |= in mt7925_init_he_caps()
60 he_cap_elem->mac_cap_info[4] |= in mt7925_init_he_caps()
62 he_cap_elem->mac_cap_info[5] |= in mt7925_init_he_caps()
64 he_cap_elem->phy_cap_info[3] |= in mt7925_init_he_caps()
67 he_cap_elem->phy_cap_info[6] |= in mt7925_init_he_caps()
70 he_cap_elem->phy_cap_info[9] |= in mt7925_init_he_caps()
75 he_cap_elem->mac_cap_info[1] |= in mt7925_init_he_caps()
79 he_cap_elem->phy_cap_info[0] |= in mt7925_init_he_caps()
82 he_cap_elem->phy_cap_info[0] |= in mt7925_init_he_caps()
85 he_cap_elem->phy_cap_info[1] |= in mt7925_init_he_caps()
88 he_cap_elem->phy_cap_info[3] |= in mt7925_init_he_caps()
91 he_cap_elem->phy_cap_info[4] |= in mt7925_init_he_caps()
95 he_cap_elem->phy_cap_info[5] |= in mt7925_init_he_caps()
98 he_cap_elem->phy_cap_info[6] |= in mt7925_init_he_caps()
104 he_cap_elem->phy_cap_info[7] |= in mt7925_init_he_caps()
107 he_cap_elem->phy_cap_info[8] |= in mt7925_init_he_caps()
112 he_cap_elem->phy_cap_info[9] |= in mt7925_init_he_caps()
124 he_mcs->rx_mcs_80 = cpu_to_le16(mcs_map); in mt7925_init_he_caps()
125 he_mcs->tx_mcs_80 = cpu_to_le16(mcs_map); in mt7925_init_he_caps()
126 he_mcs->rx_mcs_160 = cpu_to_le16(mcs_map); in mt7925_init_he_caps()
127 he_mcs->tx_mcs_160 = cpu_to_le16(mcs_map); in mt7925_init_he_caps()
129 memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres)); in mt7925_init_he_caps()
131 if (he_cap_elem->phy_cap_info[6] & in mt7925_init_he_caps()
133 mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band); in mt7925_init_he_caps()
135 he_cap_elem->phy_cap_info[9] |= in mt7925_init_he_caps()
151 data->he_6ghz_capa.capa = cpu_to_le16(cap); in mt7925_init_he_caps()
159 struct ieee80211_sta_eht_cap *eht_cap = &data->eht_cap; in mt7925_init_eht_caps()
160 struct ieee80211_eht_cap_elem_fixed *eht_cap_elem = &eht_cap->eht_cap_elem; in mt7925_init_eht_caps()
161 struct ieee80211_eht_mcs_nss_supp *eht_nss = &eht_cap->eht_mcs_nss_supp; in mt7925_init_eht_caps()
162 enum nl80211_chan_width width = phy->mt76->chandef.width; in mt7925_init_eht_caps()
163 int nss = hweight8(phy->mt76->antenna_mask); in mt7925_init_eht_caps()
164 int sts = hweight16(phy->mt76->chainmask); in mt7925_init_eht_caps()
167 if (!phy->dev->has_eht) in mt7925_init_eht_caps()
170 eht_cap->has_eht = true; in mt7925_init_eht_caps()
172 eht_cap_elem->mac_cap_info[0] = in mt7925_init_eht_caps()
176 eht_cap_elem->phy_cap_info[0] = in mt7925_init_eht_caps()
181 eht_cap_elem->phy_cap_info[0] |= in mt7925_init_eht_caps()
182 u8_encode_bits(u8_get_bits(sts - 1, BIT(0)), in mt7925_init_eht_caps()
185 eht_cap_elem->phy_cap_info[1] = in mt7925_init_eht_caps()
186 u8_encode_bits(u8_get_bits(sts - 1, GENMASK(2, 1)), in mt7925_init_eht_caps()
188 u8_encode_bits(sts - 1, in mt7925_init_eht_caps()
191 eht_cap_elem->phy_cap_info[2] = in mt7925_init_eht_caps()
192 u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK) | in mt7925_init_eht_caps()
193 u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK); in mt7925_init_eht_caps()
195 eht_cap_elem->phy_cap_info[3] = in mt7925_init_eht_caps()
204 eht_cap_elem->phy_cap_info[4] = in mt7925_init_eht_caps()
205 u8_encode_bits(min_t(int, sts - 1, 2), in mt7925_init_eht_caps()
208 eht_cap_elem->phy_cap_info[5] = in mt7925_init_eht_caps()
217 eht_cap_elem->phy_cap_info[6] = in mt7925_init_eht_caps()
222 eht_cap_elem->phy_cap_info[7] = in mt7925_init_eht_caps()
231 eht_nss->bw._80.rx_tx_mcs9_max_nss = val; in mt7925_init_eht_caps()
232 eht_nss->bw._80.rx_tx_mcs11_max_nss = val; in mt7925_init_eht_caps()
233 eht_nss->bw._80.rx_tx_mcs13_max_nss = val; in mt7925_init_eht_caps()
234 eht_nss->bw._160.rx_tx_mcs9_max_nss = val; in mt7925_init_eht_caps()
235 eht_nss->bw._160.rx_tx_mcs11_max_nss = val; in mt7925_init_eht_caps()
236 eht_nss->bw._160.rx_tx_mcs13_max_nss = val; in mt7925_init_eht_caps()
241 struct wiphy *wiphy = phy->mt76->hw->wiphy; in mt7925_init_mlo_caps()
254 if (!(phy->chip_cap & MT792x_CHIP_CAP_MLO_EN)) in mt7925_init_mlo_caps()
257 ext_capab[0].eml_capabilities = phy->eml_cap; in mt7925_init_mlo_caps()
261 wiphy->flags |= WIPHY_FLAG_SUPPORTS_MLO; in mt7925_init_mlo_caps()
262 wiphy->iftype_ext_capab = ext_capab; in mt7925_init_mlo_caps()
263 wiphy->num_iftype_ext_capab = ARRAY_SIZE(ext_capab); in mt7925_init_mlo_caps()
273 struct ieee80211_sband_iftype_data *data = phy->iftype[band]; in __mt7925_set_stream_he_eht_caps()
297 if (phy->mt76->cap.has_2ghz) in mt7925_set_stream_he_eht_caps()
298 __mt7925_set_stream_he_eht_caps(phy, &phy->mt76->sband_2g.sband, in mt7925_set_stream_he_eht_caps()
301 if (phy->mt76->cap.has_5ghz) in mt7925_set_stream_he_eht_caps()
302 __mt7925_set_stream_he_eht_caps(phy, &phy->mt76->sband_5g.sband, in mt7925_set_stream_he_eht_caps()
305 if (phy->mt76->cap.has_6ghz) in mt7925_set_stream_he_eht_caps()
306 __mt7925_set_stream_he_eht_caps(phy, &phy->mt76->sband_6g.sband, in mt7925_set_stream_he_eht_caps()
312 struct mt76_phy *mphy = phy->mt76; in __mt7925_start()
313 struct mt792x_dev *dev = phy->dev; in __mt7925_start()
324 if (!dev->sar_inited) { in __mt7925_start()
325 err = mt7925_set_tx_sar_pwr(mphy->hw, NULL); in __mt7925_start()
328 dev->sar_inited = true; in __mt7925_start()
332 set_bit(MT76_STATE_RUNNING, &mphy->state); in __mt7925_start()
334 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in __mt7925_start()
337 if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) in __mt7925_start()
338 wiphy_rfkill_start_polling(mphy->hw->wiphy); in __mt7925_start()
344 static int mt7925_start(struct ieee80211_hw *hw) in mt7925_start() argument
346 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_start()
349 mt792x_mutex_acquire(phy->dev); in mt7925_start()
351 mt792x_mutex_release(phy->dev); in mt7925_start()
361 struct ieee80211_vif *vif = link_conf->vif; in mt7925_mac_link_bss_add()
362 struct mt792x_vif *mvif = mconf->vif; in mt7925_mac_link_bss_add()
366 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { in mt7925_mac_link_bss_add()
367 mconf->mt76.idx = MT792x_MAX_INTERFACES; in mt7925_mac_link_bss_add()
369 mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask); in mt7925_mac_link_bss_add()
371 if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) { in mt7925_mac_link_bss_add()
372 ret = -ENOSPC; in mt7925_mac_link_bss_add()
377 mconf->mt76.omac_idx = ieee80211_vif_is_mld(vif) ? in mt7925_mac_link_bss_add()
378 0 : mconf->mt76.idx; in mt7925_mac_link_bss_add()
379 mconf->mt76.band_idx = 0xff; in mt7925_mac_link_bss_add()
380 mconf->mt76.wmm_idx = ieee80211_vif_is_mld(vif) ? in mt7925_mac_link_bss_add()
381 0 : mconf->mt76.idx % MT76_CONNAC_MAX_WMM_SETS; in mt7925_mac_link_bss_add()
382 mconf->mt76.link_idx = hweight16(mvif->valid_links); in mt7925_mac_link_bss_add()
384 if (mvif->phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ) in mt7925_mac_link_bss_add()
385 mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4; in mt7925_mac_link_bss_add()
387 mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL; in mt7925_mac_link_bss_add()
389 dev->mt76.vif_mask |= BIT_ULL(mconf->mt76.idx); in mt7925_mac_link_bss_add()
390 mvif->phy->omac_mask |= BIT_ULL(mconf->mt76.omac_idx); in mt7925_mac_link_bss_add()
392 idx = MT792x_WTBL_RESERVED - mconf->mt76.idx; in mt7925_mac_link_bss_add()
394 mlink->wcid.idx = idx; in mt7925_mac_link_bss_add()
395 mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7925_mac_link_bss_add()
396 mt76_wcid_init(&mlink->wcid, 0); in mt7925_mac_link_bss_add()
401 ewma_rssi_init(&mconf->rssi); in mt7925_mac_link_bss_add()
403 rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->wcid); in mt7925_mac_link_bss_add()
405 ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf, &mconf->mt76, in mt7925_mac_link_bss_add()
406 &mlink->wcid, true); in mt7925_mac_link_bss_add()
410 if (vif->txq) { in mt7925_mac_link_bss_add()
411 mtxq = (struct mt76_txq *)vif->txq->drv_priv; in mt7925_mac_link_bss_add()
412 mtxq->wcid = idx; in mt7925_mac_link_bss_add()
420 mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) in mt7925_add_interface() argument
422 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_add_interface()
423 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_add_interface()
424 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_add_interface()
429 mvif->phy = phy; in mt7925_add_interface()
430 mvif->bss_conf.vif = mvif; in mt7925_add_interface()
431 mvif->sta.vif = mvif; in mt7925_add_interface()
432 mvif->deflink_id = IEEE80211_LINK_UNSPECIFIED; in mt7925_add_interface()
433 mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; in mt7925_add_interface()
435 ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink); in mt7925_add_interface()
439 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; in mt7925_add_interface()
449 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_roc_iter()
452 mt7925_mcu_abort_roc(phy, &mvif->bss_conf, phy->roc_token_id); in mt7925_roc_iter()
457 struct mt792x_phy *phy = &dev->phy; in mt7925_roc_abort_sync()
459 timer_delete_sync(&phy->roc_timer); in mt7925_roc_abort_sync()
460 cancel_work_sync(&phy->roc_work); in mt7925_roc_abort_sync()
461 if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7925_roc_abort_sync()
475 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7925_roc_work()
478 mt792x_mutex_acquire(phy->dev); in mt7925_roc_work()
479 ieee80211_iterate_active_interfaces(phy->mt76->hw, in mt7925_roc_work()
482 mt792x_mutex_release(phy->dev); in mt7925_roc_work()
483 ieee80211_remain_on_channel_expired(phy->mt76->hw); in mt7925_roc_work()
491 timer_delete_sync(&phy->roc_timer); in mt7925_abort_roc()
492 cancel_work_sync(&phy->roc_work); in mt7925_abort_roc()
494 mt792x_mutex_acquire(phy->dev); in mt7925_abort_roc()
495 if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7925_abort_roc()
496 err = mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id); in mt7925_abort_roc()
497 mt792x_mutex_release(phy->dev); in mt7925_abort_roc()
510 if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state)) in mt7925_set_roc()
511 return -EBUSY; in mt7925_set_roc()
513 phy->roc_grant = false; in mt7925_set_roc()
516 ++phy->roc_token_id); in mt7925_set_roc()
518 clear_bit(MT76_STATE_ROC, &phy->mt76->state); in mt7925_set_roc()
522 if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, 4 * HZ)) { in mt7925_set_roc()
523 mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id); in mt7925_set_roc()
524 clear_bit(MT76_STATE_ROC, &phy->mt76->state); in mt7925_set_roc()
525 err = -ETIMEDOUT; in mt7925_set_roc()
538 if (WARN_ON_ONCE(test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state))) in mt7925_set_mlo_roc()
539 return -EBUSY; in mt7925_set_mlo_roc()
541 phy->roc_grant = false; in mt7925_set_mlo_roc()
543 err = mt7925_mcu_set_mlo_roc(mconf, sel_links, 5, ++phy->roc_token_id); in mt7925_set_mlo_roc()
545 clear_bit(MT76_STATE_ROC, &phy->mt76->state); in mt7925_set_mlo_roc()
549 if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, 4 * HZ)) { in mt7925_set_mlo_roc()
550 mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id); in mt7925_set_mlo_roc()
551 clear_bit(MT76_STATE_ROC, &phy->mt76->state); in mt7925_set_mlo_roc()
552 err = -ETIMEDOUT; in mt7925_set_mlo_roc()
559 static int mt7925_remain_on_channel(struct ieee80211_hw *hw, in mt7925_remain_on_channel() argument
565 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_remain_on_channel()
566 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_remain_on_channel()
569 mt792x_mutex_acquire(phy->dev); in mt7925_remain_on_channel()
570 err = mt7925_set_roc(phy, &mvif->bss_conf, in mt7925_remain_on_channel()
572 mt792x_mutex_release(phy->dev); in mt7925_remain_on_channel()
577 static int mt7925_cancel_remain_on_channel(struct ieee80211_hw *hw, in mt7925_cancel_remain_on_channel() argument
580 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_cancel_remain_on_channel()
581 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_cancel_remain_on_channel()
583 return mt7925_abort_roc(phy, &mvif->bss_conf); in mt7925_cancel_remain_on_channel()
586 static int mt7925_set_link_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, in mt7925_set_link_key() argument
590 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_set_link_key()
591 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_set_link_key()
592 struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : in mt7925_set_link_key()
593 &mvif->sta; in mt7925_set_link_key()
596 int idx = key->keyidx, err = 0; in mt7925_set_link_key()
606 wcid = &mlink->wcid; in mt7925_set_link_key()
607 wcid_keyidx = &wcid->hw_key_idx; in mt7925_set_link_key()
610 switch (key->cipher) { in mt7925_set_link_key()
612 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE; in mt7925_set_link_key()
613 wcid_keyidx = &wcid->hw_key_idx2; in mt7925_set_link_key()
617 if (!mvif->wep_sta) in mt7925_set_link_key()
618 return -EOPNOTSUPP; in mt7925_set_link_key()
628 return -EOPNOTSUPP; in mt7925_set_link_key()
631 if (cmd == SET_KEY && !mconf->mt76.cipher) { in mt7925_set_link_key()
632 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_set_link_key()
634 mconf->mt76.cipher = mt7925_mcu_get_cipher(key->cipher); in mt7925_set_link_key()
635 mt7925_mcu_add_bss_info(phy, mconf->mt76.ctx, link_conf, in mt7925_set_link_key()
642 *wcid_keyidx = -1; in mt7925_set_link_key()
646 mt76_wcid_key_setup(&dev->mt76, wcid, in mt7925_set_link_key()
649 err = mt7925_mcu_add_key(&dev->mt76, vif, &mlink->bip, in mt7925_set_link_key()
651 &mlink->wcid, cmd, msta); in mt7925_set_link_key()
656 if (key->cipher == WLAN_CIPHER_SUITE_WEP104 || in mt7925_set_link_key()
657 key->cipher == WLAN_CIPHER_SUITE_WEP40) in mt7925_set_link_key()
658 err = mt7925_mcu_add_key(&dev->mt76, vif, &mvif->wep_sta->deflink.bip, in mt7925_set_link_key()
660 &mvif->wep_sta->deflink.wcid, cmd, msta); in mt7925_set_link_key()
665 static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, in mt7925_set_key() argument
669 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_set_key()
670 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_set_key()
671 struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : in mt7925_set_key()
672 &mvif->sta; in mt7925_set_key()
675 /* The hardware does not support per-STA RX GTK, fallback in mt7925_set_key()
678 if ((vif->type == NL80211_IFTYPE_ADHOC || in mt7925_set_key()
679 vif->type == NL80211_IFTYPE_MESH_POINT) && in mt7925_set_key()
680 (key->cipher == WLAN_CIPHER_SUITE_TKIP || in mt7925_set_key()
681 key->cipher == WLAN_CIPHER_SUITE_CCMP) && in mt7925_set_key()
682 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) in mt7925_set_key()
683 return -EOPNOTSUPP; in mt7925_set_key()
691 add = key->link_id != -1 ? BIT(key->link_id) : msta->valid_links; in mt7925_set_key()
694 err = mt7925_set_link_key(hw, cmd, vif, sta, key, link_id); in mt7925_set_key()
699 err = mt7925_set_link_key(hw, cmd, vif, sta, key, vif->bss_conf.link_id); in mt7925_set_key()
711 struct ieee80211_hw *hw = mt76_hw(dev); in mt7925_pm_interface_iter() local
712 bool pm_enable = dev->pm.enable; in mt7925_pm_interface_iter()
720 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; in mt7925_pm_interface_iter()
721 ieee80211_hw_set(hw, CONNECTION_MONITOR); in mt7925_pm_interface_iter()
723 vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; in mt7925_pm_interface_iter()
724 __clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags); in mt7925_pm_interface_iter()
732 struct ieee80211_hw *hw = mt76_hw(dev); in mt7925_sniffer_interface_iter() local
733 struct mt76_connac_pm *pm = &dev->pm; in mt7925_sniffer_interface_iter()
734 bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); in mt7925_sniffer_interface_iter() local
736 mt7925_mcu_set_sniffer(dev, vif, monitor); in mt7925_sniffer_interface_iter()
737 pm->enable = pm->enable_user && !monitor; in mt7925_sniffer_interface_iter()
738 pm->ds_enable = pm->ds_enable_user && !monitor; in mt7925_sniffer_interface_iter()
740 mt7925_mcu_set_deep_sleep(dev, pm->ds_enable); in mt7925_sniffer_interface_iter()
742 if (monitor) in mt7925_sniffer_interface_iter()
748 struct ieee80211_hw *hw = mt76_hw(dev); in mt7925_set_runtime_pm() local
749 struct mt76_connac_pm *pm = &dev->pm; in mt7925_set_runtime_pm()
750 bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); in mt7925_set_runtime_pm() local
752 pm->enable = pm->enable_user && !monitor; in mt7925_set_runtime_pm()
753 ieee80211_iterate_active_interfaces(hw, in mt7925_set_runtime_pm()
756 pm->ds_enable = pm->ds_enable_user && !monitor; in mt7925_set_runtime_pm()
757 mt7925_mcu_set_deep_sleep(dev, pm->ds_enable); in mt7925_set_runtime_pm()
760 static int mt7925_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) in mt7925_config() argument
762 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_config()
768 ret = mt7925_set_tx_sar_pwr(hw, NULL); in mt7925_config()
774 ieee80211_iterate_active_interfaces(hw, in mt7925_config()
785 static void mt7925_configure_filter(struct ieee80211_hw *hw, in mt7925_configure_filter() argument
794 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_configure_filter()
814 mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_get_rates_table() argument
817 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7925_get_rates_table()
818 struct mt76_phy *mphy = hw->priv; in mt7925_get_rates_table()
822 rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon, mcast); in mt7925_get_rates_table()
826 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_get_rates_table()
829 idx = MT7925_BEACON_RATES_TBL + 2 * (mvif->idx % 20); in mt7925_get_rates_table()
839 return mvif->basic_rates_idx; in mt7925_get_rates_table()
847 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mac_link_sta_add()
850 u8 link_id = link_sta->link_id; in mt7925_mac_link_sta_add()
856 msta = (struct mt792x_sta *)link_sta->sta->drv_priv; in mt7925_mac_link_sta_add()
859 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT792x_WTBL_STA - 1); in mt7925_mac_link_sta_add()
861 return -ENOSPC; in mt7925_mac_link_sta_add()
864 mt76_wcid_init(&mlink->wcid, 0); in mt7925_mac_link_sta_add()
865 mlink->wcid.sta = 1; in mt7925_mac_link_sta_add()
866 mlink->wcid.idx = idx; in mt7925_mac_link_sta_add()
867 mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7925_mac_link_sta_add()
868 mlink->last_txs = jiffies; in mt7925_mac_link_sta_add()
869 mlink->wcid.link_id = link_sta->link_id; in mt7925_mac_link_sta_add()
870 mlink->wcid.link_valid = !!link_sta->sta->valid_links; in mt7925_mac_link_sta_add()
871 mlink->sta = msta; in mt7925_mac_link_sta_add()
873 wcid = &mlink->wcid; in mt7925_mac_link_sta_add()
874 ewma_signal_init(&wcid->rssi); in mt7925_mac_link_sta_add()
875 rcu_assign_pointer(dev->mt76.wcid[wcid->idx], wcid); in mt7925_mac_link_sta_add()
877 ewma_avg_signal_init(&mlink->avg_ack_signal); in mt7925_mac_link_sta_add()
878 memset(mlink->airtime_ac, 0, in mt7925_mac_link_sta_add()
879 sizeof(msta->deflink.airtime_ac)); in mt7925_mac_link_sta_add()
881 ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm); in mt7925_mac_link_sta_add()
891 if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) { in mt7925_mac_link_sta_add()
893 mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, in mt7925_mac_link_sta_add()
894 link_conf, link_sta, link_sta != mlink->pri_link); in mt7925_mac_link_sta_add()
896 mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, in mt7925_mac_link_sta_add()
901 link_sta == mlink->pri_link) { in mt7925_mac_link_sta_add()
907 link_sta != mlink->pri_link) { in mt7925_mac_link_sta_add()
908 ret = mt7925_mcu_sta_update(dev, mlink->pri_link, vif, in mt7925_mac_link_sta_add()
924 mt76_connac_power_save_sched(&dev->mphy, &dev->pm); in mt7925_mac_link_sta_add()
933 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_mac_sta_add_links()
941 if (msta->deflink_id == IEEE80211_LINK_UNSPECIFIED) { in mt7925_mac_sta_add_links()
942 mlink = &msta->deflink; in mt7925_mac_sta_add_links()
943 msta->deflink_id = link_id; in mt7925_mac_sta_add_links()
945 mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink), GFP_KERNEL); in mt7925_mac_sta_add_links()
947 err = -ENOMEM; in mt7925_mac_sta_add_links()
952 msta->valid_links |= BIT(link_id); in mt7925_mac_sta_add_links()
953 rcu_assign_pointer(msta->link[link_id], mlink); in mt7925_mac_sta_add_links()
954 mlink->sta = msta; in mt7925_mac_sta_add_links()
955 mlink->pri_link = &sta->deflink; in mt7925_mac_sta_add_links()
956 mlink->wcid.def_wcid = &msta->deflink.wcid; in mt7925_mac_sta_add_links()
959 mt7925_mac_link_sta_add(&dev->mt76, vif, link_sta); in mt7925_mac_sta_add_links()
969 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mac_sta_add()
970 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_mac_sta_add()
973 msta->vif = mvif; in mt7925_mac_sta_add()
975 if (vif->type == NL80211_IFTYPE_STATION) in mt7925_mac_sta_add()
976 mvif->wep_sta = msta; in mt7925_mac_sta_add()
979 msta->deflink_id = IEEE80211_LINK_UNSPECIFIED; in mt7925_mac_sta_add()
981 err = mt7925_mac_sta_add_links(dev, vif, sta, sta->valid_links); in mt7925_mac_sta_add()
983 err = mt7925_mac_link_sta_add(mdev, vif, &sta->deflink); in mt7925_mac_sta_add()
1004 if (vif->active_links == usable_links) in mt7925_mac_select_links()
1005 return vif->active_links; in mt7925_mac_select_links()
1010 rcu_dereference(vif->link_conf[link_id]); in mt7925_mac_select_links()
1016 data[n_data].band = link_conf->chanreq.oper.chan->band; in mt7925_mac_select_links()
1022 if (!(BIT(data[i].link_id) & vif->active_links)) in mt7925_mac_select_links()
1044 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mac_set_links()
1046 mt792x_vif_to_bss_conf(vif, mvif->deflink_id); in mt7925_mac_set_links()
1047 struct cfg80211_chan_def *chandef = &link_conf->chanreq.oper; in mt7925_mac_set_links()
1048 enum nl80211_band band = chandef->chan->band, secondary_band; in mt7925_mac_set_links()
1051 u8 secondary_link_id = __ffs(~BIT(mvif->deflink_id) & sel_links); in mt7925_mac_set_links()
1057 secondary_band = link_conf->chanreq.oper.chan->band; in mt7925_mac_set_links()
1061 mt7925_abort_roc(mvif->phy, &mvif->bss_conf); in mt7925_mac_set_links()
1065 mt7925_set_mlo_roc(mvif->phy, &mvif->bss_conf, sel_links); in mt7925_mac_set_links()
1082 msta = (struct mt792x_sta *)link_sta->sta->drv_priv; in mt7925_mac_link_sta_assoc()
1083 mlink = mt792x_sta_to_link(msta, link_sta->link_id); in mt7925_mac_link_sta_assoc()
1088 link_conf = mt792x_vif_to_bss_conf(vif, msta->deflink_id); in mt7925_mac_link_sta_assoc()
1090 link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id); in mt7925_mac_link_sta_assoc()
1093 if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) { in mt7925_mac_link_sta_assoc()
1097 mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, in mt7925_mac_link_sta_assoc()
1101 ewma_avg_signal_init(&mlink->avg_ack_signal); in mt7925_mac_link_sta_assoc()
1103 mt7925_mac_wtbl_update(dev, mlink->wcid.idx, in mt7925_mac_link_sta_assoc()
1105 memset(mlink->airtime_ac, 0, sizeof(mlink->airtime_ac)); in mt7925_mac_link_sta_assoc()
1115 struct ieee80211_link_sta *link_sta = &sta->deflink; in mt7925_mac_sta_event()
1121 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_mac_sta_event()
1123 link_sta = mt792x_sta_to_link_sta(vif, sta, msta->deflink_id); in mt7925_mac_sta_event()
1139 u8 link_id = link_sta->link_id; in mt7925_mac_link_sta_remove()
1143 msta = (struct mt792x_sta *)link_sta->sta->drv_priv; in mt7925_mac_link_sta_remove()
1148 mt76_connac_free_pending_tx_skbs(&dev->pm, &mlink->wcid); in mt7925_mac_link_sta_remove()
1149 mt76_connac_pm_wake(&dev->mphy, &dev->pm); in mt7925_mac_link_sta_remove()
1153 mt7925_mac_wtbl_update(dev, mlink->wcid.idx, in mt7925_mac_link_sta_remove()
1158 if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) { in mt7925_mac_link_sta_remove()
1166 mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf, in mt7925_mac_link_sta_remove()
1170 spin_lock_bh(&mdev->sta_poll_lock); in mt7925_mac_link_sta_remove()
1171 if (!list_empty(&mlink->wcid.poll_list)) in mt7925_mac_link_sta_remove()
1172 list_del_init(&mlink->wcid.poll_list); in mt7925_mac_link_sta_remove()
1173 spin_unlock_bh(&mdev->sta_poll_lock); in mt7925_mac_link_sta_remove()
1175 mt76_connac_power_save_sched(&dev->mphy, &dev->pm); in mt7925_mac_link_sta_remove()
1182 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_mac_sta_remove_links()
1183 struct mt76_dev *mdev = &dev->mt76; in mt7925_mac_sta_remove_links()
1194 if (vif->type == NL80211_IFTYPE_AP) in mt7925_mac_sta_remove_links()
1211 mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf, in mt7925_mac_sta_remove_links()
1227 mt7925_mac_link_sta_remove(&dev->mt76, vif, link_sta); in mt7925_mac_sta_remove_links()
1229 wcid = &mlink->wcid; in mt7925_mac_sta_remove_links()
1230 rcu_assign_pointer(msta->link[link_id], NULL); in mt7925_mac_sta_remove_links()
1231 msta->valid_links &= ~BIT(link_id); in mt7925_mac_sta_remove_links()
1232 mlink->sta = NULL; in mt7925_mac_sta_remove_links()
1233 mlink->pri_link = NULL; in mt7925_mac_sta_remove_links()
1235 if (link_sta != mlink->pri_link) { in mt7925_mac_sta_remove_links()
1237 mt76_wcid_mask_clear(mdev->wcid_mask, wcid->idx); in mt7925_mac_sta_remove_links()
1240 if (msta->deflink_id == link_id) in mt7925_mac_sta_remove_links()
1241 msta->deflink_id = IEEE80211_LINK_UNSPECIFIED; in mt7925_mac_sta_remove_links()
1251 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_mac_sta_remove()
1252 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mac_sta_remove()
1255 rem = ieee80211_vif_is_mld(vif) ? msta->valid_links : BIT(0); in mt7925_mac_sta_remove()
1262 if (vif->type == NL80211_IFTYPE_STATION) { in mt7925_mac_sta_remove()
1263 mvif->wep_sta = NULL; in mt7925_mac_sta_remove()
1264 ewma_rssi_init(&mvif->bss_conf.rssi); in mt7925_mac_sta_remove()
1267 mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; in mt7925_mac_sta_remove()
1271 static int mt7925_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx, in mt7925_set_rts_threshold() argument
1274 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_set_rts_threshold()
1277 mt7925_mcu_set_rts_thresh(&dev->phy, val); in mt7925_set_rts_threshold()
1284 mt7925_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_ampdu_action() argument
1287 enum ieee80211_ampdu_mlme_action action = params->action; in mt7925_ampdu_action()
1288 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_ampdu_action()
1289 struct ieee80211_sta *sta = params->sta; in mt7925_ampdu_action()
1290 struct ieee80211_txq *txq = sta->txq[params->tid]; in mt7925_ampdu_action()
1291 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_ampdu_action()
1292 u16 tid = params->tid; in mt7925_ampdu_action()
1293 u16 ssn = params->ssn; in mt7925_ampdu_action()
1298 return -EINVAL; in mt7925_ampdu_action()
1300 mtxq = (struct mt76_txq *)txq->drv_priv; in mt7925_ampdu_action()
1305 mt76_rx_aggr_start(&dev->mt76, &msta->deflink.wcid, tid, ssn, in mt7925_ampdu_action()
1306 params->buf_size); in mt7925_ampdu_action()
1310 mt76_rx_aggr_stop(&dev->mt76, &msta->deflink.wcid, tid); in mt7925_ampdu_action()
1314 mtxq->aggr = true; in mt7925_ampdu_action()
1315 mtxq->send_bar = false; in mt7925_ampdu_action()
1320 mtxq->aggr = false; in mt7925_ampdu_action()
1321 clear_bit(tid, &msta->deflink.wcid.ampdu_state); in mt7925_ampdu_action()
1325 set_bit(tid, &msta->deflink.wcid.ampdu_state); in mt7925_ampdu_action()
1329 mtxq->aggr = false; in mt7925_ampdu_action()
1330 clear_bit(tid, &msta->deflink.wcid.ampdu_state); in mt7925_ampdu_action()
1332 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in mt7925_ampdu_action()
1344 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mlo_pm_iter()
1346 mvif->valid_links : BIT(0); in mt7925_mlo_pm_iter()
1350 if (mvif->mlo_pm_state != MT792x_MLO_CHANGED_PS) in mt7925_mlo_pm_iter()
1365 struct ieee80211_hw *hw = mt76_hw(dev); in mt7925_mlo_pm_work() local
1367 ieee80211_iterate_active_interfaces(hw, in mt7925_mlo_pm_work()
1394 struct mt76_dev *mdev = &phy->dev->mt76; in mt7925_scan_work()
1399 spin_lock_bh(&phy->dev->mt76.lock); in mt7925_scan_work()
1400 skb = __skb_dequeue(&phy->scan_event_list); in mt7925_scan_work()
1401 spin_unlock_bh(&phy->dev->mt76.lock); in mt7925_scan_work()
1407 tlv = (struct tlv *)skb->data; in mt7925_scan_work()
1408 tlv_len = skb->len; in mt7925_scan_work()
1410 while (tlv_len > 0 && le16_to_cpu(tlv->len) <= tlv_len) { in mt7925_scan_work()
1413 switch (le16_to_cpu(tlv->tag)) { in mt7925_scan_work()
1415 if (test_and_clear_bit(MT76_HW_SCANNING, &phy->mt76->state)) { in mt7925_scan_work()
1419 ieee80211_scan_completed(phy->mt76->hw, &info); in mt7925_scan_work()
1423 evt = (struct mt7925_mcu_scan_chinfo_event *)tlv->data; in mt7925_scan_work()
1425 if (!is_valid_alpha2(evt->alpha2)) in mt7925_scan_work()
1428 mt7925_regd_be_ctrl(phy->dev, evt->alpha2); in mt7925_scan_work()
1430 if (mdev->alpha2[0] != '0' && mdev->alpha2[1] != '0') in mt7925_scan_work()
1433 mt7925_mcu_set_clc(phy->dev, evt->alpha2, ENVIRON_INDOOR); in mt7925_scan_work()
1437 ieee80211_sched_scan_results(phy->mt76->hw); in mt7925_scan_work()
1443 tlv_len -= le16_to_cpu(tlv->len); in mt7925_scan_work()
1444 tlv = (struct tlv *)((char *)(tlv) + le16_to_cpu(tlv->len)); in mt7925_scan_work()
1452 mt7925_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_hw_scan() argument
1455 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_hw_scan()
1456 struct mt76_phy *mphy = hw->priv; in mt7925_hw_scan()
1467 mt7925_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif) in mt7925_cancel_hw_scan() argument
1469 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_cancel_hw_scan()
1470 struct mt76_phy *mphy = hw->priv; in mt7925_cancel_hw_scan()
1478 mt7925_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_start_sched_scan() argument
1482 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_start_sched_scan()
1483 struct mt76_phy *mphy = hw->priv; in mt7925_start_sched_scan()
1500 mt7925_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif) in mt7925_stop_sched_scan() argument
1502 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_stop_sched_scan()
1503 struct mt76_phy *mphy = hw->priv; in mt7925_stop_sched_scan()
1514 mt7925_set_antenna(struct ieee80211_hw *hw, int radio_idx, in mt7925_set_antenna() argument
1517 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_set_antenna()
1518 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_set_antenna()
1519 int max_nss = hweight8(hw->wiphy->available_antennas_tx); in mt7925_set_antenna()
1522 return -EINVAL; in mt7925_set_antenna()
1524 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant) in mt7925_set_antenna()
1525 tx_ant = BIT(ffs(tx_ant) - 1) - 1; in mt7925_set_antenna()
1529 phy->mt76->antenna_mask = tx_ant; in mt7925_set_antenna()
1530 phy->mt76->chainmask = tx_ant; in mt7925_set_antenna()
1532 mt76_set_stream_caps(phy->mt76, true); in mt7925_set_antenna()
1542 static int mt7925_suspend(struct ieee80211_hw *hw, in mt7925_suspend() argument
1545 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_suspend()
1546 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_suspend()
1548 cancel_delayed_work_sync(&phy->scan_work); in mt7925_suspend()
1549 cancel_delayed_work_sync(&phy->mt76->mac_work); in mt7925_suspend()
1551 cancel_delayed_work_sync(&dev->pm.ps_work); in mt7925_suspend()
1552 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL); in mt7925_suspend()
1556 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state); in mt7925_suspend()
1557 ieee80211_iterate_active_interfaces(hw, in mt7925_suspend()
1560 &dev->mphy); in mt7925_suspend()
1567 static int mt7925_resume(struct ieee80211_hw *hw) in mt7925_resume() argument
1569 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_resume()
1570 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_resume()
1574 set_bit(MT76_STATE_RUNNING, &phy->mt76->state); in mt7925_resume()
1575 ieee80211_iterate_active_interfaces(hw, in mt7925_resume()
1578 &dev->mphy); in mt7925_resume()
1580 ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, in mt7925_resume()
1588 static void mt7925_set_rekey_data(struct ieee80211_hw *hw, in mt7925_set_rekey_data() argument
1592 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_set_rekey_data()
1595 mt76_connac_mcu_update_gtk_rekey(hw, vif, data); in mt7925_set_rekey_data()
1600 static void mt7925_sta_set_decap_offload(struct ieee80211_hw *hw, in mt7925_sta_set_decap_offload() argument
1605 struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; in mt7925_sta_set_decap_offload()
1606 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_sta_set_decap_offload()
1607 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_sta_set_decap_offload()
1608 unsigned long valid = mvif->valid_links; in mt7925_sta_set_decap_offload()
1611 if (!msta->vif) in mt7925_sta_set_decap_offload()
1616 valid = ieee80211_vif_is_mld(vif) ? mvif->valid_links : BIT(0); in mt7925_sta_set_decap_offload()
1624 set_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); in mt7925_sta_set_decap_offload()
1626 clear_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); in mt7925_sta_set_decap_offload()
1628 if (!mlink->wcid.sta) in mt7925_sta_set_decap_offload()
1638 static void __mt7925_ipv6_addr_change(struct ieee80211_hw *hw, in __mt7925_ipv6_addr_change() argument
1643 struct mt792x_dev *dev = mt792x_hw_dev(hw); in __mt7925_ipv6_addr_change()
1657 .bss_idx = mconf->mt76.idx, in __mt7925_ipv6_addr_change()
1661 .len = cpu_to_le16(sizeof(req_hdr) - 4), in __mt7925_ipv6_addr_change()
1666 read_lock_bh(&idev->lock); in __mt7925_ipv6_addr_change()
1667 list_for_each_entry(ifa, &idev->addr_list, if_list) { in __mt7925_ipv6_addr_change()
1668 if (ifa->flags & IFA_F_TENTATIVE) in __mt7925_ipv6_addr_change()
1670 req_hdr.ns_addrs[idx] = ifa->addr; in __mt7925_ipv6_addr_change()
1674 read_unlock_bh(&idev->lock); in __mt7925_ipv6_addr_change()
1681 skb = __mt76_mcu_msg_alloc(&dev->mt76, NULL, sizeof(req_hdr), in __mt7925_ipv6_addr_change()
1688 skb_queue_tail(&dev->ipv6_ns_list, skb); in __mt7925_ipv6_addr_change()
1690 ieee80211_queue_work(dev->mt76.hw, &dev->ipv6_ns_work); in __mt7925_ipv6_addr_change()
1693 static void mt7925_ipv6_addr_change(struct ieee80211_hw *hw, in mt7925_ipv6_addr_change() argument
1697 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_ipv6_addr_change()
1699 mvif->valid_links : BIT(0); in mt7925_ipv6_addr_change()
1705 __mt7925_ipv6_addr_change(hw, bss_conf, idev); in mt7925_ipv6_addr_change()
1711 int mt7925_set_tx_sar_pwr(struct ieee80211_hw *hw, in mt7925_set_tx_sar_pwr() argument
1714 struct mt76_phy *mphy = hw->priv; in mt7925_set_tx_sar_pwr()
1717 int err = mt76_init_sar_power(hw, sar); in mt7925_set_tx_sar_pwr()
1722 mt792x_init_acpi_sar_power(mt792x_hw_phy(hw), !sar); in mt7925_set_tx_sar_pwr()
1727 static int mt7925_set_sar_specs(struct ieee80211_hw *hw, in mt7925_set_sar_specs() argument
1730 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_set_sar_specs()
1734 err = mt7925_mcu_set_clc(dev, dev->mt76.alpha2, in mt7925_set_sar_specs()
1735 dev->country_ie_env); in mt7925_set_sar_specs()
1739 err = mt7925_set_tx_sar_pwr(hw, sar); in mt7925_set_sar_specs()
1747 mt7925_channel_switch_beacon(struct ieee80211_hw *hw, in mt7925_channel_switch_beacon() argument
1751 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_channel_switch_beacon()
1754 mt7925_mcu_uni_add_beacon_offload(dev, hw, vif, true); in mt7925_channel_switch_beacon()
1759 mt7925_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_conf_tx() argument
1763 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_conf_tx()
1773 mconf->queue_params[mq_to_aci[queue]] = *params; in mt7925_conf_tx()
1779 mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_start_ap() argument
1782 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_start_ap()
1783 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_start_ap()
1788 err = mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, in mt7925_start_ap()
1806 mt7925_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_stop_ap() argument
1809 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_stop_ap()
1810 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_stop_ap()
1819 mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, link_conf, in mt7925_stop_ap()
1827 mt7925_add_chanctx(struct ieee80211_hw *hw, in mt7925_add_chanctx() argument
1834 mt7925_remove_chanctx(struct ieee80211_hw *hw, in mt7925_remove_chanctx() argument
1840 mt7925_change_chanctx(struct ieee80211_hw *hw, in mt7925_change_chanctx() argument
1844 struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; in mt7925_change_chanctx()
1845 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_change_chanctx()
1850 if (!mctx->bss_conf) in mt7925_change_chanctx()
1853 mconf = mctx->bss_conf; in mt7925_change_chanctx()
1854 mvif = mconf->vif; in mt7925_change_chanctx()
1857 mt792x_mutex_acquire(phy->dev); in mt7925_change_chanctx()
1858 if (vif->type == NL80211_IFTYPE_MONITOR) { in mt7925_change_chanctx()
1859 mt7925_mcu_set_sniffer(mvif->phy->dev, vif, true); in mt7925_change_chanctx()
1863 unsigned long valid = mvif->valid_links; in mt7925_change_chanctx()
1868 if (mconf && mconf->mt76.ctx == ctx) in mt7925_change_chanctx()
1873 mconf = &mvif->bss_conf; in mt7925_change_chanctx()
1879 link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id); in mt7925_change_chanctx()
1880 mt7925_mcu_set_chctx(mvif->phy->mt76, &mconf->mt76, in mt7925_change_chanctx()
1884 mt7925_mcu_set_eht_pp(mvif->phy->mt76, &mconf->mt76, in mt7925_change_chanctx()
1889 mt792x_mutex_release(phy->dev); in mt7925_change_chanctx()
1892 static void mt7925_mgd_prepare_tx(struct ieee80211_hw *hw, in mt7925_mgd_prepare_tx() argument
1896 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mgd_prepare_tx()
1897 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_mgd_prepare_tx()
1898 u16 duration = info->duration ? info->duration : in mt7925_mgd_prepare_tx()
1902 mt7925_set_roc(mvif->phy, &mvif->bss_conf, in mt7925_mgd_prepare_tx()
1903 mvif->bss_conf.mt76.ctx->def.chan, duration, in mt7925_mgd_prepare_tx()
1908 static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw, in mt7925_mgd_complete_tx() argument
1912 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_mgd_complete_tx()
1914 mt7925_abort_roc(mvif->phy, &mvif->bss_conf); in mt7925_mgd_complete_tx()
1917 static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, in mt7925_vif_cfg_changed() argument
1921 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_vif_cfg_changed()
1922 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_vif_cfg_changed()
1924 mvif->valid_links : BIT(0); in mt7925_vif_cfg_changed()
1933 mt7925_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc); in mt7925_vif_cfg_changed()
1936 mvif->mlo_pm_state = MT792x_MLO_LINK_ASSOC; in mt7925_vif_cfg_changed()
1942 mt7925_mcu_update_arp_filter(&dev->mt76, bss_conf); in mt7925_vif_cfg_changed()
1947 if (hweight16(mvif->valid_links) < 2) { in mt7925_vif_cfg_changed()
1949 bss_conf = &vif->bss_conf; in mt7925_vif_cfg_changed()
1952 if (mvif->mlo_pm_state == MT792x_MLO_LINK_ASSOC) { in mt7925_vif_cfg_changed()
1953 mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS_PENDING; in mt7925_vif_cfg_changed()
1954 } else if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS) { in mt7925_vif_cfg_changed()
1966 static void mt7925_link_info_changed(struct ieee80211_hw *hw, in mt7925_link_info_changed() argument
1971 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_link_info_changed()
1972 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_link_info_changed()
1973 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_link_info_changed()
1977 mconf = mt792x_vif_to_link(mvif, info->link_id); in mt7925_link_info_changed()
1978 link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id); in mt7925_link_info_changed()
1983 int slottime = info->use_short_slot ? 9 : 20; in mt7925_link_info_changed()
1985 if (slottime != phy->slottime) { in mt7925_link_info_changed()
1986 phy->slottime = slottime; in mt7925_link_info_changed()
1992 mconf->mt76.mcast_rates_idx = in mt7925_link_info_changed()
1993 mt7925_get_rates_table(hw, vif, false, true); in mt7925_link_info_changed()
1996 mconf->mt76.basic_rates_idx = in mt7925_link_info_changed()
1997 mt7925_get_rates_table(hw, vif, false, false); in mt7925_link_info_changed()
2001 mconf->mt76.beacon_rates_idx = in mt7925_link_info_changed()
2002 mt7925_get_rates_table(hw, vif, true, false); in mt7925_link_info_changed()
2004 mt7925_mcu_uni_add_beacon_offload(dev, hw, vif, in mt7925_link_info_changed()
2005 info->enable_beacon); in mt7925_link_info_changed()
2012 if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS_PENDING) { in mt7925_link_info_changed()
2016 ieee80211_queue_delayed_work(hw, &dev->mlo_pm_work, 5 * HZ); in mt7925_link_info_changed()
2017 mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS; in mt7925_link_info_changed()
2021 mt7925_mcu_set_eht_pp(mvif->phy->mt76, &mconf->mt76, in mt7925_link_info_changed()
2028 mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_change_vif_links() argument
2034 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_change_vif_links()
2037 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_change_vif_links()
2038 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_change_vif_links()
2050 mlink = mt792x_sta_to_link(&mvif->sta, link_id); in mt7925_change_vif_links()
2055 if (mconf != &mvif->bss_conf) { in mt7925_change_vif_links()
2057 devm_kfree(dev->mt76.dev, mconf); in mt7925_change_vif_links()
2058 devm_kfree(dev->mt76.dev, mlink); in mt7925_change_vif_links()
2061 rcu_assign_pointer(mvif->link_conf[link_id], NULL); in mt7925_change_vif_links()
2062 rcu_assign_pointer(mvif->sta.link[link_id], NULL); in mt7925_change_vif_links()
2067 mvif->deflink_id = link_id; in mt7925_change_vif_links()
2068 mconf = &mvif->bss_conf; in mt7925_change_vif_links()
2069 mlink = &mvif->sta.deflink; in mt7925_change_vif_links()
2071 mconf = devm_kzalloc(dev->mt76.dev, sizeof(*mconf), in mt7925_change_vif_links()
2073 mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink), in mt7925_change_vif_links()
2077 return -ENOMEM; in mt7925_change_vif_links()
2083 mconf->link_id = link_id; in mt7925_change_vif_links()
2084 mconf->vif = mvif; in mt7925_change_vif_links()
2085 mlink->wcid.link_id = link_id; in mt7925_change_vif_links()
2086 mlink->wcid.link_valid = !!vif->valid_links; in mt7925_change_vif_links()
2087 mlink->wcid.def_wcid = &mvif->sta.deflink.wcid; in mt7925_change_vif_links()
2090 if (hweight16(mvif->valid_links) == 0) in mt7925_change_vif_links()
2091 mt792x_mac_link_bss_remove(dev, &mvif->bss_conf, in mt7925_change_vif_links()
2092 &mvif->sta.deflink); in mt7925_change_vif_links()
2099 rcu_assign_pointer(mvif->link_conf[link_id], mconf); in mt7925_change_vif_links()
2100 rcu_assign_pointer(mvif->sta.link[link_id], mlink); in mt7925_change_vif_links()
2106 if (mconf != &mvif->bss_conf) { in mt7925_change_vif_links()
2107 err = mt7925_set_mlo_roc(phy, &mvif->bss_conf, in mt7925_change_vif_links()
2108 vif->active_links); in mt7925_change_vif_links()
2114 mvif->valid_links = new_links; in mt7925_change_vif_links()
2122 rcu_assign_pointer(mvif->link_conf[link_id], NULL); in mt7925_change_vif_links()
2123 rcu_assign_pointer(mvif->sta.link[link_id], NULL); in mt7925_change_vif_links()
2125 if (mconf != &mvif->bss_conf) in mt7925_change_vif_links()
2126 devm_kfree(dev->mt76.dev, mconfs[link_id]); in mt7925_change_vif_links()
2127 if (mlink != &mvif->sta.deflink) in mt7925_change_vif_links()
2128 devm_kfree(dev->mt76.dev, mlinks[link_id]); in mt7925_change_vif_links()
2137 mt7925_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in mt7925_change_sta_links() argument
2142 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_change_sta_links()
2164 static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw, in mt7925_assign_vif_chanctx() argument
2169 struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; in mt7925_assign_vif_chanctx()
2170 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_assign_vif_chanctx()
2171 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_assign_vif_chanctx()
2175 mutex_lock(&dev->mt76.mutex); in mt7925_assign_vif_chanctx()
2178 mconf = mt792x_vif_to_link(mvif, link_conf->link_id); in mt7925_assign_vif_chanctx()
2179 pri_link_conf = mt792x_vif_to_bss_conf(vif, mvif->deflink_id); in mt7925_assign_vif_chanctx()
2181 if (vif->type == NL80211_IFTYPE_STATION && in mt7925_assign_vif_chanctx()
2182 mconf == &mvif->bss_conf) in mt7925_assign_vif_chanctx()
2183 mt7925_mcu_add_bss_info(&dev->phy, NULL, pri_link_conf, in mt7925_assign_vif_chanctx()
2186 mconf = &mvif->bss_conf; in mt7925_assign_vif_chanctx()
2189 mconf->mt76.ctx = ctx; in mt7925_assign_vif_chanctx()
2190 mctx->bss_conf = mconf; in mt7925_assign_vif_chanctx()
2191 mutex_unlock(&dev->mt76.mutex); in mt7925_assign_vif_chanctx()
2196 static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw, in mt7925_unassign_vif_chanctx() argument
2201 struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; in mt7925_unassign_vif_chanctx()
2202 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; in mt7925_unassign_vif_chanctx()
2203 struct mt792x_dev *dev = mt792x_hw_dev(hw); in mt7925_unassign_vif_chanctx()
2206 mutex_lock(&dev->mt76.mutex); in mt7925_unassign_vif_chanctx()
2209 mconf = mt792x_vif_to_link(mvif, link_conf->link_id); in mt7925_unassign_vif_chanctx()
2211 if (vif->type == NL80211_IFTYPE_STATION && in mt7925_unassign_vif_chanctx()
2212 mconf == &mvif->bss_conf) in mt7925_unassign_vif_chanctx()
2213 mt7925_mcu_add_bss_info(&dev->phy, NULL, link_conf, in mt7925_unassign_vif_chanctx()
2216 mconf = &mvif->bss_conf; in mt7925_unassign_vif_chanctx()
2219 mctx->bss_conf = NULL; in mt7925_unassign_vif_chanctx()
2220 mconf->mt76.ctx = NULL; in mt7925_unassign_vif_chanctx()
2221 mutex_unlock(&dev->mt76.mutex); in mt7925_unassign_vif_chanctx()
2224 static void mt7925_rfkill_poll(struct ieee80211_hw *hw) in mt7925_rfkill_poll() argument
2226 struct mt792x_phy *phy = mt792x_hw_phy(hw); in mt7925_rfkill_poll()
2229 mt792x_mutex_acquire(phy->dev); in mt7925_rfkill_poll()
2231 mt792x_mutex_release(phy->dev); in mt7925_rfkill_poll()
2233 wiphy_rfkill_set_hw_state(hw->wiphy, ret == 0); in mt7925_rfkill_poll()