Lines Matching +full:rates +full:- +full:ru

1 // SPDX-License-Identifier: ISC
82 /* UNII-5 */
107 /* UNII-6 */
114 /* UNII-7 */
132 /* UNII-8 */
198 struct mt76_dev *dev = phy->dev; in mt76_led_init()
199 struct ieee80211_hw *hw = phy->hw; in mt76_led_init()
200 struct device_node *np = dev->dev->of_node; in mt76_led_init()
202 if (!phy->leds.cdev.brightness_set && !phy->leds.cdev.blink_set) in mt76_led_init()
209 dev_info(dev->dev, in mt76_led_init()
214 if (phy == &dev->phy) { in mt76_led_init()
217 if (!of_property_read_u32(np, "led-sources", &led_pin)) in mt76_led_init()
218 phy->leds.pin = led_pin; in mt76_led_init()
220 phy->leds.al = in mt76_led_init()
221 of_property_read_bool(np, "led-active-low"); in mt76_led_init()
227 snprintf(phy->leds.name, sizeof(phy->leds.name), "mt76-%s", in mt76_led_init()
228 wiphy_name(hw->wiphy)); in mt76_led_init()
230 phy->leds.cdev.name = phy->leds.name; in mt76_led_init()
231 phy->leds.cdev.default_trigger = in mt76_led_init()
237 dev_info(dev->dev, in mt76_led_init()
238 "registering led '%s'\n", phy->leds.name); in mt76_led_init()
240 return led_classdev_register(dev->dev, &phy->leds.cdev); in mt76_led_init()
245 if (!phy->leds.cdev.brightness_set && !phy->leds.cdev.blink_set) in mt76_led_cleanup()
248 led_classdev_unregister(&phy->leds.cdev); in mt76_led_cleanup()
255 struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; in mt76_init_stream_cap()
256 int i, nstream = hweight8(phy->antenna_mask); in mt76_init_stream_cap()
261 ht_cap->cap |= IEEE80211_HT_CAP_TX_STBC; in mt76_init_stream_cap()
263 ht_cap->cap &= ~IEEE80211_HT_CAP_TX_STBC; in mt76_init_stream_cap()
266 ht_cap->mcs.rx_mask[i] = i < nstream ? 0xff : 0; in mt76_init_stream_cap()
271 vht_cap = &sband->vht_cap; in mt76_init_stream_cap()
273 vht_cap->cap |= IEEE80211_VHT_CAP_TXSTBC; in mt76_init_stream_cap()
275 vht_cap->cap &= ~IEEE80211_VHT_CAP_TXSTBC; in mt76_init_stream_cap()
276 vht_cap->cap |= IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN | in mt76_init_stream_cap()
286 vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); in mt76_init_stream_cap()
287 vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); in mt76_init_stream_cap()
288 if (ieee80211_hw_check(phy->hw, SUPPORTS_VHT_EXT_NSS_BW)) in mt76_init_stream_cap()
289 vht_cap->vht_mcs.tx_highest |= in mt76_init_stream_cap()
295 if (phy->cap.has_2ghz) in mt76_set_stream_caps()
296 mt76_init_stream_cap(phy, &phy->sband_2g.sband, false); in mt76_set_stream_caps()
297 if (phy->cap.has_5ghz) in mt76_set_stream_caps()
298 mt76_init_stream_cap(phy, &phy->sband_5g.sband, vht); in mt76_set_stream_caps()
299 if (phy->cap.has_6ghz) in mt76_set_stream_caps()
300 mt76_init_stream_cap(phy, &phy->sband_6g.sband, vht); in mt76_set_stream_caps()
307 struct ieee80211_rate *rates, int n_rates, in mt76_init_sband() argument
310 struct ieee80211_supported_band *sband = &msband->sband; in mt76_init_sband()
313 struct mt76_dev *dev = phy->dev; in mt76_init_sband()
318 chanlist = devm_kmemdup(dev->dev, chan, size, GFP_KERNEL); in mt76_init_sband()
320 return -ENOMEM; in mt76_init_sband()
322 msband->chan = devm_kcalloc(dev->dev, n_chan, sizeof(*msband->chan), in mt76_init_sband()
324 if (!msband->chan) in mt76_init_sband()
325 return -ENOMEM; in mt76_init_sband()
327 sband->channels = chanlist; in mt76_init_sband()
328 sband->n_channels = n_chan; in mt76_init_sband()
329 sband->bitrates = rates; in mt76_init_sband()
330 sband->n_bitrates = n_rates; in mt76_init_sband()
335 ht_cap = &sband->ht_cap; in mt76_init_sband()
336 ht_cap->ht_supported = true; in mt76_init_sband()
337 ht_cap->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40 | in mt76_init_sband()
343 ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in mt76_init_sband()
344 ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; in mt76_init_sband()
351 vht_cap = &sband->vht_cap; in mt76_init_sband()
352 vht_cap->vht_supported = true; in mt76_init_sband()
353 vht_cap->cap |= IEEE80211_VHT_CAP_RXLDPC | in mt76_init_sband()
362 mt76_init_sband_2g(struct mt76_phy *phy, struct ieee80211_rate *rates, in mt76_init_sband_2g() argument
365 phy->hw->wiphy->bands[NL80211_BAND_2GHZ] = &phy->sband_2g.sband; in mt76_init_sband_2g()
367 return mt76_init_sband(phy, &phy->sband_2g, mt76_channels_2ghz, in mt76_init_sband_2g()
368 ARRAY_SIZE(mt76_channels_2ghz), rates, in mt76_init_sband_2g()
373 mt76_init_sband_5g(struct mt76_phy *phy, struct ieee80211_rate *rates, in mt76_init_sband_5g() argument
376 phy->hw->wiphy->bands[NL80211_BAND_5GHZ] = &phy->sband_5g.sband; in mt76_init_sband_5g()
378 return mt76_init_sband(phy, &phy->sband_5g, mt76_channels_5ghz, in mt76_init_sband_5g()
379 ARRAY_SIZE(mt76_channels_5ghz), rates, in mt76_init_sband_5g()
384 mt76_init_sband_6g(struct mt76_phy *phy, struct ieee80211_rate *rates, in mt76_init_sband_6g() argument
387 phy->hw->wiphy->bands[NL80211_BAND_6GHZ] = &phy->sband_6g.sband; in mt76_init_sband_6g()
389 return mt76_init_sband(phy, &phy->sband_6g, mt76_channels_6ghz, in mt76_init_sband_6g()
390 ARRAY_SIZE(mt76_channels_6ghz), rates, in mt76_init_sband_6g()
398 struct ieee80211_supported_band *sband = &msband->sband; in mt76_check_sband()
405 for (i = 0; i < sband->n_channels; i++) { in mt76_check_sband()
406 if (sband->channels[i].flags & IEEE80211_CHAN_DISABLED) in mt76_check_sband()
414 cfg80211_chandef_create(&phy->chandef, &sband->channels[0], in mt76_check_sband()
416 phy->chan_state = &msband->chan[0]; in mt76_check_sband()
417 phy->dev->band_phys[band] = phy; in mt76_check_sband()
421 sband->n_channels = 0; in mt76_check_sband()
422 if (phy->hw->wiphy->bands[band] == sband) in mt76_check_sband()
423 phy->hw->wiphy->bands[band] = NULL; in mt76_check_sband()
429 struct mt76_dev *dev = phy->dev; in mt76_phy_init()
430 struct wiphy *wiphy = hw->wiphy; in mt76_phy_init()
432 INIT_LIST_HEAD(&phy->tx_list); in mt76_phy_init()
433 spin_lock_init(&phy->tx_lock); in mt76_phy_init()
434 INIT_DELAYED_WORK(&phy->roc_work, mt76_roc_complete_work); in mt76_phy_init()
436 if ((void *)phy != hw->priv) in mt76_phy_init()
439 SET_IEEE80211_DEV(hw, dev->dev); in mt76_phy_init()
440 SET_IEEE80211_PERM_ADDR(hw, phy->macaddr); in mt76_phy_init()
442 wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR | in mt76_phy_init()
444 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH | in mt76_phy_init()
452 if (!wiphy->available_antennas_tx) in mt76_phy_init()
453 wiphy->available_antennas_tx = phy->antenna_mask; in mt76_phy_init()
454 if (!wiphy->available_antennas_rx) in mt76_phy_init()
455 wiphy->available_antennas_rx = phy->antenna_mask; in mt76_phy_init()
457 wiphy->sar_capa = &mt76_sar_capa; in mt76_phy_init()
458 phy->frp = devm_kcalloc(dev->dev, wiphy->sar_capa->num_freq_ranges, in mt76_phy_init()
461 if (!phy->frp) in mt76_phy_init()
462 return -ENOMEM; in mt76_phy_init()
464 hw->txq_data_size = sizeof(struct mt76_txq); in mt76_phy_init()
465 hw->uapsd_max_sp_len = IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL; in mt76_phy_init()
467 if (!hw->max_tx_fragments) in mt76_phy_init()
468 hw->max_tx_fragments = 16; in mt76_phy_init()
479 if (!(dev->drv->drv_flags & MT_DRV_AMSDU_OFFLOAD) && in mt76_phy_init()
480 hw->max_tx_fragments > 1) { in mt76_phy_init()
496 struct ieee80211_hw *hw = dev->phy.hw; in mt76_alloc_radio_phy()
501 phy = devm_kzalloc(dev->dev, size + phy_size, GFP_KERNEL); in mt76_alloc_radio_phy()
505 phy->dev = dev; in mt76_alloc_radio_phy()
506 phy->hw = hw; in mt76_alloc_radio_phy()
507 phy->priv = (void *)phy + phy_size; in mt76_alloc_radio_phy()
508 phy->band_idx = band_idx; in mt76_alloc_radio_phy()
527 phy = hw->priv; in mt76_alloc_phy()
528 phy->dev = dev; in mt76_alloc_phy()
529 phy->hw = hw; in mt76_alloc_phy()
530 phy->priv = hw->priv + phy_size; in mt76_alloc_phy()
531 phy->band_idx = band_idx; in mt76_alloc_phy()
533 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in mt76_alloc_phy()
534 hw->wiphy->interface_modes = in mt76_alloc_phy()
549 struct ieee80211_rate *rates, int n_rates) in mt76_register_phy() argument
553 ret = mt76_phy_init(phy, phy->hw); in mt76_register_phy()
557 if (phy->cap.has_2ghz) { in mt76_register_phy()
558 ret = mt76_init_sband_2g(phy, rates, n_rates); in mt76_register_phy()
563 if (phy->cap.has_5ghz) { in mt76_register_phy()
564 ret = mt76_init_sband_5g(phy, rates + 4, n_rates - 4, vht); in mt76_register_phy()
569 if (phy->cap.has_6ghz) { in mt76_register_phy()
570 ret = mt76_init_sband_6g(phy, rates + 4, n_rates - 4); in mt76_register_phy()
581 wiphy_read_of_freq_limits(phy->hw->wiphy); in mt76_register_phy()
582 mt76_check_sband(phy, &phy->sband_2g, NL80211_BAND_2GHZ); in mt76_register_phy()
583 mt76_check_sband(phy, &phy->sband_5g, NL80211_BAND_5GHZ); in mt76_register_phy()
584 mt76_check_sband(phy, &phy->sband_6g, NL80211_BAND_6GHZ); in mt76_register_phy()
586 if ((void *)phy == phy->hw->priv) { in mt76_register_phy()
587 ret = ieee80211_register_hw(phy->hw); in mt76_register_phy()
592 set_bit(MT76_STATE_REGISTERED, &phy->state); in mt76_register_phy()
593 phy->dev->phys[phy->band_idx] = phy; in mt76_register_phy()
601 struct mt76_dev *dev = phy->dev; in mt76_unregister_phy()
603 if (!test_bit(MT76_STATE_REGISTERED, &phy->state)) in mt76_unregister_phy()
609 ieee80211_unregister_hw(phy->hw); in mt76_unregister_phy()
610 dev->phys[phy->band_idx] = NULL; in mt76_unregister_phy()
621 .dev = dev->dma_dev, in mt76_create_page_pool()
623 int idx = is_qrx ? q - dev->q_rx : -1; in mt76_create_page_pool()
647 if (idx >= 0 && idx < ARRAY_SIZE(dev->napi)) in mt76_create_page_pool()
648 pp_params.napi = &dev->napi[idx]; in mt76_create_page_pool()
651 q->page_pool = page_pool_create(&pp_params); in mt76_create_page_pool()
652 if (IS_ERR(q->page_pool)) { in mt76_create_page_pool()
653 int err = PTR_ERR(q->page_pool); in mt76_create_page_pool()
655 q->page_pool = NULL; in mt76_create_page_pool()
677 dev = hw->priv; in mt76_alloc_device()
678 dev->hw = hw; in mt76_alloc_device()
679 dev->dev = pdev; in mt76_alloc_device()
680 dev->drv = drv_ops; in mt76_alloc_device()
681 dev->dma_dev = pdev; in mt76_alloc_device()
683 phy = &dev->phy; in mt76_alloc_device()
684 phy->dev = dev; in mt76_alloc_device()
685 phy->hw = hw; in mt76_alloc_device()
686 phy->band_idx = MT_BAND0; in mt76_alloc_device()
687 dev->phys[phy->band_idx] = phy; in mt76_alloc_device()
689 spin_lock_init(&dev->rx_lock); in mt76_alloc_device()
690 spin_lock_init(&dev->lock); in mt76_alloc_device()
691 spin_lock_init(&dev->cc_lock); in mt76_alloc_device()
692 spin_lock_init(&dev->status_lock); in mt76_alloc_device()
693 spin_lock_init(&dev->wed_lock); in mt76_alloc_device()
694 mutex_init(&dev->mutex); in mt76_alloc_device()
695 init_waitqueue_head(&dev->tx_wait); in mt76_alloc_device()
697 skb_queue_head_init(&dev->mcu.res_q); in mt76_alloc_device()
698 init_waitqueue_head(&dev->mcu.wait); in mt76_alloc_device()
699 mutex_init(&dev->mcu.mutex); in mt76_alloc_device()
700 dev->tx_worker.fn = mt76_tx_worker; in mt76_alloc_device()
702 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in mt76_alloc_device()
703 hw->wiphy->interface_modes = in mt76_alloc_device()
713 spin_lock_init(&dev->token_lock); in mt76_alloc_device()
714 idr_init(&dev->token); in mt76_alloc_device()
716 spin_lock_init(&dev->rx_token_lock); in mt76_alloc_device()
717 idr_init(&dev->rx_token); in mt76_alloc_device()
719 INIT_LIST_HEAD(&dev->wcid_list); in mt76_alloc_device()
720 INIT_LIST_HEAD(&dev->sta_poll_list); in mt76_alloc_device()
721 spin_lock_init(&dev->sta_poll_lock); in mt76_alloc_device()
723 INIT_LIST_HEAD(&dev->txwi_cache); in mt76_alloc_device()
724 INIT_LIST_HEAD(&dev->rxwi_cache); in mt76_alloc_device()
725 dev->token_size = dev->drv->token_size; in mt76_alloc_device()
726 INIT_DELAYED_WORK(&dev->scan_work, mt76_scan_work); in mt76_alloc_device()
728 for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) in mt76_alloc_device()
729 skb_queue_head_init(&dev->rx_skb[i]); in mt76_alloc_device()
731 dev->wq = alloc_ordered_workqueue("mt76", 0); in mt76_alloc_device()
732 if (!dev->wq) { in mt76_alloc_device()
742 struct ieee80211_rate *rates, int n_rates) in mt76_register_device() argument
744 struct ieee80211_hw *hw = dev->hw; in mt76_register_device()
745 struct mt76_phy *phy = &dev->phy; in mt76_register_device()
748 dev_set_drvdata(dev->dev, dev); in mt76_register_device()
749 mt76_wcid_init(&dev->global_wcid, phy->band_idx); in mt76_register_device()
754 if (phy->cap.has_2ghz) { in mt76_register_device()
755 ret = mt76_init_sband_2g(phy, rates, n_rates); in mt76_register_device()
760 if (phy->cap.has_5ghz) { in mt76_register_device()
761 ret = mt76_init_sband_5g(phy, rates + 4, n_rates - 4, vht); in mt76_register_device()
766 if (phy->cap.has_6ghz) { in mt76_register_device()
767 ret = mt76_init_sband_6g(phy, rates + 4, n_rates - 4); in mt76_register_device()
772 wiphy_read_of_freq_limits(hw->wiphy); in mt76_register_device()
773 mt76_check_sband(&dev->phy, &phy->sband_2g, NL80211_BAND_2GHZ); in mt76_register_device()
774 mt76_check_sband(&dev->phy, &phy->sband_5g, NL80211_BAND_5GHZ); in mt76_register_device()
775 mt76_check_sband(&dev->phy, &phy->sband_6g, NL80211_BAND_6GHZ); in mt76_register_device()
787 WARN_ON(mt76_worker_setup(hw, &dev->tx_worker, NULL, "tx")); in mt76_register_device()
788 set_bit(MT76_STATE_REGISTERED, &phy->state); in mt76_register_device()
789 sched_set_fifo_low(dev->tx_worker.task); in mt76_register_device()
797 struct ieee80211_hw *hw = dev->hw; in mt76_unregister_device()
799 if (!test_bit(MT76_STATE_REGISTERED, &dev->phy.state)) in mt76_unregister_device()
803 mt76_led_cleanup(&dev->phy); in mt76_unregister_device()
805 mt76_wcid_cleanup(dev, &dev->global_wcid); in mt76_unregister_device()
812 mt76_worker_teardown(&dev->tx_worker); in mt76_free_device()
813 if (dev->wq) { in mt76_free_device()
814 destroy_workqueue(dev->wq); in mt76_free_device()
815 dev->wq = NULL; in mt76_free_device()
817 ieee80211_free_hw(dev->hw); in mt76_free_device()
826 INIT_LIST_HEAD(&phy->tx_list); in mt76_reset_phy()
827 phy->num_sta = 0; in mt76_reset_phy()
828 phy->chanctx = NULL; in mt76_reset_phy()
837 for (i = 0; i < ARRAY_SIZE(dev->wcid); i++) { in mt76_reset_device()
840 wcid = rcu_dereference(dev->wcid[i]); in mt76_reset_device()
844 wcid->sta = 0; in mt76_reset_device()
846 rcu_assign_pointer(dev->wcid[i], NULL); in mt76_reset_device()
852 INIT_LIST_HEAD(&dev->wcid_list); in mt76_reset_device()
853 INIT_LIST_HEAD(&dev->sta_poll_list); in mt76_reset_device()
854 dev->vif_mask = 0; in mt76_reset_device()
855 memset(dev->wcid_mask, 0, sizeof(dev->wcid_mask)); in mt76_reset_device()
857 mt76_reset_phy(&dev->phy); in mt76_reset_device()
858 for (i = 0; i < ARRAY_SIZE(dev->phys); i++) in mt76_reset_device()
859 mt76_reset_phy(dev->phys[i]); in mt76_reset_device()
866 struct mt76_vif_link *mlink = (struct mt76_vif_link *)vif->drv_priv; in mt76_vif_phy()
869 if (!hw->wiphy->n_radio) in mt76_vif_phy()
870 return hw->priv; in mt76_vif_phy()
872 if (!mlink->ctx) in mt76_vif_phy()
875 ctx = (struct mt76_chanctx *)mlink->ctx->drv_priv; in mt76_vif_phy()
876 return ctx->phy; in mt76_vif_phy()
882 struct sk_buff *skb = phy->rx_amsdu[q].head; in mt76_rx_release_amsdu()
883 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt76_rx_release_amsdu()
884 struct mt76_dev *dev = phy->dev; in mt76_rx_release_amsdu()
886 phy->rx_amsdu[q].head = NULL; in mt76_rx_release_amsdu()
887 phy->rx_amsdu[q].tail = NULL; in mt76_rx_release_amsdu()
891 * A single MSDU can be parsed as A-MSDU when the unauthenticated A-MSDU in mt76_rx_release_amsdu()
896 if (skb_shinfo(skb)->frag_list) { in mt76_rx_release_amsdu()
899 if (!(status->flag & RX_FLAG_8023)) { in mt76_rx_release_amsdu()
902 if ((status->flag & in mt76_rx_release_amsdu()
908 if (ether_addr_equal(skb->data + offset, rfc1042_header)) { in mt76_rx_release_amsdu()
913 __skb_queue_tail(&dev->rx_skb[q], skb); in mt76_rx_release_amsdu()
919 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt76_rx_release_burst()
921 if (phy->rx_amsdu[q].head && in mt76_rx_release_burst()
922 (!status->amsdu || status->first_amsdu || in mt76_rx_release_burst()
923 status->seqno != phy->rx_amsdu[q].seqno)) in mt76_rx_release_burst()
926 if (!phy->rx_amsdu[q].head) { in mt76_rx_release_burst()
927 phy->rx_amsdu[q].tail = &skb_shinfo(skb)->frag_list; in mt76_rx_release_burst()
928 phy->rx_amsdu[q].seqno = status->seqno; in mt76_rx_release_burst()
929 phy->rx_amsdu[q].head = skb; in mt76_rx_release_burst()
931 *phy->rx_amsdu[q].tail = skb; in mt76_rx_release_burst()
932 phy->rx_amsdu[q].tail = &skb->next; in mt76_rx_release_burst()
935 if (!status->amsdu || status->last_amsdu) in mt76_rx_release_burst()
941 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt76_rx()
942 struct mt76_phy *phy = mt76_dev_phy(dev, status->phy_idx); in mt76_rx()
944 if (!test_bit(MT76_STATE_RUNNING, &phy->state)) { in mt76_rx()
950 if (phy->test.state == MT76_TM_STATE_RX_FRAMES) { in mt76_rx()
951 phy->test.rx_stats.packets[q]++; in mt76_rx()
952 if (status->flag & RX_FLAG_FAILED_FCS_CRC) in mt76_rx()
953 phy->test.rx_stats.fcs_error[q]++; in mt76_rx()
967 q = phy->q_tx[i]; in mt76_has_tx_pending()
968 if (q && q->queued) in mt76_has_tx_pending()
982 if (c->band == NL80211_BAND_2GHZ) in mt76_channel_state()
983 msband = &phy->sband_2g; in mt76_channel_state()
984 else if (c->band == NL80211_BAND_6GHZ) in mt76_channel_state()
985 msband = &phy->sband_6g; in mt76_channel_state()
987 msband = &phy->sband_5g; in mt76_channel_state()
989 idx = c - &msband->sband.channels[0]; in mt76_channel_state()
990 return &msband->chan[idx]; in mt76_channel_state()
995 struct mt76_channel_state *state = phy->chan_state; in mt76_update_survey_active_time()
997 state->cc_active += ktime_to_us(ktime_sub(time, in mt76_update_survey_active_time()
998 phy->survey_time)); in mt76_update_survey_active_time()
999 phy->survey_time = time; in mt76_update_survey_active_time()
1005 struct mt76_dev *dev = phy->dev; in mt76_update_survey()
1008 if (dev->drv->update_survey) in mt76_update_survey()
1009 dev->drv->update_survey(phy); in mt76_update_survey()
1014 if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) { in mt76_update_survey()
1015 struct mt76_channel_state *state = phy->chan_state; in mt76_update_survey()
1017 spin_lock_bh(&dev->cc_lock); in mt76_update_survey()
1018 state->cc_bss_rx += dev->cur_cc_bss_rx; in mt76_update_survey()
1019 dev->cur_cc_bss_rx = 0; in mt76_update_survey()
1020 spin_unlock_bh(&dev->cc_lock); in mt76_update_survey()
1028 struct mt76_dev *dev = phy->dev; in __mt76_set_channel()
1032 set_bit(MT76_RESET, &phy->state); in __mt76_set_channel()
1034 mt76_worker_disable(&dev->tx_worker); in __mt76_set_channel()
1035 wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout); in __mt76_set_channel()
1038 if (phy->chandef.chan->center_freq != chandef->chan->center_freq || in __mt76_set_channel()
1039 phy->chandef.width != chandef->width) in __mt76_set_channel()
1040 phy->dfs_state = MT_DFS_STATE_UNKNOWN; in __mt76_set_channel()
1042 phy->chandef = *chandef; in __mt76_set_channel()
1043 phy->chan_state = mt76_channel_state(phy, chandef->chan); in __mt76_set_channel()
1044 phy->offchannel = offchannel; in __mt76_set_channel()
1047 phy->main_chandef = *chandef; in __mt76_set_channel()
1049 if (chandef->chan != phy->main_chandef.chan) in __mt76_set_channel()
1050 memset(phy->chan_state, 0, sizeof(*phy->chan_state)); in __mt76_set_channel()
1052 ret = dev->drv->set_channel(phy); in __mt76_set_channel()
1054 clear_bit(MT76_RESET, &phy->state); in __mt76_set_channel()
1055 mt76_worker_enable(&dev->tx_worker); in __mt76_set_channel()
1056 mt76_worker_schedule(&dev->tx_worker); in __mt76_set_channel()
1064 struct mt76_dev *dev = phy->dev; in mt76_set_channel()
1067 cancel_delayed_work_sync(&phy->mac_work); in mt76_set_channel()
1069 mutex_lock(&dev->mutex); in mt76_set_channel()
1071 mutex_unlock(&dev->mutex); in mt76_set_channel()
1078 struct ieee80211_hw *hw = phy->hw; in mt76_update_channel()
1079 struct cfg80211_chan_def *chandef = &hw->conf.chandef; in mt76_update_channel()
1080 bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL; in mt76_update_channel()
1082 phy->radar_enabled = hw->conf.radar_enabled; in mt76_update_channel()
1091 if (*idx < phy->sband_2g.sband.n_channels) in mt76_get_survey_sband()
1092 return &phy->sband_2g; in mt76_get_survey_sband()
1094 *idx -= phy->sband_2g.sband.n_channels; in mt76_get_survey_sband()
1095 if (*idx < phy->sband_5g.sband.n_channels) in mt76_get_survey_sband()
1096 return &phy->sband_5g; in mt76_get_survey_sband()
1098 *idx -= phy->sband_5g.sband.n_channels; in mt76_get_survey_sband()
1099 if (*idx < phy->sband_6g.sband.n_channels) in mt76_get_survey_sband()
1100 return &phy->sband_6g; in mt76_get_survey_sband()
1102 *idx -= phy->sband_6g.sband.n_channels; in mt76_get_survey_sband()
1109 struct mt76_phy *phy = hw->priv; in mt76_get_survey()
1110 struct mt76_dev *dev = phy->dev; in mt76_get_survey()
1117 mutex_lock(&dev->mutex); in mt76_get_survey()
1119 for (phy_idx = 0; phy_idx < ARRAY_SIZE(dev->phys); phy_idx++) { in mt76_get_survey()
1121 phy = dev->phys[phy_idx]; in mt76_get_survey()
1122 if (!phy || phy->hw != hw) in mt76_get_survey()
1127 if (idx == 0 && phy->dev->drv->update_survey) in mt76_get_survey()
1130 if (sband || !hw->wiphy->n_radio) in mt76_get_survey()
1135 ret = -ENOENT; in mt76_get_survey()
1139 chan = &sband->sband.channels[idx]; in mt76_get_survey()
1143 survey->channel = chan; in mt76_get_survey()
1144 survey->filled = SURVEY_INFO_TIME | SURVEY_INFO_TIME_BUSY; in mt76_get_survey()
1145 survey->filled |= dev->drv->survey_flags; in mt76_get_survey()
1146 if (state->noise) in mt76_get_survey()
1147 survey->filled |= SURVEY_INFO_NOISE_DBM; in mt76_get_survey()
1149 if (chan == phy->main_chandef.chan) { in mt76_get_survey()
1150 survey->filled |= SURVEY_INFO_IN_USE; in mt76_get_survey()
1152 if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) in mt76_get_survey()
1153 survey->filled |= SURVEY_INFO_TIME_BSS_RX; in mt76_get_survey()
1156 survey->time_busy = div_u64(state->cc_busy, 1000); in mt76_get_survey()
1157 survey->time_rx = div_u64(state->cc_rx, 1000); in mt76_get_survey()
1158 survey->time = div_u64(state->cc_active, 1000); in mt76_get_survey()
1159 survey->noise = state->noise; in mt76_get_survey()
1161 spin_lock_bh(&dev->cc_lock); in mt76_get_survey()
1162 survey->time_bss_rx = div_u64(state->cc_bss_rx, 1000); in mt76_get_survey()
1163 survey->time_tx = div_u64(state->cc_tx, 1000); in mt76_get_survey()
1164 spin_unlock_bh(&dev->cc_lock); in mt76_get_survey()
1167 mutex_unlock(&dev->mutex); in mt76_get_survey()
1179 wcid->rx_check_pn = false; in mt76_wcid_key_setup()
1184 if (key->cipher != WLAN_CIPHER_SUITE_CCMP) in mt76_wcid_key_setup()
1187 wcid->rx_check_pn = true; in mt76_wcid_key_setup()
1192 memcpy(wcid->rx_key_pn[i], seq.ccmp.pn, sizeof(seq.ccmp.pn)); in mt76_wcid_key_setup()
1196 ieee80211_get_key_rx_seq(key, -1, &seq); in mt76_wcid_key_setup()
1197 memcpy(wcid->rx_key_pn[i], seq.ccmp.pn, sizeof(seq.ccmp.pn)); in mt76_wcid_key_setup()
1204 int signal = -128; in mt76_rx_signal()
1218 diff = signal - cur; in mt76_rx_signal()
1240 mstat = *((struct mt76_rx_status *)skb->cb); in mt76_rx_convert()
1243 skb->priority = mstat.qos_ctl & IEEE80211_QOS_CTL_TID_MASK; in mt76_rx_convert()
1245 status->flag = mstat.flag; in mt76_rx_convert()
1246 status->freq = mstat.freq; in mt76_rx_convert()
1247 status->enc_flags = mstat.enc_flags; in mt76_rx_convert()
1248 status->encoding = mstat.encoding; in mt76_rx_convert()
1249 status->bw = mstat.bw; in mt76_rx_convert()
1250 if (status->encoding == RX_ENC_EHT) { in mt76_rx_convert()
1251 status->eht.ru = mstat.eht.ru; in mt76_rx_convert()
1252 status->eht.gi = mstat.eht.gi; in mt76_rx_convert()
1254 status->he_ru = mstat.he_ru; in mt76_rx_convert()
1255 status->he_gi = mstat.he_gi; in mt76_rx_convert()
1256 status->he_dcm = mstat.he_dcm; in mt76_rx_convert()
1258 status->rate_idx = mstat.rate_idx; in mt76_rx_convert()
1259 status->nss = mstat.nss; in mt76_rx_convert()
1260 status->band = mstat.band; in mt76_rx_convert()
1261 status->signal = mstat.signal; in mt76_rx_convert()
1262 status->chains = mstat.chains; in mt76_rx_convert()
1263 status->ampdu_reference = mstat.ampdu_ref; in mt76_rx_convert()
1264 status->device_timestamp = mstat.timestamp; in mt76_rx_convert()
1265 status->mactime = mstat.timestamp; in mt76_rx_convert()
1266 status->signal = mt76_rx_signal(mstat.chains, mstat.chain_signal); in mt76_rx_convert()
1267 if (status->signal <= -128) in mt76_rx_convert()
1268 status->flag |= RX_FLAG_NO_SIGNAL_VAL; in mt76_rx_convert()
1270 if (ieee80211_is_beacon(hdr->frame_control) || in mt76_rx_convert()
1271 ieee80211_is_probe_resp(hdr->frame_control)) in mt76_rx_convert()
1272 status->boottime_ns = ktime_get_boottime_ns(); in mt76_rx_convert()
1274 BUILD_BUG_ON(sizeof(mstat) > sizeof(skb->cb)); in mt76_rx_convert()
1275 BUILD_BUG_ON(sizeof(status->chain_signal) != in mt76_rx_convert()
1277 memcpy(status->chain_signal, mstat.chain_signal, in mt76_rx_convert()
1281 status->link_valid = mstat.wcid->link_valid; in mt76_rx_convert()
1282 status->link_id = mstat.wcid->link_id; in mt76_rx_convert()
1292 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt76_check_ccmp_pn()
1293 struct mt76_wcid *wcid = status->wcid; in mt76_check_ccmp_pn()
1298 if (!(status->flag & RX_FLAG_DECRYPTED)) in mt76_check_ccmp_pn()
1301 if (status->flag & RX_FLAG_ONLY_MONITOR) in mt76_check_ccmp_pn()
1304 if (!wcid || !wcid->rx_check_pn) in mt76_check_ccmp_pn()
1307 security_idx = status->qos_ctl & IEEE80211_QOS_CTL_TID_MASK; in mt76_check_ccmp_pn()
1308 if (status->flag & RX_FLAG_8023) in mt76_check_ccmp_pn()
1312 if (!(status->flag & RX_FLAG_IV_STRIPPED)) { in mt76_check_ccmp_pn()
1318 !ieee80211_is_first_frag(hdr->frame_control)) in mt76_check_ccmp_pn()
1322 /* IEEE 802.11-2020, 12.5.3.4.4 "PN and replay detection" c): in mt76_check_ccmp_pn()
1328 if (ieee80211_is_mgmt(hdr->frame_control) && in mt76_check_ccmp_pn()
1329 !ieee80211_has_tods(hdr->frame_control)) in mt76_check_ccmp_pn()
1333 BUILD_BUG_ON(sizeof(status->iv) != sizeof(wcid->rx_key_pn[0])); in mt76_check_ccmp_pn()
1334 ret = memcmp(status->iv, wcid->rx_key_pn[security_idx], in mt76_check_ccmp_pn()
1335 sizeof(status->iv)); in mt76_check_ccmp_pn()
1337 status->flag |= RX_FLAG_ONLY_MONITOR; in mt76_check_ccmp_pn()
1341 memcpy(wcid->rx_key_pn[security_idx], status->iv, sizeof(status->iv)); in mt76_check_ccmp_pn()
1343 if (status->flag & RX_FLAG_IV_STRIPPED) in mt76_check_ccmp_pn()
1344 status->flag |= RX_FLAG_PN_VALIDATED; in mt76_check_ccmp_pn()
1351 struct mt76_wcid *wcid = status->wcid; in mt76_airtime_report()
1353 .enc_flags = status->enc_flags, in mt76_airtime_report()
1354 .rate_idx = status->rate_idx, in mt76_airtime_report()
1355 .encoding = status->encoding, in mt76_airtime_report()
1356 .band = status->band, in mt76_airtime_report()
1357 .nss = status->nss, in mt76_airtime_report()
1358 .bw = status->bw, in mt76_airtime_report()
1362 u8 tidno = status->qos_ctl & IEEE80211_QOS_CTL_TID_MASK; in mt76_airtime_report()
1364 airtime = ieee80211_calc_rx_airtime(dev->hw, &info, len); in mt76_airtime_report()
1365 spin_lock(&dev->cc_lock); in mt76_airtime_report()
1366 dev->cur_cc_bss_rx += airtime; in mt76_airtime_report()
1367 spin_unlock(&dev->cc_lock); in mt76_airtime_report()
1369 if (!wcid || !wcid->sta) in mt76_airtime_report()
1382 if (!dev->rx_ampdu_len) in mt76_airtime_flush_ampdu()
1385 wcid_idx = dev->rx_ampdu_status.wcid_idx; in mt76_airtime_flush_ampdu()
1386 if (wcid_idx < ARRAY_SIZE(dev->wcid)) in mt76_airtime_flush_ampdu()
1387 wcid = rcu_dereference(dev->wcid[wcid_idx]); in mt76_airtime_flush_ampdu()
1390 dev->rx_ampdu_status.wcid = wcid; in mt76_airtime_flush_ampdu()
1392 mt76_airtime_report(dev, &dev->rx_ampdu_status, dev->rx_ampdu_len); in mt76_airtime_flush_ampdu()
1394 dev->rx_ampdu_len = 0; in mt76_airtime_flush_ampdu()
1395 dev->rx_ampdu_ref = 0; in mt76_airtime_flush_ampdu()
1401 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt76_airtime_check()
1402 struct mt76_wcid *wcid = status->wcid; in mt76_airtime_check()
1404 if (!(dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME)) in mt76_airtime_check()
1407 if (!wcid || !wcid->sta) { in mt76_airtime_check()
1410 if (status->flag & RX_FLAG_8023) in mt76_airtime_check()
1413 if (!ether_addr_equal(hdr->addr1, dev->phy.macaddr)) in mt76_airtime_check()
1419 if (!(status->flag & RX_FLAG_AMPDU_DETAILS) || in mt76_airtime_check()
1420 status->ampdu_ref != dev->rx_ampdu_ref) in mt76_airtime_check()
1423 if (status->flag & RX_FLAG_AMPDU_DETAILS) { in mt76_airtime_check()
1424 if (!dev->rx_ampdu_len || in mt76_airtime_check()
1425 status->ampdu_ref != dev->rx_ampdu_ref) { in mt76_airtime_check()
1426 dev->rx_ampdu_status = *status; in mt76_airtime_check()
1427 dev->rx_ampdu_status.wcid_idx = wcid ? wcid->idx : 0xff; in mt76_airtime_check()
1428 dev->rx_ampdu_ref = status->ampdu_ref; in mt76_airtime_check()
1431 dev->rx_ampdu_len += skb->len; in mt76_airtime_check()
1435 mt76_airtime_report(dev, status, skb->len); in mt76_airtime_check()
1441 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt76_check_sta()
1445 struct mt76_wcid *wcid = status->wcid; in mt76_check_sta()
1446 u8 tidno = status->qos_ctl & IEEE80211_QOS_CTL_TID_MASK; in mt76_check_sta()
1449 hw = mt76_phy_hw(dev, status->phy_idx); in mt76_check_sta()
1450 if (ieee80211_is_pspoll(hdr->frame_control) && !wcid && in mt76_check_sta()
1451 !(status->flag & RX_FLAG_8023)) { in mt76_check_sta()
1452 sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr2, NULL); in mt76_check_sta()
1454 wcid = status->wcid = (struct mt76_wcid *)sta->drv_priv; in mt76_check_sta()
1459 if (!wcid || !wcid->sta) in mt76_check_sta()
1464 if (status->signal <= 0) in mt76_check_sta()
1465 ewma_signal_add(&wcid->rssi, -status->signal); in mt76_check_sta()
1467 wcid->inactive_count = 0; in mt76_check_sta()
1469 if (status->flag & RX_FLAG_8023) in mt76_check_sta()
1472 if (!test_bit(MT_WCID_FLAG_CHECK_PS, &wcid->flags)) in mt76_check_sta()
1475 if (ieee80211_is_pspoll(hdr->frame_control)) { in mt76_check_sta()
1480 if (ieee80211_has_morefrags(hdr->frame_control) || in mt76_check_sta()
1481 !(ieee80211_is_mgmt(hdr->frame_control) || in mt76_check_sta()
1482 ieee80211_is_data(hdr->frame_control))) in mt76_check_sta()
1485 ps = ieee80211_has_pm(hdr->frame_control); in mt76_check_sta()
1487 if (ps && (ieee80211_is_data_qos(hdr->frame_control) || in mt76_check_sta()
1488 ieee80211_is_qos_nullfunc(hdr->frame_control))) in mt76_check_sta()
1491 if (!!test_bit(MT_WCID_FLAG_PS, &wcid->flags) == ps) in mt76_check_sta()
1495 set_bit(MT_WCID_FLAG_PS, &wcid->flags); in mt76_check_sta()
1497 if (dev->drv->sta_ps) in mt76_check_sta()
1498 dev->drv->sta_ps(dev, sta, ps); in mt76_check_sta()
1501 clear_bit(MT_WCID_FLAG_PS, &wcid->flags); in mt76_check_sta()
1514 spin_lock(&dev->rx_lock); in mt76_rx_complete()
1516 struct sk_buff *nskb = skb_shinfo(skb)->frag_list; in mt76_rx_complete()
1519 skb_shinfo(skb)->frag_list = NULL; in mt76_rx_complete()
1526 nskb = nskb->next; in mt76_rx_complete()
1527 skb->next = NULL; in mt76_rx_complete()
1533 spin_unlock(&dev->rx_lock); in mt76_rx_complete()
1554 while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL) { in mt76_rx_poll_complete()
1556 if (mtk_wed_device_active(&dev->mmio.wed)) in mt76_rx_poll_complete()
1570 struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; in mt76_sta_add()
1571 struct mt76_dev *dev = phy->dev; in mt76_sta_add()
1575 mutex_lock(&dev->mutex); in mt76_sta_add()
1577 ret = dev->drv->sta_add(dev, vif, sta); in mt76_sta_add()
1581 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) { in mt76_sta_add()
1584 if (!sta->txq[i]) in mt76_sta_add()
1587 mtxq = (struct mt76_txq *)sta->txq[i]->drv_priv; in mt76_sta_add()
1588 mtxq->wcid = wcid->idx; in mt76_sta_add()
1591 ewma_signal_init(&wcid->rssi); in mt76_sta_add()
1592 rcu_assign_pointer(dev->wcid[wcid->idx], wcid); in mt76_sta_add()
1593 phy->num_sta++; in mt76_sta_add()
1595 mt76_wcid_init(wcid, phy->band_idx); in mt76_sta_add()
1597 mutex_unlock(&dev->mutex); in mt76_sta_add()
1605 struct mt76_dev *dev = phy->dev; in __mt76_sta_remove()
1606 struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; in __mt76_sta_remove()
1607 int i, idx = wcid->idx; in __mt76_sta_remove()
1609 for (i = 0; i < ARRAY_SIZE(wcid->aggr); i++) in __mt76_sta_remove()
1612 if (dev->drv->sta_remove) in __mt76_sta_remove()
1613 dev->drv->sta_remove(dev, vif, sta); in __mt76_sta_remove()
1617 mt76_wcid_mask_clear(dev->wcid_mask, idx); in __mt76_sta_remove()
1618 phy->num_sta--; in __mt76_sta_remove()
1626 struct mt76_dev *dev = phy->dev; in mt76_sta_remove()
1628 mutex_lock(&dev->mutex); in mt76_sta_remove()
1630 mutex_unlock(&dev->mutex); in mt76_sta_remove()
1638 struct mt76_phy *phy = hw->priv; in mt76_sta_state()
1639 struct mt76_dev *dev = phy->dev; in mt76_sta_state()
1644 return -EINVAL; in mt76_sta_state()
1654 if (!dev->drv->sta_event) in mt76_sta_state()
1669 return dev->drv->sta_event(dev, vif, sta, ev); in mt76_sta_state()
1676 struct mt76_phy *phy = hw->priv; in mt76_sta_pre_rcu_remove()
1677 struct mt76_dev *dev = phy->dev; in mt76_sta_pre_rcu_remove()
1678 struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; in mt76_sta_pre_rcu_remove()
1680 mutex_lock(&dev->mutex); in mt76_sta_pre_rcu_remove()
1681 spin_lock_bh(&dev->status_lock); in mt76_sta_pre_rcu_remove()
1682 rcu_assign_pointer(dev->wcid[wcid->idx], NULL); in mt76_sta_pre_rcu_remove()
1683 spin_unlock_bh(&dev->status_lock); in mt76_sta_pre_rcu_remove()
1684 mutex_unlock(&dev->mutex); in mt76_sta_pre_rcu_remove()
1690 wcid->hw_key_idx = -1; in mt76_wcid_init()
1691 wcid->phy_idx = band_idx; in mt76_wcid_init()
1693 INIT_LIST_HEAD(&wcid->tx_list); in mt76_wcid_init()
1694 skb_queue_head_init(&wcid->tx_pending); in mt76_wcid_init()
1695 skb_queue_head_init(&wcid->tx_offchannel); in mt76_wcid_init()
1697 INIT_LIST_HEAD(&wcid->list); in mt76_wcid_init()
1698 idr_init(&wcid->pktid); in mt76_wcid_init()
1700 INIT_LIST_HEAD(&wcid->poll_list); in mt76_wcid_init()
1706 struct mt76_phy *phy = mt76_dev_phy(dev, wcid->phy_idx); in mt76_wcid_cleanup()
1712 mt76_tx_status_skb_get(dev, wcid, -1, &list); in mt76_wcid_cleanup()
1715 idr_destroy(&wcid->pktid); in mt76_wcid_cleanup()
1717 spin_lock_bh(&phy->tx_lock); in mt76_wcid_cleanup()
1719 if (!list_empty(&wcid->tx_list)) in mt76_wcid_cleanup()
1720 list_del_init(&wcid->tx_list); in mt76_wcid_cleanup()
1722 spin_lock(&wcid->tx_pending.lock); in mt76_wcid_cleanup()
1723 skb_queue_splice_tail_init(&wcid->tx_pending, &list); in mt76_wcid_cleanup()
1724 spin_unlock(&wcid->tx_pending.lock); in mt76_wcid_cleanup()
1726 spin_lock(&wcid->tx_offchannel.lock); in mt76_wcid_cleanup()
1727 skb_queue_splice_tail_init(&wcid->tx_offchannel, &list); in mt76_wcid_cleanup()
1728 spin_unlock(&wcid->tx_offchannel.lock); in mt76_wcid_cleanup()
1730 spin_unlock_bh(&phy->tx_lock); in mt76_wcid_cleanup()
1741 if (test_bit(MT76_MCU_RESET, &dev->phy.state) || !wcid->sta) in mt76_wcid_add_poll()
1744 spin_lock_bh(&dev->sta_poll_lock); in mt76_wcid_add_poll()
1745 if (list_empty(&wcid->poll_list)) in mt76_wcid_add_poll()
1746 list_add_tail(&wcid->poll_list, &dev->sta_poll_list); in mt76_wcid_add_poll()
1747 spin_unlock_bh(&dev->sta_poll_lock); in mt76_wcid_add_poll()
1753 int n_chains = hweight16(phy->chainmask); in mt76_get_power_bound()
1755 txpower = mt76_get_sar_power(phy, phy->chandef.chan, txpower * 2); in mt76_get_power_bound()
1756 txpower -= mt76_tx_power_path_delta(n_chains); in mt76_get_power_bound()
1769 return -EINVAL; in mt76_get_txpower()
1771 n_chains = hweight16(phy->chainmask); in mt76_get_txpower()
1773 *dbm = DIV_ROUND_UP(phy->txpower_cur + delta, 2); in mt76_get_txpower()
1782 struct mt76_phy *phy = hw->priv; in mt76_init_sar_power()
1783 const struct cfg80211_sar_capa *capa = hw->wiphy->sar_capa; in mt76_init_sar_power()
1786 if (sar->type != NL80211_SAR_TYPE_POWER || !sar->num_sub_specs) in mt76_init_sar_power()
1787 return -EINVAL; in mt76_init_sar_power()
1789 for (i = 0; i < sar->num_sub_specs; i++) { in mt76_init_sar_power()
1790 u32 index = sar->sub_specs[i].freq_range_index; in mt76_init_sar_power()
1792 s32 power = sar->sub_specs[i].power >> 1; in mt76_init_sar_power()
1794 if (power > 127 || power < -127) in mt76_init_sar_power()
1797 phy->frp[index].range = &capa->freq_ranges[index]; in mt76_init_sar_power()
1798 phy->frp[index].power = power; in mt76_init_sar_power()
1809 const struct cfg80211_sar_capa *capa = phy->hw->wiphy->sar_capa; in mt76_get_sar_power()
1812 if (!capa || !phy->frp) in mt76_get_sar_power()
1815 if (power > 127 || power < -127) in mt76_get_sar_power()
1818 freq = ieee80211_channel_to_frequency(chan->hw_value, chan->band); in mt76_get_sar_power()
1819 for (i = 0 ; i < capa->num_freq_ranges; i++) { in mt76_get_sar_power()
1820 if (phy->frp[i].range && in mt76_get_sar_power()
1821 freq >= phy->frp[i].range->start_freq && in mt76_get_sar_power()
1822 freq < phy->frp[i].range->end_freq) { in mt76_get_sar_power()
1823 power = min_t(int, phy->frp[i].power, power); in mt76_get_sar_power()
1835 if (vif->bss_conf.csa_active && ieee80211_beacon_cntdwn_is_complete(vif, 0)) in __mt76_csa_finish()
1841 if (!dev->csa_complete) in mt76_csa_finish()
1844 ieee80211_iterate_active_interfaces_atomic(dev->hw, in mt76_csa_finish()
1848 dev->csa_complete = 0; in mt76_csa_finish()
1857 if (!vif->bss_conf.csa_active) in __mt76_csa_check()
1860 dev->csa_complete |= ieee80211_beacon_cntdwn_is_complete(vif, 0); in __mt76_csa_check()
1865 ieee80211_iterate_active_interfaces_atomic(dev->hw, in mt76_csa_check()
1880 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt76_insert_ccmp_hdr()
1882 u8 *hdr, *pn = status->iv; in mt76_insert_ccmp_hdr()
1885 memmove(skb->data, skb->data + 8, hdr_len); in mt76_insert_ccmp_hdr()
1886 hdr = skb->data + hdr_len; in mt76_insert_ccmp_hdr()
1897 status->flag &= ~RX_FLAG_IV_STRIPPED; in mt76_insert_ccmp_hdr()
1905 bool is_2g = sband->band == NL80211_BAND_2GHZ; in mt76_get_rate()
1906 int i, offset = 0, len = sband->n_bitrates; in mt76_get_rate()
1918 if ((sband->bitrates[i].hw_value & GENMASK(7, 0)) == idx) in mt76_get_rate()
1929 struct mt76_phy *phy = hw->priv; in mt76_sw_scan()
1931 set_bit(MT76_SCANNING, &phy->state); in mt76_sw_scan()
1937 struct mt76_phy *phy = hw->priv; in mt76_sw_scan_complete()
1939 clear_bit(MT76_SCANNING, &phy->state); in mt76_sw_scan_complete()
1946 struct mt76_phy *phy = hw->priv; in mt76_get_antenna()
1947 struct mt76_dev *dev = phy->dev; in mt76_get_antenna()
1950 mutex_lock(&dev->mutex); in mt76_get_antenna()
1952 for (i = 0; i < ARRAY_SIZE(dev->phys); i++) in mt76_get_antenna()
1953 if (dev->phys[i] && dev->phys[i]->hw == hw) in mt76_get_antenna()
1954 *tx_ant |= dev->phys[i]->chainmask; in mt76_get_antenna()
1956 mutex_unlock(&dev->mutex); in mt76_get_antenna()
1969 hwq = devm_kzalloc(dev->dev, sizeof(*hwq), GFP_KERNEL); in mt76_init_queue()
1971 return ERR_PTR(-ENOMEM); in mt76_init_queue()
1973 hwq->flags = flags; in mt76_init_queue()
1974 hwq->wed = wed; in mt76_init_queue()
1976 err = dev->queue_ops->alloc(dev, hwq, idx, n_desc, 0, ring_base); in mt76_init_queue()
1987 int i, ei = wi->initial_stat_idx; in mt76_ethtool_worker()
1988 u64 *data = wi->data; in mt76_ethtool_worker()
1990 wi->sta_count++; in mt76_ethtool_worker()
1992 data[ei++] += stats->tx_mode[MT_PHY_TYPE_CCK]; in mt76_ethtool_worker()
1993 data[ei++] += stats->tx_mode[MT_PHY_TYPE_OFDM]; in mt76_ethtool_worker()
1994 data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT]; in mt76_ethtool_worker()
1995 data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT_GF]; in mt76_ethtool_worker()
1996 data[ei++] += stats->tx_mode[MT_PHY_TYPE_VHT]; in mt76_ethtool_worker()
1997 data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_SU]; in mt76_ethtool_worker()
1998 data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_EXT_SU]; in mt76_ethtool_worker()
1999 data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_TB]; in mt76_ethtool_worker()
2000 data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_MU]; in mt76_ethtool_worker()
2002 data[ei++] += stats->tx_mode[MT_PHY_TYPE_EHT_SU]; in mt76_ethtool_worker()
2003 data[ei++] += stats->tx_mode[MT_PHY_TYPE_EHT_TRIG]; in mt76_ethtool_worker()
2004 data[ei++] += stats->tx_mode[MT_PHY_TYPE_EHT_MU]; in mt76_ethtool_worker()
2007 for (i = 0; i < (ARRAY_SIZE(stats->tx_bw) - !eht); i++) in mt76_ethtool_worker()
2008 data[ei++] += stats->tx_bw[i]; in mt76_ethtool_worker()
2011 data[ei++] += stats->tx_mcs[i]; in mt76_ethtool_worker()
2014 data[ei++] += stats->tx_nss[i]; in mt76_ethtool_worker()
2016 wi->worker_stat_count = ei - wi->initial_stat_idx; in mt76_ethtool_worker()
2027 page_pool_get_stats(dev->q_rx[i].page_pool, &stats); in mt76_ethtool_page_pool_stats()
2037 struct ieee80211_hw *hw = phy->hw; in mt76_phy_dfs_state()
2038 struct mt76_dev *dev = phy->dev; in mt76_phy_dfs_state()
2040 if (dev->region == NL80211_DFS_UNSET || in mt76_phy_dfs_state()
2041 test_bit(MT76_SCANNING, &phy->state)) in mt76_phy_dfs_state()
2044 if (!phy->radar_enabled) { in mt76_phy_dfs_state()
2045 if ((hw->conf.flags & IEEE80211_CONF_MONITOR) && in mt76_phy_dfs_state()
2046 (phy->chandef.chan->flags & IEEE80211_CHAN_RADAR)) in mt76_phy_dfs_state()
2052 if (!cfg80211_reg_can_beacon(hw->wiphy, &phy->chandef, NL80211_IFTYPE_AP)) in mt76_phy_dfs_state()
2061 struct mt76_vif_link *mlink = (struct mt76_vif_link *)vif->drv_priv; in mt76_vif_cleanup()
2062 struct mt76_vif_data *mvif = mlink->mvif; in mt76_vif_cleanup()
2064 rcu_assign_pointer(mvif->link[0], NULL); in mt76_vif_cleanup()
2066 if (mvif->roc_phy) in mt76_vif_cleanup()
2067 mt76_abort_roc(mvif->roc_phy); in mt76_vif_cleanup()
2085 if (vif->active_links == usable_links) in mt76_select_links()
2086 return vif->active_links; in mt76_select_links()
2092 link_conf = rcu_dereference(vif->link_conf[link_id]); in mt76_select_links()
2097 data[n_data].band = link_conf->chanreq.oper.chan->band; in mt76_select_links()
2105 if (!(BIT(data[i].link_id) & vif->active_links)) in mt76_select_links()