Lines Matching +full:rates +full:- +full:cck

1 // SPDX-License-Identifier: ISC
20 #define to_rssi(field, rxv) ((FIELD_GET(field, rxv) - 220) / 2)
23 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
37 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
48 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
96 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7615_rx_get_wcid()
100 if (!wcid->sta) in mt7615_rx_get_wcid()
104 if (!sta->vif) in mt7615_rx_get_wcid()
107 return &sta->vif->sta.wcid; in mt7615_rx_get_wcid()
112 struct mt76_phy *mphy_ext = dev->mt76.phys[MT_BAND1]; in mt7615_mac_reset_counters()
120 memset(dev->mt76.aggr_stats, 0, sizeof(dev->mt76.aggr_stats)); in mt7615_mac_reset_counters()
121 dev->mt76.phy.survey_time = ktime_get_boottime(); in mt7615_mac_reset_counters()
123 mphy_ext->survey_time = ktime_get_boottime(); in mt7615_mac_reset_counters()
141 s16 coverage_class = phy->coverage_class; in mt7615_mac_set_timing()
142 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_timing()
143 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_timing()
145 u32 cck = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 231) | in mt7615_mac_set_timing() local
150 bool is_5ghz = phy->mt76->chandef.chan->band == NL80211_BAND_5GHZ; in mt7615_mac_set_timing()
152 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) in mt7615_mac_set_timing()
161 coverage_class = max_t(s16, dev->phy.coverage_class, in mt7615_mac_set_timing()
169 coverage_class = max_t(s16, phy_ext->coverage_class, in mt7615_mac_set_timing()
179 mt76_wr(dev, MT_TMAC_CDTR, cck + reg_offset); in mt7615_mac_set_timing()
186 FIELD_PREP(MT_IFS_SLOT, phy->slottime)); in mt7615_mac_set_timing()
188 if (phy->slottime < 20 || is_5ghz) in mt7615_mac_set_timing()
207 if (!test_bit(MT76_HW_SCANNING, &mphy->state) && in mt7615_get_status_freq_info()
208 !test_bit(MT76_HW_SCHED_SCANNING, &mphy->state) && in mt7615_get_status_freq_info()
209 !test_bit(MT76_STATE_ROC, &mphy->state)) { in mt7615_get_status_freq_info()
210 status->freq = mphy->chandef.chan->center_freq; in mt7615_get_status_freq_info()
211 status->band = mphy->chandef.chan->band; in mt7615_get_status_freq_info()
215 status->band = chfreq <= 14 ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ; in mt7615_get_status_freq_info()
216 status->freq = ieee80211_channel_to_frequency(chfreq, status->band); in mt7615_get_status_freq_info()
232 /* CCK */ in mt7615_mac_fill_tm_rx()
238 foe -= 4096; in mt7615_mac_fill_tm_rx()
243 phy->test.last_freq_offset = foe; in mt7615_mac_fill_tm_rx()
244 phy->test.last_rcpi[0] = FIELD_GET(MT_RXV4_RCPI0, rxv4); in mt7615_mac_fill_tm_rx()
245 phy->test.last_rcpi[1] = FIELD_GET(MT_RXV4_RCPI1, rxv4); in mt7615_mac_fill_tm_rx()
246 phy->test.last_rcpi[2] = FIELD_GET(MT_RXV4_RCPI2, rxv4); in mt7615_mac_fill_tm_rx()
247 phy->test.last_rcpi[3] = FIELD_GET(MT_RXV4_RCPI3, rxv4); in mt7615_mac_fill_tm_rx()
248 phy->test.last_ib_rssi[0] = FIELD_GET(MT_RXV3_IB_RSSI, rxv3); in mt7615_mac_fill_tm_rx()
249 phy->test.last_wb_rssi[0] = FIELD_GET(MT_RXV3_WB_RSSI, rxv3); in mt7615_mac_fill_tm_rx()
256 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7615_reverse_frag0_hdr_trans()
257 struct ethhdr *eth_hdr = (struct ethhdr *)(skb->data + hdr_gap); in mt7615_reverse_frag0_hdr_trans()
258 struct mt7615_sta *msta = (struct mt7615_sta *)status->wcid; in mt7615_reverse_frag0_hdr_trans()
259 __le32 *rxd = (__le32 *)skb->data; in mt7615_reverse_frag0_hdr_trans()
267 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
270 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
272 if (!msta || !msta->vif) in mt7615_reverse_frag0_hdr_trans()
273 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
276 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); in mt7615_reverse_frag0_hdr_trans()
284 ether_addr_copy(hdr.addr1, vif->addr); in mt7615_reverse_frag0_hdr_trans()
285 ether_addr_copy(hdr.addr2, sta->addr); in mt7615_reverse_frag0_hdr_trans()
289 ether_addr_copy(hdr.addr3, vif->bss_conf.bssid); in mt7615_reverse_frag0_hdr_trans()
292 ether_addr_copy(hdr.addr3, eth_hdr->h_source); in mt7615_reverse_frag0_hdr_trans()
295 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7615_reverse_frag0_hdr_trans()
298 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7615_reverse_frag0_hdr_trans()
299 ether_addr_copy(hdr.addr4, eth_hdr->h_source); in mt7615_reverse_frag0_hdr_trans()
305 skb_pull(skb, hdr_gap + sizeof(struct ethhdr) - 2); in mt7615_reverse_frag0_hdr_trans()
306 if (eth_hdr->h_proto == cpu_to_be16(ETH_P_AARP) || in mt7615_reverse_frag0_hdr_trans()
307 eth_hdr->h_proto == cpu_to_be16(ETH_P_IPX)) in mt7615_reverse_frag0_hdr_trans()
309 else if (be16_to_cpu(eth_hdr->h_proto) >= ETH_P_802_3_MIN) in mt7615_reverse_frag0_hdr_trans()
329 memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6); in mt7615_reverse_frag0_hdr_trans()
331 status->flag &= ~(RX_FLAG_RADIOTAP_HE | RX_FLAG_RADIOTAP_HE_MU); in mt7615_reverse_frag0_hdr_trans()
337 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7615_mac_fill_rx()
338 struct mt76_phy *mphy = &dev->mt76.phy; in mt7615_mac_fill_rx()
339 struct mt7615_phy *phy = &dev->phy; in mt7615_mac_fill_rx()
343 __le32 *rxd = (__le32 *)skb->data; in mt7615_mac_fill_rx()
348 u32 csum_status = *(u32 *)skb->cb; in mt7615_mac_fill_rx()
361 phy2 = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL; in mt7615_mac_fill_rx()
364 else if (phy2->chfreq == phy->chfreq) in mt7615_mac_fill_rx()
365 phy_idx = -1; in mt7615_mac_fill_rx()
366 else if (phy->chfreq == chfreq) in mt7615_mac_fill_rx()
368 else if (phy2->chfreq == chfreq) in mt7615_mac_fill_rx()
371 phy_idx = -1; in mt7615_mac_fill_rx()
374 return -EINVAL; in mt7615_mac_fill_rx()
378 return -EINVAL; in mt7615_mac_fill_rx()
382 status->flag |= RX_FLAG_ONLY_MONITOR; in mt7615_mac_fill_rx()
386 status->wcid = mt7615_rx_get_wcid(dev, idx, unicast); in mt7615_mac_fill_rx()
388 if (status->wcid) { in mt7615_mac_fill_rx()
391 msta = container_of(status->wcid, struct mt7615_sta, wcid); in mt7615_mac_fill_rx()
392 spin_lock_bh(&dev->sta_poll_lock); in mt7615_mac_fill_rx()
393 if (list_empty(&msta->poll_list)) in mt7615_mac_fill_rx()
394 list_add_tail(&msta->poll_list, &dev->sta_poll_list); in mt7615_mac_fill_rx()
395 spin_unlock_bh(&dev->sta_poll_lock); in mt7615_mac_fill_rx()
398 if (mt76_is_mmio(&dev->mt76) && (rxd0 & csum_mask) == csum_mask && in mt7615_mac_fill_rx()
400 skb->ip_summed = CHECKSUM_UNNECESSARY; in mt7615_mac_fill_rx()
403 status->flag |= RX_FLAG_FAILED_FCS_CRC; in mt7615_mac_fill_rx()
406 status->flag |= RX_FLAG_MMIC_ERROR; in mt7615_mac_fill_rx()
410 status->flag |= RX_FLAG_DECRYPTED; in mt7615_mac_fill_rx()
411 status->flag |= RX_FLAG_IV_STRIPPED; in mt7615_mac_fill_rx()
412 status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; in mt7615_mac_fill_rx()
418 return -EINVAL; in mt7615_mac_fill_rx()
430 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
431 return -EINVAL; in mt7615_mac_fill_rx()
437 if (status->flag & RX_FLAG_DECRYPTED) { in mt7615_mac_fill_rx()
449 status->iv[0] = data[5]; in mt7615_mac_fill_rx()
450 status->iv[1] = data[4]; in mt7615_mac_fill_rx()
451 status->iv[2] = data[3]; in mt7615_mac_fill_rx()
452 status->iv[3] = data[2]; in mt7615_mac_fill_rx()
453 status->iv[4] = data[1]; in mt7615_mac_fill_rx()
454 status->iv[5] = data[0]; in mt7615_mac_fill_rx()
461 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
462 return -EINVAL; in mt7615_mac_fill_rx()
466 status->timestamp = le32_to_cpu(rxd[0]); in mt7615_mac_fill_rx()
467 status->flag |= RX_FLAG_MACTIME_START; in mt7615_mac_fill_rx()
471 status->flag |= RX_FLAG_AMPDU_DETAILS; in mt7615_mac_fill_rx()
473 /* all subframes of an A-MPDU have the same timestamp */ in mt7615_mac_fill_rx()
474 if (phy->rx_ampdu_ts != status->timestamp) { in mt7615_mac_fill_rx()
475 if (!++phy->ampdu_ref) in mt7615_mac_fill_rx()
476 phy->ampdu_ref++; in mt7615_mac_fill_rx()
478 phy->rx_ampdu_ts = status->timestamp; in mt7615_mac_fill_rx()
480 status->ampdu_ref = phy->ampdu_ref; in mt7615_mac_fill_rx()
484 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
485 return -EINVAL; in mt7615_mac_fill_rx()
499 int first_chain = ffs(phy2->mt76->chainmask) - 1; in mt7615_mac_fill_rx()
506 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_fill_rx()
508 status->phy_idx = phy_idx; in mt7615_mac_fill_rx()
511 if (!mt7615_firmware_offload(dev) && chfreq != phy->chfreq) in mt7615_mac_fill_rx()
512 return -EINVAL; in mt7615_mac_fill_rx()
515 if (status->band == NL80211_BAND_5GHZ) in mt7615_mac_fill_rx()
516 sband = &mphy->sband_5g.sband; in mt7615_mac_fill_rx()
518 sband = &mphy->sband_2g.sband; in mt7615_mac_fill_rx()
520 if (!test_bit(MT76_STATE_RUNNING, &mphy->state)) in mt7615_mac_fill_rx()
521 return -EINVAL; in mt7615_mac_fill_rx()
523 if (!sband->channels) in mt7615_mac_fill_rx()
524 return -EINVAL; in mt7615_mac_fill_rx()
531 bool cck = false; in mt7615_mac_fill_rx() local
536 cck = true; in mt7615_mac_fill_rx()
539 i = mt76_get_rate(&dev->mt76, sband, i, cck); in mt7615_mac_fill_rx()
543 status->encoding = RX_ENC_HT; in mt7615_mac_fill_rx()
545 return -EINVAL; in mt7615_mac_fill_rx()
548 status->nss = FIELD_GET(MT_RXV2_NSTS, rxdg1) + 1; in mt7615_mac_fill_rx()
549 status->encoding = RX_ENC_VHT; in mt7615_mac_fill_rx()
552 return -EINVAL; in mt7615_mac_fill_rx()
554 status->rate_idx = i; in mt7615_mac_fill_rx()
560 status->bw = RATE_INFO_BW_40; in mt7615_mac_fill_rx()
563 status->bw = RATE_INFO_BW_80; in mt7615_mac_fill_rx()
566 status->bw = RATE_INFO_BW_160; in mt7615_mac_fill_rx()
569 return -EINVAL; in mt7615_mac_fill_rx()
573 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7615_mac_fill_rx()
575 status->enc_flags |= RX_ENC_FLAG_LDPC; in mt7615_mac_fill_rx()
577 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; in mt7615_mac_fill_rx()
579 status->chains = mphy->antenna_mask; in mt7615_mac_fill_rx()
580 status->chain_signal[0] = to_rssi(MT_RXV4_RCPI0, rxdg3); in mt7615_mac_fill_rx()
581 status->chain_signal[1] = to_rssi(MT_RXV4_RCPI1, rxdg3); in mt7615_mac_fill_rx()
582 status->chain_signal[2] = to_rssi(MT_RXV4_RCPI2, rxdg3); in mt7615_mac_fill_rx()
583 status->chain_signal[3] = to_rssi(MT_RXV4_RCPI3, rxdg3); in mt7615_mac_fill_rx()
585 mt7615_mac_fill_tm_rx(mphy->priv, rxd); in mt7615_mac_fill_rx()
588 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
589 return -EINVAL; in mt7615_mac_fill_rx()
593 status->amsdu = !!amsdu_info; in mt7615_mac_fill_rx()
594 if (status->amsdu) { in mt7615_mac_fill_rx()
595 status->first_amsdu = amsdu_info == MT_RXD1_FIRST_AMSDU_FRAME; in mt7615_mac_fill_rx()
596 status->last_amsdu = amsdu_info == MT_RXD1_LAST_AMSDU_FRAME; in mt7615_mac_fill_rx()
599 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; in mt7615_mac_fill_rx()
602 return -EINVAL; in mt7615_mac_fill_rx()
608 if (!hdr_trans && status->amsdu) { in mt7615_mac_fill_rx()
613 * the hardware will insert an extra 2-byte field in mt7615_mac_fill_rx()
615 * type field. This happens either when the LLC-SNAP in mt7615_mac_fill_rx()
620 if (get_unaligned_be16(skb->data + pad_start) == ETH_P_8021Q) in mt7615_mac_fill_rx()
627 memmove(skb->data + 2, skb->data, pad_start); in mt7615_mac_fill_rx()
639 hdr = (struct ieee80211_hdr *)skb->data; in mt7615_mac_fill_rx()
640 fc = hdr->frame_control; in mt7615_mac_fill_rx()
642 seq_ctrl = le16_to_cpu(hdr->seq_ctrl); in mt7615_mac_fill_rx()
646 status->flag |= RX_FLAG_8023; in mt7615_mac_fill_rx()
649 if (!status->wcid || !ieee80211_is_data_qos(fc)) in mt7615_mac_fill_rx()
652 status->aggr = unicast && in mt7615_mac_fill_rx()
654 status->qos_ctl = qos_ctl; in mt7615_mac_fill_rx()
655 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); in mt7615_mac_fill_rx()
676 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { in mt7615_mac_tx_rate_val()
680 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
682 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
684 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
686 } else if (rate->flags & IEEE80211_TX_RC_MCS) { in mt7615_mac_tx_rate_val()
687 rate_idx = rate->idx; in mt7615_mac_tx_rate_val()
688 nss = 1 + (rate->idx >> 3); in mt7615_mac_tx_rate_val()
690 if (rate->flags & IEEE80211_TX_RC_GREEN_FIELD) in mt7615_mac_tx_rate_val()
692 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
696 int band = mphy->chandef.chan->band; in mt7615_mac_tx_rate_val()
700 r = &mphy->hw->wiphy->bands[band]->bitrates[rate->idx]; in mt7615_mac_tx_rate_val()
701 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in mt7615_mac_tx_rate_val()
702 val = r->hw_value_short; in mt7615_mac_tx_rate_val()
704 val = r->hw_value; in mt7615_mac_tx_rate_val()
717 FIELD_PREP(MT_TX_RATE_NSS, nss - 1)); in mt7615_mac_tx_rate_val()
728 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7615_mac_write_txwi()
731 struct ieee80211_tx_rate *rate = &info->control.rates[0]; in mt7615_mac_write_txwi()
732 u8 phy_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2; in mt7615_mac_write_txwi()
733 bool multicast = is_multicast_ether_addr(hdr->addr1); in mt7615_mac_write_txwi()
734 struct ieee80211_vif *vif = info->control.vif; in mt7615_mac_write_txwi()
735 bool is_mmio = mt76_is_mmio(&dev->mt76); in mt7615_mac_write_txwi()
737 struct mt76_phy *mphy = &dev->mphy; in mt7615_mac_write_txwi()
738 __le16 fc = hdr->frame_control; in mt7615_mac_write_txwi()
743 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; in mt7615_mac_write_txwi()
745 omac_idx = mvif->omac_idx; in mt7615_mac_write_txwi()
746 wmm_idx = mvif->wmm_idx; in mt7615_mac_write_txwi()
750 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; in mt7615_mac_write_txwi()
752 tx_count = msta->rate_count; in mt7615_mac_write_txwi()
755 if (phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_mac_write_txwi()
756 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_write_txwi()
773 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + sz_txd) | in mt7615_mac_write_txwi()
779 FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) | in mt7615_mac_write_txwi()
784 skb->priority & IEEE80211_QOS_CTL_TID_MASK) | in mt7615_mac_write_txwi()
794 key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { in mt7615_mac_write_txwi()
805 if (!(info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7615_mac_write_txwi()
811 if (rate->idx >= 0 && rate->count && in mt7615_mac_write_txwi()
812 !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) { in mt7615_mac_write_txwi()
813 bool stbc = info->flags & IEEE80211_TX_CTL_STBC; in mt7615_mac_write_txwi()
825 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in mt7615_mac_write_txwi()
828 if (info->flags & IEEE80211_TX_CTL_LDPC) in mt7615_mac_write_txwi()
831 if (!(rate->flags & (IEEE80211_TX_RC_MCS | in mt7615_mac_write_txwi()
835 tx_count = rate->count; in mt7615_mac_write_txwi()
852 if (info->flags & IEEE80211_TX_CTL_INJECTED) { in mt7615_mac_write_txwi()
853 seqno = le16_to_cpu(hdr->seq_ctrl); in mt7615_mac_write_txwi()
855 if (ieee80211_is_back_req(hdr->frame_control)) { in mt7615_mac_write_txwi()
858 bar = (struct ieee80211_bar *)skb->data; in mt7615_mac_write_txwi()
859 seqno = le16_to_cpu(bar->start_seq_num); in mt7615_mac_write_txwi()
868 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mt7615_mac_write_txwi()
915 spin_lock_bh(&dev->sta_poll_lock); in mt7615_mac_sta_poll()
916 list_splice_init(&dev->sta_poll_list, &sta_poll_list); in mt7615_mac_sta_poll()
917 spin_unlock_bh(&dev->sta_poll_lock); in mt7615_mac_sta_poll()
924 list_del_init(&msta->poll_list); in mt7615_mac_sta_poll()
926 addr = mt7615_mac_wtbl_addr(dev, msta->wcid.idx) + 19 * 4; in mt7615_mac_sta_poll()
929 u32 tx_last = msta->airtime_ac[i]; in mt7615_mac_sta_poll()
930 u32 rx_last = msta->airtime_ac[i + 4]; in mt7615_mac_sta_poll()
932 msta->airtime_ac[i] = mt76_rr(dev, addr); in mt7615_mac_sta_poll()
933 msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); in mt7615_mac_sta_poll()
934 tx_time[i] = msta->airtime_ac[i] - tx_last; in mt7615_mac_sta_poll()
935 rx_time[i] = msta->airtime_ac[i + 4] - rx_last; in mt7615_mac_sta_poll()
942 mt7615_mac_wtbl_update(dev, msta->wcid.idx, in mt7615_mac_sta_poll()
944 memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac)); in mt7615_mac_sta_poll()
947 if (!msta->wcid.sta) in mt7615_mac_sta_poll()
970 struct ieee80211_tx_rate *rates, in mt7615_mac_update_rate_desc() argument
973 struct mt7615_dev *dev = phy->dev; in mt7615_mac_update_rate_desc()
974 struct mt76_phy *mphy = phy->mt76; in mt7615_mac_update_rate_desc()
977 int n_rates = sta->n_rates; in mt7615_mac_update_rate_desc()
982 rates[i] = rates[n_rates - 1]; in mt7615_mac_update_rate_desc()
984 rateset = !(sta->rate_set_tsf & BIT(0)); in mt7615_mac_update_rate_desc()
985 memcpy(sta->rateset[rateset].rates, rates, in mt7615_mac_update_rate_desc()
986 sizeof(sta->rateset[rateset].rates)); in mt7615_mac_update_rate_desc()
988 sta->rateset[rateset].probe_rate = *probe_rate; in mt7615_mac_update_rate_desc()
989 ref = &sta->rateset[rateset].probe_rate; in mt7615_mac_update_rate_desc()
991 sta->rateset[rateset].probe_rate.idx = -1; in mt7615_mac_update_rate_desc()
992 ref = &sta->rateset[rateset].rates[0]; in mt7615_mac_update_rate_desc()
995 rates = sta->rateset[rateset].rates; in mt7615_mac_update_rate_desc()
996 for (i = 0; i < ARRAY_SIZE(sta->rateset[rateset].rates); i++) { in mt7615_mac_update_rate_desc()
1004 if ((ref->flags ^ rates[i].flags) & IEEE80211_TX_RC_SHORT_GI) in mt7615_mac_update_rate_desc()
1005 rates[i].flags ^= IEEE80211_TX_RC_SHORT_GI; in mt7615_mac_update_rate_desc()
1008 if (rates[i].idx != rates[j].idx) in mt7615_mac_update_rate_desc()
1010 if ((rates[i].flags ^ rates[j].flags) & in mt7615_mac_update_rate_desc()
1016 if (!rates[i].idx) in mt7615_mac_update_rate_desc()
1019 rates[i].idx--; in mt7615_mac_update_rate_desc()
1023 rd->val[0] = mt7615_mac_tx_rate_val(dev, mphy, &rates[0], stbc, &bw); in mt7615_mac_update_rate_desc()
1027 rd->probe_val = mt7615_mac_tx_rate_val(dev, mphy, probe_rate, in mt7615_mac_update_rate_desc()
1030 rd->bw_idx = 1; in mt7615_mac_update_rate_desc()
1034 rd->probe_val = rd->val[0]; in mt7615_mac_update_rate_desc()
1037 rd->val[1] = mt7615_mac_tx_rate_val(dev, mphy, &rates[1], stbc, &bw); in mt7615_mac_update_rate_desc()
1039 rd->bw_idx = 3; in mt7615_mac_update_rate_desc()
1043 rd->val[2] = mt7615_mac_tx_rate_val(dev, mphy, &rates[2], stbc, &bw); in mt7615_mac_update_rate_desc()
1045 rd->bw_idx = 5; in mt7615_mac_update_rate_desc()
1049 rd->val[3] = mt7615_mac_tx_rate_val(dev, mphy, &rates[3], stbc, &bw); in mt7615_mac_update_rate_desc()
1051 rd->bw_idx = 7; in mt7615_mac_update_rate_desc()
1053 rd->rateset = rateset; in mt7615_mac_update_rate_desc()
1054 rd->bw = bw; in mt7615_mac_update_rate_desc()
1060 struct ieee80211_tx_rate *rates) in mt7615_mac_queue_rate_update() argument
1062 struct mt7615_dev *dev = phy->dev; in mt7615_mac_queue_rate_update()
1065 if (work_pending(&dev->rate_work)) in mt7615_mac_queue_rate_update()
1066 return -EBUSY; in mt7615_mac_queue_rate_update()
1070 return -ENOMEM; in mt7615_mac_queue_rate_update()
1072 wrd->sta = sta; in mt7615_mac_queue_rate_update()
1073 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates, in mt7615_mac_queue_rate_update()
1074 &wrd->rate); in mt7615_mac_queue_rate_update()
1075 list_add_tail(&wrd->node, &dev->wrd_head); in mt7615_mac_queue_rate_update()
1076 queue_work(dev->mt76.wq, &dev->rate_work); in mt7615_mac_queue_rate_update()
1098 val |= val2 << (32 - offset); in mt7615_mac_get_sta_tid_sn()
1106 struct ieee80211_tx_rate *rates) in mt7615_mac_set_rates() argument
1108 int wcid = sta->wcid.idx, n_rates = sta->n_rates; in mt7615_mac_set_rates()
1109 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_rates()
1112 u16 idx = sta->vif->mt76.omac_idx; in mt7615_mac_set_rates()
1114 if (!mt76_is_mmio(&dev->mt76)) { in mt7615_mac_set_rates()
1115 mt7615_mac_queue_rate_update(phy, sta, probe_rate, rates); in mt7615_mac_set_rates()
1123 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates, &rd); in mt7615_mac_set_rates()
1137 rd.bw_idx ? rd.bw_idx - 1 : 7); in mt7615_mac_set_rates()
1168 sta->rate_set_tsf = mt76_rr(dev, MT_LPON_UTTR0) & ~BIT(0); in mt7615_mac_set_rates()
1169 sta->rate_set_tsf |= rd.rateset; in mt7615_mac_set_rates()
1171 if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET)) in mt7615_mac_set_rates()
1174 sta->rate_count = 2 * MT7615_RATE_RETRY * n_rates; in mt7615_mac_set_rates()
1175 sta->wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7615_mac_set_rates()
1176 sta->rate_probe = !!probe_rate; in mt7615_mac_set_rates()
1186 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx) + 30 * 4; in mt7615_mac_wtbl_update_key()
1189 if (key->keylen > sizeof(data)) in mt7615_mac_wtbl_update_key()
1190 return -EINVAL; in mt7615_mac_wtbl_update_key()
1196 memcpy(data, key->key, 16); in mt7615_mac_wtbl_update_key()
1197 memcpy(data + 16, key->key + 24, 8); in mt7615_mac_wtbl_update_key()
1198 memcpy(data + 24, key->key + 16, 8); in mt7615_mac_wtbl_update_key()
1201 memcpy(data, key->key, key->keylen); in mt7615_mac_wtbl_update_key()
1203 memcpy(data, key->key, 16); in mt7615_mac_wtbl_update_key()
1205 memcpy(data + 16, key->key, 16); in mt7615_mac_wtbl_update_key()
1226 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx), w0, w1; in mt7615_mac_wtbl_update_pk()
1229 return -ETIMEDOUT; in mt7615_mac_wtbl_update_pk()
1253 if (!mt7615_mac_wtbl_update(dev, wcid->idx, in mt7615_mac_wtbl_update_pk()
1255 return -ETIMEDOUT; in mt7615_mac_wtbl_update_pk()
1265 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx); in mt7615_mac_wtbl_update_cipher()
1289 u16 cipher_mask = wcid->cipher; in __mt7615_mac_wtbl_set_key()
1292 cipher = mt7615_mac_get_cipher(key->cipher); in __mt7615_mac_wtbl_set_key()
1294 return -EOPNOTSUPP; in __mt7615_mac_wtbl_set_key()
1308 key->keyidx, cmd); in __mt7615_mac_wtbl_set_key()
1312 wcid->cipher = cipher_mask; in __mt7615_mac_wtbl_set_key()
1324 spin_lock_bh(&dev->mt76.lock); in mt7615_mac_wtbl_set_key()
1326 spin_unlock_bh(&dev->mt76.lock); in mt7615_mac_wtbl_set_key()
1340 bool ampdu, cck = false; in mt7615_fill_txs() local
1364 info->flags |= IEEE80211_TX_STAT_ACK; in mt7615_fill_txs()
1366 info->status.ampdu_len = 1; in mt7615_fill_txs()
1367 info->status.ampdu_ack_len = !!(info->flags & in mt7615_fill_txs()
1370 if (ampdu || (info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7615_fill_txs()
1371 info->flags |= IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_CTL_AMPDU; in mt7615_fill_txs()
1373 first_idx = max_t(int, 0, last_idx - (count - 1) / MT7615_RATE_RETRY); in mt7615_fill_txs()
1376 info->status.rates[0].count = count; in mt7615_fill_txs()
1381 rate_set_tsf = READ_ONCE(sta->rate_set_tsf); in mt7615_fill_txs()
1382 rs_idx = !((u32)(le32_get_bits(txs_data[4], MT_TXS4_F0_TIMESTAMP) - in mt7615_fill_txs()
1385 rs = &sta->rateset[rs_idx]; in mt7615_fill_txs()
1387 if (!first_idx && rs->probe_rate.idx >= 0) { in mt7615_fill_txs()
1388 info->status.rates[0] = rs->probe_rate; in mt7615_fill_txs()
1390 spin_lock_bh(&dev->mt76.lock); in mt7615_fill_txs()
1391 if (sta->rate_probe) { in mt7615_fill_txs()
1392 struct mt7615_phy *phy = &dev->phy; in mt7615_fill_txs()
1394 if (sta->wcid.phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_fill_txs()
1395 phy = dev->mt76.phys[MT_BAND1]->priv; in mt7615_fill_txs()
1397 mt7615_mac_set_rates(phy, sta, NULL, sta->rates); in mt7615_fill_txs()
1399 spin_unlock_bh(&dev->mt76.lock); in mt7615_fill_txs()
1401 info->status.rates[0] = rs->rates[first_idx / 2]; in mt7615_fill_txs()
1403 info->status.rates[0].count = 0; in mt7615_fill_txs()
1409 cur_rate = &rs->rates[idx / 2]; in mt7615_fill_txs()
1411 count -= cur_count; in mt7615_fill_txs()
1413 if (idx && (cur_rate->idx != info->status.rates[i].idx || in mt7615_fill_txs()
1414 cur_rate->flags != info->status.rates[i].flags)) { in mt7615_fill_txs()
1416 if (i == ARRAY_SIZE(info->status.rates)) { in mt7615_fill_txs()
1417 i--; in mt7615_fill_txs()
1421 info->status.rates[i] = *cur_rate; in mt7615_fill_txs()
1422 info->status.rates[i].count = 0; in mt7615_fill_txs()
1425 info->status.rates[i].count += cur_count; in mt7615_fill_txs()
1429 final_rate_flags = info->status.rates[i].flags; in mt7615_fill_txs()
1433 cck = true; in mt7615_fill_txs()
1436 mphy = &dev->mphy; in mt7615_fill_txs()
1437 if (sta->wcid.phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_fill_txs()
1438 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_fill_txs()
1440 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7615_fill_txs()
1441 sband = &mphy->sband_5g.sband; in mt7615_fill_txs()
1443 sband = &mphy->sband_2g.sband; in mt7615_fill_txs()
1445 final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, in mt7615_fill_txs()
1446 cck); in mt7615_fill_txs()
1460 final_nss--; in mt7615_fill_txs()
1469 info->status.rates[i].idx = final_rate; in mt7615_fill_txs()
1470 info->status.rates[i].flags = final_rate_flags; in mt7615_fill_txs()
1479 struct mt76_dev *mdev = &dev->mt76; in mt7615_mac_add_txs_skb()
1486 trace_mac_txdone(mdev, sta->wcid.idx, pid); in mt7615_mac_add_txs_skb()
1489 skb = mt76_tx_status_skb_get(mdev, &sta->wcid, pid, &list); in mt7615_mac_add_txs_skb()
1494 info->status.rates[0].count = 0; in mt7615_mac_add_txs_skb()
1495 info->status.rates[0].idx = -1; in mt7615_mac_add_txs_skb()
1511 struct mt76_phy *mphy = &dev->mt76.phy; in mt7615_mac_add_txs()
1527 wcid = rcu_dereference(dev->mt76.wcid[wcidx]); in mt7615_mac_add_txs()
1534 spin_lock_bh(&dev->sta_poll_lock); in mt7615_mac_add_txs()
1535 if (list_empty(&msta->poll_list)) in mt7615_mac_add_txs()
1536 list_add_tail(&msta->poll_list, &dev->sta_poll_list); in mt7615_mac_add_txs()
1537 spin_unlock_bh(&dev->sta_poll_lock); in mt7615_mac_add_txs()
1545 if (wcid->phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_mac_add_txs()
1546 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_add_txs()
1549 ieee80211_tx_status_noskb(mphy->hw, sta, &info); in mt7615_mac_add_txs()
1558 struct mt76_dev *mdev = &dev->mt76; in mt7615_txwi_free()
1564 if (!txwi->skb) in mt7615_txwi_free()
1570 mt76_tx_complete_skb(mdev, wcid, txwi->skb); in mt7615_txwi_free()
1573 txwi->skb = NULL; in mt7615_txwi_free()
1580 struct mt76_dev *mdev = &dev->mt76; in mt7615_mac_tx_free_token()
1598 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false); in mt7615_mac_tx_free()
1599 if (is_mt7615(&dev->mt76)) { in mt7615_mac_tx_free()
1600 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false); in mt7615_mac_tx_free()
1603 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[i], false); in mt7615_mac_tx_free()
1606 count = le16_get_bits(free->ctrl, MT_TX_FREE_MSDU_ID_CNT); in mt7615_mac_tx_free()
1607 if (is_mt7615(&dev->mt76)) { in mt7615_mac_tx_free()
1629 mt76_worker_schedule(&dev->mt76.tx_worker); in mt7615_mac_tx_free()
1659 __le32 *rxd = (__le32 *)skb->data; in mt7615_queue_rx_skb()
1660 __le32 *end = (__le32 *)&skb->data[skb->len]; in mt7615_queue_rx_skb()
1676 mt7615_mac_tx_free(dev, skb->data, skb->len); in mt7615_queue_rx_skb()
1685 mt76_rx(&dev->mt76, q, skb); in mt7615_queue_rx_skb()
1699 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_sensitivity()
1700 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_sensitivity()
1702 if (is_mt7663(&dev->mt76)) { in mt7615_mac_set_sensitivity()
1729 /* cck */ in mt7615_mac_set_default_sensitivity()
1732 phy->ofdm_sensitivity = -98; in mt7615_mac_set_default_sensitivity()
1733 phy->cck_sensitivity = -110; in mt7615_mac_set_default_sensitivity()
1734 phy->last_cca_adj = jiffies; in mt7615_mac_set_default_sensitivity()
1739 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_scs()
1740 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_scs()
1745 if (phy->scs_en == enable) in mt7615_mac_set_scs()
1748 if (is_mt7663(&dev->mt76)) { in mt7615_mac_set_scs()
1758 if (is_mt7622(&dev->mt76)) { in mt7615_mac_set_scs()
1767 phy->scs_en = enable; in mt7615_mac_set_scs()
1777 if (is_mt7663(&dev->mt76)) in mt7615_mac_enable_nf()
1793 struct mt7615_dev *dev = phy->dev; in mt7615_mac_cca_stats_reset()
1794 bool ext_phy = phy != &dev->phy; in mt7615_mac_cca_stats_reset()
1797 if (is_mt7663(&dev->mt76)) in mt7615_mac_cca_stats_reset()
1811 struct mt7615_dev *dev = phy->dev; in mt7615_mac_adjust_sensitivity()
1812 int false_cca = ofdm ? phy->false_cca_ofdm : phy->false_cca_cck; in mt7615_mac_adjust_sensitivity()
1813 bool ext_phy = phy != &dev->phy; in mt7615_mac_adjust_sensitivity()
1814 s16 def_th = ofdm ? -98 : -110; in mt7615_mac_adjust_sensitivity()
1819 sensitivity = ofdm ? &phy->ofdm_sensitivity : &phy->cck_sensitivity; in mt7615_mac_adjust_sensitivity()
1820 signal = mt76_get_min_avg_rssi(&dev->mt76, ext_phy); in mt7615_mac_adjust_sensitivity()
1826 signal = min(signal, -72); in mt7615_mac_adjust_sensitivity()
1832 if (*sensitivity == def_th && signal > -90) { in mt7615_mac_adjust_sensitivity()
1833 *sensitivity = -90; in mt7615_mac_adjust_sensitivity()
1842 if (*sensitivity - 2 >= def_th) { in mt7615_mac_adjust_sensitivity()
1843 *sensitivity -= 2; in mt7615_mac_adjust_sensitivity()
1857 phy->last_cca_adj = jiffies; in mt7615_mac_adjust_sensitivity()
1864 struct mt7615_dev *dev = phy->dev; in mt7615_mac_scs_check()
1865 struct mib_stats *mib = &phy->mib; in mt7615_mac_scs_check()
1868 bool ext_phy = phy != &dev->phy; in mt7615_mac_scs_check()
1870 if (!phy->scs_en) in mt7615_mac_scs_check()
1873 if (is_mt7663(&dev->mt76)) in mt7615_mac_scs_check()
1880 if (is_mt7663(&dev->mt76)) in mt7615_mac_scs_check()
1887 phy->false_cca_ofdm = pd_ofdm - mdrdy_ofdm; in mt7615_mac_scs_check()
1888 phy->false_cca_cck = pd_cck - mdrdy_cck; in mt7615_mac_scs_check()
1891 if (mib->rts_cnt + mib->rts_retries_cnt) in mt7615_mac_scs_check()
1892 rts_err_rate = MT_FRAC(mib->rts_retries_cnt, in mt7615_mac_scs_check()
1893 mib->rts_cnt + mib->rts_retries_cnt); in mt7615_mac_scs_check()
1895 /* cck */ in mt7615_mac_scs_check()
1900 if (time_after(jiffies, phy->last_cca_adj + 10 * HZ)) in mt7615_mac_scs_check()
1911 if (is_mt7663(&dev->mt76)) in mt7615_phy_get_nf()
1931 struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76); in mt7615_phy_update_channel()
1932 struct mt7615_phy *phy = mphy->priv; in mt7615_phy_update_channel()
1947 if (!phy->noise) in mt7615_phy_update_channel()
1948 phy->noise = nf << 4; in mt7615_phy_update_channel()
1950 phy->noise += nf - (phy->noise >> 4); in mt7615_phy_update_channel()
1952 state = mphy->chan_state; in mt7615_phy_update_channel()
1953 state->cc_busy += busy_time; in mt7615_phy_update_channel()
1954 state->cc_tx += tx_time; in mt7615_phy_update_channel()
1955 state->cc_rx += rx_time + obss_time; in mt7615_phy_update_channel()
1956 state->cc_bss_rx += rx_time; in mt7615_phy_update_channel()
1957 state->noise = -(phy->noise >> 4); in mt7615_phy_update_channel()
1962 struct mt76_dev *mdev = &dev->mt76; in mt7615_update_survey()
1963 struct mt76_phy *mphy_ext = mdev->phys[MT_BAND1]; in mt7615_update_survey()
1970 mt7615_phy_update_channel(&mdev->phy, 0); in mt7615_update_survey()
1976 mt76_update_survey_active_time(&mdev->phy, cur_time); in mt7615_update_survey()
1986 struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76); in mt7615_update_channel()
1988 if (mt76_connac_pm_wake(&dev->mphy, &dev->pm)) in mt7615_update_channel()
1992 mt76_connac_power_save_sched(&dev->mphy, &dev->pm); in mt7615_update_channel()
1999 struct mt7615_dev *dev = phy->dev; in mt7615_mac_update_mib_stats()
2000 struct mib_stats *mib = &phy->mib; in mt7615_mac_update_mib_stats()
2001 bool ext_phy = phy != &dev->phy; in mt7615_mac_update_mib_stats()
2005 mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(ext_phy), in mt7615_mac_update_mib_stats()
2013 mib->aggr_per = 1000 * (val - val2) / val; in mt7615_mac_update_mib_stats()
2016 aggr = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0; in mt7615_mac_update_mib_stats()
2019 mib->ba_miss_cnt += FIELD_GET(MT_MIB_BA_MISS_COUNT_MASK, val); in mt7615_mac_update_mib_stats()
2020 mib->ack_fail_cnt += FIELD_GET(MT_MIB_ACK_FAIL_COUNT_MASK, in mt7615_mac_update_mib_stats()
2024 mib->rts_cnt += FIELD_GET(MT_MIB_RTS_COUNT_MASK, val); in mt7615_mac_update_mib_stats()
2025 mib->rts_retries_cnt += FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK, in mt7615_mac_update_mib_stats()
2029 dev->mt76.aggr_stats[aggr++] += val & 0xffff; in mt7615_mac_update_mib_stats()
2030 dev->mt76.aggr_stats[aggr++] += val >> 16; in mt7615_mac_update_mib_stats()
2041 mphy = dev->phy.mt76; in mt7615_pm_wake_work()
2044 struct mt76_dev *mdev = &dev->mt76; in mt7615_pm_wake_work()
2048 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); in mt7615_pm_wake_work()
2049 mt76_worker_schedule(&mdev->sdio.txrx_worker); in mt7615_pm_wake_work()
2053 napi_schedule(&mdev->napi[i]); in mt7615_pm_wake_work()
2055 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); in mt7615_pm_wake_work()
2056 mt76_queue_tx_cleanup(dev, mdev->q_mcu[MT_MCUQ_WM], in mt7615_pm_wake_work()
2060 if (test_bit(MT76_STATE_RUNNING, &mphy->state)) { in mt7615_pm_wake_work()
2064 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in mt7615_pm_wake_work()
2069 ieee80211_wake_queues(mphy->hw); in mt7615_pm_wake_work()
2070 wake_up(&dev->pm.wait); in mt7615_pm_wake_work()
2081 delta = dev->pm.idle_timeout; in mt7615_pm_power_save_work()
2082 if (test_bit(MT76_HW_SCANNING, &dev->mphy.state) || in mt7615_pm_power_save_work()
2083 test_bit(MT76_HW_SCHED_SCANNING, &dev->mphy.state)) in mt7615_pm_power_save_work()
2086 if (mutex_is_locked(&dev->mt76.mutex)) in mt7615_pm_power_save_work()
2094 if (time_is_after_jiffies(dev->pm.last_activity + delta)) { in mt7615_pm_power_save_work()
2095 delta = dev->pm.last_activity + delta - jiffies; in mt7615_pm_power_save_work()
2102 queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta); in mt7615_pm_power_save_work()
2113 phy = mphy->priv; in mt7615_mac_work()
2115 mt7615_mutex_acquire(phy->dev); in mt7615_mac_work()
2117 mt7615_update_survey(phy->dev); in mt7615_mac_work()
2118 if (++mphy->mac_work_count == 5) { in mt7615_mac_work()
2119 mphy->mac_work_count = 0; in mt7615_mac_work()
2125 mt7615_mutex_release(phy->dev); in mt7615_mac_work()
2127 mt76_tx_status_check(mphy->dev, false); in mt7615_mac_work()
2129 timeout = mt7615_get_macwork_timeout(phy->dev); in mt7615_mac_work()
2130 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, timeout); in mt7615_mac_work()
2138 spin_lock_bh(&dev->mt76.token_lock); in mt7615_tx_token_put()
2139 idr_for_each_entry(&dev->mt76.token, txwi, id) in mt7615_tx_token_put()
2141 spin_unlock_bh(&dev->mt76.token_lock); in mt7615_tx_token_put()
2142 idr_destroy(&dev->mt76.token); in mt7615_tx_token_put()
2148 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_stop_radar_detector()
2150 if (phy->rdd_state & BIT(0)) in mt7615_dfs_stop_radar_detector()
2151 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 0, in mt7615_dfs_stop_radar_detector()
2153 if (phy->rdd_state & BIT(1)) in mt7615_dfs_stop_radar_detector()
2154 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 1, in mt7615_dfs_stop_radar_detector()
2162 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_START, chain, in mt7615_dfs_start_rdd()
2167 return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_DET_MODE, chain, in mt7615_dfs_start_rdd()
2173 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7615_dfs_start_radar_detector()
2174 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_start_radar_detector()
2175 bool ext_phy = phy != &dev->phy; in mt7615_dfs_start_radar_detector()
2179 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_START, ext_phy, in mt7615_dfs_start_radar_detector()
2188 phy->rdd_state |= BIT(ext_phy); in mt7615_dfs_start_radar_detector()
2190 if (chandef->width == NL80211_CHAN_WIDTH_160 || in mt7615_dfs_start_radar_detector()
2191 chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7615_dfs_start_radar_detector()
2196 phy->rdd_state |= BIT(1); in mt7615_dfs_start_radar_detector()
2206 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_init_radar_specs()
2209 switch (dev->mt76.region) { in mt7615_dfs_init_radar_specs()
2221 return -EINVAL; in mt7615_dfs_init_radar_specs()
2224 /* avoid FCC radar detection in non-FCC region */ in mt7615_dfs_init_radar_specs()
2229 for (i = 0; i < ARRAY_SIZE(radar_specs->radar_pattern); i++) { in mt7615_dfs_init_radar_specs()
2231 &radar_specs->radar_pattern[i]); in mt7615_dfs_init_radar_specs()
2236 return mt7615_mcu_set_pulse_th(dev, &radar_specs->pulse_th); in mt7615_dfs_init_radar_specs()
2241 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7615_dfs_init_radar_detector()
2242 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_init_radar_detector()
2243 bool ext_phy = phy != &dev->phy; in mt7615_dfs_init_radar_detector()
2247 if (is_mt7663(&dev->mt76)) in mt7615_dfs_init_radar_detector()
2250 prev_state = phy->mt76->dfs_state; in mt7615_dfs_init_radar_detector()
2251 dfs_state = mt76_phy_dfs_state(phy->mt76); in mt7615_dfs_init_radar_detector()
2252 if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) && in mt7615_dfs_init_radar_detector()
2271 phy->mt76->dfs_state = MT_DFS_STATE_CAC; in mt7615_dfs_init_radar_detector()
2277 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_END, in mt7615_dfs_init_radar_detector()
2280 phy->mt76->dfs_state = MT_DFS_STATE_UNKNOWN; in mt7615_dfs_init_radar_detector()
2284 phy->mt76->dfs_state = MT_DFS_STATE_ACTIVE; in mt7615_dfs_init_radar_detector()
2288 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_NORMAL_START, ext_phy, in mt7615_dfs_init_radar_detector()
2294 phy->mt76->dfs_state = MT_DFS_STATE_DISABLED; in mt7615_dfs_init_radar_detector()
2303 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_beacon_filter()
2304 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_beacon_filter()
2308 return -EOPNOTSUPP; in mt7615_mac_set_beacon_filter()
2310 switch (vif->type) { in mt7615_mac_set_beacon_filter()
2317 phy->n_beacon_vif++; in mt7615_mac_set_beacon_filter()
2319 phy->n_beacon_vif--; in mt7615_mac_set_beacon_filter()
2325 err = mt7615_mcu_set_bss_pm(dev, vif, !phy->n_beacon_vif); in mt7615_mac_set_beacon_filter()
2329 if (phy->n_beacon_vif) { in mt7615_mac_set_beacon_filter()
2330 vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; in mt7615_mac_set_beacon_filter()
2334 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; in mt7615_mac_set_beacon_filter()
2350 if (time_is_after_jiffies(dev->coredump.last_activity + in mt7615_coredump_work()
2352 queue_delayed_work(dev->mt76.wq, &dev->coredump.work, in mt7615_coredump_work()
2363 spin_lock_bh(&dev->mt76.lock); in mt7615_coredump_work()
2364 skb = __skb_dequeue(&dev->coredump.msg_list); in mt7615_coredump_work()
2365 spin_unlock_bh(&dev->mt76.lock); in mt7615_coredump_work()
2371 if (data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) { in mt7615_coredump_work()
2376 memcpy(data, skb->data, skb->len); in mt7615_coredump_work()
2377 data += skb->len; in mt7615_coredump_work()
2381 dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, in mt7615_coredump_work()