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 },
97 if (!wcid->sta) in mt7615_rx_get_wcid()
101 if (!sta->vif) in mt7615_rx_get_wcid()
104 return &sta->vif->sta.wcid; in mt7615_rx_get_wcid()
109 struct mt7615_dev *dev = phy->dev; in mt7615_mac_reset_counters()
117 memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats)); in mt7615_mac_reset_counters()
118 phy->mt76->survey_time = ktime_get_boottime(); in mt7615_mac_reset_counters()
136 s16 coverage_class = phy->coverage_class; in mt7615_mac_set_timing()
137 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_timing()
138 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_timing()
140 u32 cck = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 231) | in mt7615_mac_set_timing() local
145 bool is_5ghz = phy->mt76->chandef.chan->band == NL80211_BAND_5GHZ; in mt7615_mac_set_timing()
147 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) in mt7615_mac_set_timing()
156 coverage_class = max_t(s16, dev->phy.coverage_class, in mt7615_mac_set_timing()
164 coverage_class = max_t(s16, phy_ext->coverage_class, in mt7615_mac_set_timing()
174 mt76_wr(dev, MT_TMAC_CDTR, cck + reg_offset); in mt7615_mac_set_timing()
181 FIELD_PREP(MT_IFS_SLOT, phy->slottime)); in mt7615_mac_set_timing()
183 if (phy->slottime < 20 || is_5ghz) in mt7615_mac_set_timing()
202 if (!test_bit(MT76_HW_SCANNING, &mphy->state) && in mt7615_get_status_freq_info()
203 !test_bit(MT76_HW_SCHED_SCANNING, &mphy->state) && in mt7615_get_status_freq_info()
204 !test_bit(MT76_STATE_ROC, &mphy->state)) { in mt7615_get_status_freq_info()
205 status->freq = mphy->chandef.chan->center_freq; in mt7615_get_status_freq_info()
206 status->band = mphy->chandef.chan->band; in mt7615_get_status_freq_info()
210 status->band = chfreq <= 14 ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ; in mt7615_get_status_freq_info()
211 status->freq = ieee80211_channel_to_frequency(chfreq, status->band); in mt7615_get_status_freq_info()
227 /* CCK */ in mt7615_mac_fill_tm_rx()
233 foe -= 4096; in mt7615_mac_fill_tm_rx()
238 phy->test.last_freq_offset = foe; in mt7615_mac_fill_tm_rx()
239 phy->test.last_rcpi[0] = FIELD_GET(MT_RXV4_RCPI0, rxv4); in mt7615_mac_fill_tm_rx()
240 phy->test.last_rcpi[1] = FIELD_GET(MT_RXV4_RCPI1, rxv4); in mt7615_mac_fill_tm_rx()
241 phy->test.last_rcpi[2] = FIELD_GET(MT_RXV4_RCPI2, rxv4); in mt7615_mac_fill_tm_rx()
242 phy->test.last_rcpi[3] = FIELD_GET(MT_RXV4_RCPI3, rxv4); in mt7615_mac_fill_tm_rx()
243 phy->test.last_ib_rssi[0] = FIELD_GET(MT_RXV3_IB_RSSI, rxv3); in mt7615_mac_fill_tm_rx()
244 phy->test.last_wb_rssi[0] = FIELD_GET(MT_RXV3_WB_RSSI, rxv3); in mt7615_mac_fill_tm_rx()
251 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7615_reverse_frag0_hdr_trans()
252 struct ethhdr *eth_hdr = (struct ethhdr *)(skb->data + hdr_gap); in mt7615_reverse_frag0_hdr_trans()
253 struct mt7615_sta *msta = (struct mt7615_sta *)status->wcid; in mt7615_reverse_frag0_hdr_trans()
254 __le32 *rxd = (__le32 *)skb->data; in mt7615_reverse_frag0_hdr_trans()
262 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
265 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
267 if (!msta || !msta->vif) in mt7615_reverse_frag0_hdr_trans()
268 return -EINVAL; in mt7615_reverse_frag0_hdr_trans()
271 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); in mt7615_reverse_frag0_hdr_trans()
279 ether_addr_copy(hdr.addr1, vif->addr); in mt7615_reverse_frag0_hdr_trans()
280 ether_addr_copy(hdr.addr2, sta->addr); in mt7615_reverse_frag0_hdr_trans()
284 ether_addr_copy(hdr.addr3, vif->bss_conf.bssid); in mt7615_reverse_frag0_hdr_trans()
287 ether_addr_copy(hdr.addr3, eth_hdr->h_source); in mt7615_reverse_frag0_hdr_trans()
290 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7615_reverse_frag0_hdr_trans()
293 ether_addr_copy(hdr.addr3, eth_hdr->h_dest); in mt7615_reverse_frag0_hdr_trans()
294 ether_addr_copy(hdr.addr4, eth_hdr->h_source); in mt7615_reverse_frag0_hdr_trans()
300 skb_pull(skb, hdr_gap + sizeof(struct ethhdr) - 2); in mt7615_reverse_frag0_hdr_trans()
301 if (eth_hdr->h_proto == cpu_to_be16(ETH_P_AARP) || in mt7615_reverse_frag0_hdr_trans()
302 eth_hdr->h_proto == cpu_to_be16(ETH_P_IPX)) in mt7615_reverse_frag0_hdr_trans()
304 else if (be16_to_cpu(eth_hdr->h_proto) >= ETH_P_802_3_MIN) in mt7615_reverse_frag0_hdr_trans()
324 memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6); in mt7615_reverse_frag0_hdr_trans()
326 status->flag &= ~(RX_FLAG_RADIOTAP_HE | RX_FLAG_RADIOTAP_HE_MU); in mt7615_reverse_frag0_hdr_trans()
332 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; in mt7615_mac_fill_rx()
333 struct mt76_phy *mphy = &dev->mt76.phy; in mt7615_mac_fill_rx()
334 struct mt7615_phy *phy = &dev->phy; in mt7615_mac_fill_rx()
338 __le32 *rxd = (__le32 *)skb->data; in mt7615_mac_fill_rx()
343 u32 csum_status = *(u32 *)skb->cb; in mt7615_mac_fill_rx()
356 phy2 = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL; in mt7615_mac_fill_rx()
359 else if (phy2->chfreq == phy->chfreq) in mt7615_mac_fill_rx()
360 phy_idx = -1; in mt7615_mac_fill_rx()
361 else if (phy->chfreq == chfreq) in mt7615_mac_fill_rx()
363 else if (phy2->chfreq == chfreq) in mt7615_mac_fill_rx()
366 phy_idx = -1; in mt7615_mac_fill_rx()
369 return -EINVAL; in mt7615_mac_fill_rx()
373 return -EINVAL; in mt7615_mac_fill_rx()
377 status->flag |= RX_FLAG_ONLY_MONITOR; in mt7615_mac_fill_rx()
381 status->wcid = mt7615_rx_get_wcid(dev, idx, unicast); in mt7615_mac_fill_rx()
383 if (status->wcid) { in mt7615_mac_fill_rx()
386 msta = container_of(status->wcid, struct mt7615_sta, wcid); in mt7615_mac_fill_rx()
387 mt76_wcid_add_poll(&dev->mt76, &msta->wcid); in mt7615_mac_fill_rx()
390 if (mt76_is_mmio(&dev->mt76) && (rxd0 & csum_mask) == csum_mask && in mt7615_mac_fill_rx()
392 skb->ip_summed = CHECKSUM_UNNECESSARY; in mt7615_mac_fill_rx()
395 status->flag |= RX_FLAG_FAILED_FCS_CRC; in mt7615_mac_fill_rx()
398 status->flag |= RX_FLAG_MMIC_ERROR; in mt7615_mac_fill_rx()
402 status->flag |= RX_FLAG_DECRYPTED; in mt7615_mac_fill_rx()
403 status->flag |= RX_FLAG_IV_STRIPPED; in mt7615_mac_fill_rx()
404 status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; in mt7615_mac_fill_rx()
410 return -EINVAL; in mt7615_mac_fill_rx()
422 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
423 return -EINVAL; in mt7615_mac_fill_rx()
429 if (status->flag & RX_FLAG_DECRYPTED) { in mt7615_mac_fill_rx()
441 status->iv[0] = data[5]; in mt7615_mac_fill_rx()
442 status->iv[1] = data[4]; in mt7615_mac_fill_rx()
443 status->iv[2] = data[3]; in mt7615_mac_fill_rx()
444 status->iv[3] = data[2]; in mt7615_mac_fill_rx()
445 status->iv[4] = data[1]; in mt7615_mac_fill_rx()
446 status->iv[5] = data[0]; in mt7615_mac_fill_rx()
453 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
454 return -EINVAL; in mt7615_mac_fill_rx()
458 status->timestamp = le32_to_cpu(rxd[0]); in mt7615_mac_fill_rx()
459 status->flag |= RX_FLAG_MACTIME_START; in mt7615_mac_fill_rx()
463 status->flag |= RX_FLAG_AMPDU_DETAILS; in mt7615_mac_fill_rx()
465 /* all subframes of an A-MPDU have the same timestamp */ in mt7615_mac_fill_rx()
466 if (phy->rx_ampdu_ts != status->timestamp) { in mt7615_mac_fill_rx()
467 if (!++phy->ampdu_ref) in mt7615_mac_fill_rx()
468 phy->ampdu_ref++; in mt7615_mac_fill_rx()
470 phy->rx_ampdu_ts = status->timestamp; in mt7615_mac_fill_rx()
472 status->ampdu_ref = phy->ampdu_ref; in mt7615_mac_fill_rx()
476 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
477 return -EINVAL; in mt7615_mac_fill_rx()
491 int first_chain = ffs(phy2->mt76->chainmask) - 1; in mt7615_mac_fill_rx()
498 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_fill_rx()
500 status->phy_idx = phy_idx; in mt7615_mac_fill_rx()
503 if (!mt7615_firmware_offload(dev) && chfreq != phy->chfreq) in mt7615_mac_fill_rx()
504 return -EINVAL; in mt7615_mac_fill_rx()
507 if (status->band == NL80211_BAND_5GHZ) in mt7615_mac_fill_rx()
508 sband = &mphy->sband_5g.sband; in mt7615_mac_fill_rx()
510 sband = &mphy->sband_2g.sband; in mt7615_mac_fill_rx()
512 if (!test_bit(MT76_STATE_RUNNING, &mphy->state)) in mt7615_mac_fill_rx()
513 return -EINVAL; in mt7615_mac_fill_rx()
515 if (!sband->channels) in mt7615_mac_fill_rx()
516 return -EINVAL; in mt7615_mac_fill_rx()
523 bool cck = false; in mt7615_mac_fill_rx() local
528 cck = true; in mt7615_mac_fill_rx()
531 i = mt76_get_rate(&dev->mt76, sband, i, cck); in mt7615_mac_fill_rx()
535 status->encoding = RX_ENC_HT; in mt7615_mac_fill_rx()
537 return -EINVAL; in mt7615_mac_fill_rx()
540 status->nss = FIELD_GET(MT_RXV2_NSTS, rxdg1) + 1; in mt7615_mac_fill_rx()
541 status->encoding = RX_ENC_VHT; in mt7615_mac_fill_rx()
544 return -EINVAL; in mt7615_mac_fill_rx()
546 status->rate_idx = i; in mt7615_mac_fill_rx()
552 status->bw = RATE_INFO_BW_40; in mt7615_mac_fill_rx()
555 status->bw = RATE_INFO_BW_80; in mt7615_mac_fill_rx()
558 status->bw = RATE_INFO_BW_160; in mt7615_mac_fill_rx()
561 return -EINVAL; in mt7615_mac_fill_rx()
565 status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in mt7615_mac_fill_rx()
567 status->enc_flags |= RX_ENC_FLAG_LDPC; in mt7615_mac_fill_rx()
569 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; in mt7615_mac_fill_rx()
571 status->chains = mphy->antenna_mask; in mt7615_mac_fill_rx()
572 status->chain_signal[0] = to_rssi(MT_RXV4_RCPI0, rxdg3); in mt7615_mac_fill_rx()
573 status->chain_signal[1] = to_rssi(MT_RXV4_RCPI1, rxdg3); in mt7615_mac_fill_rx()
574 status->chain_signal[2] = to_rssi(MT_RXV4_RCPI2, rxdg3); in mt7615_mac_fill_rx()
575 status->chain_signal[3] = to_rssi(MT_RXV4_RCPI3, rxdg3); in mt7615_mac_fill_rx()
577 mt7615_mac_fill_tm_rx(mphy->priv, rxd); in mt7615_mac_fill_rx()
580 if ((u8 *)rxd - skb->data >= skb->len) in mt7615_mac_fill_rx()
581 return -EINVAL; in mt7615_mac_fill_rx()
585 status->amsdu = !!amsdu_info; in mt7615_mac_fill_rx()
586 if (status->amsdu) { in mt7615_mac_fill_rx()
587 status->first_amsdu = amsdu_info == MT_RXD1_FIRST_AMSDU_FRAME; in mt7615_mac_fill_rx()
588 status->last_amsdu = amsdu_info == MT_RXD1_LAST_AMSDU_FRAME; in mt7615_mac_fill_rx()
591 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; in mt7615_mac_fill_rx()
594 return -EINVAL; in mt7615_mac_fill_rx()
600 if (!hdr_trans && status->amsdu) { in mt7615_mac_fill_rx()
605 * the hardware will insert an extra 2-byte field in mt7615_mac_fill_rx()
607 * type field. This happens either when the LLC-SNAP in mt7615_mac_fill_rx()
612 if (get_unaligned_be16(skb->data + pad_start) == ETH_P_8021Q) in mt7615_mac_fill_rx()
619 memmove(skb->data + 2, skb->data, pad_start); in mt7615_mac_fill_rx()
631 hdr = (struct ieee80211_hdr *)skb->data; in mt7615_mac_fill_rx()
632 fc = hdr->frame_control; in mt7615_mac_fill_rx()
634 seq_ctrl = le16_to_cpu(hdr->seq_ctrl); in mt7615_mac_fill_rx()
638 status->flag |= RX_FLAG_8023; in mt7615_mac_fill_rx()
641 if (!status->wcid || !ieee80211_is_data_qos(fc)) in mt7615_mac_fill_rx()
644 status->aggr = unicast && in mt7615_mac_fill_rx()
646 status->qos_ctl = qos_ctl; in mt7615_mac_fill_rx()
647 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); in mt7615_mac_fill_rx()
663 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { in mt7615_mac_tx_rate_val()
667 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
669 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
671 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
673 } else if (rate->flags & IEEE80211_TX_RC_MCS) { in mt7615_mac_tx_rate_val()
674 rate_idx = rate->idx; in mt7615_mac_tx_rate_val()
675 nss = 1 + (rate->idx >> 3); in mt7615_mac_tx_rate_val()
677 if (rate->flags & IEEE80211_TX_RC_GREEN_FIELD) in mt7615_mac_tx_rate_val()
679 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in mt7615_mac_tx_rate_val()
683 int band = mphy->chandef.chan->band; in mt7615_mac_tx_rate_val()
687 r = &mphy->hw->wiphy->bands[band]->bitrates[rate->idx]; in mt7615_mac_tx_rate_val()
688 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in mt7615_mac_tx_rate_val()
689 val = r->hw_value_short; in mt7615_mac_tx_rate_val()
691 val = r->hw_value; in mt7615_mac_tx_rate_val()
704 FIELD_PREP(MT_TX_RATE_NSS, nss - 1)); in mt7615_mac_tx_rate_val()
715 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt7615_mac_write_txwi()
718 struct ieee80211_tx_rate *rate = &info->control.rates[0]; in mt7615_mac_write_txwi()
719 u8 phy_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2; in mt7615_mac_write_txwi()
720 bool multicast = is_multicast_ether_addr(hdr->addr1); in mt7615_mac_write_txwi()
721 struct ieee80211_vif *vif = info->control.vif; in mt7615_mac_write_txwi()
722 bool is_mmio = mt76_is_mmio(&dev->mt76); in mt7615_mac_write_txwi()
724 struct mt76_phy *mphy = &dev->mphy; in mt7615_mac_write_txwi()
725 __le16 fc = hdr->frame_control; in mt7615_mac_write_txwi()
730 struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; in mt7615_mac_write_txwi()
732 omac_idx = mvif->omac_idx; in mt7615_mac_write_txwi()
733 wmm_idx = mvif->wmm_idx; in mt7615_mac_write_txwi()
737 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; in mt7615_mac_write_txwi()
739 tx_count = msta->rate_count; in mt7615_mac_write_txwi()
742 if (phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_mac_write_txwi()
743 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_write_txwi()
760 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + sz_txd) | in mt7615_mac_write_txwi()
766 FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) | in mt7615_mac_write_txwi()
771 skb->priority & IEEE80211_QOS_CTL_TID_MASK) | in mt7615_mac_write_txwi()
781 key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { in mt7615_mac_write_txwi()
792 if (!(info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7615_mac_write_txwi()
798 if (rate->idx >= 0 && rate->count && in mt7615_mac_write_txwi()
799 !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) { in mt7615_mac_write_txwi()
800 bool stbc = info->flags & IEEE80211_TX_CTL_STBC; in mt7615_mac_write_txwi()
812 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in mt7615_mac_write_txwi()
815 if (info->flags & IEEE80211_TX_CTL_LDPC) in mt7615_mac_write_txwi()
818 if (!(rate->flags & (IEEE80211_TX_RC_MCS | in mt7615_mac_write_txwi()
822 tx_count = rate->count; in mt7615_mac_write_txwi()
839 if (info->flags & IEEE80211_TX_CTL_INJECTED) { in mt7615_mac_write_txwi()
840 seqno = le16_to_cpu(hdr->seq_ctrl); in mt7615_mac_write_txwi()
842 if (ieee80211_is_back_req(hdr->frame_control)) { in mt7615_mac_write_txwi()
845 bar = (struct ieee80211_bar *)skb->data; in mt7615_mac_write_txwi()
846 seqno = le16_to_cpu(bar->start_seq_num); in mt7615_mac_write_txwi()
855 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mt7615_mac_write_txwi()
902 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
903 list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); in mt7615_mac_sta_poll()
904 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
912 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
913 list_del_init(&msta->wcid.poll_list); in mt7615_mac_sta_poll()
914 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7615_mac_sta_poll()
916 addr = mt7615_mac_wtbl_addr(dev, msta->wcid.idx) + 19 * 4; in mt7615_mac_sta_poll()
919 u32 tx_last = msta->airtime_ac[i]; in mt7615_mac_sta_poll()
920 u32 rx_last = msta->airtime_ac[i + 4]; in mt7615_mac_sta_poll()
922 msta->airtime_ac[i] = mt76_rr(dev, addr); in mt7615_mac_sta_poll()
923 msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); in mt7615_mac_sta_poll()
924 tx_time[i] = msta->airtime_ac[i] - tx_last; in mt7615_mac_sta_poll()
925 rx_time[i] = msta->airtime_ac[i + 4] - rx_last; in mt7615_mac_sta_poll()
932 mt7615_mac_wtbl_update(dev, msta->wcid.idx, in mt7615_mac_sta_poll()
934 memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac)); in mt7615_mac_sta_poll()
937 if (!msta->wcid.sta) in mt7615_mac_sta_poll()
960 struct ieee80211_tx_rate *rates, in mt7615_mac_update_rate_desc() argument
963 struct mt7615_dev *dev = phy->dev; in mt7615_mac_update_rate_desc()
964 struct mt76_phy *mphy = phy->mt76; in mt7615_mac_update_rate_desc()
967 int n_rates = sta->n_rates; in mt7615_mac_update_rate_desc()
972 rates[i] = rates[n_rates - 1]; in mt7615_mac_update_rate_desc()
974 rateset = !(sta->rate_set_tsf & BIT(0)); in mt7615_mac_update_rate_desc()
975 memcpy(sta->rateset[rateset].rates, rates, in mt7615_mac_update_rate_desc()
976 sizeof(sta->rateset[rateset].rates)); in mt7615_mac_update_rate_desc()
978 sta->rateset[rateset].probe_rate = *probe_rate; in mt7615_mac_update_rate_desc()
979 ref = &sta->rateset[rateset].probe_rate; in mt7615_mac_update_rate_desc()
981 sta->rateset[rateset].probe_rate.idx = -1; in mt7615_mac_update_rate_desc()
982 ref = &sta->rateset[rateset].rates[0]; in mt7615_mac_update_rate_desc()
985 rates = sta->rateset[rateset].rates; in mt7615_mac_update_rate_desc()
986 for (i = 0; i < ARRAY_SIZE(sta->rateset[rateset].rates); i++) { in mt7615_mac_update_rate_desc()
994 if ((ref->flags ^ rates[i].flags) & IEEE80211_TX_RC_SHORT_GI) in mt7615_mac_update_rate_desc()
995 rates[i].flags ^= IEEE80211_TX_RC_SHORT_GI; in mt7615_mac_update_rate_desc()
998 if (rates[i].idx != rates[j].idx) in mt7615_mac_update_rate_desc()
1000 if ((rates[i].flags ^ rates[j].flags) & in mt7615_mac_update_rate_desc()
1006 if (!rates[i].idx) in mt7615_mac_update_rate_desc()
1009 rates[i].idx--; in mt7615_mac_update_rate_desc()
1013 rd->val[0] = mt7615_mac_tx_rate_val(dev, mphy, &rates[0], stbc, &bw); in mt7615_mac_update_rate_desc()
1017 rd->probe_val = mt7615_mac_tx_rate_val(dev, mphy, probe_rate, in mt7615_mac_update_rate_desc()
1020 rd->bw_idx = 1; in mt7615_mac_update_rate_desc()
1024 rd->probe_val = rd->val[0]; in mt7615_mac_update_rate_desc()
1027 rd->val[1] = mt7615_mac_tx_rate_val(dev, mphy, &rates[1], stbc, &bw); in mt7615_mac_update_rate_desc()
1029 rd->bw_idx = 3; in mt7615_mac_update_rate_desc()
1033 rd->val[2] = mt7615_mac_tx_rate_val(dev, mphy, &rates[2], stbc, &bw); in mt7615_mac_update_rate_desc()
1035 rd->bw_idx = 5; in mt7615_mac_update_rate_desc()
1039 rd->val[3] = mt7615_mac_tx_rate_val(dev, mphy, &rates[3], stbc, &bw); in mt7615_mac_update_rate_desc()
1041 rd->bw_idx = 7; in mt7615_mac_update_rate_desc()
1043 rd->rateset = rateset; in mt7615_mac_update_rate_desc()
1044 rd->bw = bw; in mt7615_mac_update_rate_desc()
1050 struct ieee80211_tx_rate *rates) in mt7615_mac_queue_rate_update() argument
1052 struct mt7615_dev *dev = phy->dev; in mt7615_mac_queue_rate_update()
1055 if (work_pending(&dev->rate_work)) in mt7615_mac_queue_rate_update()
1056 return -EBUSY; in mt7615_mac_queue_rate_update()
1060 return -ENOMEM; in mt7615_mac_queue_rate_update()
1062 wrd->sta = sta; in mt7615_mac_queue_rate_update()
1063 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates, in mt7615_mac_queue_rate_update()
1064 &wrd->rate); in mt7615_mac_queue_rate_update()
1065 list_add_tail(&wrd->node, &dev->wrd_head); in mt7615_mac_queue_rate_update()
1066 queue_work(dev->mt76.wq, &dev->rate_work); in mt7615_mac_queue_rate_update()
1088 val |= val2 << (32 - offset); in mt7615_mac_get_sta_tid_sn()
1096 struct ieee80211_tx_rate *rates) in mt7615_mac_set_rates() argument
1098 int wcid = sta->wcid.idx, n_rates = sta->n_rates; in mt7615_mac_set_rates()
1099 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_rates()
1102 u16 idx = sta->vif->mt76.omac_idx; in mt7615_mac_set_rates()
1104 if (!mt76_is_mmio(&dev->mt76)) { in mt7615_mac_set_rates()
1105 mt7615_mac_queue_rate_update(phy, sta, probe_rate, rates); in mt7615_mac_set_rates()
1113 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates, &rd); in mt7615_mac_set_rates()
1127 rd.bw_idx ? rd.bw_idx - 1 : 7); in mt7615_mac_set_rates()
1158 sta->rate_set_tsf = mt76_rr(dev, MT_LPON_UTTR0) & ~BIT(0); in mt7615_mac_set_rates()
1159 sta->rate_set_tsf |= rd.rateset; in mt7615_mac_set_rates()
1161 if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET)) in mt7615_mac_set_rates()
1164 sta->rate_count = 2 * MT7615_RATE_RETRY * n_rates; in mt7615_mac_set_rates()
1165 sta->wcid.tx_info |= MT_WCID_TX_INFO_SET; in mt7615_mac_set_rates()
1166 sta->rate_probe = !!probe_rate; in mt7615_mac_set_rates()
1173 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; in mt7615_mac_enable_rtscts()
1176 addr = mt7615_mac_wtbl_addr(dev, mvif->sta.wcid.idx) + 3 * 4; in mt7615_mac_enable_rtscts()
1190 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx) + 30 * 4; in mt7615_mac_wtbl_update_key()
1193 if (key->keylen > sizeof(data)) in mt7615_mac_wtbl_update_key()
1194 return -EINVAL; in mt7615_mac_wtbl_update_key()
1199 memcpy(data, key->key, 16); in mt7615_mac_wtbl_update_key()
1200 memcpy(data + 16, key->key + 24, 8); in mt7615_mac_wtbl_update_key()
1201 memcpy(data + 24, key->key + 16, 8); in mt7615_mac_wtbl_update_key()
1204 memcpy(data, key->key, key->keylen); in mt7615_mac_wtbl_update_key()
1206 memcpy(data, key->key, 16); in mt7615_mac_wtbl_update_key()
1208 memcpy(data + 16, key->key, 16); in mt7615_mac_wtbl_update_key()
1221 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx), w0, w1; in mt7615_mac_wtbl_update_pk()
1224 return -ETIMEDOUT; in mt7615_mac_wtbl_update_pk()
1246 if (!mt7615_mac_wtbl_update(dev, wcid->idx, in mt7615_mac_wtbl_update_pk()
1248 return -ETIMEDOUT; in mt7615_mac_wtbl_update_pk()
1257 u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx); in mt7615_mac_wtbl_update_cipher()
1272 u16 cipher_mask = wcid->cipher; in __mt7615_mac_wtbl_set_key()
1275 cipher = mt7615_mac_get_cipher(key->cipher); in __mt7615_mac_wtbl_set_key()
1277 return -EOPNOTSUPP; in __mt7615_mac_wtbl_set_key()
1286 key->keyidx); in __mt7615_mac_wtbl_set_key()
1290 wcid->cipher = cipher_mask; in __mt7615_mac_wtbl_set_key()
1301 spin_lock_bh(&dev->mt76.lock); in mt7615_mac_wtbl_set_key()
1303 spin_unlock_bh(&dev->mt76.lock); in mt7615_mac_wtbl_set_key()
1317 bool ampdu, cck = false; in mt7615_fill_txs() local
1341 info->flags |= IEEE80211_TX_STAT_ACK; in mt7615_fill_txs()
1343 info->status.ampdu_len = 1; in mt7615_fill_txs()
1344 info->status.ampdu_ack_len = !!(info->flags & in mt7615_fill_txs()
1347 if (ampdu || (info->flags & IEEE80211_TX_CTL_AMPDU)) in mt7615_fill_txs()
1348 info->flags |= IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_CTL_AMPDU; in mt7615_fill_txs()
1350 first_idx = max_t(int, 0, last_idx - (count - 1) / MT7615_RATE_RETRY); in mt7615_fill_txs()
1353 info->status.rates[0].count = count; in mt7615_fill_txs()
1358 rate_set_tsf = READ_ONCE(sta->rate_set_tsf); in mt7615_fill_txs()
1359 rs_idx = !((u32)(le32_get_bits(txs_data[4], MT_TXS4_F0_TIMESTAMP) - in mt7615_fill_txs()
1362 rs = &sta->rateset[rs_idx]; in mt7615_fill_txs()
1364 if (!first_idx && rs->probe_rate.idx >= 0) { in mt7615_fill_txs()
1365 info->status.rates[0] = rs->probe_rate; in mt7615_fill_txs()
1367 spin_lock_bh(&dev->mt76.lock); in mt7615_fill_txs()
1368 if (sta->rate_probe) { in mt7615_fill_txs()
1369 struct mt7615_phy *phy = &dev->phy; in mt7615_fill_txs()
1371 if (sta->wcid.phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_fill_txs()
1372 phy = dev->mt76.phys[MT_BAND1]->priv; in mt7615_fill_txs()
1374 mt7615_mac_set_rates(phy, sta, NULL, sta->rates); in mt7615_fill_txs()
1376 spin_unlock_bh(&dev->mt76.lock); in mt7615_fill_txs()
1378 info->status.rates[0] = rs->rates[first_idx / 2]; in mt7615_fill_txs()
1380 info->status.rates[0].count = 0; in mt7615_fill_txs()
1386 cur_rate = &rs->rates[idx / 2]; in mt7615_fill_txs()
1388 count -= cur_count; in mt7615_fill_txs()
1390 if (idx && (cur_rate->idx != info->status.rates[i].idx || in mt7615_fill_txs()
1391 cur_rate->flags != info->status.rates[i].flags)) { in mt7615_fill_txs()
1393 if (i == ARRAY_SIZE(info->status.rates)) { in mt7615_fill_txs()
1394 i--; in mt7615_fill_txs()
1398 info->status.rates[i] = *cur_rate; in mt7615_fill_txs()
1399 info->status.rates[i].count = 0; in mt7615_fill_txs()
1402 info->status.rates[i].count += cur_count; in mt7615_fill_txs()
1406 final_rate_flags = info->status.rates[i].flags; in mt7615_fill_txs()
1410 cck = true; in mt7615_fill_txs()
1413 mphy = &dev->mphy; in mt7615_fill_txs()
1414 if (sta->wcid.phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_fill_txs()
1415 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_fill_txs()
1417 if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) in mt7615_fill_txs()
1418 sband = &mphy->sband_5g.sband; in mt7615_fill_txs()
1420 sband = &mphy->sband_2g.sband; in mt7615_fill_txs()
1422 final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, in mt7615_fill_txs()
1423 cck); in mt7615_fill_txs()
1437 final_nss--; in mt7615_fill_txs()
1446 info->status.rates[i].idx = final_rate; in mt7615_fill_txs()
1447 info->status.rates[i].flags = final_rate_flags; in mt7615_fill_txs()
1456 struct mt76_dev *mdev = &dev->mt76; in mt7615_mac_add_txs_skb()
1463 trace_mac_txdone(mdev, sta->wcid.idx, pid); in mt7615_mac_add_txs_skb()
1466 skb = mt76_tx_status_skb_get(mdev, &sta->wcid, pid, &list); in mt7615_mac_add_txs_skb()
1471 info->status.rates[0].count = 0; in mt7615_mac_add_txs_skb()
1472 info->status.rates[0].idx = -1; in mt7615_mac_add_txs_skb()
1488 struct mt76_phy *mphy = &dev->mt76.phy; in mt7615_mac_add_txs()
1510 mt76_wcid_add_poll(&dev->mt76, &msta->wcid); in mt7615_mac_add_txs()
1518 if (wcid->phy_idx && dev->mt76.phys[MT_BAND1]) in mt7615_mac_add_txs()
1519 mphy = dev->mt76.phys[MT_BAND1]; in mt7615_mac_add_txs()
1522 spin_lock_bh(&dev->mt76.rx_lock); in mt7615_mac_add_txs()
1523 ieee80211_tx_status_noskb(mphy->hw, sta, &info); in mt7615_mac_add_txs()
1524 spin_unlock_bh(&dev->mt76.rx_lock); in mt7615_mac_add_txs()
1534 struct mt76_dev *mdev = &dev->mt76; in mt7615_txwi_free()
1540 if (!txwi->skb) in mt7615_txwi_free()
1546 mt76_tx_complete_skb(mdev, wcid, txwi->skb); in mt7615_txwi_free()
1549 txwi->skb = NULL; in mt7615_txwi_free()
1556 struct mt76_dev *mdev = &dev->mt76; in mt7615_mac_tx_free_token()
1574 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false); in mt7615_mac_tx_free()
1575 if (is_mt7615(&dev->mt76)) { in mt7615_mac_tx_free()
1576 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false); in mt7615_mac_tx_free()
1579 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[i], false); in mt7615_mac_tx_free()
1582 count = le16_get_bits(free->ctrl, MT_TX_FREE_MSDU_ID_CNT); in mt7615_mac_tx_free()
1583 if (is_mt7615(&dev->mt76)) { in mt7615_mac_tx_free()
1605 mt76_worker_schedule(&dev->mt76.tx_worker); in mt7615_mac_tx_free()
1635 __le32 *rxd = (__le32 *)skb->data; in mt7615_queue_rx_skb()
1636 __le32 *end = (__le32 *)&skb->data[skb->len]; in mt7615_queue_rx_skb()
1652 mt7615_mac_tx_free(dev, skb->data, skb->len); in mt7615_queue_rx_skb()
1661 mt76_rx(&dev->mt76, q, skb); in mt7615_queue_rx_skb()
1675 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_sensitivity()
1676 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_sensitivity()
1678 if (is_mt7663(&dev->mt76)) { in mt7615_mac_set_sensitivity()
1705 /* cck */ in mt7615_mac_set_default_sensitivity()
1708 phy->ofdm_sensitivity = -98; in mt7615_mac_set_default_sensitivity()
1709 phy->cck_sensitivity = -110; in mt7615_mac_set_default_sensitivity()
1710 phy->last_cca_adj = jiffies; in mt7615_mac_set_default_sensitivity()
1715 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_scs()
1716 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_scs()
1721 if (phy->scs_en == enable) in mt7615_mac_set_scs()
1724 if (is_mt7663(&dev->mt76)) { in mt7615_mac_set_scs()
1734 if (is_mt7622(&dev->mt76)) { in mt7615_mac_set_scs()
1743 phy->scs_en = enable; in mt7615_mac_set_scs()
1753 if (is_mt7663(&dev->mt76)) in mt7615_mac_enable_nf()
1769 struct mt7615_dev *dev = phy->dev; in mt7615_mac_cca_stats_reset()
1770 bool ext_phy = phy != &dev->phy; in mt7615_mac_cca_stats_reset()
1773 if (is_mt7663(&dev->mt76)) in mt7615_mac_cca_stats_reset()
1787 struct mt7615_dev *dev = phy->dev; in mt7615_mac_adjust_sensitivity()
1788 int false_cca = ofdm ? phy->false_cca_ofdm : phy->false_cca_cck; in mt7615_mac_adjust_sensitivity()
1789 bool ext_phy = phy != &dev->phy; in mt7615_mac_adjust_sensitivity()
1790 s16 def_th = ofdm ? -98 : -110; in mt7615_mac_adjust_sensitivity()
1795 sensitivity = ofdm ? &phy->ofdm_sensitivity : &phy->cck_sensitivity; in mt7615_mac_adjust_sensitivity()
1796 signal = mt76_get_min_avg_rssi(&dev->mt76, ext_phy); in mt7615_mac_adjust_sensitivity()
1802 signal = min(signal, -72); in mt7615_mac_adjust_sensitivity()
1808 if (*sensitivity == def_th && signal > -90) { in mt7615_mac_adjust_sensitivity()
1809 *sensitivity = -90; in mt7615_mac_adjust_sensitivity()
1818 if (*sensitivity - 2 >= def_th) { in mt7615_mac_adjust_sensitivity()
1819 *sensitivity -= 2; in mt7615_mac_adjust_sensitivity()
1833 phy->last_cca_adj = jiffies; in mt7615_mac_adjust_sensitivity()
1840 struct mt7615_dev *dev = phy->dev; in mt7615_mac_scs_check()
1841 struct mib_stats *mib = &phy->mib; in mt7615_mac_scs_check()
1844 bool ext_phy = phy != &dev->phy; in mt7615_mac_scs_check()
1846 if (!phy->scs_en) in mt7615_mac_scs_check()
1849 if (is_mt7663(&dev->mt76)) in mt7615_mac_scs_check()
1856 if (is_mt7663(&dev->mt76)) in mt7615_mac_scs_check()
1863 phy->false_cca_ofdm = pd_ofdm - mdrdy_ofdm; in mt7615_mac_scs_check()
1864 phy->false_cca_cck = pd_cck - mdrdy_cck; in mt7615_mac_scs_check()
1867 if (mib->rts_cnt + mib->rts_retries_cnt) in mt7615_mac_scs_check()
1868 rts_err_rate = MT_FRAC(mib->rts_retries_cnt, in mt7615_mac_scs_check()
1869 mib->rts_cnt + mib->rts_retries_cnt); in mt7615_mac_scs_check()
1871 /* cck */ in mt7615_mac_scs_check()
1876 if (time_after(jiffies, phy->last_cca_adj + 10 * HZ)) in mt7615_mac_scs_check()
1887 if (is_mt7663(&dev->mt76)) in mt7615_phy_get_nf()
1907 struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76); in mt7615_phy_update_channel()
1908 struct mt7615_phy *phy = mphy->priv; in mt7615_phy_update_channel()
1923 if (!phy->noise) in mt7615_phy_update_channel()
1924 phy->noise = nf << 4; in mt7615_phy_update_channel()
1926 phy->noise += nf - (phy->noise >> 4); in mt7615_phy_update_channel()
1928 state = mphy->chan_state; in mt7615_phy_update_channel()
1929 state->cc_busy += busy_time; in mt7615_phy_update_channel()
1930 state->cc_tx += tx_time; in mt7615_phy_update_channel()
1931 state->cc_rx += rx_time + obss_time; in mt7615_phy_update_channel()
1932 state->cc_bss_rx += rx_time; in mt7615_phy_update_channel()
1933 state->noise = -(phy->noise >> 4); in mt7615_phy_update_channel()
1938 struct mt76_dev *mdev = &dev->mt76; in mt7615_update_survey()
1939 struct mt76_phy *mphy_ext = mdev->phys[MT_BAND1]; in mt7615_update_survey()
1946 mt7615_phy_update_channel(&mdev->phy, 0); in mt7615_update_survey()
1952 mt76_update_survey_active_time(&mdev->phy, cur_time); in mt7615_update_survey()
1962 struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76); in mt7615_update_channel()
1964 if (mt76_connac_pm_wake(&dev->mphy, &dev->pm)) in mt7615_update_channel()
1968 mt76_connac_power_save_sched(&dev->mphy, &dev->pm); in mt7615_update_channel()
1975 struct mt7615_dev *dev = phy->dev; in mt7615_mac_update_mib_stats()
1976 struct mib_stats *mib = &phy->mib; in mt7615_mac_update_mib_stats()
1977 bool ext_phy = phy != &dev->phy; in mt7615_mac_update_mib_stats()
1981 mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(ext_phy), in mt7615_mac_update_mib_stats()
1989 mib->aggr_per = 1000 * (val - val2) / val; in mt7615_mac_update_mib_stats()
1994 mib->ba_miss_cnt += FIELD_GET(MT_MIB_BA_MISS_COUNT_MASK, val); in mt7615_mac_update_mib_stats()
1995 mib->ack_fail_cnt += FIELD_GET(MT_MIB_ACK_FAIL_COUNT_MASK, in mt7615_mac_update_mib_stats()
1999 mib->rts_cnt += FIELD_GET(MT_MIB_RTS_COUNT_MASK, val); in mt7615_mac_update_mib_stats()
2000 mib->rts_retries_cnt += FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK, in mt7615_mac_update_mib_stats()
2004 phy->mt76->aggr_stats[aggr++] += val & 0xffff; in mt7615_mac_update_mib_stats()
2005 phy->mt76->aggr_stats[aggr++] += val >> 16; in mt7615_mac_update_mib_stats()
2016 mphy = dev->phy.mt76; in mt7615_pm_wake_work()
2019 struct mt76_dev *mdev = &dev->mt76; in mt7615_pm_wake_work()
2023 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); in mt7615_pm_wake_work()
2024 mt76_worker_schedule(&mdev->sdio.txrx_worker); in mt7615_pm_wake_work()
2028 napi_schedule(&mdev->napi[i]); in mt7615_pm_wake_work()
2030 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); in mt7615_pm_wake_work()
2031 mt76_queue_tx_cleanup(dev, mdev->q_mcu[MT_MCUQ_WM], in mt7615_pm_wake_work()
2035 if (test_bit(MT76_STATE_RUNNING, &mphy->state)) { in mt7615_pm_wake_work()
2039 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, in mt7615_pm_wake_work()
2044 ieee80211_wake_queues(mphy->hw); in mt7615_pm_wake_work()
2045 wake_up(&dev->pm.wait); in mt7615_pm_wake_work()
2056 delta = dev->pm.idle_timeout; in mt7615_pm_power_save_work()
2057 if (test_bit(MT76_HW_SCANNING, &dev->mphy.state) || in mt7615_pm_power_save_work()
2058 test_bit(MT76_HW_SCHED_SCANNING, &dev->mphy.state)) in mt7615_pm_power_save_work()
2061 if (mutex_is_locked(&dev->mt76.mutex)) in mt7615_pm_power_save_work()
2069 if (time_is_after_jiffies(dev->pm.last_activity + delta)) { in mt7615_pm_power_save_work()
2070 delta = dev->pm.last_activity + delta - jiffies; in mt7615_pm_power_save_work()
2077 queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta); in mt7615_pm_power_save_work()
2088 phy = mphy->priv; in mt7615_mac_work()
2090 mt7615_mutex_acquire(phy->dev); in mt7615_mac_work()
2092 mt7615_update_survey(phy->dev); in mt7615_mac_work()
2093 if (++mphy->mac_work_count == 5) { in mt7615_mac_work()
2094 mphy->mac_work_count = 0; in mt7615_mac_work()
2100 mt7615_mutex_release(phy->dev); in mt7615_mac_work()
2102 mt76_tx_status_check(mphy->dev, false); in mt7615_mac_work()
2104 timeout = mt7615_get_macwork_timeout(phy->dev); in mt7615_mac_work()
2105 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, timeout); in mt7615_mac_work()
2113 spin_lock_bh(&dev->mt76.token_lock); in mt7615_tx_token_put()
2114 idr_for_each_entry(&dev->mt76.token, txwi, id) in mt7615_tx_token_put()
2116 spin_unlock_bh(&dev->mt76.token_lock); in mt7615_tx_token_put()
2117 idr_destroy(&dev->mt76.token); in mt7615_tx_token_put()
2123 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_stop_radar_detector()
2125 if (phy->rdd_state & BIT(0)) in mt7615_dfs_stop_radar_detector()
2126 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 0, in mt7615_dfs_stop_radar_detector()
2128 if (phy->rdd_state & BIT(1)) in mt7615_dfs_stop_radar_detector()
2129 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 1, in mt7615_dfs_stop_radar_detector()
2137 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_START, chain, in mt7615_dfs_start_rdd()
2142 return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_DET_MODE, chain, in mt7615_dfs_start_rdd()
2148 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7615_dfs_start_radar_detector()
2149 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_start_radar_detector()
2150 bool ext_phy = phy != &dev->phy; in mt7615_dfs_start_radar_detector()
2154 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_START, ext_phy, in mt7615_dfs_start_radar_detector()
2163 phy->rdd_state |= BIT(ext_phy); in mt7615_dfs_start_radar_detector()
2165 if (chandef->width == NL80211_CHAN_WIDTH_160 || in mt7615_dfs_start_radar_detector()
2166 chandef->width == NL80211_CHAN_WIDTH_80P80) { in mt7615_dfs_start_radar_detector()
2171 phy->rdd_state |= BIT(1); in mt7615_dfs_start_radar_detector()
2181 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_init_radar_specs()
2184 switch (dev->mt76.region) { in mt7615_dfs_init_radar_specs()
2196 return -EINVAL; in mt7615_dfs_init_radar_specs()
2199 /* avoid FCC radar detection in non-FCC region */ in mt7615_dfs_init_radar_specs()
2204 for (i = 0; i < ARRAY_SIZE(radar_specs->radar_pattern); i++) { in mt7615_dfs_init_radar_specs()
2206 &radar_specs->radar_pattern[i]); in mt7615_dfs_init_radar_specs()
2211 return mt7615_mcu_set_pulse_th(dev, &radar_specs->pulse_th); in mt7615_dfs_init_radar_specs()
2216 struct cfg80211_chan_def *chandef = &phy->mt76->chandef; in mt7615_dfs_init_radar_detector()
2217 struct mt7615_dev *dev = phy->dev; in mt7615_dfs_init_radar_detector()
2218 bool ext_phy = phy != &dev->phy; in mt7615_dfs_init_radar_detector()
2222 if (is_mt7663(&dev->mt76)) in mt7615_dfs_init_radar_detector()
2225 prev_state = phy->mt76->dfs_state; in mt7615_dfs_init_radar_detector()
2226 dfs_state = mt76_phy_dfs_state(phy->mt76); in mt7615_dfs_init_radar_detector()
2227 if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) && in mt7615_dfs_init_radar_detector()
2246 phy->mt76->dfs_state = MT_DFS_STATE_CAC; in mt7615_dfs_init_radar_detector()
2252 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_END, in mt7615_dfs_init_radar_detector()
2255 phy->mt76->dfs_state = MT_DFS_STATE_UNKNOWN; in mt7615_dfs_init_radar_detector()
2259 phy->mt76->dfs_state = MT_DFS_STATE_ACTIVE; in mt7615_dfs_init_radar_detector()
2263 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_NORMAL_START, ext_phy, in mt7615_dfs_init_radar_detector()
2269 phy->mt76->dfs_state = MT_DFS_STATE_DISABLED; in mt7615_dfs_init_radar_detector()
2278 struct mt7615_dev *dev = phy->dev; in mt7615_mac_set_beacon_filter()
2279 bool ext_phy = phy != &dev->phy; in mt7615_mac_set_beacon_filter()
2283 return -EOPNOTSUPP; in mt7615_mac_set_beacon_filter()
2285 switch (vif->type) { in mt7615_mac_set_beacon_filter()
2292 phy->n_beacon_vif++; in mt7615_mac_set_beacon_filter()
2294 phy->n_beacon_vif--; in mt7615_mac_set_beacon_filter()
2300 err = mt7615_mcu_set_bss_pm(dev, vif, !phy->n_beacon_vif); in mt7615_mac_set_beacon_filter()
2304 if (phy->n_beacon_vif) { in mt7615_mac_set_beacon_filter()
2305 vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; in mt7615_mac_set_beacon_filter()
2309 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; in mt7615_mac_set_beacon_filter()
2325 if (time_is_after_jiffies(dev->coredump.last_activity + in mt7615_coredump_work()
2327 queue_delayed_work(dev->mt76.wq, &dev->coredump.work, in mt7615_coredump_work()
2338 spin_lock_bh(&dev->mt76.lock); in mt7615_coredump_work()
2339 skb = __skb_dequeue(&dev->coredump.msg_list); in mt7615_coredump_work()
2340 spin_unlock_bh(&dev->mt76.lock); in mt7615_coredump_work()
2346 if (!dump || data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) { in mt7615_coredump_work()
2351 memcpy(data, skb->data, skb->len); in mt7615_coredump_work()
2352 data += skb->len; in mt7615_coredump_work()
2358 dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, in mt7615_coredump_work()